function e(e) {
return e;
}
function t(e, t, n, r, i, a, o, s, c) {
switch (arguments.length) {
case 1:
return e;
case 2:
return t(e);
case 3:
return n(t(e));
case 4:
return r(n(t(e)));
case 5:
return i(r(n(t(e))));
case 6:
return a(i(r(n(t(e)))));
case 7:
return o(a(i(r(n(t(e))))));
case 8:
return s(o(a(i(r(n(t(e)))))));
case 9:
return c(s(o(a(i(r(n(t(e))))))));
default:
for (var l = arguments[0], u = 1; u < arguments.length; u++) l = arguments[u](l);
return l;
}
}
var n = function (e) {
return e._tag === `Left`;
},
r = function (e) {
return { _tag: `Left`, left: e };
},
i = function (e) {
return { _tag: `Right`, right: e };
};
function a(e) {
return function (t, n) {
return e.map(t, function () {
return n;
});
};
}
function o(e) {
var t = a(e);
return function (e) {
return t(e, void 0);
};
}
var s = r,
c = i,
l = function (e, n) {
return t(e, d(n));
},
u = `Either`,
d = function (e) {
return function (t) {
return p(t) ? t : c(e(t.right));
};
};
o({ URI: u, map: l });
var f = { URI: u, fromEither: e },
p = n;
f.fromEither;
var m = (function () {
var e = function (t, n) {
return (
(e =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (e, t) {
e.__proto__ = t;
}) ||
function (e, t) {
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
}),
e(t, n)
);
};
return function (t, n) {
if (typeof n != `function` && n !== null)
throw TypeError(`Class extends value ` + String(n) + ` is not a constructor or null`);
e(t, n);
function r() {
this.constructor = t;
}
t.prototype = n === null ? Object.create(n) : ((r.prototype = n.prototype), new r());
};
})(),
h = function () {
return (
(h =
Object.assign ||
function (e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var i in ((t = arguments[n]), t))
Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
return e;
}),
h.apply(this, arguments)
);
},
g = s,
_ = function (e, t, n) {
return g([{ value: e, context: t, message: n }]);
},
v = c,
y = (function () {
function e(e, t, n, r) {
((this.name = e),
(this.is = t),
(this.validate = n),
(this.encode = r),
(this.decode = this.decode.bind(this)));
}
return (
(e.prototype.pipe = function (t, n) {
var r = this;
return (
n === void 0 && (n = `pipe(${this.name}, ${t.name})`),
new e(
n,
t.is,
function (e, n) {
var i = r.validate(e, n);
return p(i) ? i : t.validate(i.right, n);
},
this.encode === b && t.encode === b
? b
: function (e) {
return r.encode(t.encode(e));
},
)
);
}),
(e.prototype.asDecoder = function () {
return this;
}),
(e.prototype.asEncoder = function () {
return this;
}),
(e.prototype.decode = function (e) {
return this.validate(e, [{ key: ``, type: this, actual: e }]);
}),
e
);
})(),
b = function (e) {
return e;
};
function ee(e) {
return e.displayName || e.name || `<function${e.length}>`;
}
function x(e, t, n, r) {
for (var i = e.length, a = Array(i + 1), o = 0; o < i; o++) a[o] = e[o];
return ((a[i] = { key: t, type: n, actual: r }), a);
}
function S(e, t) {
for (var n = t.length, r = 0; r < n; r++) e.push(t[r]);
}
var C = Object.prototype.hasOwnProperty;
function w(e) {
return Object.keys(e)
.map(function (t) {
return `${t}: ${e[t].name}`;
})
.join(`, `);
}
function T(e) {
for (var t = 0; t < e.length; t++) if (e[t].encode !== b) return !1;
return !0;
}
function te(e) {
return `{ ${w(e)} }`;
}
function ne(e) {
return (
`(` +
e
.map(function (e) {
return e.name;
})
.join(` | `) +
`)`
);
}
function E(e) {
return e.length > 0;
}
var D = {};
function O(e, t) {
for (var n = [], r = 0, i = e; r < i.length; r++) {
var a = i[r];
t.indexOf(a) !== -1 && n.push(a);
}
return n;
}
function k(e, t) {
if (e === D) return t;
if (t === D) return e;
var n = Object.assign({}, e);
for (var r in t)
if (C.call(e, r)) {
var i = O(e[r], t[r]);
if (E(i)) n[r] = i;
else {
n = D;
break;
}
} else n[r] = t[r];
return n;
}
function re(e, t) {
if (e === D || t === D) return D;
var n = D;
for (var r in e)
C.call(t, r) && O(e[r], t[r]).length === 0 && (n === D && (n = {}), (n[r] = e[r].concat(t[r])));
return n;
}
function ie(e) {
return e._tag === `LiteralType`;
}
function ae(e) {
return e._tag === `InterfaceType`;
}
function oe(e) {
return e._tag === `StrictType`;
}
function A(e) {
return e._tag === `ExactType`;
}
function j(e) {
return e._tag === `RefinementType`;
}
function M(e) {
return e._tag === `IntersectionType`;
}
function N(e) {
return e._tag === `UnionType`;
}
function P(e) {
return e._tag === `RecursiveType`;
}
function se(e) {
return e._tag === `ReadonlyType`;
}
var F = [];
function I(e) {
if (F.indexOf(e) !== -1) return D;
if (ae(e) || oe(e)) {
var t = D;
for (var n in e.props) {
var r = e.props[n];
ie(r) && (t === D && (t = {}), (t[n] = [r.value]));
}
return t;
} else if (A(e) || j(e) || se(e)) return I(e.type);
else if (M(e))
return e.types.reduce(function (e, t) {
return k(e, I(t));
}, D);
else if (N(e))
return e.types.slice(1).reduce(function (e, t) {
return re(e, I(t));
}, I(e.types[0]));
else if (P(e)) {
F.push(e);
var i = I(e.type);
return (F.pop(), i);
}
return D;
}
function ce(e) {
var t = I(e[0]),
n = Object.keys(t),
r = e.length,
i = function (n) {
for (var i = t[n].slice(), a = [t[n]], o = 1; o < r; o++) {
var s = e[o],
c = I(s)[n];
if (
c === void 0 ||
c.some(function (e) {
return i.indexOf(e) !== -1;
})
)
return `continue-keys`;
(i.push.apply(i, c), a.push(c));
}
return { value: [n, a] };
};
keys: for (var a = 0, o = n; a < o.length; a++) {
var s = o[a],
c = i(s);
if (typeof c == `object`) return c.value;
switch (c) {
case `continue-keys`:
continue keys;
}
}
}
var L = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`null`,
function (e) {
return e === null;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `NullType`), t);
}
return t;
})(y))(),
R = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`undefined`,
function (e) {
return e === void 0;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `UndefinedType`), t);
}
return t;
})(y))();
(new ((function (e) {
m(t, e);
function t() {
var t = e.call(this, `void`, R.is, R.validate, b) || this;
return ((t._tag = `VoidType`), t);
}
return t;
})(y))(),
new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`unknown`,
function (e) {
return !0;
},
v,
b,
) || this;
return ((t._tag = `UnknownType`), t);
}
return t;
})(y))());
var z = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`string`,
function (e) {
return typeof e == `string`;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `StringType`), t);
}
return t;
})(y))(),
B = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`number`,
function (e) {
return typeof e == `number`;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `NumberType`), t);
}
return t;
})(y))();
(new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`bigint`,
function (e) {
return typeof e == `bigint`;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `BigIntType`), t);
}
return t;
})(y))(),
new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`boolean`,
function (e) {
return typeof e == `boolean`;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `BooleanType`), t);
}
return t;
})(y))());
var V = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`UnknownArray`,
Array.isArray,
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `AnyArrayType`), t);
}
return t;
})(y))(),
H = new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`UnknownRecord`,
function (e) {
return typeof e == `object` && !!e && !Array.isArray(e);
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `AnyDictionaryType`), t);
}
return t;
})(y))(),
U = (function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.value = a), (o._tag = `LiteralType`), o);
}
return t;
})(y);
function W(e, t) {
t === void 0 && (t = JSON.stringify(e));
var n = function (t) {
return t === e;
};
return new U(
t,
n,
function (t, r) {
return n(t) ? v(e) : _(t, r);
},
b,
e,
);
}
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.keys = a), (o._tag = `KeyofType`), o);
}
return t;
})(y);
var le = (function (e) {
m(t, e);
function t(t, n, r, i, a, o) {
var s = e.call(this, t, n, r, i) || this;
return ((s.type = a), (s.predicate = o), (s._tag = `RefinementType`), s);
}
return t;
})(y);
function ue(e, t, n) {
return Y(e, t, n);
}
ue(
B,
function (e) {
return Number.isInteger(e);
},
`Int`,
);
var de = (function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.runDefinition = a), (o._tag = `RecursiveType`), o);
}
return t;
})(y);
Object.defineProperty(de.prototype, "type", {
get: function () {
return this.runDefinition();
},
enumerable: !0,
configurable: !0,
});
var fe = (function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.type = a), (o._tag = `ArrayType`), o);
}
return t;
})(y);
function G(e, t) {
return (
t === void 0 && (t = `Array<${e.name}>`),
new fe(
t,
function (t) {
return V.is(t) && t.every(e.is);
},
function (t, n) {
var r = V.validate(t, n);
if (p(r)) return r;
for (var i = r.right, a = i.length, o = i, s = [], c = 0; c < a; c++) {
var l = i[c],
u = e.validate(l, x(n, String(c), e, l));
if (p(u)) S(s, u.left);
else {
var d = u.right;
d !== l && (o === i && (o = i.slice()), (o[c] = d));
}
}
return s.length > 0 ? g(s) : v(o);
},
e.encode === b
? b
: function (t) {
return t.map(e.encode);
},
e,
)
);
}
var pe = (function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.props = a), (o._tag = `InterfaceType`), o);
}
return t;
})(y);
function K(e, t) {
t === void 0 && (t = te(e));
var n = Object.keys(e),
r = n.map(function (t) {
return e[t];
}),
i = n.length;
return new pe(
t,
function (e) {
if (H.is(e)) {
for (var t = 0; t < i; t++) {
var a = n[t],
o = e[a];
if ((o === void 0 && !C.call(e, a)) || !r[t].is(o)) return !1;
}
return !0;
}
return !1;
},
function (e, t) {
var a = H.validate(e, t);
if (p(a)) return a;
for (var o = a.right, s = o, c = [], l = 0; l < i; l++) {
var u = n[l],
d = s[u],
f = r[l],
m = f.validate(d, x(t, u, f, d));
if (p(m)) S(c, m.left);
else {
var _ = m.right;
(_ !== d || (_ === void 0 && !C.call(s, u))) && (s === o && (s = h({}, o)), (s[u] = _));
}
}
return c.length > 0 ? g(c) : v(s);
},
T(r)
? b
: function (e) {
for (var t = h({}, e), a = 0; a < i; a++) {
var o = n[a],
s = r[a].encode;
s !== b && (t[o] = s(e[o]));
}
return t;
},
e,
);
}
((function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.props = a), (o._tag = `PartialType`), o);
}
return t;
})(y),
(function (e) {
m(t, e);
function t(t, n, r, i, a, o) {
var s = e.call(this, t, n, r, i) || this;
return ((s.domain = a), (s.codomain = o), (s._tag = `DictionaryType`), s);
}
return t;
})(y));
var q = (function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.types = a), (o._tag = `UnionType`), o);
}
return t;
})(y);
function J(e, t) {
t === void 0 && (t = ne(e));
var n = ce(e);
if (n !== void 0 && e.length > 0) {
var r = n[0],
i = n[1],
a = i.length,
o = function (e) {
for (var t = 0; t < a; t++) if (i[t].indexOf(e) !== -1) return t;
};
return new me(
t,
function (t) {
if (H.is(t)) {
var n = o(t[r]);
return n !== void 0 && e[n].is(t);
}
return !1;
},
function (t, n) {
var i = H.validate(t, n);
if (p(i)) return i;
var a = i.right,
s = o(a[r]);
if (s === void 0) return _(t, n);
var c = e[s];
return c.validate(a, x(n, String(s), c, a));
},
T(e)
? b
: function (n) {
var i = o(n[r]);
if (i === void 0) throw Error(`no codec found to encode value in union codec ${t}`);
return e[i].encode(n);
},
e,
r,
);
} else
return new q(
t,
function (t) {
return e.some(function (e) {
return e.is(t);
});
},
function (t, n) {
for (var r = [], i = 0; i < e.length; i++) {
var a = e[i],
o = a.validate(t, x(n, String(i), a, t));
if (p(o)) S(r, o.left);
else return v(o.right);
}
return g(r);
},
T(e)
? b
: function (n) {
for (var r = 0, i = e; r < i.length; r++) {
var a = i[r];
if (a.is(n)) return a.encode(n);
}
throw Error(`no codec found to encode value in union type ${t}`);
},
e,
);
}
((function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.types = a), (o._tag = `IntersectionType`), o);
}
return t;
})(y),
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.types = a), (o._tag = `TupleType`), o);
}
return t;
})(y),
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.type = a), (o._tag = `ReadonlyType`), o);
}
return t;
})(y),
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.type = a), (o._tag = `ReadonlyArrayType`), o);
}
return t;
})(y),
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.type = a), (o._tag = `ExactType`), o);
}
return t;
})(y),
new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`Function`,
function (e) {
return typeof e == `function`;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `FunctionType`), t);
}
return t;
})(y))(),
new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`never`,
function (e) {
return !1;
},
function (e, t) {
return _(e, t);
},
function () {
throw Error(`cannot encode never`);
},
) || this;
return ((t._tag = `NeverType`), t);
}
return t;
})(y))(),
new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`any`,
function (e) {
return !0;
},
v,
b,
) || this;
return ((t._tag = `AnyType`), t);
}
return t;
})(y))());
function Y(e, t, n) {
return (
n === void 0 && (n = `(${e.name} | ${ee(t)})`),
new le(
n,
function (n) {
return e.is(n) && t(n);
},
function (n, r) {
var i = e.validate(n, r);
if (p(i)) return i;
var a = i.right;
return t(a) ? v(a) : _(a, r);
},
e.encode,
e,
t,
)
);
}
Y(B, Number.isInteger, `Integer`);
var me = (function (e) {
m(t, e);
function t(t, n, r, i, a, o) {
var s = e.call(this, t, n, r, i, a) || this;
return ((s.tag = o), s);
}
return t;
})(q);
(new ((function (e) {
m(t, e);
function t() {
var t =
e.call(
this,
`object`,
function (e) {
return typeof e == `object` && !!e;
},
function (e, n) {
return t.is(e) ? v(e) : _(e, n);
},
b,
) || this;
return ((t._tag = `ObjectType`), t);
}
return t;
})(y))(),
(function (e) {
m(t, e);
function t(t, n, r, i, a) {
var o = e.call(this, t, n, r, i) || this;
return ((o.props = a), (o._tag = `StrictType`), o);
}
return t;
})(y));
function he(e, t) {
return new y(
e,
t,
function (e, n) {
return t(e) ? v(e) : _(e, n);
},
b,
);
}
var X = he(`Date`, function (e) {
return e instanceof Date;
});
const Z = (e, t) =>
Y(z, (n) => n.length >= e && n.length <= t, `string with length between ${e} and ${t}`),
Q = (e, t) => Y(B, (n) => n >= e && n <= t, `number between ${e} and ${t}`),
ge = Y(z, (e) => URL.canParse(e), `url`),
$ = K({
id: B,
created: X,
title: Z(1, 100),
type: (([e, t, ...n]) => J([W(e), W(t), ...n.map((e) => W(e))]))([`jpg`, `png`]),
size: B,
url: ge,
}),
_e = K({ id: B, stars: Q(0, 5), title: Z(1, 100), text: Z(1, 1e3), images: G($) });
K(
{
id: B,
created: X,
title: Z(1, 100),
brand: Z(1, 30),
description: Z(1, 500),
price: Q(1, 1e4),
discount: J([Q(1, 100), L]),
quantity: Q(0, 10),
tags: G(Z(1, 30)),
images: G($),
ratings: G(_e),
},
`ProductData`,
).decode({});