@busha/ramp-web-sdk
Version:
Official Busha Ramp Web SDK for integrating cryptocurrency on-ramp functionality into web applications
1,528 lines (1,524 loc) • 54.6 kB
JavaScript
var $e = Object.defineProperty;
var Se = (n, e, t) => e in n ? $e(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var z = (n, e, t) => Se(n, typeof e != "symbol" ? e + "" : e, t);
const q = "busha-ramp-container", G = "busha-ramp-loader", X = "busha-ramp-styles", ee = "busha-ramp-close-btn", L = "busha-ramp-iframe", Oe = "busha-ramp-form";
const Te = "INITIALIZED", oe = "CANCELLED", ke = "COMPLETED";
function Ce(n) {
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
var J, le;
function De() {
if (le) return J;
le = 1;
function n(c) {
this._maxSize = c, this.clear();
}
n.prototype.clear = function() {
this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
}, n.prototype.get = function(c) {
return this._values[c];
}, n.prototype.set = function(c, p) {
return this._size >= this._maxSize && this.clear(), c in this._values || this._size++, this._values[c] = p;
};
var e = /[^.^\]^[]+|(?=\[\]|\.\.)/g, t = /^\d+$/, r = /^\d/, s = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, i = /^\s*(['"]?)(.*?)(\1)\s*$/, a = 512, u = new n(a), o = new n(a), d = new n(a);
J = {
Cache: n,
split: f,
normalizePath: l,
setter: function(c) {
var p = l(c);
return o.get(c) || o.set(c, function(O, y) {
for (var g = 0, T = p.length, C = O; g < T - 1; ) {
var D = p[g];
if (D === "__proto__" || D === "constructor" || D === "prototype")
return O;
C = C[p[g++]];
}
C[p[g]] = y;
});
},
getter: function(c, p) {
var w = l(c);
return d.get(c) || d.set(c, function(y) {
for (var g = 0, T = w.length; g < T; )
if (y != null || !p) y = y[w[g++]];
else return;
return y;
});
},
join: function(c) {
return c.reduce(function(p, w) {
return p + (m(w) || t.test(w) ? "[" + w + "]" : (p ? "." : "") + w);
}, "");
},
forEach: function(c, p, w) {
h(Array.isArray(c) ? c : f(c), p, w);
}
};
function l(c) {
return u.get(c) || u.set(
c,
f(c).map(function(p) {
return p.replace(i, "$2");
})
);
}
function f(c) {
return c.match(e) || [""];
}
function h(c, p, w) {
var O = c.length, y, g, T, C;
for (g = 0; g < O; g++)
y = c[g], y && (v(y) && (y = '"' + y + '"'), C = m(y), T = !C && /^\d+$/.test(y), p.call(w, y, C, T, g, c));
}
function m(c) {
return typeof c == "string" && c && ["'", '"'].indexOf(c.charAt(0)) !== -1;
}
function E(c) {
return c.match(r) && !c.match(t);
}
function x(c) {
return s.test(c);
}
function v(c) {
return !m(c) && (E(c) || x(c));
}
return J;
}
var U = De(), Q, ce;
function Ae() {
if (ce) return Q;
ce = 1;
const n = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g, e = (l) => l.match(n) || [], t = (l) => l[0].toUpperCase() + l.slice(1), r = (l, f) => e(l).join(f).toLowerCase(), s = (l) => e(l).reduce(
(f, h) => `${f}${f ? h[0].toUpperCase() + h.slice(1).toLowerCase() : h.toLowerCase()}`,
""
);
return Q = {
words: e,
upperFirst: t,
camelCase: s,
pascalCase: (l) => t(s(l)),
snakeCase: (l) => r(l, "_"),
kebabCase: (l) => r(l, "-"),
sentenceCase: (l) => t(r(l, " ")),
titleCase: (l) => e(l).map(t).join(" ")
}, Q;
}
var W = Ae(), V = { exports: {} }, fe;
function Ie() {
if (fe) return V.exports;
fe = 1, V.exports = function(s) {
return n(e(s), s);
}, V.exports.array = n;
function n(s, i) {
var a = s.length, u = new Array(a), o = {}, d = a, l = t(i), f = r(s);
for (i.forEach(function(m) {
if (!f.has(m[0]) || !f.has(m[1]))
throw new Error("Unknown node. There is an unknown node in the supplied edges.");
}); d--; )
o[d] || h(s[d], d, /* @__PURE__ */ new Set());
return u;
function h(m, E, x) {
if (x.has(m)) {
var v;
try {
v = ", node was:" + JSON.stringify(m);
} catch {
v = "";
}
throw new Error("Cyclic dependency" + v);
}
if (!f.has(m))
throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(m));
if (!o[E]) {
o[E] = !0;
var c = l.get(m) || /* @__PURE__ */ new Set();
if (c = Array.from(c), E = c.length) {
x.add(m);
do {
var p = c[--E];
h(p, f.get(p), x);
} while (E);
x.delete(m);
}
u[--a] = m;
}
}
}
function e(s) {
for (var i = /* @__PURE__ */ new Set(), a = 0, u = s.length; a < u; a++) {
var o = s[a];
i.add(o[0]), i.add(o[1]);
}
return Array.from(i);
}
function t(s) {
for (var i = /* @__PURE__ */ new Map(), a = 0, u = s.length; a < u; a++) {
var o = s[a];
i.has(o[0]) || i.set(o[0], /* @__PURE__ */ new Set()), i.has(o[1]) || i.set(o[1], /* @__PURE__ */ new Set()), i.get(o[0]).add(o[1]);
}
return i;
}
function r(s) {
for (var i = /* @__PURE__ */ new Map(), a = 0, u = s.length; a < u; a++)
i.set(s[a], a);
return i;
}
return V.exports;
}
var je = Ie();
const Ne = /* @__PURE__ */ Ce(je), Ue = Object.prototype.toString, Pe = Error.prototype.toString, Me = RegExp.prototype.toString, Re = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", ze = /^Symbol\((.*)\)(.*)$/;
function Le(n) {
return n != +n ? "NaN" : n === 0 && 1 / n < 0 ? "-0" : "" + n;
}
function de(n, e = !1) {
if (n == null || n === !0 || n === !1) return "" + n;
const t = typeof n;
if (t === "number") return Le(n);
if (t === "string") return e ? `"${n}"` : n;
if (t === "function") return "[Function " + (n.name || "anonymous") + "]";
if (t === "symbol") return Re.call(n).replace(ze, "Symbol($1)");
const r = Ue.call(n).slice(8, -1);
return r === "Date" ? isNaN(n.getTime()) ? "" + n : n.toISOString(n) : r === "Error" || n instanceof Error ? "[" + Pe.call(n) + "]" : r === "RegExp" ? Me.call(n) : null;
}
function I(n, e) {
let t = de(n, e);
return t !== null ? t : JSON.stringify(n, function(r, s) {
let i = de(this[r], e);
return i !== null ? i : s;
}, 2);
}
function be(n) {
return n == null ? [] : [].concat(n);
}
let xe, ge, Ee, qe = /\$\{\s*(\w+)\s*\}/g;
xe = Symbol.toStringTag;
class he {
constructor(e, t, r, s) {
this.name = void 0, this.message = void 0, this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = void 0, this.inner = void 0, this[xe] = "Error", this.name = "ValidationError", this.value = t, this.path = r, this.type = s, this.errors = [], this.inner = [], be(e).forEach((i) => {
if (F.isError(i)) {
this.errors.push(...i.errors);
const a = i.inner.length ? i.inner : [i];
this.inner.push(...a);
} else
this.errors.push(i);
}), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
}
}
ge = Symbol.hasInstance;
Ee = Symbol.toStringTag;
class F extends Error {
static formatError(e, t) {
const r = t.label || t.path || "this";
return t = Object.assign({}, t, {
path: r,
originalPath: t.path
}), typeof e == "string" ? e.replace(qe, (s, i) => I(t[i])) : typeof e == "function" ? e(t) : e;
}
static isError(e) {
return e && e.name === "ValidationError";
}
constructor(e, t, r, s, i) {
const a = new he(e, t, r, s);
if (i)
return a;
super(), this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = [], this.inner = [], this[Ee] = "Error", this.name = a.name, this.message = a.message, this.type = a.type, this.value = a.value, this.path = a.path, this.errors = a.errors, this.inner = a.inner, Error.captureStackTrace && Error.captureStackTrace(this, F);
}
static [ge](e) {
return he[Symbol.hasInstance](e) || super[Symbol.hasInstance](e);
}
}
let $ = {
default: "${path} is invalid",
required: "${path} is a required field",
defined: "${path} must be defined",
notNull: "${path} cannot be null",
oneOf: "${path} must be one of the following values: ${values}",
notOneOf: "${path} must not be one of the following values: ${values}",
notType: ({
path: n,
type: e,
value: t,
originalValue: r
}) => {
const s = r != null && r !== t ? ` (cast from the value \`${I(r, !0)}\`).` : ".";
return e !== "mixed" ? `${n} must be a \`${e}\` type, but the final value was: \`${I(t, !0)}\`` + s : `${n} must match the configured type. The validated value was: \`${I(t, !0)}\`` + s;
}
}, _ = {
length: "${path} must be exactly ${length} characters",
min: "${path} must be at least ${min} characters",
max: "${path} must be at most ${max} characters",
matches: '${path} must match the following: "${regex}"',
email: "${path} must be a valid email",
url: "${path} must be a valid URL",
uuid: "${path} must be a valid UUID",
datetime: "${path} must be a valid ISO date-time",
datetime_precision: "${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",
datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
trim: "${path} must be a trimmed string",
lowercase: "${path} must be a lowercase string",
uppercase: "${path} must be a upper case string"
}, Ve = {
min: "${path} must be greater than or equal to ${min}",
max: "${path} must be less than or equal to ${max}",
lessThan: "${path} must be less than ${less}",
moreThan: "${path} must be greater than ${more}",
positive: "${path} must be a positive number",
negative: "${path} must be a negative number",
integer: "${path} must be an integer"
}, te = {
min: "${path} field must be later than ${min}",
max: "${path} field must be at earlier than ${max}"
}, Ze = {
isValue: "${path} field must be ${value}"
}, B = {
noUnknown: "${path} field has unspecified keys: ${unknown}",
exact: "${path} object contains unknown properties: ${properties}"
}, Be = {
min: "${path} field must have at least ${min} items",
max: "${path} field must have less than or equal to ${max} items",
length: "${path} must have ${length} items"
}, Ye = {
notType: (n) => {
const {
path: e,
value: t,
spec: r
} = n, s = r.types.length;
if (Array.isArray(t)) {
if (t.length < s) return `${e} tuple value has too few items, expected a length of ${s} but got ${t.length} for value: \`${I(t, !0)}\``;
if (t.length > s) return `${e} tuple value has too many items, expected a length of ${s} but got ${t.length} for value: \`${I(t, !0)}\``;
}
return F.formatError($.notType, n);
}
};
Object.assign(/* @__PURE__ */ Object.create(null), {
mixed: $,
string: _,
number: Ve,
date: te,
object: B,
array: Be,
boolean: Ze,
tuple: Ye
});
const ne = (n) => n && n.__isYupSchema__;
class H {
static fromOptions(e, t) {
if (!t.then && !t.otherwise) throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
let {
is: r,
then: s,
otherwise: i
} = t, a = typeof r == "function" ? r : (...u) => u.every((o) => o === r);
return new H(e, (u, o) => {
var d;
let l = a(...u) ? s : i;
return (d = l == null ? void 0 : l(o)) != null ? d : o;
});
}
constructor(e, t) {
this.fn = void 0, this.refs = e, this.refs = e, this.fn = t;
}
resolve(e, t) {
let r = this.refs.map((i) => (
// TODO: ? operator here?
i.getValue(t == null ? void 0 : t.value, t == null ? void 0 : t.parent, t == null ? void 0 : t.context)
)), s = this.fn(r, e, t);
if (s === void 0 || // @ts-ignore this can be base
s === e)
return e;
if (!ne(s)) throw new TypeError("conditions must return a schema object");
return s.resolve(t);
}
}
const Z = {
context: "$",
value: "."
};
class P {
constructor(e, t = {}) {
if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof e != "string") throw new TypeError("ref must be a string, got: " + e);
if (this.key = e.trim(), e === "") throw new TypeError("ref must be a non-empty string");
this.isContext = this.key[0] === Z.context, this.isValue = this.key[0] === Z.value, this.isSibling = !this.isContext && !this.isValue;
let r = this.isContext ? Z.context : this.isValue ? Z.value : "";
this.path = this.key.slice(r.length), this.getter = this.path && U.getter(this.path, !0), this.map = t.map;
}
getValue(e, t, r) {
let s = this.isContext ? r : this.isValue ? e : t;
return this.getter && (s = this.getter(s || {})), this.map && (s = this.map(s)), s;
}
/**
*
* @param {*} value
* @param {Object} options
* @param {Object=} options.context
* @param {Object=} options.parent
*/
cast(e, t) {
return this.getValue(e, t == null ? void 0 : t.parent, t == null ? void 0 : t.context);
}
resolve() {
return this;
}
describe() {
return {
type: "ref",
key: this.key
};
}
toString() {
return `Ref(${this.key})`;
}
static isRef(e) {
return e && e.__isYupRef;
}
}
P.prototype.__isYupRef = !0;
const N = (n) => n == null;
function M(n) {
function e({
value: t,
path: r = "",
options: s,
originalValue: i,
schema: a
}, u, o) {
const {
name: d,
test: l,
params: f,
message: h,
skipAbsent: m
} = n;
let {
parent: E,
context: x,
abortEarly: v = a.spec.abortEarly,
disableStackTrace: c = a.spec.disableStackTrace
} = s;
function p(b) {
return P.isRef(b) ? b.getValue(t, E, x) : b;
}
function w(b = {}) {
const j = Object.assign({
value: t,
originalValue: i,
label: a.spec.label,
path: b.path || r,
spec: a.spec,
disableStackTrace: b.disableStackTrace || c
}, f, b.params);
for (const ue of Object.keys(j)) j[ue] = p(j[ue]);
const ae = new F(F.formatError(b.message || h, j), t, j.path, b.type || d, j.disableStackTrace);
return ae.params = j, ae;
}
const O = v ? u : o;
let y = {
path: r,
parent: E,
type: d,
from: s.from,
createError: w,
resolve: p,
options: s,
originalValue: i,
schema: a
};
const g = (b) => {
F.isError(b) ? O(b) : b ? o(null) : O(w());
}, T = (b) => {
F.isError(b) ? O(b) : u(b);
};
if (m && N(t))
return g(!0);
let D;
try {
var ie;
if (D = l.call(y, t, y), typeof ((ie = D) == null ? void 0 : ie.then) == "function") {
if (s.sync)
throw new Error(`Validation test of type: "${y.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
return Promise.resolve(D).then(g, T);
}
} catch (b) {
T(b);
return;
}
g(D);
}
return e.OPTIONS = n, e;
}
function Ge(n, e, t, r = t) {
let s, i, a;
return e ? (U.forEach(e, (u, o, d) => {
let l = o ? u.slice(1, u.length - 1) : u;
n = n.resolve({
context: r,
parent: s,
value: t
});
let f = n.type === "tuple", h = d ? parseInt(l, 10) : 0;
if (n.innerType || f) {
if (f && !d) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${a}" must contain an index to the tuple element, e.g. "${a}[0]"`);
if (t && h >= t.length)
throw new Error(`Yup.reach cannot resolve an array item at index: ${u}, in the path: ${e}. because there is no value at that index. `);
s = t, t = t && t[h], n = f ? n.spec.types[h] : n.innerType;
}
if (!d) {
if (!n.fields || !n.fields[l]) throw new Error(`The schema does not contain the path: ${e}. (failed at: ${a} which is a type: "${n.type}")`);
s = t, t = t && t[l], n = n.fields[l];
}
i = l, a = o ? "[" + u + "]" : "." + u;
}), {
schema: n,
parent: s,
parentPath: i
}) : {
parent: s,
parentPath: e,
schema: n
};
}
class K extends Set {
describe() {
const e = [];
for (const t of this.values())
e.push(P.isRef(t) ? t.describe() : t);
return e;
}
resolveAll(e) {
let t = [];
for (const r of this.values())
t.push(e(r));
return t;
}
clone() {
return new K(this.values());
}
merge(e, t) {
const r = this.clone();
return e.forEach((s) => r.add(s)), t.forEach((s) => r.delete(s)), r;
}
}
function R(n, e = /* @__PURE__ */ new Map()) {
if (ne(n) || !n || typeof n != "object") return n;
if (e.has(n)) return e.get(n);
let t;
if (n instanceof Date)
t = new Date(n.getTime()), e.set(n, t);
else if (n instanceof RegExp)
t = new RegExp(n), e.set(n, t);
else if (Array.isArray(n)) {
t = new Array(n.length), e.set(n, t);
for (let r = 0; r < n.length; r++) t[r] = R(n[r], e);
} else if (n instanceof Map) {
t = /* @__PURE__ */ new Map(), e.set(n, t);
for (const [r, s] of n.entries()) t.set(r, R(s, e));
} else if (n instanceof Set) {
t = /* @__PURE__ */ new Set(), e.set(n, t);
for (const r of n) t.add(R(r, e));
} else if (n instanceof Object) {
t = {}, e.set(n, t);
for (const [r, s] of Object.entries(n)) t[r] = R(s, e);
} else
throw Error(`Unable to clone ${n}`);
return t;
}
class S {
constructor(e) {
this.type = void 0, this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this.internalTests = {}, this._whitelist = new K(), this._blacklist = new K(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this._typeCheck = void 0, this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
this.typeError($.notType);
}), this.type = e.type, this._typeCheck = e.check, this.spec = Object.assign({
strip: !1,
strict: !1,
abortEarly: !0,
recursive: !0,
disableStackTrace: !1,
nullable: !1,
optional: !0,
coerce: !0
}, e == null ? void 0 : e.spec), this.withMutation((t) => {
t.nonNullable();
});
}
// TODO: remove
get _type() {
return this.type;
}
clone(e) {
if (this._mutate)
return e && Object.assign(this.spec, e), this;
const t = Object.create(Object.getPrototypeOf(this));
return t.type = this.type, t._typeCheck = this._typeCheck, t._whitelist = this._whitelist.clone(), t._blacklist = this._blacklist.clone(), t.internalTests = Object.assign({}, this.internalTests), t.exclusiveTests = Object.assign({}, this.exclusiveTests), t.deps = [...this.deps], t.conditions = [...this.conditions], t.tests = [...this.tests], t.transforms = [...this.transforms], t.spec = R(Object.assign({}, this.spec, e)), t;
}
label(e) {
let t = this.clone();
return t.spec.label = e, t;
}
meta(...e) {
if (e.length === 0) return this.spec.meta;
let t = this.clone();
return t.spec.meta = Object.assign(t.spec.meta || {}, e[0]), t;
}
withMutation(e) {
let t = this._mutate;
this._mutate = !0;
let r = e(this);
return this._mutate = t, r;
}
concat(e) {
if (!e || e === this) return this;
if (e.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);
let t = this, r = e.clone();
const s = Object.assign({}, t.spec, r.spec);
return r.spec = s, r.internalTests = Object.assign({}, t.internalTests, r.internalTests), r._whitelist = t._whitelist.merge(e._whitelist, e._blacklist), r._blacklist = t._blacklist.merge(e._blacklist, e._whitelist), r.tests = t.tests, r.exclusiveTests = t.exclusiveTests, r.withMutation((i) => {
e.tests.forEach((a) => {
i.test(a.OPTIONS);
});
}), r.transforms = [...t.transforms, ...r.transforms], r;
}
isType(e) {
return e == null ? !!(this.spec.nullable && e === null || this.spec.optional && e === void 0) : this._typeCheck(e);
}
resolve(e) {
let t = this;
if (t.conditions.length) {
let r = t.conditions;
t = t.clone(), t.conditions = [], t = r.reduce((s, i) => i.resolve(s, e), t), t = t.resolve(e);
}
return t;
}
resolveOptions(e) {
var t, r, s, i;
return Object.assign({}, e, {
from: e.from || [],
strict: (t = e.strict) != null ? t : this.spec.strict,
abortEarly: (r = e.abortEarly) != null ? r : this.spec.abortEarly,
recursive: (s = e.recursive) != null ? s : this.spec.recursive,
disableStackTrace: (i = e.disableStackTrace) != null ? i : this.spec.disableStackTrace
});
}
/**
* Run the configured transform pipeline over an input value.
*/
cast(e, t = {}) {
let r = this.resolve(Object.assign({
value: e
}, t)), s = t.assert === "ignore-optionality", i = r._cast(e, t);
if (t.assert !== !1 && !r.isType(i)) {
if (s && N(i))
return i;
let a = I(e), u = I(i);
throw new TypeError(`The value of ${t.path || "field"} could not be cast to a value that satisfies the schema type: "${r.type}".
attempted value: ${a}
` + (u !== a ? `result of cast: ${u}` : ""));
}
return i;
}
_cast(e, t) {
let r = e === void 0 ? e : this.transforms.reduce((s, i) => i.call(this, s, e, this), e);
return r === void 0 && (r = this.getDefault(t)), r;
}
_validate(e, t = {}, r, s) {
let {
path: i,
originalValue: a = e,
strict: u = this.spec.strict
} = t, o = e;
u || (o = this._cast(o, Object.assign({
assert: !1
}, t)));
let d = [];
for (let l of Object.values(this.internalTests))
l && d.push(l);
this.runTests({
path: i,
value: o,
originalValue: a,
options: t,
tests: d
}, r, (l) => {
if (l.length)
return s(l, o);
this.runTests({
path: i,
value: o,
originalValue: a,
options: t,
tests: this.tests
}, r, s);
});
}
/**
* Executes a set of validations, either schema, produced Tests or a nested
* schema validate result.
*/
runTests(e, t, r) {
let s = !1, {
tests: i,
value: a,
originalValue: u,
path: o,
options: d
} = e, l = (x) => {
s || (s = !0, t(x, a));
}, f = (x) => {
s || (s = !0, r(x, a));
}, h = i.length, m = [];
if (!h) return f([]);
let E = {
value: a,
originalValue: u,
path: o,
options: d,
schema: this
};
for (let x = 0; x < i.length; x++) {
const v = i[x];
v(E, l, function(p) {
p && (Array.isArray(p) ? m.push(...p) : m.push(p)), --h <= 0 && f(m);
});
}
}
asNestedTest({
key: e,
index: t,
parent: r,
parentPath: s,
originalParent: i,
options: a
}) {
const u = e ?? t;
if (u == null)
throw TypeError("Must include `key` or `index` for nested validations");
const o = typeof u == "number";
let d = r[u];
const l = Object.assign({}, a, {
// Nested validations fields are always strict:
// 1. parent isn't strict so the casting will also have cast inner values
// 2. parent is strict in which case the nested values weren't cast either
strict: !0,
parent: r,
value: d,
originalValue: i[u],
// FIXME: tests depend on `index` being passed around deeply,
// we should not let the options.key/index bleed through
key: void 0,
// index: undefined,
[o ? "index" : "key"]: u,
path: o || u.includes(".") ? `${s || ""}[${o ? u : `"${u}"`}]` : (s ? `${s}.` : "") + e
});
return (f, h, m) => this.resolve(l)._validate(d, l, h, m);
}
validate(e, t) {
var r;
let s = this.resolve(Object.assign({}, t, {
value: e
})), i = (r = t == null ? void 0 : t.disableStackTrace) != null ? r : s.spec.disableStackTrace;
return new Promise((a, u) => s._validate(e, t, (o, d) => {
F.isError(o) && (o.value = d), u(o);
}, (o, d) => {
o.length ? u(new F(o, d, void 0, void 0, i)) : a(d);
}));
}
validateSync(e, t) {
var r;
let s = this.resolve(Object.assign({}, t, {
value: e
})), i, a = (r = t == null ? void 0 : t.disableStackTrace) != null ? r : s.spec.disableStackTrace;
return s._validate(e, Object.assign({}, t, {
sync: !0
}), (u, o) => {
throw F.isError(u) && (u.value = o), u;
}, (u, o) => {
if (u.length) throw new F(u, e, void 0, void 0, a);
i = o;
}), i;
}
isValid(e, t) {
return this.validate(e, t).then(() => !0, (r) => {
if (F.isError(r)) return !1;
throw r;
});
}
isValidSync(e, t) {
try {
return this.validateSync(e, t), !0;
} catch (r) {
if (F.isError(r)) return !1;
throw r;
}
}
_getDefault(e) {
let t = this.spec.default;
return t == null ? t : typeof t == "function" ? t.call(this, e) : R(t);
}
getDefault(e) {
return this.resolve(e || {})._getDefault(e);
}
default(e) {
return arguments.length === 0 ? this._getDefault() : this.clone({
default: e
});
}
strict(e = !0) {
return this.clone({
strict: e
});
}
nullability(e, t) {
const r = this.clone({
nullable: e
});
return r.internalTests.nullable = M({
message: t,
name: "nullable",
test(s) {
return s === null ? this.schema.spec.nullable : !0;
}
}), r;
}
optionality(e, t) {
const r = this.clone({
optional: e
});
return r.internalTests.optionality = M({
message: t,
name: "optionality",
test(s) {
return s === void 0 ? this.schema.spec.optional : !0;
}
}), r;
}
optional() {
return this.optionality(!0);
}
defined(e = $.defined) {
return this.optionality(!1, e);
}
nullable() {
return this.nullability(!0);
}
nonNullable(e = $.notNull) {
return this.nullability(!1, e);
}
required(e = $.required) {
return this.clone().withMutation((t) => t.nonNullable(e).defined(e));
}
notRequired() {
return this.clone().withMutation((e) => e.nullable().optional());
}
transform(e) {
let t = this.clone();
return t.transforms.push(e), t;
}
/**
* Adds a test function to the schema's queue of tests.
* tests can be exclusive or non-exclusive.
*
* - exclusive tests, will replace any existing tests of the same name.
* - non-exclusive: can be stacked
*
* If a non-exclusive test is added to a schema with an exclusive test of the same name
* the exclusive test is removed and further tests of the same name will be stacked.
*
* If an exclusive test is added to a schema with non-exclusive tests of the same name
* the previous tests are removed and further tests of the same name will replace each other.
*/
test(...e) {
let t;
if (e.length === 1 ? typeof e[0] == "function" ? t = {
test: e[0]
} : t = e[0] : e.length === 2 ? t = {
name: e[0],
test: e[1]
} : t = {
name: e[0],
message: e[1],
test: e[2]
}, t.message === void 0 && (t.message = $.default), typeof t.test != "function") throw new TypeError("`test` is a required parameters");
let r = this.clone(), s = M(t), i = t.exclusive || t.name && r.exclusiveTests[t.name] === !0;
if (t.exclusive && !t.name)
throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
return t.name && (r.exclusiveTests[t.name] = !!t.exclusive), r.tests = r.tests.filter((a) => !(a.OPTIONS.name === t.name && (i || a.OPTIONS.test === s.OPTIONS.test))), r.tests.push(s), r;
}
when(e, t) {
!Array.isArray(e) && typeof e != "string" && (t = e, e = ".");
let r = this.clone(), s = be(e).map((i) => new P(i));
return s.forEach((i) => {
i.isSibling && r.deps.push(i.key);
}), r.conditions.push(typeof t == "function" ? new H(s, t) : H.fromOptions(s, t)), r;
}
typeError(e) {
let t = this.clone();
return t.internalTests.typeError = M({
message: e,
name: "typeError",
skipAbsent: !0,
test(r) {
return this.schema._typeCheck(r) ? !0 : this.createError({
params: {
type: this.schema.type
}
});
}
}), t;
}
oneOf(e, t = $.oneOf) {
let r = this.clone();
return e.forEach((s) => {
r._whitelist.add(s), r._blacklist.delete(s);
}), r.internalTests.whiteList = M({
message: t,
name: "oneOf",
skipAbsent: !0,
test(s) {
let i = this.schema._whitelist, a = i.resolveAll(this.resolve);
return a.includes(s) ? !0 : this.createError({
params: {
values: Array.from(i).join(", "),
resolved: a
}
});
}
}), r;
}
notOneOf(e, t = $.notOneOf) {
let r = this.clone();
return e.forEach((s) => {
r._blacklist.add(s), r._whitelist.delete(s);
}), r.internalTests.blacklist = M({
message: t,
name: "notOneOf",
test(s) {
let i = this.schema._blacklist, a = i.resolveAll(this.resolve);
return a.includes(s) ? this.createError({
params: {
values: Array.from(i).join(", "),
resolved: a
}
}) : !0;
}
}), r;
}
strip(e = !0) {
let t = this.clone();
return t.spec.strip = e, t;
}
/**
* Return a serialized description of the schema including validations, flags, types etc.
*
* @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
*/
describe(e) {
const t = (e ? this.resolve(e) : this).clone(), {
label: r,
meta: s,
optional: i,
nullable: a
} = t.spec;
return {
meta: s,
label: r,
optional: i,
nullable: a,
default: t.getDefault(e),
type: t.type,
oneOf: t._whitelist.describe(),
notOneOf: t._blacklist.describe(),
tests: t.tests.map((o) => ({
name: o.OPTIONS.name,
params: o.OPTIONS.params
})).filter((o, d, l) => l.findIndex((f) => f.name === o.name) === d)
};
}
}
S.prototype.__isYupSchema__ = !0;
for (const n of ["validate", "validateSync"]) S.prototype[`${n}At`] = function(e, t, r = {}) {
const {
parent: s,
parentPath: i,
schema: a
} = Ge(this, e, t, r.context);
return a[n](s && s[i], Object.assign({}, r, {
parent: s,
path: e
}));
};
for (const n of ["equals", "is"]) S.prototype[n] = S.prototype.oneOf;
for (const n of ["not", "nope"]) S.prototype[n] = S.prototype.notOneOf;
const He = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
function Ke(n) {
const e = re(n);
if (!e) return Date.parse ? Date.parse(n) : Number.NaN;
if (e.z === void 0 && e.plusMinus === void 0)
return new Date(e.year, e.month, e.day, e.hour, e.minute, e.second, e.millisecond).valueOf();
let t = 0;
return e.z !== "Z" && e.plusMinus !== void 0 && (t = e.hourOffset * 60 + e.minuteOffset, e.plusMinus === "+" && (t = 0 - t)), Date.UTC(e.year, e.month, e.day, e.hour, e.minute + t, e.second, e.millisecond);
}
function re(n) {
var e, t;
const r = He.exec(n);
return r ? {
year: k(r[1]),
month: k(r[2], 1) - 1,
day: k(r[3], 1),
hour: k(r[4]),
minute: k(r[5]),
second: k(r[6]),
millisecond: r[7] ? (
// allow arbitrary sub-second precision beyond milliseconds
k(r[7].substring(0, 3))
) : 0,
precision: (e = (t = r[7]) == null ? void 0 : t.length) != null ? e : void 0,
z: r[8] || void 0,
plusMinus: r[9] || void 0,
hourOffset: k(r[10]),
minuteOffset: k(r[11])
} : null;
}
function k(n, e = 0) {
return Number(n) || e;
}
let Xe = (
// eslint-disable-next-line
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
), Je = (
// eslint-disable-next-line
/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
), Qe = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, We = "^\\d{4}-\\d{2}-\\d{2}", et = "\\d{2}:\\d{2}:\\d{2}", tt = "(([+-]\\d{2}(:?\\d{2})?)|Z)", rt = new RegExp(`${We}T${et}(\\.\\d+)?${tt}$`), nt = (n) => N(n) || n === n.trim(), st = {}.toString();
function A() {
return new we();
}
class we extends S {
constructor() {
super({
type: "string",
check(e) {
return e instanceof String && (e = e.valueOf()), typeof e == "string";
}
}), this.withMutation(() => {
this.transform((e, t, r) => {
if (!r.spec.coerce || r.isType(e) || Array.isArray(e)) return e;
const s = e != null && e.toString ? e.toString() : e;
return s === st ? e : s;
});
});
}
required(e) {
return super.required(e).withMutation((t) => t.test({
message: e || $.required,
name: "required",
skipAbsent: !0,
test: (r) => !!r.length
}));
}
notRequired() {
return super.notRequired().withMutation((e) => (e.tests = e.tests.filter((t) => t.OPTIONS.name !== "required"), e));
}
length(e, t = _.length) {
return this.test({
message: t,
name: "length",
exclusive: !0,
params: {
length: e
},
skipAbsent: !0,
test(r) {
return r.length === this.resolve(e);
}
});
}
min(e, t = _.min) {
return this.test({
message: t,
name: "min",
exclusive: !0,
params: {
min: e
},
skipAbsent: !0,
test(r) {
return r.length >= this.resolve(e);
}
});
}
max(e, t = _.max) {
return this.test({
name: "max",
exclusive: !0,
message: t,
params: {
max: e
},
skipAbsent: !0,
test(r) {
return r.length <= this.resolve(e);
}
});
}
matches(e, t) {
let r = !1, s, i;
return t && (typeof t == "object" ? {
excludeEmptyString: r = !1,
message: s,
name: i
} = t : s = t), this.test({
name: i || "matches",
message: s || _.matches,
params: {
regex: e
},
skipAbsent: !0,
test: (a) => a === "" && r || a.search(e) !== -1
});
}
email(e = _.email) {
return this.matches(Xe, {
name: "email",
message: e,
excludeEmptyString: !0
});
}
url(e = _.url) {
return this.matches(Je, {
name: "url",
message: e,
excludeEmptyString: !0
});
}
uuid(e = _.uuid) {
return this.matches(Qe, {
name: "uuid",
message: e,
excludeEmptyString: !1
});
}
datetime(e) {
let t = "", r, s;
return e && (typeof e == "object" ? {
message: t = "",
allowOffset: r = !1,
precision: s = void 0
} = e : t = e), this.matches(rt, {
name: "datetime",
message: t || _.datetime,
excludeEmptyString: !0
}).test({
name: "datetime_offset",
message: t || _.datetime_offset,
params: {
allowOffset: r
},
skipAbsent: !0,
test: (i) => {
if (!i || r) return !0;
const a = re(i);
return a ? !!a.z : !1;
}
}).test({
name: "datetime_precision",
message: t || _.datetime_precision,
params: {
precision: s
},
skipAbsent: !0,
test: (i) => {
if (!i || s == null) return !0;
const a = re(i);
return a ? a.precision === s : !1;
}
});
}
//-- transforms --
ensure() {
return this.default("").transform((e) => e === null ? "" : e);
}
trim(e = _.trim) {
return this.transform((t) => t != null ? t.trim() : t).test({
message: e,
name: "trim",
test: nt
});
}
lowercase(e = _.lowercase) {
return this.transform((t) => N(t) ? t : t.toLowerCase()).test({
message: e,
name: "string_case",
exclusive: !0,
skipAbsent: !0,
test: (t) => N(t) || t === t.toLowerCase()
});
}
uppercase(e = _.uppercase) {
return this.transform((t) => N(t) ? t : t.toUpperCase()).test({
message: e,
name: "string_case",
exclusive: !0,
skipAbsent: !0,
test: (t) => N(t) || t === t.toUpperCase()
});
}
}
A.prototype = we.prototype;
let it = /* @__PURE__ */ new Date(""), at = (n) => Object.prototype.toString.call(n) === "[object Date]";
class se extends S {
constructor() {
super({
type: "date",
check(e) {
return at(e) && !isNaN(e.getTime());
}
}), this.withMutation(() => {
this.transform((e, t, r) => !r.spec.coerce || r.isType(e) || e === null ? e : (e = Ke(e), isNaN(e) ? se.INVALID_DATE : new Date(e)));
});
}
prepareParam(e, t) {
let r;
if (P.isRef(e))
r = e;
else {
let s = this.cast(e);
if (!this._typeCheck(s)) throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);
r = s;
}
return r;
}
min(e, t = te.min) {
let r = this.prepareParam(e, "min");
return this.test({
message: t,
name: "min",
exclusive: !0,
params: {
min: e
},
skipAbsent: !0,
test(s) {
return s >= this.resolve(r);
}
});
}
max(e, t = te.max) {
let r = this.prepareParam(e, "max");
return this.test({
message: t,
name: "max",
exclusive: !0,
params: {
max: e
},
skipAbsent: !0,
test(s) {
return s <= this.resolve(r);
}
});
}
}
se.INVALID_DATE = it;
function ut(n, e = []) {
let t = [], r = /* @__PURE__ */ new Set(), s = new Set(e.map(([a, u]) => `${a}-${u}`));
function i(a, u) {
let o = U.split(a)[0];
r.add(o), s.has(`${u}-${o}`) || t.push([u, o]);
}
for (const a of Object.keys(n)) {
let u = n[a];
r.add(a), P.isRef(u) && u.isSibling ? i(u.path, a) : ne(u) && "deps" in u && u.deps.forEach((o) => i(o, a));
}
return Ne.array(Array.from(r), t).reverse();
}
function pe(n, e) {
let t = 1 / 0;
return n.some((r, s) => {
var i;
if ((i = e.path) != null && i.includes(r))
return t = s, !0;
}), t;
}
function ve(n) {
return (e, t) => pe(n, e) - pe(n, t);
}
const ot = (n, e, t) => {
if (typeof n != "string")
return n;
let r = n;
try {
r = JSON.parse(n);
} catch {
}
return t.isType(r) ? r : n;
};
function Y(n) {
if ("fields" in n) {
const e = {};
for (const [t, r] of Object.entries(n.fields))
e[t] = Y(r);
return n.setFields(e);
}
if (n.type === "array") {
const e = n.optional();
return e.innerType && (e.innerType = Y(e.innerType)), e;
}
return n.type === "tuple" ? n.optional().clone({
types: n.spec.types.map(Y)
}) : "optional" in n ? n.optional() : n;
}
const lt = (n, e) => {
const t = [...U.normalizePath(e)];
if (t.length === 1) return t[0] in n;
let r = t.pop(), s = U.getter(U.join(t), !0)(n);
return !!(s && r in s);
};
let me = (n) => Object.prototype.toString.call(n) === "[object Object]";
function ye(n, e) {
let t = Object.keys(n.fields);
return Object.keys(e).filter((r) => t.indexOf(r) === -1);
}
const ct = ve([]);
function _e(n) {
return new Fe(n);
}
class Fe extends S {
constructor(e) {
super({
type: "object",
check(t) {
return me(t) || typeof t == "function";
}
}), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = ct, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
e && this.shape(e);
});
}
_cast(e, t = {}) {
var r;
let s = super._cast(e, t);
if (s === void 0) return this.getDefault(t);
if (!this._typeCheck(s)) return s;
let i = this.fields, a = (r = t.stripUnknown) != null ? r : this.spec.noUnknown, u = [].concat(this._nodes, Object.keys(s).filter((f) => !this._nodes.includes(f))), o = {}, d = Object.assign({}, t, {
parent: o,
__validating: t.__validating || !1
}), l = !1;
for (const f of u) {
let h = i[f], m = f in s;
if (h) {
let E, x = s[f];
d.path = (t.path ? `${t.path}.` : "") + f, h = h.resolve({
value: x,
context: t.context,
parent: o
});
let v = h instanceof S ? h.spec : void 0, c = v == null ? void 0 : v.strict;
if (v != null && v.strip) {
l = l || f in s;
continue;
}
E = !t.__validating || !c ? (
// TODO: use _cast, this is double resolving
h.cast(s[f], d)
) : s[f], E !== void 0 && (o[f] = E);
} else m && !a && (o[f] = s[f]);
(m !== f in o || o[f] !== s[f]) && (l = !0);
}
return l ? o : s;
}
_validate(e, t = {}, r, s) {
let {
from: i = [],
originalValue: a = e,
recursive: u = this.spec.recursive
} = t;
t.from = [{
schema: this,
value: a
}, ...i], t.__validating = !0, t.originalValue = a, super._validate(e, t, r, (o, d) => {
if (!u || !me(d)) {
s(o, d);
return;
}
a = a || d;
let l = [];
for (let f of this._nodes) {
let h = this.fields[f];
!h || P.isRef(h) || l.push(h.asNestedTest({
options: t,
key: f,
parent: d,
parentPath: t.path,
originalParent: a
}));
}
this.runTests({
tests: l,
value: d,
originalValue: a,
options: t
}, r, (f) => {
s(f.sort(this._sortErrors).concat(o), d);
});
});
}
clone(e) {
const t = super.clone(e);
return t.fields = Object.assign({}, this.fields), t._nodes = this._nodes, t._excludedEdges = this._excludedEdges, t._sortErrors = this._sortErrors, t;
}
concat(e) {
let t = super.concat(e), r = t.fields;
for (let [s, i] of Object.entries(this.fields)) {
const a = r[s];
r[s] = a === void 0 ? i : a;
}
return t.withMutation((s) => (
// XXX: excludes here is wrong
s.setFields(r, [...this._excludedEdges, ...e._excludedEdges])
));
}
_getDefault(e) {
if ("default" in this.spec)
return super._getDefault(e);
if (!this._nodes.length)
return;
let t = {};
return this._nodes.forEach((r) => {
var s;
const i = this.fields[r];
let a = e;
(s = a) != null && s.value && (a = Object.assign({}, a, {
parent: a.value,
value: a.value[r]
})), t[r] = i && "getDefault" in i ? i.getDefault(a) : void 0;
}), t;
}
setFields(e, t) {
let r = this.clone();
return r.fields = e, r._nodes = ut(e, t), r._sortErrors = ve(Object.keys(e)), t && (r._excludedEdges = t), r;
}
shape(e, t = []) {
return this.clone().withMutation((r) => {
let s = r._excludedEdges;
return t.length && (Array.isArray(t[0]) || (t = [t]), s = [...r._excludedEdges, ...t]), r.setFields(Object.assign(r.fields, e), s);
});
}
partial() {
const e = {};
for (const [t, r] of Object.entries(this.fields))
e[t] = "optional" in r && r.optional instanceof Function ? r.optional() : r;
return this.setFields(e);
}
deepPartial() {
return Y(this);
}
pick(e) {
const t = {};
for (const r of e)
this.fields[r] && (t[r] = this.fields[r]);
return this.setFields(t, this._excludedEdges.filter(([r, s]) => e.includes(r) && e.includes(s)));
}
omit(e) {
const t = [];
for (const r of Object.keys(this.fields))
e.includes(r) || t.push(r);
return this.pick(t);
}
from(e, t, r) {
let s = U.getter(e, !0);
return this.transform((i) => {
if (!i) return i;
let a = i;
return lt(i, e) && (a = Object.assign({}, i), r || delete a[e], a[t] = s(i)), a;
});
}
/** Parse an input JSON string to an object */
json() {
return this.transform(ot);
}
/**
* Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
*/
exact(e) {
return this.test({
name: "exact",
exclusive: !0,
message: e || B.exact,
test(t) {
if (t == null) return !0;
const r = ye(this.schema, t);
return r.length === 0 || this.createError({
params: {
properties: r.join(", ")
}
});
}
});
}
stripUnknown() {
return this.clone({
noUnknown: !0
});
}
noUnknown(e = !0, t = B.noUnknown) {
typeof e != "boolean" && (t = e, e = !0);
let r = this.test({
name: "noUnknown",
exclusive: !0,
message: t,
test(s) {
if (s == null) return !0;
const i = ye(this.schema, s);
return !e || i.length === 0 || this.createError({
params: {
unknown: i.join(", ")
}
});
}
});
return r.spec.noUnknown = e, r;
}
unknown(e = !0, t = B.noUnknown) {
return this.noUnknown(!e, t);
}
transformKeys(e) {
return this.transform((t) => {
if (!t) return t;
const r = {};
for (const s of Object.keys(t)) r[e(s)] = t[s];
return r;
});
}
camelCase() {
return this.transformKeys(W.camelCase);
}
snakeCase() {
return this.transformKeys(W.snakeCase);
}
constantCase() {
return this.transformKeys((e) => W.snakeCase(e).toUpperCase());
}
describe(e) {
const t = (e ? this.resolve(e) : this).clone(), r = super.describe(e);
r.fields = {};
for (const [i, a] of Object.entries(t.fields)) {
var s;
let u = e;
(s = u) != null && s.value && (u = Object.assign({}, u, {
parent: u.value,
value: u.value[i]
})), r.fields[i] = a.describe(u);
}
return r;
}
}
_e.prototype = Fe.prototype;
const ft = "#000639", dt = '<svg width="40" height="41" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 10.5C0 4.977 4.477.5 10 .5h20c5.523 0 10 4.477 10 10v20c0 5.523-4.477 10-10 10H10c-5.523 0-10-4.477-10-10v-20Z" fill="#F1F1F1"/><path fill-rule="evenodd" clip-rule="evenodd" d="M25.927 15.78a.75.75 0 1 0-1.06-1.06l-4.793 4.793-4.793-4.793a.75.75 0 0 0-1.061 1.06l4.793 4.793-4.793 4.793a.75.75 0 1 0 1.06 1.061l4.794-4.793 4.793 4.793a.75.75 0 0 0 1.06-1.06l-4.793-4.794 4.793-4.793Z" fill="#000639"/></svg>';
function ht() {
if (document.head.querySelector(`#${X}`)) return;
const e = document.createElement("style");
e.id = X, e.dataset.testid = X, document.head.appendChild(e), e.textContent = `
#${q}, #${q} * {
margin: 0;
padding: 0px;
box-sizing: border-box;
}
#${G} {
position: absolute;