@storepecker/storefront-core 1.1.1 → 2.0.0

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 (72) hide show
  1. package/dist/api/index.cjs +76 -75
  2. package/dist/api/index.d.cts +4 -3
  3. package/dist/api/index.d.ts +4 -3
  4. package/dist/api/index.js +9 -8
  5. package/dist/{booking-B21s0inO.d.cts → booking-B39Ilxhg.d.ts} +1 -1
  6. package/dist/{booking-CegE1cje.d.ts → booking-Dk-BoHUB.d.cts} +1 -1
  7. package/dist/cart-BY8D8w-s.d.cts +90 -0
  8. package/dist/cart-GuhgeBBt.d.ts +90 -0
  9. package/dist/checkout/index.cjs +38 -37
  10. package/dist/checkout/index.d.cts +2 -1
  11. package/dist/checkout/index.d.ts +2 -1
  12. package/dist/checkout/index.js +6 -5
  13. package/dist/{chunk-34KV265H.cjs → chunk-26A3EBZI.cjs} +20 -20
  14. package/dist/chunk-2AHH3XBW.cjs +47 -0
  15. package/dist/{chunk-K5B62JZO.cjs → chunk-47XTPPII.cjs} +4 -4
  16. package/dist/chunk-4C4NTH6O.js +41 -0
  17. package/dist/{chunk-UM24VDYB.js → chunk-7R2V4C7Q.js} +2 -2
  18. package/dist/{chunk-CSISWBZZ.js → chunk-B7FOXIZN.js} +1 -1
  19. package/dist/chunk-BBRB475I.cjs +43 -0
  20. package/dist/chunk-BBRXE57K.cjs +50 -0
  21. package/dist/{chunk-QCQCFYYR.js → chunk-BHOXJGIE.js} +1 -1
  22. package/dist/chunk-BQ256JKN.js +39 -0
  23. package/dist/{chunk-7UH6REGV.js → chunk-C7ZJZEEN.js} +1 -1
  24. package/dist/{chunk-A6IO3HIN.cjs → chunk-FMHR5ABF.cjs} +28 -28
  25. package/dist/{chunk-JHGXIIBZ.cjs → chunk-G3R7ZVAG.cjs} +7 -7
  26. package/dist/{chunk-4MJMNIAB.js → chunk-GHABOHLA.js} +1 -1
  27. package/dist/chunk-GTV42PDK.cjs +46 -0
  28. package/dist/chunk-HEFA67WK.js +42 -0
  29. package/dist/chunk-HSF2D56O.js +40 -0
  30. package/dist/{chunk-GB3HW6DM.js → chunk-JWKDXFS4.js} +1 -1
  31. package/dist/{chunk-KWKHHRRJ.cjs → chunk-KKQKHG26.cjs} +3 -3
  32. package/dist/{chunk-QM73PI5L.cjs → chunk-N3ZCCKXV.cjs} +10 -10
  33. package/dist/{chunk-GQTO5ZE2.cjs → chunk-NE3ZHELZ.cjs} +0 -46
  34. package/dist/chunk-PWYWNRVO.cjs +150 -0
  35. package/dist/{chunk-E7WPE3PV.js → chunk-QAC72HKO.js} +1 -1
  36. package/dist/{chunk-CFF632IQ.cjs → chunk-SMHJRNCR.cjs} +4 -4
  37. package/dist/chunk-UOFTDL4D.js +146 -0
  38. package/dist/chunk-WEMNXIRS.js +47 -0
  39. package/dist/{chunk-LC5ZAUKL.cjs → chunk-XLQAALMU.cjs} +10 -10
  40. package/dist/{chunk-Z7LHRD3V.js → chunk-Y6NFUWTH.js} +3 -3
  41. package/dist/{chunk-LBGIUNM6.js → chunk-YY77CUWX.js} +1 -1
  42. package/dist/{chunk-UXLUE3HW.cjs → chunk-ZO2HREQL.cjs} +2 -2
  43. package/dist/components/index.cjs +126 -7
  44. package/dist/components/index.d.cts +35 -8
  45. package/dist/components/index.d.ts +35 -8
  46. package/dist/components/index.js +122 -7
  47. package/dist/hooks/index.cjs +368 -27
  48. package/dist/hooks/index.d.cts +83 -3
  49. package/dist/hooks/index.d.ts +83 -3
  50. package/dist/hooks/index.js +352 -14
  51. package/dist/middleware/index.cjs +47 -0
  52. package/dist/middleware/index.d.cts +8 -0
  53. package/dist/middleware/index.d.ts +8 -0
  54. package/dist/middleware/index.js +44 -0
  55. package/dist/models/index.d.cts +4 -3
  56. package/dist/models/index.d.ts +4 -3
  57. package/dist/{cart-VaCKkJ1C.d.cts → product-Dfi0ke-4.d.cts} +1 -88
  58. package/dist/{cart-VaCKkJ1C.d.ts → product-Dfi0ke-4.d.ts} +1 -88
  59. package/dist/store/index.cjs +17 -85
  60. package/dist/store/index.d.cts +22 -2
  61. package/dist/store/index.d.ts +22 -2
  62. package/dist/store/index.js +7 -82
  63. package/dist/utils/index.cjs +80 -65
  64. package/dist/utils/index.d.cts +54 -3
  65. package/dist/utils/index.d.ts +54 -3
  66. package/dist/utils/index.js +20 -43
  67. package/dist/{wishlist-FG8tgn76.d.ts → wishlist-DHOvXmJj.d.cts} +1 -1
  68. package/dist/{wishlist-CkAhLpbI.d.cts → wishlist-LfdFxddw.d.ts} +1 -1
  69. package/package.json +24 -5
  70. package/dist/chunk-7DQIKSGY.js +0 -40
  71. package/dist/chunk-FLBJKM6G.js +0 -83
  72. package/dist/chunk-S3WIGYDS.cjs +0 -42
@@ -0,0 +1,146 @@
1
+ import { updateCart, removeFromCart, addToCart, getCart } from './chunk-Y6NFUWTH.js';
2
+ import { cart_default } from './chunk-QAC72HKO.js';
3
+ import { auth_default } from './chunk-WEMNXIRS.js';
4
+ import { USER_CRED_TOKEN, USER_CREDENTIALS } from './chunk-BQ256JKN.js';
5
+ import { create } from 'zustand';
6
+ import { getCookie } from 'typescript-cookie';
7
+
8
+ var initialState = {
9
+ cart: null,
10
+ status: "idle" /* IDLE */
11
+ };
12
+ var useCartStore = create((set) => ({
13
+ ...initialState,
14
+ setCart: (cart) => set({ cart, status: "idle" /* IDLE */ }),
15
+ resetCart: () => set(initialState),
16
+ resetCartCount: () => set((state) => {
17
+ if (!state.cart) return state;
18
+ return { cart: { ...state.cart, total_quantity: 0 } };
19
+ }),
20
+ syncCart: async (addressId) => {
21
+ set({ status: "loading" /* LOADING */ });
22
+ try {
23
+ const response = await getCart("/customer/cart/", addressId);
24
+ if (response) {
25
+ set({ cart: response, status: "idle" /* IDLE */ });
26
+ }
27
+ } catch {
28
+ set({ status: "idle" /* IDLE */ });
29
+ }
30
+ },
31
+ fetchCart: async (addressId) => {
32
+ set({ status: "loading" /* LOADING */ });
33
+ try {
34
+ const response = await getCart("/customer/cart/", addressId);
35
+ if (response) {
36
+ set({ cart: response, status: "idle" /* IDLE */ });
37
+ }
38
+ } catch {
39
+ set({ status: "idle" /* IDLE */ });
40
+ }
41
+ },
42
+ addToCart: async (items, customizationInputs, addressId) => {
43
+ set({ status: "loading" /* LOADING */ });
44
+ try {
45
+ await addToCart(items, customizationInputs);
46
+ await useCartStore.getState().syncCart(addressId);
47
+ } catch {
48
+ } finally {
49
+ set({ status: "idle" /* IDLE */ });
50
+ }
51
+ },
52
+ removeFromCart: async (items, addressId) => {
53
+ set({ status: "loading" /* LOADING */ });
54
+ try {
55
+ await removeFromCart(items);
56
+ await useCartStore.getState().syncCart(addressId);
57
+ } catch {
58
+ } finally {
59
+ set({ status: "idle" /* IDLE */ });
60
+ }
61
+ },
62
+ updateCart: async (items, addressId) => {
63
+ set({ status: "loading" /* LOADING */ });
64
+ try {
65
+ await updateCart(items);
66
+ await useCartStore.getState().syncCart(addressId);
67
+ } catch {
68
+ } finally {
69
+ set({ status: "idle" /* IDLE */ });
70
+ }
71
+ }
72
+ }));
73
+ var getInitialState = () => ({
74
+ user: null,
75
+ status: "idle" /* IDLE */,
76
+ isAuthenticated: typeof window !== "undefined" ? !!getCookie(USER_CRED_TOKEN) : false
77
+ });
78
+ var useAuthStore = create((set, get) => ({
79
+ ...getInitialState(),
80
+ fetchUser: () => set({ status: "loading" /* LOADING */ }),
81
+ fetchUserSuccess: (user) => set({ user, status: "success" /* SUCCESS */, isAuthenticated: true }),
82
+ fetchUserFailure: (error) => set({ status: "failure" /* FAILURE */, isAuthenticated: false, error }),
83
+ setAuthenticated: () => set({ isAuthenticated: true }),
84
+ resetUser: () => set(getInitialState()),
85
+ logoutUser: () => {
86
+ try {
87
+ auth_default.removeTokens();
88
+ set(getInitialState());
89
+ } catch {
90
+ set({ status: "failure" /* FAILURE */, isAuthenticated: false, error: "Something went wrong" });
91
+ }
92
+ },
93
+ loadCurrentUser: (user, referer, redirect = true, preventRefreshAfterLogin) => {
94
+ set({ status: "loading" /* LOADING */ });
95
+ setTimeout(async () => {
96
+ try {
97
+ set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
98
+ const localCartItems = cart_default.get();
99
+ if (localCartItems) {
100
+ await useCartStore.getState().addToCart(
101
+ Object.entries(localCartItems.products_quantity).map(
102
+ ([key, value]) => ({
103
+ variant_id: parseInt(key),
104
+ quantity: value
105
+ })
106
+ )
107
+ );
108
+ cart_default.clear();
109
+ await useCartStore.getState().fetchCart();
110
+ setTimeout(() => {
111
+ if (!preventRefreshAfterLogin) {
112
+ if (redirect) {
113
+ window.location.href = referer;
114
+ } else {
115
+ window.location.reload();
116
+ }
117
+ }
118
+ }, 500);
119
+ } else {
120
+ if (!preventRefreshAfterLogin) {
121
+ if (redirect) {
122
+ window.location.href = referer;
123
+ } else {
124
+ window.location.reload();
125
+ }
126
+ }
127
+ }
128
+ } catch {
129
+ localStorage.removeItem("userExists");
130
+ set({
131
+ status: "failure" /* FAILURE */,
132
+ isAuthenticated: false,
133
+ error: "Something went wrong while fetching user"
134
+ });
135
+ }
136
+ }, 1e3);
137
+ }
138
+ }));
139
+ var loginUser = async (user) => {
140
+ const { access, refresh, ...userData } = user;
141
+ localStorage.setItem(USER_CREDENTIALS, JSON.stringify(userData));
142
+ auth_default.setAccessToken(access);
143
+ auth_default.setRefreshToken(refresh);
144
+ };
145
+
146
+ export { loginUser, useAuthStore, useCartStore };
@@ -0,0 +1,47 @@
1
+ import { USER_CRED_TOKEN, USER_CRED_REFRESH_TOKEN, USER_CREDENTIALS } from './chunk-BQ256JKN.js';
2
+ import { removeCookie, getCookie, setCookie } from 'typescript-cookie';
3
+
4
+ var _onTokenChange = null;
5
+ function setAuthTokenChangeCallback(callback) {
6
+ _onTokenChange = callback;
7
+ }
8
+ var Auth = {
9
+ isAuthenticated: false,
10
+ getUserDetails() {
11
+ return typeof window === "undefined" ? false : getCookie(USER_CRED_TOKEN);
12
+ },
13
+ setUserDetails(data) {
14
+ setCookie(USER_CREDENTIALS, JSON.stringify(data), {
15
+ expires: 60,
16
+ path: "/"
17
+ });
18
+ },
19
+ setAccessToken(token) {
20
+ setCookie(USER_CRED_TOKEN, token, {
21
+ expires: 60,
22
+ path: "/"
23
+ });
24
+ _onTokenChange?.(token);
25
+ },
26
+ getAccessToken() {
27
+ return getCookie(USER_CRED_TOKEN);
28
+ },
29
+ setRefreshToken(token) {
30
+ setCookie(USER_CRED_REFRESH_TOKEN, token, {
31
+ expires: 60,
32
+ path: "/"
33
+ });
34
+ },
35
+ getRefreshToken() {
36
+ return getCookie(USER_CRED_REFRESH_TOKEN);
37
+ },
38
+ removeTokens() {
39
+ removeCookie(USER_CRED_TOKEN);
40
+ removeCookie(USER_CRED_REFRESH_TOKEN);
41
+ removeCookie(USER_CREDENTIALS);
42
+ _onTokenChange?.(void 0);
43
+ }
44
+ };
45
+ var auth_default = Auth;
46
+
47
+ export { auth_default, setAuthTokenChangeCallback };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkA6IO3HIN_cjs = require('./chunk-A6IO3HIN.cjs');
3
+ var chunkFMHR5ABF_cjs = require('./chunk-FMHR5ABF.cjs');
4
4
  var chunkK44JZ5NL_cjs = require('./chunk-K44JZ5NL.cjs');
5
5
  var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
6
6
  var axios = require('axios');
@@ -65,7 +65,7 @@ function openRazorpayCheckout(order, callbacks) {
65
65
  async function handleRazorpaySuccess(data, order, callbacks) {
66
66
  try {
67
67
  callbacks.onPaymentStart?.();
68
- await chunkA6IO3HIN_cjs.razorpayOrderSuccess(data);
68
+ await chunkFMHR5ABF_cjs.razorpayOrderSuccess(data);
69
69
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
70
70
  chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
71
71
  callbacks.onCartReset();
@@ -78,7 +78,7 @@ async function handleRazorpaySuccess(data, order, callbacks) {
78
78
  }
79
79
  async function handleRazorpayFail(order, callbacks) {
80
80
  try {
81
- await chunkA6IO3HIN_cjs.razorpayOrderFail({
81
+ await chunkFMHR5ABF_cjs.razorpayOrderFail({
82
82
  order_id: order.id,
83
83
  razorpay_order_id: order.razorpay_order_id
84
84
  });
@@ -110,9 +110,9 @@ async function handleCODPayment(order, callbacks, options) {
110
110
  callbacks.onPaymentStart?.();
111
111
  chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "cod");
112
112
  if (options?.isPublic) {
113
- await chunkA6IO3HIN_cjs.publicMakeCODOrder(order.order_number);
113
+ await chunkFMHR5ABF_cjs.publicMakeCODOrder(order.order_number);
114
114
  } else {
115
- await chunkA6IO3HIN_cjs.makeCODOrder(order.id);
115
+ await chunkFMHR5ABF_cjs.makeCODOrder(order.id);
116
116
  }
117
117
  chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
118
118
  chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
@@ -140,7 +140,7 @@ function handleStripePayment(order, callbacks) {
140
140
  async function handleStripeSuccess(order, paymentIntentId, callbacks) {
141
141
  try {
142
142
  callbacks.onPaymentStart?.();
143
- await chunkA6IO3HIN_cjs.stripeOrderSuccess({
143
+ await chunkFMHR5ABF_cjs.stripeOrderSuccess({
144
144
  order_id: order.id,
145
145
  payment_intent_id: paymentIntentId
146
146
  });
@@ -174,12 +174,12 @@ function processPayment(order, paymentMethod, callbacks, options) {
174
174
  handlePhonepePayment(order, callbacks);
175
175
  }
176
176
  async function fetchAvailableCoupons() {
177
- const response = await chunkA6IO3HIN_cjs.getCoupons();
177
+ const response = await chunkFMHR5ABF_cjs.getCoupons();
178
178
  return response.data;
179
179
  }
180
180
  async function fetchAppliedCoupon() {
181
181
  try {
182
- const response = await chunkA6IO3HIN_cjs.getAppliedCoupon();
182
+ const response = await chunkFMHR5ABF_cjs.getAppliedCoupon();
183
183
  return response.data || null;
184
184
  } catch {
185
185
  return null;
@@ -187,7 +187,7 @@ async function fetchAppliedCoupon() {
187
187
  }
188
188
  async function applyCheckoutCoupon(code, callbacks) {
189
189
  try {
190
- const response = await chunkA6IO3HIN_cjs.applyCoupon(code);
190
+ const response = await chunkFMHR5ABF_cjs.applyCoupon(code);
191
191
  if (response.data?.coupon) {
192
192
  await callbacks.onCartRefresh();
193
193
  return response.data.coupon;
@@ -201,7 +201,7 @@ async function applyCheckoutCoupon(code, callbacks) {
201
201
  }
202
202
  }
203
203
  async function removeCheckoutCoupon(couponCode, callbacks) {
204
- await chunkA6IO3HIN_cjs.removeCoupon(couponCode);
204
+ await chunkFMHR5ABF_cjs.removeCoupon(couponCode);
205
205
  await callbacks.onCartRefresh();
206
206
  }
207
207
 
@@ -1,6 +1,6 @@
1
- import { cart_default } from './chunk-E7WPE3PV.js';
2
- import { http_service_default } from './chunk-GB3HW6DM.js';
3
- import { auth_default } from './chunk-FLBJKM6G.js';
1
+ import { cart_default } from './chunk-QAC72HKO.js';
2
+ import { http_service_default } from './chunk-JWKDXFS4.js';
3
+ import { auth_default } from './chunk-WEMNXIRS.js';
4
4
 
5
5
  // src/api/cart.ts
6
6
  async function getCart(url, addressId) {
@@ -1,4 +1,4 @@
1
- import { http_service_default } from './chunk-GB3HW6DM.js';
1
+ import { http_service_default } from './chunk-JWKDXFS4.js';
2
2
 
3
3
  // src/api/address.ts
4
4
  async function getAddresses(url) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkGQTO5ZE2_cjs = require('./chunk-GQTO5ZE2.cjs');
3
+ var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
4
4
  var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
5
5
  var axios = require('axios');
6
6
  var typescriptCookie = require('typescript-cookie');
@@ -22,7 +22,7 @@ function createInstance() {
22
22
  });
23
23
  const onRequestSuccess = (config) => {
24
24
  const csrftoken = typescriptCookie.getCookie("csrftoken");
25
- const token = chunkGQTO5ZE2_cjs.auth_default.getAccessToken();
25
+ const token = chunkBBRXE57K_cjs.auth_default.getAccessToken();
26
26
  config.headers["X-CSRFToken"] = csrftoken;
27
27
  if (token) config.headers["Authorization"] = `Bearer ${token}`;
28
28
  const storeId = chunkN3CTXRFT_cjs.getStoreId();
@@ -1,19 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var chunkQM73PI5L_cjs = require('../chunk-QM73PI5L.cjs');
4
- require('../chunk-JHGXIIBZ.cjs');
5
- require('../chunk-4CVKE6CC.cjs');
6
- require('../chunk-K5B62JZO.cjs');
7
- require('../chunk-UXLUE3HW.cjs');
8
- require('../chunk-GQTO5ZE2.cjs');
3
+ var chunkBBRB475I_cjs = require('../chunk-BBRB475I.cjs');
4
+ var chunkN3ZCCKXV_cjs = require('../chunk-N3ZCCKXV.cjs');
5
+ require('../chunk-G3R7ZVAG.cjs');
6
+ var chunk4CVKE6CC_cjs = require('../chunk-4CVKE6CC.cjs');
7
+ require('../chunk-47XTPPII.cjs');
8
+ require('../chunk-ZO2HREQL.cjs');
9
+ require('../chunk-BBRXE57K.cjs');
10
+ require('../chunk-NE3ZHELZ.cjs');
9
11
  require('../chunk-N3CTXRFT.cjs');
10
12
  var react = require('react');
11
13
  var clsx = require('clsx');
12
14
  var jsxRuntime = require('react/jsx-runtime');
15
+ var Modal = require('react-responsive-modal');
16
+ require('react-responsive-modal/styles.css');
13
17
 
14
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
19
 
16
20
  var clsx__default = /*#__PURE__*/_interopDefault(clsx);
21
+ var Modal__default = /*#__PURE__*/_interopDefault(Modal);
17
22
 
18
23
  // src/components/search-dropdown/search-dropdown.module.css
19
24
  var search_dropdown_default = {};
@@ -338,7 +343,7 @@ var AddressForm = react.forwardRef(
338
343
  handlePhoneChange,
339
344
  isSubmitting,
340
345
  isEditing
341
- } = chunkQM73PI5L_cjs.useAddressForm({
346
+ } = chunkN3ZCCKXV_cjs.useAddressForm({
342
347
  address,
343
348
  onSuccess,
344
349
  onError,
@@ -571,6 +576,120 @@ var AddressForm = react.forwardRef(
571
576
  );
572
577
  AddressForm.displayName = "AddressForm";
573
578
  var address_form_default2 = AddressForm;
579
+ function ShareIcon({
580
+ width = 20,
581
+ height = 23,
582
+ className
583
+ }) {
584
+ return /* @__PURE__ */ jsxRuntime.jsx(
585
+ "svg",
586
+ {
587
+ width,
588
+ height,
589
+ viewBox: "0 0 20 23",
590
+ fill: "none",
591
+ xmlns: "http://www.w3.org/2000/svg",
592
+ className,
593
+ children: /* @__PURE__ */ jsxRuntime.jsx(
594
+ "path",
595
+ {
596
+ d: "M5.0745 10.357C4.82568 9.90934 4.43524 9.55692 3.96446 9.35513C3.49369 9.15333 2.96923 9.11357 2.47341 9.24209C1.97759 9.37061 1.53848 9.66013 1.22501 10.0652C0.911539 10.4703 0.741455 10.968 0.741455 11.4802C0.741455 11.9924 0.911539 12.4901 1.22501 12.8952C1.53848 13.3003 1.97759 13.5898 2.47341 13.7183C2.96923 13.8469 3.49369 13.8071 3.96446 13.6053C4.43524 13.4035 4.82568 13.0511 5.0745 12.6034M5.0745 10.357C5.25947 10.69 5.36531 11.0723 5.36531 11.4802C5.36531 11.8882 5.25947 12.2715 5.0745 12.6034M5.0745 10.357L14.9045 4.89641M5.0745 12.6034L14.9045 18.064M14.9045 4.89641C15.0486 5.16783 15.2454 5.4078 15.4833 5.60229C15.7213 5.79678 15.9956 5.94187 16.2903 6.0291C16.585 6.11633 16.8941 6.14393 17.1996 6.1103C17.5051 6.07667 17.8008 5.98247 18.0694 5.83323C18.338 5.68398 18.5742 5.48267 18.7642 5.24108C18.9541 4.99948 19.094 4.72244 19.1756 4.42616C19.2572 4.12988 19.279 3.8203 19.2395 3.51552C19.2001 3.21074 19.1003 2.91687 18.946 2.65111C18.6419 2.12739 18.1445 1.74388 17.5606 1.58304C16.9768 1.4222 16.3531 1.49685 15.8237 1.79096C15.2943 2.08507 14.9014 2.57515 14.7295 3.15586C14.5577 3.73656 14.6205 4.36152 14.9045 4.89641ZM14.9045 18.064C14.757 18.3295 14.6632 18.6215 14.6286 18.9232C14.5939 19.225 14.619 19.5306 14.7025 19.8226C14.7859 20.1146 14.9261 20.3874 15.1149 20.6253C15.3038 20.8631 15.5376 21.0615 15.8031 21.209C16.0686 21.3565 16.3606 21.4502 16.6623 21.4849C16.9641 21.5196 17.2697 21.4944 17.5617 21.411C17.8537 21.3276 18.1265 21.1874 18.3644 20.9986C18.6022 20.8097 18.8006 20.5758 18.9481 20.3103C19.246 19.7741 19.3186 19.1415 19.1501 18.5517C18.9816 17.962 18.5857 17.4633 18.0494 17.1654C17.5132 16.8675 16.8806 16.7948 16.2908 16.9634C15.7011 17.1319 15.2024 17.5278 14.9045 18.064Z",
597
+ stroke: "currentColor",
598
+ strokeWidth: "1.5",
599
+ strokeLinecap: "round",
600
+ strokeLinejoin: "round"
601
+ }
602
+ )
603
+ }
604
+ );
605
+ }
606
+ var ShareButton = ({
607
+ product,
608
+ className = "flex space-x-2 items-center hover:text-textSecondary transition-all duration-100",
609
+ iconSize = 22
610
+ }) => {
611
+ const _handleShare = () => {
612
+ chunk4CVKE6CC_cjs.shareLink(
613
+ `Buy ${product.name} at ${chunk4CVKE6CC_cjs.convertToCurrency(
614
+ Number(product.selling_price)
615
+ )}`,
616
+ product.name
617
+ );
618
+ };
619
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className, onClick: _handleShare, children: /* @__PURE__ */ jsxRuntime.jsx(ShareIcon, { width: iconSize, height: iconSize }) }) });
620
+ };
621
+ var share_button_default = ShareButton;
622
+ var checkIfLimitReached = (attribute) => {
623
+ return chunkBBRB475I_cjs.isExpired(attribute.expiry_date) || attribute.download_count === 0;
624
+ };
625
+ var DigitalProductDownloadModal = ({ open, onClose, product, downloadAttribute, onDownload, loading }) => {
626
+ return /* @__PURE__ */ jsxRuntime.jsx(
627
+ Modal__default.default,
628
+ {
629
+ classNames: {
630
+ modal: "modal modal-lg modal-confirm",
631
+ closeButton: "modal-close"
632
+ },
633
+ open,
634
+ onClose,
635
+ center: true,
636
+ closeIcon: null,
637
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "modal-body px-4 py-2", children: [
638
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-2xl block mb-2 fw-regular", children: [
639
+ "Download links for ",
640
+ product?.product_name
641
+ ] }),
642
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "mb-4 mt-2" }),
643
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "download-links", children: loading ? Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-100 rounded-1 mb-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-100", children: [
645
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine line w-75" }),
646
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine line w-50 mt-2" })
647
+ ] }),
648
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shine w-160 h-32 rounded-1" })
649
+ ] }) }, index)) : downloadAttribute.map((attribute, index) => /* @__PURE__ */ jsxRuntime.jsxs(
650
+ "div",
651
+ {
652
+ className: "flex items-center justify-between mt-3",
653
+ children: [
654
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
655
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "block text-md lh-1", children: [
656
+ "Download link ",
657
+ index + 1
658
+ ] }),
659
+ checkIfLimitReached(attribute) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-danger text-sm lh-1", children: "Download link expired." }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-textSecondary text-sm lh-1", children: [
660
+ "Remaining tries: ",
661
+ attribute.download_count,
662
+ " ",
663
+ "\u2022\xA0 Expires",
664
+ " ",
665
+ chunkBBRB475I_cjs.timeFromNow(attribute.expiry_date)
666
+ ] })
667
+ ] }),
668
+ /* @__PURE__ */ jsxRuntime.jsx(
669
+ "button",
670
+ {
671
+ className: "btn btn-text btn-medium",
672
+ onClick: () => onDownload(attribute),
673
+ disabled: checkIfLimitReached(attribute),
674
+ children: "Download"
675
+ }
676
+ )
677
+ ]
678
+ },
679
+ `${attribute.download_link}-${index}`
680
+ )) }),
681
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-textSecondary text-sm fw-regular p-2 bg-warning-light rounded-2 mt-4", children: [
682
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "text-textSecondary", children: "Warning:" }),
683
+ " The download link is time-sensitive and will expire after a set period. You are limited to a specific number of download attempts, with each attempt reducing the remaining tries. To avoid any disruptions, please ensure a stable internet connection before proceeding with the download."
684
+ ] })
685
+ ] })
686
+ }
687
+ );
688
+ };
689
+ var digital_product_download_modal_default = DigitalProductDownloadModal;
574
690
 
575
691
  exports.AddressForm = address_form_default2;
692
+ exports.DigitalProductDownloadModal = digital_product_download_modal_default;
576
693
  exports.SearchDropdown = search_dropdown_default2;
694
+ exports.ShareButton = share_button_default;
695
+ exports.ShareIcon = ShareIcon;
@@ -1,7 +1,11 @@
1
- import React from 'react';
1
+ import React$1 from 'react';
2
2
  import { U as UseAddressFormOptions, u as useAddressForm } from '../useAddressForm-DgkCP1nG.cjs';
3
+ import { c as ProductDetail } from '../product-Dfi0ke-4.cjs';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { O as Order } from '../orders-DHJhJ3xz.cjs';
3
6
  import 'formik';
4
7
  import '../address-DQEZzyUG.cjs';
8
+ import 'react-toastify';
5
9
 
6
10
  interface SearchDropdownOption {
7
11
  value: string | number;
@@ -20,13 +24,13 @@ interface SearchDropdownProps {
20
24
  error?: string;
21
25
  label?: string;
22
26
  name?: string;
23
- renderOption?: (option: SearchDropdownOption) => React.ReactNode;
24
- renderSelected?: (option: SearchDropdownOption | null) => React.ReactNode;
27
+ renderOption?: (option: SearchDropdownOption) => React$1.ReactNode;
28
+ renderSelected?: (option: SearchDropdownOption | null) => React$1.ReactNode;
25
29
  filterFunction?: (option: SearchDropdownOption, searchTerm: string) => boolean;
26
30
  emptyMessage?: string;
27
31
  maxHeight?: string;
28
32
  }
29
- declare const SearchDropdown: React.FC<SearchDropdownProps>;
33
+ declare const SearchDropdown: React$1.FC<SearchDropdownProps>;
30
34
 
31
35
  interface AddressFormRef {
32
36
  formik: ReturnType<typeof useAddressForm>["formik"];
@@ -38,8 +42,8 @@ interface AddressFormProps extends UseAddressFormOptions {
38
42
  type: "submit";
39
43
  disabled: boolean;
40
44
  loading: boolean;
41
- children: React.ReactNode;
42
- }) => React.ReactNode;
45
+ children: React$1.ReactNode;
46
+ }) => React$1.ReactNode;
43
47
  /** Called when formik instance is ready (alternative to ref) */
44
48
  onFormikReady?: (formik: ReturnType<typeof useAddressForm>["formik"]) => void;
45
49
  /** Called when cancel is clicked */
@@ -53,6 +57,29 @@ interface AddressFormProps extends UseAddressFormOptions {
53
57
  /** Submit button text. Default: "Save" */
54
58
  submitLabel?: string;
55
59
  }
56
- declare const AddressForm: React.ForwardRefExoticComponent<AddressFormProps & React.RefAttributes<AddressFormRef>>;
60
+ declare const AddressForm: React$1.ForwardRefExoticComponent<AddressFormProps & React$1.RefAttributes<AddressFormRef>>;
57
61
 
58
- export { AddressForm, type AddressFormProps, type AddressFormRef, SearchDropdown, type SearchDropdownOption, type SearchDropdownProps };
62
+ interface ShareButtonProps {
63
+ product: ProductDetail.Root;
64
+ className?: string;
65
+ iconSize?: number;
66
+ }
67
+ declare const ShareButton: React.FC<ShareButtonProps>;
68
+
69
+ declare function ShareIcon({ width, height, className, }: {
70
+ width?: number;
71
+ height?: number;
72
+ className?: string;
73
+ }): react_jsx_runtime.JSX.Element;
74
+
75
+ interface DigitalProductDownloadModalProps {
76
+ open: boolean;
77
+ onClose: () => void;
78
+ product: Order.PurchasedProduct | null;
79
+ downloadAttribute: ProductDetail.DigitalProductVariant[];
80
+ onDownload: (attribute: ProductDetail.DigitalProductVariant) => void;
81
+ loading?: boolean;
82
+ }
83
+ declare const DigitalProductDownloadModal: React.FC<DigitalProductDownloadModalProps>;
84
+
85
+ export { AddressForm, type AddressFormProps, type AddressFormRef, DigitalProductDownloadModal, type DigitalProductDownloadModalProps, SearchDropdown, type SearchDropdownOption, type SearchDropdownProps, ShareButton, type ShareButtonProps, ShareIcon };
@@ -1,7 +1,11 @@
1
- import React from 'react';
1
+ import React$1 from 'react';
2
2
  import { U as UseAddressFormOptions, u as useAddressForm } from '../useAddressForm-C-Uzug4d.js';
3
+ import { c as ProductDetail } from '../product-Dfi0ke-4.js';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { O as Order } from '../orders-DHJhJ3xz.js';
3
6
  import 'formik';
4
7
  import '../address-DQEZzyUG.js';
8
+ import 'react-toastify';
5
9
 
6
10
  interface SearchDropdownOption {
7
11
  value: string | number;
@@ -20,13 +24,13 @@ interface SearchDropdownProps {
20
24
  error?: string;
21
25
  label?: string;
22
26
  name?: string;
23
- renderOption?: (option: SearchDropdownOption) => React.ReactNode;
24
- renderSelected?: (option: SearchDropdownOption | null) => React.ReactNode;
27
+ renderOption?: (option: SearchDropdownOption) => React$1.ReactNode;
28
+ renderSelected?: (option: SearchDropdownOption | null) => React$1.ReactNode;
25
29
  filterFunction?: (option: SearchDropdownOption, searchTerm: string) => boolean;
26
30
  emptyMessage?: string;
27
31
  maxHeight?: string;
28
32
  }
29
- declare const SearchDropdown: React.FC<SearchDropdownProps>;
33
+ declare const SearchDropdown: React$1.FC<SearchDropdownProps>;
30
34
 
31
35
  interface AddressFormRef {
32
36
  formik: ReturnType<typeof useAddressForm>["formik"];
@@ -38,8 +42,8 @@ interface AddressFormProps extends UseAddressFormOptions {
38
42
  type: "submit";
39
43
  disabled: boolean;
40
44
  loading: boolean;
41
- children: React.ReactNode;
42
- }) => React.ReactNode;
45
+ children: React$1.ReactNode;
46
+ }) => React$1.ReactNode;
43
47
  /** Called when formik instance is ready (alternative to ref) */
44
48
  onFormikReady?: (formik: ReturnType<typeof useAddressForm>["formik"]) => void;
45
49
  /** Called when cancel is clicked */
@@ -53,6 +57,29 @@ interface AddressFormProps extends UseAddressFormOptions {
53
57
  /** Submit button text. Default: "Save" */
54
58
  submitLabel?: string;
55
59
  }
56
- declare const AddressForm: React.ForwardRefExoticComponent<AddressFormProps & React.RefAttributes<AddressFormRef>>;
60
+ declare const AddressForm: React$1.ForwardRefExoticComponent<AddressFormProps & React$1.RefAttributes<AddressFormRef>>;
57
61
 
58
- export { AddressForm, type AddressFormProps, type AddressFormRef, SearchDropdown, type SearchDropdownOption, type SearchDropdownProps };
62
+ interface ShareButtonProps {
63
+ product: ProductDetail.Root;
64
+ className?: string;
65
+ iconSize?: number;
66
+ }
67
+ declare const ShareButton: React.FC<ShareButtonProps>;
68
+
69
+ declare function ShareIcon({ width, height, className, }: {
70
+ width?: number;
71
+ height?: number;
72
+ className?: string;
73
+ }): react_jsx_runtime.JSX.Element;
74
+
75
+ interface DigitalProductDownloadModalProps {
76
+ open: boolean;
77
+ onClose: () => void;
78
+ product: Order.PurchasedProduct | null;
79
+ downloadAttribute: ProductDetail.DigitalProductVariant[];
80
+ onDownload: (attribute: ProductDetail.DigitalProductVariant) => void;
81
+ loading?: boolean;
82
+ }
83
+ declare const DigitalProductDownloadModal: React.FC<DigitalProductDownloadModalProps>;
84
+
85
+ export { AddressForm, type AddressFormProps, type AddressFormRef, DigitalProductDownloadModal, type DigitalProductDownloadModalProps, SearchDropdown, type SearchDropdownOption, type SearchDropdownProps, ShareButton, type ShareButtonProps, ShareIcon };