@jsdev_ninja/core 0.13.26 → 0.13.27

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 (110) hide show
  1. package/lib/entities/Order.ts +1 -0
  2. package/lib/entities/Store.ts +1 -0
  3. package/package.json +2 -2
  4. package/dist/core.cjs.js +0 -2
  5. package/dist/core.cjs.js.map +0 -1
  6. package/dist/core.es.js +0 -3610
  7. package/dist/core.es.js.map +0 -1
  8. package/dist/core.umd.js +0 -2
  9. package/dist/core.umd.js.map +0 -1
  10. package/dist/lib/entities/Address.d.ts +0 -28
  11. package/dist/lib/entities/Address.d.ts.map +0 -1
  12. package/dist/lib/entities/Address.js +0 -10
  13. package/dist/lib/entities/Atoms.d.ts +0 -16
  14. package/dist/lib/entities/Atoms.d.ts.map +0 -1
  15. package/dist/lib/entities/Atoms.js +0 -7
  16. package/dist/lib/entities/Cart.d.ts +0 -1278
  17. package/dist/lib/entities/Cart.d.ts.map +0 -1
  18. package/dist/lib/entities/Cart.js +0 -18
  19. package/dist/lib/entities/Category.d.ts +0 -103
  20. package/dist/lib/entities/Category.d.ts.map +0 -1
  21. package/dist/lib/entities/Category.js +0 -20
  22. package/dist/lib/entities/Company.d.ts +0 -16
  23. package/dist/lib/entities/Company.d.ts.map +0 -1
  24. package/dist/lib/entities/Company.js +0 -6
  25. package/dist/lib/entities/DeliveryNote.d.ts +0 -248
  26. package/dist/lib/entities/DeliveryNote.d.ts.map +0 -1
  27. package/dist/lib/entities/DeliveryNote.js +0 -61
  28. package/dist/lib/entities/Discount/__tests__/engine.test.d.ts +0 -2
  29. package/dist/lib/entities/Discount/__tests__/engine.test.d.ts.map +0 -1
  30. package/dist/lib/entities/Discount/__tests__/engine.test.js +0 -298
  31. package/dist/lib/entities/Discount/__tests__/factory.test.d.ts +0 -2
  32. package/dist/lib/entities/Discount/__tests__/factory.test.d.ts.map +0 -1
  33. package/dist/lib/entities/Discount/__tests__/factory.test.js +0 -75
  34. package/dist/lib/entities/Discount/__tests__/integration.test.d.ts +0 -2
  35. package/dist/lib/entities/Discount/__tests__/integration.test.d.ts.map +0 -1
  36. package/dist/lib/entities/Discount/__tests__/integration.test.js +0 -115
  37. package/dist/lib/entities/Discount/__tests__/simple.test.d.ts +0 -2
  38. package/dist/lib/entities/Discount/__tests__/simple.test.d.ts.map +0 -1
  39. package/dist/lib/entities/Discount/__tests__/simple.test.js +0 -186
  40. package/dist/lib/entities/Discount/__tests__/utils.test.d.ts +0 -2
  41. package/dist/lib/entities/Discount/__tests__/utils.test.d.ts.map +0 -1
  42. package/dist/lib/entities/Discount/__tests__/utils.test.js +0 -55
  43. package/dist/lib/entities/Discount/engine.d.ts +0 -29
  44. package/dist/lib/entities/Discount/engine.d.ts.map +0 -1
  45. package/dist/lib/entities/Discount/engine.js +0 -85
  46. package/dist/lib/entities/Discount/factory.d.ts +0 -10
  47. package/dist/lib/entities/Discount/factory.d.ts.map +0 -1
  48. package/dist/lib/entities/Discount/factory.js +0 -18
  49. package/dist/lib/entities/Discount/index.d.ts +0 -9
  50. package/dist/lib/entities/Discount/index.d.ts.map +0 -1
  51. package/dist/lib/entities/Discount/index.js +0 -8
  52. package/dist/lib/entities/Discount/strategies/BundleStrategy.d.ts +0 -12
  53. package/dist/lib/entities/Discount/strategies/BundleStrategy.d.ts.map +0 -1
  54. package/dist/lib/entities/Discount/strategies/BundleStrategy.js +0 -78
  55. package/dist/lib/entities/Discount/strategies/__tests__/BundleStrategy.test.d.ts +0 -2
  56. package/dist/lib/entities/Discount/strategies/__tests__/BundleStrategy.test.d.ts.map +0 -1
  57. package/dist/lib/entities/Discount/strategies/__tests__/BundleStrategy.test.js +0 -265
  58. package/dist/lib/entities/Discount/strategy.d.ts +0 -6
  59. package/dist/lib/entities/Discount/strategy.d.ts.map +0 -1
  60. package/dist/lib/entities/Discount/strategy.js +0 -1
  61. package/dist/lib/entities/Discount/types.d.ts +0 -148
  62. package/dist/lib/entities/Discount/types.d.ts.map +0 -1
  63. package/dist/lib/entities/Discount/types.js +0 -29
  64. package/dist/lib/entities/Discount/utils.d.ts +0 -29
  65. package/dist/lib/entities/Discount/utils.d.ts.map +0 -1
  66. package/dist/lib/entities/Discount/utils.js +0 -39
  67. package/dist/lib/entities/FavoriteProduct.d.ts +0 -25
  68. package/dist/lib/entities/FavoriteProduct.d.ts.map +0 -1
  69. package/dist/lib/entities/FavoriteProduct.js +0 -9
  70. package/dist/lib/entities/Invoice.d.ts +0 -210
  71. package/dist/lib/entities/Invoice.d.ts.map +0 -1
  72. package/dist/lib/entities/Invoice.js +0 -49
  73. package/dist/lib/entities/Locale.d.ts +0 -22
  74. package/dist/lib/entities/Locale.d.ts.map +0 -1
  75. package/dist/lib/entities/Locale.js +0 -6
  76. package/dist/lib/entities/Order.d.ts +0 -1803
  77. package/dist/lib/entities/Order.d.ts.map +0 -1
  78. package/dist/lib/entities/Order.js +0 -61
  79. package/dist/lib/entities/Organization.d.ts +0 -100
  80. package/dist/lib/entities/Organization.d.ts.map +0 -1
  81. package/dist/lib/entities/Organization.js +0 -16
  82. package/dist/lib/entities/Product.d.ts +0 -694
  83. package/dist/lib/entities/Product.d.ts.map +0 -1
  84. package/dist/lib/entities/Product.js +0 -61
  85. package/dist/lib/entities/Profile.d.ts +0 -98
  86. package/dist/lib/entities/Profile.d.ts.map +0 -1
  87. package/dist/lib/entities/Profile.js +0 -50
  88. package/dist/lib/entities/Store.d.ts +0 -47
  89. package/dist/lib/entities/Store.d.ts.map +0 -1
  90. package/dist/lib/entities/Store.js +0 -17
  91. package/dist/lib/entities/index.d.ts +0 -15
  92. package/dist/lib/entities/index.d.ts.map +0 -1
  93. package/dist/lib/entities/index.js +0 -14
  94. package/dist/lib/firebase-api/app.d.ts +0 -2
  95. package/dist/lib/firebase-api/app.d.ts.map +0 -1
  96. package/dist/lib/firebase-api/app.js +0 -16
  97. package/dist/lib/firebase-api/index.d.ts +0 -75
  98. package/dist/lib/firebase-api/index.d.ts.map +0 -1
  99. package/dist/lib/firebase-api/index.js +0 -33
  100. package/dist/lib/index.d.ts +0 -4
  101. package/dist/lib/index.d.ts.map +0 -1
  102. package/dist/lib/index.js +0 -3
  103. package/dist/lib/utils/index.d.ts +0 -109
  104. package/dist/lib/utils/index.d.ts.map +0 -1
  105. package/dist/lib/utils/index.js +0 -95
  106. package/dist/tsconfig.app.tsbuildinfo +0 -1
  107. package/dist/tsconfig.node.tsbuildinfo +0 -1
  108. package/dist/vite.config.d.ts +0 -3
  109. package/dist/vite.config.d.ts.map +0 -1
  110. package/dist/vite.config.js +0 -25
package/dist/core.es.js DELETED
@@ -1,3610 +0,0 @@
1
- var at = Object.defineProperty;
2
- var it = (n, e, t) => e in n ? at(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var Re = (n, e, t) => it(n, typeof e != "symbol" ? e + "" : e, t);
4
- var x;
5
- (function(n) {
6
- n.assertEqual = (s) => s;
7
- function e(s) {
8
- }
9
- n.assertIs = e;
10
- function t(s) {
11
- throw new Error();
12
- }
13
- n.assertNever = t, n.arrayToEnum = (s) => {
14
- const a = {};
15
- for (const o of s)
16
- a[o] = o;
17
- return a;
18
- }, n.getValidEnumValues = (s) => {
19
- const a = n.objectKeys(s).filter((c) => typeof s[s[c]] != "number"), o = {};
20
- for (const c of a)
21
- o[c] = s[c];
22
- return n.objectValues(o);
23
- }, n.objectValues = (s) => n.objectKeys(s).map(function(a) {
24
- return s[a];
25
- }), n.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
26
- const a = [];
27
- for (const o in s)
28
- Object.prototype.hasOwnProperty.call(s, o) && a.push(o);
29
- return a;
30
- }, n.find = (s, a) => {
31
- for (const o of s)
32
- if (a(o))
33
- return o;
34
- }, n.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
35
- function r(s, a = " | ") {
36
- return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
37
- }
38
- n.joinValues = r, n.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
39
- })(x || (x = {}));
40
- var Ze;
41
- (function(n) {
42
- n.mergeShapes = (e, t) => ({
43
- ...e,
44
- ...t
45
- // second overwrites first
46
- });
47
- })(Ze || (Ze = {}));
48
- const f = x.arrayToEnum([
49
- "string",
50
- "nan",
51
- "number",
52
- "integer",
53
- "float",
54
- "boolean",
55
- "date",
56
- "bigint",
57
- "symbol",
58
- "function",
59
- "undefined",
60
- "null",
61
- "array",
62
- "object",
63
- "unknown",
64
- "promise",
65
- "void",
66
- "never",
67
- "map",
68
- "set"
69
- ]), R = (n) => {
70
- switch (typeof n) {
71
- case "undefined":
72
- return f.undefined;
73
- case "string":
74
- return f.string;
75
- case "number":
76
- return isNaN(n) ? f.nan : f.number;
77
- case "boolean":
78
- return f.boolean;
79
- case "function":
80
- return f.function;
81
- case "bigint":
82
- return f.bigint;
83
- case "symbol":
84
- return f.symbol;
85
- case "object":
86
- return Array.isArray(n) ? f.array : n === null ? f.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? f.promise : typeof Map < "u" && n instanceof Map ? f.map : typeof Set < "u" && n instanceof Set ? f.set : typeof Date < "u" && n instanceof Date ? f.date : f.object;
87
- default:
88
- return f.unknown;
89
- }
90
- }, u = x.arrayToEnum([
91
- "invalid_type",
92
- "invalid_literal",
93
- "custom",
94
- "invalid_union",
95
- "invalid_union_discriminator",
96
- "invalid_enum_value",
97
- "unrecognized_keys",
98
- "invalid_arguments",
99
- "invalid_return_type",
100
- "invalid_date",
101
- "invalid_string",
102
- "too_small",
103
- "too_big",
104
- "invalid_intersection_types",
105
- "not_multiple_of",
106
- "not_finite"
107
- ]), ot = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
108
- class S extends Error {
109
- get errors() {
110
- return this.issues;
111
- }
112
- constructor(e) {
113
- super(), this.issues = [], this.addIssue = (r) => {
114
- this.issues = [...this.issues, r];
115
- }, this.addIssues = (r = []) => {
116
- this.issues = [...this.issues, ...r];
117
- };
118
- const t = new.target.prototype;
119
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
120
- }
121
- format(e) {
122
- const t = e || function(a) {
123
- return a.message;
124
- }, r = { _errors: [] }, s = (a) => {
125
- for (const o of a.issues)
126
- if (o.code === "invalid_union")
127
- o.unionErrors.map(s);
128
- else if (o.code === "invalid_return_type")
129
- s(o.returnTypeError);
130
- else if (o.code === "invalid_arguments")
131
- s(o.argumentsError);
132
- else if (o.path.length === 0)
133
- r._errors.push(t(o));
134
- else {
135
- let c = r, l = 0;
136
- for (; l < o.path.length; ) {
137
- const d = o.path[l];
138
- l === o.path.length - 1 ? (c[d] = c[d] || { _errors: [] }, c[d]._errors.push(t(o))) : c[d] = c[d] || { _errors: [] }, c = c[d], l++;
139
- }
140
- }
141
- };
142
- return s(this), r;
143
- }
144
- static assert(e) {
145
- if (!(e instanceof S))
146
- throw new Error(`Not a ZodError: ${e}`);
147
- }
148
- toString() {
149
- return this.message;
150
- }
151
- get message() {
152
- return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
153
- }
154
- get isEmpty() {
155
- return this.issues.length === 0;
156
- }
157
- flatten(e = (t) => t.message) {
158
- const t = {}, r = [];
159
- for (const s of this.issues)
160
- s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : r.push(e(s));
161
- return { formErrors: r, fieldErrors: t };
162
- }
163
- get formErrors() {
164
- return this.flatten();
165
- }
166
- }
167
- S.create = (n) => new S(n);
168
- const X = (n, e) => {
169
- let t;
170
- switch (n.code) {
171
- case u.invalid_type:
172
- n.received === f.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
173
- break;
174
- case u.invalid_literal:
175
- t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
176
- break;
177
- case u.unrecognized_keys:
178
- t = `Unrecognized key(s) in object: ${x.joinValues(n.keys, ", ")}`;
179
- break;
180
- case u.invalid_union:
181
- t = "Invalid input";
182
- break;
183
- case u.invalid_union_discriminator:
184
- t = `Invalid discriminator value. Expected ${x.joinValues(n.options)}`;
185
- break;
186
- case u.invalid_enum_value:
187
- t = `Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;
188
- break;
189
- case u.invalid_arguments:
190
- t = "Invalid function arguments";
191
- break;
192
- case u.invalid_return_type:
193
- t = "Invalid function return type";
194
- break;
195
- case u.invalid_date:
196
- t = "Invalid date";
197
- break;
198
- case u.invalid_string:
199
- typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : x.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
200
- break;
201
- case u.too_small:
202
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
203
- break;
204
- case u.too_big:
205
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
206
- break;
207
- case u.custom:
208
- t = "Invalid input";
209
- break;
210
- case u.invalid_intersection_types:
211
- t = "Intersection results could not be merged";
212
- break;
213
- case u.not_multiple_of:
214
- t = `Number must be a multiple of ${n.multipleOf}`;
215
- break;
216
- case u.not_finite:
217
- t = "Number must be finite";
218
- break;
219
- default:
220
- t = e.defaultError, x.assertNever(n);
221
- }
222
- return { message: t };
223
- };
224
- let Fe = X;
225
- function ct(n) {
226
- Fe = n;
227
- }
228
- function ve() {
229
- return Fe;
230
- }
231
- const _e = (n) => {
232
- const { data: e, path: t, errorMaps: r, issueData: s } = n, a = [...t, ...s.path || []], o = {
233
- ...s,
234
- path: a
235
- };
236
- if (s.message !== void 0)
237
- return {
238
- ...s,
239
- path: a,
240
- message: s.message
241
- };
242
- let c = "";
243
- const l = r.filter((d) => !!d).slice().reverse();
244
- for (const d of l)
245
- c = d(o, { data: e, defaultError: c }).message;
246
- return {
247
- ...s,
248
- path: a,
249
- message: c
250
- };
251
- }, dt = [];
252
- function m(n, e) {
253
- const t = ve(), r = _e({
254
- issueData: e,
255
- data: n.data,
256
- path: n.path,
257
- errorMaps: [
258
- n.common.contextualErrorMap,
259
- // contextual error map is first priority
260
- n.schemaErrorMap,
261
- // then schema-bound map if available
262
- t,
263
- // then global override map
264
- t === X ? void 0 : X
265
- // then global default map
266
- ].filter((s) => !!s)
267
- });
268
- n.common.issues.push(r);
269
- }
270
- class T {
271
- constructor() {
272
- this.value = "valid";
273
- }
274
- dirty() {
275
- this.value === "valid" && (this.value = "dirty");
276
- }
277
- abort() {
278
- this.value !== "aborted" && (this.value = "aborted");
279
- }
280
- static mergeArray(e, t) {
281
- const r = [];
282
- for (const s of t) {
283
- if (s.status === "aborted")
284
- return y;
285
- s.status === "dirty" && e.dirty(), r.push(s.value);
286
- }
287
- return { status: e.value, value: r };
288
- }
289
- static async mergeObjectAsync(e, t) {
290
- const r = [];
291
- for (const s of t) {
292
- const a = await s.key, o = await s.value;
293
- r.push({
294
- key: a,
295
- value: o
296
- });
297
- }
298
- return T.mergeObjectSync(e, r);
299
- }
300
- static mergeObjectSync(e, t) {
301
- const r = {};
302
- for (const s of t) {
303
- const { key: a, value: o } = s;
304
- if (a.status === "aborted" || o.status === "aborted")
305
- return y;
306
- a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (r[a.value] = o.value);
307
- }
308
- return { status: e.value, value: r };
309
- }
310
- }
311
- const y = Object.freeze({
312
- status: "aborted"
313
- }), Y = (n) => ({ status: "dirty", value: n }), I = (n) => ({ status: "valid", value: n }), De = (n) => n.status === "aborted", je = (n) => n.status === "dirty", q = (n) => n.status === "valid", se = (n) => typeof Promise < "u" && n instanceof Promise;
314
- function be(n, e, t, r) {
315
- if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
316
- return e.get(n);
317
- }
318
- function ze(n, e, t, r, s) {
319
- if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
320
- return e.set(n, t), t;
321
- }
322
- var h;
323
- (function(n) {
324
- n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
325
- })(h || (h = {}));
326
- var te, ne;
327
- class O {
328
- constructor(e, t, r, s) {
329
- this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = s;
330
- }
331
- get path() {
332
- return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
333
- }
334
- }
335
- const Me = (n, e) => {
336
- if (q(e))
337
- return { success: !0, data: e.value };
338
- if (!n.common.issues.length)
339
- throw new Error("Validation failed but no issues detected.");
340
- return {
341
- success: !1,
342
- get error() {
343
- if (this._error)
344
- return this._error;
345
- const t = new S(n.common.issues);
346
- return this._error = t, this._error;
347
- }
348
- };
349
- };
350
- function v(n) {
351
- if (!n)
352
- return {};
353
- const { errorMap: e, invalid_type_error: t, required_error: r, description: s } = n;
354
- if (e && (t || r))
355
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
356
- return e ? { errorMap: e, description: s } : { errorMap: (o, c) => {
357
- var l, d;
358
- const { message: p } = n;
359
- return o.code === "invalid_enum_value" ? { message: p ?? c.defaultError } : typeof c.data > "u" ? { message: (l = p ?? r) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (d = p ?? t) !== null && d !== void 0 ? d : c.defaultError };
360
- }, description: s };
361
- }
362
- class _ {
363
- get description() {
364
- return this._def.description;
365
- }
366
- _getType(e) {
367
- return R(e.data);
368
- }
369
- _getOrReturnCtx(e, t) {
370
- return t || {
371
- common: e.parent.common,
372
- data: e.data,
373
- parsedType: R(e.data),
374
- schemaErrorMap: this._def.errorMap,
375
- path: e.path,
376
- parent: e.parent
377
- };
378
- }
379
- _processInputParams(e) {
380
- return {
381
- status: new T(),
382
- ctx: {
383
- common: e.parent.common,
384
- data: e.data,
385
- parsedType: R(e.data),
386
- schemaErrorMap: this._def.errorMap,
387
- path: e.path,
388
- parent: e.parent
389
- }
390
- };
391
- }
392
- _parseSync(e) {
393
- const t = this._parse(e);
394
- if (se(t))
395
- throw new Error("Synchronous parse encountered promise.");
396
- return t;
397
- }
398
- _parseAsync(e) {
399
- const t = this._parse(e);
400
- return Promise.resolve(t);
401
- }
402
- parse(e, t) {
403
- const r = this.safeParse(e, t);
404
- if (r.success)
405
- return r.data;
406
- throw r.error;
407
- }
408
- safeParse(e, t) {
409
- var r;
410
- const s = {
411
- common: {
412
- issues: [],
413
- async: (r = t == null ? void 0 : t.async) !== null && r !== void 0 ? r : !1,
414
- contextualErrorMap: t == null ? void 0 : t.errorMap
415
- },
416
- path: (t == null ? void 0 : t.path) || [],
417
- schemaErrorMap: this._def.errorMap,
418
- parent: null,
419
- data: e,
420
- parsedType: R(e)
421
- }, a = this._parseSync({ data: e, path: s.path, parent: s });
422
- return Me(s, a);
423
- }
424
- "~validate"(e) {
425
- var t, r;
426
- const s = {
427
- common: {
428
- issues: [],
429
- async: !!this["~standard"].async
430
- },
431
- path: [],
432
- schemaErrorMap: this._def.errorMap,
433
- parent: null,
434
- data: e,
435
- parsedType: R(e)
436
- };
437
- if (!this["~standard"].async)
438
- try {
439
- const a = this._parseSync({ data: e, path: [], parent: s });
440
- return q(a) ? {
441
- value: a.value
442
- } : {
443
- issues: s.common.issues
444
- };
445
- } catch (a) {
446
- !((r = (t = a == null ? void 0 : a.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || r === void 0) && r.includes("encountered") && (this["~standard"].async = !0), s.common = {
447
- issues: [],
448
- async: !0
449
- };
450
- }
451
- return this._parseAsync({ data: e, path: [], parent: s }).then((a) => q(a) ? {
452
- value: a.value
453
- } : {
454
- issues: s.common.issues
455
- });
456
- }
457
- async parseAsync(e, t) {
458
- const r = await this.safeParseAsync(e, t);
459
- if (r.success)
460
- return r.data;
461
- throw r.error;
462
- }
463
- async safeParseAsync(e, t) {
464
- const r = {
465
- common: {
466
- issues: [],
467
- contextualErrorMap: t == null ? void 0 : t.errorMap,
468
- async: !0
469
- },
470
- path: (t == null ? void 0 : t.path) || [],
471
- schemaErrorMap: this._def.errorMap,
472
- parent: null,
473
- data: e,
474
- parsedType: R(e)
475
- }, s = this._parse({ data: e, path: r.path, parent: r }), a = await (se(s) ? s : Promise.resolve(s));
476
- return Me(r, a);
477
- }
478
- refine(e, t) {
479
- const r = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
480
- return this._refinement((s, a) => {
481
- const o = e(s), c = () => a.addIssue({
482
- code: u.custom,
483
- ...r(s)
484
- });
485
- return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
486
- });
487
- }
488
- refinement(e, t) {
489
- return this._refinement((r, s) => e(r) ? !0 : (s.addIssue(typeof t == "function" ? t(r, s) : t), !1));
490
- }
491
- _refinement(e) {
492
- return new Z({
493
- schema: this,
494
- typeName: g.ZodEffects,
495
- effect: { type: "refinement", refinement: e }
496
- });
497
- }
498
- superRefine(e) {
499
- return this._refinement(e);
500
- }
501
- constructor(e) {
502
- this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
503
- version: 1,
504
- vendor: "zod",
505
- validate: (t) => this["~validate"](t)
506
- };
507
- }
508
- optional() {
509
- return j.create(this, this._def);
510
- }
511
- nullable() {
512
- return U.create(this, this._def);
513
- }
514
- nullish() {
515
- return this.nullable().optional();
516
- }
517
- array() {
518
- return C.create(this);
519
- }
520
- promise() {
521
- return G.create(this, this._def);
522
- }
523
- or(e) {
524
- return ce.create([this, e], this._def);
525
- }
526
- and(e) {
527
- return de.create(this, e, this._def);
528
- }
529
- transform(e) {
530
- return new Z({
531
- ...v(this._def),
532
- schema: this,
533
- typeName: g.ZodEffects,
534
- effect: { type: "transform", transform: e }
535
- });
536
- }
537
- default(e) {
538
- const t = typeof e == "function" ? e : () => e;
539
- return new pe({
540
- ...v(this._def),
541
- innerType: this,
542
- defaultValue: t,
543
- typeName: g.ZodDefault
544
- });
545
- }
546
- brand() {
547
- return new Ee({
548
- typeName: g.ZodBranded,
549
- type: this,
550
- ...v(this._def)
551
- });
552
- }
553
- catch(e) {
554
- const t = typeof e == "function" ? e : () => e;
555
- return new he({
556
- ...v(this._def),
557
- innerType: this,
558
- catchValue: t,
559
- typeName: g.ZodCatch
560
- });
561
- }
562
- describe(e) {
563
- const t = this.constructor;
564
- return new t({
565
- ...this._def,
566
- description: e
567
- });
568
- }
569
- pipe(e) {
570
- return ye.create(this, e);
571
- }
572
- readonly() {
573
- return ge.create(this);
574
- }
575
- isOptional() {
576
- return this.safeParse(void 0).success;
577
- }
578
- isNullable() {
579
- return this.safeParse(null).success;
580
- }
581
- }
582
- const ut = /^c[^\s-]{8,}$/i, lt = /^[0-9a-z]+$/, mt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ft = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, pt = /^[a-z0-9_-]{21}$/i, ht = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, gt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, yt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, vt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
583
- let Ne;
584
- const _t = /^(?:(?: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])$/, bt = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/, xt = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, kt = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, wt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Tt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ue = "((\\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])))", It = new RegExp(`^${Ue}$`);
585
- function Le(n) {
586
- let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
587
- return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
588
- }
589
- function At(n) {
590
- return new RegExp(`^${Le(n)}$`);
591
- }
592
- function qe(n) {
593
- let e = `${Ue}T${Le(n)}`;
594
- const t = [];
595
- return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
596
- }
597
- function St(n, e) {
598
- return !!((e === "v4" || !e) && _t.test(n) || (e === "v6" || !e) && xt.test(n));
599
- }
600
- function Nt(n, e) {
601
- if (!ht.test(n))
602
- return !1;
603
- try {
604
- const [t] = n.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(r));
605
- return !(typeof s != "object" || s === null || !s.typ || !s.alg || e && s.alg !== e);
606
- } catch {
607
- return !1;
608
- }
609
- }
610
- function Ct(n, e) {
611
- return !!((e === "v4" || !e) && bt.test(n) || (e === "v6" || !e) && kt.test(n));
612
- }
613
- class N extends _ {
614
- _parse(e) {
615
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
616
- const a = this._getOrReturnCtx(e);
617
- return m(a, {
618
- code: u.invalid_type,
619
- expected: f.string,
620
- received: a.parsedType
621
- }), y;
622
- }
623
- const r = new T();
624
- let s;
625
- for (const a of this._def.checks)
626
- if (a.kind === "min")
627
- e.data.length < a.value && (s = this._getOrReturnCtx(e, s), m(s, {
628
- code: u.too_small,
629
- minimum: a.value,
630
- type: "string",
631
- inclusive: !0,
632
- exact: !1,
633
- message: a.message
634
- }), r.dirty());
635
- else if (a.kind === "max")
636
- e.data.length > a.value && (s = this._getOrReturnCtx(e, s), m(s, {
637
- code: u.too_big,
638
- maximum: a.value,
639
- type: "string",
640
- inclusive: !0,
641
- exact: !1,
642
- message: a.message
643
- }), r.dirty());
644
- else if (a.kind === "length") {
645
- const o = e.data.length > a.value, c = e.data.length < a.value;
646
- (o || c) && (s = this._getOrReturnCtx(e, s), o ? m(s, {
647
- code: u.too_big,
648
- maximum: a.value,
649
- type: "string",
650
- inclusive: !0,
651
- exact: !0,
652
- message: a.message
653
- }) : c && m(s, {
654
- code: u.too_small,
655
- minimum: a.value,
656
- type: "string",
657
- inclusive: !0,
658
- exact: !0,
659
- message: a.message
660
- }), r.dirty());
661
- } else if (a.kind === "email")
662
- yt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
663
- validation: "email",
664
- code: u.invalid_string,
665
- message: a.message
666
- }), r.dirty());
667
- else if (a.kind === "emoji")
668
- Ne || (Ne = new RegExp(vt, "u")), Ne.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
669
- validation: "emoji",
670
- code: u.invalid_string,
671
- message: a.message
672
- }), r.dirty());
673
- else if (a.kind === "uuid")
674
- ft.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
675
- validation: "uuid",
676
- code: u.invalid_string,
677
- message: a.message
678
- }), r.dirty());
679
- else if (a.kind === "nanoid")
680
- pt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
681
- validation: "nanoid",
682
- code: u.invalid_string,
683
- message: a.message
684
- }), r.dirty());
685
- else if (a.kind === "cuid")
686
- ut.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
687
- validation: "cuid",
688
- code: u.invalid_string,
689
- message: a.message
690
- }), r.dirty());
691
- else if (a.kind === "cuid2")
692
- lt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
693
- validation: "cuid2",
694
- code: u.invalid_string,
695
- message: a.message
696
- }), r.dirty());
697
- else if (a.kind === "ulid")
698
- mt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
699
- validation: "ulid",
700
- code: u.invalid_string,
701
- message: a.message
702
- }), r.dirty());
703
- else if (a.kind === "url")
704
- try {
705
- new URL(e.data);
706
- } catch {
707
- s = this._getOrReturnCtx(e, s), m(s, {
708
- validation: "url",
709
- code: u.invalid_string,
710
- message: a.message
711
- }), r.dirty();
712
- }
713
- else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
714
- validation: "regex",
715
- code: u.invalid_string,
716
- message: a.message
717
- }), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), m(s, {
718
- code: u.invalid_string,
719
- validation: { includes: a.value, position: a.position },
720
- message: a.message
721
- }), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), m(s, {
722
- code: u.invalid_string,
723
- validation: { startsWith: a.value },
724
- message: a.message
725
- }), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), m(s, {
726
- code: u.invalid_string,
727
- validation: { endsWith: a.value },
728
- message: a.message
729
- }), r.dirty()) : a.kind === "datetime" ? qe(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
730
- code: u.invalid_string,
731
- validation: "datetime",
732
- message: a.message
733
- }), r.dirty()) : a.kind === "date" ? It.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
734
- code: u.invalid_string,
735
- validation: "date",
736
- message: a.message
737
- }), r.dirty()) : a.kind === "time" ? At(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
738
- code: u.invalid_string,
739
- validation: "time",
740
- message: a.message
741
- }), r.dirty()) : a.kind === "duration" ? gt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
742
- validation: "duration",
743
- code: u.invalid_string,
744
- message: a.message
745
- }), r.dirty()) : a.kind === "ip" ? St(e.data, a.version) || (s = this._getOrReturnCtx(e, s), m(s, {
746
- validation: "ip",
747
- code: u.invalid_string,
748
- message: a.message
749
- }), r.dirty()) : a.kind === "jwt" ? Nt(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), m(s, {
750
- validation: "jwt",
751
- code: u.invalid_string,
752
- message: a.message
753
- }), r.dirty()) : a.kind === "cidr" ? Ct(e.data, a.version) || (s = this._getOrReturnCtx(e, s), m(s, {
754
- validation: "cidr",
755
- code: u.invalid_string,
756
- message: a.message
757
- }), r.dirty()) : a.kind === "base64" ? wt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
758
- validation: "base64",
759
- code: u.invalid_string,
760
- message: a.message
761
- }), r.dirty()) : a.kind === "base64url" ? Tt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
762
- validation: "base64url",
763
- code: u.invalid_string,
764
- message: a.message
765
- }), r.dirty()) : x.assertNever(a);
766
- return { status: r.value, value: e.data };
767
- }
768
- _regex(e, t, r) {
769
- return this.refinement((s) => e.test(s), {
770
- validation: t,
771
- code: u.invalid_string,
772
- ...h.errToObj(r)
773
- });
774
- }
775
- _addCheck(e) {
776
- return new N({
777
- ...this._def,
778
- checks: [...this._def.checks, e]
779
- });
780
- }
781
- email(e) {
782
- return this._addCheck({ kind: "email", ...h.errToObj(e) });
783
- }
784
- url(e) {
785
- return this._addCheck({ kind: "url", ...h.errToObj(e) });
786
- }
787
- emoji(e) {
788
- return this._addCheck({ kind: "emoji", ...h.errToObj(e) });
789
- }
790
- uuid(e) {
791
- return this._addCheck({ kind: "uuid", ...h.errToObj(e) });
792
- }
793
- nanoid(e) {
794
- return this._addCheck({ kind: "nanoid", ...h.errToObj(e) });
795
- }
796
- cuid(e) {
797
- return this._addCheck({ kind: "cuid", ...h.errToObj(e) });
798
- }
799
- cuid2(e) {
800
- return this._addCheck({ kind: "cuid2", ...h.errToObj(e) });
801
- }
802
- ulid(e) {
803
- return this._addCheck({ kind: "ulid", ...h.errToObj(e) });
804
- }
805
- base64(e) {
806
- return this._addCheck({ kind: "base64", ...h.errToObj(e) });
807
- }
808
- base64url(e) {
809
- return this._addCheck({
810
- kind: "base64url",
811
- ...h.errToObj(e)
812
- });
813
- }
814
- jwt(e) {
815
- return this._addCheck({ kind: "jwt", ...h.errToObj(e) });
816
- }
817
- ip(e) {
818
- return this._addCheck({ kind: "ip", ...h.errToObj(e) });
819
- }
820
- cidr(e) {
821
- return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
822
- }
823
- datetime(e) {
824
- var t, r;
825
- return typeof e == "string" ? this._addCheck({
826
- kind: "datetime",
827
- precision: null,
828
- offset: !1,
829
- local: !1,
830
- message: e
831
- }) : this._addCheck({
832
- kind: "datetime",
833
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
834
- offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
835
- local: (r = e == null ? void 0 : e.local) !== null && r !== void 0 ? r : !1,
836
- ...h.errToObj(e == null ? void 0 : e.message)
837
- });
838
- }
839
- date(e) {
840
- return this._addCheck({ kind: "date", message: e });
841
- }
842
- time(e) {
843
- return typeof e == "string" ? this._addCheck({
844
- kind: "time",
845
- precision: null,
846
- message: e
847
- }) : this._addCheck({
848
- kind: "time",
849
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
850
- ...h.errToObj(e == null ? void 0 : e.message)
851
- });
852
- }
853
- duration(e) {
854
- return this._addCheck({ kind: "duration", ...h.errToObj(e) });
855
- }
856
- regex(e, t) {
857
- return this._addCheck({
858
- kind: "regex",
859
- regex: e,
860
- ...h.errToObj(t)
861
- });
862
- }
863
- includes(e, t) {
864
- return this._addCheck({
865
- kind: "includes",
866
- value: e,
867
- position: t == null ? void 0 : t.position,
868
- ...h.errToObj(t == null ? void 0 : t.message)
869
- });
870
- }
871
- startsWith(e, t) {
872
- return this._addCheck({
873
- kind: "startsWith",
874
- value: e,
875
- ...h.errToObj(t)
876
- });
877
- }
878
- endsWith(e, t) {
879
- return this._addCheck({
880
- kind: "endsWith",
881
- value: e,
882
- ...h.errToObj(t)
883
- });
884
- }
885
- min(e, t) {
886
- return this._addCheck({
887
- kind: "min",
888
- value: e,
889
- ...h.errToObj(t)
890
- });
891
- }
892
- max(e, t) {
893
- return this._addCheck({
894
- kind: "max",
895
- value: e,
896
- ...h.errToObj(t)
897
- });
898
- }
899
- length(e, t) {
900
- return this._addCheck({
901
- kind: "length",
902
- value: e,
903
- ...h.errToObj(t)
904
- });
905
- }
906
- /**
907
- * Equivalent to `.min(1)`
908
- */
909
- nonempty(e) {
910
- return this.min(1, h.errToObj(e));
911
- }
912
- trim() {
913
- return new N({
914
- ...this._def,
915
- checks: [...this._def.checks, { kind: "trim" }]
916
- });
917
- }
918
- toLowerCase() {
919
- return new N({
920
- ...this._def,
921
- checks: [...this._def.checks, { kind: "toLowerCase" }]
922
- });
923
- }
924
- toUpperCase() {
925
- return new N({
926
- ...this._def,
927
- checks: [...this._def.checks, { kind: "toUpperCase" }]
928
- });
929
- }
930
- get isDatetime() {
931
- return !!this._def.checks.find((e) => e.kind === "datetime");
932
- }
933
- get isDate() {
934
- return !!this._def.checks.find((e) => e.kind === "date");
935
- }
936
- get isTime() {
937
- return !!this._def.checks.find((e) => e.kind === "time");
938
- }
939
- get isDuration() {
940
- return !!this._def.checks.find((e) => e.kind === "duration");
941
- }
942
- get isEmail() {
943
- return !!this._def.checks.find((e) => e.kind === "email");
944
- }
945
- get isURL() {
946
- return !!this._def.checks.find((e) => e.kind === "url");
947
- }
948
- get isEmoji() {
949
- return !!this._def.checks.find((e) => e.kind === "emoji");
950
- }
951
- get isUUID() {
952
- return !!this._def.checks.find((e) => e.kind === "uuid");
953
- }
954
- get isNANOID() {
955
- return !!this._def.checks.find((e) => e.kind === "nanoid");
956
- }
957
- get isCUID() {
958
- return !!this._def.checks.find((e) => e.kind === "cuid");
959
- }
960
- get isCUID2() {
961
- return !!this._def.checks.find((e) => e.kind === "cuid2");
962
- }
963
- get isULID() {
964
- return !!this._def.checks.find((e) => e.kind === "ulid");
965
- }
966
- get isIP() {
967
- return !!this._def.checks.find((e) => e.kind === "ip");
968
- }
969
- get isCIDR() {
970
- return !!this._def.checks.find((e) => e.kind === "cidr");
971
- }
972
- get isBase64() {
973
- return !!this._def.checks.find((e) => e.kind === "base64");
974
- }
975
- get isBase64url() {
976
- return !!this._def.checks.find((e) => e.kind === "base64url");
977
- }
978
- get minLength() {
979
- let e = null;
980
- for (const t of this._def.checks)
981
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
982
- return e;
983
- }
984
- get maxLength() {
985
- let e = null;
986
- for (const t of this._def.checks)
987
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
988
- return e;
989
- }
990
- }
991
- N.create = (n) => {
992
- var e;
993
- return new N({
994
- checks: [],
995
- typeName: g.ZodString,
996
- coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
997
- ...v(n)
998
- });
999
- };
1000
- function Zt(n, e) {
1001
- const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r, a = parseInt(n.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
1002
- return a % o / Math.pow(10, s);
1003
- }
1004
- class V extends _ {
1005
- constructor() {
1006
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1007
- }
1008
- _parse(e) {
1009
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1010
- const a = this._getOrReturnCtx(e);
1011
- return m(a, {
1012
- code: u.invalid_type,
1013
- expected: f.number,
1014
- received: a.parsedType
1015
- }), y;
1016
- }
1017
- let r;
1018
- const s = new T();
1019
- for (const a of this._def.checks)
1020
- a.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
1021
- code: u.invalid_type,
1022
- expected: "integer",
1023
- received: "float",
1024
- message: a.message
1025
- }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
1026
- code: u.too_small,
1027
- minimum: a.value,
1028
- type: "number",
1029
- inclusive: a.inclusive,
1030
- exact: !1,
1031
- message: a.message
1032
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
1033
- code: u.too_big,
1034
- maximum: a.value,
1035
- type: "number",
1036
- inclusive: a.inclusive,
1037
- exact: !1,
1038
- message: a.message
1039
- }), s.dirty()) : a.kind === "multipleOf" ? Zt(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), m(r, {
1040
- code: u.not_multiple_of,
1041
- multipleOf: a.value,
1042
- message: a.message
1043
- }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
1044
- code: u.not_finite,
1045
- message: a.message
1046
- }), s.dirty()) : x.assertNever(a);
1047
- return { status: s.value, value: e.data };
1048
- }
1049
- gte(e, t) {
1050
- return this.setLimit("min", e, !0, h.toString(t));
1051
- }
1052
- gt(e, t) {
1053
- return this.setLimit("min", e, !1, h.toString(t));
1054
- }
1055
- lte(e, t) {
1056
- return this.setLimit("max", e, !0, h.toString(t));
1057
- }
1058
- lt(e, t) {
1059
- return this.setLimit("max", e, !1, h.toString(t));
1060
- }
1061
- setLimit(e, t, r, s) {
1062
- return new V({
1063
- ...this._def,
1064
- checks: [
1065
- ...this._def.checks,
1066
- {
1067
- kind: e,
1068
- value: t,
1069
- inclusive: r,
1070
- message: h.toString(s)
1071
- }
1072
- ]
1073
- });
1074
- }
1075
- _addCheck(e) {
1076
- return new V({
1077
- ...this._def,
1078
- checks: [...this._def.checks, e]
1079
- });
1080
- }
1081
- int(e) {
1082
- return this._addCheck({
1083
- kind: "int",
1084
- message: h.toString(e)
1085
- });
1086
- }
1087
- positive(e) {
1088
- return this._addCheck({
1089
- kind: "min",
1090
- value: 0,
1091
- inclusive: !1,
1092
- message: h.toString(e)
1093
- });
1094
- }
1095
- negative(e) {
1096
- return this._addCheck({
1097
- kind: "max",
1098
- value: 0,
1099
- inclusive: !1,
1100
- message: h.toString(e)
1101
- });
1102
- }
1103
- nonpositive(e) {
1104
- return this._addCheck({
1105
- kind: "max",
1106
- value: 0,
1107
- inclusive: !0,
1108
- message: h.toString(e)
1109
- });
1110
- }
1111
- nonnegative(e) {
1112
- return this._addCheck({
1113
- kind: "min",
1114
- value: 0,
1115
- inclusive: !0,
1116
- message: h.toString(e)
1117
- });
1118
- }
1119
- multipleOf(e, t) {
1120
- return this._addCheck({
1121
- kind: "multipleOf",
1122
- value: e,
1123
- message: h.toString(t)
1124
- });
1125
- }
1126
- finite(e) {
1127
- return this._addCheck({
1128
- kind: "finite",
1129
- message: h.toString(e)
1130
- });
1131
- }
1132
- safe(e) {
1133
- return this._addCheck({
1134
- kind: "min",
1135
- inclusive: !0,
1136
- value: Number.MIN_SAFE_INTEGER,
1137
- message: h.toString(e)
1138
- })._addCheck({
1139
- kind: "max",
1140
- inclusive: !0,
1141
- value: Number.MAX_SAFE_INTEGER,
1142
- message: h.toString(e)
1143
- });
1144
- }
1145
- get minValue() {
1146
- let e = null;
1147
- for (const t of this._def.checks)
1148
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1149
- return e;
1150
- }
1151
- get maxValue() {
1152
- let e = null;
1153
- for (const t of this._def.checks)
1154
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1155
- return e;
1156
- }
1157
- get isInt() {
1158
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1159
- }
1160
- get isFinite() {
1161
- let e = null, t = null;
1162
- for (const r of this._def.checks) {
1163
- if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
1164
- return !0;
1165
- r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1166
- }
1167
- return Number.isFinite(t) && Number.isFinite(e);
1168
- }
1169
- }
1170
- V.create = (n) => new V({
1171
- checks: [],
1172
- typeName: g.ZodNumber,
1173
- coerce: (n == null ? void 0 : n.coerce) || !1,
1174
- ...v(n)
1175
- });
1176
- class F extends _ {
1177
- constructor() {
1178
- super(...arguments), this.min = this.gte, this.max = this.lte;
1179
- }
1180
- _parse(e) {
1181
- if (this._def.coerce)
1182
- try {
1183
- e.data = BigInt(e.data);
1184
- } catch {
1185
- return this._getInvalidInput(e);
1186
- }
1187
- if (this._getType(e) !== f.bigint)
1188
- return this._getInvalidInput(e);
1189
- let r;
1190
- const s = new T();
1191
- for (const a of this._def.checks)
1192
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
1193
- code: u.too_small,
1194
- type: "bigint",
1195
- minimum: a.value,
1196
- inclusive: a.inclusive,
1197
- message: a.message
1198
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), m(r, {
1199
- code: u.too_big,
1200
- type: "bigint",
1201
- maximum: a.value,
1202
- inclusive: a.inclusive,
1203
- message: a.message
1204
- }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), m(r, {
1205
- code: u.not_multiple_of,
1206
- multipleOf: a.value,
1207
- message: a.message
1208
- }), s.dirty()) : x.assertNever(a);
1209
- return { status: s.value, value: e.data };
1210
- }
1211
- _getInvalidInput(e) {
1212
- const t = this._getOrReturnCtx(e);
1213
- return m(t, {
1214
- code: u.invalid_type,
1215
- expected: f.bigint,
1216
- received: t.parsedType
1217
- }), y;
1218
- }
1219
- gte(e, t) {
1220
- return this.setLimit("min", e, !0, h.toString(t));
1221
- }
1222
- gt(e, t) {
1223
- return this.setLimit("min", e, !1, h.toString(t));
1224
- }
1225
- lte(e, t) {
1226
- return this.setLimit("max", e, !0, h.toString(t));
1227
- }
1228
- lt(e, t) {
1229
- return this.setLimit("max", e, !1, h.toString(t));
1230
- }
1231
- setLimit(e, t, r, s) {
1232
- return new F({
1233
- ...this._def,
1234
- checks: [
1235
- ...this._def.checks,
1236
- {
1237
- kind: e,
1238
- value: t,
1239
- inclusive: r,
1240
- message: h.toString(s)
1241
- }
1242
- ]
1243
- });
1244
- }
1245
- _addCheck(e) {
1246
- return new F({
1247
- ...this._def,
1248
- checks: [...this._def.checks, e]
1249
- });
1250
- }
1251
- positive(e) {
1252
- return this._addCheck({
1253
- kind: "min",
1254
- value: BigInt(0),
1255
- inclusive: !1,
1256
- message: h.toString(e)
1257
- });
1258
- }
1259
- negative(e) {
1260
- return this._addCheck({
1261
- kind: "max",
1262
- value: BigInt(0),
1263
- inclusive: !1,
1264
- message: h.toString(e)
1265
- });
1266
- }
1267
- nonpositive(e) {
1268
- return this._addCheck({
1269
- kind: "max",
1270
- value: BigInt(0),
1271
- inclusive: !0,
1272
- message: h.toString(e)
1273
- });
1274
- }
1275
- nonnegative(e) {
1276
- return this._addCheck({
1277
- kind: "min",
1278
- value: BigInt(0),
1279
- inclusive: !0,
1280
- message: h.toString(e)
1281
- });
1282
- }
1283
- multipleOf(e, t) {
1284
- return this._addCheck({
1285
- kind: "multipleOf",
1286
- value: e,
1287
- message: h.toString(t)
1288
- });
1289
- }
1290
- get minValue() {
1291
- let e = null;
1292
- for (const t of this._def.checks)
1293
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1294
- return e;
1295
- }
1296
- get maxValue() {
1297
- let e = null;
1298
- for (const t of this._def.checks)
1299
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1300
- return e;
1301
- }
1302
- }
1303
- F.create = (n) => {
1304
- var e;
1305
- return new F({
1306
- checks: [],
1307
- typeName: g.ZodBigInt,
1308
- coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
1309
- ...v(n)
1310
- });
1311
- };
1312
- class ae extends _ {
1313
- _parse(e) {
1314
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1315
- const r = this._getOrReturnCtx(e);
1316
- return m(r, {
1317
- code: u.invalid_type,
1318
- expected: f.boolean,
1319
- received: r.parsedType
1320
- }), y;
1321
- }
1322
- return I(e.data);
1323
- }
1324
- }
1325
- ae.create = (n) => new ae({
1326
- typeName: g.ZodBoolean,
1327
- coerce: (n == null ? void 0 : n.coerce) || !1,
1328
- ...v(n)
1329
- });
1330
- class B extends _ {
1331
- _parse(e) {
1332
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1333
- const a = this._getOrReturnCtx(e);
1334
- return m(a, {
1335
- code: u.invalid_type,
1336
- expected: f.date,
1337
- received: a.parsedType
1338
- }), y;
1339
- }
1340
- if (isNaN(e.data.getTime())) {
1341
- const a = this._getOrReturnCtx(e);
1342
- return m(a, {
1343
- code: u.invalid_date
1344
- }), y;
1345
- }
1346
- const r = new T();
1347
- let s;
1348
- for (const a of this._def.checks)
1349
- a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), m(s, {
1350
- code: u.too_small,
1351
- message: a.message,
1352
- inclusive: !0,
1353
- exact: !1,
1354
- minimum: a.value,
1355
- type: "date"
1356
- }), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), m(s, {
1357
- code: u.too_big,
1358
- message: a.message,
1359
- inclusive: !0,
1360
- exact: !1,
1361
- maximum: a.value,
1362
- type: "date"
1363
- }), r.dirty()) : x.assertNever(a);
1364
- return {
1365
- status: r.value,
1366
- value: new Date(e.data.getTime())
1367
- };
1368
- }
1369
- _addCheck(e) {
1370
- return new B({
1371
- ...this._def,
1372
- checks: [...this._def.checks, e]
1373
- });
1374
- }
1375
- min(e, t) {
1376
- return this._addCheck({
1377
- kind: "min",
1378
- value: e.getTime(),
1379
- message: h.toString(t)
1380
- });
1381
- }
1382
- max(e, t) {
1383
- return this._addCheck({
1384
- kind: "max",
1385
- value: e.getTime(),
1386
- message: h.toString(t)
1387
- });
1388
- }
1389
- get minDate() {
1390
- let e = null;
1391
- for (const t of this._def.checks)
1392
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1393
- return e != null ? new Date(e) : null;
1394
- }
1395
- get maxDate() {
1396
- let e = null;
1397
- for (const t of this._def.checks)
1398
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1399
- return e != null ? new Date(e) : null;
1400
- }
1401
- }
1402
- B.create = (n) => new B({
1403
- checks: [],
1404
- coerce: (n == null ? void 0 : n.coerce) || !1,
1405
- typeName: g.ZodDate,
1406
- ...v(n)
1407
- });
1408
- class xe extends _ {
1409
- _parse(e) {
1410
- if (this._getType(e) !== f.symbol) {
1411
- const r = this._getOrReturnCtx(e);
1412
- return m(r, {
1413
- code: u.invalid_type,
1414
- expected: f.symbol,
1415
- received: r.parsedType
1416
- }), y;
1417
- }
1418
- return I(e.data);
1419
- }
1420
- }
1421
- xe.create = (n) => new xe({
1422
- typeName: g.ZodSymbol,
1423
- ...v(n)
1424
- });
1425
- class ie extends _ {
1426
- _parse(e) {
1427
- if (this._getType(e) !== f.undefined) {
1428
- const r = this._getOrReturnCtx(e);
1429
- return m(r, {
1430
- code: u.invalid_type,
1431
- expected: f.undefined,
1432
- received: r.parsedType
1433
- }), y;
1434
- }
1435
- return I(e.data);
1436
- }
1437
- }
1438
- ie.create = (n) => new ie({
1439
- typeName: g.ZodUndefined,
1440
- ...v(n)
1441
- });
1442
- class oe extends _ {
1443
- _parse(e) {
1444
- if (this._getType(e) !== f.null) {
1445
- const r = this._getOrReturnCtx(e);
1446
- return m(r, {
1447
- code: u.invalid_type,
1448
- expected: f.null,
1449
- received: r.parsedType
1450
- }), y;
1451
- }
1452
- return I(e.data);
1453
- }
1454
- }
1455
- oe.create = (n) => new oe({
1456
- typeName: g.ZodNull,
1457
- ...v(n)
1458
- });
1459
- class H extends _ {
1460
- constructor() {
1461
- super(...arguments), this._any = !0;
1462
- }
1463
- _parse(e) {
1464
- return I(e.data);
1465
- }
1466
- }
1467
- H.create = (n) => new H({
1468
- typeName: g.ZodAny,
1469
- ...v(n)
1470
- });
1471
- class L extends _ {
1472
- constructor() {
1473
- super(...arguments), this._unknown = !0;
1474
- }
1475
- _parse(e) {
1476
- return I(e.data);
1477
- }
1478
- }
1479
- L.create = (n) => new L({
1480
- typeName: g.ZodUnknown,
1481
- ...v(n)
1482
- });
1483
- class $ extends _ {
1484
- _parse(e) {
1485
- const t = this._getOrReturnCtx(e);
1486
- return m(t, {
1487
- code: u.invalid_type,
1488
- expected: f.never,
1489
- received: t.parsedType
1490
- }), y;
1491
- }
1492
- }
1493
- $.create = (n) => new $({
1494
- typeName: g.ZodNever,
1495
- ...v(n)
1496
- });
1497
- class ke extends _ {
1498
- _parse(e) {
1499
- if (this._getType(e) !== f.undefined) {
1500
- const r = this._getOrReturnCtx(e);
1501
- return m(r, {
1502
- code: u.invalid_type,
1503
- expected: f.void,
1504
- received: r.parsedType
1505
- }), y;
1506
- }
1507
- return I(e.data);
1508
- }
1509
- }
1510
- ke.create = (n) => new ke({
1511
- typeName: g.ZodVoid,
1512
- ...v(n)
1513
- });
1514
- class C extends _ {
1515
- _parse(e) {
1516
- const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
1517
- if (t.parsedType !== f.array)
1518
- return m(t, {
1519
- code: u.invalid_type,
1520
- expected: f.array,
1521
- received: t.parsedType
1522
- }), y;
1523
- if (s.exactLength !== null) {
1524
- const o = t.data.length > s.exactLength.value, c = t.data.length < s.exactLength.value;
1525
- (o || c) && (m(t, {
1526
- code: o ? u.too_big : u.too_small,
1527
- minimum: c ? s.exactLength.value : void 0,
1528
- maximum: o ? s.exactLength.value : void 0,
1529
- type: "array",
1530
- inclusive: !0,
1531
- exact: !0,
1532
- message: s.exactLength.message
1533
- }), r.dirty());
1534
- }
1535
- if (s.minLength !== null && t.data.length < s.minLength.value && (m(t, {
1536
- code: u.too_small,
1537
- minimum: s.minLength.value,
1538
- type: "array",
1539
- inclusive: !0,
1540
- exact: !1,
1541
- message: s.minLength.message
1542
- }), r.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (m(t, {
1543
- code: u.too_big,
1544
- maximum: s.maxLength.value,
1545
- type: "array",
1546
- inclusive: !0,
1547
- exact: !1,
1548
- message: s.maxLength.message
1549
- }), r.dirty()), t.common.async)
1550
- return Promise.all([...t.data].map((o, c) => s.type._parseAsync(new O(t, o, t.path, c)))).then((o) => T.mergeArray(r, o));
1551
- const a = [...t.data].map((o, c) => s.type._parseSync(new O(t, o, t.path, c)));
1552
- return T.mergeArray(r, a);
1553
- }
1554
- get element() {
1555
- return this._def.type;
1556
- }
1557
- min(e, t) {
1558
- return new C({
1559
- ...this._def,
1560
- minLength: { value: e, message: h.toString(t) }
1561
- });
1562
- }
1563
- max(e, t) {
1564
- return new C({
1565
- ...this._def,
1566
- maxLength: { value: e, message: h.toString(t) }
1567
- });
1568
- }
1569
- length(e, t) {
1570
- return new C({
1571
- ...this._def,
1572
- exactLength: { value: e, message: h.toString(t) }
1573
- });
1574
- }
1575
- nonempty(e) {
1576
- return this.min(1, e);
1577
- }
1578
- }
1579
- C.create = (n, e) => new C({
1580
- type: n,
1581
- minLength: null,
1582
- maxLength: null,
1583
- exactLength: null,
1584
- typeName: g.ZodArray,
1585
- ...v(e)
1586
- });
1587
- function Q(n) {
1588
- if (n instanceof k) {
1589
- const e = {};
1590
- for (const t in n.shape) {
1591
- const r = n.shape[t];
1592
- e[t] = j.create(Q(r));
1593
- }
1594
- return new k({
1595
- ...n._def,
1596
- shape: () => e
1597
- });
1598
- } else return n instanceof C ? new C({
1599
- ...n._def,
1600
- type: Q(n.element)
1601
- }) : n instanceof j ? j.create(Q(n.unwrap())) : n instanceof U ? U.create(Q(n.unwrap())) : n instanceof E ? E.create(n.items.map((e) => Q(e))) : n;
1602
- }
1603
- class k extends _ {
1604
- constructor() {
1605
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1606
- }
1607
- _getCached() {
1608
- if (this._cached !== null)
1609
- return this._cached;
1610
- const e = this._def.shape(), t = x.objectKeys(e);
1611
- return this._cached = { shape: e, keys: t };
1612
- }
1613
- _parse(e) {
1614
- if (this._getType(e) !== f.object) {
1615
- const d = this._getOrReturnCtx(e);
1616
- return m(d, {
1617
- code: u.invalid_type,
1618
- expected: f.object,
1619
- received: d.parsedType
1620
- }), y;
1621
- }
1622
- const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), c = [];
1623
- if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
1624
- for (const d in s.data)
1625
- o.includes(d) || c.push(d);
1626
- const l = [];
1627
- for (const d of o) {
1628
- const p = a[d], b = s.data[d];
1629
- l.push({
1630
- key: { status: "valid", value: d },
1631
- value: p._parse(new O(s, b, s.path, d)),
1632
- alwaysSet: d in s.data
1633
- });
1634
- }
1635
- if (this._def.catchall instanceof $) {
1636
- const d = this._def.unknownKeys;
1637
- if (d === "passthrough")
1638
- for (const p of c)
1639
- l.push({
1640
- key: { status: "valid", value: p },
1641
- value: { status: "valid", value: s.data[p] }
1642
- });
1643
- else if (d === "strict")
1644
- c.length > 0 && (m(s, {
1645
- code: u.unrecognized_keys,
1646
- keys: c
1647
- }), r.dirty());
1648
- else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1649
- } else {
1650
- const d = this._def.catchall;
1651
- for (const p of c) {
1652
- const b = s.data[p];
1653
- l.push({
1654
- key: { status: "valid", value: p },
1655
- value: d._parse(
1656
- new O(s, b, s.path, p)
1657
- //, ctx.child(key), value, getParsedType(value)
1658
- ),
1659
- alwaysSet: p in s.data
1660
- });
1661
- }
1662
- }
1663
- return s.common.async ? Promise.resolve().then(async () => {
1664
- const d = [];
1665
- for (const p of l) {
1666
- const b = await p.key, w = await p.value;
1667
- d.push({
1668
- key: b,
1669
- value: w,
1670
- alwaysSet: p.alwaysSet
1671
- });
1672
- }
1673
- return d;
1674
- }).then((d) => T.mergeObjectSync(r, d)) : T.mergeObjectSync(r, l);
1675
- }
1676
- get shape() {
1677
- return this._def.shape();
1678
- }
1679
- strict(e) {
1680
- return h.errToObj, new k({
1681
- ...this._def,
1682
- unknownKeys: "strict",
1683
- ...e !== void 0 ? {
1684
- errorMap: (t, r) => {
1685
- var s, a, o, c;
1686
- const l = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, r).message) !== null && o !== void 0 ? o : r.defaultError;
1687
- return t.code === "unrecognized_keys" ? {
1688
- message: (c = h.errToObj(e).message) !== null && c !== void 0 ? c : l
1689
- } : {
1690
- message: l
1691
- };
1692
- }
1693
- } : {}
1694
- });
1695
- }
1696
- strip() {
1697
- return new k({
1698
- ...this._def,
1699
- unknownKeys: "strip"
1700
- });
1701
- }
1702
- passthrough() {
1703
- return new k({
1704
- ...this._def,
1705
- unknownKeys: "passthrough"
1706
- });
1707
- }
1708
- // const AugmentFactory =
1709
- // <Def extends ZodObjectDef>(def: Def) =>
1710
- // <Augmentation extends ZodRawShape>(
1711
- // augmentation: Augmentation
1712
- // ): ZodObject<
1713
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1714
- // Def["unknownKeys"],
1715
- // Def["catchall"]
1716
- // > => {
1717
- // return new ZodObject({
1718
- // ...def,
1719
- // shape: () => ({
1720
- // ...def.shape(),
1721
- // ...augmentation,
1722
- // }),
1723
- // }) as any;
1724
- // };
1725
- extend(e) {
1726
- return new k({
1727
- ...this._def,
1728
- shape: () => ({
1729
- ...this._def.shape(),
1730
- ...e
1731
- })
1732
- });
1733
- }
1734
- /**
1735
- * Prior to zod@1.0.12 there was a bug in the
1736
- * inferred type of merged objects. Please
1737
- * upgrade if you are experiencing issues.
1738
- */
1739
- merge(e) {
1740
- return new k({
1741
- unknownKeys: e._def.unknownKeys,
1742
- catchall: e._def.catchall,
1743
- shape: () => ({
1744
- ...this._def.shape(),
1745
- ...e._def.shape()
1746
- }),
1747
- typeName: g.ZodObject
1748
- });
1749
- }
1750
- // merge<
1751
- // Incoming extends AnyZodObject,
1752
- // Augmentation extends Incoming["shape"],
1753
- // NewOutput extends {
1754
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1755
- // ? Augmentation[k]["_output"]
1756
- // : k extends keyof Output
1757
- // ? Output[k]
1758
- // : never;
1759
- // },
1760
- // NewInput extends {
1761
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1762
- // ? Augmentation[k]["_input"]
1763
- // : k extends keyof Input
1764
- // ? Input[k]
1765
- // : never;
1766
- // }
1767
- // >(
1768
- // merging: Incoming
1769
- // ): ZodObject<
1770
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1771
- // Incoming["_def"]["unknownKeys"],
1772
- // Incoming["_def"]["catchall"],
1773
- // NewOutput,
1774
- // NewInput
1775
- // > {
1776
- // const merged: any = new ZodObject({
1777
- // unknownKeys: merging._def.unknownKeys,
1778
- // catchall: merging._def.catchall,
1779
- // shape: () =>
1780
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1781
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1782
- // }) as any;
1783
- // return merged;
1784
- // }
1785
- setKey(e, t) {
1786
- return this.augment({ [e]: t });
1787
- }
1788
- // merge<Incoming extends AnyZodObject>(
1789
- // merging: Incoming
1790
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1791
- // ZodObject<
1792
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1793
- // Incoming["_def"]["unknownKeys"],
1794
- // Incoming["_def"]["catchall"]
1795
- // > {
1796
- // // const mergedShape = objectUtil.mergeShapes(
1797
- // // this._def.shape(),
1798
- // // merging._def.shape()
1799
- // // );
1800
- // const merged: any = new ZodObject({
1801
- // unknownKeys: merging._def.unknownKeys,
1802
- // catchall: merging._def.catchall,
1803
- // shape: () =>
1804
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1805
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1806
- // }) as any;
1807
- // return merged;
1808
- // }
1809
- catchall(e) {
1810
- return new k({
1811
- ...this._def,
1812
- catchall: e
1813
- });
1814
- }
1815
- pick(e) {
1816
- const t = {};
1817
- return x.objectKeys(e).forEach((r) => {
1818
- e[r] && this.shape[r] && (t[r] = this.shape[r]);
1819
- }), new k({
1820
- ...this._def,
1821
- shape: () => t
1822
- });
1823
- }
1824
- omit(e) {
1825
- const t = {};
1826
- return x.objectKeys(this.shape).forEach((r) => {
1827
- e[r] || (t[r] = this.shape[r]);
1828
- }), new k({
1829
- ...this._def,
1830
- shape: () => t
1831
- });
1832
- }
1833
- /**
1834
- * @deprecated
1835
- */
1836
- deepPartial() {
1837
- return Q(this);
1838
- }
1839
- partial(e) {
1840
- const t = {};
1841
- return x.objectKeys(this.shape).forEach((r) => {
1842
- const s = this.shape[r];
1843
- e && !e[r] ? t[r] = s : t[r] = s.optional();
1844
- }), new k({
1845
- ...this._def,
1846
- shape: () => t
1847
- });
1848
- }
1849
- required(e) {
1850
- const t = {};
1851
- return x.objectKeys(this.shape).forEach((r) => {
1852
- if (e && !e[r])
1853
- t[r] = this.shape[r];
1854
- else {
1855
- let a = this.shape[r];
1856
- for (; a instanceof j; )
1857
- a = a._def.innerType;
1858
- t[r] = a;
1859
- }
1860
- }), new k({
1861
- ...this._def,
1862
- shape: () => t
1863
- });
1864
- }
1865
- keyof() {
1866
- return Be(x.objectKeys(this.shape));
1867
- }
1868
- }
1869
- k.create = (n, e) => new k({
1870
- shape: () => n,
1871
- unknownKeys: "strip",
1872
- catchall: $.create(),
1873
- typeName: g.ZodObject,
1874
- ...v(e)
1875
- });
1876
- k.strictCreate = (n, e) => new k({
1877
- shape: () => n,
1878
- unknownKeys: "strict",
1879
- catchall: $.create(),
1880
- typeName: g.ZodObject,
1881
- ...v(e)
1882
- });
1883
- k.lazycreate = (n, e) => new k({
1884
- shape: n,
1885
- unknownKeys: "strip",
1886
- catchall: $.create(),
1887
- typeName: g.ZodObject,
1888
- ...v(e)
1889
- });
1890
- class ce extends _ {
1891
- _parse(e) {
1892
- const { ctx: t } = this._processInputParams(e), r = this._def.options;
1893
- function s(a) {
1894
- for (const c of a)
1895
- if (c.result.status === "valid")
1896
- return c.result;
1897
- for (const c of a)
1898
- if (c.result.status === "dirty")
1899
- return t.common.issues.push(...c.ctx.common.issues), c.result;
1900
- const o = a.map((c) => new S(c.ctx.common.issues));
1901
- return m(t, {
1902
- code: u.invalid_union,
1903
- unionErrors: o
1904
- }), y;
1905
- }
1906
- if (t.common.async)
1907
- return Promise.all(r.map(async (a) => {
1908
- const o = {
1909
- ...t,
1910
- common: {
1911
- ...t.common,
1912
- issues: []
1913
- },
1914
- parent: null
1915
- };
1916
- return {
1917
- result: await a._parseAsync({
1918
- data: t.data,
1919
- path: t.path,
1920
- parent: o
1921
- }),
1922
- ctx: o
1923
- };
1924
- })).then(s);
1925
- {
1926
- let a;
1927
- const o = [];
1928
- for (const l of r) {
1929
- const d = {
1930
- ...t,
1931
- common: {
1932
- ...t.common,
1933
- issues: []
1934
- },
1935
- parent: null
1936
- }, p = l._parseSync({
1937
- data: t.data,
1938
- path: t.path,
1939
- parent: d
1940
- });
1941
- if (p.status === "valid")
1942
- return p;
1943
- p.status === "dirty" && !a && (a = { result: p, ctx: d }), d.common.issues.length && o.push(d.common.issues);
1944
- }
1945
- if (a)
1946
- return t.common.issues.push(...a.ctx.common.issues), a.result;
1947
- const c = o.map((l) => new S(l));
1948
- return m(t, {
1949
- code: u.invalid_union,
1950
- unionErrors: c
1951
- }), y;
1952
- }
1953
- }
1954
- get options() {
1955
- return this._def.options;
1956
- }
1957
- }
1958
- ce.create = (n, e) => new ce({
1959
- options: n,
1960
- typeName: g.ZodUnion,
1961
- ...v(e)
1962
- });
1963
- const P = (n) => n instanceof le ? P(n.schema) : n instanceof Z ? P(n.innerType()) : n instanceof me ? [n.value] : n instanceof z ? n.options : n instanceof fe ? x.objectValues(n.enum) : n instanceof pe ? P(n._def.innerType) : n instanceof ie ? [void 0] : n instanceof oe ? [null] : n instanceof j ? [void 0, ...P(n.unwrap())] : n instanceof U ? [null, ...P(n.unwrap())] : n instanceof Ee || n instanceof ge ? P(n.unwrap()) : n instanceof he ? P(n._def.innerType) : [];
1964
- class Ie extends _ {
1965
- _parse(e) {
1966
- const { ctx: t } = this._processInputParams(e);
1967
- if (t.parsedType !== f.object)
1968
- return m(t, {
1969
- code: u.invalid_type,
1970
- expected: f.object,
1971
- received: t.parsedType
1972
- }), y;
1973
- const r = this.discriminator, s = t.data[r], a = this.optionsMap.get(s);
1974
- return a ? t.common.async ? a._parseAsync({
1975
- data: t.data,
1976
- path: t.path,
1977
- parent: t
1978
- }) : a._parseSync({
1979
- data: t.data,
1980
- path: t.path,
1981
- parent: t
1982
- }) : (m(t, {
1983
- code: u.invalid_union_discriminator,
1984
- options: Array.from(this.optionsMap.keys()),
1985
- path: [r]
1986
- }), y);
1987
- }
1988
- get discriminator() {
1989
- return this._def.discriminator;
1990
- }
1991
- get options() {
1992
- return this._def.options;
1993
- }
1994
- get optionsMap() {
1995
- return this._def.optionsMap;
1996
- }
1997
- /**
1998
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1999
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2000
- * have a different value for each object in the union.
2001
- * @param discriminator the name of the discriminator property
2002
- * @param types an array of object schemas
2003
- * @param params
2004
- */
2005
- static create(e, t, r) {
2006
- const s = /* @__PURE__ */ new Map();
2007
- for (const a of t) {
2008
- const o = P(a.shape[e]);
2009
- if (!o.length)
2010
- throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2011
- for (const c of o) {
2012
- if (s.has(c))
2013
- throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
2014
- s.set(c, a);
2015
- }
2016
- }
2017
- return new Ie({
2018
- typeName: g.ZodDiscriminatedUnion,
2019
- discriminator: e,
2020
- options: t,
2021
- optionsMap: s,
2022
- ...v(r)
2023
- });
2024
- }
2025
- }
2026
- function Oe(n, e) {
2027
- const t = R(n), r = R(e);
2028
- if (n === e)
2029
- return { valid: !0, data: n };
2030
- if (t === f.object && r === f.object) {
2031
- const s = x.objectKeys(e), a = x.objectKeys(n).filter((c) => s.indexOf(c) !== -1), o = { ...n, ...e };
2032
- for (const c of a) {
2033
- const l = Oe(n[c], e[c]);
2034
- if (!l.valid)
2035
- return { valid: !1 };
2036
- o[c] = l.data;
2037
- }
2038
- return { valid: !0, data: o };
2039
- } else if (t === f.array && r === f.array) {
2040
- if (n.length !== e.length)
2041
- return { valid: !1 };
2042
- const s = [];
2043
- for (let a = 0; a < n.length; a++) {
2044
- const o = n[a], c = e[a], l = Oe(o, c);
2045
- if (!l.valid)
2046
- return { valid: !1 };
2047
- s.push(l.data);
2048
- }
2049
- return { valid: !0, data: s };
2050
- } else return t === f.date && r === f.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2051
- }
2052
- class de extends _ {
2053
- _parse(e) {
2054
- const { status: t, ctx: r } = this._processInputParams(e), s = (a, o) => {
2055
- if (De(a) || De(o))
2056
- return y;
2057
- const c = Oe(a.value, o.value);
2058
- return c.valid ? ((je(a) || je(o)) && t.dirty(), { status: t.value, value: c.data }) : (m(r, {
2059
- code: u.invalid_intersection_types
2060
- }), y);
2061
- };
2062
- return r.common.async ? Promise.all([
2063
- this._def.left._parseAsync({
2064
- data: r.data,
2065
- path: r.path,
2066
- parent: r
2067
- }),
2068
- this._def.right._parseAsync({
2069
- data: r.data,
2070
- path: r.path,
2071
- parent: r
2072
- })
2073
- ]).then(([a, o]) => s(a, o)) : s(this._def.left._parseSync({
2074
- data: r.data,
2075
- path: r.path,
2076
- parent: r
2077
- }), this._def.right._parseSync({
2078
- data: r.data,
2079
- path: r.path,
2080
- parent: r
2081
- }));
2082
- }
2083
- }
2084
- de.create = (n, e, t) => new de({
2085
- left: n,
2086
- right: e,
2087
- typeName: g.ZodIntersection,
2088
- ...v(t)
2089
- });
2090
- class E extends _ {
2091
- _parse(e) {
2092
- const { status: t, ctx: r } = this._processInputParams(e);
2093
- if (r.parsedType !== f.array)
2094
- return m(r, {
2095
- code: u.invalid_type,
2096
- expected: f.array,
2097
- received: r.parsedType
2098
- }), y;
2099
- if (r.data.length < this._def.items.length)
2100
- return m(r, {
2101
- code: u.too_small,
2102
- minimum: this._def.items.length,
2103
- inclusive: !0,
2104
- exact: !1,
2105
- type: "array"
2106
- }), y;
2107
- !this._def.rest && r.data.length > this._def.items.length && (m(r, {
2108
- code: u.too_big,
2109
- maximum: this._def.items.length,
2110
- inclusive: !0,
2111
- exact: !1,
2112
- type: "array"
2113
- }), t.dirty());
2114
- const a = [...r.data].map((o, c) => {
2115
- const l = this._def.items[c] || this._def.rest;
2116
- return l ? l._parse(new O(r, o, r.path, c)) : null;
2117
- }).filter((o) => !!o);
2118
- return r.common.async ? Promise.all(a).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, a);
2119
- }
2120
- get items() {
2121
- return this._def.items;
2122
- }
2123
- rest(e) {
2124
- return new E({
2125
- ...this._def,
2126
- rest: e
2127
- });
2128
- }
2129
- }
2130
- E.create = (n, e) => {
2131
- if (!Array.isArray(n))
2132
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2133
- return new E({
2134
- items: n,
2135
- typeName: g.ZodTuple,
2136
- rest: null,
2137
- ...v(e)
2138
- });
2139
- };
2140
- class ue extends _ {
2141
- get keySchema() {
2142
- return this._def.keyType;
2143
- }
2144
- get valueSchema() {
2145
- return this._def.valueType;
2146
- }
2147
- _parse(e) {
2148
- const { status: t, ctx: r } = this._processInputParams(e);
2149
- if (r.parsedType !== f.object)
2150
- return m(r, {
2151
- code: u.invalid_type,
2152
- expected: f.object,
2153
- received: r.parsedType
2154
- }), y;
2155
- const s = [], a = this._def.keyType, o = this._def.valueType;
2156
- for (const c in r.data)
2157
- s.push({
2158
- key: a._parse(new O(r, c, r.path, c)),
2159
- value: o._parse(new O(r, r.data[c], r.path, c)),
2160
- alwaysSet: c in r.data
2161
- });
2162
- return r.common.async ? T.mergeObjectAsync(t, s) : T.mergeObjectSync(t, s);
2163
- }
2164
- get element() {
2165
- return this._def.valueType;
2166
- }
2167
- static create(e, t, r) {
2168
- return t instanceof _ ? new ue({
2169
- keyType: e,
2170
- valueType: t,
2171
- typeName: g.ZodRecord,
2172
- ...v(r)
2173
- }) : new ue({
2174
- keyType: N.create(),
2175
- valueType: e,
2176
- typeName: g.ZodRecord,
2177
- ...v(t)
2178
- });
2179
- }
2180
- }
2181
- class we extends _ {
2182
- get keySchema() {
2183
- return this._def.keyType;
2184
- }
2185
- get valueSchema() {
2186
- return this._def.valueType;
2187
- }
2188
- _parse(e) {
2189
- const { status: t, ctx: r } = this._processInputParams(e);
2190
- if (r.parsedType !== f.map)
2191
- return m(r, {
2192
- code: u.invalid_type,
2193
- expected: f.map,
2194
- received: r.parsedType
2195
- }), y;
2196
- const s = this._def.keyType, a = this._def.valueType, o = [...r.data.entries()].map(([c, l], d) => ({
2197
- key: s._parse(new O(r, c, r.path, [d, "key"])),
2198
- value: a._parse(new O(r, l, r.path, [d, "value"]))
2199
- }));
2200
- if (r.common.async) {
2201
- const c = /* @__PURE__ */ new Map();
2202
- return Promise.resolve().then(async () => {
2203
- for (const l of o) {
2204
- const d = await l.key, p = await l.value;
2205
- if (d.status === "aborted" || p.status === "aborted")
2206
- return y;
2207
- (d.status === "dirty" || p.status === "dirty") && t.dirty(), c.set(d.value, p.value);
2208
- }
2209
- return { status: t.value, value: c };
2210
- });
2211
- } else {
2212
- const c = /* @__PURE__ */ new Map();
2213
- for (const l of o) {
2214
- const d = l.key, p = l.value;
2215
- if (d.status === "aborted" || p.status === "aborted")
2216
- return y;
2217
- (d.status === "dirty" || p.status === "dirty") && t.dirty(), c.set(d.value, p.value);
2218
- }
2219
- return { status: t.value, value: c };
2220
- }
2221
- }
2222
- }
2223
- we.create = (n, e, t) => new we({
2224
- valueType: e,
2225
- keyType: n,
2226
- typeName: g.ZodMap,
2227
- ...v(t)
2228
- });
2229
- class W extends _ {
2230
- _parse(e) {
2231
- const { status: t, ctx: r } = this._processInputParams(e);
2232
- if (r.parsedType !== f.set)
2233
- return m(r, {
2234
- code: u.invalid_type,
2235
- expected: f.set,
2236
- received: r.parsedType
2237
- }), y;
2238
- const s = this._def;
2239
- s.minSize !== null && r.data.size < s.minSize.value && (m(r, {
2240
- code: u.too_small,
2241
- minimum: s.minSize.value,
2242
- type: "set",
2243
- inclusive: !0,
2244
- exact: !1,
2245
- message: s.minSize.message
2246
- }), t.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (m(r, {
2247
- code: u.too_big,
2248
- maximum: s.maxSize.value,
2249
- type: "set",
2250
- inclusive: !0,
2251
- exact: !1,
2252
- message: s.maxSize.message
2253
- }), t.dirty());
2254
- const a = this._def.valueType;
2255
- function o(l) {
2256
- const d = /* @__PURE__ */ new Set();
2257
- for (const p of l) {
2258
- if (p.status === "aborted")
2259
- return y;
2260
- p.status === "dirty" && t.dirty(), d.add(p.value);
2261
- }
2262
- return { status: t.value, value: d };
2263
- }
2264
- const c = [...r.data.values()].map((l, d) => a._parse(new O(r, l, r.path, d)));
2265
- return r.common.async ? Promise.all(c).then((l) => o(l)) : o(c);
2266
- }
2267
- min(e, t) {
2268
- return new W({
2269
- ...this._def,
2270
- minSize: { value: e, message: h.toString(t) }
2271
- });
2272
- }
2273
- max(e, t) {
2274
- return new W({
2275
- ...this._def,
2276
- maxSize: { value: e, message: h.toString(t) }
2277
- });
2278
- }
2279
- size(e, t) {
2280
- return this.min(e, t).max(e, t);
2281
- }
2282
- nonempty(e) {
2283
- return this.min(1, e);
2284
- }
2285
- }
2286
- W.create = (n, e) => new W({
2287
- valueType: n,
2288
- minSize: null,
2289
- maxSize: null,
2290
- typeName: g.ZodSet,
2291
- ...v(e)
2292
- });
2293
- class J extends _ {
2294
- constructor() {
2295
- super(...arguments), this.validate = this.implement;
2296
- }
2297
- _parse(e) {
2298
- const { ctx: t } = this._processInputParams(e);
2299
- if (t.parsedType !== f.function)
2300
- return m(t, {
2301
- code: u.invalid_type,
2302
- expected: f.function,
2303
- received: t.parsedType
2304
- }), y;
2305
- function r(c, l) {
2306
- return _e({
2307
- data: c,
2308
- path: t.path,
2309
- errorMaps: [
2310
- t.common.contextualErrorMap,
2311
- t.schemaErrorMap,
2312
- ve(),
2313
- X
2314
- ].filter((d) => !!d),
2315
- issueData: {
2316
- code: u.invalid_arguments,
2317
- argumentsError: l
2318
- }
2319
- });
2320
- }
2321
- function s(c, l) {
2322
- return _e({
2323
- data: c,
2324
- path: t.path,
2325
- errorMaps: [
2326
- t.common.contextualErrorMap,
2327
- t.schemaErrorMap,
2328
- ve(),
2329
- X
2330
- ].filter((d) => !!d),
2331
- issueData: {
2332
- code: u.invalid_return_type,
2333
- returnTypeError: l
2334
- }
2335
- });
2336
- }
2337
- const a = { errorMap: t.common.contextualErrorMap }, o = t.data;
2338
- if (this._def.returns instanceof G) {
2339
- const c = this;
2340
- return I(async function(...l) {
2341
- const d = new S([]), p = await c._def.args.parseAsync(l, a).catch((A) => {
2342
- throw d.addIssue(r(l, A)), d;
2343
- }), b = await Reflect.apply(o, this, p);
2344
- return await c._def.returns._def.type.parseAsync(b, a).catch((A) => {
2345
- throw d.addIssue(s(b, A)), d;
2346
- });
2347
- });
2348
- } else {
2349
- const c = this;
2350
- return I(function(...l) {
2351
- const d = c._def.args.safeParse(l, a);
2352
- if (!d.success)
2353
- throw new S([r(l, d.error)]);
2354
- const p = Reflect.apply(o, this, d.data), b = c._def.returns.safeParse(p, a);
2355
- if (!b.success)
2356
- throw new S([s(p, b.error)]);
2357
- return b.data;
2358
- });
2359
- }
2360
- }
2361
- parameters() {
2362
- return this._def.args;
2363
- }
2364
- returnType() {
2365
- return this._def.returns;
2366
- }
2367
- args(...e) {
2368
- return new J({
2369
- ...this._def,
2370
- args: E.create(e).rest(L.create())
2371
- });
2372
- }
2373
- returns(e) {
2374
- return new J({
2375
- ...this._def,
2376
- returns: e
2377
- });
2378
- }
2379
- implement(e) {
2380
- return this.parse(e);
2381
- }
2382
- strictImplement(e) {
2383
- return this.parse(e);
2384
- }
2385
- static create(e, t, r) {
2386
- return new J({
2387
- args: e || E.create([]).rest(L.create()),
2388
- returns: t || L.create(),
2389
- typeName: g.ZodFunction,
2390
- ...v(r)
2391
- });
2392
- }
2393
- }
2394
- class le extends _ {
2395
- get schema() {
2396
- return this._def.getter();
2397
- }
2398
- _parse(e) {
2399
- const { ctx: t } = this._processInputParams(e);
2400
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2401
- }
2402
- }
2403
- le.create = (n, e) => new le({
2404
- getter: n,
2405
- typeName: g.ZodLazy,
2406
- ...v(e)
2407
- });
2408
- class me extends _ {
2409
- _parse(e) {
2410
- if (e.data !== this._def.value) {
2411
- const t = this._getOrReturnCtx(e);
2412
- return m(t, {
2413
- received: t.data,
2414
- code: u.invalid_literal,
2415
- expected: this._def.value
2416
- }), y;
2417
- }
2418
- return { status: "valid", value: e.data };
2419
- }
2420
- get value() {
2421
- return this._def.value;
2422
- }
2423
- }
2424
- me.create = (n, e) => new me({
2425
- value: n,
2426
- typeName: g.ZodLiteral,
2427
- ...v(e)
2428
- });
2429
- function Be(n, e) {
2430
- return new z({
2431
- values: n,
2432
- typeName: g.ZodEnum,
2433
- ...v(e)
2434
- });
2435
- }
2436
- class z extends _ {
2437
- constructor() {
2438
- super(...arguments), te.set(this, void 0);
2439
- }
2440
- _parse(e) {
2441
- if (typeof e.data != "string") {
2442
- const t = this._getOrReturnCtx(e), r = this._def.values;
2443
- return m(t, {
2444
- expected: x.joinValues(r),
2445
- received: t.parsedType,
2446
- code: u.invalid_type
2447
- }), y;
2448
- }
2449
- if (be(this, te) || ze(this, te, new Set(this._def.values)), !be(this, te).has(e.data)) {
2450
- const t = this._getOrReturnCtx(e), r = this._def.values;
2451
- return m(t, {
2452
- received: t.data,
2453
- code: u.invalid_enum_value,
2454
- options: r
2455
- }), y;
2456
- }
2457
- return I(e.data);
2458
- }
2459
- get options() {
2460
- return this._def.values;
2461
- }
2462
- get enum() {
2463
- const e = {};
2464
- for (const t of this._def.values)
2465
- e[t] = t;
2466
- return e;
2467
- }
2468
- get Values() {
2469
- const e = {};
2470
- for (const t of this._def.values)
2471
- e[t] = t;
2472
- return e;
2473
- }
2474
- get Enum() {
2475
- const e = {};
2476
- for (const t of this._def.values)
2477
- e[t] = t;
2478
- return e;
2479
- }
2480
- extract(e, t = this._def) {
2481
- return z.create(e, {
2482
- ...this._def,
2483
- ...t
2484
- });
2485
- }
2486
- exclude(e, t = this._def) {
2487
- return z.create(this.options.filter((r) => !e.includes(r)), {
2488
- ...this._def,
2489
- ...t
2490
- });
2491
- }
2492
- }
2493
- te = /* @__PURE__ */ new WeakMap();
2494
- z.create = Be;
2495
- class fe extends _ {
2496
- constructor() {
2497
- super(...arguments), ne.set(this, void 0);
2498
- }
2499
- _parse(e) {
2500
- const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2501
- if (r.parsedType !== f.string && r.parsedType !== f.number) {
2502
- const s = x.objectValues(t);
2503
- return m(r, {
2504
- expected: x.joinValues(s),
2505
- received: r.parsedType,
2506
- code: u.invalid_type
2507
- }), y;
2508
- }
2509
- if (be(this, ne) || ze(this, ne, new Set(x.getValidEnumValues(this._def.values))), !be(this, ne).has(e.data)) {
2510
- const s = x.objectValues(t);
2511
- return m(r, {
2512
- received: r.data,
2513
- code: u.invalid_enum_value,
2514
- options: s
2515
- }), y;
2516
- }
2517
- return I(e.data);
2518
- }
2519
- get enum() {
2520
- return this._def.values;
2521
- }
2522
- }
2523
- ne = /* @__PURE__ */ new WeakMap();
2524
- fe.create = (n, e) => new fe({
2525
- values: n,
2526
- typeName: g.ZodNativeEnum,
2527
- ...v(e)
2528
- });
2529
- class G extends _ {
2530
- unwrap() {
2531
- return this._def.type;
2532
- }
2533
- _parse(e) {
2534
- const { ctx: t } = this._processInputParams(e);
2535
- if (t.parsedType !== f.promise && t.common.async === !1)
2536
- return m(t, {
2537
- code: u.invalid_type,
2538
- expected: f.promise,
2539
- received: t.parsedType
2540
- }), y;
2541
- const r = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2542
- return I(r.then((s) => this._def.type.parseAsync(s, {
2543
- path: t.path,
2544
- errorMap: t.common.contextualErrorMap
2545
- })));
2546
- }
2547
- }
2548
- G.create = (n, e) => new G({
2549
- type: n,
2550
- typeName: g.ZodPromise,
2551
- ...v(e)
2552
- });
2553
- class Z extends _ {
2554
- innerType() {
2555
- return this._def.schema;
2556
- }
2557
- sourceType() {
2558
- return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2559
- }
2560
- _parse(e) {
2561
- const { status: t, ctx: r } = this._processInputParams(e), s = this._def.effect || null, a = {
2562
- addIssue: (o) => {
2563
- m(r, o), o.fatal ? t.abort() : t.dirty();
2564
- },
2565
- get path() {
2566
- return r.path;
2567
- }
2568
- };
2569
- if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2570
- const o = s.transform(r.data, a);
2571
- if (r.common.async)
2572
- return Promise.resolve(o).then(async (c) => {
2573
- if (t.value === "aborted")
2574
- return y;
2575
- const l = await this._def.schema._parseAsync({
2576
- data: c,
2577
- path: r.path,
2578
- parent: r
2579
- });
2580
- return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ? Y(l.value) : l;
2581
- });
2582
- {
2583
- if (t.value === "aborted")
2584
- return y;
2585
- const c = this._def.schema._parseSync({
2586
- data: o,
2587
- path: r.path,
2588
- parent: r
2589
- });
2590
- return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? Y(c.value) : c;
2591
- }
2592
- }
2593
- if (s.type === "refinement") {
2594
- const o = (c) => {
2595
- const l = s.refinement(c, a);
2596
- if (r.common.async)
2597
- return Promise.resolve(l);
2598
- if (l instanceof Promise)
2599
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2600
- return c;
2601
- };
2602
- if (r.common.async === !1) {
2603
- const c = this._def.schema._parseSync({
2604
- data: r.data,
2605
- path: r.path,
2606
- parent: r
2607
- });
2608
- return c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value), { status: t.value, value: c.value });
2609
- } else
2610
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((c) => c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value).then(() => ({ status: t.value, value: c.value }))));
2611
- }
2612
- if (s.type === "transform")
2613
- if (r.common.async === !1) {
2614
- const o = this._def.schema._parseSync({
2615
- data: r.data,
2616
- path: r.path,
2617
- parent: r
2618
- });
2619
- if (!q(o))
2620
- return o;
2621
- const c = s.transform(o.value, a);
2622
- if (c instanceof Promise)
2623
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2624
- return { status: t.value, value: c };
2625
- } else
2626
- return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => q(o) ? Promise.resolve(s.transform(o.value, a)).then((c) => ({ status: t.value, value: c })) : o);
2627
- x.assertNever(s);
2628
- }
2629
- }
2630
- Z.create = (n, e, t) => new Z({
2631
- schema: n,
2632
- typeName: g.ZodEffects,
2633
- effect: e,
2634
- ...v(t)
2635
- });
2636
- Z.createWithPreprocess = (n, e, t) => new Z({
2637
- schema: e,
2638
- effect: { type: "preprocess", transform: n },
2639
- typeName: g.ZodEffects,
2640
- ...v(t)
2641
- });
2642
- class j extends _ {
2643
- _parse(e) {
2644
- return this._getType(e) === f.undefined ? I(void 0) : this._def.innerType._parse(e);
2645
- }
2646
- unwrap() {
2647
- return this._def.innerType;
2648
- }
2649
- }
2650
- j.create = (n, e) => new j({
2651
- innerType: n,
2652
- typeName: g.ZodOptional,
2653
- ...v(e)
2654
- });
2655
- class U extends _ {
2656
- _parse(e) {
2657
- return this._getType(e) === f.null ? I(null) : this._def.innerType._parse(e);
2658
- }
2659
- unwrap() {
2660
- return this._def.innerType;
2661
- }
2662
- }
2663
- U.create = (n, e) => new U({
2664
- innerType: n,
2665
- typeName: g.ZodNullable,
2666
- ...v(e)
2667
- });
2668
- class pe extends _ {
2669
- _parse(e) {
2670
- const { ctx: t } = this._processInputParams(e);
2671
- let r = t.data;
2672
- return t.parsedType === f.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
2673
- data: r,
2674
- path: t.path,
2675
- parent: t
2676
- });
2677
- }
2678
- removeDefault() {
2679
- return this._def.innerType;
2680
- }
2681
- }
2682
- pe.create = (n, e) => new pe({
2683
- innerType: n,
2684
- typeName: g.ZodDefault,
2685
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2686
- ...v(e)
2687
- });
2688
- class he extends _ {
2689
- _parse(e) {
2690
- const { ctx: t } = this._processInputParams(e), r = {
2691
- ...t,
2692
- common: {
2693
- ...t.common,
2694
- issues: []
2695
- }
2696
- }, s = this._def.innerType._parse({
2697
- data: r.data,
2698
- path: r.path,
2699
- parent: {
2700
- ...r
2701
- }
2702
- });
2703
- return se(s) ? s.then((a) => ({
2704
- status: "valid",
2705
- value: a.status === "valid" ? a.value : this._def.catchValue({
2706
- get error() {
2707
- return new S(r.common.issues);
2708
- },
2709
- input: r.data
2710
- })
2711
- })) : {
2712
- status: "valid",
2713
- value: s.status === "valid" ? s.value : this._def.catchValue({
2714
- get error() {
2715
- return new S(r.common.issues);
2716
- },
2717
- input: r.data
2718
- })
2719
- };
2720
- }
2721
- removeCatch() {
2722
- return this._def.innerType;
2723
- }
2724
- }
2725
- he.create = (n, e) => new he({
2726
- innerType: n,
2727
- typeName: g.ZodCatch,
2728
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2729
- ...v(e)
2730
- });
2731
- class Te extends _ {
2732
- _parse(e) {
2733
- if (this._getType(e) !== f.nan) {
2734
- const r = this._getOrReturnCtx(e);
2735
- return m(r, {
2736
- code: u.invalid_type,
2737
- expected: f.nan,
2738
- received: r.parsedType
2739
- }), y;
2740
- }
2741
- return { status: "valid", value: e.data };
2742
- }
2743
- }
2744
- Te.create = (n) => new Te({
2745
- typeName: g.ZodNaN,
2746
- ...v(n)
2747
- });
2748
- const Dt = Symbol("zod_brand");
2749
- class Ee extends _ {
2750
- _parse(e) {
2751
- const { ctx: t } = this._processInputParams(e), r = t.data;
2752
- return this._def.type._parse({
2753
- data: r,
2754
- path: t.path,
2755
- parent: t
2756
- });
2757
- }
2758
- unwrap() {
2759
- return this._def.type;
2760
- }
2761
- }
2762
- class ye extends _ {
2763
- _parse(e) {
2764
- const { status: t, ctx: r } = this._processInputParams(e);
2765
- if (r.common.async)
2766
- return (async () => {
2767
- const a = await this._def.in._parseAsync({
2768
- data: r.data,
2769
- path: r.path,
2770
- parent: r
2771
- });
2772
- return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), Y(a.value)) : this._def.out._parseAsync({
2773
- data: a.value,
2774
- path: r.path,
2775
- parent: r
2776
- });
2777
- })();
2778
- {
2779
- const s = this._def.in._parseSync({
2780
- data: r.data,
2781
- path: r.path,
2782
- parent: r
2783
- });
2784
- return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), {
2785
- status: "dirty",
2786
- value: s.value
2787
- }) : this._def.out._parseSync({
2788
- data: s.value,
2789
- path: r.path,
2790
- parent: r
2791
- });
2792
- }
2793
- }
2794
- static create(e, t) {
2795
- return new ye({
2796
- in: e,
2797
- out: t,
2798
- typeName: g.ZodPipeline
2799
- });
2800
- }
2801
- }
2802
- class ge extends _ {
2803
- _parse(e) {
2804
- const t = this._def.innerType._parse(e), r = (s) => (q(s) && (s.value = Object.freeze(s.value)), s);
2805
- return se(t) ? t.then((s) => r(s)) : r(t);
2806
- }
2807
- unwrap() {
2808
- return this._def.innerType;
2809
- }
2810
- }
2811
- ge.create = (n, e) => new ge({
2812
- innerType: n,
2813
- typeName: g.ZodReadonly,
2814
- ...v(e)
2815
- });
2816
- function $e(n, e) {
2817
- const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
2818
- return typeof t == "string" ? { message: t } : t;
2819
- }
2820
- function We(n, e = {}, t) {
2821
- return n ? H.create().superRefine((r, s) => {
2822
- var a, o;
2823
- const c = n(r);
2824
- if (c instanceof Promise)
2825
- return c.then((l) => {
2826
- var d, p;
2827
- if (!l) {
2828
- const b = $e(e, r), w = (p = (d = b.fatal) !== null && d !== void 0 ? d : t) !== null && p !== void 0 ? p : !0;
2829
- s.addIssue({ code: "custom", ...b, fatal: w });
2830
- }
2831
- });
2832
- if (!c) {
2833
- const l = $e(e, r), d = (o = (a = l.fatal) !== null && a !== void 0 ? a : t) !== null && o !== void 0 ? o : !0;
2834
- s.addIssue({ code: "custom", ...l, fatal: d });
2835
- }
2836
- }) : H.create();
2837
- }
2838
- const jt = {
2839
- object: k.lazycreate
2840
- };
2841
- var g;
2842
- (function(n) {
2843
- n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
2844
- })(g || (g = {}));
2845
- const Ot = (n, e = {
2846
- message: `Input not instance of ${n.name}`
2847
- }) => We((t) => t instanceof n, e), Qe = N.create, Ye = V.create, Et = Te.create, Pt = F.create, Je = ae.create, Rt = B.create, Mt = xe.create, $t = ie.create, Vt = oe.create, Ft = H.create, zt = L.create, Ut = $.create, Lt = ke.create, qt = C.create, Bt = k.create, Wt = k.strictCreate, Qt = ce.create, Yt = Ie.create, Jt = de.create, Xt = E.create, Ht = ue.create, Gt = we.create, Kt = W.create, en = J.create, tn = le.create, nn = me.create, rn = z.create, sn = fe.create, an = G.create, Ve = Z.create, on = j.create, cn = U.create, dn = Z.createWithPreprocess, un = ye.create, ln = () => Qe().optional(), mn = () => Ye().optional(), fn = () => Je().optional(), pn = {
2848
- string: (n) => N.create({ ...n, coerce: !0 }),
2849
- number: (n) => V.create({ ...n, coerce: !0 }),
2850
- boolean: (n) => ae.create({
2851
- ...n,
2852
- coerce: !0
2853
- }),
2854
- bigint: (n) => F.create({ ...n, coerce: !0 }),
2855
- date: (n) => B.create({ ...n, coerce: !0 })
2856
- }, hn = y;
2857
- var i = /* @__PURE__ */ Object.freeze({
2858
- __proto__: null,
2859
- defaultErrorMap: X,
2860
- setErrorMap: ct,
2861
- getErrorMap: ve,
2862
- makeIssue: _e,
2863
- EMPTY_PATH: dt,
2864
- addIssueToContext: m,
2865
- ParseStatus: T,
2866
- INVALID: y,
2867
- DIRTY: Y,
2868
- OK: I,
2869
- isAborted: De,
2870
- isDirty: je,
2871
- isValid: q,
2872
- isAsync: se,
2873
- get util() {
2874
- return x;
2875
- },
2876
- get objectUtil() {
2877
- return Ze;
2878
- },
2879
- ZodParsedType: f,
2880
- getParsedType: R,
2881
- ZodType: _,
2882
- datetimeRegex: qe,
2883
- ZodString: N,
2884
- ZodNumber: V,
2885
- ZodBigInt: F,
2886
- ZodBoolean: ae,
2887
- ZodDate: B,
2888
- ZodSymbol: xe,
2889
- ZodUndefined: ie,
2890
- ZodNull: oe,
2891
- ZodAny: H,
2892
- ZodUnknown: L,
2893
- ZodNever: $,
2894
- ZodVoid: ke,
2895
- ZodArray: C,
2896
- ZodObject: k,
2897
- ZodUnion: ce,
2898
- ZodDiscriminatedUnion: Ie,
2899
- ZodIntersection: de,
2900
- ZodTuple: E,
2901
- ZodRecord: ue,
2902
- ZodMap: we,
2903
- ZodSet: W,
2904
- ZodFunction: J,
2905
- ZodLazy: le,
2906
- ZodLiteral: me,
2907
- ZodEnum: z,
2908
- ZodNativeEnum: fe,
2909
- ZodPromise: G,
2910
- ZodEffects: Z,
2911
- ZodTransformer: Z,
2912
- ZodOptional: j,
2913
- ZodNullable: U,
2914
- ZodDefault: pe,
2915
- ZodCatch: he,
2916
- ZodNaN: Te,
2917
- BRAND: Dt,
2918
- ZodBranded: Ee,
2919
- ZodPipeline: ye,
2920
- ZodReadonly: ge,
2921
- custom: We,
2922
- Schema: _,
2923
- ZodSchema: _,
2924
- late: jt,
2925
- get ZodFirstPartyTypeKind() {
2926
- return g;
2927
- },
2928
- coerce: pn,
2929
- any: Ft,
2930
- array: qt,
2931
- bigint: Pt,
2932
- boolean: Je,
2933
- date: Rt,
2934
- discriminatedUnion: Yt,
2935
- effect: Ve,
2936
- enum: rn,
2937
- function: en,
2938
- instanceof: Ot,
2939
- intersection: Jt,
2940
- lazy: tn,
2941
- literal: nn,
2942
- map: Gt,
2943
- nan: Et,
2944
- nativeEnum: sn,
2945
- never: Ut,
2946
- null: Vt,
2947
- nullable: cn,
2948
- number: Ye,
2949
- object: Bt,
2950
- oboolean: fn,
2951
- onumber: mn,
2952
- optional: on,
2953
- ostring: ln,
2954
- pipeline: un,
2955
- preprocess: dn,
2956
- promise: an,
2957
- record: Ht,
2958
- set: Kt,
2959
- strictObject: Wt,
2960
- string: Qe,
2961
- symbol: Mt,
2962
- transformer: Ve,
2963
- tuple: Xt,
2964
- undefined: $t,
2965
- union: Qt,
2966
- unknown: zt,
2967
- void: Lt,
2968
- NEVER: hn,
2969
- ZodIssueCode: u,
2970
- quotelessJson: ot,
2971
- ZodError: S
2972
- });
2973
- const gn = i.object({
2974
- country: i.string().optional(),
2975
- city: i.string().optional(),
2976
- street: i.string().optional(),
2977
- streetNumber: i.string().optional(),
2978
- floor: i.string().optional(),
2979
- apartmentEnterNumber: i.string().optional(),
2980
- apartmentNumber: i.string().optional()
2981
- }), M = i.string().min(1, { message: "שדה חובה" }), En = i.string().regex(/^\d+$/, "Must be a numeric string"), Pn = i.object({ url: i.string().url(), id: i.string() });
2982
- function Rn(n) {
2983
- return !!(n != null && n.url);
2984
- }
2985
- const re = i.object({
2986
- lang: i.enum(["he"]),
2987
- value: i.string()
2988
- }), Mn = i.array(re), Xe = i.object({
2989
- id: i.string().min(1),
2990
- companyId: i.string().min(1),
2991
- storeId: i.string().min(1),
2992
- parentId: i.string().nullish(),
2993
- tag: i.string().optional(),
2994
- locales: i.array(re),
2995
- depth: i.number()
2996
- }), Pe = Xe.extend({
2997
- children: i.lazy(() => Pe.array())
2998
- }), $n = Xe.extend({
2999
- index: i.number(),
3000
- depth: i.number(),
3001
- collapsed: i.boolean().optional(),
3002
- children: i.array(Pe)
3003
- }), ee = i.string().min(1), He = i.object({
3004
- type: i.literal("Product"),
3005
- storeId: ee,
3006
- companyId: ee,
3007
- id: ee,
3008
- objectID: ee,
3009
- sku: ee,
3010
- name: i.array(re),
3011
- description: i.array(re),
3012
- isPublished: i.boolean(),
3013
- vat: i.boolean(),
3014
- priceType: i.object({
3015
- type: i.enum(["unit", "kg", "gram", "liter", "ml"]),
3016
- value: i.number()
3017
- }),
3018
- price: i.number().positive(),
3019
- purchasePrice: i.number().optional(),
3020
- profitPercentage: i.number().optional(),
3021
- currency: i.literal("ILS"),
3022
- discount: i.object({
3023
- type: i.enum(["number", "percent", "none"]),
3024
- value: i.number()
3025
- }),
3026
- isDiscountable: i.boolean({ description: "included in store discounts" }).optional(),
3027
- weight: i.object({
3028
- value: i.number(),
3029
- unit: i.enum(["kg", "gram", "none"])
3030
- }),
3031
- volume: i.object({
3032
- value: i.number(),
3033
- unit: i.enum(["liter", "ml", "none"])
3034
- }),
3035
- images: i.array(i.object({ url: i.string().url(), id: i.string() })),
3036
- manufacturer: i.string(),
3037
- brand: i.string(),
3038
- importer: i.string(),
3039
- supplier: i.string(),
3040
- ingredients: i.array(re),
3041
- created_at: i.number(),
3042
- updated_at: i.number(),
3043
- categoryIds: i.array(i.string().nonempty()),
3044
- // @deprecated
3045
- categoryList: i.array(Pe).optional(),
3046
- // @deprecated
3047
- categories: i.object({
3048
- lvl0: i.array(i.string()),
3049
- lvl1: i.array(i.string()),
3050
- lvl2: i.array(i.string()),
3051
- lvl3: i.array(i.string()),
3052
- lvl4: i.array(i.string())
3053
- }).optional(),
3054
- // @deprecated
3055
- categoryNames: i.array(i.string()).optional()
3056
- }), Vn = He.extend({
3057
- image: i.instanceof(File).optional()
3058
- }), Ge = i.object({
3059
- product: He,
3060
- originalPrice: i.number().optional(),
3061
- finalPrice: i.number().optional(),
3062
- finalDiscount: i.number().optional(),
3063
- amount: i.number().positive({ message: "Quantity must be a positive number." })
3064
- }), Fn = i.object({
3065
- type: i.literal("Cart"),
3066
- id: i.string().uuid(),
3067
- companyId: i.string().uuid(),
3068
- storeId: i.string().uuid(),
3069
- userId: i.string().uuid(),
3070
- status: i.enum(["active", "draft", "completed"]),
3071
- items: i.array(Ge)
3072
- }), zn = i.object({
3073
- id: i.string(),
3074
- name: i.string(),
3075
- websiteDomains: i.array(i.string())
3076
- }), Un = i.object({
3077
- type: i.literal("FavoriteProduct"),
3078
- id: i.string().uuid(),
3079
- companyId: i.string().uuid(),
3080
- storeId: i.string().uuid(),
3081
- userId: i.string().uuid(),
3082
- productId: i.string().uuid()
3083
- }), Ke = i.enum(["default", "delayed"], {
3084
- description: "delayed is J5 transaction"
3085
- }), yn = i.object({
3086
- type: i.literal("Profile"),
3087
- id: M,
3088
- companyId: M,
3089
- storeId: M,
3090
- tenantId: M,
3091
- clientType: i.enum(["user", "company"]),
3092
- companyName: i.string().optional(),
3093
- displayName: M,
3094
- email: i.string().email(),
3095
- phoneNumber: i.string().optional(),
3096
- address: gn.optional(),
3097
- isAnonymous: i.boolean(),
3098
- createdDate: i.number(),
3099
- lastActivityDate: i.number(),
3100
- paymentType: Ke,
3101
- organizationId: i.string().optional().nullable()
3102
- });
3103
- function Ln() {
3104
- return {
3105
- type: "Profile",
3106
- id: "",
3107
- companyId: "",
3108
- storeId: "",
3109
- tenantId: "",
3110
- clientType: "user",
3111
- displayName: "",
3112
- email: "",
3113
- phoneNumber: "",
3114
- address: {
3115
- country: "",
3116
- city: "",
3117
- street: "",
3118
- streetNumber: "",
3119
- floor: "",
3120
- apartmentEnterNumber: "",
3121
- apartmentNumber: ""
3122
- },
3123
- createdDate: 0,
3124
- lastActivityDate: 0,
3125
- isAnonymous: !0,
3126
- paymentType: Ke.Values.default
3127
- };
3128
- }
3129
- const et = i.object({
3130
- _COMMENT: i.string().optional(),
3131
- transaction_id: i.string(),
3132
- date: i.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
3133
- currency: i.string().length(3, "Currency must be 3 characters"),
3134
- rate: i.number().positive(),
3135
- vat: i.string().regex(/^\d+\.\d{2}$/, "VAT must be in format XX.XX"),
3136
- vat_price: i.number().positive(),
3137
- price_discount: i.number(),
3138
- price_discount_in_currency: i.number(),
3139
- price_total: i.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
3140
- price_total_in_currency: i.number().positive()
3141
- }), vn = i.object({
3142
- doc_uuid: i.string().uuid("Document UUID must be a valid UUID"),
3143
- pdf_link: i.string().url("PDF link must be a valid URL"),
3144
- pdf_link_copy: i.string().url("PDF copy link must be a valid URL"),
3145
- doc_number: i.string().min(1, "Document number is required"),
3146
- sent_mails: i.array(i.string().email("Each email must be valid")),
3147
- success: i.boolean(),
3148
- ua_uuid: i.string().uuid("UA UUID must be a valid UUID"),
3149
- calculatedData: et,
3150
- warning: i.string().optional(),
3151
- date: i.number().optional()
3152
- }), _n = i.object({
3153
- id: i.string().min(1, "ID is required"),
3154
- number: i.string().min(1, "Number is required"),
3155
- date: i.number().min(1, "Date is required"),
3156
- createdAt: i.number().min(1, "Created at is required"),
3157
- status: i.enum(["pending", "paid", "cancelled"]),
3158
- companyDetails: i.object({
3159
- name: i.string().min(1, "Name is required").optional(),
3160
- address: i.string().min(1, "Address is required").optional(),
3161
- phone: i.string().min(1, "Phone is required").optional(),
3162
- email: i.string().email("Email must be valid").optional()
3163
- }).optional(),
3164
- clientDetails: i.object({
3165
- name: i.string().min(1, "Name is required").optional(),
3166
- address: i.string().min(1, "Address is required").optional(),
3167
- phone: i.string().min(1, "Phone is required").optional(),
3168
- email: i.string().email("Email must be valid").optional()
3169
- }).optional(),
3170
- items: i.array(
3171
- i.object({
3172
- name: i.string().min(1, "Name is required").optional(),
3173
- price: i.number().min(1, "Price is required").optional(),
3174
- quantity: i.number().min(1, "Quantity is required").optional(),
3175
- total: i.number().min(1, "Total is required").optional()
3176
- })
3177
- ).optional(),
3178
- total: i.number().min(1, "Total is required").optional(),
3179
- vat: i.number().min(1, "VAT is required").optional(),
3180
- link: i.string().url("Link must be a valid URL").optional()
3181
- }), tt = i.object({
3182
- number: i.string(),
3183
- name: i.string(),
3184
- id: i.string()
3185
- }), bn = i.object({
3186
- id: i.string(),
3187
- name: i.string(),
3188
- discountPercentage: i.number().positive().min(0).max(100).optional(),
3189
- nameOnInvoice: i.string().optional(),
3190
- billingAccounts: i.array(tt),
3191
- paymentType: i.enum(["default", "delayed"])
3192
- }), qn = bn.omit({ id: !0 }), xn = i.object({
3193
- doc_uuid: i.string().uuid("Document UUID must be a valid UUID"),
3194
- pdf_link: i.string().url("PDF link must be a valid URL"),
3195
- pdf_link_copy: i.string().url("PDF copy link must be a valid URL"),
3196
- doc_number: i.string().min(1, "Document number is required"),
3197
- sent_mails: i.array(i.string().email("Each email must be valid")),
3198
- success: i.boolean(),
3199
- ua_uuid: i.string().uuid("UA UUID must be a valid UUID"),
3200
- calculatedData: et,
3201
- warning: i.string().optional(),
3202
- date: i.number().optional()
3203
- }), kn = i.object({
3204
- id: i.string().min(1, "ID is required"),
3205
- number: i.string().min(1, "Number is required"),
3206
- date: i.string().min(1, "Date is required"),
3207
- createdAt: i.number().min(1, "Created at is required"),
3208
- status: i.enum(["pending", "paid", "cancelled"]),
3209
- companyDetails: i.object({
3210
- name: i.string().min(1, "Name is required").optional(),
3211
- address: i.string().min(1, "Address is required").optional(),
3212
- phone: i.string().min(1, "Phone is required").optional(),
3213
- email: i.string().email("Email must be valid").optional()
3214
- }).optional(),
3215
- clientDetails: i.object({
3216
- name: i.string().min(1, "Name is required").optional(),
3217
- address: i.string().min(1, "Address is required").optional(),
3218
- phone: i.string().min(1, "Phone is required").optional(),
3219
- email: i.string().email("Email must be valid").optional()
3220
- }).optional(),
3221
- items: i.array(
3222
- i.object({
3223
- name: i.string().min(1, "Name is required").optional(),
3224
- price: i.number().min(1, "Price is required").optional(),
3225
- quantity: i.number().min(1, "Quantity is required").optional(),
3226
- total: i.number().min(1, "Total is required").optional()
3227
- })
3228
- ).optional(),
3229
- total: i.number().min(1, "Total is required").optional(),
3230
- vat: i.number().min(1, "VAT is required").optional(),
3231
- link: i.string().url("Link must be a valid URL").optional()
3232
- }), Bn = i.object({
3233
- type: i.literal("Order"),
3234
- id: M,
3235
- companyId: M,
3236
- storeId: M,
3237
- userId: M,
3238
- status: i.enum([
3239
- "draft",
3240
- // before payment
3241
- "pending",
3242
- // after payment
3243
- "processing",
3244
- // after admin approve
3245
- "in_delivery",
3246
- //
3247
- "delivered",
3248
- "cancelled",
3249
- "completed",
3250
- "refunded"
3251
- ]),
3252
- paymentType: i.enum(["internal", "external"]).optional(),
3253
- paymentStatus: i.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
3254
- //todo check if hyp support partial refund
3255
- cart: i.object({
3256
- id: i.string(),
3257
- items: i.array(Ge),
3258
- cartDiscount: i.number(),
3259
- cartTotal: i.number(),
3260
- cartVat: i.number(),
3261
- deliveryPrice: i.number().optional()
3262
- // final delivery price for cart
3263
- }),
3264
- storeOptions: i.object({
3265
- deliveryPrice: i.number().optional(),
3266
- freeDeliveryPrice: i.number().optional(),
3267
- isVatIncludedInPrice: i.boolean().optional()
3268
- }).optional(),
3269
- orderDeliveryPrice: i.number().optional(),
3270
- // delivery price for order
3271
- originalAmount: i.number().positive().optional(),
3272
- // what client pay
3273
- actualAmount: i.number().positive().optional(),
3274
- // what store charge
3275
- date: i.number(),
3276
- deliveryDate: i.coerce.number(),
3277
- client: yn.required({}),
3278
- nameOnInvoice: i.string().optional(),
3279
- clientComment: i.string().optional(),
3280
- organizationId: i.string().optional(),
3281
- billingAccount: tt.optional(),
3282
- deliveryNote: _n.optional(),
3283
- invoice: kn.optional(),
3284
- ezInvoice: xn.optional(),
3285
- ezDeliveryNote: vn.optional()
3286
- }), wn = i.enum(["individual", "company"]), Wn = i.object({
3287
- id: i.string(),
3288
- companyId: i.string(),
3289
- name: i.string(),
3290
- urls: i.array(i.string()),
3291
- logoUrl: i.string(),
3292
- tenantId: i.string(),
3293
- // firebase auth tenantId
3294
- paymentType: i.enum(["external", "j5"]),
3295
- allowAnonymousClients: i.boolean(),
3296
- isVatIncludedInPrice: i.boolean(),
3297
- clientTypes: i.array(wn),
3298
- minimumOrder: i.number().optional(),
3299
- freeDeliveryPrice: i.number().optional(),
3300
- deliveryPrice: i.number().optional()
3301
- }), Tn = i.object({
3302
- minSpend: i.number().positive().optional(),
3303
- stackable: i.boolean().default(!1)
3304
- }).optional(), In = i.discriminatedUnion("variantType", [
3305
- i.object({
3306
- variantType: i.literal("bundle"),
3307
- productsId: i.array(i.string().nonempty()).min(1),
3308
- // Which products are included
3309
- requiredQuantity: i.number().positive(),
3310
- // How many items needed (e.g., 3)
3311
- bundlePrice: i.number().positive()
3312
- // Total price for the bundle (e.g., $25)
3313
- })
3314
- ]), Qn = i.object({
3315
- type: i.literal("Discount"),
3316
- storeId: i.string().min(1),
3317
- companyId: i.string().min(1),
3318
- id: i.string().min(1),
3319
- name: i.array(i.object({ lang: i.enum(["he"]), value: i.string().nonempty() })),
3320
- active: i.boolean(),
3321
- startDate: i.number(),
3322
- endDate: i.number(),
3323
- variant: In,
3324
- conditions: Tn
3325
- });
3326
- class An {
3327
- canApply(e, t) {
3328
- if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
3329
- const { productsId: r, requiredQuantity: s } = e.variant;
3330
- return this.getTotalQuantity(t.cart, r) >= s;
3331
- }
3332
- calculate(e, t) {
3333
- if (e.variant.variantType !== "bundle")
3334
- return { applicable: !1, discountAmount: 0, affectedItems: [] };
3335
- const { productsId: r, requiredQuantity: s, bundlePrice: a } = e.variant, o = t.cart.filter((K) => r.includes(K.product.id)), c = this.getTotalQuantity(t.cart, r), l = Math.floor(c / s);
3336
- if (l === 0)
3337
- return { applicable: !1, discountAmount: 0, affectedItems: [] };
3338
- const d = this.calculateOriginalPrice(o), p = this.getTotalQuantity(t.cart, r), b = this.calculateDiscountedPrice(
3339
- d,
3340
- a,
3341
- l,
3342
- s,
3343
- p
3344
- ), w = d - b, A = this.distributeDiscount(o, w, d);
3345
- return {
3346
- applicable: !0,
3347
- discountAmount: Number(w.toFixed(2)),
3348
- affectedItems: A
3349
- };
3350
- }
3351
- isDiscountActive(e) {
3352
- const t = Date.now();
3353
- return e.active && e.startDate <= t && e.endDate >= t;
3354
- }
3355
- getTotalQuantity(e, t) {
3356
- return e.filter((r) => t.includes(r.product.id)).reduce((r, s) => r + s.amount, 0);
3357
- }
3358
- calculateOriginalPrice(e) {
3359
- return e.reduce((t, r) => t + r.product.price * r.amount, 0);
3360
- }
3361
- calculateDiscountedPrice(e, t, r, s, a) {
3362
- const o = t * r, c = r * s, d = Math.max(0, a - c) / a * e;
3363
- return o + d;
3364
- }
3365
- distributeDiscount(e, t, r) {
3366
- const s = t / r;
3367
- return e.map((a) => {
3368
- const o = a.product.price * a.amount * s;
3369
- return {
3370
- productId: a.product.id,
3371
- quantity: a.amount,
3372
- originalPrice: Number(a.product.price.toFixed(2)),
3373
- discountedPrice: Number((a.product.price - o / a.amount).toFixed(2)),
3374
- discountAmount: Number(o.toFixed(2))
3375
- };
3376
- });
3377
- }
3378
- }
3379
- class nt {
3380
- static getStrategy(e) {
3381
- return this.strategies.get(e.variant.variantType) || null;
3382
- }
3383
- static registerStrategy(e, t) {
3384
- this.strategies.set(e, t);
3385
- }
3386
- static getRegisteredTypes() {
3387
- return Array.from(this.strategies.keys());
3388
- }
3389
- static clearStrategies() {
3390
- this.strategies.clear();
3391
- }
3392
- }
3393
- Re(nt, "strategies", /* @__PURE__ */ new Map([
3394
- ["bundle", new An()]
3395
- ]));
3396
- class Sn {
3397
- static calculateDiscounts(e, t, r) {
3398
- var d, p;
3399
- const s = {
3400
- cart: e,
3401
- user: r,
3402
- appliedDiscounts: []
3403
- }, a = this.filterActiveDiscounts(t), o = [];
3404
- for (const b of a) {
3405
- const w = nt.getStrategy(b);
3406
- if (!w || !w.canApply(b, s) || !((d = b.conditions) != null && d.stackable) && o.length > 0) continue;
3407
- const A = w.calculate(b, s);
3408
- A.applicable && (o.push({
3409
- discountId: b.id,
3410
- discountName: ((p = b.name[0]) == null ? void 0 : p.value) || "Discount",
3411
- discountAmount: Number(A.discountAmount.toFixed(2)),
3412
- affectedItems: A.affectedItems
3413
- }), s.appliedDiscounts = o);
3414
- }
3415
- const c = this.calculateFinalPrices(e, o), l = o.reduce(
3416
- (b, w) => b + w.discountAmount,
3417
- 0
3418
- );
3419
- return {
3420
- items: c,
3421
- totalDiscount: Number(l.toFixed(2)),
3422
- appliedDiscounts: o
3423
- };
3424
- }
3425
- static filterActiveDiscounts(e) {
3426
- const t = Date.now();
3427
- return e.filter(
3428
- (r) => r.active && r.startDate <= t && r.endDate >= t
3429
- );
3430
- }
3431
- static calculateFinalPrices(e, t) {
3432
- return e.map((r) => {
3433
- const s = t.filter(
3434
- (l) => l.affectedItems.some((d) => d.productId === r.product.id)
3435
- ), a = s.reduce((l, d) => {
3436
- const p = d.affectedItems.find(
3437
- (b) => b.productId === r.product.id
3438
- );
3439
- return l + ((p == null ? void 0 : p.discountAmount) || 0);
3440
- }, 0), o = a / r.amount, c = r.product.price - o;
3441
- return {
3442
- amount: r.amount,
3443
- product: r.product,
3444
- originalPrice: Number(r.product.price.toFixed(2)),
3445
- finalPrice: Number(Math.max(0, c).toFixed(2)),
3446
- finalDiscount: Number(a.toFixed(2)),
3447
- appliedDiscounts: s.map((l) => l.discountId)
3448
- };
3449
- });
3450
- }
3451
- static isDiscountActive(e) {
3452
- const t = Date.now();
3453
- return e.active && e.startDate <= t && e.endDate >= t;
3454
- }
3455
- static getActiveDiscounts(e) {
3456
- return this.filterActiveDiscounts(e);
3457
- }
3458
- }
3459
- function rt(n) {
3460
- return Number(n.toFixed(2));
3461
- }
3462
- function Yn(n) {
3463
- return n.toFixed(2);
3464
- }
3465
- function Jn(n) {
3466
- return Math.max(0, rt(n));
3467
- }
3468
- function Xn(n, e) {
3469
- if (n <= 0) return 0;
3470
- const t = n - e;
3471
- return rt(t / n * 100);
3472
- }
3473
- const Ce = {
3474
- VAT: 18
3475
- };
3476
- function Nn(n) {
3477
- var e, t;
3478
- return ((e = n.discount) == null ? void 0 : e.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((t = n.discount) == null ? void 0 : t.type) === "number" ? n.discount.value ?? 0 : 0;
3479
- }
3480
- function Cn(n) {
3481
- var e, t;
3482
- if (((e = n.discount) == null ? void 0 : e.type) === "percent") {
3483
- const r = n.price * n.discount.value / 100;
3484
- return n.price - r;
3485
- }
3486
- return ((t = n.discount) == null ? void 0 : t.type) === "number" ? n.price - n.discount.value : n.price;
3487
- }
3488
- function Hn({
3489
- cart: n,
3490
- discounts: e,
3491
- deliveryPrice: t = 0,
3492
- freeDeliveryPrice: r = 0,
3493
- isVatIncludedInPrice: s = !1
3494
- }) {
3495
- const a = n.map((d) => ({
3496
- amount: d.amount,
3497
- product: {
3498
- id: d.product.id,
3499
- price: d.product.price
3500
- }
3501
- })), o = Sn.calculateDiscounts(a, e), c = n.map((d, p) => {
3502
- const b = o.items[p];
3503
- return {
3504
- amount: d.amount,
3505
- product: { ...d.product },
3506
- originalPrice: d.product.price,
3507
- finalPrice: b ? b.finalPrice : Cn(d.product),
3508
- finalDiscount: b ? b.finalDiscount : Nn(d.product)
3509
- };
3510
- }), l = c.reduce(
3511
- (d, p) => {
3512
- const { product: b, amount: w, finalPrice: A, finalDiscount: K } = p;
3513
- let D = 0;
3514
- if (b.vat) {
3515
- let Se = 0;
3516
- if (s) {
3517
- const st = A * (Ce.VAT / (100 + Ce.VAT));
3518
- D = Number(st.toFixed(2)), D = D * w, Se = Number(D.toFixed(2));
3519
- } else
3520
- D = A * Ce.VAT / 100, D = D * w, Se = Number(D.toFixed(2));
3521
- d.vat = Number((d.vat + Se).toFixed(2));
3522
- }
3523
- const Ae = Number(A.toFixed(2));
3524
- return d.cost += w * Ae, d.discount += K && w * K, d.finalCost += w * Ae + (s ? 0 : D), d.productsCost += w * Ae + (s ? 0 : D), d.cost = Number(d.cost.toFixed(2)), d.discount = Number(d.discount.toFixed(2)), d.finalCost = Number(d.finalCost.toFixed(2)), d.productsCost = Number(d.productsCost.toFixed(2)), d;
3525
- },
3526
- {
3527
- discount: 0,
3528
- cost: 0,
3529
- finalCost: 0,
3530
- vat: 0,
3531
- productsCost: 0,
3532
- deliveryPrice: t
3533
- }
3534
- );
3535
- return l.deliveryPrice && l.productsCost >= r ? l.deliveryPrice = 0 : l.finalCost += l.deliveryPrice, console.log("cartDetails", l), { items: c, ...l };
3536
- }
3537
- const Zn = {
3538
- stores: "STORES",
3539
- companies: "COMPANIES"
3540
- }, Dn = {
3541
- products: "products",
3542
- profiles: "profiles",
3543
- cart: "cart",
3544
- clients: "clients",
3545
- orders: "orders",
3546
- categories: "categories",
3547
- favorites: "favorites",
3548
- payments: "payments",
3549
- settings: "settings",
3550
- discounts: "discounts",
3551
- organizations: "organizations",
3552
- invoices: "invoices"
3553
- }, jn = {
3554
- systemCollections: Zn,
3555
- storeCollections: Dn,
3556
- // for client and server
3557
- getPath: ({
3558
- companyId: n,
3559
- storeId: e,
3560
- collectionName: t,
3561
- id: r
3562
- }) => `${n}/${e}/${t}${r ? `/${r}` : ""}`,
3563
- // for firestore events
3564
- getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`
3565
- }, Gn = {
3566
- firestore: jn
3567
- };
3568
- export {
3569
- gn as AddressSchema,
3570
- Xe as BaseCategorySchema,
3571
- tt as BillingAccountSchema,
3572
- An as BundleDiscountStrategy,
3573
- et as CalculatedDataSchema,
3574
- Ge as CartItemProductSchema,
3575
- Fn as CartSchema,
3576
- Pe as CategorySchema,
3577
- zn as CompanySchema,
3578
- _n as DeliveryNoteSchema,
3579
- Tn as DiscountConditionsSchema,
3580
- Sn as DiscountEngine,
3581
- Qn as DiscountSchema,
3582
- nt as DiscountStrategyFactory,
3583
- In as DiscountVariantSchema,
3584
- vn as EzDeliveryNoteSchema,
3585
- Un as FavoriteProductSchema,
3586
- Pn as FileSchema,
3587
- Gn as FirebaseAPI,
3588
- re as LocaleSchema,
3589
- Mn as LocaleValueSchema,
3590
- qn as NewOrganizationSchema,
3591
- Vn as NewProductSchema,
3592
- Bn as OrderSchema,
3593
- bn as OrganizationSchema,
3594
- He as ProductSchema,
3595
- Ke as ProfilePaymentTypeSchema,
3596
- yn as ProfileSchema,
3597
- Wn as StoreSchema,
3598
- $n as TFlattenCategorySchema,
3599
- Xn as calculatePercentageDiscount,
3600
- wn as clientTypesSchema,
3601
- Ln as createEmptyProfile,
3602
- Jn as ensureNonNegative,
3603
- rt as formatCurrency,
3604
- Yn as formatCurrencyString,
3605
- Hn as getCartCost,
3606
- Rn as isFile,
3607
- M as notEmptyTextSchema,
3608
- En as numericTextSchema
3609
- };
3610
- //# sourceMappingURL=core.es.js.map