@instockng/storefront-ui 1.0.22 → 1.0.23

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.
Files changed (176) hide show
  1. package/dist/components/Checkout.d.ts.map +1 -1
  2. package/dist/components/ShoppingCart.d.ts.map +1 -1
  3. package/dist/contexts/CartContext.d.ts.map +1 -1
  4. package/dist/index10.mjs +53 -59
  5. package/dist/index100.mjs +3 -3
  6. package/dist/index101.mjs +1 -1
  7. package/dist/index102.mjs +1 -1
  8. package/dist/index103.mjs +1 -1
  9. package/dist/index104.mjs +2 -2
  10. package/dist/index105.mjs +2 -2
  11. package/dist/index106.mjs +3 -3
  12. package/dist/index107.mjs +1 -1
  13. package/dist/index108.mjs +3 -3
  14. package/dist/index109.mjs +2 -2
  15. package/dist/index110.mjs +2 -2
  16. package/dist/index111.mjs +1 -1
  17. package/dist/index112.mjs +3 -3
  18. package/dist/index113.mjs +1 -1
  19. package/dist/index114.mjs +1 -1
  20. package/dist/index115.mjs +3 -3
  21. package/dist/index116.mjs +2 -2
  22. package/dist/index117.mjs +4 -4
  23. package/dist/index118.mjs +1 -1
  24. package/dist/index119.mjs +3 -3
  25. package/dist/index12.mjs +456 -438
  26. package/dist/index120.mjs +4 -4
  27. package/dist/index121.mjs +1 -1
  28. package/dist/index122.mjs +1 -1
  29. package/dist/index123.mjs +1 -1
  30. package/dist/index124.mjs +1 -1
  31. package/dist/index125.mjs +1 -1
  32. package/dist/index126.mjs +1 -1
  33. package/dist/index127.mjs +1 -1
  34. package/dist/index128.mjs +2 -2
  35. package/dist/index129.mjs +3 -3
  36. package/dist/index132.mjs +1 -1
  37. package/dist/index134.mjs +2 -21
  38. package/dist/index135.mjs +2 -56
  39. package/dist/index136.mjs +2 -29
  40. package/dist/index137.mjs +2 -7
  41. package/dist/index138.mjs +16 -50
  42. package/dist/index139.mjs +32 -6
  43. package/dist/index140.mjs +37 -11
  44. package/dist/index141.mjs +18 -7
  45. package/dist/index142.mjs +18 -28
  46. package/dist/index143.mjs +2 -2
  47. package/dist/index144.mjs +20 -70
  48. package/dist/index145.mjs +42 -163
  49. package/dist/index147.mjs +30 -2
  50. package/dist/index148.mjs +18 -2
  51. package/dist/index149.mjs +2 -2
  52. package/dist/index150.mjs +2 -18
  53. package/dist/index151.mjs +2 -32
  54. package/dist/index152.mjs +2 -38
  55. package/dist/index153.mjs +67 -13
  56. package/dist/index154.mjs +2 -18
  57. package/dist/index155.mjs +53 -2
  58. package/dist/index156.mjs +2 -20
  59. package/dist/index157.mjs +29 -39
  60. package/dist/index158.mjs +152 -2
  61. package/dist/index159.mjs +2 -30
  62. package/dist/index160.mjs +2 -18
  63. package/dist/index161.mjs +19 -2
  64. package/dist/index162.mjs +2 -2
  65. package/dist/index163.mjs +2 -2
  66. package/dist/index164.mjs +26 -2
  67. package/dist/index165.mjs +2 -72
  68. package/dist/index166.mjs +2 -2
  69. package/dist/index167.mjs +20 -49
  70. package/dist/index168.mjs +23 -2
  71. package/dist/index169.mjs +2 -36
  72. package/dist/index170.mjs +2 -152
  73. package/dist/index171.mjs +2 -2
  74. package/dist/index172.mjs +23 -2
  75. package/dist/index173.mjs +2 -19
  76. package/dist/index174.mjs +23 -2
  77. package/dist/index176.mjs +2 -26
  78. package/dist/index177.mjs +2 -2
  79. package/dist/index178.mjs +23 -2
  80. package/dist/index179.mjs +2 -24
  81. package/dist/index180.mjs +15 -15
  82. package/dist/index181.mjs +2 -2
  83. package/dist/index182.mjs +2 -2
  84. package/dist/index183.mjs +2 -2
  85. package/dist/index184.mjs +2 -23
  86. package/dist/index185.mjs +2 -2
  87. package/dist/index186.mjs +2 -23
  88. package/dist/index187.mjs +2 -2
  89. package/dist/index188.mjs +2 -2
  90. package/dist/index189.mjs +127 -2
  91. package/dist/index190.mjs +2 -23
  92. package/dist/index191.mjs +74 -2
  93. package/dist/index192.mjs +71 -20
  94. package/dist/index193.mjs +21 -2
  95. package/dist/index194.mjs +56 -2
  96. package/dist/index195.mjs +29 -2
  97. package/dist/index196.mjs +7 -2
  98. package/dist/index197.mjs +52 -2
  99. package/dist/index198.mjs +6 -2
  100. package/dist/index199.mjs +12 -2
  101. package/dist/index2.mjs +10 -10
  102. package/dist/index20.mjs +2 -2
  103. package/dist/index200.mjs +7 -2
  104. package/dist/index201.mjs +28 -127
  105. package/dist/index202.mjs +2 -2
  106. package/dist/index203.mjs +69 -73
  107. package/dist/index204.mjs +164 -71
  108. package/dist/index205.mjs +2 -2
  109. package/dist/index206.mjs +2 -2
  110. package/dist/index208.mjs +2 -2
  111. package/dist/index209.mjs +2 -2
  112. package/dist/index21.mjs +2 -2
  113. package/dist/index210.mjs +2 -2
  114. package/dist/index211.mjs +108 -2
  115. package/dist/index212.mjs +2 -2
  116. package/dist/index213.mjs +2 -108
  117. package/dist/index214.mjs +2 -2
  118. package/dist/index215.mjs +2 -2
  119. package/dist/index216.mjs +243 -36
  120. package/dist/index217.mjs +2 -2
  121. package/dist/index218.mjs +32 -243
  122. package/dist/index219.mjs +65 -2
  123. package/dist/index220.mjs +16 -24
  124. package/dist/index221.mjs +2 -65
  125. package/dist/index222.mjs +31 -19
  126. package/dist/index230.mjs +2 -2
  127. package/dist/index231.mjs +2 -2
  128. package/dist/index245.mjs +3 -3
  129. package/dist/index248.mjs +2 -2
  130. package/dist/index249.mjs +2 -18
  131. package/dist/index25.mjs +5 -0
  132. package/dist/index250.mjs +13 -42
  133. package/dist/index251.mjs +47 -2
  134. package/dist/index252.mjs +2 -2
  135. package/dist/index253.mjs +2 -2
  136. package/dist/index254.mjs +2 -2
  137. package/dist/index255.mjs +2 -91
  138. package/dist/index256.mjs +91 -2
  139. package/dist/index263.mjs +1 -1
  140. package/dist/index264.mjs +1 -1
  141. package/dist/index3.mjs +82 -82
  142. package/dist/index38.mjs +1 -1
  143. package/dist/index42.mjs +1 -1
  144. package/dist/index49.mjs +59 -59
  145. package/dist/index50.mjs +50 -50
  146. package/dist/index51.mjs +48 -48
  147. package/dist/index52.mjs +56 -56
  148. package/dist/index53.mjs +39 -39
  149. package/dist/index54.mjs +55 -55
  150. package/dist/index55.mjs +15 -15
  151. package/dist/index56.mjs +10 -10
  152. package/dist/index57.mjs +23 -23
  153. package/dist/index58.mjs +64 -64
  154. package/dist/index59.mjs +73 -73
  155. package/dist/index62.mjs +149 -19
  156. package/dist/index63.mjs +19 -149
  157. package/dist/index73.mjs +1 -1
  158. package/dist/index78.mjs +5 -5
  159. package/dist/index80.mjs +3 -3
  160. package/dist/index90.mjs +1 -1
  161. package/dist/index91.mjs +3 -3
  162. package/dist/index96.mjs +1 -1
  163. package/dist/index97.mjs +1 -1
  164. package/dist/index98.mjs +6 -6
  165. package/dist/index99.mjs +4 -4
  166. package/dist/providers/StorefrontProvider.d.ts.map +1 -1
  167. package/dist/styles.css +1 -1
  168. package/package.json +12 -11
  169. package/src/components/CartItem.stories.tsx +5 -5
  170. package/src/components/Checkout.stories.tsx +16 -15
  171. package/src/components/Checkout.tsx +42 -0
  172. package/src/components/ShoppingCart.stories.tsx +17 -16
  173. package/src/components/ShoppingCart.tsx +3 -11
  174. package/src/contexts/CartContext.tsx +2 -1
  175. package/src/providers/StorefrontProvider.tsx +4 -1
  176. package/src/test-utils/MockCartProvider.tsx +31 -25
package/dist/index250.mjs CHANGED
@@ -1,50 +1,21 @@
1
1
  'use client';
2
- import { __exports as u } from "./index266.mjs";
3
- var _;
4
- function g() {
5
- return _ ? u : (_ = 1, function(i) {
6
- Object.defineProperty(i, "__esModule", {
2
+ import { __exports as r } from "./index265.mjs";
3
+ var u;
4
+ function s() {
5
+ return u ? r : (u = 1, function(n) {
6
+ Object.defineProperty(n, "__esModule", {
7
7
  value: !0
8
- });
9
- function a(e, n) {
10
- for (var t in n) Object.defineProperty(e, t, {
11
- enumerable: !0,
12
- get: n[t]
13
- });
14
- }
15
- a(i, {
16
- DEFAULT_SEGMENT_KEY: function() {
17
- return E;
18
- },
19
- PAGE_SEGMENT_KEY: function() {
20
- return r;
21
- },
22
- addSearchParamsIfPageSegment: function() {
23
- return s;
24
- },
25
- isGroupSegment: function() {
26
- return c;
27
- },
28
- isParallelRouteSegment: function() {
29
- return f;
8
+ }), Object.defineProperty(n, "ensureLeadingSlash", {
9
+ enumerable: !0,
10
+ get: function() {
11
+ return t;
30
12
  }
31
13
  });
32
- function c(e) {
33
- return e[0] === "(" && e.endsWith(")");
34
- }
35
- function f(e) {
36
- return e.startsWith("@") && e !== "@children";
37
- }
38
- function s(e, n) {
39
- if (e.includes(r)) {
40
- const o = JSON.stringify(n);
41
- return o !== "{}" ? r + "?" + o : r;
42
- }
43
- return e;
14
+ function t(e) {
15
+ return e.startsWith("/") ? e : "/" + e;
44
16
  }
45
- const r = "__PAGE__", E = "__DEFAULT__";
46
- }(u), u);
17
+ }(r), r);
47
18
  }
48
19
  export {
49
- g as __require
20
+ s as __require
50
21
  };
package/dist/index251.mjs CHANGED
@@ -1,5 +1,50 @@
1
1
  'use client';
2
- var e = { exports: {} };
2
+ import { __exports as u } from "./index266.mjs";
3
+ var _;
4
+ function g() {
5
+ return _ ? u : (_ = 1, function(i) {
6
+ Object.defineProperty(i, "__esModule", {
7
+ value: !0
8
+ });
9
+ function a(e, n) {
10
+ for (var t in n) Object.defineProperty(e, t, {
11
+ enumerable: !0,
12
+ get: n[t]
13
+ });
14
+ }
15
+ a(i, {
16
+ DEFAULT_SEGMENT_KEY: function() {
17
+ return E;
18
+ },
19
+ PAGE_SEGMENT_KEY: function() {
20
+ return r;
21
+ },
22
+ addSearchParamsIfPageSegment: function() {
23
+ return s;
24
+ },
25
+ isGroupSegment: function() {
26
+ return c;
27
+ },
28
+ isParallelRouteSegment: function() {
29
+ return f;
30
+ }
31
+ });
32
+ function c(e) {
33
+ return e[0] === "(" && e.endsWith(")");
34
+ }
35
+ function f(e) {
36
+ return e.startsWith("@") && e !== "@children";
37
+ }
38
+ function s(e, n) {
39
+ if (e.includes(r)) {
40
+ const o = JSON.stringify(n);
41
+ return o !== "{}" ? r + "?" + o : r;
42
+ }
43
+ return e;
44
+ }
45
+ const r = "__PAGE__", E = "__DEFAULT__";
46
+ }(u), u);
47
+ }
3
48
  export {
4
- e as __module
49
+ g as __require
5
50
  };
package/dist/index252.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var r = {};
2
+ var e = { exports: {} };
3
3
  export {
4
- r as __exports
4
+ e as __module
5
5
  };
package/dist/index253.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var e = { exports: {} };
2
+ var r = {};
3
3
  export {
4
- e as __module
4
+ r as __exports
5
5
  };
package/dist/index254.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var e = {};
2
+ var e = { exports: {} };
3
3
  export {
4
- e as __exports
4
+ e as __module
5
5
  };
package/dist/index255.mjs CHANGED
@@ -1,94 +1,5 @@
1
1
  'use client';
2
- import { __module as c } from "./index267.mjs";
3
- var l;
4
- function T() {
5
- return l ? c.exports : (l = 1, (() => {
6
- typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = __dirname + "/");
7
- var m = {};
8
- (() => {
9
- var v = m;
10
- /*!
11
- * cookie
12
- * Copyright(c) 2012-2014 Roman Shtylman
13
- * Copyright(c) 2015 Douglas Christopher Wilson
14
- * MIT Licensed
15
- */
16
- v.parse = S, v.serialize = x;
17
- var w = decodeURIComponent, h = encodeURIComponent, y = /; */, f = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
18
- function S(i, n) {
19
- if (typeof i != "string")
20
- throw new TypeError("argument str must be a string");
21
- for (var a = {}, e = n || {}, o = i.split(y), s = e.decode || w, r = 0; r < o.length; r++) {
22
- var t = o[r], p = t.indexOf("=");
23
- if (!(p < 0)) {
24
- var d = t.substr(0, p).trim(), u = t.substr(++p, t.length).trim();
25
- u[0] == '"' && (u = u.slice(1, -1)), a[d] == null && (a[d] = _(u, s));
26
- }
27
- }
28
- return a;
29
- }
30
- function x(i, n, a) {
31
- var e = a || {}, o = e.encode || h;
32
- if (typeof o != "function")
33
- throw new TypeError("option encode is invalid");
34
- if (!f.test(i))
35
- throw new TypeError("argument name is invalid");
36
- var s = o(n);
37
- if (s && !f.test(s))
38
- throw new TypeError("argument val is invalid");
39
- var r = i + "=" + s;
40
- if (e.maxAge != null) {
41
- var t = e.maxAge - 0;
42
- if (isNaN(t) || !isFinite(t))
43
- throw new TypeError("option maxAge is invalid");
44
- r += "; Max-Age=" + Math.floor(t);
45
- }
46
- if (e.domain) {
47
- if (!f.test(e.domain))
48
- throw new TypeError("option domain is invalid");
49
- r += "; Domain=" + e.domain;
50
- }
51
- if (e.path) {
52
- if (!f.test(e.path))
53
- throw new TypeError("option path is invalid");
54
- r += "; Path=" + e.path;
55
- }
56
- if (e.expires) {
57
- if (typeof e.expires.toUTCString != "function")
58
- throw new TypeError("option expires is invalid");
59
- r += "; Expires=" + e.expires.toUTCString();
60
- }
61
- if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.sameSite) {
62
- var p = typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite;
63
- switch (p) {
64
- case !0:
65
- r += "; SameSite=Strict";
66
- break;
67
- case "lax":
68
- r += "; SameSite=Lax";
69
- break;
70
- case "strict":
71
- r += "; SameSite=Strict";
72
- break;
73
- case "none":
74
- r += "; SameSite=None";
75
- break;
76
- default:
77
- throw new TypeError("option sameSite is invalid");
78
- }
79
- }
80
- return r;
81
- }
82
- function _(i, n) {
83
- try {
84
- return n(i);
85
- } catch {
86
- return i;
87
- }
88
- }
89
- })(), c.exports = m;
90
- })(), c.exports);
91
- }
2
+ var e = {};
92
3
  export {
93
- T as __require
4
+ e as __exports
94
5
  };
package/dist/index256.mjs CHANGED
@@ -1,5 +1,94 @@
1
1
  'use client';
2
- var e = {};
2
+ import { __module as c } from "./index267.mjs";
3
+ var l;
4
+ function T() {
5
+ return l ? c.exports : (l = 1, (() => {
6
+ typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = __dirname + "/");
7
+ var m = {};
8
+ (() => {
9
+ var v = m;
10
+ /*!
11
+ * cookie
12
+ * Copyright(c) 2012-2014 Roman Shtylman
13
+ * Copyright(c) 2015 Douglas Christopher Wilson
14
+ * MIT Licensed
15
+ */
16
+ v.parse = S, v.serialize = x;
17
+ var w = decodeURIComponent, h = encodeURIComponent, y = /; */, f = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
18
+ function S(i, n) {
19
+ if (typeof i != "string")
20
+ throw new TypeError("argument str must be a string");
21
+ for (var a = {}, e = n || {}, o = i.split(y), s = e.decode || w, r = 0; r < o.length; r++) {
22
+ var t = o[r], p = t.indexOf("=");
23
+ if (!(p < 0)) {
24
+ var d = t.substr(0, p).trim(), u = t.substr(++p, t.length).trim();
25
+ u[0] == '"' && (u = u.slice(1, -1)), a[d] == null && (a[d] = _(u, s));
26
+ }
27
+ }
28
+ return a;
29
+ }
30
+ function x(i, n, a) {
31
+ var e = a || {}, o = e.encode || h;
32
+ if (typeof o != "function")
33
+ throw new TypeError("option encode is invalid");
34
+ if (!f.test(i))
35
+ throw new TypeError("argument name is invalid");
36
+ var s = o(n);
37
+ if (s && !f.test(s))
38
+ throw new TypeError("argument val is invalid");
39
+ var r = i + "=" + s;
40
+ if (e.maxAge != null) {
41
+ var t = e.maxAge - 0;
42
+ if (isNaN(t) || !isFinite(t))
43
+ throw new TypeError("option maxAge is invalid");
44
+ r += "; Max-Age=" + Math.floor(t);
45
+ }
46
+ if (e.domain) {
47
+ if (!f.test(e.domain))
48
+ throw new TypeError("option domain is invalid");
49
+ r += "; Domain=" + e.domain;
50
+ }
51
+ if (e.path) {
52
+ if (!f.test(e.path))
53
+ throw new TypeError("option path is invalid");
54
+ r += "; Path=" + e.path;
55
+ }
56
+ if (e.expires) {
57
+ if (typeof e.expires.toUTCString != "function")
58
+ throw new TypeError("option expires is invalid");
59
+ r += "; Expires=" + e.expires.toUTCString();
60
+ }
61
+ if (e.httpOnly && (r += "; HttpOnly"), e.secure && (r += "; Secure"), e.sameSite) {
62
+ var p = typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite;
63
+ switch (p) {
64
+ case !0:
65
+ r += "; SameSite=Strict";
66
+ break;
67
+ case "lax":
68
+ r += "; SameSite=Lax";
69
+ break;
70
+ case "strict":
71
+ r += "; SameSite=Strict";
72
+ break;
73
+ case "none":
74
+ r += "; SameSite=None";
75
+ break;
76
+ default:
77
+ throw new TypeError("option sameSite is invalid");
78
+ }
79
+ }
80
+ return r;
81
+ }
82
+ function _(i, n) {
83
+ try {
84
+ return n(i);
85
+ } catch {
86
+ return i;
87
+ }
88
+ }
89
+ })(), c.exports = m;
90
+ })(), c.exports);
91
+ }
3
92
  export {
4
- e as __exports
93
+ T as __require
5
94
  };
package/dist/index263.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import o from "./index141.mjs";
2
+ import o from "./index200.mjs";
3
3
  const n = o.hasStandardBrowserEnv ? /* @__PURE__ */ ((r, e) => (t) => (t = new URL(t, o.origin), r.protocol === t.protocol && r.host === t.host && (e || r.port === t.port)))(
4
4
  new URL(o.origin),
5
5
  o.navigator && /(msie|trident)/i.test(o.navigator.userAgent)
package/dist/index264.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import r from "./index76.mjs";
3
- import c from "./index141.mjs";
3
+ import c from "./index200.mjs";
4
4
  const p = c.hasStandardBrowserEnv ? (
5
5
  // Standard browser envs support document.cookie
6
6
  {
package/dist/index3.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use client';
2
- import { jsxs as nt, jsx as ct } from "react/jsx-runtime";
3
- import { createContext as st, useState as k, useRef as _, useCallback as c, useEffect as d, useContext as at } from "react";
2
+ import { jsxs as ct, jsx as st } from "react/jsx-runtime";
3
+ import { createContext as at, useState as _, useRef as g, useCallback as c, useEffect as d, useContext as ut } from "react";
4
4
  import "./index20.mjs";
5
- import { useGetCart as ut, useCreateCart as it, useAddCartItem as ft, useUpdateCartItem as mt, useRemoveCartItem as dt, useApplyDiscount as lt, useRemoveDiscount as pt, useUpdateCart as Ct, useCheckoutCart as It } from "./index32.mjs";
5
+ import { useGetCart as it, useCreateCart as ft, useAddCartItem as mt, useUpdateCartItem as dt, useRemoveCartItem as lt, useApplyDiscount as pt, useRemoveDiscount as Ct, useUpdateCart as wt, useCheckoutCart as It } from "./index32.mjs";
6
6
  import "@tanstack/react-query";
7
- import { ShoppingCart as wt } from "./index10.mjs";
8
- import { useMetaPixel as ht } from "./index4.mjs";
9
- const l = "oms_cart_id", F = st(null);
10
- function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L }) {
11
- const [t, f] = k(C || null), [g, A] = k(!1), [U, j] = k(!1), S = _(!1), b = _(!1), w = _(!1), { trackAddToCart: h, trackInitiateCheckout: M, trackPurchase: G } = ht(), E = c(() => {
7
+ import { ShoppingCart as ht } from "./index10.mjs";
8
+ import { useMetaPixel as vt } from "./index4.mjs";
9
+ const l = "oms_cart_id", U = at(null);
10
+ function bt({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L }) {
11
+ const [t, f] = _(C || null), [A, S] = _(!1), [j, G] = _(!1), b = g(!1), M = g(!1), h = g(!1), { trackAddToCart: v, trackInitiateCheckout: E, trackPurchase: O } = vt(), N = c(() => {
12
12
  if (typeof document > "u") return { fbc: void 0, fbp: void 0 };
13
13
  const e = (r) => {
14
14
  var o;
@@ -21,10 +21,10 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
21
21
  };
22
22
  }, []);
23
23
  d(() => {
24
- j(!0);
24
+ G(!0);
25
25
  }, []), d(() => {
26
- if (C || S.current) return;
27
- S.current = !0;
26
+ if (C || b.current) return;
27
+ b.current = !0;
28
28
  const r = new URLSearchParams(window.location.search).get("cartId");
29
29
  if (r) {
30
30
  f(r);
@@ -33,11 +33,11 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
33
33
  const s = localStorage.getItem(l);
34
34
  s && f(s);
35
35
  }, [C]);
36
- const { data: m, isLoading: O, error: I, refetch: a } = ut(t || "", {
36
+ const { data: m, isLoading: q, error: w, refetch: a } = it(t || "", {
37
37
  enabled: !!t,
38
38
  retry: !1
39
39
  // Don't retry on failure - cart might be invalid/expired
40
- }), v = it({
40
+ }), y = ft({
41
41
  onSuccess: (e) => {
42
42
  if ("error" in e) {
43
43
  console.error("Failed to create cart:", e.error);
@@ -51,20 +51,18 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
51
51
  retry: 10
52
52
  });
53
53
  d(() => {
54
- if (b.current) return;
55
- b.current = !0;
54
+ if (M.current) return;
55
+ M.current = !0;
56
56
  const e = setTimeout(() => {
57
- !(typeof window < "u" ? localStorage.getItem(l) : null) && !C && v.mutate(i);
57
+ !(typeof window < "u" ? localStorage.getItem(l) : null) && !C && y.mutate(i);
58
58
  }, 150);
59
59
  return () => clearTimeout(e);
60
60
  }, []), d(() => {
61
- I && t && !w.current && (w.current = !0, console.warn("Cart fetch failed, creating new cart:", I), f(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
62
- v.mutate(i), w.current = !1;
61
+ w && t && !h.current && (h.current = !0, console.warn("Cart fetch failed, creating new cart:", w), f(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
62
+ y.mutate(i), h.current = !1;
63
63
  }, 100));
64
- }, [I, t, i]);
65
- const q = ft(t || "", {
66
- onSuccess: () => a()
67
- }), H = mt(t || "", {
64
+ }, [w, t, i]);
65
+ const H = mt(t || "", {
68
66
  onSuccess: () => a()
69
67
  }), K = dt(t || "", {
70
68
  onSuccess: () => a()
@@ -73,9 +71,11 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
73
71
  }), z = pt(t || "", {
74
72
  onSuccess: () => a()
75
73
  }), B = Ct(t || "", {
74
+ onSuccess: () => a()
75
+ }), J = wt(t || "", {
76
76
  onSuccess: () => a(),
77
77
  retry: 3
78
- }), J = It(t || "", {
78
+ }), Q = It(t || "", {
79
79
  onSuccess: (e) => {
80
80
  var n;
81
81
  if ("error" in e) return;
@@ -87,7 +87,7 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
87
87
  item_price: Number(o.priceAtPurchase)
88
88
  };
89
89
  })) || [], s = `order_${e.id}`;
90
- G(
90
+ O(
91
91
  Number(e.totalPrice),
92
92
  "NGN",
93
93
  e.id,
@@ -99,103 +99,103 @@ function St({ children: p, brandSlug: i, initialCartId: C, shoppingCartProps: L
99
99
  d(() => {
100
100
  t && typeof window < "u" && localStorage.setItem(l, t);
101
101
  }, [t]);
102
- const Q = c(
102
+ const V = c(
103
103
  async (e, r, s, n, o) => {
104
- var T;
104
+ var $;
105
105
  if (!t) throw new Error("No cart ID");
106
- const { fbc: u, fbp: y } = E(), x = await q.mutateAsync({ sku: n, quantity: o, fbc: u, fbp: y });
107
- if ("error" in x) return;
108
- const R = (T = x.items) == null ? void 0 : T.findLast(
109
- (D) => {
110
- var $;
111
- return (($ = D.variant) == null ? void 0 : $.sku) === n;
106
+ const { fbc: u, fbp: D } = N(), R = await H.mutateAsync({ sku: n, quantity: o, fbc: u, fbp: D });
107
+ if ("error" in R) return;
108
+ const I = ($ = R.items) == null ? void 0 : $.filter(
109
+ (k) => {
110
+ var F;
111
+ return ((F = k.variant) == null ? void 0 : F.sku) === n;
112
112
  }
113
- );
114
- if (R) {
115
- const D = `cart_${t}_item_${R.id}`;
116
- h(e, r, s, o, D);
113
+ ), T = I == null ? void 0 : I[I.length - 1];
114
+ if (T) {
115
+ const k = `cart_${t}_item_${T.id}`;
116
+ v(e, r, s, o, k);
117
117
  } else
118
- h(e, r, s, o);
118
+ v(e, r, s, o);
119
119
  },
120
120
  // eslint-disable-next-line react-hooks/exhaustive-deps
121
- [t, h, E]
122
- ), V = c(
121
+ [t, v, N]
122
+ ), W = c(
123
123
  async (e, r) => {
124
124
  if (!t) throw new Error("No cart ID");
125
- await H.mutateAsync({ itemId: e, quantity: r });
125
+ await K.mutateAsync({ itemId: e, quantity: r });
126
126
  },
127
127
  // eslint-disable-next-line react-hooks/exhaustive-deps
128
128
  [t]
129
- ), W = c(
129
+ ), X = c(
130
130
  async (e) => {
131
131
  if (!t) throw new Error("No cart ID");
132
- await K.mutateAsync(e);
132
+ await Y.mutateAsync(e);
133
133
  },
134
134
  // eslint-disable-next-line react-hooks/exhaustive-deps
135
135
  [t]
136
- ), X = c(
136
+ ), Z = c(
137
137
  async (e) => {
138
138
  if (!t) throw new Error("No cart ID");
139
- await Y.mutateAsync({ code: e });
139
+ await z.mutateAsync({ code: e });
140
140
  },
141
141
  // eslint-disable-next-line react-hooks/exhaustive-deps
142
142
  [t]
143
- ), Z = c(async () => {
143
+ ), tt = c(async () => {
144
144
  if (!t) throw new Error("No cart ID");
145
- await z.mutateAsync();
146
- }, [t]), N = c(() => {
145
+ await B.mutateAsync();
146
+ }, [t]), P = c(() => {
147
147
  f(null), typeof window < "u" && localStorage.removeItem(l);
148
- }, []), tt = c(() => {
149
- N(), v.mutate(i);
150
- }, [i]), et = c(() => {
151
- A(!0);
152
- }, []), P = c(() => {
153
- A(!1);
154
- }, []), rt = c(() => {
148
+ }, []), et = c(() => {
149
+ P(), y.mutate(i);
150
+ }, [i]), rt = c(() => {
151
+ S(!0);
152
+ }, []), x = c(() => {
153
+ S(!1);
154
+ }, []), ot = c(() => {
155
155
  var n, o;
156
156
  if (!m || !t) return;
157
- const e = Number(((n = m.pricing) == null ? void 0 : n.total) || 0), r = ((o = m.items) == null ? void 0 : o.reduce((u, y) => u + y.quantity, 0)) || 0, s = `cart_${t}_checkout`;
158
- M(e, r, s);
159
- }, [m, t, M]), ot = {
157
+ const e = Number(((n = m.pricing) == null ? void 0 : n.total) || 0), r = ((o = m.items) == null ? void 0 : o.reduce((u, D) => u + D.quantity, 0)) || 0, s = `cart_${t}_checkout`;
158
+ E(e, r, s);
159
+ }, [m, t, E]), nt = {
160
160
  cart: m || null,
161
161
  cartId: t,
162
- isLoading: O,
163
- error: I,
164
- updateCartMutation: B,
165
- checkoutMutation: J,
166
- addItem: Q,
167
- updateItem: V,
168
- removeItem: W,
169
- applyDiscount: X,
170
- removeDiscount: Z,
171
- trackCheckoutInitiated: rt,
172
- clearCart: N,
173
- clearAndCreateNewCart: tt,
162
+ isLoading: q,
163
+ error: w,
164
+ updateCartMutation: J,
165
+ checkoutMutation: Q,
166
+ addItem: V,
167
+ updateItem: W,
168
+ removeItem: X,
169
+ applyDiscount: Z,
170
+ removeDiscount: tt,
171
+ trackCheckoutInitiated: ot,
172
+ clearCart: P,
173
+ clearAndCreateNewCart: et,
174
174
  refetch: a,
175
- isOpen: g,
176
- open: et,
177
- close: P
175
+ isOpen: A,
176
+ open: rt,
177
+ close: x
178
178
  };
179
- return /* @__PURE__ */ nt(F.Provider, { value: ot, children: [
179
+ return /* @__PURE__ */ ct(U.Provider, { value: nt, children: [
180
180
  p,
181
- U && /* @__PURE__ */ ct(
182
- wt,
181
+ j && /* @__PURE__ */ st(
182
+ ht,
183
183
  {
184
- isOpen: g,
185
- onClose: P,
184
+ isOpen: A,
185
+ onClose: x,
186
186
  ...L
187
187
  }
188
188
  )
189
189
  ] });
190
190
  }
191
- function bt() {
192
- const p = at(F);
191
+ function Mt() {
192
+ const p = ut(U);
193
193
  if (!p)
194
194
  throw new Error("useCart must be used within CartProvider");
195
195
  return p;
196
196
  }
197
197
  export {
198
- F as CartContext,
199
- St as CartProvider,
200
- bt as useCart
198
+ U as CartContext,
199
+ bt as CartProvider,
200
+ Mt as useCart
201
201
  };
package/dist/index38.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { getDefaultExportFromCjs as n } from "./index60.mjs";
3
- import { __require as i } from "./index63.mjs";
3
+ import { __require as i } from "./index62.mjs";
4
4
  function s(t, a) {
5
5
  for (var o = 0; o < a.length; o++) {
6
6
  const e = a[o];
package/dist/index42.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as l from "react";
3
- import { composeRefs as m } from "./index62.mjs";
3
+ import { composeRefs as m } from "./index63.mjs";
4
4
  import { jsx as u } from "react/jsx-runtime";
5
5
  // @__NO_SIDE_EFFECTS__
6
6
  function y(e) {