UNPKG

joi

Version:

Object schema validation

1,519 lines 205 kB
//#region \0rolldown/runtime.js var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (e && (t = e(e = 0)), t), s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), c = (e, n) => { let r = {}; for (var i in e) t(r, i, { get: e[i], enumerable: !0 }); return n || t(r, Symbol.toStringTag, { value: "Module" }), r; }, l = (e, i, o, s) => { if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, { get: ((e) => i[e]).bind(null, d), enumerable: !(s = n(i, d)) || s.enumerable }); return e; }, u = (n, r, a) => (a = n == null ? {} : e(i(n)), l(r || !n || !n.__esModule ? t(a, "default", { value: n, enumerable: !0 }) : a, n)), d = (e) => a.call(e, "module.exports") ? e["module.exports"] : l(t({}, "__esModule", { value: !0 }), e), f = /* @__PURE__ */ s(((e, t) => { t.exports = class extends Error { name = "AssertError"; constructor(e, t) { super(e || "Unknown error"), typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, t); } }; })), p = /* @__PURE__ */ s(((e, t) => { t.exports = function(...e) { try { return JSON.stringify(...e); } catch (e) { return "[Cannot display object: " + e.message + "]"; } }; })), m = /* @__PURE__ */ s(((e, t) => { var n = f(), r = p(), i = t.exports = function(e, ...t) { if (!e) throw t.length === 1 && t[0] instanceof Error ? t[0] : new n(t.filter((e) => e !== "").map((e) => typeof e == "string" ? e : e instanceof Error ? e.message : r(e)).join(" "), i); }; })), h = /* @__PURE__ */ s(((e, t) => { var n = m(), r = {}; t.exports = function(e, t, i) { if (t === !1 || t == null) return e; i ||= {}, typeof i == "string" && (i = { separator: i }); let a = Array.isArray(t); n(!a || !i.separator, "Separator option is not valid for array-based chain"); let o = a ? t : t.split(i.separator || "."), s = e; for (let e = 0; e < o.length; ++e) { let a = o[e], c = i.iterables && r.iterables(s); if (Array.isArray(s) || c === "set") { let e = Number(a); Number.isInteger(e) && (a = e < 0 ? s.length + e : e); } if (!s || typeof s == "function" && i.functions === !1 || !c && s[a] === void 0) { n(!i.strict || e + 1 === o.length, "Missing segment", a, "in reach path ", t), n(typeof s == "object" || i.functions === !0 || typeof s != "function", "Invalid segment", a, "in reach path ", t), s = i.default; break; } s = c ? c === "set" ? [...s][a] : s.get(a) : s[a]; } return s; }, r.iterables = function(e) { if (e instanceof Set) return "set"; if (e instanceof Map) return "map"; }; })), g = /* @__PURE__ */ s(((e, t) => { var n = {}; e = t.exports = { array: Array.prototype, buffer: !1, date: Date.prototype, error: Error.prototype, generic: Object.prototype, map: Map.prototype, promise: Promise.prototype, regex: RegExp.prototype, set: Set.prototype, url: URL.prototype, weakMap: WeakMap.prototype, weakSet: WeakSet.prototype }, n.typeMap = new Map([ ["[object Error]", e.error], ["[object Map]", e.map], ["[object Promise]", e.promise], ["[object Set]", e.set], ["[object URL]", e.url], ["[object WeakMap]", e.weakMap], ["[object WeakSet]", e.weakSet] ]), e.getInternalProto = function(t) { if (Array.isArray(t)) return e.array; if (t instanceof Date) return e.date; if (t instanceof RegExp) return e.regex; if (t instanceof Error) return e.error; let r = Object.prototype.toString.call(t); return n.typeMap.get(r) || e.generic; }; })), _ = /* @__PURE__ */ s(((e) => { e.keys = function(e, t = {}) { return t.symbols === !1 ? Object.getOwnPropertyNames(e) : Reflect.ownKeys(e); }; })), v = /* @__PURE__ */ s(((e, t) => { var n = h(), r = g(), i = _(), a = { needsProtoHack: new Set([ r.set, r.map, r.weakSet, r.weakMap ]), structuredCloneExists: typeof structuredClone == "function" }; t.exports = a.clone = function(e, t = {}, n = null) { if (typeof e != "object" || !e) return e; let o = a.clone, s = n; if (t.shallow) { if (t.shallow !== !0) return a.cloneWithShallow(e, t); o = (e) => e; } else if (s) { let t = s.get(e); if (t) return t; } else s = /* @__PURE__ */ new Map(); let c = r.getInternalProto(e); switch (c) { case r.buffer: return (!1)?.from(e); case r.date: return new Date(e.getTime()); case r.regex: case r.url: return new c.constructor(e); } let l = a.base(e, c, t); if (l === e) return e; if (s && s.set(e, l), c === r.set) for (let n of e) l.add(o(n, t, s)); else if (c === r.map) for (let [n, r] of e) l.set(n, o(r, t, s)); let u = i.keys(e, t); for (let n of u) { if (n === "__proto__") continue; if (c === r.array && n === "length") { l.length = e.length; continue; } if (a.structuredCloneExists && c === r.error && n === "stack") continue; let i = Object.getOwnPropertyDescriptor(e, n); i ? i.get || i.set ? Object.defineProperty(l, n, i) : i.enumerable ? l[n] = o(e[n], t, s) : Object.defineProperty(l, n, { enumerable: !1, writable: !0, configurable: !0, value: o(e[n], t, s) }) : Object.defineProperty(l, n, { enumerable: !0, writable: !0, configurable: !0, value: o(e[n], t, s) }); } return l; }, a.cloneWithShallow = function(e, t) { let r = t.shallow; t = Object.assign({}, t), t.shallow = !1; let i = /* @__PURE__ */ new Map(); for (let t of r) { let r = n(e, t); (typeof r == "object" || typeof r == "function") && i.set(r, r); } return a.clone(e, t, i); }, a.base = function(e, t, n) { if (n.prototype === !1) return a.needsProtoHack.has(t) ? new t.constructor() : t === r.array ? [] : {}; let i = Object.getPrototypeOf(e); if (i && i.isImmutable) return e; if (t === r.array) { let e = []; return i !== t && Object.setPrototypeOf(e, i), e; } else if (t === r.error && a.structuredCloneExists && (i === t || Error.isPrototypeOf(i.constructor))) { let t = structuredClone(e); return Object.getPrototypeOf(t) !== i && Object.setPrototypeOf(t, i), t; } if (a.needsProtoHack.has(t)) { let e = new i.constructor(); return i !== t && Object.setPrototypeOf(e, i), e; } return Object.create(i); }; })), y = /* @__PURE__ */ s(((e, t) => { var n = m(), r = v(), i = _(), a = {}; t.exports = a.merge = function(e, t, o) { if (n(e && typeof e == "object", "Invalid target value: must be an object"), n(t == null || typeof t == "object", "Invalid source value: must be null, undefined, or an object"), !t) return e; if (o = Object.assign({ nullOverride: !0, mergeArrays: !0 }, o), Array.isArray(t)) { n(Array.isArray(e), "Cannot merge array onto an object"), o.mergeArrays || (e.length = 0); for (let n = 0; n < t.length; ++n) e.push(r(t[n], { symbols: o.symbols })); return e; } let s = i.keys(t, o); for (let n = 0; n < s.length; ++n) { let i = s[n]; if (i === "__proto__" || !Object.prototype.propertyIsEnumerable.call(t, i)) continue; let c = t[i]; if (c && typeof c == "object") { if (e[i] === c) continue; !e[i] || typeof e[i] != "object" || Array.isArray(e[i]) !== Array.isArray(c) || c instanceof Date || c instanceof RegExp ? e[i] = r(c, { symbols: o.symbols }) : a.merge(e[i], c, o); } else c == null ? o.nullOverride && (e[i] = c) : e[i] = c; } return e; }; })), b = /* @__PURE__ */ s(((e, t) => { var n = m(), r = v(), i = y(), a = h(), o = {}; t.exports = function(e, t, a = {}) { if (n(e && typeof e == "object", "Invalid defaults value: must be an object"), n(!t || t === !0 || typeof t == "object", "Invalid source value: must be true, falsy or an object"), n(typeof a == "object", "Invalid options: must be an object"), !t) return null; if (a.shallow) return o.applyToDefaultsWithShallow(e, t, a); let s = r(e); return t === !0 ? s : i(s, t, { nullOverride: a.nullOverride === void 0 ? !1 : a.nullOverride, mergeArrays: !1 }); }, o.applyToDefaultsWithShallow = function(e, t, s) { let c = s.shallow; n(Array.isArray(c), "Invalid keys"); let l = /* @__PURE__ */ new Map(), u = t === !0 ? null : /* @__PURE__ */ new Set(); for (let n of c) { n = Array.isArray(n) ? n : n.split("."); let r = a(e, n); r && typeof r == "object" ? l.set(r, u && a(t, n) || r) : u && u.add(n); } let d = r(e, {}, l); if (!u) return d; for (let e of u) o.reachCopy(d, t, e); return i(d, t, { nullOverride: s.nullOverride === void 0 ? !1 : s.nullOverride, mergeArrays: !1 }); }, o.reachCopy = function(e, t, n) { for (let e of n) { if (!(e in t)) return; let n = t[e]; if (typeof n != "object" || !n) return; t = n; } let r = t, i = e; for (let e = 0; e < n.length - 1; ++e) { let t = n[e]; typeof i[t] != "object" && (i[t] = {}), i = i[t]; } i[n[n.length - 1]] = r; }; })), x = /* @__PURE__ */ s(((e, t) => { t.exports = {}; })), S = /* @__PURE__ */ s(((e, t) => { var n = g(), r = { mismatched: null }; t.exports = function(e, t, n) { return n = Object.assign({ prototype: !0 }, n), !!r.isDeepEqual(e, t, n, []); }, r.isDeepEqual = function(e, t, i, a) { if (e === t) return e !== 0 || 1 / e == 1 / t; let o = typeof e; if (o !== typeof t || e === null || t === null) return !1; if (o === "function") { if (!i.deepFunction || e.toString() !== t.toString()) return !1; } else if (o !== "object") return e !== e && t !== t; let s = r.getSharedType(e, t, !!i.prototype); switch (s) { case n.buffer: return !1; case n.promise: return e === t; case n.regex: case n.url: return e.toString() === t.toString(); case r.mismatched: return !1; } for (let n = a.length - 1; n >= 0; --n) if (a[n].isSame(e, t)) return !0; a.push(new r.SeenEntry(e, t)); try { return !!r.isDeepEqualObj(s, e, t, i, a); } finally { a.pop(); } }, r.getSharedType = function(e, t, i) { if (i) return Object.getPrototypeOf(e) === Object.getPrototypeOf(t) ? n.getInternalProto(e) : r.mismatched; let a = n.getInternalProto(e); return a === n.getInternalProto(t) ? a : r.mismatched; }, r.valueOf = function(e) { let t = e.valueOf; if (t === void 0) return e; try { return t.call(e); } catch (e) { return e; } }, r.hasOwnEnumerableProperty = function(e, t) { return Object.prototype.propertyIsEnumerable.call(e, t); }, r.isSetSimpleEqual = function(e, t) { for (let n of Set.prototype.values.call(e)) if (!Set.prototype.has.call(t, n)) return !1; return !0; }, r.isDeepEqualObj = function(e, t, i, a, o) { let { isDeepEqual: s, valueOf: c, hasOwnEnumerableProperty: l } = r, { keys: u, getOwnPropertySymbols: d } = Object; if (e === n.array) if (a.part) { for (let e of t) for (let t of i) if (s(e, t, a, o)) return !0; } else { if (t.length !== i.length) return !1; for (let e = 0; e < t.length; ++e) if (!s(t[e], i[e], a, o)) return !1; return !0; } else if (e === n.set) { if (t.size !== i.size) return !1; if (!r.isSetSimpleEqual(t, i)) { let e = new Set(Set.prototype.values.call(i)); for (let n of Set.prototype.values.call(t)) { if (e.delete(n)) continue; let t = !1; for (let r of e) if (s(n, r, a, o)) { e.delete(r), t = !0; break; } if (!t) return !1; } } } else if (e === n.map) { if (t.size !== i.size) return !1; for (let [e, n] of Map.prototype.entries.call(t)) if (n === void 0 && !Map.prototype.has.call(i, e) || !s(n, Map.prototype.get.call(i, e), a, o)) return !1; } else if (e === n.error && (t.name !== i.name || t.message !== i.message)) return !1; let f = c(t), p = c(i); if ((t !== f || i !== p) && !s(f, p, a, o)) return !1; let m = u(t); if (!a.part && m.length !== u(i).length && !a.skip) return !1; let h = 0; for (let e of m) { if (a.skip && a.skip.includes(e)) { i[e] === void 0 && ++h; continue; } if (!l(i, e) || !s(t[e], i[e], a, o)) return !1; } if (!a.part && m.length - h !== u(i).length) return !1; if (a.symbols !== !1) { let e = d(t), n = new Set(d(i)); for (let r of e) { if (!a.skip?.includes(r)) { if (l(t, r)) { if (!l(i, r) || !s(t[r], i[r], a, o)) return !1; } else if (l(i, r)) return !1; } n.delete(r); } for (let e of n) if (l(i, e)) return !1; } return !0; }, r.SeenEntry = class { constructor(e, t) { this.obj = e, this.ref = t; } isSame(e, t) { return this.obj === e && this.ref === t; } }; })), C = /* @__PURE__ */ s(((e, t) => { var n = {}; t.exports = function(e) { if (!e) return ""; let t = ""; for (let r = 0; r < e.length; ++r) { let i = e.charCodeAt(r); n.isSafe(i) ? t += e[r] : t += n.escapeHtmlChar(i); } return t; }, n.escapeHtmlChar = function(e) { return n.namedHtml.get(e) || (e >= 256 ? "&#" + e + ";" : `&#x${e.toString(16).padStart(2, "0")};`); }, n.isSafe = function(e) { return n.safeCharCodes.has(e); }, n.namedHtml = new Map([ [38, "&amp;"], [60, "&lt;"], [62, "&gt;"], [34, "&quot;"], [160, "&nbsp;"], [162, "&cent;"], [163, "&pound;"], [164, "&curren;"], [169, "&copy;"], [174, "&reg;"] ]), n.safeCharCodes = function() { let e = /* @__PURE__ */ new Set(); for (let t = 32; t < 123; ++t) (t >= 97 || t >= 65 && t <= 90 || t >= 48 && t <= 57 || t === 32 || t === 46 || t === 44 || t === 45 || t === 58 || t === 95) && e.add(t); return e; }(); })), w = /* @__PURE__ */ s(((e, t) => { t.exports = function(e) { return e.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, "\\$&"); }; })), T = /* @__PURE__ */ s(((e, t) => { t.exports = function() {}; })), E = /* @__PURE__ */ s(((e) => { e.applyToDefaults = b(), e.assert = m(), e.AssertError = f(), e.Bench = x(), e.block = x(), e.clone = v(), e.contain = x(), e.deepEqual = S(), e.escapeHeaderAttribute = x(), e.escapeHtml = C(), e.escapeJson = x(), e.escapeRegex = w(), e.flatten = x(), e.ignore = T(), e.intersect = x(), e.isPromise = x(), e.merge = y(), e.once = x(), e.reach = h(), e.reachTemplate = x(), e.stringify = p(), e.wait = x(); })), D = /* @__PURE__ */ c({ default: () => k, version: () => O }), O, k, ee = o((() => { O = "18.2.1", k = { version: "18.2.1" }; })), te = /* @__PURE__ */ s(((e) => { var t = $(), n = {}; n.wrap = t.string().min(1).max(2).allow(!1), e.preferences = t.object({ allowUnknown: t.boolean(), abortEarly: t.boolean(), artifacts: t.boolean(), cache: t.boolean(), context: t.object(), convert: t.boolean(), dateFormat: t.valid("date", "iso", "string", "time", "utc"), debug: t.boolean(), errors: { escapeHtml: t.boolean(), label: t.valid("path", "key", !1), language: [t.string(), t.object().ref()], render: t.boolean(), stack: t.boolean(), wrap: { label: n.wrap, array: n.wrap, string: n.wrap } }, externals: t.boolean(), messages: t.object(), noDefaults: t.boolean(), nonEnumerables: t.boolean(), presence: t.valid("required", "optional", "forbidden"), skipFunctions: t.boolean(), stripUnknown: t.object({ arrays: t.boolean(), objects: t.boolean() }).or("arrays", "objects").allow(!0, !1), warnings: t.boolean() }).strict(), n.nameRx = /^[a-zA-Z0-9]\w*$/, n.rule = t.object({ alias: t.array().items(t.string().pattern(n.nameRx)).single(), args: t.array().items(t.string(), t.object({ name: t.string().pattern(n.nameRx).required(), ref: t.boolean(), assert: t.alternatives([t.function(), t.object().schema()]).conditional("ref", { is: !0, then: t.required() }), normalize: t.function(), message: t.string().when("assert", { is: t.function(), then: t.required() }) })), convert: t.boolean(), manifest: t.boolean(), method: t.function().allow(!1), multi: t.boolean(), validate: t.function(), jsonSchema: t.function() }), e.extension = t.object({ type: t.alternatives([t.string(), t.object().regex()]).required(), args: t.function(), cast: t.object().pattern(n.nameRx, t.object({ from: t.function().maxArity(1).required(), to: t.function().minArity(1).maxArity(2).required() })), base: t.object().schema().when("type", { is: t.object().regex(), then: t.forbidden() }), coerce: [t.function().maxArity(3), t.object({ method: t.function().maxArity(3).required(), from: t.array().items(t.string()).single() })], flags: t.object().pattern(n.nameRx, t.object({ setter: t.string(), default: t.any() })), manifest: { build: t.function().arity(2) }, messages: [t.object(), t.string()], modifiers: t.object().pattern(n.nameRx, t.function().minArity(1).maxArity(2)), overrides: t.object().pattern(n.nameRx, t.function()), prepare: t.function().maxArity(3), rebuild: t.function().arity(1), rules: t.object().pattern(n.nameRx, n.rule), jsonSchema: t.function(), terms: t.object().pattern(n.nameRx, t.object({ init: t.array().allow(null).required(), manifest: t.object().pattern(/.+/, [t.valid("schema", "single"), t.object({ mapped: t.object({ from: t.string().required(), to: t.string().required() }).required() })]) })), validate: t.function().maxArity(3) }).strict(), e.extensions = t.array().items(t.object(), t.function().arity(1)).strict(), n.desc = { buffer: t.object({ buffer: t.string() }), func: t.object({ function: t.function().required(), options: { literal: !0 } }), override: t.object({ override: !0 }), ref: t.object({ ref: t.object({ type: t.valid("value", "global", "local"), path: t.array().required(), separator: t.string().length(1).allow(!1), ancestor: t.number().min(0).integer().allow("root"), map: t.array().items(t.array().length(2)).min(1), adjust: t.function(), iterables: t.boolean(), in: t.boolean(), render: t.boolean() }).required() }), regex: t.object({ regex: t.string().min(3) }), special: t.object({ special: t.valid("deep").required() }), template: t.object({ template: t.string().required(), options: t.object() }), value: t.object({ value: t.alternatives([t.object(), t.array()]).required() }) }, n.desc.entity = t.alternatives([ t.array().items(t.link("...")), t.boolean(), t.function(), t.number(), t.string(), n.desc.buffer, n.desc.func, n.desc.ref, n.desc.regex, n.desc.special, n.desc.template, n.desc.value, t.link("/") ]), n.desc.values = t.array().items(null, t.boolean(), t.function(), t.number().allow(Infinity, -Infinity, NaN), t.string().allow(""), t.symbol(), n.desc.buffer, n.desc.func, n.desc.override, n.desc.ref, n.desc.regex, n.desc.template, n.desc.value), n.desc.messages = t.object().pattern(/.+/, [ t.string(), n.desc.template, t.object().pattern(/.+/, [t.string(), n.desc.template]) ]), e.description = t.object({ type: t.string().required(), flags: t.object({ cast: t.string(), default: t.any(), description: t.string(), empty: t.link("/"), failover: n.desc.entity, id: t.string(), label: t.string(), only: !0, presence: [ "optional", "required", "forbidden" ], result: ["raw", "strip"], strip: t.boolean(), unit: t.string() }).unknown(), preferences: { allowUnknown: t.boolean(), abortEarly: t.boolean(), artifacts: t.boolean(), cache: t.boolean(), convert: t.boolean(), dateFormat: [ "date", "iso", "string", "time", "utc" ], errors: { escapeHtml: t.boolean(), label: ["path", "key"], language: [t.string(), n.desc.ref], wrap: { label: n.wrap, array: n.wrap } }, externals: t.boolean(), messages: n.desc.messages, noDefaults: t.boolean(), nonEnumerables: t.boolean(), presence: [ "required", "optional", "forbidden" ], skipFunctions: t.boolean(), stripUnknown: t.object({ arrays: t.boolean(), objects: t.boolean() }).or("arrays", "objects").allow(!0, !1), warnings: t.boolean() }, allow: n.desc.values, invalid: n.desc.values, rules: t.array().min(1).items({ name: t.string().required(), args: t.object().min(1), keep: t.boolean(), message: [t.string(), n.desc.messages], warn: t.boolean() }), keys: t.object().pattern(/.*/, t.link("/")), link: n.desc.ref }).pattern(/^[a-z]\w*$/, t.any()); })), ne = /* @__PURE__ */ s(((e) => { var t = { operators: [ "!", "^", "*", "/", "%", "+", "-", "<", "<=", ">", ">=", "==", "!=", "&&", "||", "??" ], operatorCharacters: [ "!", "^", "*", "/", "%", "+", "-", "<", "=", ">", "&", "|", "?" ], operatorsOrder: [ ["^"], [ "*", "/", "%" ], ["+", "-"], [ "<", "<=", ">", ">=" ], ["==", "!="], ["&&"], ["||", "??"] ], operatorsPrefix: ["!", "n"], literals: { "\"": "\"", "`": "`", "'": "'", "[": "]" }, numberRx: /^(?:[0-9]*(\.[0-9]*)?){1}$/, tokenRx: /^[\w\$\#\.\@\:\{\}]+$/, symbol: Symbol("formula"), settings: Symbol("settings") }; e.Parser = class { constructor(e, n = {}) { if (!n[t.settings] && n.constants) for (let e in n.constants) { let t = n.constants[e]; if (t !== null && ![ "boolean", "number", "string" ].includes(typeof t)) throw Error(`Formula constant ${e} contains invalid ${typeof t} value type`); } this.settings = n[t.settings] ? n : Object.assign({ [t.settings]: !0, constants: {}, functions: {} }, n), this.single = null, this._parts = null, this._parse(e); } _parse(n) { let r = [], i = "", a = 0, o = !1, s = (n) => { if (a) throw Error("Formula missing closing parenthesis"); let s = r.length ? r[r.length - 1] : null; if (!(!o && !i && !n)) { if (s && s.type === "reference" && n === ")") { s.type = "function", s.value = this._subFormula(i, s.value), i = ""; return; } if (n === ")") { let t = new e.Parser(i, this.settings); r.push({ type: "segment", value: t }); } else if (o) { if (o === "]") { r.push({ type: "reference", value: i }), i = ""; return; } r.push({ type: "literal", value: i }); } else if (t.operatorCharacters.includes(i)) s && s.type === "operator" && t.operators.includes(s.value + i) ? s.value += i : r.push({ type: "operator", value: i }); else if (i.match(t.numberRx)) r.push({ type: "constant", value: parseFloat(i) }); else if (this.settings.constants[i] !== void 0) r.push({ type: "constant", value: this.settings.constants[i] }); else { if (!i.match(t.tokenRx)) throw Error(`Formula contains invalid token: ${i}`); r.push({ type: "reference", value: i }); } i = ""; } }; for (let e of n) o ? e === o ? (s(), o = !1) : i += e : a ? e === "(" ? (i += e, ++a) : e === ")" ? (--a, a ? i += e : s(e)) : i += e : e in t.literals ? o = t.literals[e] : e === "(" ? (s(), ++a) : t.operatorCharacters.includes(e) ? (s(), i = e, s()) : e === " " ? s() : i += e; s(), r = r.map((e, t) => e.type !== "operator" || e.value !== "-" || t && r[t - 1].type !== "operator" ? e : { type: "operator", value: "n" }); let c = !1; for (let e of r) { if (e.type === "operator") { if (t.operatorsPrefix.includes(e.value)) continue; if (!c) throw Error("Formula contains an operator in invalid position"); if (!t.operators.includes(e.value)) throw Error(`Formula contains an unknown operator ${e.value}`); } else if (c) throw Error("Formula missing expected operator"); c = !c; } if (!c) throw Error("Formula contains invalid trailing operator"); r.length === 1 && [ "reference", "literal", "constant" ].includes(r[0].type) && (this.single = { type: r[0].type === "reference" ? "reference" : "value", value: r[0].value }), this._parts = r.map((e) => { if (e.type === "operator") return t.operatorsPrefix.includes(e.value) ? e : e.value; if (e.type !== "reference") return e.value; if (this.settings.tokenRx && !this.settings.tokenRx.test(e.value)) throw Error(`Formula contains invalid reference ${e.value}`); return this.settings.reference ? this.settings.reference(e.value) : t.reference(e.value); }); } _subFormula(n, r) { let i = this.settings.functions[r]; if (typeof i != "function") throw Error(`Formula contains unknown function ${r}`); let a = []; if (n) { let e = "", i = 0, o = !1, s = () => { if (!e) throw Error(`Formula contains function ${r} with invalid arguments ${n}`); a.push(e), e = ""; }; for (let r = 0; r < n.length; ++r) { let a = n[r]; o ? (e += a, a === o && (o = !1)) : a in t.literals && !i ? (e += a, o = t.literals[a]) : a === "," && !i ? s() : (e += a, a === "(" ? ++i : a === ")" && --i); } s(); } return a = a.map((t) => new e.Parser(t, this.settings)), function(e) { let t = []; for (let n of a) t.push(n.evaluate(e)); return i.call(e, ...t); }; } evaluate(e) { let n = this._parts.slice(); for (let r = n.length - 2; r >= 0; --r) { let i = n[r]; if (i && i.type === "operator") { let a = n[r + 1]; n.splice(r + 1, 1); let o = t.evaluate(a, e); n[r] = t.single(i.value, o); } } return t.operatorsOrder.forEach((r) => { for (let i = 1; i < n.length - 1;) if (r.includes(n[i])) { let r = n[i], a = t.evaluate(n[i - 1], e), o = t.evaluate(n[i + 1], e); n.splice(i, 2); let s = t.calculate(r, a, o); n[i - 1] = s === 0 ? 0 : s; } else i += 2; }), t.evaluate(n[0], e); } }, e.Parser.prototype[t.symbol] = !0, t.reference = function(e) { return function(t) { return t && t[e] !== void 0 ? t[e] : null; }; }, t.evaluate = function(e, n) { return e === null ? null : typeof e == "function" ? e(n) : e[t.symbol] ? e.evaluate(n) : e; }, t.single = function(e, t) { if (e === "!") return !t; let n = -t; return n === 0 ? 0 : n; }, t.calculate = function(e, n, r) { if (e === "??") return t.exists(n) ? n : r; if (typeof n == "string" || typeof r == "string") { if (e === "+") return n = t.exists(n) ? n : "", r = t.exists(r) ? r : "", n + r; } else switch (e) { case "^": return n ** +r; case "*": return n * r; case "/": return n / r; case "%": return n % r; case "+": return n + r; case "-": return n - r; } switch (e) { case "<": return n < r; case "<=": return n <= r; case ">": return n > r; case ">=": return n >= r; case "==": return n === r; case "!=": return n !== r; case "&&": return n && r; case "||": return n || r; } return null; }, t.exists = function(e) { return e != null; }; })), A = /* @__PURE__ */ s(((e) => { var t = x(), n = P(), r = M(); e.Report = class { constructor(t, n, r, i, a, o, s) { if (this.code = t, this.flags = i, this.messages = a, this.path = o.path, this.prefs = s, this.state = o, this.value = n, this.message = null, this.template = null, this.local = r || {}, this.local.label = e.label(this.flags, this.state, this.prefs, this.messages), this.value !== void 0 && !this.local.hasOwnProperty("value") && (this.local.value = this.value), this.path.length) { let e = this.path[this.path.length - 1]; typeof e != "object" && (this.local.key = e); } } _setTemplate(e) { if (this.template = e, !this.flags.label && this.path.length === 0) { let e = this._template(this.template, "root"); e && (this.local.label = e); } } toString() { if (this.message) return this.message; let e = this.code; if (!this.prefs.errors.render) return this.code; let t = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages); return t === void 0 ? `Error code "${e}" is not defined, your custom type is missing the correct messages definition` : (this.message = t.render(this.value, this.state, this.prefs, this.local, { errors: this.prefs.errors, messages: [this.prefs.messages, this.messages] }), this.prefs.errors.label || (this.message = this.message.replace(/^"" /, "").trim()), this.message); } _template(t, n) { return e.template(this.value, t, n || this.code, this.state, this.prefs); } }, e.path = function(e) { let t = ""; for (let n of e) typeof n != "object" && (typeof n == "string" ? (t && (t += "."), t += n) : t += `[${n}]`); return t; }, e.template = function(e, t, i, a, o) { if (!t) return; if (r.isTemplate(t)) return i === "root" ? null : t; let s = o.errors.language; if (n.isResolvable(s) && (s = s.resolve(e, a, o)), s && t[s]) { if (t[s][i] !== void 0) return t[s][i]; if (t[s]["*"] !== void 0) return t[s]["*"]; } return t[i] ? t[i] : t["*"]; }, e.label = function(t, n, r, i) { if (!r.errors.label) return ""; if (t.label) return t.label; let a = n.path; return r.errors.label === "key" && n.path.length > 1 && (a = n.path.slice(-1)), e.path(a) || e.template(null, r.messages, "root", n, r) || i && e.template(null, i, "root", n, r) || "value"; }, e.process = function(t, n, r) { if (!t) return null; let { override: i, message: a, details: o } = e.details(t); if (i) return i; if (r.errors.stack) return new e.ValidationError(a, o, n); let s = Error.stackTraceLimit; Error.stackTraceLimit = 0; let c = new e.ValidationError(a, o, n); return Error.stackTraceLimit = s, c; }, e.details = function(e, t = {}) { let n = [], r = []; for (let i of e) { if (i instanceof Error) { if (t.override !== !1) return { override: i }; let e = i.toString(); n.push(e), r.push({ message: e, type: "override", context: { error: i } }); continue; } let e = i.toString(); n.push(e), r.push({ message: e, path: i.path.filter((e) => typeof e != "object"), type: i.code, context: i.local }); } return n.length > 1 && (n = [...new Set(n)]), { message: n.join(". "), details: r }; }, e.ValidationError = class extends Error { constructor(e, t, n) { super(e), this._original = n, this.details = t; } static isError(t) { return t instanceof e.ValidationError; } }, e.ValidationError.prototype.isJoi = !0, e.ValidationError.prototype.name = "ValidationError", e.ValidationError.prototype.annotate = t.error; })), j = /* @__PURE__ */ s(((e) => { var { assert: t, clone: n, reach: r } = E(), i = P(), a, o = { symbol: Symbol("ref"), defaults: { adjust: null, in: !1, iterables: null, map: null, separator: ".", type: "value" } }; e.create = function(e, n = {}) { t(typeof e == "string", "Invalid reference key:", e), i.assertOptions(n, [ "adjust", "ancestor", "in", "iterables", "map", "prefix", "render", "separator" ]), t(!n.prefix || typeof n.prefix == "object", "options.prefix must be of type object"); let r = Object.assign({}, o.defaults, n); delete r.prefix; let a = r.separator, s = o.context(e, a, n.prefix); if (r.type = s.type, e = s.key, r.type === "value") if (s.root && (t(!a || e[0] !== a, "Cannot specify relative path with root prefix"), r.ancestor = "root", e ||= null), a && a === e) e = null, r.ancestor = 0; else if (r.ancestor !== void 0) t(!a || !e || e[0] !== a, "Cannot combine prefix with ancestor option"); else { let [t, n] = o.ancestor(e, a); n && (e = e.slice(n), e === "" && (e = null)), r.ancestor = t; } return r.path = a ? e === null ? [] : e.split(a) : [e], new o.Ref(r); }, e.in = function(t, n = {}) { return e.create(t, { ...n, in: !0 }); }, e.isRef = function(e) { return e ? !!e[i.symbols.ref] : !1; }, o.Ref = class { constructor(e) { t(typeof e == "object", "Invalid reference construction"), i.assertOptions(e, [ "adjust", "ancestor", "in", "iterables", "map", "path", "render", "separator", "type", "depth", "key", "root", "display" ]), t([!1, void 0].includes(e.separator) || typeof e.separator == "string" && e.separator.length === 1, "Invalid separator"), t(!e.adjust || typeof e.adjust == "function", "options.adjust must be a function"), t(!e.map || Array.isArray(e.map), "options.map must be an array"), t(!e.map || !e.adjust, "Cannot set both map and adjust options"), Object.assign(this, o.defaults, e), t(this.type === "value" || this.ancestor === void 0, "Non-value references cannot reference ancestors"), Array.isArray(this.map) && (this.map = new Map(this.map)), this.depth = this.path.length, this.key = this.path.length ? this.path.join(this.separator) : null, this.root = this.path[0], this.updateDisplay(); } resolve(e, n, r, i, a = {}) { return t(!this.in || a.in, "Invalid in() reference usage"), this.type === "global" ? this._resolve(r.context, n, a) : this.type === "local" ? this._resolve(i, n, a) : this.ancestor ? this.ancestor === "root" ? this._resolve(n.ancestors[n.ancestors.length - 1], n, a) : (t(this.ancestor <= n.ancestors.length, "Invalid reference exceeds the schema root:", this.display), this._resolve(n.ancestors[this.ancestor - 1], n, a)) : this._resolve(e, n, a); } _resolve(e, t, n) { let i; if (this.type === "value" && t.mainstay.shadow && n.shadow !== !1 && (i = t.mainstay.shadow.get(this.absolute(t))), i === void 0 && (i = r(e, this.path, { iterables: this.iterables, functions: !0 })), this.adjust && (i = this.adjust(i)), this.map) { let e = this.map.get(i); e !== void 0 && (i = e); } return t.mainstay && t.mainstay.tracer.resolve(t, this, i), i; } toString() { return this.display; } absolute(e) { return [...e.path.slice(0, -this.ancestor), ...this.path]; } clone() { return new o.Ref(this); } describe() { let e = { path: this.path }; this.type !== "value" && (e.type = this.type), this.separator !== "." && (e.separator = this.separator), this.type === "value" && this.ancestor !== 1 && (e.ancestor = this.ancestor), this.map && (e.map = [...this.map]); for (let t of [ "adjust", "iterables", "render" ]) this[t] !== null && this[t] !== void 0 && (e[t] = this[t]); return this.in !== !1 && (e.in = !0), { ref: e }; } updateDisplay() { let e = this.key === null ? "" : this.key; if (this.type !== "value") { this.display = `ref:${this.type}:${e}`; return; } if (!this.separator) { this.display = `ref:${e}`; return; } if (!this.ancestor) { this.display = `ref:${this.separator}${e}`; return; } if (this.ancestor === "root") { this.display = `ref:root:${e}`; return; } if (this.ancestor === 1) { this.display = `ref:${e || ".."}`; return; } let t = Array(this.ancestor + 1).fill(this.separator).join(""); this.display = `ref:${t}${e || ""}`; } }, o.Ref.prototype[i.symbols.ref] = !0, e.build = function(e) { return e = Object.assign({}, o.defaults, e), e.type === "value" && e.ancestor === void 0 && (e.ancestor = 1), new o.Ref(e); }, o.context = function(e, t, n = {}) { if (e = e.trim(), n) { let r = n.global === void 0 ? "$" : n.global; if (r !== t && e.startsWith(r)) return { key: e.slice(r.length), type: "global" }; let i = n.local === void 0 ? "#" : n.local; if (i !== t && e.startsWith(i)) return { key: e.slice(i.length), type: "local" }; let a = n.root === void 0 ? "/" : n.root; if (a !== t && e.startsWith(a)) return { key: e.slice(a.length), type: "value", root: !0 }; } return { key: e, type: "value" }; }, o.ancestor = function(e, t) { if (!t || e[0] !== t) return [1, 0]; if (e[1] !== t) return [0, 1]; let n = 2; for (; e[n] === t;) ++n; return [n - 1, n]; }, e.toSibling = 0, e.toParent = 1, e.Manager = class { constructor() { this.refs = []; } register(t, n) { if (t) { if (n = n === void 0 ? e.toParent : n, Array.isArray(t)) { for (let e of t) this.register(e, n); return; } if (i.isSchema(t)) { for (let e of t._refs.refs) e.ancestor - n >= 0 && this.refs.push({ ancestor: e.ancestor - n, root: e.root }); return; } e.isRef(t) && t.type === "value" && t.ancestor - n >= 0 && this.refs.push({ ancestor: t.ancestor - n, root: t.root }), a ||= M(), a.isTemplate(t) && this.register(t.refs(), n); } } get length() { return this.refs.length; } clone() { let t = new e.Manager(); return t.refs = n(this.refs), t; } reset() { this.refs = []; } roots() { return this.refs.filter((e) => !e.ancestor).map((e) => e.root); } }; })), M = /* @__PURE__ */ s(((e, t) => { var { assert: n, clone: r, escapeHtml: i } = E(), a = ne(), o = P(), s = A(), c = j(), l = { symbol: Symbol("template"), opens: Array(1e3).join("\0"), closes: Array(1e3).join(""), dateFormat: { date: Date.prototype.toDateString, iso: Date.prototype.toISOString, string: Date.prototype.toString, time: Date.prototype.toTimeString, utc: Date.prototype.toUTCString } }; t.exports = e = l.Template = class { constructor(e, t) { if (n(typeof e == "string", "Template source must be a string"), n(!e.includes("\0") && !e.includes(""), "Template source cannot contain reserved control characters"), this.source = e, this.rendered = e, this._template = null, t) { let { functions: e, ...i } = t; this._settings = Object.keys(i).length ? r(i) : void 0, this._functions = e, this._functions && (n(Object.keys(this._functions).every((e) => typeof e == "string"), "Functions keys must be strings"), n(Object.values(this._functions).every((e) => typeof e == "function"), "Functions values must be functions")); } else this._settings = void 0, this._functions = void 0; this._parse(); } _parse() { if (!this.source.includes("{")) return; let e = l.encode(this.source), t = l.split(e), n = !1, r = [], i = t.shift(); i && r.push(l.decode(i)); for (let e of t) { let t = e[0] !== "{", i = t ? "}" : "}}", a = e.indexOf(i); if (a === -1 || e[1] === "{") { r.push(`{${l.decode(e)}`); continue; } let o = e.slice(+!t, a), s = o[0] === ":"; s && (o = o.slice(1)); let c = this._ref(l.decode(o), { raw: t, wrapped: s }); r.push(c), typeof c != "string" && (n = !0); let u = e.slice(a + i.length); u && r.push(l.decode(u)); } if (!n) { this.rendered = r.join(""); return; } this._template = r; } static date(e, t) { return l.dateFormat[t.dateFormat].call(e); } describe(e = {}) { if (!this._settings && e.compact) return this.source; let t = { template: this.source }; return this._settings && (t.options = this._settings), this._functions && (t.functions = this._functions), t; } static build(e) { return new l.Template(e.template, e.options || e.functions ? { ...e.options, functions: e.functions } : void 0); } isDynamic() { return !!this._template; } static isTemplate(e) { return e ? !!e[o.symbols.template] : !1; } refs() { if (!this._template) return; let e = []; for (let t of this._template) typeof t != "string" && e.push(...t.refs); return e; } resolve(e, t, n, r) { return this._template && this._template.length === 1 ? this._part(this._template[0], e, t, n, r, {}) : this.render(e, t, n, r); } _part(e, ...t) { return e.ref ? e.ref.resolve(...t) : e.formula.evaluate(t); } render(e, t, n, r, a = {}) { if (!this.isDynamic()) return this.rendered; let o = []; for (let s of this._template) if (typeof s == "string") o.push(s); else { let c = this._part(s, e, t, n, r, a), u = l.stringify(c, e, t, n, r, a); if (u !== void 0) { let e = s.raw || (a.errors && a.errors.escapeHtml) === !1 ? u : i(u); o.push(l.wrap(e, s.wrapped && n.errors.wrap.label)); } } return o.join(""); } _ref(e, { raw: t, wrapped: n }) { let r = [], i = (e) => { let t = c.create(e, this._settings); return r.push(t), (e) => { let n = t.resolve(...e); return n === void 0 ? null : n; }; }; try { let t = this._functions ? { ...l.functions, ...this._functions } : l.functions; var o = new a.Parser(e, { reference: i, functions: t, constants: l.constants }); } catch (t) { throw t.message = `Invalid template variable "${e}" fails due to: ${t.message}`, t; } if (o.single) { if (o.single.type === "reference") { let e = r[0]; return { ref: e, raw: t, refs: r, wrapped: n || e.type === "local" && e.key === "label" }; } return l.stringify(o.single.value); } return { formula: o, raw: t, refs: r }; } toString() { return this.source; } }, l.Template.prototype[o.symbols.template] = !0, l.Template.prototype.isImmutable = !0, l.encode = function(e) { return e.replace(/\\(\{+)/g, (e, t) => l.opens.slice(0, t.length)).replace(/\\(\}+)/g, (e, t) => l.closes.slice(0, t.length)); }, l.decode = function(e) { return e.replace(/\u0000/g, "{").replace(/\u0001/g, "}"); }, l.split = function(e) { let t = [], n = ""; for (let r = 0; r < e.length; ++r) { let i = e[r]; if (i === "{") { let i = ""; for (; r + 1 < e.length && e[r + 1] === "{";) i += "{", ++r; t.push(n), n = i; } else n += i; } return t.push(n), t; }, l.wrap = function(e, t) { return t ? t.length === 1 ? `${t}${e}${t}` : `${t[0]}${e}${t[1]}` : e; }, l.stringify = function(e, t, n, r, i, a = {}) { let o = typeof e, s = r && r.errors && r.errors.wrap || {}, u = !1; if (c.isRef(e) && e.render && (u = e.in, e = e.resolve(t, n, r, i, { in: e.in, ...a })), e === null) return "null"; if (o === "string") return l.wrap(e, a.arrayItems && s.string); if (o === "number" || o === "function" || o === "symbol") return e.toString(); if (o !== "object") return JSON.stringify(e); if (e instanceof Date) return l.Template.date(e, r); if (e instanceof Map) { let t = []; for (let [n, r] of e.entries()) t.push(`${n.toString()} -> ${r.toString()}`); e = t; } if (!Array.isArray(e)) return e.toString(); let d = []; for (let o of e) d.push(l.stringify(o, t, n, r, i, { arrayItems: !0, ...a })); return l.wrap(d.join(", "), !u && s.array); }, l.constants = { true: !0, false: !1, null: null, second: 1e3, minute: 60 * 1e3, hour: 3600 * 1e3, day: 1440 * 60 * 1e3 }, l.functions = { if(e, t, n) { return e ? t : n; }, length(e) { return typeof e == "string" ? e.length : !e || typeof e != "object" ? null : Array.isArray(e) ? e.length : Object.keys(e).length; }, msg(e) { let [t, n, r, i, a] = this, o = a.messages; if (!o) return ""; let c = s.template(t, o[0], e, n, r) || s.template(t, o[1], e, n, r); return c ? c.render(t, n, r, i, a) : ""; }, number(e) { return typeof e == "number" ? e : typeof e == "string" ? parseFloat(e) : typeof e == "boolean" ? +!!e : e instanceof Date ? e.getTime() : null; } }; })), N = /* @__PURE__ */ s(((e) => { var { assert: t, clone: n } = E(), r = M(); e.compile = function(e, i) { if (typeof e == "string") return t(!i, "Cannot set single message string"), new r(e); if (r.isTemplate(e)) return t(!i, "Cannot set single message template"), e; t(typeof e == "object" && !Array.isArray(e), "Invalid message options"), i = i ? n(i) : {}; for (let n in e) { let a = e[n]; if (n === "root" || r.isTemplate(a)) { i[n] = a; continue; } if (typeof a == "string") { i[n] = new r(a); continue; } t(typeof a == "object" && !Array.isArray(a), "Invalid message for", n); let o = n; for (n in i[o] = i[o] || {}, a) { let e = a[n]; if (n === "root" || r.isTemplate(e)) { i[o][n] = e; continue; } t(typeof e == "string", "Invalid message for", n, "in", o), i[o][n] = new r(e); } } return i; }, e.decompile = function(e) { let t = {}; for (let n in e) { let i = e[n]; if (n === "root") { t.root = i; continue; } if (r.isTemplate(i)) { t[n] = i.describe({ compact: !0 }); continue; } let a = n; for (n in t[a] = {}, i) { let e = i[n]; if (n === "root") { t[a].root = e; continue; } t[a][n] = e.describe({ compact: !0 }); } } return t; }, e.merge = function(i, a) { if (!i) return e.compile(a); if (!a) return i; if (typeof a == "string") return new r(a); if (r.isTemplate(a)) return a; let o = n(i); for (let e in a) { let n = a[e]; if (e === "root" || r.isTemplate(n)) { o[e] = n; continue; } if (typeof n == "string") { o[e] = new r(n); continue; } t(typeof n == "object" && !Array.isArray(n), "Invalid message for", e); let i = e; for (e in o[i] = o[i] || {}, n) { let a = n[e]; if (e === "root" || r.isTemplate(a)) { o[i][e] = a; continue; } t(typeof a == "string", "Invalid message for", e, "in", i), o[i][e] = new r(a); } } return o; }; })), P = /* @__PURE__ */ s(((e) => { var { assert: t, AssertError: n } = E(), r = (ee(), d(D)), i, a, o = { isoDate: /^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/ }; e.version = r.version, e.defaults = { abortEarly: !0, allowUnknown: !1, artifacts: !1, cache: !0, context: null, convert: !0, dateFormat: "iso", errors: { escapeHtml: !1, label: "path", language: null, render: !0, stack: !1, wrap: { label: "\"", array: "[]" } }, externals: !0, messages: {}, nonEnumerables: !1, noDefaults: !1, presence: "optional", skipFunctions: !1, stripUnknown: !1, warnings: !1 }, e.symbols = { any: Symbol.for("@hapi/joi/schema"), arraySingle: Symbol("arraySingle"), deepDefault: Symbol("deepDefault"), errors: Symbol("errors"), literal: Symbol("literal"), override: Symbol("override"), parent: Symbol("parent"), prefs: Symbol("prefs"), ref: Symbol("ref"), template: Symbol("template"), values: Symbol("values") }, e.assertOptions = function(e, n, r = "Options") { t(e && typeof e == "object" && !Array.isArray(e), "Options must be of type object"); let i = Object.keys(e).filter((e) => !n.includes(e)); t(i.length === 0, `${r} contain unknown keys: ${i}`); }, e.checkPreferences = function(e) { a ||= te(); let t = a.preferences.validate(e); if (t.error) throw new n([t.error.details[0].message]); }, e.compare = function(e, t, n) { switch (n) { case "=": return e === t; case ">": return e > t; case "<": return e < t; case ">=": return e >= t; case "<=": return e <= t; } }, e.default = function(e, t) { return e === void 0 ? t : e; }, e.intersect = function(e, t) { if (typeof e.intersection == "function") return e.intersection(t); let n = /* @__PURE__ */ new Set(); for (let r of e) t.has(r) && n.add(r); return n; }, e.isIsoDate = function(e) { return o.isoDate.test(e); }, e.isNumber = function(e) { return typeof e == "number" && !isNaN(e); }, e.isResolvable = function(t) { return t ? t[e.symbols.ref] || t[e.symbols.template] : !1; }, e.isSchema = function(n, r = {}) { let i = n && n[e.symbols.any]; return i ? (t(r.legacy || i.version === e.version, "Cannot mix different versions of joi schemas"), !0) : !1; }, e.isValues = function(t) { return t[e.symbols.values]; }, e.limit = function(e) { return Number.isSafeInteger(e) && e >= 0; }, e.preferences = function(t, n) { i ||= N(), t ||= {}, n ||= {}; let r = Object.assign({}, t, n); return n.errors && t.errors && (r.errors = Object.assign({}, t.errors, n.errors), r.errors.wrap = Object.assign({}, t.errors.wrap, n.errors.wrap)), n.messages && (r.messages = i.compile(n.messages, t.messages)), delete r[e.symbols.prefs], r; }, e.tryWithPath = function(e, t, n = {}) { try { return e(); } catch (e) { throw e.path === void 0 ? e.path = t : e.path = t + "." + e.path, n.append && (e.message = `${e.message} (${e.path})`), e; } }, e.validateArg = function(t, n, { assert: r, message: i }) { if (e.isSchema(r)) { let e = r.validate(t); return e.error ? e.error.message : void 0; } else if (!r(t)) return n ? `${n} ${i}` : i; }, e.verifyFlat = function(e, n) { for (let r of e) t(!Array.isArray(r), "Method no longer accepts array arguments:", n); }; })), F = /* @__PURE__ */ s(((e) => { var { assert: t, clone: n } = E(), r = P(), i = { max: 1e3, supported: new Set([ "undefined", "boolean", "number", "string" ]) }; e.provider = { provision(e) { return new i.Cache(e); } }, i.Cache = class { constructor(e = {}) { r.assertOptions(e, ["max"]), t(e.max === void 0 || e.max && e.max > 0 && isFinite(e.max), "Invalid max cache size"), this._max = e.max || i.max, this._map = /* @__PURE__ */ new Map(), this._list = new i.List(); } get length() { return this._map.size; } set(e, t) { if (e !== null && !i.supported.has(typeof e)) return; let n = this._map.get(e); if (n) { n.value = t, this._list.first(n); return; } n = this._list.unshift({ key: e, value: t }), this._map.set(e, n), this._compact(); } get(e) { let t = this._map.get(e); if (t) return this._list.first(t), n(t.value); } _compact() { if (this._map.size > this._max) { let e = this._list.pop(); this._map.delete(e.key); } } }, i.List = class { constructor() { this.tail = null, this.head = null; } unshift(e) { return e.next = null,