@orderingstack/front-hooks 5.0.0 → 5.0.2

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/index.es.js CHANGED
@@ -1434,22 +1434,22 @@ function sp(e, r) {
1434
1434
  }
1435
1435
  return !0;
1436
1436
  }
1437
- const De = (e, r, t = 0, n = !1) => {
1437
+ const De = (e, r, t = !1, n = 0) => {
1438
1438
  var f, b;
1439
1439
  if (!e)
1440
1440
  return 0;
1441
1441
  const a = e.price ? parseFloat(e.price) : 0, i = (f = e._) != null && f.basePrice ? parseFloat((b = e._) == null ? void 0 : b.basePrice) : a;
1442
- let s = n ? i : a;
1442
+ let s = t ? i : a;
1443
1443
  if (!(r != null && r.selected) || jr(r.selected))
1444
1444
  return s;
1445
1445
  const { items: o } = e, l = ip(r);
1446
1446
  return sp(e, l) && Array.isArray(o) && o.forEach(($) => {
1447
1447
  let p = 0;
1448
1448
  if ($.kind !== "3e/product")
1449
- p = De($, l, t + 1, n);
1449
+ p = De($, l, t, n + 1);
1450
1450
  else {
1451
1451
  const { selected: y = {} } = l, { selCtx: E, id: v } = $;
1452
- E in y && v in y[E] && (p = De($, l, t + 1, n) * Number(y[E][v]), delete l.selected[E][v]);
1452
+ E in y && v in y[E] && (p = De($, l, t, n + 1) * Number(y[E][v]), delete l.selected[E][v]);
1453
1453
  }
1454
1454
  s += p;
1455
1455
  }), Math.round(100 * s) / 100;
@@ -1457,14 +1457,16 @@ const De = (e, r, t = 0, n = !1) => {
1457
1457
  product: e,
1458
1458
  state: r,
1459
1459
  selected: t,
1460
- cheapestGroupOptionsProduct: n
1460
+ cheapestGroupOptionsProduct: n,
1461
+ basePrice: a
1461
1462
  }) => {
1462
- const a = De(e, r), i = De(
1463
+ const i = De(e, r, a), s = De(
1463
1464
  e,
1464
- e.state
1465
- ), s = e.minPrice && Number(e.price) === a;
1466
- let o = t || n || Number(e.price) === 0 ? a || i : Number(e.price);
1467
- return n !== void 0 && (o -= n), s && e.minPrice && (o = Number(e.minPrice)), { displayPrice: o, showAsMinPrice: s, calculatedPriceDefaultProductState: i };
1465
+ e.state,
1466
+ a
1467
+ ), o = e.minPrice && Number(e.price) === i;
1468
+ let l = t || n || Number(e.price) === 0 ? i || s : Number(e.price);
1469
+ return n !== void 0 && (l -= n), o && e.minPrice && (l = Number(e.minPrice)), { displayPrice: l, showAsMinPrice: o, calculatedPriceDefaultProductState: s };
1468
1470
  }, Yv = op;
1469
1471
  function Bn(e) {
1470
1472
  const r = [];
@@ -2552,19 +2554,19 @@ function zv(e, r) {
2552
2554
  [e, r]
2553
2555
  );
2554
2556
  }
2555
- function Zv(e, r) {
2556
- const [t, n] = X(
2557
- Ae(e == null ? void 0 : e.DINE_IN, r)
2558
- ), [a, i] = X(
2559
- Ae(e == null ? void 0 : e.TAKE_AWAY, r)
2557
+ function Zv(e) {
2558
+ const [r, t] = X(
2559
+ Ae(e == null ? void 0 : e.DINE_IN)
2560
+ ), [n, a] = X(
2561
+ Ae(e == null ? void 0 : e.TAKE_AWAY)
2560
2562
  );
2561
- function s() {
2562
- const o = Ae(e == null ? void 0 : e.DINE_IN), l = Ae(e == null ? void 0 : e.TAKE_AWAY);
2563
- o !== t && (console.log("dine in open changed", t, "=>", o), n(o)), l !== a && (console.log("take away open changed", a, "=>", l), i(l));
2563
+ function i() {
2564
+ const s = Ae(e == null ? void 0 : e.DINE_IN), o = Ae(e == null ? void 0 : e.TAKE_AWAY);
2565
+ s !== r && (console.log("dine in open changed", r, "=>", s), t(s)), o !== n && (console.log("take away open changed", n, "=>", o), a(o));
2564
2566
  }
2565
2567
  return ie(() => {
2566
- s();
2567
- }, [e]), wr(s, 6e4), { dineInOpen: t, takeAwayOpen: a, loaded: !!e };
2568
+ i();
2569
+ }, [e]), wr(i, 6e4), { dineInOpen: r, takeAwayOpen: n, loaded: !!e };
2568
2570
  }
2569
2571
  var Er = {}, Iv = (e) => encodeURIComponent(e).replace(/[!'()*]/g, (r) => `%${r.charCodeAt(0).toString(16).toUpperCase()}`), ra = "%[a-f0-9]{2}", un = new RegExp("(" + ra + ")|([^%]+?)", "gi"), fn = new RegExp("(" + ra + ")+", "gi");
2570
2572
  function Tr(e, r) {