@jsdev_ninja/core 0.11.2 → 0.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.es.js CHANGED
@@ -9,28 +9,28 @@ var b;
9
9
  }
10
10
  r.assertNever = t, r.arrayToEnum = (s) => {
11
11
  const a = {};
12
- for (const o of s)
13
- a[o] = o;
12
+ for (const c of s)
13
+ a[c] = c;
14
14
  return a;
15
15
  }, r.getValidEnumValues = (s) => {
16
- const a = r.objectKeys(s).filter((i) => typeof s[s[i]] != "number"), o = {};
16
+ const a = r.objectKeys(s).filter((i) => typeof s[s[i]] != "number"), c = {};
17
17
  for (const i of a)
18
- o[i] = s[i];
19
- return r.objectValues(o);
18
+ c[i] = s[i];
19
+ return r.objectValues(c);
20
20
  }, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
21
21
  return s[a];
22
22
  }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
23
23
  const a = [];
24
- for (const o in s)
25
- Object.prototype.hasOwnProperty.call(s, o) && a.push(o);
24
+ for (const c in s)
25
+ Object.prototype.hasOwnProperty.call(s, c) && a.push(c);
26
26
  return a;
27
27
  }, r.find = (s, a) => {
28
- for (const o of s)
29
- if (a(o))
30
- return o;
28
+ for (const c of s)
29
+ if (a(c))
30
+ return c;
31
31
  }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
32
32
  function n(s, a = " | ") {
33
- return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
33
+ return s.map((c) => typeof c == "string" ? `'${c}'` : c).join(a);
34
34
  }
35
35
  r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
36
36
  })(b || (b = {}));
@@ -119,20 +119,20 @@ class Z extends Error {
119
119
  const t = e || function(a) {
120
120
  return a.message;
121
121
  }, n = { _errors: [] }, s = (a) => {
122
- for (const o of a.issues)
123
- if (o.code === "invalid_union")
124
- o.unionErrors.map(s);
125
- else if (o.code === "invalid_return_type")
126
- s(o.returnTypeError);
127
- else if (o.code === "invalid_arguments")
128
- s(o.argumentsError);
129
- else if (o.path.length === 0)
130
- n._errors.push(t(o));
122
+ for (const c of a.issues)
123
+ if (c.code === "invalid_union")
124
+ c.unionErrors.map(s);
125
+ else if (c.code === "invalid_return_type")
126
+ s(c.returnTypeError);
127
+ else if (c.code === "invalid_arguments")
128
+ s(c.argumentsError);
129
+ else if (c.path.length === 0)
130
+ n._errors.push(t(c));
131
131
  else {
132
132
  let i = n, l = 0;
133
- for (; l < o.path.length; ) {
134
- const u = o.path[l];
135
- l === o.path.length - 1 ? (i[u] = i[u] || { _errors: [] }, i[u]._errors.push(t(o))) : i[u] = i[u] || { _errors: [] }, i = i[u], l++;
133
+ for (; l < c.path.length; ) {
134
+ const u = c.path[l];
135
+ l === c.path.length - 1 ? (i[u] = i[u] || { _errors: [] }, i[u]._errors.push(t(c))) : i[u] = i[u] || { _errors: [] }, i = i[u], l++;
136
136
  }
137
137
  }
138
138
  };
@@ -226,7 +226,7 @@ function _e() {
226
226
  return Ue;
227
227
  }
228
228
  const be = (r) => {
229
- const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], o = {
229
+ const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], c = {
230
230
  ...s,
231
231
  path: a
232
232
  };
@@ -239,7 +239,7 @@ const be = (r) => {
239
239
  let i = "";
240
240
  const l = n.filter((u) => !!u).slice().reverse();
241
241
  for (const u of l)
242
- i = u(o, { data: e, defaultError: i }).message;
242
+ i = u(c, { data: e, defaultError: i }).message;
243
243
  return {
244
244
  ...s,
245
245
  path: a,
@@ -286,10 +286,10 @@ class C {
286
286
  static async mergeObjectAsync(e, t) {
287
287
  const n = [];
288
288
  for (const s of t) {
289
- const a = await s.key, o = await s.value;
289
+ const a = await s.key, c = await s.value;
290
290
  n.push({
291
291
  key: a,
292
- value: o
292
+ value: c
293
293
  });
294
294
  }
295
295
  return C.mergeObjectSync(e, n);
@@ -297,10 +297,10 @@ class C {
297
297
  static mergeObjectSync(e, t) {
298
298
  const n = {};
299
299
  for (const s of t) {
300
- const { key: a, value: o } = s;
301
- if (a.status === "aborted" || o.status === "aborted")
300
+ const { key: a, value: c } = s;
301
+ if (a.status === "aborted" || c.status === "aborted")
302
302
  return g;
303
- a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (n[a.value] = o.value);
303
+ a.status === "dirty" && e.dirty(), c.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof c.value < "u" || s.alwaysSet) && (n[a.value] = c.value);
304
304
  }
305
305
  return { status: e.value, value: n };
306
306
  }
@@ -350,10 +350,10 @@ function v(r) {
350
350
  const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
351
351
  if (e && (t || n))
352
352
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
353
- return e ? { errorMap: e, description: s } : { errorMap: (o, i) => {
353
+ return e ? { errorMap: e, description: s } : { errorMap: (c, i) => {
354
354
  var l, u;
355
355
  const { message: p } = r;
356
- return o.code === "invalid_enum_value" ? { message: p ?? i.defaultError } : typeof i.data > "u" ? { message: (l = p ?? n) !== null && l !== void 0 ? l : i.defaultError } : o.code !== "invalid_type" ? { message: i.defaultError } : { message: (u = p ?? t) !== null && u !== void 0 ? u : i.defaultError };
356
+ return c.code === "invalid_enum_value" ? { message: p ?? i.defaultError } : typeof i.data > "u" ? { message: (l = p ?? n) !== null && l !== void 0 ? l : i.defaultError } : c.code !== "invalid_type" ? { message: i.defaultError } : { message: (u = p ?? t) !== null && u !== void 0 ? u : i.defaultError };
357
357
  }, description: s };
358
358
  }
359
359
  class _ {
@@ -475,11 +475,11 @@ class _ {
475
475
  refine(e, t) {
476
476
  const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
477
477
  return this._refinement((s, a) => {
478
- const o = e(s), i = () => a.addIssue({
478
+ const c = e(s), i = () => a.addIssue({
479
479
  code: d.custom,
480
480
  ...n(s)
481
481
  });
482
- return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (i(), !1)) : o ? !0 : (i(), !1);
482
+ return typeof Promise < "u" && c instanceof Promise ? c.then((l) => l ? !0 : (i(), !1)) : c ? !0 : (i(), !1);
483
483
  });
484
484
  }
485
485
  refinement(e, t) {
@@ -639,8 +639,8 @@ class N extends _ {
639
639
  message: a.message
640
640
  }), n.dirty());
641
641
  else if (a.kind === "length") {
642
- const o = e.data.length > a.value, i = e.data.length < a.value;
643
- (o || i) && (s = this._getOrReturnCtx(e, s), o ? f(s, {
642
+ const c = e.data.length > a.value, i = e.data.length < a.value;
643
+ (c || i) && (s = this._getOrReturnCtx(e, s), c ? f(s, {
644
644
  code: d.too_big,
645
645
  maximum: a.value,
646
646
  type: "string",
@@ -995,8 +995,8 @@ N.create = (r) => {
995
995
  });
996
996
  };
997
997
  function At(r, e) {
998
- const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
999
- return a % o / Math.pow(10, s);
998
+ const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), c = parseInt(e.toFixed(s).replace(".", ""));
999
+ return a % c / Math.pow(10, s);
1000
1000
  }
1001
1001
  class M extends _ {
1002
1002
  constructor() {
@@ -1518,11 +1518,11 @@ class O extends _ {
1518
1518
  received: t.parsedType
1519
1519
  }), g;
1520
1520
  if (s.exactLength !== null) {
1521
- const o = t.data.length > s.exactLength.value, i = t.data.length < s.exactLength.value;
1522
- (o || i) && (f(t, {
1523
- code: o ? d.too_big : d.too_small,
1521
+ const c = t.data.length > s.exactLength.value, i = t.data.length < s.exactLength.value;
1522
+ (c || i) && (f(t, {
1523
+ code: c ? d.too_big : d.too_small,
1524
1524
  minimum: i ? s.exactLength.value : void 0,
1525
- maximum: o ? s.exactLength.value : void 0,
1525
+ maximum: c ? s.exactLength.value : void 0,
1526
1526
  type: "array",
1527
1527
  inclusive: !0,
1528
1528
  exact: !0,
@@ -1544,8 +1544,8 @@ class O extends _ {
1544
1544
  exact: !1,
1545
1545
  message: s.maxLength.message
1546
1546
  }), n.dirty()), t.common.async)
1547
- return Promise.all([...t.data].map((o, i) => s.type._parseAsync(new R(t, o, t.path, i)))).then((o) => C.mergeArray(n, o));
1548
- const a = [...t.data].map((o, i) => s.type._parseSync(new R(t, o, t.path, i)));
1547
+ return Promise.all([...t.data].map((c, i) => s.type._parseAsync(new R(t, c, t.path, i)))).then((c) => C.mergeArray(n, c));
1548
+ const a = [...t.data].map((c, i) => s.type._parseSync(new R(t, c, t.path, i)));
1549
1549
  return C.mergeArray(n, a);
1550
1550
  }
1551
1551
  get element() {
@@ -1616,12 +1616,12 @@ class k extends _ {
1616
1616
  received: u.parsedType
1617
1617
  }), g;
1618
1618
  }
1619
- const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), i = [];
1619
+ const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: c } = this._getCached(), i = [];
1620
1620
  if (!(this._def.catchall instanceof D && this._def.unknownKeys === "strip"))
1621
1621
  for (const u in s.data)
1622
- o.includes(u) || i.push(u);
1622
+ c.includes(u) || i.push(u);
1623
1623
  const l = [];
1624
- for (const u of o) {
1624
+ for (const u of c) {
1625
1625
  const p = a[u], x = s.data[u];
1626
1626
  l.push({
1627
1627
  key: { status: "valid", value: u },
@@ -1679,8 +1679,8 @@ class k extends _ {
1679
1679
  unknownKeys: "strict",
1680
1680
  ...e !== void 0 ? {
1681
1681
  errorMap: (t, n) => {
1682
- var s, a, o, i;
1683
- const l = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && o !== void 0 ? o : n.defaultError;
1682
+ var s, a, c, i;
1683
+ const l = (c = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && c !== void 0 ? c : n.defaultError;
1684
1684
  return t.code === "unrecognized_keys" ? {
1685
1685
  message: (i = m.errToObj(e).message) !== null && i !== void 0 ? i : l
1686
1686
  } : {
@@ -1894,15 +1894,15 @@ class oe extends _ {
1894
1894
  for (const i of a)
1895
1895
  if (i.result.status === "dirty")
1896
1896
  return t.common.issues.push(...i.ctx.common.issues), i.result;
1897
- const o = a.map((i) => new Z(i.ctx.common.issues));
1897
+ const c = a.map((i) => new Z(i.ctx.common.issues));
1898
1898
  return f(t, {
1899
1899
  code: d.invalid_union,
1900
- unionErrors: o
1900
+ unionErrors: c
1901
1901
  }), g;
1902
1902
  }
1903
1903
  if (t.common.async)
1904
1904
  return Promise.all(n.map(async (a) => {
1905
- const o = {
1905
+ const c = {
1906
1906
  ...t,
1907
1907
  common: {
1908
1908
  ...t.common,
@@ -1914,14 +1914,14 @@ class oe extends _ {
1914
1914
  result: await a._parseAsync({
1915
1915
  data: t.data,
1916
1916
  path: t.path,
1917
- parent: o
1917
+ parent: c
1918
1918
  }),
1919
- ctx: o
1919
+ ctx: c
1920
1920
  };
1921
1921
  })).then(s);
1922
1922
  {
1923
1923
  let a;
1924
- const o = [];
1924
+ const c = [];
1925
1925
  for (const l of n) {
1926
1926
  const u = {
1927
1927
  ...t,
@@ -1937,11 +1937,11 @@ class oe extends _ {
1937
1937
  });
1938
1938
  if (p.status === "valid")
1939
1939
  return p;
1940
- p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && o.push(u.common.issues);
1940
+ p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && c.push(u.common.issues);
1941
1941
  }
1942
1942
  if (a)
1943
1943
  return t.common.issues.push(...a.ctx.common.issues), a.result;
1944
- const i = o.map((l) => new Z(l));
1944
+ const i = c.map((l) => new Z(l));
1945
1945
  return f(t, {
1946
1946
  code: d.invalid_union,
1947
1947
  unionErrors: i
@@ -2002,10 +2002,10 @@ class Se extends _ {
2002
2002
  static create(e, t, n) {
2003
2003
  const s = /* @__PURE__ */ new Map();
2004
2004
  for (const a of t) {
2005
- const o = $(a.shape[e]);
2006
- if (!o.length)
2005
+ const c = $(a.shape[e]);
2006
+ if (!c.length)
2007
2007
  throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2008
- for (const i of o) {
2008
+ for (const i of c) {
2009
2009
  if (s.has(i))
2010
2010
  throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);
2011
2011
  s.set(i, a);
@@ -2025,20 +2025,20 @@ function Ee(r, e) {
2025
2025
  if (r === e)
2026
2026
  return { valid: !0, data: r };
2027
2027
  if (t === h.object && n === h.object) {
2028
- const s = b.objectKeys(e), a = b.objectKeys(r).filter((i) => s.indexOf(i) !== -1), o = { ...r, ...e };
2028
+ const s = b.objectKeys(e), a = b.objectKeys(r).filter((i) => s.indexOf(i) !== -1), c = { ...r, ...e };
2029
2029
  for (const i of a) {
2030
2030
  const l = Ee(r[i], e[i]);
2031
2031
  if (!l.valid)
2032
2032
  return { valid: !1 };
2033
- o[i] = l.data;
2033
+ c[i] = l.data;
2034
2034
  }
2035
- return { valid: !0, data: o };
2035
+ return { valid: !0, data: c };
2036
2036
  } else if (t === h.array && n === h.array) {
2037
2037
  if (r.length !== e.length)
2038
2038
  return { valid: !1 };
2039
2039
  const s = [];
2040
2040
  for (let a = 0; a < r.length; a++) {
2041
- const o = r[a], i = e[a], l = Ee(o, i);
2041
+ const c = r[a], i = e[a], l = Ee(c, i);
2042
2042
  if (!l.valid)
2043
2043
  return { valid: !1 };
2044
2044
  s.push(l.data);
@@ -2048,11 +2048,11 @@ function Ee(r, e) {
2048
2048
  }
2049
2049
  class ce extends _ {
2050
2050
  _parse(e) {
2051
- const { status: t, ctx: n } = this._processInputParams(e), s = (a, o) => {
2052
- if (Oe(a) || Oe(o))
2051
+ const { status: t, ctx: n } = this._processInputParams(e), s = (a, c) => {
2052
+ if (Oe(a) || Oe(c))
2053
2053
  return g;
2054
- const i = Ee(a.value, o.value);
2055
- return i.valid ? ((je(a) || je(o)) && t.dirty(), { status: t.value, value: i.data }) : (f(n, {
2054
+ const i = Ee(a.value, c.value);
2055
+ return i.valid ? ((je(a) || je(c)) && t.dirty(), { status: t.value, value: i.data }) : (f(n, {
2056
2056
  code: d.invalid_intersection_types
2057
2057
  }), g);
2058
2058
  };
@@ -2067,7 +2067,7 @@ class ce extends _ {
2067
2067
  path: n.path,
2068
2068
  parent: n
2069
2069
  })
2070
- ]).then(([a, o]) => s(a, o)) : s(this._def.left._parseSync({
2070
+ ]).then(([a, c]) => s(a, c)) : s(this._def.left._parseSync({
2071
2071
  data: n.data,
2072
2072
  path: n.path,
2073
2073
  parent: n
@@ -2108,11 +2108,11 @@ class P extends _ {
2108
2108
  exact: !1,
2109
2109
  type: "array"
2110
2110
  }), t.dirty());
2111
- const a = [...n.data].map((o, i) => {
2111
+ const a = [...n.data].map((c, i) => {
2112
2112
  const l = this._def.items[i] || this._def.rest;
2113
- return l ? l._parse(new R(n, o, n.path, i)) : null;
2114
- }).filter((o) => !!o);
2115
- return n.common.async ? Promise.all(a).then((o) => C.mergeArray(t, o)) : C.mergeArray(t, a);
2113
+ return l ? l._parse(new R(n, c, n.path, i)) : null;
2114
+ }).filter((c) => !!c);
2115
+ return n.common.async ? Promise.all(a).then((c) => C.mergeArray(t, c)) : C.mergeArray(t, a);
2116
2116
  }
2117
2117
  get items() {
2118
2118
  return this._def.items;
@@ -2149,11 +2149,11 @@ class de extends _ {
2149
2149
  expected: h.object,
2150
2150
  received: n.parsedType
2151
2151
  }), g;
2152
- const s = [], a = this._def.keyType, o = this._def.valueType;
2152
+ const s = [], a = this._def.keyType, c = this._def.valueType;
2153
2153
  for (const i in n.data)
2154
2154
  s.push({
2155
2155
  key: a._parse(new R(n, i, n.path, i)),
2156
- value: o._parse(new R(n, n.data[i], n.path, i)),
2156
+ value: c._parse(new R(n, n.data[i], n.path, i)),
2157
2157
  alwaysSet: i in n.data
2158
2158
  });
2159
2159
  return n.common.async ? C.mergeObjectAsync(t, s) : C.mergeObjectSync(t, s);
@@ -2190,14 +2190,14 @@ class Te extends _ {
2190
2190
  expected: h.map,
2191
2191
  received: n.parsedType
2192
2192
  }), g;
2193
- const s = this._def.keyType, a = this._def.valueType, o = [...n.data.entries()].map(([i, l], u) => ({
2193
+ const s = this._def.keyType, a = this._def.valueType, c = [...n.data.entries()].map(([i, l], u) => ({
2194
2194
  key: s._parse(new R(n, i, n.path, [u, "key"])),
2195
2195
  value: a._parse(new R(n, l, n.path, [u, "value"]))
2196
2196
  }));
2197
2197
  if (n.common.async) {
2198
2198
  const i = /* @__PURE__ */ new Map();
2199
2199
  return Promise.resolve().then(async () => {
2200
- for (const l of o) {
2200
+ for (const l of c) {
2201
2201
  const u = await l.key, p = await l.value;
2202
2202
  if (u.status === "aborted" || p.status === "aborted")
2203
2203
  return g;
@@ -2207,7 +2207,7 @@ class Te extends _ {
2207
2207
  });
2208
2208
  } else {
2209
2209
  const i = /* @__PURE__ */ new Map();
2210
- for (const l of o) {
2210
+ for (const l of c) {
2211
2211
  const u = l.key, p = l.value;
2212
2212
  if (u.status === "aborted" || p.status === "aborted")
2213
2213
  return g;
@@ -2249,7 +2249,7 @@ class W extends _ {
2249
2249
  message: s.maxSize.message
2250
2250
  }), t.dirty());
2251
2251
  const a = this._def.valueType;
2252
- function o(l) {
2252
+ function c(l) {
2253
2253
  const u = /* @__PURE__ */ new Set();
2254
2254
  for (const p of l) {
2255
2255
  if (p.status === "aborted")
@@ -2259,7 +2259,7 @@ class W extends _ {
2259
2259
  return { status: t.value, value: u };
2260
2260
  }
2261
2261
  const i = [...n.data.values()].map((l, u) => a._parse(new R(n, l, n.path, u)));
2262
- return n.common.async ? Promise.all(i).then((l) => o(l)) : o(i);
2262
+ return n.common.async ? Promise.all(i).then((l) => c(l)) : c(i);
2263
2263
  }
2264
2264
  min(e, t) {
2265
2265
  return new W({
@@ -2331,13 +2331,13 @@ class Y extends _ {
2331
2331
  }
2332
2332
  });
2333
2333
  }
2334
- const a = { errorMap: t.common.contextualErrorMap }, o = t.data;
2334
+ const a = { errorMap: t.common.contextualErrorMap }, c = t.data;
2335
2335
  if (this._def.returns instanceof K) {
2336
2336
  const i = this;
2337
2337
  return S(async function(...l) {
2338
2338
  const u = new Z([]), p = await i._def.args.parseAsync(l, a).catch((w) => {
2339
2339
  throw u.addIssue(n(l, w)), u;
2340
- }), x = await Reflect.apply(o, this, p);
2340
+ }), x = await Reflect.apply(c, this, p);
2341
2341
  return await i._def.returns._def.type.parseAsync(x, a).catch((w) => {
2342
2342
  throw u.addIssue(s(x, w)), u;
2343
2343
  });
@@ -2348,7 +2348,7 @@ class Y extends _ {
2348
2348
  const u = i._def.args.safeParse(l, a);
2349
2349
  if (!u.success)
2350
2350
  throw new Z([n(l, u.error)]);
2351
- const p = Reflect.apply(o, this, u.data), x = i._def.returns.safeParse(p, a);
2351
+ const p = Reflect.apply(c, this, u.data), x = i._def.returns.safeParse(p, a);
2352
2352
  if (!x.success)
2353
2353
  throw new Z([s(p, x.error)]);
2354
2354
  return x.data;
@@ -2556,17 +2556,17 @@ class j extends _ {
2556
2556
  }
2557
2557
  _parse(e) {
2558
2558
  const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
2559
- addIssue: (o) => {
2560
- f(n, o), o.fatal ? t.abort() : t.dirty();
2559
+ addIssue: (c) => {
2560
+ f(n, c), c.fatal ? t.abort() : t.dirty();
2561
2561
  },
2562
2562
  get path() {
2563
2563
  return n.path;
2564
2564
  }
2565
2565
  };
2566
2566
  if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2567
- const o = s.transform(n.data, a);
2567
+ const c = s.transform(n.data, a);
2568
2568
  if (n.common.async)
2569
- return Promise.resolve(o).then(async (i) => {
2569
+ return Promise.resolve(c).then(async (i) => {
2570
2570
  if (t.value === "aborted")
2571
2571
  return g;
2572
2572
  const l = await this._def.schema._parseAsync({
@@ -2580,7 +2580,7 @@ class j extends _ {
2580
2580
  if (t.value === "aborted")
2581
2581
  return g;
2582
2582
  const i = this._def.schema._parseSync({
2583
- data: o,
2583
+ data: c,
2584
2584
  path: n.path,
2585
2585
  parent: n
2586
2586
  });
@@ -2588,7 +2588,7 @@ class j extends _ {
2588
2588
  }
2589
2589
  }
2590
2590
  if (s.type === "refinement") {
2591
- const o = (i) => {
2591
+ const c = (i) => {
2592
2592
  const l = s.refinement(i, a);
2593
2593
  if (n.common.async)
2594
2594
  return Promise.resolve(l);
@@ -2602,25 +2602,25 @@ class j extends _ {
2602
2602
  path: n.path,
2603
2603
  parent: n
2604
2604
  });
2605
- return i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), o(i.value), { status: t.value, value: i.value });
2605
+ return i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), c(i.value), { status: t.value, value: i.value });
2606
2606
  } else
2607
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), o(i.value).then(() => ({ status: t.value, value: i.value }))));
2607
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => i.status === "aborted" ? g : (i.status === "dirty" && t.dirty(), c(i.value).then(() => ({ status: t.value, value: i.value }))));
2608
2608
  }
2609
2609
  if (s.type === "transform")
2610
2610
  if (n.common.async === !1) {
2611
- const o = this._def.schema._parseSync({
2611
+ const c = this._def.schema._parseSync({
2612
2612
  data: n.data,
2613
2613
  path: n.path,
2614
2614
  parent: n
2615
2615
  });
2616
- if (!B(o))
2617
- return o;
2618
- const i = s.transform(o.value, a);
2616
+ if (!B(c))
2617
+ return c;
2618
+ const i = s.transform(c.value, a);
2619
2619
  if (i instanceof Promise)
2620
2620
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2621
2621
  return { status: t.value, value: i };
2622
2622
  } else
2623
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => B(o) ? Promise.resolve(s.transform(o.value, a)).then((i) => ({ status: t.value, value: i })) : o);
2623
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((c) => B(c) ? Promise.resolve(s.transform(c.value, a)).then((i) => ({ status: t.value, value: i })) : c);
2624
2624
  b.assertNever(s);
2625
2625
  }
2626
2626
  }
@@ -2816,7 +2816,7 @@ function ze(r, e) {
2816
2816
  }
2817
2817
  function Ye(r, e = {}, t) {
2818
2818
  return r ? X.create().superRefine((n, s) => {
2819
- var a, o;
2819
+ var a, c;
2820
2820
  const i = r(n);
2821
2821
  if (i instanceof Promise)
2822
2822
  return i.then((l) => {
@@ -2827,7 +2827,7 @@ function Ye(r, e = {}, t) {
2827
2827
  }
2828
2828
  });
2829
2829
  if (!i) {
2830
- const l = ze(e, n), u = (o = (a = l.fatal) !== null && a !== void 0 ? a : t) !== null && o !== void 0 ? o : !0;
2830
+ const l = ze(e, n), u = (c = (a = l.fatal) !== null && a !== void 0 ? a : t) !== null && c !== void 0 ? c : !0;
2831
2831
  s.addIssue({ code: "custom", ...l, fatal: u });
2832
2832
  }
2833
2833
  }) : X.create();
@@ -2851,7 +2851,7 @@ const jt = (r, e = {
2851
2851
  bigint: (r) => L.create({ ...r, coerce: !0 }),
2852
2852
  date: (r) => q.create({ ...r, coerce: !0 })
2853
2853
  }, hr = g;
2854
- var c = /* @__PURE__ */ Object.freeze({
2854
+ var o = /* @__PURE__ */ Object.freeze({
2855
2855
  __proto__: null,
2856
2856
  defaultErrorMap: G,
2857
2857
  setErrorMap: ot,
@@ -2967,7 +2967,7 @@ var c = /* @__PURE__ */ Object.freeze({
2967
2967
  quotelessJson: it,
2968
2968
  ZodError: Z
2969
2969
  });
2970
- const T = c.string().min(1, { message: "שדה חובה" }), _r = c.string().regex(/^\d+$/, "Must be a numeric string"), pr = c.object({
2970
+ const T = o.string().min(1, { message: "שדה חובה" }), br = o.string().regex(/^\d+$/, "Must be a numeric string"), pr = o.object({
2971
2971
  country: T,
2972
2972
  city: T,
2973
2973
  street: T,
@@ -2975,121 +2975,122 @@ const T = c.string().min(1, { message: "שדה חובה" }), _r = c.string().reg
2975
2975
  floor: T,
2976
2976
  apartmentEnterNumber: T,
2977
2977
  apartmentNumber: T
2978
- }), H = c.object({
2979
- lang: c.enum(["he"]),
2980
- value: c.string()
2981
- }), br = c.array(H), Ke = c.object({
2982
- id: c.string().min(1),
2983
- companyId: c.string().min(1),
2984
- storeId: c.string().min(1),
2985
- parentId: c.string().nullish(),
2986
- tag: c.string().optional(),
2987
- locales: c.array(H),
2988
- depth: c.number()
2978
+ }), H = o.object({
2979
+ lang: o.enum(["he"]),
2980
+ value: o.string()
2981
+ }), xr = o.array(H), Ke = o.object({
2982
+ id: o.string().min(1),
2983
+ companyId: o.string().min(1),
2984
+ storeId: o.string().min(1),
2985
+ parentId: o.string().nullish(),
2986
+ tag: o.string().optional(),
2987
+ locales: o.array(H),
2988
+ depth: o.number()
2989
2989
  }), Pe = Ke.extend({
2990
- children: c.lazy(() => Pe.array())
2991
- }), xr = Ke.extend({
2992
- index: c.number(),
2993
- depth: c.number(),
2994
- collapsed: c.boolean().optional(),
2995
- children: c.array(Pe)
2996
- }), ee = c.string().min(1), et = c.object({
2997
- type: c.literal("Product"),
2990
+ children: o.lazy(() => Pe.array())
2991
+ }), kr = Ke.extend({
2992
+ index: o.number(),
2993
+ depth: o.number(),
2994
+ collapsed: o.boolean().optional(),
2995
+ children: o.array(Pe)
2996
+ }), ee = o.string().min(1), et = o.object({
2997
+ type: o.literal("Product"),
2998
2998
  storeId: ee,
2999
2999
  companyId: ee,
3000
3000
  id: ee,
3001
3001
  objectID: ee,
3002
3002
  sku: ee,
3003
- name: c.array(H),
3004
- description: c.array(H),
3005
- isPublished: c.boolean(),
3006
- vat: c.boolean(),
3007
- priceType: c.object({
3008
- type: c.enum(["unit", "kg", "gram", "liter", "ml"]),
3009
- value: c.number()
3003
+ name: o.array(H),
3004
+ description: o.array(H),
3005
+ isPublished: o.boolean(),
3006
+ vat: o.boolean(),
3007
+ priceType: o.object({
3008
+ type: o.enum(["unit", "kg", "gram", "liter", "ml"]),
3009
+ value: o.number()
3010
3010
  }),
3011
- price: c.number().positive(),
3012
- purchasePrice: c.number().optional(),
3013
- profitPercentage: c.number().optional(),
3014
- currency: c.literal("ILS"),
3015
- discount: c.object({
3016
- type: c.enum(["number", "percent", "none"]),
3017
- value: c.number()
3011
+ price: o.number().positive(),
3012
+ purchasePrice: o.number().optional(),
3013
+ profitPercentage: o.number().optional(),
3014
+ currency: o.literal("ILS"),
3015
+ discount: o.object({
3016
+ type: o.enum(["number", "percent", "none"]),
3017
+ value: o.number()
3018
3018
  }),
3019
- isDiscountable: c.boolean({ description: "included in store discounts" }).optional(),
3020
- weight: c.object({
3021
- value: c.number(),
3022
- unit: c.enum(["kg", "gram", "none"])
3019
+ isDiscountable: o.boolean({ description: "included in store discounts" }).optional(),
3020
+ weight: o.object({
3021
+ value: o.number(),
3022
+ unit: o.enum(["kg", "gram", "none"])
3023
3023
  }),
3024
- volume: c.object({
3025
- value: c.number(),
3026
- unit: c.enum(["liter", "ml", "none"])
3024
+ volume: o.object({
3025
+ value: o.number(),
3026
+ unit: o.enum(["liter", "ml", "none"])
3027
3027
  }),
3028
- images: c.array(c.object({ url: c.string().url(), id: c.string() })),
3029
- manufacturer: c.string(),
3030
- brand: c.string(),
3031
- importer: c.string(),
3032
- supplier: c.string(),
3033
- ingredients: c.array(H),
3034
- created_at: c.number(),
3035
- updated_at: c.number(),
3036
- categoryIds: c.array(c.string().nonempty()),
3028
+ images: o.array(o.object({ url: o.string().url(), id: o.string() })),
3029
+ manufacturer: o.string(),
3030
+ brand: o.string(),
3031
+ importer: o.string(),
3032
+ supplier: o.string(),
3033
+ ingredients: o.array(H),
3034
+ created_at: o.number(),
3035
+ updated_at: o.number(),
3036
+ categoryIds: o.array(o.string().nonempty()),
3037
3037
  // @deprecated
3038
- categoryList: c.array(Pe),
3038
+ categoryList: o.array(Pe),
3039
3039
  // @deprecated
3040
- categories: c.object({
3041
- lvl0: c.array(c.string()),
3042
- lvl1: c.array(c.string()),
3043
- lvl2: c.array(c.string()),
3044
- lvl3: c.array(c.string()),
3045
- lvl4: c.array(c.string())
3040
+ categories: o.object({
3041
+ lvl0: o.array(o.string()),
3042
+ lvl1: o.array(o.string()),
3043
+ lvl2: o.array(o.string()),
3044
+ lvl3: o.array(o.string()),
3045
+ lvl4: o.array(o.string())
3046
3046
  }),
3047
3047
  // @deprecated
3048
- categoryNames: c.array(c.string())
3049
- }), kr = et.extend({
3050
- image: c.instanceof(File).optional()
3051
- }), tt = c.object({
3048
+ categoryNames: o.array(o.string())
3049
+ }), wr = et.extend({
3050
+ image: o.instanceof(File).optional()
3051
+ }), tt = o.object({
3052
3052
  product: et,
3053
- originalPrice: c.number().optional(),
3054
- finalPrice: c.number().optional(),
3055
- finalDiscount: c.number().optional(),
3056
- amount: c.number().int().positive({ message: "Quantity must be a positive integer." })
3057
- }), wr = c.object({
3058
- type: c.literal("Cart"),
3059
- id: c.string().uuid(),
3060
- companyId: c.string().uuid(),
3061
- storeId: c.string().uuid(),
3062
- userId: c.string().uuid(),
3063
- status: c.enum(["active", "draft", "completed"]),
3064
- items: c.array(tt)
3065
- }), Tr = c.object({
3066
- id: c.string(),
3067
- name: c.string(),
3068
- websiteDomains: c.array(c.string())
3069
- }), Cr = c.object({
3070
- type: c.literal("FavoriteProduct"),
3071
- id: c.string().uuid(),
3072
- companyId: c.string().uuid(),
3073
- storeId: c.string().uuid(),
3074
- userId: c.string().uuid(),
3075
- productId: c.string().uuid()
3076
- }), rt = c.enum(["default", "delayed"]), mr = c.object({
3077
- type: c.literal("Profile"),
3053
+ originalPrice: o.number().optional(),
3054
+ finalPrice: o.number().optional(),
3055
+ finalDiscount: o.number().optional(),
3056
+ amount: o.number().int().positive({ message: "Quantity must be a positive integer." })
3057
+ }), Tr = o.object({
3058
+ type: o.literal("Cart"),
3059
+ id: o.string().uuid(),
3060
+ companyId: o.string().uuid(),
3061
+ storeId: o.string().uuid(),
3062
+ userId: o.string().uuid(),
3063
+ status: o.enum(["active", "draft", "completed"]),
3064
+ items: o.array(tt)
3065
+ }), Cr = o.object({
3066
+ id: o.string(),
3067
+ name: o.string(),
3068
+ websiteDomains: o.array(o.string())
3069
+ }), Sr = o.object({
3070
+ type: o.literal("FavoriteProduct"),
3071
+ id: o.string().uuid(),
3072
+ companyId: o.string().uuid(),
3073
+ storeId: o.string().uuid(),
3074
+ userId: o.string().uuid(),
3075
+ productId: o.string().uuid()
3076
+ }), rt = o.enum(["default", "delayed"]), mr = o.object({
3077
+ type: o.literal("Profile"),
3078
3078
  id: T,
3079
3079
  companyId: T,
3080
3080
  storeId: T,
3081
3081
  tenantId: T,
3082
- clientType: c.enum(["user", "company"]),
3082
+ clientType: o.enum(["user", "company"]),
3083
+ companyName: o.string().optional(),
3083
3084
  displayName: T,
3084
- email: c.string().email(),
3085
+ email: o.string().email(),
3085
3086
  phoneNumber: T.optional(),
3086
3087
  address: pr.optional(),
3087
- isAnonymous: c.boolean(),
3088
- createdDate: c.number(),
3089
- lastActivityDate: c.number(),
3088
+ isAnonymous: o.boolean(),
3089
+ createdDate: o.number(),
3090
+ lastActivityDate: o.number(),
3090
3091
  paymentType: rt
3091
3092
  });
3092
- function Sr() {
3093
+ function Zr() {
3093
3094
  return {
3094
3095
  type: "Profile",
3095
3096
  id: "",
@@ -3115,13 +3116,13 @@ function Sr() {
3115
3116
  paymentType: rt.Values.default
3116
3117
  };
3117
3118
  }
3118
- const Zr = c.object({
3119
- type: c.literal("Order"),
3119
+ const Ir = o.object({
3120
+ type: o.literal("Order"),
3120
3121
  id: T,
3121
3122
  companyId: T,
3122
3123
  storeId: T,
3123
3124
  userId: T,
3124
- status: c.enum([
3125
+ status: o.enum([
3125
3126
  "draft",
3126
3127
  // before payment
3127
3128
  "pending",
@@ -3135,49 +3136,50 @@ const Zr = c.object({
3135
3136
  "completed",
3136
3137
  "refunded"
3137
3138
  ]),
3138
- paymentStatus: c.enum(["pending", "pending_j5", "completed", "failed", "refunded"]),
3139
+ paymentStatus: o.enum(["pending", "pending_j5", "completed", "failed", "refunded"]),
3139
3140
  //todo check if hyp support partial refund
3140
- cart: c.object({
3141
- id: c.string(),
3142
- items: c.array(tt),
3143
- cartDiscount: c.number(),
3144
- cartTotal: c.number(),
3145
- cartVat: c.number()
3141
+ cart: o.object({
3142
+ id: o.string(),
3143
+ items: o.array(tt),
3144
+ cartDiscount: o.number(),
3145
+ cartTotal: o.number(),
3146
+ cartVat: o.number()
3146
3147
  }),
3147
- originalAmount: c.number().positive().optional(),
3148
+ originalAmount: o.number().positive().optional(),
3148
3149
  // what client pay
3149
- actualAmount: c.number().positive().optional(),
3150
+ actualAmount: o.number().positive().optional(),
3150
3151
  // what store charge
3151
- date: c.number(),
3152
- deliveryDate: c.number().optional(),
3153
- createdAt: c.number().optional(),
3152
+ date: o.number(),
3153
+ deliveryDate: o.number().optional(),
3154
+ createdAt: o.number().optional(),
3154
3155
  client: mr.required({})
3155
- });
3156
- c.object({
3157
- id: c.string(),
3158
- companyId: c.string(),
3159
- name: c.string(),
3160
- urls: c.array(c.string()),
3161
- logoUrl: c.string(),
3162
- tenantId: c.string(),
3156
+ }), yr = o.enum(["individual", "company"]);
3157
+ o.object({
3158
+ id: o.string(),
3159
+ companyId: o.string(),
3160
+ name: o.string(),
3161
+ urls: o.array(o.string()),
3162
+ logoUrl: o.string(),
3163
+ tenantId: o.string(),
3163
3164
  // firebase auth tenantId
3164
- paymentType: c.enum(["external", "j5"]),
3165
- allowAnonymousClients: c.boolean(),
3166
- isVatIncludedInPrice: c.boolean()
3165
+ paymentType: o.enum(["external", "j5"]),
3166
+ allowAnonymousClients: o.boolean(),
3167
+ isVatIncludedInPrice: o.boolean(),
3168
+ clientTypes: o.array(yr)
3167
3169
  });
3168
- const Ae = c.string().min(1), Ir = c.object({
3169
- type: c.literal("Discount"),
3170
+ const Ae = o.string().min(1), Ar = o.object({
3171
+ type: o.literal("Discount"),
3170
3172
  storeId: Ae,
3171
3173
  companyId: Ae,
3172
3174
  id: Ae,
3173
- name: c.array(H),
3174
- active: c.boolean(),
3175
- variant: c.discriminatedUnion("variantType", [
3176
- c.object({
3177
- variantType: c.literal("bundle"),
3178
- productsId: c.array(c.string()).min(1),
3179
- requiredQuantity: c.number().positive(),
3180
- discountPrice: c.number().positive()
3175
+ name: o.array(H),
3176
+ active: o.boolean(),
3177
+ variant: o.discriminatedUnion("variantType", [
3178
+ o.object({
3179
+ variantType: o.literal("bundle"),
3180
+ productsId: o.array(o.string()).min(1),
3181
+ requiredQuantity: o.number().positive(),
3182
+ discountPrice: o.number().positive()
3181
3183
  })
3182
3184
  ])
3183
3185
  }), ve = {
@@ -3195,7 +3197,7 @@ function st(r) {
3195
3197
  }
3196
3198
  return ((t = r.discount) == null ? void 0 : t.type) === "number" ? r.price - r.discount.value : r.price;
3197
3199
  }
3198
- function Ar({
3200
+ function Nr({
3199
3201
  cart: r,
3200
3202
  discounts: e,
3201
3203
  store: t
@@ -3236,7 +3238,7 @@ function Ar({
3236
3238
  ), console.log("dis", x, p);
3237
3239
  }
3238
3240
  }), console.log("result", s);
3239
- const o = s.reduce(
3241
+ const c = s.reduce(
3240
3242
  (i, l) => {
3241
3243
  const { product: u, amount: p, finalPrice: x, finalDiscount: I } = l;
3242
3244
  console.log("isVatIncludedInPrice", n);
@@ -3256,14 +3258,14 @@ function Ar({
3256
3258
  vat: 0
3257
3259
  }
3258
3260
  );
3259
- return console.log("cartDetails", o), { items: s, ...o };
3261
+ return console.log("cartDetails", c), { items: s, ...c };
3260
3262
  }
3261
- function Nr(r) {
3263
+ function Or(r) {
3262
3264
  return (r ?? []).reduce(
3263
3265
  (e, t) => {
3264
- const { product: n, amount: s } = t, a = st(n), o = nt(n), i = n.price - o;
3266
+ const { product: n, amount: s } = t, a = st(n), c = nt(n), i = n.price - c;
3265
3267
  let l = 0;
3266
- return n.vat && (l = i * ve.VAT / 100, l = l * s, e.vat += l), e.cost += s * n.price, e.discount += o && s * o, e.finalCost += s * a + l, e;
3268
+ return n.vat && (l = i * ve.VAT / 100, l = l * s, e.vat += l), e.cost += s * n.price, e.discount += c && s * c, e.finalCost += s * a + l, e;
3267
3269
  },
3268
3270
  {
3269
3271
  cost: 0,
@@ -3273,10 +3275,10 @@ function Nr(r) {
3273
3275
  }
3274
3276
  );
3275
3277
  }
3276
- const yr = {
3278
+ const gr = {
3277
3279
  stores: "STORES",
3278
3280
  companies: "COMPANIES"
3279
- }, gr = {
3281
+ }, vr = {
3280
3282
  products: "products",
3281
3283
  profiles: "profiles",
3282
3284
  cart: "cart",
@@ -3287,9 +3289,9 @@ const yr = {
3287
3289
  payments: "payments",
3288
3290
  settings: "settings",
3289
3291
  discounts: "discounts"
3290
- }, vr = {
3291
- systemCollections: yr,
3292
- storeCollections: gr,
3292
+ }, _r = {
3293
+ systemCollections: gr,
3294
+ storeCollections: vr,
3293
3295
  // for client
3294
3296
  getPath: ({
3295
3297
  companyId: r,
@@ -3299,31 +3301,31 @@ const yr = {
3299
3301
  }) => `${r}/${e}/${t}${n ? `/${n}` : ""}`,
3300
3302
  // for backend
3301
3303
  getDocPath: (r) => `{companyId}/{storeId}/${r}/{id}`
3302
- }, Or = {
3303
- firestore: vr
3304
+ }, jr = {
3305
+ firestore: _r
3304
3306
  };
3305
3307
  export {
3306
3308
  pr as AddressSchema,
3307
3309
  Ke as BaseCategorySchema,
3308
3310
  tt as CartItemProductSchema,
3309
- wr as CartSchema,
3311
+ Tr as CartSchema,
3310
3312
  Pe as CategorySchema,
3311
- Tr as CompanySchema,
3312
- Ir as DiscountSchema,
3313
- Cr as FavoriteProductSchema,
3314
- Or as FirebaseAPI,
3313
+ Cr as CompanySchema,
3314
+ Ar as DiscountSchema,
3315
+ Sr as FavoriteProductSchema,
3316
+ jr as FirebaseAPI,
3315
3317
  H as LocaleSchema,
3316
- br as LocaleValueSchema,
3317
- kr as NewProductSchema,
3318
- Zr as OrderSchema,
3318
+ xr as LocaleValueSchema,
3319
+ wr as NewProductSchema,
3320
+ Ir as OrderSchema,
3319
3321
  et as ProductSchema,
3320
3322
  rt as ProfilePaymentTypeSchema,
3321
3323
  mr as ProfileSchema,
3322
- xr as TFlattenCategorySchema,
3323
- Nr as calculateCartPrice,
3324
- Sr as createEmptyProfile,
3325
- Ar as getCartCost,
3324
+ kr as TFlattenCategorySchema,
3325
+ Or as calculateCartPrice,
3326
+ Zr as createEmptyProfile,
3327
+ Nr as getCartCost,
3326
3328
  T as notEmptyTextSchema,
3327
- _r as numericTextSchema
3329
+ br as numericTextSchema
3328
3330
  };
3329
3331
  //# sourceMappingURL=core.es.js.map