@lightspeed/ecom-headless 1.1.4 → 1.1.5-rc.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.
@@ -1,4 +1,4 @@
1
- import { E as EcwidApiPromise, g as CartData, y as CustomerCookieConsentType, v as JsApiPage, s as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, t as CustomerGetCallback, u as CustomerSignOutCallback } from './ecom-headless.BTXuBMcG.cjs';
1
+ import { E as EcwidApiPromise, g as CartData, z as CustomerCookieConsentType, w as JsApiPage, t as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, p as CartRemoveProductsCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, u as CustomerGetCallback, v as CustomerSignOutCallback } from './ecom-headless.DGDJogyS.mjs';
2
2
 
3
3
  declare const EcwidWidgetValues: {
4
4
  /** Minicart widget */
@@ -421,7 +421,7 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
421
421
  *
422
422
  * // Add product by ID with default quantity
423
423
  * Cart.addProduct(10, (success, product, cart) => {
424
- * if (success) {
424
+ * if (success && product !== null) {
425
425
  * console.log('Product added successfully');
426
426
  * }
427
427
  * });
@@ -431,10 +431,11 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
431
431
  * id: 10,
432
432
  * quantity: 3,
433
433
  * options: {
434
- * "Size": "L"
434
+ * "Size": "L",
435
+ * "Extras": ["Gift wrap", "Greeting card"]
435
436
  * }
436
437
  * }, (success, product, cart, error) => {
437
- * if (success) {
438
+ * if (success && product !== null) {
438
439
  * console.log(`Added ${product.quantity} items to cart`);
439
440
  * } else {
440
441
  * console.error('Failed to add product:', error);
@@ -472,8 +473,8 @@ declare function addProduct(product: AddProductParameter, callback?: CartAddProd
472
473
  * import { Cart } from '@lightspeed/ecom-headless';
473
474
  *
474
475
  * // Remove the first product from cart
475
- * Cart.removeProduct(0, (success, itemsRemovedQuantity, product, cart, error) => {
476
- * if (success) {
476
+ * Cart.removeProduct(0, (success, product, itemsRemovedQuantity, cart, error) => {
477
+ * if (success && product !== undefined) {
477
478
  * console.log(`Removed ${itemsRemovedQuantity} items from cart`);
478
479
  * console.log(`Product removed: ${product.name}`);
479
480
  * } else {
@@ -500,9 +501,10 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
500
501
  * import { Cart } from '@lightspeed/ecom-headless';
501
502
  *
502
503
  * // Remove first and second products from cart
503
- * Cart.removeProducts([0, 1], (success, itemsRemovedQuantity, product, cart, error) => {
504
- * if (success) {
504
+ * Cart.removeProducts([0, 1], (success, products, itemsRemovedQuantity, cart, error) => {
505
+ * if (success && products !== undefined) {
505
506
  * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);
507
+ * console.log(`Removed ${products.length} cart positions`);
506
508
  * } else {
507
509
  * console.error('Failed to remove products:', error);
508
510
  * }
@@ -512,7 +514,7 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
512
514
  * Cart.removeProducts([0, 2, 3]);
513
515
  * ```
514
516
  */
515
- declare function removeProducts(indices: number[], callback?: CartRemoveProductCallback): Promise<void>;
517
+ declare function removeProducts(indices: number[], callback?: CartRemoveProductsCallback): Promise<void>;
516
518
 
517
519
  /**
518
520
  * This method allows you to clear all details from the shopping cart.
@@ -1,4 +1,4 @@
1
- import { E as EcwidApiPromise, g as CartData, y as CustomerCookieConsentType, v as JsApiPage, s as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, t as CustomerGetCallback, u as CustomerSignOutCallback } from './ecom-headless.BTXuBMcG.mjs';
1
+ import { E as EcwidApiPromise, g as CartData, z as CustomerCookieConsentType, w as JsApiPage, t as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, p as CartRemoveProductsCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, u as CustomerGetCallback, v as CustomerSignOutCallback } from './ecom-headless.DGDJogyS.cjs';
2
2
 
3
3
  declare const EcwidWidgetValues: {
4
4
  /** Minicart widget */
@@ -421,7 +421,7 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
421
421
  *
422
422
  * // Add product by ID with default quantity
423
423
  * Cart.addProduct(10, (success, product, cart) => {
424
- * if (success) {
424
+ * if (success && product !== null) {
425
425
  * console.log('Product added successfully');
426
426
  * }
427
427
  * });
@@ -431,10 +431,11 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
431
431
  * id: 10,
432
432
  * quantity: 3,
433
433
  * options: {
434
- * "Size": "L"
434
+ * "Size": "L",
435
+ * "Extras": ["Gift wrap", "Greeting card"]
435
436
  * }
436
437
  * }, (success, product, cart, error) => {
437
- * if (success) {
438
+ * if (success && product !== null) {
438
439
  * console.log(`Added ${product.quantity} items to cart`);
439
440
  * } else {
440
441
  * console.error('Failed to add product:', error);
@@ -472,8 +473,8 @@ declare function addProduct(product: AddProductParameter, callback?: CartAddProd
472
473
  * import { Cart } from '@lightspeed/ecom-headless';
473
474
  *
474
475
  * // Remove the first product from cart
475
- * Cart.removeProduct(0, (success, itemsRemovedQuantity, product, cart, error) => {
476
- * if (success) {
476
+ * Cart.removeProduct(0, (success, product, itemsRemovedQuantity, cart, error) => {
477
+ * if (success && product !== undefined) {
477
478
  * console.log(`Removed ${itemsRemovedQuantity} items from cart`);
478
479
  * console.log(`Product removed: ${product.name}`);
479
480
  * } else {
@@ -500,9 +501,10 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
500
501
  * import { Cart } from '@lightspeed/ecom-headless';
501
502
  *
502
503
  * // Remove first and second products from cart
503
- * Cart.removeProducts([0, 1], (success, itemsRemovedQuantity, product, cart, error) => {
504
- * if (success) {
504
+ * Cart.removeProducts([0, 1], (success, products, itemsRemovedQuantity, cart, error) => {
505
+ * if (success && products !== undefined) {
505
506
  * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);
507
+ * console.log(`Removed ${products.length} cart positions`);
506
508
  * } else {
507
509
  * console.error('Failed to remove products:', error);
508
510
  * }
@@ -512,7 +514,7 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
512
514
  * Cart.removeProducts([0, 2, 3]);
513
515
  * ```
514
516
  */
515
- declare function removeProducts(indices: number[], callback?: CartRemoveProductCallback): Promise<void>;
517
+ declare function removeProducts(indices: number[], callback?: CartRemoveProductsCallback): Promise<void>;
516
518
 
517
519
  /**
518
520
  * This method allows you to clear all details from the shopping cart.
@@ -68,10 +68,13 @@ interface AddProductData {
68
68
  id: number;
69
69
  /** Quantity of the product that will be added to the cart. */
70
70
  quantity?: number;
71
- /** Map of the selected product options (option name as a key and option value as a value). */
72
- options?: Record<string, string>;
71
+ /**
72
+ * Map of selected product options by option name.
73
+ * Checkbox options accept multiple selected values.
74
+ */
75
+ options?: Record<string, string | readonly string[] | undefined>;
73
76
  /** Selected price for the product with the parameter "nameYourPriceEnabled": true. */
74
- selectedPrice?: string;
77
+ selectedPrice?: number;
75
78
  /** Defines subscription product settings if needed. */
76
79
  recurringChargeSettings?: AddProductRecurringChargeSettings;
77
80
  }
@@ -251,16 +254,17 @@ interface Order {
251
254
  }
252
255
 
253
256
  type CartGetCallback = (cart: CartData) => void;
254
- type CartAddProductCallback = (success: boolean, product: CartProduct, cart: CartData, error?: string) => void;
255
- type CartRemoveProductCallback = (success: boolean, itemsRemovedQuantity: number, product: CartProduct, cart: CartData, error?: string) => void;
256
- type CartClearCallback = (success: boolean, error?: string) => void;
257
+ type CartAddProductCallback = (success: boolean, product: CartProduct | null, cart: CartData, error: string | null) => void;
258
+ type CartRemoveProductCallback = (success: boolean, product: CartProduct | undefined, itemsRemovedQuantity: number, cart: CartData, error: string | null) => void;
259
+ type CartRemoveProductsCallback = (success: boolean, products: CartProduct[] | undefined, itemsRemovedQuantity: number, cart: CartData, error: string[] | null) => void;
260
+ type CartClearCallback = (success: boolean, error: string | null) => void;
257
261
  type CartCalculateTotalCallback = (order: Order) => void;
258
262
  type CartGoToCheckoutCallback = () => void;
259
263
  interface CartApi {
260
264
  get: (callback?: CartGetCallback) => Promise<void>;
261
265
  addProduct: (product: AddProductParameter, callback?: CartAddProductCallback) => Promise<void>;
262
266
  removeProduct: (index: number, callback?: CartRemoveProductCallback) => Promise<void>;
263
- removeProducts: (indices: number[], callback?: CartRemoveProductCallback) => Promise<void>;
267
+ removeProducts: (indices: number[], callback?: CartRemoveProductsCallback) => Promise<void>;
264
268
  clear: (callback?: CartClearCallback) => Promise<void>;
265
269
  calculateTotal: (callback?: CartCalculateTotalCallback) => Promise<void>;
266
270
  gotoCheckout: (callback?: CartGoToCheckoutCallback) => Promise<void>;
@@ -268,7 +272,7 @@ interface CartApi {
268
272
  }
269
273
 
270
274
  type CustomerGetCallback = (customer: CustomerData | null) => void;
271
- type CustomerSignOutCallback = (success: boolean, error?: string) => void;
275
+ type CustomerSignOutCallback = (success: boolean, error: string | null) => void;
272
276
  interface CustomerApi {
273
277
  get: (callback?: CustomerGetCallback) => Promise<void>;
274
278
  signOut: (callback?: CustomerSignOutCallback) => Promise<void>;
@@ -471,5 +475,5 @@ interface VisitorLocation {
471
475
  source: VisitorLocationSourceType;
472
476
  }
473
477
 
474
- export { LegalPageTypeValues as L, CustomerCookieConsentValues as r, JsApiPageValues as w, VisitorLocationSourceValues as x };
475
- export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartVideoInfo as p, CustomerApi as q, CustomerData as s, CustomerGetCallback as t, CustomerSignOutCallback as u, JsApiPage as v, CustomerCookieConsentType as y };
478
+ export { LegalPageTypeValues as L, CustomerCookieConsentValues as s, JsApiPageValues as x, VisitorLocationSourceValues as y };
479
+ export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartRemoveProductsCallback as p, CartVideoInfo as q, CustomerApi as r, CustomerData as t, CustomerGetCallback as u, CustomerSignOutCallback as v, JsApiPage as w, CustomerCookieConsentType as z };
@@ -68,10 +68,13 @@ interface AddProductData {
68
68
  id: number;
69
69
  /** Quantity of the product that will be added to the cart. */
70
70
  quantity?: number;
71
- /** Map of the selected product options (option name as a key and option value as a value). */
72
- options?: Record<string, string>;
71
+ /**
72
+ * Map of selected product options by option name.
73
+ * Checkbox options accept multiple selected values.
74
+ */
75
+ options?: Record<string, string | readonly string[] | undefined>;
73
76
  /** Selected price for the product with the parameter "nameYourPriceEnabled": true. */
74
- selectedPrice?: string;
77
+ selectedPrice?: number;
75
78
  /** Defines subscription product settings if needed. */
76
79
  recurringChargeSettings?: AddProductRecurringChargeSettings;
77
80
  }
@@ -251,16 +254,17 @@ interface Order {
251
254
  }
252
255
 
253
256
  type CartGetCallback = (cart: CartData) => void;
254
- type CartAddProductCallback = (success: boolean, product: CartProduct, cart: CartData, error?: string) => void;
255
- type CartRemoveProductCallback = (success: boolean, itemsRemovedQuantity: number, product: CartProduct, cart: CartData, error?: string) => void;
256
- type CartClearCallback = (success: boolean, error?: string) => void;
257
+ type CartAddProductCallback = (success: boolean, product: CartProduct | null, cart: CartData, error: string | null) => void;
258
+ type CartRemoveProductCallback = (success: boolean, product: CartProduct | undefined, itemsRemovedQuantity: number, cart: CartData, error: string | null) => void;
259
+ type CartRemoveProductsCallback = (success: boolean, products: CartProduct[] | undefined, itemsRemovedQuantity: number, cart: CartData, error: string[] | null) => void;
260
+ type CartClearCallback = (success: boolean, error: string | null) => void;
257
261
  type CartCalculateTotalCallback = (order: Order) => void;
258
262
  type CartGoToCheckoutCallback = () => void;
259
263
  interface CartApi {
260
264
  get: (callback?: CartGetCallback) => Promise<void>;
261
265
  addProduct: (product: AddProductParameter, callback?: CartAddProductCallback) => Promise<void>;
262
266
  removeProduct: (index: number, callback?: CartRemoveProductCallback) => Promise<void>;
263
- removeProducts: (indices: number[], callback?: CartRemoveProductCallback) => Promise<void>;
267
+ removeProducts: (indices: number[], callback?: CartRemoveProductsCallback) => Promise<void>;
264
268
  clear: (callback?: CartClearCallback) => Promise<void>;
265
269
  calculateTotal: (callback?: CartCalculateTotalCallback) => Promise<void>;
266
270
  gotoCheckout: (callback?: CartGoToCheckoutCallback) => Promise<void>;
@@ -268,7 +272,7 @@ interface CartApi {
268
272
  }
269
273
 
270
274
  type CustomerGetCallback = (customer: CustomerData | null) => void;
271
- type CustomerSignOutCallback = (success: boolean, error?: string) => void;
275
+ type CustomerSignOutCallback = (success: boolean, error: string | null) => void;
272
276
  interface CustomerApi {
273
277
  get: (callback?: CustomerGetCallback) => Promise<void>;
274
278
  signOut: (callback?: CustomerSignOutCallback) => Promise<void>;
@@ -471,5 +475,5 @@ interface VisitorLocation {
471
475
  source: VisitorLocationSourceType;
472
476
  }
473
477
 
474
- export { LegalPageTypeValues as L, CustomerCookieConsentValues as r, JsApiPageValues as w, VisitorLocationSourceValues as x };
475
- export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartVideoInfo as p, CustomerApi as q, CustomerData as s, CustomerGetCallback as t, CustomerSignOutCallback as u, JsApiPage as v, CustomerCookieConsentType as y };
478
+ export { LegalPageTypeValues as L, CustomerCookieConsentValues as s, JsApiPageValues as x, VisitorLocationSourceValues as y };
479
+ export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartRemoveProductsCallback as p, CartVideoInfo as q, CustomerApi as r, CustomerData as t, CustomerGetCallback as u, CustomerSignOutCallback as v, JsApiPage as w, CustomerCookieConsentType as z };
@@ -68,10 +68,13 @@ interface AddProductData {
68
68
  id: number;
69
69
  /** Quantity of the product that will be added to the cart. */
70
70
  quantity?: number;
71
- /** Map of the selected product options (option name as a key and option value as a value). */
72
- options?: Record<string, string>;
71
+ /**
72
+ * Map of selected product options by option name.
73
+ * Checkbox options accept multiple selected values.
74
+ */
75
+ options?: Record<string, string | readonly string[] | undefined>;
73
76
  /** Selected price for the product with the parameter "nameYourPriceEnabled": true. */
74
- selectedPrice?: string;
77
+ selectedPrice?: number;
75
78
  /** Defines subscription product settings if needed. */
76
79
  recurringChargeSettings?: AddProductRecurringChargeSettings;
77
80
  }
@@ -251,16 +254,17 @@ interface Order {
251
254
  }
252
255
 
253
256
  type CartGetCallback = (cart: CartData) => void;
254
- type CartAddProductCallback = (success: boolean, product: CartProduct, cart: CartData, error?: string) => void;
255
- type CartRemoveProductCallback = (success: boolean, itemsRemovedQuantity: number, product: CartProduct, cart: CartData, error?: string) => void;
256
- type CartClearCallback = (success: boolean, error?: string) => void;
257
+ type CartAddProductCallback = (success: boolean, product: CartProduct | null, cart: CartData, error: string | null) => void;
258
+ type CartRemoveProductCallback = (success: boolean, product: CartProduct | undefined, itemsRemovedQuantity: number, cart: CartData, error: string | null) => void;
259
+ type CartRemoveProductsCallback = (success: boolean, products: CartProduct[] | undefined, itemsRemovedQuantity: number, cart: CartData, error: string[] | null) => void;
260
+ type CartClearCallback = (success: boolean, error: string | null) => void;
257
261
  type CartCalculateTotalCallback = (order: Order) => void;
258
262
  type CartGoToCheckoutCallback = () => void;
259
263
  interface CartApi {
260
264
  get: (callback?: CartGetCallback) => Promise<void>;
261
265
  addProduct: (product: AddProductParameter, callback?: CartAddProductCallback) => Promise<void>;
262
266
  removeProduct: (index: number, callback?: CartRemoveProductCallback) => Promise<void>;
263
- removeProducts: (indices: number[], callback?: CartRemoveProductCallback) => Promise<void>;
267
+ removeProducts: (indices: number[], callback?: CartRemoveProductsCallback) => Promise<void>;
264
268
  clear: (callback?: CartClearCallback) => Promise<void>;
265
269
  calculateTotal: (callback?: CartCalculateTotalCallback) => Promise<void>;
266
270
  gotoCheckout: (callback?: CartGoToCheckoutCallback) => Promise<void>;
@@ -268,7 +272,7 @@ interface CartApi {
268
272
  }
269
273
 
270
274
  type CustomerGetCallback = (customer: CustomerData | null) => void;
271
- type CustomerSignOutCallback = (success: boolean, error?: string) => void;
275
+ type CustomerSignOutCallback = (success: boolean, error: string | null) => void;
272
276
  interface CustomerApi {
273
277
  get: (callback?: CustomerGetCallback) => Promise<void>;
274
278
  signOut: (callback?: CustomerSignOutCallback) => Promise<void>;
@@ -471,5 +475,5 @@ interface VisitorLocation {
471
475
  source: VisitorLocationSourceType;
472
476
  }
473
477
 
474
- export { LegalPageTypeValues as L, CustomerCookieConsentValues as r, JsApiPageValues as w, VisitorLocationSourceValues as x };
475
- export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartVideoInfo as p, CustomerApi as q, CustomerData as s, CustomerGetCallback as t, CustomerSignOutCallback as u, JsApiPage as v, CustomerCookieConsentType as y };
478
+ export { LegalPageTypeValues as L, CustomerCookieConsentValues as s, JsApiPageValues as x, VisitorLocationSourceValues as y };
479
+ export type { AddProductData as A, BaseJsApiPage as B, CartAddProductCallback as C, EcwidApiPromise as E, JsApiFilterParams as J, Order as O, RecurringChargeSettings as R, ShippingAddress as S, TrackingConsent as T, VisitorLocation as V, AddProductParameter as a, AddProductRecurringChargeSettings as b, BillingPerson as c, CartApi as d, CartCalculateTotalCallback as e, CartClearCallback as f, CartData as g, CartDominatingColor as h, CartGetCallback as i, CartGoToCheckoutCallback as j, CartImageBorderInfo as k, CartItem as l, CartMediaItem as m, CartProduct as n, CartRemoveProductCallback as o, CartRemoveProductsCallback as p, CartVideoInfo as q, CustomerApi as r, CustomerData as t, CustomerGetCallback as u, CustomerSignOutCallback as v, JsApiPage as w, CustomerCookieConsentType as z };
@@ -1,4 +1,4 @@
1
- import { E as EcwidApiPromise, g as CartData, y as CustomerCookieConsentType, v as JsApiPage, s as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, t as CustomerGetCallback, u as CustomerSignOutCallback } from './ecom-headless.BTXuBMcG.js';
1
+ import { E as EcwidApiPromise, g as CartData, z as CustomerCookieConsentType, w as JsApiPage, t as CustomerData, T as TrackingConsent, V as VisitorLocation, i as CartGetCallback, a as AddProductParameter, C as CartAddProductCallback, o as CartRemoveProductCallback, p as CartRemoveProductsCallback, f as CartClearCallback, e as CartCalculateTotalCallback, j as CartGoToCheckoutCallback, u as CustomerGetCallback, v as CustomerSignOutCallback } from './ecom-headless.DGDJogyS.js';
2
2
 
3
3
  declare const EcwidWidgetValues: {
4
4
  /** Minicart widget */
@@ -421,7 +421,7 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
421
421
  *
422
422
  * // Add product by ID with default quantity
423
423
  * Cart.addProduct(10, (success, product, cart) => {
424
- * if (success) {
424
+ * if (success && product !== null) {
425
425
  * console.log('Product added successfully');
426
426
  * }
427
427
  * });
@@ -431,10 +431,11 @@ declare function get$1(callback?: CartGetCallback): Promise<void>;
431
431
  * id: 10,
432
432
  * quantity: 3,
433
433
  * options: {
434
- * "Size": "L"
434
+ * "Size": "L",
435
+ * "Extras": ["Gift wrap", "Greeting card"]
435
436
  * }
436
437
  * }, (success, product, cart, error) => {
437
- * if (success) {
438
+ * if (success && product !== null) {
438
439
  * console.log(`Added ${product.quantity} items to cart`);
439
440
  * } else {
440
441
  * console.error('Failed to add product:', error);
@@ -472,8 +473,8 @@ declare function addProduct(product: AddProductParameter, callback?: CartAddProd
472
473
  * import { Cart } from '@lightspeed/ecom-headless';
473
474
  *
474
475
  * // Remove the first product from cart
475
- * Cart.removeProduct(0, (success, itemsRemovedQuantity, product, cart, error) => {
476
- * if (success) {
476
+ * Cart.removeProduct(0, (success, product, itemsRemovedQuantity, cart, error) => {
477
+ * if (success && product !== undefined) {
477
478
  * console.log(`Removed ${itemsRemovedQuantity} items from cart`);
478
479
  * console.log(`Product removed: ${product.name}`);
479
480
  * } else {
@@ -500,9 +501,10 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
500
501
  * import { Cart } from '@lightspeed/ecom-headless';
501
502
  *
502
503
  * // Remove first and second products from cart
503
- * Cart.removeProducts([0, 1], (success, itemsRemovedQuantity, product, cart, error) => {
504
- * if (success) {
504
+ * Cart.removeProducts([0, 1], (success, products, itemsRemovedQuantity, cart, error) => {
505
+ * if (success && products !== undefined) {
505
506
  * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);
507
+ * console.log(`Removed ${products.length} cart positions`);
506
508
  * } else {
507
509
  * console.error('Failed to remove products:', error);
508
510
  * }
@@ -512,7 +514,7 @@ declare function removeProduct(index: number, callback?: CartRemoveProductCallba
512
514
  * Cart.removeProducts([0, 2, 3]);
513
515
  * ```
514
516
  */
515
- declare function removeProducts(indices: number[], callback?: CartRemoveProductCallback): Promise<void>;
517
+ declare function removeProducts(indices: number[], callback?: CartRemoveProductsCallback): Promise<void>;
516
518
 
517
519
  /**
518
520
  * This method allows you to clear all details from the shopping cart.
@@ -1,2 +1,2 @@
1
- "use strict";const getStoreId=require("../shared/ecom-headless.CiGkSfL9.cjs"),OnCartChanged={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnCartChanged").add(t))},OnConsentChanged={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnConsentChanged").add(t))},OnPageLoad={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoad").add(t))},OnPageLoaded={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoaded").add(t))},OnPageSwitch={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageSwitch").add(t))},OnSetProfile={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnSetProfile").add(t))};async function formatCurrency(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("formatCurrency")(t))}async function getAppPublicConfig(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicConfig")(t))}async function getAppPublicToken(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicToken")(t))}async function getInitializedWidgets(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getInitializedWidgets")())}async function getStorefrontLang(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getStorefrontLang")())}async function getTrackingConsent(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getTrackingConsent")())}async function getVisitorLocation(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getVisitorLocation")())}async function isStorefrontV3(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("isStorefrontV3")())}async function openPage(t,e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("openPage")(t,e))}async function setTrackingConsent(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("setTrackingConsent")(t))}async function get$1(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").get(t))}async function addProduct(t,e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").addProduct(t,e))}async function removeProduct(t,e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").removeProduct(t,e))}async function removeProducts(t,e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").removeProducts(t,e))}async function clear(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").clear(t))}async function calculateTotal(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").calculateTotal(t))}async function canGotoCheckout(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").canGotoCheckout())}async function gotoCheckout(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").gotoCheckout(t))}const index$1={__proto__:null,addProduct,calculateTotal,canGotoCheckout,clear,get:get$1,gotoCheckout,removeProduct,removeProducts};async function get(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Customer").get(t))}async function signOut(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Customer").signOut(t))}const index={__proto__:null,get,signOut};exports.getOwnerId=getStoreId.getOwnerId;exports.getStoreId=getStoreId.getStoreId;exports.Cart=index$1;exports.Customer=index;exports.OnCartChanged=OnCartChanged;exports.OnConsentChanged=OnConsentChanged;exports.OnPageLoad=OnPageLoad;exports.OnPageLoaded=OnPageLoaded;exports.OnPageSwitch=OnPageSwitch;exports.OnSetProfile=OnSetProfile;exports.formatCurrency=formatCurrency;exports.getAppPublicConfig=getAppPublicConfig;exports.getAppPublicToken=getAppPublicToken;exports.getInitializedWidgets=getInitializedWidgets;exports.getStorefrontLang=getStorefrontLang;exports.getTrackingConsent=getTrackingConsent;exports.getVisitorLocation=getVisitorLocation;exports.isStorefrontV3=isStorefrontV3;exports.openPage=openPage;exports.setTrackingConsent=setTrackingConsent;
1
+ "use strict";const getStoreId=require("../shared/ecom-headless.CiGkSfL9.cjs");async function waitEcwidApiOperation({invoke:t,callback:e,getError:o}){return getStoreId.waitEcwidApiLoaded(()=>new Promise((n,d)=>{let r=!1;const i=(...c)=>{if(r)return;r=!0;let a;try{a=e?.(...c)}catch{}let g=!1,w,s;try{s=o?.(...c)}catch(u){g=!0,w=u}if(g||s!==void 0){Promise.resolve(a).catch(()=>{}),d(g?w:s);return}Promise.resolve(a).catch(()=>{}),n()};try{t(i)}catch(c){r=!0,d(c)}}))}function getEcwidApiOperationError(t,e,o){if(e)return;if(o instanceof Error)return o;const n=Array.isArray(o)?o.filter(Boolean).join(", "):typeof o=="string"?o.trim():"";return new Error(n||`${t} failed`)}const OnCartChanged={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnCartChanged").add(t))},OnConsentChanged={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnConsentChanged").add(t))},OnPageLoad={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoad").add(t))},OnPageLoaded={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageLoaded").add(t))},OnPageSwitch={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnPageSwitch").add(t))},OnSetProfile={add:t=>getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("OnSetProfile").add(t))};async function formatCurrency(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("formatCurrency")(t))}async function getAppPublicConfig(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicConfig")(t))}async function getAppPublicToken(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getAppPublicToken")(t))}async function getInitializedWidgets(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getInitializedWidgets")())}async function getStorefrontLang(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getStorefrontLang")())}async function getTrackingConsent(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getTrackingConsent")())}async function getVisitorLocation(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("getVisitorLocation")())}async function isStorefrontV3(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("isStorefrontV3")())}async function openPage(t,e){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("openPage")(t,e))}async function setTrackingConsent(t){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("setTrackingConsent")(t))}async function get$1(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Cart").get(e),callback:t})}async function addProduct(t,e){const o=typeof t=="number"?void 0:t.callback;return waitEcwidApiOperation({invoke:n=>{if(typeof t=="number"){getStoreId.getEcwidWindowMethod("Cart").addProduct(t,n);return}const d={...t,callback:n};getStoreId.getEcwidWindowMethod("Cart").addProduct(d)},callback:typeof o=="function"?o:e,getError:(n,d,r,i)=>getEcwidApiOperationError("Cart.addProduct",n,i)})}async function removeProduct(t,e){return waitEcwidApiOperation({invoke:o=>getStoreId.getEcwidWindowMethod("Cart").removeProduct(t,o),callback:e,getError:(o,n,d,r,i)=>getEcwidApiOperationError("Cart.removeProduct",o,i)})}async function removeProducts(t,e){return waitEcwidApiOperation({invoke:o=>getStoreId.getEcwidWindowMethod("Cart").removeProducts(t,o),callback:e,getError:(o,n,d,r,i)=>getEcwidApiOperationError("Cart.removeProducts",o,i)})}async function clear(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Cart").clear(e),callback:t,getError:(e,o)=>getEcwidApiOperationError("Cart.clear",e,o)})}async function calculateTotal(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Cart").calculateTotal(e),callback:t})}async function canGotoCheckout(){return getStoreId.waitEcwidApiLoaded(()=>getStoreId.getEcwidWindowMethod("Cart").canGotoCheckout())}async function gotoCheckout(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Cart").gotoCheckout(e),callback:t})}const index$1={__proto__:null,addProduct,calculateTotal,canGotoCheckout,clear,get:get$1,gotoCheckout,removeProduct,removeProducts};async function get(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Customer").get(e),callback:t})}async function signOut(t){return waitEcwidApiOperation({invoke:e=>getStoreId.getEcwidWindowMethod("Customer").signOut(e),callback:t,getError:(e,o)=>getEcwidApiOperationError("Customer.signOut",e,o)})}const index={__proto__:null,get,signOut};exports.getOwnerId=getStoreId.getOwnerId;exports.getStoreId=getStoreId.getStoreId;exports.Cart=index$1;exports.Customer=index;exports.OnCartChanged=OnCartChanged;exports.OnConsentChanged=OnConsentChanged;exports.OnPageLoad=OnPageLoad;exports.OnPageLoaded=OnPageLoaded;exports.OnPageSwitch=OnPageSwitch;exports.OnSetProfile=OnSetProfile;exports.formatCurrency=formatCurrency;exports.getAppPublicConfig=getAppPublicConfig;exports.getAppPublicToken=getAppPublicToken;exports.getInitializedWidgets=getInitializedWidgets;exports.getStorefrontLang=getStorefrontLang;exports.getTrackingConsent=getTrackingConsent;exports.getVisitorLocation=getVisitorLocation;exports.isStorefrontV3=isStorefrontV3;exports.openPage=openPage;exports.setTrackingConsent=setTrackingConsent;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/storefront/callbacks/on-cart-changed.ts","../../src/storefront/callbacks/on-consent-changed.ts","../../src/storefront/callbacks/on-page-load.ts","../../src/storefront/callbacks/on-page-loaded.ts","../../src/storefront/callbacks/on-page-switch.ts","../../src/storefront/callbacks/on-set-profile.ts","../../src/storefront/methods/format-currency.ts","../../src/storefront/methods/get-app-public-config.ts","../../src/storefront/methods/get-app-public-token.ts","../../src/storefront/methods/get-initialized-widgets.ts","../../src/storefront/methods/get-storefront-lang.ts","../../src/storefront/methods/get-tracking-consent.ts","../../src/storefront/methods/get-visitor-location.ts","../../src/storefront/methods/is-storefront-v3.ts","../../src/storefront/methods/open-page.ts","../../src/storefront/methods/set-tracking-consent.ts","../../src/storefront/cart/get.ts","../../src/storefront/cart/add-product.ts","../../src/storefront/cart/remove-product.ts","../../src/storefront/cart/remove-products.ts","../../src/storefront/cart/clear.ts","../../src/storefront/cart/calculate-total.ts","../../src/storefront/cart/can-go-to-checkout.ts","../../src/storefront/cart/go-to-checkout.ts","../../src/storefront/customer/get.ts","../../src/storefront/customer/sign-out.ts"],"sourcesContent":["import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CartData } from '@/types';\n\n/**\n * This event allows tracking any cart changes excluding the payment method selection.\n * Its callback function with the cart argument contains details about the cart after the change event.\n *\n * OnCartChanged event triggers when:\n * - Cart is initialized, synced, or cleared\n * - Product has been added, updated (increased quantity, changed selected options), or removed from the cart\n * - Discount coupon or discount is applied or removed\n * - Shipping address is added or updated\n * - Shipping method is selected or changed\n *\n * @example\n *\n * ```ts\n * import { OnCartChanged } from '@lightspeed/ecom-headless';\n *\n * OnCartChanged.add((cart) => {\n * console.log(`Cart ID: ${cart.cartId}`);\n * console.log(`Items in cart: ${cart.productsQuantity}`);\n * console.log(`Cart total: ${cart.total}`);\n * });\n * ```\n */\nexport const OnCartChanged: EcwidApiPromise<CartData> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnCartChanged').add(callback),\n ),\n};\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This method allows you to catch any changes to the consent value.\n *\n * @example\n *\n * ```ts\n * import { OnConsentChanged, CustomerCookieConsent } from '@lightspeed/ecom-headless';\n *\n * OnConsentChanged.add((consent) => {\n * console.log(\"consent changed to \" + consent);\n * });\n * setTrackingConsent(CustomerCookieConsent.DECLINED);\n * // \"consent changed to DECLINED\"\n * ```\n*/\nexport const OnConsentChanged: EcwidApiPromise<CustomerCookieConsentType> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnConsentChanged').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This event triggers instantly when the page DOM is loaded.\n *\n * This method doesn't wait for the Ecwid product browser and its contents to fully load\n * and therefore doesn't return any details about the opened page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoad } from '@lightspeed/ecom-headless';\n *\n * OnPageLoad.add(() => {\n * console.log(\"Page DOM has just loaded\");\n * });\n * ```\n*/\nexport const OnPageLoad: EcwidApiPromise<void> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoad').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows you to track the full page load –\n * a moment when both DOM and product browser are loaded and ready for customization.\n *\n * It contains a callback function with page argument containing information about a loaded page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoaded, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageLoaded.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageLoaded: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoaded').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows tracking and preventing page switches on the storefront.\n * It is triggered when a user is about to switch a page (a new page is not yet loaded).\n *\n * The method works synchronously and contains the page argument in its callback function.\n * Use it to identify the page where users go and prevent page loading by returning a false value.\n *\n * @example\n *\n * ```ts\n * import { OnPageSwitch, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageSwitch.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageSwitch: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageSwitch').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CustomerData } from '@/types';\n\n/**\n * This method allows you to track a moment when customers log in and out on the storefront.\n * It contains a callback function with customer argument when a customer logs in, and null if a customer has logged out.\n *\n * @example\n *\n * ```ts\n * import { OnSetProfile } from '@lightspeed/ecom-headless';\n *\n * OnSetProfile.add((customer) => {\n * console.log(customer.email);\n * // \"ec.apps@lightspeedhq.com\"\n * });\n * ```\n*/\nexport const OnSetProfile: EcwidApiPromise<CustomerData | null> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnSetProfile').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to get store currency settings on the storefront.\n * It is useful if you need to add a widget that displays some price to customers.\n *\n * It accepts a numeric price as an argument and responds with a formatted price\n * using store settings: currency symbol, and delimiter symbol and precision.\n *\n * @example\n *\n * ```ts\n * import { formatCurrency } from '@lightspeed/ecom-headless';\n *\n * const formattedPrice = await formatCurrency(12.99);\n * console.log(formattedPrice);\n * // \"$12.99\"\n * ```\n*/\nexport async function formatCurrency(amount: number): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('formatCurrency')(amount),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an app `client_id` as an argument and responds with a\n * \"public config\" for the app. This config is the data saved in App Storage\n * as a public key.\n *\n * Read more about setting up App Storage:\n * {@link https://docs.ecwid.com/launch-apps/native-and-external-apps/build-user-settings-page-for-ecwid-admin/manage-personal-user-settings-storage}.\n *\n * @example\n * ```ts\n * import { getAppPublicConfig } from '@lightspeed/ecom-headless';\n *\n * const publicConfig = await getAppPublicConfig('client_id');\n * console.log(JSON.parse(publicConfig));\n * // {\"key\": \"public\",\"value\": \"{'color':'red','text':'Email button','border-radius':'3px'}\"}\n * ```\n */\n\nexport async function getAppPublicConfig(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicConfig')(clientId),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts app client_id as an argument and responds with a public access token for the app.\n * Public tokens are safe to use on the storefront, as they won't be able to reveal any private store data.\n *\n * @example\n *\n * ```ts\n * import { getAppPublicToken } from '@lightspeed/ecom-headless';\n *\n * const publicToken = await getAppPublicToken('client_id');\n * console.log(publicToken);\n * // \"public_qKsUqKkNXzcj9DejwMUqEkY2q2E6BXM9\"\n * ```\n*/\nexport async function getAppPublicToken(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicToken')(clientId),\n );\n}\n","import { EcwidWidgetType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with a list of widgets currently loaded on the website.\n *\n * @example\n *\n * ```ts\n * import { getInitializedWidgets } from '@lightspeed/ecom-headless';\n * const widgets = await getInitializedWidgets();\n * console.log(widgets);\n * // [\"Minicart\", \"SearchPanel\", \"ProductBrowser\"]\n * ```\n*/\nexport async function getInitializedWidgets(): Promise<EcwidWidgetType[]> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getInitializedWidgets')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with the current storefront language in ISO 639-1 language code.\n * Use it to dynamically translate custom content on the page.\n *\n * @example\n *\n * ```ts\n * import { getStorefrontLang } from '@lightspeed/ecom-headless';\n *\n * const lang = await getStorefrontLang();\n * console.log(lang);\n * // \"en\"\n * ```\n*/\nexport async function getStorefrontLang(): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getStorefrontLang')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { TrackingConsent } from '@/types';\n\n/**\n * This method receives the customer's answer to the cookie consent banner.\n * Use it to define what cookies your application can collect.\n *\n * If the cookie consent value is overridden by the JS method or config,\n * getTrackingConsent() returns the new value added by JS method/config.\n *\n * @example\n *\n * ```ts\n * import { getTrackingConsent } from '@lightspeed/ecom-headless';\n *\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"ACCEPTED\", askConsent: true }\n * ```\n*/\nexport async function getTrackingConsent(): Promise<TrackingConsent> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getTrackingConsent')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { VisitorLocation } from '@/types';\n\n/**\n * This method gets the visitor's location based on their shipping or billing address (when entered), or IP.\n * The call works even for signed-out customers.\n *\n * @example\n *\n * ```ts\n * import { getVisitorLocation } from '@lightspeed/ecom-headless';\n *\n * const location = await getVisitorLocation();\n * console.log(location);\n * // { countryCode: \"US\", stateCode: \"NE\", source: \"IP_ADDRESS\" }\n * ```\n*/\nexport async function getVisitorLocation(): Promise<VisitorLocation> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getVisitorLocation')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method is useful for public applications developed before 2024.\n * It helps apps to adapt their design by detecting the old storefront version.\n *\n * All stores created in 2024 and later are using the latest storefront without the ability to switch the version.\n *\n * @example\n *\n * ```ts\n * import { isStorefrontV3 } from '@lightspeed/ecom-headless';\n *\n * const isStorefrontV3 = await isStorefrontV3();\n * console.log(isStorefrontV3);\n * // true\n * ```\n*/\nexport async function isStorefrontV3(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('isStorefrontV3')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to open a specific page on the storefront. The function accepts page slugs and additional parameters in its arguments.\n *\n * For example, you can use these redirects in different promo activities:\n * - Create a popup with a sale product and redirect customers to this product on click.\n * - Offer customers to log in to receive some bonus.\n * - Redirect customers to the search page with pre-configured terms showing promo products.\n *\n * @example\n *\n * ```ts\n * import { openPage } from '@lightspeed/ecom-headless';\n *\n * // Redirect customers to the cart page\n * openPage('cart');\n *\n * // Open search page with shoes of one brand\n * openPage('search', {\n * keyword: 'shoes',\n * attribute_Brand: 'Nike',\n * inventory: 'instock'\n * });\n * ```\n *\n * @see Full list of available pages: https://docs.ecwid.com/storefronts/open-page-on-the-storefront/overview-of-open-page-options#full-list-of-available-pages\n *\n * Learn more about pages that can be opened with additional params:\n *\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-product-pages-with-params Open product pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-category-pages-with-params Open category pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-search-page-with-params Open search page with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-account-pages-with-params Open account pages with params}\n*/\nexport async function openPage(\n page: string,\n options?: Record<string, unknown>,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('openPage')(page, options),\n );\n}\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an argument matching one of the following values:\n *\n * \"UNDEFINED\": Customer hasn't given their consent yet.\n *\n * \"ACCEPTED\": Collect all types of cookies.\n *\n * \"DECLINED\": Collect only essential cookies.\n *\n * \"ANALYTICS_ONLY\": Collect essential and analytics cookies only.\n *\n * \"PERSONALIZATION_ONLY\": Collect essential and personalization cookies.\n *\n * @example\n *\n * ```ts\n * import { setTrackingConsent, getTrackingConsent, CustomerCookieConsentValues } from '@lightspeed/ecom-headless';\n *\n * await setTrackingConsent(CustomerCookieConsentValues.DECLINED);\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"DECLINED\", askConsent: false }\n * ```\n*/\nexport async function setTrackingConsent(cookieConsent: CustomerCookieConsentType): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('setTrackingConsent')(cookieConsent),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartGetCallback } from '@/types';\n\n/**\n * This method allows you to receive full information about the current shopping cart.\n * The response is available in the cart callback.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.get((cart) => {\n * console.log(`Cart has ${cart.productsQuantity} products`);\n * console.log(`Cart ID: ${cart.cartId}`);\n * cart.items.forEach(item => {\n * console.log(`${item.product.name} - Quantity: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function get(callback?: CartGetCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').get(callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { AddProductParameter, CartAddProductCallback } from '@/types';\n\n/**\n * This method allows you to add a new product position to the shopping cart.\n * It accepts either a product ID or a product object with extended details including\n * product ID, quantity, selected options, or subscription product settings.\n *\n * When you use this method, it first checks the product by specified ID for stock and variations.\n * If the selected options match one of the variations, Ecwid will check its stock first.\n * If you don't have enough stock to add a product, Ecwid adds the available quantity.\n * If the product is out of stock, nothing is added to the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Add product by ID with default quantity\n * Cart.addProduct(10, (success, product, cart) => {\n * if (success) {\n * console.log('Product added successfully');\n * }\n * });\n *\n * // Add product with specific options and quantity\n * Cart.addProduct({\n * id: 10,\n * quantity: 3,\n * options: {\n * \"Size\": \"L\"\n * }\n * }, (success, product, cart, error) => {\n * if (success) {\n * console.log(`Added ${product.quantity} items to cart`);\n * } else {\n * console.error('Failed to add product:', error);\n * }\n * });\n *\n * // Add subscription product\n * Cart.addProduct({\n * id: 15,\n * quantity: 1,\n * recurringChargeSettings: {\n * recurringInterval: \"MONTH\",\n * recurringIntervalCount: 1,\n * }\n * });\n * ```\n */\nexport async function addProduct(\n product: AddProductParameter,\n callback?: CartAddProductCallback,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').addProduct(product, callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartRemoveProductCallback } from '@/types';\n\n/**\n * This method removes product position from the shopping cart entirely.\n * The specified product will be removed completely even if its quantity is greater than zero.\n *\n * This method completely removes the product from the cart. If you want to decrease its quantity,\n * use Cart.get() to save product details, then remove the product with Cart.removeProduct()\n * and add it back with all the same details except for the decreased quantity with Cart.addProduct().\n *\n * To remove a product position from the cart, first, you need to get an index with the Cart.get() method.\n * Position of the product in the items array is the index. For example, if you have two different\n * products added to the cart, the first product has an index of 0, and the second has an index of 1.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove the first product from cart\n * Cart.removeProduct(0, (success, itemsRemovedQuantity, product, cart, error) => {\n * if (success) {\n * console.log(`Removed ${itemsRemovedQuantity} items from cart`);\n * console.log(`Product removed: ${product.name}`);\n * } else {\n * console.error('Failed to remove product:', error);\n * }\n * });\n *\n * // Remove product without callback\n * Cart.removeProduct(1);\n * ```\n */\nexport async function removeProduct(\n index: number,\n callback?: CartRemoveProductCallback,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').removeProduct(index, callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartRemoveProductCallback } from '@/types';\n\n/**\n * This method works in the same way as Cart.removeProduct(), but allows you to remove\n * multiple items from the cart at once by passing an array of indices.\n *\n * Each index represents the position of a product in the cart's items array.\n * All specified products will be removed completely even if their quantity is greater than zero.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove first and second products from cart\n * Cart.removeProducts([0, 1], (success, itemsRemovedQuantity, product, cart, error) => {\n * if (success) {\n * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);\n * } else {\n * console.error('Failed to remove products:', error);\n * }\n * });\n *\n * // Remove multiple products without callback\n * Cart.removeProducts([0, 2, 3]);\n * ```\n */\nexport async function removeProducts(\n indices: number[],\n callback?: CartRemoveProductCallback,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').removeProducts(indices, callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartClearCallback } from '@/types';\n\n/**\n * This method allows you to clear all details from the shopping cart.\n * If the method clears the cart successfully, you receive true in the success argument.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.clear((success, error) => {\n * if (success) {\n * console.log(\"Cart was cleared\");\n * } else {\n * console.log(\"Cart clear failed. Error message: \" + error);\n * }\n * });\n *\n * // Clear without callback\n * Cart.clear();\n * ```\n */\nexport async function clear(callback?: CartClearCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').clear(callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartCalculateTotalCallback } from '@/types';\n\n/**\n * This method calculates the current cart asynchronously and passes the result as an order\n * callback argument with a snapshot of the generated order with essential details.\n *\n * The order object includes subtotals, taxes, discounts, shipping costs, and a full cart snapshot.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.calculateTotal((order) => {\n * console.log(`Order total: ${order.total}`);\n * console.log(`Subtotal: ${order.subtotal}`);\n * console.log(`Tax: ${order.tax}`);\n * console.log(`Shipping: ${order.shipping}`);\n * console.log(`Items in cart: ${order.cart.productsQuantity}`);\n *\n * // Access individual cart items\n * order.cart.items.forEach(item => {\n * console.log(`${item.product.name} - Qty: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function calculateTotal(callback?: CartCalculateTotalCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').calculateTotal(callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method checks whether you can send customers to the first step of the checkout called the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * const canGoToCheckout = await Cart.canGotoCheckout();\n *\n * if (canGoToCheckout) {\n * Cart.gotoCheckout();\n * }\n * ```\n */\nexport async function canGotoCheckout(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').canGotoCheckout(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CartGoToCheckoutCallback } from '@/types';\n\n/**\n * This method sends a customer to the first or second checkout step.\n *\n * This method works differently depending on the Ecwid admin > Settings > Legal > Terms & Conditions toggle\n * and whether the customer has already left an email in the shopping cart:\n *\n * - No email: the customer is sent to the shopping cart page.\n * - Email + toggle disabled: the customer is sent to the second checkout page (address details)\n * - Email + toggle disabled + no shipping: the customer is sent to the payment page.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.gotoCheckout(() => {\n * console.log(\"Checkout process started\");\n * });\n * ```\n */\nexport async function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').gotoCheckout(callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CustomerGetCallback } from '@/types';\n\n/**\n * This method receives all data on the customer currently logged in to the store.\n * If no customer is logged in, the method returns null.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.get((customer) => {\n * if (customer === null) {\n * console.log('No customer is logged in');\n * } else {\n * console.log(customer.email);\n * }\n * });\n * ```\n*/\nexport async function get(callback?: CustomerGetCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Customer').get(callback),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { CustomerSignOutCallback } from '@/types';\n\n/**\n * This method signs out customer from their account.\n *\n * Error message has value only if success is false.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.signOut((success, error) => {\n * if (success === true) {\n * console.log('Customer signed out');\n * } else {\n * console.log('Signout failed. Error message: ' + error);\n * }\n * });\n * ```\n*/\nexport async function signOut(callback?: CustomerSignOutCallback): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Customer').signOut(callback),\n );\n}\n"],"names":["callback","waitEcwidApiLoaded","getEcwidWindowMethod","amount","clientId","page","options","cookieConsent","get","product","index","indices"],"mappings":"8EA0Ba,cAA2C,CACtD,IAAKA,GACHC,WAAAA,mBACE,IAAMC,WAAAA,qBAAqB,eAAe,EAAE,IAAIF,CAAQ,CAC1D,CACJ,ECZa,iBAA+D,CAC1E,IAAKA,GACHC,WAAAA,mBACE,IAAMC,WAAAA,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F,CAAQ,CACrD,CACF,CCHA,eAAsB,QAAQA,EAAmD,CAC/E,OAAOC,8BACL,IAAMC,WAAAA,qBAAqB,UAAU,EAAE,QAAQF,CAAQ,CACzD,CACF"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/storefront/utils/wait-ecwid-api-operation.ts","../../src/storefront/callbacks/on-cart-changed.ts","../../src/storefront/callbacks/on-consent-changed.ts","../../src/storefront/callbacks/on-page-load.ts","../../src/storefront/callbacks/on-page-loaded.ts","../../src/storefront/callbacks/on-page-switch.ts","../../src/storefront/callbacks/on-set-profile.ts","../../src/storefront/methods/format-currency.ts","../../src/storefront/methods/get-app-public-config.ts","../../src/storefront/methods/get-app-public-token.ts","../../src/storefront/methods/get-initialized-widgets.ts","../../src/storefront/methods/get-storefront-lang.ts","../../src/storefront/methods/get-tracking-consent.ts","../../src/storefront/methods/get-visitor-location.ts","../../src/storefront/methods/is-storefront-v3.ts","../../src/storefront/methods/open-page.ts","../../src/storefront/methods/set-tracking-consent.ts","../../src/storefront/cart/get.ts","../../src/storefront/cart/add-product.ts","../../src/storefront/cart/remove-product.ts","../../src/storefront/cart/remove-products.ts","../../src/storefront/cart/clear.ts","../../src/storefront/cart/calculate-total.ts","../../src/storefront/cart/can-go-to-checkout.ts","../../src/storefront/cart/go-to-checkout.ts","../../src/storefront/customer/get.ts","../../src/storefront/customer/sign-out.ts"],"sourcesContent":["import { waitEcwidApiLoaded } from './wait-ecwid-api-loaded';\n\ntype OperationCallback<CallbackArguments extends unknown[]> = (...args: CallbackArguments) => void;\n\ninterface WaitEcwidApiOperationOptions<CallbackArguments extends unknown[]> {\n invoke: (callback: OperationCallback<CallbackArguments>) => void;\n callback?: OperationCallback<CallbackArguments>;\n getError?: (...args: CallbackArguments) => Error | undefined;\n}\n\nexport async function waitEcwidApiOperation<CallbackArguments extends unknown[]>({\n invoke,\n callback,\n getError,\n}: WaitEcwidApiOperationOptions<CallbackArguments>): Promise<void> {\n return waitEcwidApiLoaded(() => new Promise<void>((resolve, reject) => {\n let completed = false;\n\n const complete = (...args: CallbackArguments): void => {\n if (completed) {\n return;\n }\n completed = true;\n\n let callbackResult: unknown;\n try {\n callbackResult = callback?.(...args);\n } catch {\n // Consumer callback errors must not change the native operation result.\n }\n\n let getErrorThrew = false;\n let getErrorError: unknown;\n let operationError: Error | undefined;\n try {\n operationError = getError?.(...args);\n } catch (error) {\n getErrorThrew = true;\n getErrorError = error;\n }\n\n if (getErrorThrew || operationError !== undefined) {\n Promise.resolve(callbackResult).catch(() => undefined);\n reject(getErrorThrew ? getErrorError : operationError);\n return;\n }\n\n Promise.resolve(callbackResult).catch(() => undefined);\n resolve();\n };\n\n try {\n invoke(complete);\n } catch (error) {\n completed = true;\n reject(error);\n }\n }));\n}\n\nexport function getEcwidApiOperationError(\n operationName: string,\n success: boolean,\n nativeError?: unknown,\n): Error | undefined {\n if (success) {\n return undefined;\n }\n\n if (nativeError instanceof Error) {\n return nativeError;\n }\n\n const errorMessage = Array.isArray(nativeError)\n ? nativeError.filter(Boolean).join(', ')\n : typeof nativeError === 'string' ? nativeError.trim() : '';\n\n return new Error(errorMessage || `${operationName} failed`);\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CartData } from '@/types';\n\n/**\n * This event allows tracking any cart changes excluding the payment method selection.\n * Its callback function with the cart argument contains details about the cart after the change event.\n *\n * OnCartChanged event triggers when:\n * - Cart is initialized, synced, or cleared\n * - Product has been added, updated (increased quantity, changed selected options), or removed from the cart\n * - Discount coupon or discount is applied or removed\n * - Shipping address is added or updated\n * - Shipping method is selected or changed\n *\n * @example\n *\n * ```ts\n * import { OnCartChanged } from '@lightspeed/ecom-headless';\n *\n * OnCartChanged.add((cart) => {\n * console.log(`Cart ID: ${cart.cartId}`);\n * console.log(`Items in cart: ${cart.productsQuantity}`);\n * console.log(`Cart total: ${cart.total}`);\n * });\n * ```\n */\nexport const OnCartChanged: EcwidApiPromise<CartData> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnCartChanged').add(callback),\n ),\n};\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This method allows you to catch any changes to the consent value.\n *\n * @example\n *\n * ```ts\n * import { OnConsentChanged, CustomerCookieConsent } from '@lightspeed/ecom-headless';\n *\n * OnConsentChanged.add((consent) => {\n * console.log(\"consent changed to \" + consent);\n * });\n * setTrackingConsent(CustomerCookieConsent.DECLINED);\n * // \"consent changed to DECLINED\"\n * ```\n*/\nexport const OnConsentChanged: EcwidApiPromise<CustomerCookieConsentType> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnConsentChanged').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise } from '@/types';\n\n/**\n * This event triggers instantly when the page DOM is loaded.\n *\n * This method doesn't wait for the Ecwid product browser and its contents to fully load\n * and therefore doesn't return any details about the opened page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoad } from '@lightspeed/ecom-headless';\n *\n * OnPageLoad.add(() => {\n * console.log(\"Page DOM has just loaded\");\n * });\n * ```\n*/\nexport const OnPageLoad: EcwidApiPromise<void> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoad').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows you to track the full page load –\n * a moment when both DOM and product browser are loaded and ready for customization.\n *\n * It contains a callback function with page argument containing information about a loaded page.\n *\n * @example\n *\n * ```ts\n * import { OnPageLoaded, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageLoaded.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageLoaded: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageLoaded').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, JsApiPage } from '@/types';\n\n/**\n * This method allows tracking and preventing page switches on the storefront.\n * It is triggered when a user is about to switch a page (a new page is not yet loaded).\n *\n * The method works synchronously and contains the page argument in its callback function.\n * Use it to identify the page where users go and prevent page loading by returning a false value.\n *\n * @example\n *\n * ```ts\n * import { OnPageSwitch, JsApiPageValues } from '@lightspeed/ecom-headless';\n *\n * OnPageSwitch.add((page) => {\n * if (page.type === JsApiPageValues.PRODUCT) {\n * console.log(page);\n * }\n * });\n * // {\n * // \"type\":\"PRODUCT\",\n * // \"categoryId\":0,\n * // \"hasPrevious\":false,\n * // \"mainCategoryId\":0,\n * // \"name\":\"Desk Black 101x50x76.5 cm Engineered Wood\",\n * // \"nameTranslated\":{\n * // \"cs\":\"\",\n * // \"en\":\"Desk Black 101x50x76.5 cm Engineered Wood\"\n * // },\n * // \"productId\":561386461\n * // }\n * ```\n*/\nexport const OnPageSwitch: EcwidApiPromise<JsApiPage> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnPageSwitch').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { EcwidApiPromise, CustomerData } from '@/types';\n\n/**\n * This method allows you to track a moment when customers log in and out on the storefront.\n * It contains a callback function with customer argument when a customer logs in, and null if a customer has logged out.\n *\n * @example\n *\n * ```ts\n * import { OnSetProfile } from '@lightspeed/ecom-headless';\n *\n * OnSetProfile.add((customer) => {\n * console.log(customer.email);\n * // \"ec.apps@lightspeedhq.com\"\n * });\n * ```\n*/\nexport const OnSetProfile: EcwidApiPromise<CustomerData | null> = {\n add: callback =>\n waitEcwidApiLoaded(\n () => getEcwidWindowMethod('OnSetProfile').add(callback),\n ),\n};\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to get store currency settings on the storefront.\n * It is useful if you need to add a widget that displays some price to customers.\n *\n * It accepts a numeric price as an argument and responds with a formatted price\n * using store settings: currency symbol, and delimiter symbol and precision.\n *\n * @example\n *\n * ```ts\n * import { formatCurrency } from '@lightspeed/ecom-headless';\n *\n * const formattedPrice = await formatCurrency(12.99);\n * console.log(formattedPrice);\n * // \"$12.99\"\n * ```\n*/\nexport async function formatCurrency(amount: number): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('formatCurrency')(amount),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an app `client_id` as an argument and responds with a\n * \"public config\" for the app. This config is the data saved in App Storage\n * as a public key.\n *\n * Read more about setting up App Storage:\n * {@link https://docs.ecwid.com/launch-apps/native-and-external-apps/build-user-settings-page-for-ecwid-admin/manage-personal-user-settings-storage}.\n *\n * @example\n * ```ts\n * import { getAppPublicConfig } from '@lightspeed/ecom-headless';\n *\n * const publicConfig = await getAppPublicConfig('client_id');\n * console.log(JSON.parse(publicConfig));\n * // {\"key\": \"public\",\"value\": \"{'color':'red','text':'Email button','border-radius':'3px'}\"}\n * ```\n */\n\nexport async function getAppPublicConfig(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicConfig')(clientId),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts app client_id as an argument and responds with a public access token for the app.\n * Public tokens are safe to use on the storefront, as they won't be able to reveal any private store data.\n *\n * @example\n *\n * ```ts\n * import { getAppPublicToken } from '@lightspeed/ecom-headless';\n *\n * const publicToken = await getAppPublicToken('client_id');\n * console.log(publicToken);\n * // \"public_qKsUqKkNXzcj9DejwMUqEkY2q2E6BXM9\"\n * ```\n*/\nexport async function getAppPublicToken(clientId: string): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getAppPublicToken')(clientId),\n );\n}\n","import { EcwidWidgetType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with a list of widgets currently loaded on the website.\n *\n * @example\n *\n * ```ts\n * import { getInitializedWidgets } from '@lightspeed/ecom-headless';\n * const widgets = await getInitializedWidgets();\n * console.log(widgets);\n * // [\"Minicart\", \"SearchPanel\", \"ProductBrowser\"]\n * ```\n*/\nexport async function getInitializedWidgets(): Promise<EcwidWidgetType[]> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getInitializedWidgets')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method responds with the current storefront language in ISO 639-1 language code.\n * Use it to dynamically translate custom content on the page.\n *\n * @example\n *\n * ```ts\n * import { getStorefrontLang } from '@lightspeed/ecom-headless';\n *\n * const lang = await getStorefrontLang();\n * console.log(lang);\n * // \"en\"\n * ```\n*/\nexport async function getStorefrontLang(): Promise<string> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getStorefrontLang')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { TrackingConsent } from '@/types';\n\n/**\n * This method receives the customer's answer to the cookie consent banner.\n * Use it to define what cookies your application can collect.\n *\n * If the cookie consent value is overridden by the JS method or config,\n * getTrackingConsent() returns the new value added by JS method/config.\n *\n * @example\n *\n * ```ts\n * import { getTrackingConsent } from '@lightspeed/ecom-headless';\n *\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"ACCEPTED\", askConsent: true }\n * ```\n*/\nexport async function getTrackingConsent(): Promise<TrackingConsent> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getTrackingConsent')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\nimport { VisitorLocation } from '@/types';\n\n/**\n * This method gets the visitor's location based on their shipping or billing address (when entered), or IP.\n * The call works even for signed-out customers.\n *\n * @example\n *\n * ```ts\n * import { getVisitorLocation } from '@lightspeed/ecom-headless';\n *\n * const location = await getVisitorLocation();\n * console.log(location);\n * // { countryCode: \"US\", stateCode: \"NE\", source: \"IP_ADDRESS\" }\n * ```\n*/\nexport async function getVisitorLocation(): Promise<VisitorLocation> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('getVisitorLocation')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method is useful for public applications developed before 2024.\n * It helps apps to adapt their design by detecting the old storefront version.\n *\n * All stores created in 2024 and later are using the latest storefront without the ability to switch the version.\n *\n * @example\n *\n * ```ts\n * import { isStorefrontV3 } from '@lightspeed/ecom-headless';\n *\n * const isStorefrontV3 = await isStorefrontV3();\n * console.log(isStorefrontV3);\n * // true\n * ```\n*/\nexport async function isStorefrontV3(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('isStorefrontV3')(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method allows you to open a specific page on the storefront. The function accepts page slugs and additional parameters in its arguments.\n *\n * For example, you can use these redirects in different promo activities:\n * - Create a popup with a sale product and redirect customers to this product on click.\n * - Offer customers to log in to receive some bonus.\n * - Redirect customers to the search page with pre-configured terms showing promo products.\n *\n * @example\n *\n * ```ts\n * import { openPage } from '@lightspeed/ecom-headless';\n *\n * // Redirect customers to the cart page\n * openPage('cart');\n *\n * // Open search page with shoes of one brand\n * openPage('search', {\n * keyword: 'shoes',\n * attribute_Brand: 'Nike',\n * inventory: 'instock'\n * });\n * ```\n *\n * @see Full list of available pages: https://docs.ecwid.com/storefronts/open-page-on-the-storefront/overview-of-open-page-options#full-list-of-available-pages\n *\n * Learn more about pages that can be opened with additional params:\n *\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-product-pages-with-params Open product pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-category-pages-with-params Open category pages with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-search-page-with-params Open search page with params} |\n * {@link https://docs.ecwid.com/storefronts/open-page-on-the-storefront/open-account-pages-with-params Open account pages with params}\n*/\nexport async function openPage(\n page: string,\n options?: Record<string, unknown>,\n): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('openPage')(page, options),\n );\n}\n","import { CustomerCookieConsentType } from '@/constants';\nimport { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method accepts an argument matching one of the following values:\n *\n * \"UNDEFINED\": Customer hasn't given their consent yet.\n *\n * \"ACCEPTED\": Collect all types of cookies.\n *\n * \"DECLINED\": Collect only essential cookies.\n *\n * \"ANALYTICS_ONLY\": Collect essential and analytics cookies only.\n *\n * \"PERSONALIZATION_ONLY\": Collect essential and personalization cookies.\n *\n * @example\n *\n * ```ts\n * import { setTrackingConsent, getTrackingConsent, CustomerCookieConsentValues } from '@lightspeed/ecom-headless';\n *\n * await setTrackingConsent(CustomerCookieConsentValues.DECLINED);\n * const trackingConsent = await getTrackingConsent();\n * console.log(trackingConsent);\n * // { userResponse: \"DECLINED\", askConsent: false }\n * ```\n*/\nexport async function setTrackingConsent(cookieConsent: CustomerCookieConsentType): Promise<void> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('setTrackingConsent')(cookieConsent),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartGetCallback } from '@/types';\n\n/**\n * This method allows you to receive full information about the current shopping cart.\n * The response is available in the cart callback.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.get((cart) => {\n * console.log(`Cart has ${cart.productsQuantity} products`);\n * console.log(`Cart ID: ${cart.cartId}`);\n * cart.items.forEach(item => {\n * console.log(`${item.product.name} - Quantity: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function get(callback?: CartGetCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartGetCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').get(completionCallback),\n callback,\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { AddProductParameter, CartAddProductCallback } from '@/types';\nimport type { NativeAddProductData } from '@/types/private/native-storefront-api';\n\ntype AddProductData = Exclude<AddProductParameter, number>;\n\n/**\n * This method allows you to add a new product position to the shopping cart.\n * It accepts either a product ID or a product object with extended details including\n * product ID, quantity, selected options, or subscription product settings.\n *\n * When you use this method, it first checks the product by specified ID for stock and variations.\n * If the selected options match one of the variations, Ecwid will check its stock first.\n * If you don't have enough stock to add a product, Ecwid adds the available quantity.\n * If the product is out of stock, nothing is added to the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Add product by ID with default quantity\n * Cart.addProduct(10, (success, product, cart) => {\n * if (success && product !== null) {\n * console.log('Product added successfully');\n * }\n * });\n *\n * // Add product with specific options and quantity\n * Cart.addProduct({\n * id: 10,\n * quantity: 3,\n * options: {\n * \"Size\": \"L\",\n * \"Extras\": [\"Gift wrap\", \"Greeting card\"]\n * }\n * }, (success, product, cart, error) => {\n * if (success && product !== null) {\n * console.log(`Added ${product.quantity} items to cart`);\n * } else {\n * console.error('Failed to add product:', error);\n * }\n * });\n *\n * // Add subscription product\n * Cart.addProduct({\n * id: 15,\n * quantity: 1,\n * recurringChargeSettings: {\n * recurringInterval: \"MONTH\",\n * recurringIntervalCount: 1,\n * }\n * });\n * ```\n */\nexport async function addProduct(\n product: AddProductParameter,\n callback?: CartAddProductCallback,\n): Promise<void> {\n const embeddedCallback = typeof product === 'number'\n ? undefined\n : (product as AddProductData & { callback?: unknown }).callback;\n const consumerCallback = typeof embeddedCallback === 'function'\n ? embeddedCallback as CartAddProductCallback\n : callback;\n\n return waitEcwidApiOperation<Parameters<CartAddProductCallback>>({\n invoke: (completionCallback) => {\n if (typeof product === 'number') {\n getEcwidWindowMethod('Cart').addProduct(product, completionCallback);\n return;\n }\n\n const productWithCallback: NativeAddProductData = {\n ...product,\n callback: completionCallback,\n };\n getEcwidWindowMethod('Cart').addProduct(productWithCallback);\n },\n callback: consumerCallback,\n getError: (success, _product, _cart, error) => getEcwidApiOperationError('Cart.addProduct', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartRemoveProductCallback } from '@/types';\n\n/**\n * This method removes product position from the shopping cart entirely.\n * The specified product will be removed completely even if its quantity is greater than zero.\n *\n * This method completely removes the product from the cart. If you want to decrease its quantity,\n * use Cart.get() to save product details, then remove the product with Cart.removeProduct()\n * and add it back with all the same details except for the decreased quantity with Cart.addProduct().\n *\n * To remove a product position from the cart, first, you need to get an index with the Cart.get() method.\n * Position of the product in the items array is the index. For example, if you have two different\n * products added to the cart, the first product has an index of 0, and the second has an index of 1.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove the first product from cart\n * Cart.removeProduct(0, (success, product, itemsRemovedQuantity, cart, error) => {\n * if (success && product !== undefined) {\n * console.log(`Removed ${itemsRemovedQuantity} items from cart`);\n * console.log(`Product removed: ${product.name}`);\n * } else {\n * console.error('Failed to remove product:', error);\n * }\n * });\n *\n * // Remove product without callback\n * Cart.removeProduct(1);\n * ```\n */\nexport async function removeProduct(\n index: number,\n callback?: CartRemoveProductCallback,\n): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartRemoveProductCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').removeProduct(index, completionCallback),\n callback,\n getError: (success, _product, _quantity, _cart, error) => getEcwidApiOperationError('Cart.removeProduct', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartRemoveProductsCallback } from '@/types';\n\n/**\n * This method works in the same way as Cart.removeProduct(), but allows you to remove\n * multiple items from the cart at once by passing an array of indices.\n *\n * Each index represents the position of a product in the cart's items array.\n * All specified products will be removed completely even if their quantity is greater than zero.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * // Remove first and second products from cart\n * Cart.removeProducts([0, 1], (success, products, itemsRemovedQuantity, cart, error) => {\n * if (success && products !== undefined) {\n * console.log(`Removed ${itemsRemovedQuantity} total items from cart`);\n * console.log(`Removed ${products.length} cart positions`);\n * } else {\n * console.error('Failed to remove products:', error);\n * }\n * });\n *\n * // Remove multiple products without callback\n * Cart.removeProducts([0, 2, 3]);\n * ```\n */\nexport async function removeProducts(\n indices: number[],\n callback?: CartRemoveProductsCallback,\n): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartRemoveProductsCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').removeProducts(indices, completionCallback),\n callback,\n getError: (success, _products, _quantity, _cart, error) => getEcwidApiOperationError('Cart.removeProducts', success, error),\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CartClearCallback } from '@/types';\n\n/**\n * This method allows you to clear all details from the shopping cart.\n * If the method clears the cart successfully, you receive true in the success argument.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.clear((success, error) => {\n * if (success) {\n * console.log(\"Cart was cleared\");\n * } else {\n * console.log(\"Cart clear failed. Error message: \" + error);\n * }\n * });\n *\n * // Clear without callback\n * Cart.clear();\n * ```\n */\nexport async function clear(callback?: CartClearCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartClearCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').clear(completionCallback),\n callback,\n getError: (success, error) => getEcwidApiOperationError('Cart.clear', success, error),\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartCalculateTotalCallback } from '@/types';\n\n/**\n * This method calculates the current cart asynchronously and passes the result as an order\n * callback argument with a snapshot of the generated order with essential details.\n *\n * The order object includes subtotals, taxes, discounts, shipping costs, and a full cart snapshot.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.calculateTotal((order) => {\n * console.log(`Order total: ${order.total}`);\n * console.log(`Subtotal: ${order.subtotal}`);\n * console.log(`Tax: ${order.tax}`);\n * console.log(`Shipping: ${order.shipping}`);\n * console.log(`Items in cart: ${order.cart.productsQuantity}`);\n *\n * // Access individual cart items\n * order.cart.items.forEach(item => {\n * console.log(`${item.product.name} - Qty: ${item.quantity}`);\n * });\n * });\n * ```\n */\nexport async function calculateTotal(callback?: CartCalculateTotalCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartCalculateTotalCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').calculateTotal(completionCallback),\n callback,\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiLoaded } from '@/storefront/utils';\n\n/**\n * This method checks whether you can send customers to the first step of the checkout called the shopping cart.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * const canGoToCheckout = await Cart.canGotoCheckout();\n *\n * if (canGoToCheckout) {\n * Cart.gotoCheckout();\n * }\n * ```\n */\nexport async function canGotoCheckout(): Promise<boolean> {\n return waitEcwidApiLoaded(\n () => getEcwidWindowMethod('Cart').canGotoCheckout(),\n );\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CartGoToCheckoutCallback } from '@/types';\n\n/**\n * This method sends a customer to the first or second checkout step.\n *\n * This method works differently depending on the Ecwid admin > Settings > Legal > Terms & Conditions toggle\n * and whether the customer has already left an email in the shopping cart:\n *\n * - No email: the customer is sent to the shopping cart page.\n * - Email + toggle disabled: the customer is sent to the second checkout page (address details)\n * - Email + toggle disabled + no shipping: the customer is sent to the payment page.\n *\n * @example\n *\n * ```ts\n * import { Cart } from '@lightspeed/ecom-headless';\n *\n * Cart.gotoCheckout(() => {\n * console.log(\"Checkout process started\");\n * });\n * ```\n */\nexport async function gotoCheckout(callback?: CartGoToCheckoutCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CartGoToCheckoutCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Cart').gotoCheckout(completionCallback),\n callback,\n });\n}\n","import { getEcwidWindowMethod, waitEcwidApiOperation } from '@/storefront/utils';\nimport { CustomerGetCallback } from '@/types';\n\n/**\n * This method receives all data on the customer currently logged in to the store.\n * If no customer is logged in, the method returns null.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.get((customer) => {\n * if (customer === null) {\n * console.log('No customer is logged in');\n * } else {\n * console.log(customer.email);\n * }\n * });\n * ```\n*/\nexport async function get(callback?: CustomerGetCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CustomerGetCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Customer').get(completionCallback),\n callback,\n });\n}\n","import {\n getEcwidApiOperationError,\n getEcwidWindowMethod,\n waitEcwidApiOperation,\n} from '@/storefront/utils';\nimport { CustomerSignOutCallback } from '@/types';\n\n/**\n * This method signs out customer from their account.\n *\n * Error message has value only if success is false.\n *\n * @example\n *\n * ```ts\n * import { Customer } from '@lightspeed/ecom-headless';\n *\n * Customer.signOut((success, error) => {\n * if (success === true) {\n * console.log('Customer signed out');\n * } else {\n * console.log('Signout failed. Error message: ' + error);\n * }\n * });\n * ```\n*/\nexport async function signOut(callback?: CustomerSignOutCallback): Promise<void> {\n return waitEcwidApiOperation<Parameters<CustomerSignOutCallback>>({\n invoke: completionCallback => getEcwidWindowMethod('Customer').signOut(completionCallback),\n callback,\n getError: (success, error) => getEcwidApiOperationError('Customer.signOut', success, error),\n });\n}\n"],"names":["invoke","callback","getError","waitEcwidApiLoaded","resolve","reject","completed","complete","args","callbackResult","getErrorThrew","getErrorError","operationError","error","operationName","success","nativeError","errorMessage","getEcwidWindowMethod","amount","clientId","page","options","cookieConsent","get","waitEcwidApiOperation","completionCallback","product","embeddedCallback","productWithCallback","_product","_cart","getEcwidApiOperationError","index","_quantity","indices","_products"],"mappings":"8EAUA,eAAsB,sBAA2D,CAC/E,OAAAA,EACA,SAAAC,EACA,SAAAC,CACF,EAAmE,CACjE,OAAOC,WAAAA,mBAAmB,IAAM,IAAI,QAAc,CAACC,EAASC,IAAW,CACrE,IAAIC,EAAY,GAEhB,MAAMC,EAAW,IAAIC,IAAkC,CACrD,GAAIF,EACF,OAEFA,EAAY,GAEZ,IAAIG,EACJ,GAAI,CACFA,EAAiBR,IAAW,GAAGO,CAAI,CACrC,MAAQ,CAER,CAEA,IAAIE,EAAgB,GAChBC,EACAC,EACJ,GAAI,CACFA,EAAiBV,IAAW,GAAGM,CAAI,CACrC,OAASK,EAAO,CACdH,EAAgB,GAChBC,EAAgBE,CAClB,CAEA,GAAIH,GAAiBE,IAAmB,OAAW,CACjD,QAAQ,QAAQH,CAAc,EAAE,MAAM,IAAG,CAAA,CAAY,EACrDJ,EAAOK,EAAgBC,EAAgBC,CAAc,EACrD,MACF,CAEA,QAAQ,QAAQH,CAAc,EAAE,MAAM,IAAG,CAAA,CAAY,EACrDL,GACF,EAEA,GAAI,CACFJ,EAAOO,CAAQ,CACjB,OAASM,EAAO,CACdP,EAAY,GACZD,EAAOQ,CAAK,CACd,CACF,CAAC,CAAC,CACJ,CAEO,SAAS,0BAC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CACvE,OAAOwB,sBAAuD,CAC5D,OAAQC,GAAsBR,WAAAA,qBAAqB,UAAU,EAAE,IAAIQ,CAAkB,EACrF,SAAAzB,CACF,CAAC,CACH,CCAA,eAAsB,QAAQA,EAAmD,CAC/E,OAAOwB,sBAA2D,CAChE,OAAQC,GAAsBR,WAAAA,qBAAqB,UAAU,EAAE,QAAQQ,CAAkB,EACzF,SAAAzB,EACA,SAAU,CAACc,EAASF,IAAUmB,0BAA0B,mBAAoBjB,EAASF,CAAK,CAC5F,CAAC,CACH"}
@@ -1,2 +1,2 @@
1
- export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.CdAf5aSI.cjs';
2
- import '../shared/ecom-headless.BTXuBMcG.cjs';
1
+ export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.C9ivNZI7.cjs';
2
+ import '../shared/ecom-headless.DGDJogyS.cjs';
@@ -1,2 +1,2 @@
1
- export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.r8wgepwM.mjs';
2
- import '../shared/ecom-headless.BTXuBMcG.mjs';
1
+ export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.BhIymLsJ.mjs';
2
+ import '../shared/ecom-headless.DGDJogyS.mjs';
@@ -1,2 +1,2 @@
1
- export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.B47rEAOn.js';
2
- import '../shared/ecom-headless.BTXuBMcG.js';
1
+ export { i as Cart, a as Customer, O as OnCartChanged, b as OnConsentChanged, c as OnPageLoad, d as OnPageLoaded, e as OnPageSwitch, f as OnSetProfile, g as formatCurrency, h as getAppPublicConfig, j as getAppPublicToken, k as getInitializedWidgets, l as getOwnerId, m as getStoreId, n as getStorefrontLang, o as getTrackingConsent, p as getVisitorLocation, q as isStorefrontV3, r as openPage, s as setTrackingConsent } from '../shared/ecom-headless.DU9eDsgV.js';
2
+ import '../shared/ecom-headless.DGDJogyS.js';