schemas/libraries/zod-compiler/download_compiled/bag + mini/unminified.js
function toZod() {
return (schema) => schema;
}
function getEnumValues(entries) {
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
}
function jsonStringifyReplacer(_, value) {
if (typeof value === "bigint") return value.toString();
return value;
}
var Cached = class {
constructor(getter) {
this._getter = getter;
this._value = void 0;
}
get value() {
const getter = this._getter;
if (getter !== void 0) {
this._value = getter();
this._getter = void 0;
}
return this._value;
}
};
function cached(getter) {
return new Cached(getter);
}
function nullish(input) {
return input === null || input === void 0;
}
function cleanRegex(source) {
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
return source.slice(start, end);
}
function assignProp(target, prop, value) {
Object.defineProperty(target, prop, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
function isObject(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
const propertyKeyTypes = new Set([
"string",
"number",
"symbol"
]);
function escapeRegex(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(inst, def, params) {
const cl = new inst._zod.constr(def ?? inst._zod.def);
if (!def || params?.parent) cl._zod.parent = inst;
return cl;
}
function normalizeParams(_params) {
const params = _params;
if (!params) return {};
if (typeof params === "string") return { error: () => params };
if (params?.message !== void 0) {
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
params.error = params.message;
}
delete params.message;
if (typeof params.error === "string") return {
...params,
error: () => params.error
};
return params;
}
function optionalKeys(shape) {
return Object.keys(shape).filter((k) => {
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
});
}
function aborted(x, startIndex = 0) {
if (x.aborted === true) return true;
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
return false;
}
function explicitlyAborted(x, startIndex = 0) {
if (x.aborted === true) return true;
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
return false;
}
function prefixIssues(path, issues) {
return issues.map((iss) => {
var _a;
(_a = iss).path ?? (_a.path = []);
iss.path.unshift(path);
return iss;
});
}
function unwrapMessage(message) {
return typeof message === "string" ? message : message?.message;
}
function sizeCaps(defChecks) {
const caps = [];
for (const ch of defChecks ?? []) {
const d = ch._zod.def;
if (!/_(length|size)$|_equals$/.test(d.check)) break;
const max = d.maximum ?? d.length ?? d.size;
if (max >= 0) caps.push([max, ch]);
}
return caps;
}
function attachSchema(issues, start, inst) {
var _a;
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
}
function finalizeIssue(iss, ctx, config) {
var _a;
const traits = iss.inst?._zod?.traits;
if (traits?.has("$ZodType")) {
if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
else iss.schema = iss.inst;
}
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
const full = {};
for (const k of Object.keys(iss)) {
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
full[k] = iss[k];
}
full.path ?? (full.path = []);
full.message = message;
if (ctx?.reportInput) full.input = iss.input;
return full;
}
const highSurrogate = /[\uD800-\uDBFF]/;
function codePointLength(str) {
const units = str.length;
if (!highSurrogate.test(str)) return units;
let count = units;
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
count--;
i++;
}
return count;
}
function getLengthableOrigin(input) {
if (Array.isArray(input)) return "array";
if (typeof input === "string") return "string";
return "unknown";
}
function members(proto, table) {
for (const key in table) {
const desc = Object.getOwnPropertyDescriptor(table, key);
if (desc.get) Object.defineProperty(proto, key, {
...desc,
enumerable: false
});
else defineBound(proto, key, desc.value);
}
}
function own(inst, key, value, enumerable = true) {
Object.defineProperty(inst, key, {
configurable: true,
writable: true,
enumerable,
value
});
return value;
}
function hide(inst, key, value) {
return own(inst, key, value, false);
}
function defineBound(proto, key, fn) {
Object.defineProperty(proto, key, {
configurable: true,
get() {
return this == null ? fn : own(this, key, fn.bind(this));
},
set(value) {
own(this, key, value);
}
});
}
function claim(inst, sentinel) {
const proto = Object.getPrototypeOf(inst);
return sentinel in proto ? void 0 : proto;
}
let installing;
let broke = false;
const breaker = {
configurable: true,
get() {
broke = true;
}
};
function defineLazyInternal(inst, key, compute) {
const proto = Object.getPrototypeOf(inst._zod);
if (key in proto && installing !== inst._zod) {
installing = void 0;
return;
}
installing = inst._zod;
Object.defineProperty(proto, key, {
configurable: true,
get() {
Object.defineProperty(this, key, breaker);
const outer = broke;
broke = false;
try {
const value = compute(this);
if (broke) delete this[key];
else Object.defineProperty(this, key, {
configurable: true,
writable: true,
value
});
broke = broke || outer;
return value;
} catch (err) {
delete this[key];
broke = broke || outer;
throw err;
}
},
set(value) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
value
});
}
});
}
function installLazyProp(inst, key, make, enumerable) {
const proto = claim(inst, key);
if (!proto) return;
Object.defineProperty(proto, key, {
configurable: true,
get() {
const desc = {
configurable: true,
writable: true,
enumerable,
value: void 0
};
Object.defineProperty(this, key, desc);
desc.value = make(this);
Object.defineProperty(this, key, desc);
return desc.value;
},
set(value) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
enumerable,
value
});
}
});
}
var _a;
const _zodDesc = {
value: void 0,
enumerable: false
};
let _E = "captureStackTrace" in Error ? Error : null;
function newError(Definition) {
const E = _E;
if (E) {
const saved = E.stackTraceLimit;
if (typeof saved === "number") {
try {
E.stackTraceLimit = 0;
} catch {
_E = null;
return new Definition();
}
try {
return new Definition();
} finally {
E.stackTraceLimit = saved;
}
}
}
return new Definition();
}
function $constructor(name, initializer, proto, params) {
const zodProto = {};
function Internals(def) {
this.def = def;
this.constr = _;
this.traits = new Set();
}
Internals.prototype = zodProto;
const protoMembers = proto;
const initialized = protoMembers && new WeakSet();
function init(inst, def) {
if (!inst._zod) {
_zodDesc.value = new Internals(def);
try {
Object.defineProperty(inst, "_zod", _zodDesc);
} finally {
_zodDesc.value = void 0;
}
} else if (inst._zod.traits.has(name)) return;
inst._zod.traits.add(name);
initializer(inst, def);
if (initialized) {
const own = Object.getPrototypeOf(inst);
const ctorProto = inst._zod.constr.prototype;
let up = own;
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
const target = up ?? own;
if (!initialized.has(target)) {
initialized.add(target);
members(target, protoMembers);
}
}
const proto = _.prototype;
for (const k in proto) {
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
if (!(k in inst)) inst[k] = proto[k].bind(inst);
}
}
const Parent = params?.Parent ?? Object;
class Definition extends Parent {}
Object.defineProperty(Definition, "name", { value: name });
function _(def) {
const inst = params?.Parent ? newError(Definition) : this;
init(inst, def);
const deferred = inst._zod.deferred;
if (deferred) {
for (const fn of deferred) fn();
inst._zod.deferred = void 0;
}
const pp = globalThis.__zod_globalConfig?.postProcessor;
if (pp) pp(inst);
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
if (params?.Parent && inst instanceof params.Parent) return true;
return inst?._zod?.traits?.has(name);
} });
Object.defineProperty(_, "name", { value: name });
return _;
}
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
const globalConfig = globalThis.__zod_globalConfig;
function config(newConfig) {
if (newConfig) Object.assign(globalConfig, newConfig);
return globalConfig;
}
function _getMessage() {
const internals = this._zod;
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
return internals.message;
}
function _setMessage(value) {
this._zod.message = value;
}
const _messageDesc = {
get: _getMessage,
set: _setMessage,
enumerable: true,
configurable: true
};
const _issuesDesc = {
value: void 0,
enumerable: false
};
const _installedToString = new WeakSet([Object.prototype, Error.prototype]);
const initializer = (inst, def) => {
inst.name = "$ZodError";
_issuesDesc.value = def;
Object.defineProperty(inst, "issues", _issuesDesc);
_issuesDesc.value = void 0;
Object.defineProperty(inst, "message", _messageDesc);
const proto = Object.getPrototypeOf(inst);
if (!_installedToString.has(proto)) {
_installedToString.add(proto);
Object.defineProperty(proto, "toString", {
configurable: true,
enumerable: false,
get() {
const value = () => this.message;
Object.defineProperty(this, "toString", {
value,
configurable: true,
writable: true
});
return value;
},
set(value) {
Object.defineProperty(this, "toString", {
value,
configurable: true,
writable: true
});
}
});
}
};
const $ZodRealError = $constructor("$ZodError", initializer, void 0, { Parent: Error });
const _parse = (_Err) => {
const fn = (schema, value, _ctx, _params) => {
const ctx = _ctx ? {
..._ctx,
async: false
} : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError();
if (result.issues.length) {
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, _params?.callee ?? fn);
throw e;
}
return result.value;
};
return fn;
};
const parse = _parse($ZodRealError);
const _parseAsync = (_Err) => {
const fn = async (schema, value, _ctx, params) => {
const ctx = _ctx ? {
..._ctx,
async: true
} : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
if (result.issues.length) {
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, params?.callee ?? fn);
throw e;
}
return result.value;
};
return fn;
};
const parseAsync = _parseAsync($ZodRealError);
const _safeParse = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
async: false
} : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError();
return result.issues.length ? failure(_Err, result.issues, ctx) : {
success: true,
data: result.value
};
};
const safeParse = _safeParse($ZodRealError);
function failure(Err, issues, ctx) {
let error;
return {
success: false,
get error() {
if (!error) {
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
issues = void 0;
ctx = void 0;
}
return error;
},
set error(e) {
error = e;
issues = void 0;
ctx = void 0;
}
};
}
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
async: true
} : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
return result.issues.length ? failure(_Err, result.issues, ctx) : {
success: true,
data: result.value
};
};
const safeParseAsync = _safeParseAsync($ZodRealError);
const httpProtocol = /^https?$/;
const anyString = /^[\s\S]{0,}$/;
const number$1 = /^-?\d+(?:\.\d+)?$/;
const $ZodCheck = $constructor("$ZodCheck", (inst, def) => {
var _a;
inst._zod ?? (inst._zod = {});
inst._zod.def = def;
(_a = inst._zod).onattach ?? (_a.onattach = []);
});
const _whenHasLength = (payload) => {
const val = payload.value;
return !nullish(val) && val.length !== void 0;
};
const numericOriginMap = {
number: "number",
bigint: "bigint",
object: "date"
};
const $ZodCheckLessThan = $constructor("$ZodCheckLessThan", (inst, def) => {
$ZodCheck.init(inst, def);
const origin = numericOriginMap[typeof def.value];
inst._zod.check = (payload) => {
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
payload.issues.push({
origin: numericOriginMap[typeof payload.value] ?? origin,
code: "too_big",
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
input: payload.value,
inclusive: def.inclusive,
inst,
continue: !def.abort
});
};
});
const $ZodCheckGreaterThan = $constructor("$ZodCheckGreaterThan", (inst, def) => {
$ZodCheck.init(inst, def);
const origin = numericOriginMap[typeof def.value];
inst._zod.check = (payload) => {
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
payload.issues.push({
origin: numericOriginMap[typeof payload.value] ?? origin,
code: "too_small",
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
input: payload.value,
inclusive: def.inclusive,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMaxLength = $constructor("$ZodCheckMaxLength", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
inst._zod.check = (payload) => {
const input = payload.value;
const units = input.length;
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
const origin = getLengthableOrigin(input);
payload.issues.push({
origin,
code: "too_big",
maximum: def.maximum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMinLength = $constructor("$ZodCheckMinLength", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
inst._zod.check = (payload) => {
const input = payload.value;
const units = input.length;
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
const origin = getLengthableOrigin(input);
payload.issues.push({
origin,
code: "too_small",
minimum: def.minimum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckStringFormat = $constructor("$ZodCheckStringFormat", (inst, def) => {
var _a, _b;
$ZodCheck.init(inst, def);
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: def.format,
input: payload.value,
...def.pattern ? { pattern: def.pattern.toString() } : {},
inst,
continue: !def.abort
});
});
else (_b = inst._zod).check ?? (_b.check = () => {});
});
const version = {
major: 4,
minor: 6,
patch: 7
};
const $ZodType = $constructor("$ZodType", (inst, def) => {
var _a;
inst ?? (inst = {});
inst._zod.def = def;
inst._zod.bag = inst._zod.bag || {};
inst._zod.version = version;
const defChecks = inst._zod.def.checks;
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
if (checks.length === 0) {
(_a = inst._zod).deferred ?? (_a.deferred = []);
inst._zod.deferred?.push(() => {
inst._zod.run = inst._zod.parse;
});
} else {
const runChecks = (payload, checks, ctx) => {
if (payload.memo) return payload;
let isAborted = aborted(payload);
let asyncResult;
for (const ch of checks) {
if (ch._zod.def.when) {
if (explicitlyAborted(payload)) continue;
if (!ch._zod.def.when(payload)) continue;
} else if (isAborted) continue;
const currLen = payload.issues.length;
const _ = ch._zod.check(payload);
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
await _;
if (payload.issues.length === currLen) return;
attachSchema(payload.issues, currLen, inst);
if (!isAborted) isAborted = aborted(payload, currLen);
});
else {
if (payload.issues.length === currLen) continue;
attachSchema(payload.issues, currLen, inst);
if (!isAborted) isAborted = aborted(payload, currLen);
}
}
if (asyncResult) return asyncResult.then(() => {
return payload;
});
return payload;
};
const handleCanaryResult = (canary, payload, ctx) => {
if (aborted(canary)) {
canary.aborted = true;
return canary;
}
const checkResult = runChecks(payload, checks, ctx);
if (checkResult instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError();
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
}
return inst._zod.parse(checkResult, ctx);
};
inst._zod.run = (payload, ctx) => {
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
if (ctx.direction === "backward") {
const canary = inst._zod.parse({
value: payload.value,
issues: []
}, {
...ctx,
skipChecks: true
});
if (canary instanceof Promise) return canary.then((canary) => {
return handleCanaryResult(canary, payload, ctx);
});
return handleCanaryResult(canary, payload, ctx);
}
const result = inst._zod.parse(payload, ctx);
if (result instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError();
return result.then((result) => runChecks(result, checks, ctx));
}
return runChecks(result, checks, ctx);
};
}
}, {
get "~standard"() {
return hide(this, "~standard", standardProps(this));
},
set "~standard"(value) {
own(this, "~standard", value);
}
});
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
async function validateAsync(inst, value) {
const ctx = { async: true };
return toStandardResult(await inst._zod.run({
value,
issues: []
}, ctx), ctx);
}
function standardProps(inst) {
return {
validate: (value) => {
const ctx = { async: false };
try {
const r = inst._zod.run({
value,
issues: []
}, ctx);
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
} catch (_) {}
return validateAsync(inst, value);
},
vendor: "zod",
version: 1
};
}
const $ZodString = $constructor("$ZodString", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = def.pattern ?? anyString;
inst._zod.parse = (payload, _) => {
if (def.coerce) try {
payload.value = String(payload.value);
} catch (_) {}
if (typeof payload.value === "string") return payload;
payload.issues.push({
expected: "string",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
const $ZodStringFormat = $constructor("$ZodStringFormat", (inst, def) => {
$ZodCheckStringFormat.init(inst, def);
$ZodString.init(inst, def);
});
function canParseURL(input) {
try {
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
new URL(input);
return true;
} catch {
return false;
}
}
function validateURL(trimmed, def) {
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
return parseURLObject(trimmed, def);
}
function parseURLObject(trimmed, def) {
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
try {
if (typeof URL !== "undefined") {
const URLStatic = URL;
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
}
return new URL(trimmed);
} catch {
return 2;
}
}
const asciiTabOrNewline = /[\t\n\r]/g;
function stripTabAndNewline(value) {
return value.replace(asciiTabOrNewline, "");
}
function urlHostnameOk(url, hostname) {
hostname.lastIndex = 0;
return hostname.test(url.hostname);
}
function urlProtocolOk(url, protocol) {
protocol.lastIndex = 0;
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
}
const $ZodURL = $constructor("$ZodURL", (inst, def) => {
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
try {
const trimmed = payload.value.trim();
const url = validateURL(trimmed, def);
if (url === 1) {
payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: payload.value,
inst,
continue: !def.abort
});
return;
}
if (url === 2) {
payload.issues.push({
code: "invalid_format",
format: "url",
input: payload.value,
inst,
continue: !def.abort
});
return;
}
if (url === true) {
payload.value = stripTabAndNewline(trimmed);
return;
}
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: def.hostname.source,
input: payload.value,
inst,
continue: !def.abort
});
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: def.protocol.source,
input: payload.value,
inst,
continue: !def.abort
});
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
return;
} catch (_) {
payload.issues.push({
code: "invalid_format",
format: "url",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
const $ZodNumber = $constructor("$ZodNumber", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = number$1;
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = Number(payload.value);
} catch (_) {}
const input = payload.value;
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
payload.issues.push({
expected: "number",
code: "invalid_type",
input,
inst,
...received ? { received } : {}
});
return payload;
};
});
const $ZodDate = $constructor("$ZodDate", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = new Date(payload.value);
} catch (_err) {}
const input = payload.value;
const isDate = input instanceof Date;
if (isDate && !Number.isNaN(input.getTime())) return payload;
payload.issues.push({
expected: "date",
code: "invalid_type",
input,
...isDate ? { received: "Invalid Date" } : {},
inst
});
return payload;
};
});
function capSize(inst, size) {
const caps = sizeCaps(inst._zod.def.checks);
if (!caps.length) return;
const cap = Math.min(...caps.map((c) => c[0]));
const parse = inst._zod.parse;
inst._zod.parse = (payload, ctx) => {
const n = size(payload.value);
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
const start = payload.issues.length;
ch._zod.check(payload);
payload.issues[start].continue = false;
attachSchema(payload.issues, start, inst);
return payload;
}
}
return parse(payload, ctx);
};
}
const arraySize = (input) => Array.isArray(input) ? input.length : -1;
function handleArrayResult(result, final, index) {
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
final.value[index] = result.value;
}
const $ZodArray = $constructor("$ZodArray", (inst, def) => {
$ZodType.init(inst, def);
const memo = globalConfig.memoizer;
memo?.attach(inst);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!Array.isArray(input)) {
payload.issues.push({
expected: "array",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
const proms = [];
const abortEarly = ctx?.abortEarly;
for (let i = 0; i < input.length; i++) {
const item = input[i];
const result = def.element._zod.run({
value: item,
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
else {
handleArrayResult(result, payload, i);
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
}
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
capSize(inst, arraySize);
});
function handlePropertyResult(result, final, key, input, optin, optout) {
const isPresent = key in input;
const isOptionalOut = optout === "optional";
if (!isPresent && isOptionalOut && optin === "optional") return;
if (result.issues.length) {
if (optin !== void 0 && isOptionalOut && !isPresent) return;
final.issues.push(...prefixIssues(key, result.issues));
}
if (!isPresent && optin === void 0) {
if (!result.issues.length) final.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [key]
});
return;
}
if (result.value === void 0) {
if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
} else final.value[key] = result.value;
}
const NO_SYMBOL_KEYS = [];
function normalizeDef(def) {
const keys = Object.keys(def.shape);
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
const okeys = optionalKeys(def.shape);
return {
...def,
allKeys,
symbolKeys,
keySet: new Set(keys),
numKeys: keys.length,
optionalKeys: new Set(okeys)
};
}
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
const unrecognized = [];
const keySet = def.keySet;
const _catchall = def.catchall._zod;
const t = _catchall.def.type;
const optin = _catchall.optin;
const optout = _catchall.optout;
let seen = 0;
for (const key in input) {
if (abortEarly && payload.issues.length !== seen) {
if (aborted(payload, seen)) break;
seen = payload.issues.length;
}
if (keySet.has(key)) continue;
if (key === "__proto__") {
if (t === "never") unrecognized.push(key);
continue;
}
if (t === "never") {
unrecognized.push(key);
continue;
}
const r = _catchall.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
else handlePropertyResult(r, payload, key, input, optin, optout);
}
if (unrecognized.length) payload.issues.push({
code: "unrecognized_keys",
keys: unrecognized,
input,
inst,
continue: true
});
if (!proms.length) return payload;
return Promise.all(proms).then(() => {
return payload;
});
}
const $ZodObject = $constructor("$ZodObject", (inst, def) => {
$ZodType.init(inst, def);
const desc = Object.getOwnPropertyDescriptor(def, "shape");
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
if (sh) {
const get = () => {
const newSh = { ...sh };
Object.defineProperty(def, "shape", { value: newSh });
get.raw = newSh;
return newSh;
};
get.raw = sh;
Object.defineProperty(def, "shape", { get });
}
const _normalized = cached(() => normalizeDef(def));
defineLazyInternal(inst, "propValues", (zod) => {
const shape = zod.def.shape;
const propValues = {};
for (const key in shape) {
const field = shape[key]._zod;
if (field.values) {
if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, new Set());
for (const v of field.values) propValues[key].add(v);
if (field.optin !== void 0) propValues[key].add(void 0);
}
}
return propValues;
});
const isObject$1 = isObject;
const catchall = def.catchall;
let value;
const memo = globalConfig.memoizer;
memo?.attach(inst);
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject$1(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
const proms = [];
const shape = value.shape;
const abortEarly = ctx?.abortEarly;
let seen = payload.issues.length;
for (const key of value.allKeys) {
if (abortEarly && payload.issues.length !== seen) {
if (aborted(payload, seen)) break;
seen = payload.issues.length;
}
if (key === "__proto__") continue;
const el = shape[key];
const optin = el._zod.optin;
const optout = el._zod.optout;
const r = el._zod.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
else handlePropertyResult(r, payload, key, input, optin, optout);
}
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
};
});
const $ZodEnum = $constructor("$ZodEnum", (inst, def) => {
$ZodType.init(inst, def);
const values = getEnumValues(def.entries);
const valuesSet = new Set(values);
inst._zod.values = valuesSet;
defineLazyInternal(inst, "pattern", (zod) => {
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
});
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (valuesSet.has(input)) return payload;
payload.issues.push({
code: "invalid_value",
values,
input,
inst
});
return payload;
};
});
const $ZodNullable = $constructor("$ZodNullable", (inst, def) => {
$ZodType.init(inst, def);
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
defineLazyInternal(inst, "pattern", (zod) => {
const pattern = zod.def.innerType._zod.pattern;
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
});
defineLazyInternal(inst, "values", (zod) => {
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : void 0;
});
inst._zod.parse = (payload, ctx) => {
if (payload.value === null) return payload;
return def.innerType._zod.run(payload, ctx);
};
});
function snapshotChecks(def) {
if (def.checks) def.checks = [...def.checks];
return def;
}
function _string(Class, params) {
return new Class(snapshotChecks({
type: "string",
...normalizeParams(params)
}));
}
function _url(Class, params) {
return new Class({
type: "string",
format: "url",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
function _number(Class, params) {
return new Class(snapshotChecks({
type: "number",
checks: [],
...normalizeParams(params)
}));
}
function _date(Class, params) {
return new Class({
type: "date",
...normalizeParams(params)
});
}
function _lte(value, params) {
return new $ZodCheckLessThan({
check: "less_than",
...normalizeParams(params),
value,
inclusive: true
});
}
function _gte(value, params) {
return new $ZodCheckGreaterThan({
check: "greater_than",
...normalizeParams(params),
value,
inclusive: true
});
}
function _maxLength(maximum, params) {
return new $ZodCheckMaxLength({
check: "max_length",
...normalizeParams(params),
maximum
});
}
function _minLength(minimum, params) {
return new $ZodCheckMinLength({
check: "min_length",
...normalizeParams(params),
minimum
});
}
function __zcUw(m) {
return typeof m === "string" ? m : m === void 0 || m === null ? void 0 : m.message;
}
var __zcMsg = function(iss) {
var c = config(), m;
if (c.customError) {
m = __zcUw(c.customError(iss));
if (m !== void 0 && m !== null) return m;
}
if (c.localeError) {
m = __zcUw(c.localeError(iss));
if (m !== void 0 && m !== null) return m;
}
return "Invalid input";
};
var __ZcFailC = (function() {
function __ZcFailC(e, f, i) {
this.success = false;
this._e = e;
this._f = f;
this._i = i;
this._c = void 0;
}
Object.defineProperty(__ZcFailC.prototype, "error", {
configurable: true,
get: function() {
if (this._c) return this._c;
var e = this._f !== null ? this._f(this._i) : this._e;
for (var i = 0; i < e.length; i++) {
var s = e[i], o = {}, k;
if (s.message === void 0 && typeof __zcMsg === "function") s.message = __zcMsg(s);
for (k in s) if (k !== "input" && k !== "continue" && Object.prototype.hasOwnProperty.call(s, k)) o[k] = s[k];
e[i] = o;
}
return this._c = new $ZodRealError(e);
}
});
return __ZcFailC;
})();
function __ZcFailZ(z, r, i) {
this.success = false;
this._z = z;
this._r = r;
this._i = i;
this._c = void 0;
}
Object.defineProperty(__ZcFailZ.prototype, "error", {
configurable: true,
get: function() {
if (this._c) return this._c;
var p = {};
p[Symbol.for("zod.compile.fallback")] = true;
return this._c = this._z.call(this._r, this._i, p).error;
}
});
function __zcMkv(fn, schema, fc, is, p, v) {
var w = schema || {};
var zpa = w.parseAsync, zspa = w.safeParseAsync;
w.parse = p || (fc ? function parse(input) {
if (fc(input)) return input;
var r = fn(input);
if (r.success) return r.data;
throw __zcSt(r.error, parse);
} : function parse(input) {
var r = fn(input);
if (r.success) return r.data;
throw __zcSt(r.error, parse);
});
w.safeParse = fn;
w.safeParseAsync = function(input) {
try {
return Promise.resolve(fn(input));
} catch (e) {
if (zspa) return zspa(input);
throw e;
}
};
w.parseAsync = fc ? function parseAsync(input) {
try {
if (fc(input)) return Promise.resolve(input);
var r = fn(input);
if (r.success) return Promise.resolve(r.data);
return Promise.reject(__zcSt(r.error, parseAsync));
} catch (e) {
if (zpa) return zpa(input);
throw e;
}
} : function parseAsync(input) {
try {
var r = fn(input);
if (r.success) return Promise.resolve(r.data);
return Promise.reject(__zcSt(r.error, parseAsync));
} catch (e) {
if (zpa) return zpa(input);
throw e;
}
};
w.is = is || function(input) {
return fn(input).success;
};
if (v) v.a = zspa;
Object.defineProperty(w, "~standard", {
configurable: true,
value: {
version: 1,
vendor: "zod",
validate: v || function(input) {
var r;
try {
if (fc && fc(input)) return { value: input };
r = fn(input);
} catch (e) {
if (zspa) return zspa(input).then(function(q) {
return q.success ? { value: q.data } : { issues: q.error.issues };
});
throw e;
}
return r.success ? { value: r.data } : { issues: r.error.issues };
}
}
});
return w;
}
function __zcSt(e, c) {
var t = Error.captureStackTrace;
if (typeof t === "function") t(e, c);
return e;
}
function __zcPu(r, c) {
if (r.success) return r.data;
throw __zcSt(r.error, c);
}
function __zcVr(r) {
return r.success ? { value: r.data } : { issues: r.error.issues };
}
function __zcVc(e, i, v) {
var a = v.a;
if (a) return a(i).then(__zcVr);
throw e;
}
function __zcFinDC(f, inp) {
return new __ZcFailC(null, f, inp);
}
function __zcTS(m, o, i, inp, p, msg) {
var r = {
origin: o,
code: "too_small",
minimum: m,
inclusive: i,
input: inp,
path: p
};
if (msg !== void 0) r.message = msg;
return r;
}
function __zcTB(m, o, i, inp, p, msg) {
var r = {
origin: o,
code: "too_big",
maximum: m,
inclusive: i,
input: inp,
path: p
};
if (msg !== void 0) r.message = msg;
return r;
}
function __zcIT(e, inp, p, msg) {
var r = {
expected: e,
code: "invalid_type",
input: inp,
path: p
};
if (msg !== void 0) r.message = msg;
return r;
}
function __zcIF(o, f, inp, p, extra, msg) {
var r = o === void 0 ? {
code: "invalid_format",
format: f
} : {
origin: o,
code: "invalid_format",
format: f
};
if (extra) Object.assign(r, extra);
r.input = inp;
r.path = p;
if (msg !== void 0) r.message = msg;
return r;
}
function __zcIV(values, inp, p, extra, msg) {
var r = { code: "invalid_value" };
if (extra) Object.assign(r, extra);
r.values = values;
r.input = inp;
r.path = p;
if (msg !== void 0) r.message = msg;
return r;
}
function __zcLo(v) {
return Array.isArray(v) ? "array" : typeof v === "string" ? "string" : "unknown";
}
function __zcCpl(s) {
var n = s.length;
if (!/[\uD800-\uDBFF]/.test(s)) return n;
var c = n;
for (var i = 0; i < n - 1; i++) if ((s.charCodeAt(i) & 64512) === 55296 && (s.charCodeAt(i + 1) & 64512) === 56320) {
c--;
i++;
}
return c;
}
function __zcUrl(s) {
if (typeof URL === "function" && typeof URL.canParse === "function") return URL.canParse(s);
try {
new URL(s);
return true;
} catch (_) {
return false;
}
}
function __zcPa(p, k) {
var n = p.length, r = new Array(n + 1);
for (var i = 0; i < n; i++) r[i] = p[i];
r[n] = k;
return r;
}
const ZodMiniType = $constructor("ZodMiniType", (inst, def) => {
if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType.");
$ZodType.init(inst, def);
inst.def = def;
inst.type = def.type;
}, {
get with() {
return this.check;
},
set with(value) {
own(this, "with", value);
},
parse(data, params) {
return parse(this, data, params, { callee: this.parse });
},
parseAsync(data, params) {
return parseAsync(this, data, params, { callee: this.parseAsync });
},
safeParse(data, params) {
return safeParse(this, data, params);
},
safeParseAsync(data, params) {
return safeParseAsync(this, data, params);
},
check(...checks) {
const def = this.def;
return this.clone({
...def,
checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
check: ch,
def: { check: "custom" },
onattach: []
} } : ch)]
}, { parent: true });
},
clone(_def, params) {
return clone(this, _def, params);
},
brand() {
return this;
},
register(reg, meta) {
reg.add(this, meta);
return this;
},
apply(fn, ...args) {
return args.length === 0 ? fn(this) : fn(this, ...args);
}
});
const ZodMiniString = $constructor("ZodMiniString", (inst, def) => {
$ZodString.init(inst, def);
ZodMiniType.init(inst, def);
});
function string(params) {
return _string(ZodMiniString, params);
}
const ZodMiniStringFormat = $constructor("ZodMiniStringFormat", (inst, def) => {
$ZodStringFormat.init(inst, def);
ZodMiniString.init(inst, def);
});
const ZodMiniURL = $constructor("ZodMiniURL", (inst, def) => {
$ZodURL.init(inst, def);
ZodMiniStringFormat.init(inst, def);
});
function url(params) {
return _url(ZodMiniURL, params);
}
const ZodMiniNumber = $constructor("ZodMiniNumber", (inst, def) => {
$ZodNumber.init(inst, def);
ZodMiniType.init(inst, def);
});
function number(params) {
return _number(ZodMiniNumber, params);
}
const ZodMiniDate = $constructor("ZodMiniDate", (inst, def) => {
$ZodDate.init(inst, def);
ZodMiniType.init(inst, def);
});
function date(params) {
return _date(ZodMiniDate, params);
}
const ZodMiniArray = $constructor("ZodMiniArray", (inst, def) => {
$ZodArray.init(inst, def);
ZodMiniType.init(inst, def);
});
function array(element, params) {
return new ZodMiniArray({
type: "array",
element,
...normalizeParams(params)
});
}
const ZodMiniObject = $constructor("ZodMiniObject", (inst, def) => {
$ZodObject.init(inst, def);
ZodMiniType.init(inst, def);
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
});
function object(shape, params) {
const def = {
type: "object",
shape: shape ?? {},
...normalizeParams(params)
};
return new ZodMiniObject(def);
}
const ZodMiniEnum = $constructor("ZodMiniEnum", (inst, def) => {
$ZodEnum.init(inst, def);
ZodMiniType.init(inst, def);
inst.options = [...inst._zod.values];
});
function _enum(values, params) {
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
return new ZodMiniEnum({
type: "enum",
entries,
...normalizeParams(params)
});
}
const ZodMiniNullable = $constructor("ZodMiniNullable", (inst, def) => {
$ZodNullable.init(inst, def);
ZodMiniType.init(inst, def);
});
function nullable(innerType) {
return new ZodMiniNullable({
type: "nullable",
innerType
});
}
var __re_tnl_10 = new RegExp("[\\t\\n\\r]", "g");
var __re_urlOk_11 = new RegExp("^https?:\\/\\/(?:(?!xn--)[a-z0-9-]+\\.)*(?!xn--)[a-z][a-z0-9-]*(?::[0-9]{1,4})?(?:[\\/?#][^\\t\\n\\r]*)?$");
function __zcSw_0(input, path, _e) {
if (!Array.isArray(input)) _e.push(__zcIT("array", input, path));
else {
var __ar_0 = input;
__ar_0 = __ar_0.slice();
for (var __i_1 = 0; __i_1 < __ar_0.length; __i_1++) __ar_0[__i_1] = __zcSw_1(__ar_0[__i_1], __zcPa(path, __i_1), _e);
input = __ar_0;
}
return input;
}
function __zcSw_1(input, path, _e) {
if (typeof input !== "object" || input === null || Array.isArray(input)) _e.push(__zcIT("object", input, path));
else {
var __sv_3 = input["id"];
if (typeof __sv_3 !== "number") _e.push(__zcIT("number", __sv_3, __zcPa(path, "id")));
else if (Number.isNaN(__sv_3)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_3,
path: __zcPa(path, "id")
});
else if (!Number.isFinite(__sv_3)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_3),
input: __sv_3,
path: __zcPa(path, "id")
});
var __sv_4 = input["created"];
if (!(__sv_4 instanceof Date)) _e.push(__zcIT("date", __sv_4, __zcPa(path, "created")));
else if (isNaN(__sv_4.getTime())) _e.push({
expected: "date",
code: "invalid_type",
received: "Invalid Date",
input: __sv_4,
path: __zcPa(path, "created")
});
var __sv_5 = input["title"];
if (typeof __sv_5 !== "string") {
_e.push(__zcIT("string", __sv_5, __zcPa(path, "title")));
if (__sv_5 !== void 0 && __sv_5 !== null && __sv_5.length !== void 0) {
if (__sv_5.length < 1) _e.push(__zcTS(1, __zcLo(__sv_5), true, __sv_5, __zcPa(path, "title")));
if (__sv_5.length > 100) _e.push(__zcTB(100, __zcLo(__sv_5), true, __sv_5, __zcPa(path, "title")));
}
} else {
if (__sv_5.length < 1) _e.push(__zcTS(1, "string", true, __sv_5, __zcPa(path, "title")));
if (__sv_5.length > 100 && (__sv_5.length > 200 || __zcCpl(__sv_5) > 100)) _e.push(__zcTB(100, "string", true, __sv_5, __zcPa(path, "title")));
}
var __sv_6 = input["type"];
if (__sv_6 !== "jpg" && __sv_6 !== "png") _e.push(__zcIV(["jpg", "png"], __sv_6, __zcPa(path, "type")));
var __sv_7 = input["size"];
if (typeof __sv_7 !== "number") _e.push(__zcIT("number", __sv_7, __zcPa(path, "size")));
else if (Number.isNaN(__sv_7)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_7,
path: __zcPa(path, "size")
});
else if (!Number.isFinite(__sv_7)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_7),
input: __sv_7,
path: __zcPa(path, "size")
});
var __sv_8 = input["url"];
if (typeof __sv_8 !== "string") _e.push(__zcIT("string", __sv_8, __zcPa(path, "url")));
else {
var __ut_9 = __sv_8.trim();
if (__re_urlOk_11.test(__ut_9)) __sv_8 = __ut_9;
else if (!__zcUrl(__ut_9)) _e.push(__zcIF(void 0, "url", __sv_8, __zcPa(path, "url")));
else __sv_8 = __ut_9.replace(__re_tnl_10, "");
}
input = {
"id": __sv_3,
"created": __sv_4,
"title": __sv_5,
"type": __sv_6,
"size": __sv_7,
"url": __sv_8
};
}
return input;
}
const imageSchema = object({
id: number(),
created: date(),
title: ( string()).check( _minLength(1), _maxLength(100)),
type: _enum(["jpg", "png"]),
size: number(),
url: url()
});
const ratingSchema = object({
id: number(),
stars: ( number()).check( _gte(1), _lte(5)),
title: ( string()).check( _minLength(1), _maxLength(100)),
text: ( string()).check( _minLength(1), _maxLength(1e3)),
images: array(imageSchema)
});
toZod()( object({
id: number(),
created: date(),
title: ( string()).check( _minLength(1), _maxLength(100)),
brand: ( string()).check( _minLength(1), _maxLength(30)),
description: ( string()).check( _minLength(1), _maxLength(500)),
price: ( number()).check( _gte(1), _lte(1e4)),
discount: nullable(( number()).check( _gte(1), _lte(100))),
quantity: ( number()).check( _gte(0), _lte(10)),
tags: array(( string()).check( _minLength(1), _maxLength(30))),
images: array(imageSchema),
ratings: array(ratingSchema)
}));
( (() => {
var __bf_16 = {};
function __af_28(a) {
for (var __ae_27, i = 0; i < a.length; i++) {
__ae_27 = a[i];
if (!(typeof __ae_27 === "string" && __ae_27.length >= 1 && (__ae_27.length <= 30 || __ae_27.length <= 60 && __zcCpl(__ae_27) <= 30))) return false;
}
return true;
}
var __re_tnl_41 = new RegExp("[\\t\\n\\r]", "g");
var __re_urlOk_42 = new RegExp("^https?:\\/\\/(?:(?!xn--)[a-z0-9-]+\\.)*(?!xn--)[a-z][a-z0-9-]*(?::[0-9]{1,4})?(?:[\\/?#][^\\t\\n\\r]*)?$");
function __vb_17(input) {
var __bv_18, __bv_19, __bv_20, __bv_21, __bv_22, __bv_23, __bv_24, __bv_25, __bv_26, __bv_29, __ba_30, __bi_31, __be_32, __bv_33, __bv_34, __bv_35, __bv_36, __bv_37, __bv_38, __bs_39, __but_40, __bo_43, __bv_44, __ba_45, __bi_46, __be_47, __bv_48, __bv_49, __bv_50, __bv_51, __bv_52, __ba_53, __bi_54, __be_55, __bv_56, __bv_57, __bv_58, __bv_59, __bv_60, __bv_61, __bs_62, __but_63, __bo_64, __bo_65, __bo_66;
if (typeof input !== "object" || input === null || Array.isArray(input)) return __bf_16;
__bv_18 = input["id"];
if (!Number.isFinite(__bv_18)) return __bf_16;
__bv_19 = input["created"];
if (!(__bv_19 instanceof Date && !Number.isNaN(__bv_19.getTime()))) return __bf_16;
__bv_20 = input["title"];
if (!(typeof __bv_20 === "string" && __bv_20.length >= 1 && (__bv_20.length <= 100 || __bv_20.length <= 200 && __zcCpl(__bv_20) <= 100))) return __bf_16;
__bv_21 = input["brand"];
if (!(typeof __bv_21 === "string" && __bv_21.length >= 1 && (__bv_21.length <= 30 || __bv_21.length <= 60 && __zcCpl(__bv_21) <= 30))) return __bf_16;
__bv_22 = input["description"];
if (!(typeof __bv_22 === "string" && __bv_22.length >= 1 && (__bv_22.length <= 500 || __bv_22.length <= 1e3 && __zcCpl(__bv_22) <= 500))) return __bf_16;
__bv_23 = input["price"];
if (!(Number.isFinite(__bv_23) && __bv_23 >= 1 && __bv_23 <= 1e4)) return __bf_16;
__bv_24 = input["quantity"];
if (!(Number.isFinite(__bv_24) && __bv_24 >= 0 && __bv_24 <= 10)) return __bf_16;
__bv_25 = input["discount"];
if (!(__bv_25 === null || Number.isFinite(__bv_25) && __bv_25 >= 1 && __bv_25 <= 100)) return __bf_16;
__bv_26 = input["tags"];
if (!(Array.isArray(__bv_26) && __af_28(__bv_26))) return __bf_16;
__bv_29 = input["images"];
if (!Array.isArray(__bv_29)) return __bf_16;
__ba_30 = new Array(__bv_29.length);
for (__bi_31 = 0; __bi_31 < __bv_29.length; __bi_31++) {
__be_32 = __bv_29[__bi_31];
if (typeof __be_32 !== "object" || __be_32 === null || Array.isArray(__be_32)) return __bf_16;
__bv_33 = __be_32["id"];
if (!Number.isFinite(__bv_33)) return __bf_16;
__bv_34 = __be_32["size"];
if (!Number.isFinite(__bv_34)) return __bf_16;
__bv_35 = __be_32["created"];
if (!(__bv_35 instanceof Date && !Number.isNaN(__bv_35.getTime()))) return __bf_16;
__bv_36 = __be_32["type"];
if (!(__bv_36 === "jpg" || __bv_36 === "png")) return __bf_16;
__bv_37 = __be_32["title"];
if (!(typeof __bv_37 === "string" && __bv_37.length >= 1 && (__bv_37.length <= 100 || __bv_37.length <= 200 && __zcCpl(__bv_37) <= 100))) return __bf_16;
__bv_38 = __be_32["url"];
if (typeof __bv_38 !== "string") return __bf_16;
__bs_39 = __bv_38;
__but_40 = __bs_39.trim();
if (__re_urlOk_42.test(__but_40)) __bs_39 = __but_40;
else {
if (!__zcUrl(__but_40)) return __bf_16;
__bs_39 = __but_40.replace(__re_tnl_41, "");
}
__bo_43 = {
"id": __bv_33,
"created": __bv_35,
"title": __bv_37,
"type": __bv_36,
"size": __bv_34,
"url": __bs_39
};
__ba_30[__bi_31] = __bo_43;
}
__bv_44 = input["ratings"];
if (!Array.isArray(__bv_44)) return __bf_16;
__ba_45 = new Array(__bv_44.length);
for (__bi_46 = 0; __bi_46 < __bv_44.length; __bi_46++) {
__be_47 = __bv_44[__bi_46];
if (typeof __be_47 !== "object" || __be_47 === null || Array.isArray(__be_47)) return __bf_16;
__bv_48 = __be_47["id"];
if (!Number.isFinite(__bv_48)) return __bf_16;
__bv_49 = __be_47["stars"];
if (!(Number.isFinite(__bv_49) && __bv_49 >= 1 && __bv_49 <= 5)) return __bf_16;
__bv_50 = __be_47["title"];
if (!(typeof __bv_50 === "string" && __bv_50.length >= 1 && (__bv_50.length <= 100 || __bv_50.length <= 200 && __zcCpl(__bv_50) <= 100))) return __bf_16;
__bv_51 = __be_47["text"];
if (!(typeof __bv_51 === "string" && __bv_51.length >= 1 && (__bv_51.length <= 1e3 || __bv_51.length <= 2e3 && __zcCpl(__bv_51) <= 1e3))) return __bf_16;
__bv_52 = __be_47["images"];
if (!Array.isArray(__bv_52)) return __bf_16;
__ba_53 = new Array(__bv_52.length);
for (__bi_54 = 0; __bi_54 < __bv_52.length; __bi_54++) {
__be_55 = __bv_52[__bi_54];
if (typeof __be_55 !== "object" || __be_55 === null || Array.isArray(__be_55)) return __bf_16;
__bv_56 = __be_55["id"];
if (!Number.isFinite(__bv_56)) return __bf_16;
__bv_57 = __be_55["size"];
if (!Number.isFinite(__bv_57)) return __bf_16;
__bv_58 = __be_55["created"];
if (!(__bv_58 instanceof Date && !Number.isNaN(__bv_58.getTime()))) return __bf_16;
__bv_59 = __be_55["type"];
if (!(__bv_59 === "jpg" || __bv_59 === "png")) return __bf_16;
__bv_60 = __be_55["title"];
if (!(typeof __bv_60 === "string" && __bv_60.length >= 1 && (__bv_60.length <= 100 || __bv_60.length <= 200 && __zcCpl(__bv_60) <= 100))) return __bf_16;
__bv_61 = __be_55["url"];
if (typeof __bv_61 !== "string") return __bf_16;
__bs_62 = __bv_61;
__but_63 = __bs_62.trim();
if (__re_urlOk_42.test(__but_63)) __bs_62 = __but_63;
else {
if (!__zcUrl(__but_63)) return __bf_16;
__bs_62 = __but_63.replace(__re_tnl_41, "");
}
__bo_64 = {
"id": __bv_56,
"created": __bv_58,
"title": __bv_60,
"type": __bv_59,
"size": __bv_57,
"url": __bs_62
};
__ba_53[__bi_54] = __bo_64;
}
__bo_65 = {
"id": __bv_48,
"stars": __bv_49,
"title": __bv_50,
"text": __bv_51,
"images": __ba_53
};
__ba_45[__bi_46] = __bo_65;
}
__bo_66 = {
"id": __bv_18,
"created": __bv_19,
"title": __bv_20,
"brand": __bv_21,
"description": __bv_22,
"price": __bv_23,
"discount": __bv_25,
"quantity": __bv_24,
"tags": __bv_26,
"images": __ba_30,
"ratings": __ba_45
};
return __bo_66;
}
function __sw_92(input) {
var _e = [];
var _d = input;
if (typeof _d !== "object" || _d === null || Array.isArray(_d)) _e.push(__zcIT("object", _d, []));
else {
var __sv_68 = _d["id"];
if (typeof __sv_68 !== "number") _e.push(__zcIT("number", __sv_68, ["id"]));
else if (Number.isNaN(__sv_68)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_68,
path: ["id"]
});
else if (!Number.isFinite(__sv_68)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_68),
input: __sv_68,
path: ["id"]
});
var __sv_69 = _d["created"];
if (!(__sv_69 instanceof Date)) _e.push(__zcIT("date", __sv_69, ["created"]));
else if (isNaN(__sv_69.getTime())) _e.push({
expected: "date",
code: "invalid_type",
received: "Invalid Date",
input: __sv_69,
path: ["created"]
});
var __sv_70 = _d["title"];
if (typeof __sv_70 !== "string") {
_e.push(__zcIT("string", __sv_70, ["title"]));
if (__sv_70 !== void 0 && __sv_70 !== null && __sv_70.length !== void 0) {
if (__sv_70.length < 1) _e.push(__zcTS(1, __zcLo(__sv_70), true, __sv_70, ["title"]));
if (__sv_70.length > 100) _e.push(__zcTB(100, __zcLo(__sv_70), true, __sv_70, ["title"]));
}
} else {
if (__sv_70.length < 1) _e.push(__zcTS(1, "string", true, __sv_70, ["title"]));
if (__sv_70.length > 100 && (__sv_70.length > 200 || __zcCpl(__sv_70) > 100)) _e.push(__zcTB(100, "string", true, __sv_70, ["title"]));
}
var __sv_71 = _d["brand"];
if (typeof __sv_71 !== "string") {
_e.push(__zcIT("string", __sv_71, ["brand"]));
if (__sv_71 !== void 0 && __sv_71 !== null && __sv_71.length !== void 0) {
if (__sv_71.length < 1) _e.push(__zcTS(1, __zcLo(__sv_71), true, __sv_71, ["brand"]));
if (__sv_71.length > 30) _e.push(__zcTB(30, __zcLo(__sv_71), true, __sv_71, ["brand"]));
}
} else {
if (__sv_71.length < 1) _e.push(__zcTS(1, "string", true, __sv_71, ["brand"]));
if (__sv_71.length > 30 && (__sv_71.length > 60 || __zcCpl(__sv_71) > 30)) _e.push(__zcTB(30, "string", true, __sv_71, ["brand"]));
}
var __sv_72 = _d["description"];
if (typeof __sv_72 !== "string") {
_e.push(__zcIT("string", __sv_72, ["description"]));
if (__sv_72 !== void 0 && __sv_72 !== null && __sv_72.length !== void 0) {
if (__sv_72.length < 1) _e.push(__zcTS(1, __zcLo(__sv_72), true, __sv_72, ["description"]));
if (__sv_72.length > 500) _e.push(__zcTB(500, __zcLo(__sv_72), true, __sv_72, ["description"]));
}
} else {
if (__sv_72.length < 1) _e.push(__zcTS(1, "string", true, __sv_72, ["description"]));
if (__sv_72.length > 500 && (__sv_72.length > 1e3 || __zcCpl(__sv_72) > 500)) _e.push(__zcTB(500, "string", true, __sv_72, ["description"]));
}
var __sv_73 = _d["price"];
if (typeof __sv_73 !== "number") _e.push(__zcIT("number", __sv_73, ["price"]));
else if (Number.isNaN(__sv_73)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_73,
path: ["price"]
});
else if (!Number.isFinite(__sv_73)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_73),
input: __sv_73,
path: ["price"]
});
else {
if (__sv_73 < 1) _e.push(__zcTS(1, "number", true, __sv_73, ["price"]));
if (__sv_73 > 1e4) _e.push(__zcTB(1e4, "number", true, __sv_73, ["price"]));
}
var __sv_74 = _d["discount"];
if (__sv_74 !== null) {
if (typeof __sv_74 !== "number") _e.push(__zcIT("number", __sv_74, ["discount"]));
else if (Number.isNaN(__sv_74)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_74,
path: ["discount"]
});
else if (!Number.isFinite(__sv_74)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_74),
input: __sv_74,
path: ["discount"]
});
else {
if (__sv_74 < 1) _e.push(__zcTS(1, "number", true, __sv_74, ["discount"]));
if (__sv_74 > 100) _e.push(__zcTB(100, "number", true, __sv_74, ["discount"]));
}
}
var __sv_75 = _d["quantity"];
if (typeof __sv_75 !== "number") _e.push(__zcIT("number", __sv_75, ["quantity"]));
else if (Number.isNaN(__sv_75)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_75,
path: ["quantity"]
});
else if (!Number.isFinite(__sv_75)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_75),
input: __sv_75,
path: ["quantity"]
});
else {
if (__sv_75 < 0) _e.push(__zcTS(0, "number", true, __sv_75, ["quantity"]));
if (__sv_75 > 10) _e.push(__zcTB(10, "number", true, __sv_75, ["quantity"]));
}
var __sv_76 = _d["tags"];
if (!Array.isArray(__sv_76)) _e.push(__zcIT("array", __sv_76, ["tags"]));
else {
var __ar_77 = __sv_76;
for (var __i_78 = 0; __i_78 < __ar_77.length; __i_78++) {
var __mv_79 = __ar_77[__i_78];
if (typeof __mv_79 !== "string") {
_e.push(__zcIT("string", __mv_79, ["tags", __i_78]));
if (__mv_79 !== void 0 && __mv_79 !== null && __mv_79.length !== void 0) {
if (__mv_79.length < 1) _e.push(__zcTS(1, __zcLo(__mv_79), true, __mv_79, ["tags", __i_78]));
if (__mv_79.length > 30) _e.push(__zcTB(30, __zcLo(__mv_79), true, __mv_79, ["tags", __i_78]));
}
} else {
if (__mv_79.length < 1) _e.push(__zcTS(1, "string", true, __mv_79, ["tags", __i_78]));
if (__mv_79.length > 30 && (__mv_79.length > 60 || __zcCpl(__mv_79) > 30)) _e.push(__zcTB(30, "string", true, __mv_79, ["tags", __i_78]));
}
}
__sv_76 = __ar_77;
}
var __sv_81 = _d["images"];
__sv_81 = __zcSw_0(__sv_81, ["images"], _e);
var __sv_82 = _d["ratings"];
if (!Array.isArray(__sv_82)) _e.push(__zcIT("array", __sv_82, ["ratings"]));
else {
var __ar_83 = __sv_82;
__ar_83 = __ar_83.slice();
for (var __i_84 = 0; __i_84 < __ar_83.length; __i_84++) if (typeof __ar_83[__i_84] !== "object" || __ar_83[__i_84] === null || Array.isArray(__ar_83[__i_84])) _e.push(__zcIT("object", __ar_83[__i_84], ["ratings", __i_84]));
else {
var __sv_86 = __ar_83[__i_84]["id"];
if (typeof __sv_86 !== "number") _e.push(__zcIT("number", __sv_86, [
"ratings",
__i_84,
"id"
]));
else if (Number.isNaN(__sv_86)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_86,
path: [
"ratings",
__i_84,
"id"
]
});
else if (!Number.isFinite(__sv_86)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_86),
input: __sv_86,
path: [
"ratings",
__i_84,
"id"
]
});
var __sv_87 = __ar_83[__i_84]["stars"];
if (typeof __sv_87 !== "number") _e.push(__zcIT("number", __sv_87, [
"ratings",
__i_84,
"stars"
]));
else if (Number.isNaN(__sv_87)) _e.push({
expected: "number",
code: "invalid_type",
received: "NaN",
input: __sv_87,
path: [
"ratings",
__i_84,
"stars"
]
});
else if (!Number.isFinite(__sv_87)) _e.push({
expected: "number",
code: "invalid_type",
received: String(__sv_87),
input: __sv_87,
path: [
"ratings",
__i_84,
"stars"
]
});
else {
if (__sv_87 < 1) _e.push(__zcTS(1, "number", true, __sv_87, [
"ratings",
__i_84,
"stars"
]));
if (__sv_87 > 5) _e.push(__zcTB(5, "number", true, __sv_87, [
"ratings",
__i_84,
"stars"
]));
}
var __sv_88 = __ar_83[__i_84]["title"];
if (typeof __sv_88 !== "string") {
_e.push(__zcIT("string", __sv_88, [
"ratings",
__i_84,
"title"
]));
if (__sv_88 !== void 0 && __sv_88 !== null && __sv_88.length !== void 0) {
if (__sv_88.length < 1) _e.push(__zcTS(1, __zcLo(__sv_88), true, __sv_88, [
"ratings",
__i_84,
"title"
]));
if (__sv_88.length > 100) _e.push(__zcTB(100, __zcLo(__sv_88), true, __sv_88, [
"ratings",
__i_84,
"title"
]));
}
} else {
if (__sv_88.length < 1) _e.push(__zcTS(1, "string", true, __sv_88, [
"ratings",
__i_84,
"title"
]));
if (__sv_88.length > 100 && (__sv_88.length > 200 || __zcCpl(__sv_88) > 100)) _e.push(__zcTB(100, "string", true, __sv_88, [
"ratings",
__i_84,
"title"
]));
}
var __sv_89 = __ar_83[__i_84]["text"];
if (typeof __sv_89 !== "string") {
_e.push(__zcIT("string", __sv_89, [
"ratings",
__i_84,
"text"
]));
if (__sv_89 !== void 0 && __sv_89 !== null && __sv_89.length !== void 0) {
if (__sv_89.length < 1) _e.push(__zcTS(1, __zcLo(__sv_89), true, __sv_89, [
"ratings",
__i_84,
"text"
]));
if (__sv_89.length > 1e3) _e.push(__zcTB(1e3, __zcLo(__sv_89), true, __sv_89, [
"ratings",
__i_84,
"text"
]));
}
} else {
if (__sv_89.length < 1) _e.push(__zcTS(1, "string", true, __sv_89, [
"ratings",
__i_84,
"text"
]));
if (__sv_89.length > 1e3 && (__sv_89.length > 2e3 || __zcCpl(__sv_89) > 1e3)) _e.push(__zcTB(1e3, "string", true, __sv_89, [
"ratings",
__i_84,
"text"
]));
}
var __sv_90 = __ar_83[__i_84]["images"];
__sv_90 = __zcSw_0(__sv_90, [
"ratings",
__i_84,
"images"
], _e);
__ar_83[__i_84] = {
"id": __sv_86,
"stars": __sv_87,
"title": __sv_88,
"text": __sv_89,
"images": __sv_90
};
}
__sv_82 = __ar_83;
}
_d = {
"id": __sv_68,
"created": __sv_69,
"title": __sv_70,
"brand": __sv_71,
"description": __sv_72,
"price": __sv_73,
"discount": __sv_74,
"quantity": __sv_75,
"tags": __sv_76,
"images": __sv_81,
"ratings": __sv_82
};
}
return _e;
}
function safeParse_compiledProductSchema(input) {
var __bd_91 = __vb_17(input);
if (__bd_91 !== __bf_16) return {
success: true,
data: __bd_91
};
return __zcFinDC(__sw_92, input);
}
function __zp(input) {
return __zcPu(safeParse_compiledProductSchema(input), __zp);
}
function __zv(input) {
try {
return __zcVr(safeParse_compiledProductSchema(input));
} catch (e) {
return __zcVc(e, input, __zv);
}
}
return __zcMkv(safeParse_compiledProductSchema, null, null, null, __zp, __zv);
})()).parse({});