@ikas/bp-storefront 1.4.0-beta.20 → 1.4.0-beta.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/analytics/analytics-functions/addToCart.js +1 -1
  2. package/dist/analytics/analytics-functions/addToWishlist.js +1 -1
  3. package/dist/analytics/analytics-functions/completeRegistration.js +1 -1
  4. package/dist/analytics/analytics-functions/contactForm.js +1 -1
  5. package/dist/analytics/analytics-functions/createEmailSubscription.js +1 -1
  6. package/dist/analytics/analytics-functions/customerLogin.js +1 -1
  7. package/dist/analytics/analytics-functions/customerLogout.js +1 -1
  8. package/dist/analytics/analytics-functions/customerVisit.js +1 -1
  9. package/dist/analytics/analytics-functions/pageView.js +1 -1
  10. package/dist/analytics/analytics-functions/productView.js +1 -1
  11. package/dist/analytics/analytics-functions/removeFromCart.js +1 -1
  12. package/dist/analytics/analytics-functions/search.js +1 -1
  13. package/dist/analytics/analytics-functions/viewBrand.js +1 -1
  14. package/dist/analytics/analytics-functions/viewCart.js +1 -1
  15. package/dist/analytics/analytics-functions/viewCategory.js +1 -1
  16. package/dist/analytics/analytics-functions/viewListing.js +1 -1
  17. package/dist/analytics/analytics-functions/viewSearchResults.js +1 -1
  18. package/dist/analytics/analytics-functions/viewStorefrontPopup.js +1 -1
  19. package/dist/analytics/events.d.ts +8 -0
  20. package/dist/analytics/events.js +1 -1
  21. package/dist/analytics/ikas/analytics.js +1 -1
  22. package/dist/analytics/openai/addToCart.d.ts +2 -0
  23. package/dist/analytics/openai/addToCart.js +1 -0
  24. package/dist/analytics/openai/completeRegistration.d.ts +1 -0
  25. package/dist/analytics/openai/completeRegistration.js +1 -0
  26. package/dist/analytics/openai/contactForm.d.ts +1 -0
  27. package/dist/analytics/openai/contactForm.js +1 -0
  28. package/dist/analytics/openai/initAdvancedMatching.d.ts +12 -0
  29. package/dist/analytics/openai/initAdvancedMatching.js +1 -0
  30. package/dist/analytics/openai/pageView.d.ts +1 -0
  31. package/dist/analytics/openai/pageView.js +1 -0
  32. package/dist/analytics/openai/productView.d.ts +2 -0
  33. package/dist/analytics/openai/productView.js +1 -0
  34. package/dist/analytics/openai/utils.d.ts +26 -0
  35. package/dist/analytics/openai/utils.js +1 -0
  36. package/dist/analytics/utils.d.ts +1 -0
  37. package/dist/analytics/utils.js +1 -1
  38. package/dist/functions/api/cart/index.d.ts +2 -0
  39. package/dist/functions/api/cart/index.js +1 -1
  40. package/dist/functions/api/customer/index.d.ts +5 -0
  41. package/dist/functions/api/customer/index.js +1 -1
  42. package/dist/functions/api/loyalty/index.d.ts +2 -1
  43. package/dist/functions/api/loyalty/index.js +1 -1
  44. package/dist/functions/api/product/index.js +1 -1
  45. package/dist/functions/models/attribute-detail/index.d.ts +3 -0
  46. package/dist/functions/models/attribute-list/index.d.ts +3 -0
  47. package/dist/functions/models/image/index.d.ts +71 -21
  48. package/dist/functions/models/image/index.js +1 -1
  49. package/dist/functions/models/index.d.ts +1 -0
  50. package/dist/functions/models/order/index.d.ts +21 -0
  51. package/dist/functions/models/order/index.js +1 -1
  52. package/dist/functions/models/product/attribute-value/index.d.ts +5 -0
  53. package/dist/functions/models/product/variant/index.d.ts +96 -6
  54. package/dist/functions/models/product/variant/index.js +1 -1
  55. package/dist/functions/models/product-list/index.js +1 -1
  56. package/dist/functions/models/validator/address/index.d.ts +70 -2
  57. package/dist/functions/models/validator/deactivate-customer/index.d.ts +54 -0
  58. package/dist/functions/models/validator/deactivate-customer/index.js +1 -0
  59. package/dist/functions/stores/base/index.d.ts +67 -0
  60. package/dist/functions/stores/base/index.js +1 -1
  61. package/dist/functions/stores/cart/index.d.ts +46 -2
  62. package/dist/functions/stores/cart/index.js +1 -1
  63. package/dist/functions/stores/customer/index.d.ts +278 -27
  64. package/dist/functions/stores/customer/index.js +1 -1
  65. package/dist/index.d.ts +5 -1
  66. package/dist/index.js +1 -1
  67. package/dist/packages/storefront-api/src/__api/mutations/removeGiftCardFromCart.js +1 -0
  68. package/dist/packages/storefront-api/src/__api/mutations/unlinkExternalAccount.js +1 -0
  69. package/dist/packages/storefront-api/src/__api/queries/getExternalAccountLink.js +1 -0
  70. package/dist/packages/storefront-api/src/__api/queries/getLoyaltyProgram.js +1 -0
  71. package/dist/packages/storefront-api/src/__api/queries/getMilesSmilesDetails.js +1 -0
  72. package/dist/packages/storefront-api-client/src/utils/api.js +1 -1
  73. package/dist/packages/storefront-config/src/index.js +1 -1
  74. package/dist/packages/storefront-config/src/theme-globals.js +1 -0
  75. package/dist/router/index.d.ts +28 -0
  76. package/dist/router/index.js +1 -1
  77. package/dist/storefront-api/src/__api/mutations/removeGiftCardFromCart.d.ts +7 -0
  78. package/dist/storefront-api/src/__api/mutations/unlinkExternalAccount.d.ts +6 -0
  79. package/dist/storefront-api/src/__api/queries/getExternalAccountLink.d.ts +6 -0
  80. package/dist/storefront-api/src/__api/queries/getLoyaltyProgram.d.ts +3 -0
  81. package/dist/storefront-api/src/__api/queries/getMilesSmilesDetails.d.ts +3 -0
  82. package/dist/storefront-api/src/__api/types/index.d.ts +68 -6
  83. package/dist/storefront-api-client/src/utils/api.d.ts +7 -0
  84. package/dist/storefront-config/src/index.d.ts +6 -0
  85. package/dist/storefront-config/src/theme-globals.d.ts +328 -0
  86. package/dist/storefront-models/src/index.d.ts +3 -0
  87. package/dist/storefront-models/src/models/blueprint/prop-value/attribute-list.d.ts +2 -0
  88. package/dist/storefront-models/src/models/blueprint/prop-value/attribute.d.ts +2 -0
  89. package/dist/storefront-models/src/models/blueprint/prop-value/color.d.ts +2 -0
  90. package/dist/storefront-models/src/models/blueprint/prop-value/index.d.ts +1 -0
  91. package/dist/storefront-models/src/models/blueprint/prop-value/variable-binding.d.ts +16 -0
  92. package/dist/storefront-models/src/models/image/index.d.ts +7 -0
  93. package/dist/storefront-models/src/models/loyalty-program/customer-info/index.d.ts +2 -0
  94. package/dist/storefront-models/src/models/loyalty-program/earning-method/index.d.ts +1 -0
  95. package/dist/storefront-models/src/models/loyalty-program/index.d.ts +1 -0
  96. package/dist/storefront-models/src/models/loyalty-program/point-history/index.d.ts +1 -0
  97. package/dist/storefront-models/src/models/order/gift-card-line/index.d.ts +15 -0
  98. package/dist/storefront-models/src/models/order/index.d.ts +2 -0
  99. package/dist/storefront-models/src/models/order/line-item/index.d.ts +1 -1
  100. package/dist/storefront-models/src/models/order/package/index.d.ts +1 -1
  101. package/dist/storefront-models/src/models/payment-gateway/index.d.ts +3 -1
  102. package/dist/storefront-models/src/models/product/attribute/index.d.ts +6 -1
  103. package/dist/storefront-models/src/models/product/campaign/data/index.d.ts +2 -0
  104. package/dist/storefront-models/src/models/product/campaign/filter/index.d.ts +1 -1
  105. package/dist/storefront-models/src/models/product/campaign/product-tiered-discount/index.d.ts +13 -0
  106. package/dist/storefront-models/src/models/product/image/index.d.ts +5 -0
  107. package/dist/storefront-models/src/models/product/variant/index.d.ts +17 -0
  108. package/dist/storefront-models/src/models/storefront/index.d.ts +1 -0
  109. package/dist/storefront-models/src/models/validator/deactivate-customer/index.d.ts +4 -0
  110. package/dist/stores/customer/index.d.ts +2 -1
  111. package/dist/stores/customer/index.js +1 -1
  112. package/dist/theme/settings/index.d.ts +51 -0
  113. package/dist/theme/settings/index.js +1 -0
  114. package/dist/utils/component-renderer.d.ts +1 -0
  115. package/dist/utils/component-renderer.js +1 -1
  116. package/dist/utils/currency.d.ts +36 -3
  117. package/dist/utils/helper.d.ts +1 -0
  118. package/dist/utils/helper.js +1 -1
  119. package/dist/utils/pay-with-ikas.d.ts +553 -0
  120. package/dist/utils/pay-with-ikas.js +1 -0
  121. package/dist/utils/svg.d.ts +15 -0
  122. package/dist/utils/svg.js +1 -0
  123. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import type { ListLoyaltyProgramPointHistoryQueryParams, SaveCustomerFormDataInput, UseLoyaltyPointsQueryParams } from "../../../storefront-api/src";
1
+ import type { ExternalAccountLink, ListLoyaltyProgramPointHistoryQueryParams, MilesSmilesDetailsResponse, SaveCustomerFormDataInput, UseLoyaltyPointsQueryParams } from "../../../storefront-api/src";
2
2
  import { APIResponse } from "../../../storefront-api-client/src";
3
- import { AccountInfoForm, AddressForm, ContactForm, CouponCodeForm, ForgotPasswordForm, IkasContactForm, IkasCustomer, IkasCustomerAddress, IkasCustomerAttributeValue, IkasCustomerReviewForm, IkasFavoriteProduct, IkasOrder, IkasOrderTransaction, IkasProduct, IkasProductFile, LoginForm, NewsletterSubscriptionForm, OrderTrackingForm, RecoverPasswordForm, RegisterForm, SmsLoginForm, VerifyPhoneNumberForm } from "../../../storefront-models/src";
3
+ import { AccountInfoForm, AddressForm, ContactForm, CouponCodeForm, DeactivateCustomerForm, ForgotPasswordForm, IkasContactForm, IkasCustomer, IkasCustomerAddress, IkasCustomerAttributeValue, IkasCustomerReviewForm, IkasFavoriteProduct, IkasOrder, IkasOrderTransaction, IkasProduct, IkasProductFile, LoginForm, NewsletterSubscriptionForm, OrderTrackingForm, RecoverPasswordForm, RegisterForm, SmsLoginForm, VerifyPhoneNumberForm } from "../../../storefront-models/src";
4
4
  import { IkasCustomerStore } from "../../../stores/customer";
5
5
  import { IkasLoginError, IkasRegisterError } from "../../api/customer";
6
- export type SocialLoginProvider = "facebook" | "google" | "twitch" | "miles_smiles";
6
+ export type SocialLoginProvider = "facebook" | "google" | "twitch";
7
7
  /**
8
8
  * Initialize the customer store by loading tokens, refreshing authentication, and fetching customer data.
9
9
  *
@@ -24,6 +24,42 @@ export type SocialLoginProvider = "facebook" | "google" | "twitch" | "miles_smil
24
24
  * ```
25
25
  */
26
26
  export declare function initCustomerStore(customerStore: IkasCustomerStore): Promise<void>;
27
+ /**
28
+ * The already-restored session of another store instance, as plain data. `null` means that
29
+ * instance settled as a guest (or failed) — the seeded store then settles as a guest too.
30
+ */
31
+ export type CustomerSessionSnapshot = {
32
+ customer: IkasCustomer;
33
+ favoriteProducts?: IkasFavoriteProduct[];
34
+ } | null;
35
+ /**
36
+ * Initialize the customer store from a session another store instance already restored, instead
37
+ * of restoring it again. A page can run two copies of this SDK (a host theme and an embedded
38
+ * component bundle); both share one localStorage session, so letting each copy run
39
+ * `initCustomerStore` duplicates the refresh-token and get-customer requests and double-counts
40
+ * the visit analytics event. The copy that restored the session hands its result over as plain
41
+ * data; this seeds the other copy with no network traffic at all.
42
+ *
43
+ * The token is still read from localStorage rather than taken from the snapshot: the restoring
44
+ * copy's refresh already persisted the rotated token there, and `loadToken` also wires it into
45
+ * this copy's API client config.
46
+ *
47
+ * `requiredCustomerFields` is the version-skew escape hatch. The snapshot's customer was fetched
48
+ * by the OTHER copy's get-customer query, which froze when that copy was built — so a snapshot
49
+ * from a much older copy can lack fields this copy's components rely on. Keys are checked for
50
+ * PRESENCE (`in`), not truthiness: a field the query asked for arrives even when null. When one
51
+ * is missing, this copy runs its own customer fetch — one request, and only against stale peers;
52
+ * an up-to-date peer's snapshot carries every key and stays at zero. If that fetch fails, the
53
+ * partially seeded customer is kept: stale data a page can render beats none.
54
+ */
55
+ export declare function seedCustomerSession(customerStore: IkasCustomerStore, snapshot: CustomerSessionSnapshot, requiredCustomerFields?: string[]): Promise<void>;
56
+ /**
57
+ * Reset this store's session state locally — no network, no analytics, no cart mutation. This is
58
+ * NOT `logout` (which revokes the session and fires the logout side effects); it is for the other
59
+ * SDK copy on the page, whose `logout` already did all of that, to bring this copy in line.
60
+ * Idempotent, and safe to call on a store that never held a session.
61
+ */
62
+ export declare function clearCustomerSession(customerStore: IkasCustomerStore): void;
27
63
  /**
28
64
  * Check whether a customer is eligible to create an email subscription.
29
65
  *
@@ -156,6 +192,143 @@ export declare function handleSocialLogin(customerStore: IkasCustomerStore): Pro
156
192
  * ```
157
193
  */
158
194
  export declare function socialLoginToken(customerStore: IkasCustomerStore, token: string): Promise<boolean>;
195
+ /** Provider segment of the customer-service external-account endpoints (`/ms/miles_smiles/bind/*`). */
196
+ export declare const MILES_SMILES_PROVIDER: string;
197
+ /** Synthetic gateway code a Miles&Smiles SALE is written on. Never selectable at checkout. */
198
+ export declare const MILES_SMILES_PAYMENT_GATEWAY_CODE: string;
199
+ /** Synthetic gateway id of the Miles&Smiles SALE. Never send it as `paymentGatewayId`. */
200
+ export declare const MILES_SMILES_PAYMENT_GATEWAY_ID: string;
201
+ /**
202
+ * Start the Turkish Airlines Miles&Smiles account bind flow for the logged-in customer.
203
+ * Opens the THY login page in a popup; once THY confirms, the browser is sent to the
204
+ * ikas bind callback and lands back on `redirect` with `milesSmilesStatus` query params
205
+ * (see handleMilesSmilesBind). Binding is required before miles can be spent at checkout.
206
+ *
207
+ * @ai-category Customer, Miles&Smiles
208
+ * @ai-related handleMilesSmilesBind, getMilesSmilesLink, unlinkMilesSmiles, getMilesSmilesDetails
209
+ *
210
+ * @param customerStore - The customer store instance (customer must be logged in)
211
+ * @param redirect - Relative store path to land on after bind, e.g. "/account" or "/checkout?id=...&step=payment"
212
+ * @returns `isSuccess: true` when the bind hand-off started; otherwise an `errorCode`
213
+ * such as "AUTHORIZATION_REQUIRED" or "MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * import { customerStore, milesSmilesBind } from "@ikas/bp-storefront";
218
+ *
219
+ * async function onLinkClick() {
220
+ * const result = await milesSmilesBind(customerStore, "/account");
221
+ * if (!result.isSuccess) showToast(result.errorCode || "UNEXPECTED_ERROR");
222
+ * }
223
+ * ```
224
+ */
225
+ export declare function milesSmilesBind(customerStore: IkasCustomerStore, redirect?: string | null): Promise<MilesSmilesBindResult>;
226
+ /**
227
+ * Read the Miles&Smiles bind result from the current URL after THY redirects back
228
+ * (`?milesSmilesStatus=success` or `?milesSmilesStatus=fail&milesSmilesError=CODE`).
229
+ * Call this on the landing page (account or checkout). The params are removed from the
230
+ * URL so a refresh does not repeat the same message.
231
+ *
232
+ * @ai-category Customer, Miles&Smiles
233
+ * @ai-related milesSmilesBind, getMilesSmilesLink
234
+ *
235
+ * @param clear - Remove the params from the URL with history.replaceState (default: true)
236
+ * @returns The landing result, or null when the URL carries no bind result
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * import { handleMilesSmilesBind } from "@ikas/bp-storefront";
241
+ *
242
+ * useEffect(() => {
243
+ * const result = handleMilesSmilesBind();
244
+ * if (result?.status === "success") showToast("Miles&Smiles account linked");
245
+ * if (result?.status === "fail") showToast(result.errorCode || "Bind failed");
246
+ * }, []);
247
+ * ```
248
+ */
249
+ export declare function handleMilesSmilesBind(clear?: boolean): HandleMilesSmilesBindReturnType | null;
250
+ /**
251
+ * Get the customer's durable Miles&Smiles link (TK membership number and link date).
252
+ * A link does not guarantee a live checkout session; when getMilesSmilesDetails returns
253
+ * MILES_SMILES_LOGIN_REQUIRED, run milesSmilesBind again.
254
+ *
255
+ * @ai-category Customer, Miles&Smiles
256
+ * @ai-related milesSmilesBind, unlinkMilesSmiles
257
+ *
258
+ * @param customerStore - The customer store instance
259
+ * @returns API response whose data is the link, or null when not linked
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * import { customerStore, getMilesSmilesLink } from "@ikas/bp-storefront";
264
+ *
265
+ * const response = await getMilesSmilesLink(customerStore);
266
+ * const tkNumber = response.data?.externalId;
267
+ * ```
268
+ */
269
+ export declare function getMilesSmilesLink(customerStore: IkasCustomerStore): Promise<APIResponse<ExternalAccountLink | null>>;
270
+ /**
271
+ * Remove the customer's Miles&Smiles link. Also clears the server-side checkout
272
+ * session token, so miles cannot be spent until the customer binds again.
273
+ *
274
+ * @ai-category Customer, Miles&Smiles
275
+ * @ai-related milesSmilesBind, getMilesSmilesLink
276
+ *
277
+ * @param customerStore - The customer store instance
278
+ * @returns API response whose data is true on success
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * import { customerStore, unlinkMilesSmiles } from "@ikas/bp-storefront";
283
+ *
284
+ * const response = await unlinkMilesSmiles(customerStore);
285
+ * if (response.isSuccess) showToast("Miles&Smiles link removed");
286
+ * ```
287
+ */
288
+ export declare function unlinkMilesSmiles(customerStore: IkasCustomerStore): Promise<APIResponse<boolean>>;
289
+ /**
290
+ * Get the Miles&Smiles balance and member details for the payment step.
291
+ * Requires a recent bind; MILES_SMILES_LOGIN_REQUIRED means the short-lived session
292
+ * expired and milesSmilesBind should be run again. MILES_SMILES_NOT_ENABLED and
293
+ * PAYMENT_GATEWAY_NOT_FOUND mean the Miles UI should be hidden.
294
+ *
295
+ * @ai-category Customer, Miles&Smiles
296
+ * @ai-related milesSmilesBind, getMilesSmilesLink
297
+ *
298
+ * @param customerStore - The customer store instance
299
+ * @returns API response whose data holds availableMiles, memberId, firstName and lastName
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * import { customerStore, getMilesSmilesDetails } from "@ikas/bp-storefront";
304
+ *
305
+ * const response = await getMilesSmilesDetails(customerStore);
306
+ * if (response.errorCodes.includes("MILES_SMILES_LOGIN_REQUIRED")) {
307
+ * await milesSmilesBind(customerStore, window.location.pathname + window.location.search);
308
+ * } else if (response.data) {
309
+ * console.log("Available miles:", response.data.availableMiles);
310
+ * }
311
+ * ```
312
+ */
313
+ export declare function getMilesSmilesDetails(customerStore: IkasCustomerStore): Promise<APIResponse<MilesSmilesDetailsResponse | undefined>>;
314
+ /**
315
+ * Check whether an order transaction is the Miles&Smiles leg of a multi-tender payment.
316
+ * Such rows are written on the synthetic MILES_SMILES gateway and are not refundable from the storefront.
317
+ *
318
+ * @ai-category Customer, Orders, Miles&Smiles
319
+ * @ai-related getOrderTransactions
320
+ *
321
+ * @param transaction - The order transaction to check
322
+ * @returns True when the transaction is a Miles&Smiles SALE
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * import { isMilesSmilesTransaction } from "@ikas/bp-storefront";
327
+ *
328
+ * const label = isMilesSmilesTransaction(tx) ? "Miles&Smiles" : tx.paymentGatewayName;
329
+ * ```
330
+ */
331
+ export declare function isMilesSmilesTransaction(transaction: IkasOrderTransaction): boolean;
159
332
  /**
160
333
  * Delete a customer address from their address list.
161
334
  *
@@ -908,7 +1081,7 @@ export declare function sendReview(customerStore: IkasCustomerStore, input: Ikas
908
1081
  * Deactivate (delete) the current customer's account after password verification.
909
1082
  *
910
1083
  * @ai-category Customer, Account
911
- * @ai-related hasCustomer, logout
1084
+ * @ai-related hasCustomer, logout, getDeactivateCustomerForm
912
1085
  *
913
1086
  * @param customerStore - The customer store instance
914
1087
  * @param password - The customer's current password for verification
@@ -1276,6 +1449,16 @@ type HandleSocialLoginReturnType = {
1276
1449
  status?: "fail" | "success";
1277
1450
  message?: string;
1278
1451
  };
1452
+ export type MilesSmilesBindResult = {
1453
+ isSuccess: boolean;
1454
+ /** Bind error code, e.g. AUTHORIZATION_REQUIRED, MILES_SMILES_LOGIN_CANCELLED_OR_FAILED, UNEXPECTED_ERROR. */
1455
+ errorCode?: string | null;
1456
+ };
1457
+ export type HandleMilesSmilesBindReturnType = {
1458
+ status: "success" | "fail";
1459
+ /** milesSmilesError from the redirect, e.g. EXTERNAL_ACCOUNT_ALREADY_LINKED. */
1460
+ errorCode: string | null;
1461
+ };
1279
1462
  /**
1280
1463
  * Get or initialize the account info form with validation for updating customer profile details.
1281
1464
  *
@@ -1421,6 +1604,68 @@ export declare function getCouponCodeForm(customerStore: IkasCustomerStore): Cou
1421
1604
  * ```
1422
1605
  */
1423
1606
  export declare function clearCouponCodeForm(customerStore: IkasCustomerStore): void;
1607
+ /**
1608
+ * Get or initialize the deactivate customer form with validation for deleting the current customer's account.
1609
+ *
1610
+ * @ai-category Customer, Account
1611
+ * @ai-related clearDeactivateCustomerForm, deactivateCustomer
1612
+ *
1613
+ * @param customerStore - The customer store instance
1614
+ * @returns The deactivate customer form object with validated fields
1615
+ *
1616
+ * @example
1617
+ * ```typescript
1618
+ * import {
1619
+ * customerStore,
1620
+ * getDeactivateCustomerForm,
1621
+ * setDeactivateCustomerFormPassword,
1622
+ * submitDeactivateCustomerForm,
1623
+ * logout,
1624
+ * } from "@ikas/bp-storefront";
1625
+ *
1626
+ * function DeleteAccountPage() {
1627
+ * const form = getDeactivateCustomerForm(customerStore);
1628
+ *
1629
+ * const handleSubmit = async () => {
1630
+ * const isSuccess = await submitDeactivateCustomerForm(form);
1631
+ * if (isSuccess) {
1632
+ * await logout(customerStore);
1633
+ * Router.navigateToPage("INDEX");
1634
+ * }
1635
+ * };
1636
+ *
1637
+ * return (
1638
+ * <form>
1639
+ * <input
1640
+ * type="password"
1641
+ * value={form.password.value}
1642
+ * onChange={e => setDeactivateCustomerFormPassword(form, e.target.value)}
1643
+ * />
1644
+ * <button onClick={handleSubmit}>Delete Account</button>
1645
+ * </form>
1646
+ * );
1647
+ * }
1648
+ * ```
1649
+ */
1650
+ export declare function getDeactivateCustomerForm(customerStore: IkasCustomerStore): DeactivateCustomerForm;
1651
+ /**
1652
+ * Clear the cached deactivate customer form, forcing a fresh form on next retrieval.
1653
+ *
1654
+ * @ai-category Customer, Account
1655
+ * @ai-related getDeactivateCustomerForm
1656
+ *
1657
+ * @param customerStore - The customer store instance
1658
+ *
1659
+ * @example
1660
+ * ```typescript
1661
+ * import { customerStore, clearDeactivateCustomerForm } from "@ikas/bp-storefront";
1662
+ *
1663
+ * function handleDeactivateCustomerReset() {
1664
+ * clearDeactivateCustomerForm(customerStore);
1665
+ * }
1666
+ * ```
1667
+ */
1668
+ export declare function clearDeactivateCustomerForm(customerStore: IkasCustomerStore): void;
1424
1669
  /**
1425
1670
  * Get or initialize the forgot password form with validation for requesting a password reset.
1426
1671
  *
@@ -1868,35 +2113,41 @@ export declare function clearRegisterForm(customerStore: IkasCustomerStore): voi
1868
2113
  /**
1869
2114
  * Create and return a new, empty address form with validation, wrapped in MobX observability.
1870
2115
  *
2116
+ * Use this to create an address; use `getIkasCustomerAddressForm(address)` to edit an existing
2117
+ * one. It starts `initAddressForm` internally but does not await it, so await `initAddressForm`
2118
+ * yourself when you need to know that the country layout (`addressFormat`) and the country/state/
2119
+ * city lists are ready to render.
2120
+ *
1871
2121
  * @ai-category Customer, Address
1872
- * @ai-related deleteCustomerAddress, saveCustomer
2122
+ * @ai-related initAddressForm, submitAddressForm, getIkasCustomerAddressForm, deleteCustomerAddress
1873
2123
  *
1874
2124
  * @param customerStore - The customer store instance
1875
2125
  * @returns A new observable address form object with validated fields
1876
2126
  *
1877
2127
  * @example
1878
- * ```typescript
1879
- * import { customerStore, getEmptyAddressForm, saveCustomer } from "@ikas/bp-storefront";
1880
- *
1881
- * function AddAddressPage() {
1882
- * const form = getEmptyAddressForm(customerStore);
1883
- *
1884
- * const handleSave = async () => {
1885
- * const customer = { ...customerStore.customer! };
1886
- * customer.addresses = [...(customer.addresses || []), formToAddress(form)];
1887
- * await saveCustomer(customerStore, customer);
1888
- * };
1889
- *
1890
- * return (
1891
- * <form>
1892
- * <input
1893
- * value={form.addressLine1.value}
1894
- * onChange={e => form.addressLine1.value = e.target.value}
1895
- * />
1896
- * <button onClick={handleSave}>Save Address</button>
1897
- * </form>
1898
- * );
1899
- * }
2128
+ * ```tsx
2129
+ * import {
2130
+ * customerStore,
2131
+ * getEmptyAddressForm,
2132
+ * initAddressForm,
2133
+ * setAddressFormAddressLine1,
2134
+ * submitAddressForm,
2135
+ * } from "@ikas/bp-storefront";
2136
+ *
2137
+ * // Create the form once, then await init before rendering the country-driven layout.
2138
+ * const [form] = useState(() => getEmptyAddressForm(customerStore));
2139
+ * const [isLoading, setIsLoading] = useState(true);
2140
+ * useEffect(() => {
2141
+ * initAddressForm(form).then(() => setIsLoading(false));
2142
+ * }, []);
2143
+ *
2144
+ * // Always go through the setters. Assigning `form.addressLine1.value` directly skips
2145
+ * // re-validation and the dependent-field resets the location setters perform.
2146
+ * setAddressFormAddressLine1(form, "123 Main Street");
2147
+ *
2148
+ * // submitAddressForm validates and saves the address onto the customer itself --
2149
+ * // do not hand-build a customer object and call saveCustomer for this.
2150
+ * const ok = await submitAddressForm(form);
1900
2151
  * ```
1901
2152
  */
1902
2153
  export declare function getEmptyAddressForm(customerStore: IkasCustomerStore): AddressForm;
@@ -1 +1 @@
1
- import{__awaiter as t,__assign as e,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import n from"../../../packages/storefront-api-client/src/config/index.js";import"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import{makeAutoObservable as o,observable as s}from'./../../../ext/mobx/dist/mobx.esm.js';import{Router as a}from"../../../router/index.js";import{baseStore as c}from"../../../stores/base/index.js";import{cartStore as u}from"../../../stores/cart/index.js";import{isServer as d,cloneDeep as l}from"../../../utils/helper.js";import'./../../../ext/lodash/sortBy.js';import"../../../stores/customer/index.js";import"../../../i18n/index.js";import'./../../../ext/lodash/_isFlattenable.js';import{removeCart as m,getCart as f}from"../cart/index.js";import{isCustomerSubscribed as p}from"../../models/customer/index.js";import{initAddressForm as v}from"../../models/validator/address/index.js";import{getOrderLineItemRefundQuantity as h}from"../../models/order/line-item/index.js";import"../../models/product-list/index.js";import{initAccountInfoForm as _}from"../../models/validator/account-info/index.js";import{initContactForm as w}from"../../models/validator/contact-form/index.js";import{initCouponCodeForm as g}from"../../models/validator/coupon-code-form/index.js";import{initForgotPasswordForm as b}from"../../models/validator/forgot-password/index.js";import{initLoginForm as I}from"../../models/validator/login/index.js";import{initNewsletterSubscriptionForm as S}from"../../models/validator/newsletter-subscription/index.js";import{initOrderTrackingForm as y}from"../../models/validator/order-tracking/index.js";import{initRecoverPasswordForm as k}from"../../models/validator/recover-password/index.js";import{initRegisterForm as x}from"../../models/validator/register/index.js";import{initSmsLoginForm as T}from"../../models/validator/sms-login/index.js";import{initVerifyPhoneNumberForm as j}from"../../models/validator/verify-phone-number/index.js";var E="customerToken",F="customerTokenExpiry",P="customerEmailSubscription",C="lastViewedProducts",L="customerConsent";function N(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return function(t){if(d())return;var e=localStorage.getItem(E),r=localStorage.getItem(F);e&&r?xt(t,e,parseInt(r)):Tt(t)}(e),Nt(e),function(t){if(d())return;t._customerConsentGranted=!!window.localStorage.getItem(L)}(e),[4,kt(e)];case 1:return t.sent(),[4,St(e)];case 2:return t.sent(),e._initialized=!0,[4,ct(e)];case 3:return t.sent(),e.customer?[4,import("../../../analytics/analytics-functions/customerVisit.js")]:[3,5];case 4:(0,t.sent().anl_customerVisit)(),t.label=5;case 5:return[2]}})})}function O(t){return!!t.customer&&(!(p(t.customer)||d()||t._visitorSubscribedEmail)&&!window.localStorage.getItem(P))}function R(t){return e(e({},t.customer),{consentGranted:t._customerConsentGranted})}function A(e,n){return t(this,void 0,void 0,function(){var t,e,o,s,c,u;return r(this,function(r){switch(r.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",e="".concat(import.meta.env.VITE_BASE_URL,"/ms/").concat(n,"/login/authenticate?redirect=").concat(t),[4,fetch(e,{headers:{"x-api-key":i.apiKey||"","x-sfid":i.storefrontId||"","x-sfrid":i.storefrontRoutingId||""}})]);case 1:return[4,r.sent().json()];case 2:return o=r.sent(),"miles_smiles"===n?(s=function(t){try{return new URL(t).searchParams.get("redirectUrl")}catch(t){return null}},c=function(t){try{var e=s(t);return e?new URL(e).searchParams.get("transactionId"):null}catch(t){return null}},u=function(t){var e=s(o.redirectUrl)||"",r=document.createElement("form");r.method="POST",r.action=e,r.style.display="none";for(var n=0,i=[["transactionId",t.transactionId],["token",t.token],["memberId",t.memberId],["shortTokenExpireMinute",null!=t.shortTokenExpireMinute?String(t.shortTokenExpireMinute):""],["longToken",t.longToken||""],["longTokenExpireMinute",null!=t.longTokenExpireMinute?String(t.longTokenExpireMinute):""]];n<i.length;n++){var a=i[n],c=a[0],u=a[1],d=document.createElement("input");d.type="hidden",d.name=c,d.value=u,r.appendChild(d)}document.body.appendChild(r),r.submit()},window.addEventListener("message",function(t){var e;try{e="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){return}if(e&&!0===e.isSuccess){var r={transactionId:c(o.redirectUrl),token:e.token,memberId:e.ffid||e.memberId||e.memberID,shortTokenExpireMinute:e.tokenExpireMinute,longToken:e.longToken,longTokenExpireMinute:e.longTokenExpireMinute};r.memberId&&r.token?u(r):console.error("Missing token or memberId")}}),window.open(o.redirectUrl,"mslogin","width=480,height=720"),[2]):(a.navigate(o.redirectUrl),[2])}})})}function V(e){return t(this,void 0,void 0,function(){var t,n,i,o,s;return r(this,function(r){switch(r.label){case 0:return t={status:"fail"},n=new URLSearchParams(window.location.search),i=n.get("socialLoginStatus"),o=n.get("socialLoginToken"),"success"===i&&o?[4,U(e,o)]:[3,2];case 1:return r.sent()?(t.status="success",[2,t]):[2,t];case 2:return s=n.get("socialLoginError"),t.message=s||void 0,[2,t]}})})}function U(e,n){return t(this,void 0,void 0,function(){var t,i,o;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSocialLogin)({code:n})];case 2:return(null==(t=r.sent())?void 0:t.isSuccess)&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(xt(e,t.data.token,t.data.tokenExpiry),yt(e,t.data.customer),[4,import("../../../analytics/analytics-functions/customerLogin.js")]):[2,!1];case 3:return i=r.sent().anl_customerLogin,e.customer&&i(),[2,!0]}})})}function D(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return(t=l(e.customer))&&t.addresses?-1===(i=t.addresses.findIndex(function(t){return t.id===n.id}))?[2,!1]:(t.addresses.splice(i,1),[4,$(e,t)]):[2,!1];case 1:return[2,r.sent()]}})})}function M(e,n,i){return t(this,void 0,void 0,function(){var t,e,o;return r(this,function(r){switch(r.label){case 0:r.label=1;case 1:return r.trys.push([1,4,,5]),t=[],n.orderLineItems.map(function(e){var r=h(e);r&&(null==t||t.push({orderLineItemId:e.id,quantity:r}))}),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiCreateOrderRefundRequest)({input:{email:i,orderId:n.id,orderLineItems:t}})];case 3:return(e=r.sent()).isSuccess&&e.data?(Object.entries(e.data).forEach(function(t){var e=t[0],r=t[1];n[e]=r}),[2,!0]):[3,5];case 4:return o=r.sent(),console.error(o),[3,5];case 5:return[2,!1]}})})}function B(e,n,i,o){return t(this,void 0,void 0,function(){var t,s;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiLogin)({email:n,password:i,phone:o,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),t&&t.isSuccess&&t.data?(s=t.data,xt(e,s.token,s.tokenExpiry),s.customer&&yt(e,s.customer),e.customer?[4,import("../../../analytics/analytics-functions/customerLogin.js")]:[3,5]):[3,6];case 4:(0,r.sent().anl_customerLogin)(),r.label=5;case 5:return At(e),[2,{isSuccess:!0,errorCodes:[],otpSend:s.otpSend,flowId:s.flowId}];case 6:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["CUSTOMER_ACCOUNT_DISABLED","EMAIL_IS_NOT_VERIFIED","CUSTOMER_NOT_FOUND","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED","WRONG_PASSWORD"].includes(t)?t:"UNKOWN"})}]}})})}function G(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return jt(e),m(u),[4,import("../../../analytics/analytics-functions/customerLogout.js")];case 1:return(0,t.sent().anl_customerLogout)(),[2]}})})}function W(e,n,i,o,s,a,c,u,d){return t(this,void 0,void 0,function(){var t,l;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiRegister)({email:o,password:s,firstName:n,lastName:i,isAcceptMarketing:a,attributes:c,captchaToken:e._captchaToken,phone:u,flowId:d})];case 3:return t=r.sent(),Et(e),t&&t.isSuccess&&(null===(l=t.data)||void 0===l?void 0:l.customer)?(xt(e,t.data.token,t.data.tokenExpiry),yt(e,t.data.customer),At(e),[4,import("../../../analytics/analytics-functions/completeRegistration.js")]):[3,5];case 4:return(0,r.sent().anl_completeRegistration)(R(e)),[2,{isSuccess:!0,errorCodes:[]}];case 5:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["EMAIL_IS_NOT_VERIFIED","CUSTOMER_EMAIL_ALREADY_EXISTS","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED"].includes(t)?t:"UNKOWN"})}]}})})}function q(e){return t(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new URLSearchParams(window.location.search),(n=t.get("token"))?[4,Pt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiActivateCustomer)({token:n,captchaToken:e._captchaToken})];case 3:return i=r.sent(),Et(e),[2,i.isSuccess];case 4:return[2,!1]}})})}function K(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return n?[4,Pt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiResendCustomerActivationMail)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),[2,t.isSuccess];case 4:return[2,!1]}})})}function z(e,n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return n?[4,Pt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiValidateCustomerPhoneVerificationCode)({verificationCode:n,otpInfo:i,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),[2,!(!t.isSuccess||!t.data)&&t.data];case 4:return[2,!1]}})})}function H(n,i,o){return t(this,void 0,void 0,function(){var t,s,a,c,u;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiValidateOTPCode)({verificationCode:i,otpInfo:o,captchaToken:n._captchaToken})];case 2:return t=r.sent(),Et(n),t&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(xt(n,t.data.token,t.data.tokenExpiry),yt(n,t.data.customer),At(n),[4,import("../../../analytics/analytics-functions/completeRegistration.js")]):[3,4];case 3:return(0,r.sent().anl_completeRegistration)(R(n)),[2,{isSuccess:!0,errorCodes:[]}];case 4:return t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:t.errorCodes.some(function(t){return"B2B_CUSTOMER_ACCOUNT_DISABLED"===t})?[4,import("../../../analytics/analytics-functions/completeRegistration.js")]:[3,6];case 5:(0,r.sent().anl_completeRegistration)(e(e({},R(n)),{notificationsAccepted:null}),!0),r.label=6;case 6:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["EMAIL_IS_NOT_VERIFIED","CUSTOMER_EMAIL_ALREADY_EXISTS","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED"].includes(t)?t:"UNKOWN"})}];case 7:return r.sent(),[2,{isSuccess:!1,errorCodes:[]}];case 8:return[2]}})})}function J(e){return t(this,void 0,void 0,function(){var t;return r(this,function(e){switch(e.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,e.sent().apiResendCustomerPhoneVerificationCode)()];case 2:return[2,!(!(t=e.sent()).isSuccess||!t.data)&&t.data]}})})}function X(n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../analytics/analytics-functions/contactForm.js")];case 1:return(0,r.sent().anl_contactForm)(i),[4,Pt(n)];case 2:return r.sent(),[4,import("../../api/customer/index.js")];case 3:return[4,(0,r.sent().apiSendContactFormToMerchant)(e(e({},i),{captchaToken:n._captchaToken}))];case 4:return t=r.sent(),Et(n),[2,t.isSuccess]}})})}function Y(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiCheckEmail)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),[2,!!t.isSuccess&&!!(null===(i=t.data)||void 0===i?void 0:i.exists)]}})})}function Q(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiForgotPassword)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),[2,!!t.isSuccess&&t.data]}})})}function Z(e,n,i,o){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiRecoverPassword)({password:n,passwordAgain:i,token:o,captchaToken:e._captchaToken})];case 3:return t=r.sent(),Et(e),[2,t.isSuccess]}})})}function $(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveCustomer)({input:Dt(n)})];case 2:return(t=r.sent()).isSuccess&&t.data?(yt(e,t.data),[2,!0]):[2,!1]}})})}function tt(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,ht(e)];case 1:return t.sent(),e.customer?[4,import("../../api/customer/index.js")]:[2,[]];case 2:return[4,(0,t.sent().apiGetOrders)({})];case 3:return[2,t.sent().data||[]]}})})}function et(e,n){return t(this,void 0,void 0,function(){var o,s,a,c,u,d,l,m=this;return r(this,function(f){switch(f.label){case 0:return[4,ht(e)];case 1:return f.sent(),e.customer?(o=n,!i.isPreview||o&&"orders"!==o?[3,3]:[4,tt(e)]):[2,null];case 2:(s=f.sent()).length&&(o=s[0].id),f.label=3;case 3:return[4,Promise.all([t(m,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[2,(0,t.sent().apiGetOrders)({orderId:o})]}})}),It(e),nt(e,{orderId:o})])];case 4:return a=f.sent(),c=a[0],u=a[2],c.isSuccess&&(null===(l=c.data)||void 0===l?void 0:l.length)?((d=c.data[0]).transactions=u,[2,d]):[2,null]}})})}function rt(e,n,i){return t(this,void 0,void 0,function(){var t,o,s,a;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiGetOrderByEmail)({email:n,orderNumber:i})];case 2:return(t=r.sent()).isSuccess&&t.data?(o=t.data,[4,Promise.all([It(e),nt(e,{orderId:o.id})])]):[2,null];case 3:return s=r.sent(),a=s[1],o.transactions=a,[2,o]}})})}function nt(e){return t(this,arguments,void 0,function(t,e){var n;return void 0===e&&(e={}),r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return n=t.sent().apiListOrderTransactions,e.orderId||e.checkoutId||e.id?[4,n({checkoutId:{eq:e.checkoutId},id:{eq:e.checkoutId},orderId:{eq:e.orderId}})]:[2,[]];case 2:return[2,t.sent().data||[]]}})})}function it(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[2,[]];case 1:return[4,(0,t.sent().apiListFavoriteProducts)()];case 2:return[2,t.sent().data||[]]}})})}function ot(e){return t(this,void 0,void 0,function(){var t,n,o,a,c;return r(this,function(r){switch(r.label){case 0:return[4,ct(e)];case 1:return 0===(t=r.sent()).length?[2,[]]:[4,import("../../api/product/index.js")];case 2:return[4,(0,r.sent().apiSearchProducts)({input:{productIdList:t.map(function(t){return t.productId}),priceListId:i.priceListId,salesChannelId:i.salesChannelId,perPage:100}})];case 3:return n=r.sent(),null===(a=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===a||a.forEach(function(t){t.selectedVariantValues=t.variants[0].variantValues}),[2,s((null===(c=null==n?void 0:n.data)||void 0===c?void 0:c.data)||[])]}})})}function st(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:if(!(null===(i=e.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveFavoriteProduct)({isFavorite:!0,productId:n})];case 2:return t=r.sent(),[4,import("../../../analytics/analytics-functions/addToWishlist.js")];case 3:return(0,r.sent().anl_addToWishlist)(n),t.isSuccess?[4,ct(e,!0)]:[3,5];case 4:r.sent(),r.label=5;case 5:return[2,t.data||!1]}})})}function at(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:if(!(null===(i=e.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveFavoriteProduct)({isFavorite:!1,productId:n})];case 2:return t=r.sent(),[4,import("../../../analytics/analytics-functions/addToWishlist.js")];case 3:return(0,r.sent().anl_addToWishlist)(n,!0),t.isSuccess?[4,ct(e,!0)]:[3,5];case 4:r.sent(),r.label=5;case 5:return[2,t.data||!1]}})})}function ct(e){return t(this,arguments,void 0,function(t,e){var n;return void 0===e&&(e=!1),r(this,function(r){switch(r.label){case 0:return[4,ht(t)];case 1:return r.sent(),t.customer?t._isFavoriteProductsLoaded&&!e?[3,3]:[4,it(t)]:[2,[]];case 2:n=r.sent(),t._favoriteProducts=n,t._isFavoriteProductsLoaded=!0,r.label=3;case 3:return[2,t._favoriteProducts]}})})}function ut(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){return[2,e._favoriteProducts.some(function(t){return t.productId===n})]})})}function dt(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return[4,Pt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiSubscribeToMarketingNotifications)({input:{email:n,captchaToken:e._captchaToken}})];case 3:return(t=r.sent()).isSuccess?(i=e.customer,window.localStorage.setItem(P,"true"),i?i.subscriptionStatus:e._visitorSubscribedEmail=!0,[4,import("../../../analytics/analytics-functions/createEmailSubscription.js")]):[3,5];case 4:(0,r.sent().anl_createEmailSubscription)(n),r.label=5;case 5:return[2,t]}})})}function lt(n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Pt(n)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiSaveCustomerFormData)({input:e(e({},i),{captchaToken:n._captchaToken})})];case 3:return(t=r.sent()).isSuccess?(window.localStorage.setItem(P,"true"),n.customer?n.customer.subscriptionStatus:n._visitorSubscribedEmail=!0,[4,import("../../../analytics/analytics-functions/createEmailSubscription.js")]):[3,5];case 4:(0,r.sent().anl_createEmailSubscription)(i.email),r.label=5;case 5:return[2,t.isSuccess]}})})}function mt(n,o){return t(this,void 0,void 0,function(){var t,s,a,c,u;return r(this,function(r){switch(r.label){case 0:if(t=i.customerReviewSettings,s=i.salesChannelId,a=i.getCurrentLocale(),!t)return[2];if(!(c=null===(u=n.customer)||void 0===u?void 0:u.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiCreateCustomerReview)({input:e(e({},o),{customerId:t.customerLoginRequired?c:void 0,salesChannelId:s||"",locale:a})})];case 2:return[2,r.sent().data]}})})}function ft(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiDeactivateCustomer)({password:n})];case 2:return[2,t.sent()];case 3:return[2]}})})}function pt(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiExportCustomerPersonalData)()];case 2:return[2,t.sent()];case 3:return[2]}})})}function vt(t){!function(t){if(d())return;t._customerConsentGranted=!0,window.localStorage.setItem(L,"true")}(t)}function ht(e){return t(this,void 0,void 0,function(){return r(this,function(t){return d()?[2]:[2,new Promise(function(t){var r=setInterval(function(){e._initialized&&(clearInterval(r),t(null))},100)})]})})}function _t(t){return new Promise(function(e){var r=setInterval(function(){t._captchaToken&&(clearInterval(r),e(null))},100)})}function wt(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiListCustomerAttribute)()];case 2:return t=r.sent(),e.customer&&(null===(n=e.customer.attributes)||void 0===n||n.forEach(function(e){var r,n,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.customerAttributeId}))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(n=e.customerAttribute)||void 0===n?void 0:n.options)||void 0===i?void 0:i.find(function(t){return t.id===e.customerAttributeOptionId}))||null)})),[2,t.data||[]]}})})}function gt(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return n.length?[4,import("../../api/checkout/index.js")]:[2,[]];case 1:return[4,(0,t.sent().apiListProductFile)({id:{in:n}})];case 2:return[2,t.sent().data||[]]}})})}function bt(e,n,i){return t(this,void 0,void 0,function(){var t,e,o,s,a;return r(this,function(r){switch(r.label){case 0:r.label=1;case 1:return r.trys.push([1,5,,6]),(t=n.orderLineItems.find(function(t){return t.variant.id===i.variantId}))?[4,import("../../api/customer/index.js")]:[3,4];case 2:return[4,(0,r.sent().apiGetDigitalProductFileDownloadUrl)(n.id,t.id)];case 3:e=r.sent(),(o=e.data)&&((s=document.createElement("a")).href=o,s.download=decodeURIComponent(i.name.split("/")[i.name.split("/").length-1])||"",s.click(),s.remove()),r.label=4;case 4:return[3,6];case 5:return a=r.sent(),console.error(a),[3,6];case 6:return[2]}})})}function It(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return e._refundSettings?[3,3]:[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiListOrderRefundSettings)({})];case 2:(t=r.sent()).isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.length)&&(e._refundSettings=t.data[0]),r.label=3;case 3:return[2]}})})}function St(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return d()||!e._token?[2]:[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiGetCustomer)()];case 2:return(t=r.sent()).data&&yt(e,t.data),[2]}})})}function yt(t,e){t.customer=e}function kt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return e._token?[4,import("../../api/customer/index.js")]:[2];case 1:return[4,(0,r.sent().apiRefreshToken)({token:e._token})];case 2:if((t=r.sent()).isSuccess&&t.data)xt(e,t.data.token,t.data.tokenExpiry);else{if(t.isCancelled||t.isNetworkError)return[2];console.log("refreshToken error",t),e._token=null,e._tokenExpiry=null,jt(e)}return[2]}})})}function xt(t,e,r){d()||(t._token=e,t._tokenExpiry=r,localStorage.setItem(E,e),localStorage.setItem(F,r+""),i.init({customerToken:e}),n.TOKEN=e)}function Tt(t){localStorage.removeItem(E),localStorage.removeItem(F),t._token=null,t._tokenExpiry=null}function jt(t){Tt(t),t.customer=null,t._favoriteProducts=[],t._isFavoriteProductsLoaded=!1,i.init({customerToken:""}),n.TOKEN="",Et(t)}function Et(t){t._captchaToken=null}function Ft(t,e){t._captchaToken=e}function Pt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),i.isCaptchaRequired()?(window.grecaptcha.execute(),[4,_t(e)]):[3,2];case 1:r.sent(),window.grecaptcha.reset(),r.label=2;case 2:return[3,4];case 3:return t=r.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}})})}function Ct(t,e){t._savedLastViewedProducts=l(t._lastViewedProducts),t._savedLastViewedProductsResponse=e}function Lt(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetLastViewedProducts)({customerId:e.customer.id})];case 2:return t=r.sent(),e._lastViewedProducts=(null===(n=l(t.data))||void 0===n?void 0:n.reverse())||[],[3,4];case 3:Nt(e),r.label=4;case 4:return[2,e._lastViewedProducts]}})})}function Nt(t){d()||(t._lastViewedProducts=Ot(),t._lastViewedProducts=l(t._lastViewedProducts).reverse())}function Ot(){if(d())return[];try{var t=window.localStorage.getItem(C);if(t)return JSON.parse(t)}catch(t){console.error(t)}return[]}function Rt(e,n,i){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?e._lastViewedProducts.find(function(t){return t.productId===n})?[2]:[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiSaveLastViewedProducts)({input:{customerId:e.customer.id,products:[{productId:n,variantId:i}]}})];case 2:return t.sent()&&e._lastViewedProducts.push({productId:n,variantId:i}),[3,4];case 3:e._lastViewedProducts=Ot(),e._lastViewedProducts=e._lastViewedProducts.filter(function(t){return t.productId!==n}),e._lastViewedProducts.push({productId:n,variantId:i}),e._lastViewedProducts=e._lastViewedProducts.slice(-20),function(t){d()||window.localStorage.setItem(C,JSON.stringify(t._lastViewedProducts))}(e),t.label=4;case 4:return[2]}})})}function At(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(d())return[2];r.label=1;case 1:return r.trys.push([1,5,,6]),(t=Ot()).length?[4,import("../../api/customer/index.js")]:[3,4];case 2:return[4,(0,r.sent().apiSaveLastViewedProducts)({input:{customerId:e.customer.id,products:t}})];case 3:r.sent()&&(d()||window.localStorage.removeItem(C)),r.label=4;case 4:return[3,6];case 5:return n=r.sent(),console.error(n),[3,6];case 6:return[2]}})})}function Vt(t){return t._customerConsentGranted}function Ut(t){d()||window.localStorage.removeItem(L)}function Dt(t){var e;return{addresses:null===(e=t.addresses)||void 0===e?void 0:e.map(function(t){return{addressLine1:t.addressLine1,addressLine2:t.addressLine2,city:t.city,company:t.company,country:t.country,createdAt:t.createdAt,deleted:t.deleted,district:t.district,firstName:t.firstName,id:t.id,identityNumber:t.identityNumber,isDefault:t.isDefault,lastName:t.lastName,phone:t.phone,postalCode:t.postalCode,region:t.region,state:t.state,taxNumber:t.taxNumber,taxOffice:t.taxOffice,title:t.title,updatedAt:t.updatedAt}}),attributes:t.attributes,birthDate:t.birthDate,firstName:t.firstName,gender:t.gender,lastName:t.lastName,phone:t.phone,phoneSubscriptionStatus:t.phoneSubscriptionStatus,smsSubscriptionStatus:t.smsSubscriptionStatus,subscriptionStatus:t.subscriptionStatus}}function Mt(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListEarningMethods)()];case 2:return[2,t.sent().data]}})})}function Bt(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,ht(e)];case 1:return r.sent(),(t=null===(n=u.cart)||void 0===n?void 0:n.id)?[4,import("../../api/loyalty/index.js")]:[2,[]];case 2:return[4,(0,r.sent().apiListSpendingMethodsByCartId)({cartId:t})];case 3:return[2,r.sent().data]}})})}function Gt(e){return t(this,void 0,void 0,function(){var t,n,i,o,s,a,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),[4,ht(e)];case 1:return r.sent(),t=null===(o=u.cart)||void 0===o?void 0:o.id,n=null===(c=null===(a=null===(s=u.cart)||void 0===s?void 0:s.loyaltyLines)||void 0===a?void 0:a[0])||void 0===c?void 0:c.loyaltySpendingMethodId,t&&n?[4,import("../../api/loyalty/index.js")]:[2];case 2:return[4,(0,r.sent().apiRemoveLoyaltyPointsFromCart)({cartId:t,loyaltySpendingMethodId:n})];case 3:return r.sent().isSuccess?[4,f()]:[3,5];case 4:r.sent(),r.label=5;case 5:return[3,7];case 6:return i=r.sent(),console.error(i),[3,7];case 7:return[2]}})})}function Wt(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,ht(e)];case 1:return r.sent(),Ht(e)?(t=null===(n=u.cart)||void 0===n?void 0:n.id,[4,import("../../api/loyalty/index.js")]):[2,null];case 2:return[4,(0,r.sent().apiGetLoyaltyCustomerInfo)({cartId:t})];case 3:return[2,r.sent().data||null]}})})}function qt(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListLoyaltyProgramTiers)()];case 2:return[2,t.sent().data]}})})}function Kt(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListLoyaltyProgramPointHistory)(n)];case 2:return[2,t.sent().data]}})})}function zt(n,i){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return(t=null===(n=u.cart)||void 0===n?void 0:n.id)?[4,import("../../api/loyalty/index.js")]:[2,null];case 1:return[4,(0,r.sent().apiUseLoyaltyPoints)({input:e(e({},i.input),{cartId:t})})];case 2:return[2,r.sent().data||null]}})})}function Ht(t){return!!t.customer}function Jt(t){return t._accountInfoForm||(t._accountInfoForm={},_(t._accountInfoForm)),t._accountInfoForm}function Xt(t){t._accountInfoForm=null}function Yt(t){return t._contactForm||(t._contactForm={},w(t._contactForm)),t._contactForm}function Qt(t){t._contactForm=null}function Zt(t){return t._couponCodeForm||(t._couponCodeForm={},g(t._couponCodeForm)),t._couponCodeForm}function $t(t){t._couponCodeForm=null}function te(t){return t._forgotPasswordForm||(t._forgotPasswordForm={},b(t._forgotPasswordForm)),t._forgotPasswordForm}function ee(t){t._forgotPasswordForm=null}function re(t){return t._loginForm||(t._loginForm={},I(t._loginForm)),t._loginForm}function ne(t){return t._smsLoginForm||(t._smsLoginForm={},T(t._smsLoginForm)),t._smsLoginForm}function ie(t){return t._verifyPhoneNumberForm||(t._verifyPhoneNumberForm={},j(t._verifyPhoneNumberForm)),t._verifyPhoneNumberForm}function oe(t){t._loginForm=null}function se(t){return t._newsletterSubscriptionForm||(t._newsletterSubscriptionForm={},S(t._newsletterSubscriptionForm)),t._newsletterSubscriptionForm}function ae(t){t._newsletterSubscriptionForm=null}function ce(t){return t._orderTrackingForm||(t._orderTrackingForm={},y(t._orderTrackingForm)),t._orderTrackingForm}function ue(t){t._orderTrackingForm=null}function de(t){return t._recoverPasswordForm||(t._recoverPasswordForm={},k(t._recoverPasswordForm)),t._recoverPasswordForm}function le(t){t._recoverPasswordForm=null}function me(t){return t._registerForm||(t._registerForm={},x(t._registerForm)),t._registerForm}function fe(t){t._registerForm=null}function pe(t){var e={};return v(e),o(e)}function ve(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return"ORDER_DETAIL"!==c.currentPageType||"undefined"==typeof window?[3,4]:(t=a.getCurrentPath().split("/").pop(),!i.isPreview||t&&"orders"!==t?[3,2]:[4,tt(e)]);case 1:(n=r.sent()).length&&(t=n[0].id),r.label=2;case 2:return t?[4,et(e,t)]:[3,4];case 3:return[2,r.sent()];case 4:return[2]}})})}function he(t){try{window.openIkasStorefrontWidget()}catch(t){console.error("Failed to open ikas storefront widget",t)}}function _e(t){try{window.closeIkasStorefrontWidget()}catch(t){console.error("Failed to close ikas storefront widget",t)}}export{q as activateCustomer,st as addProductToFavorites,O as canCustomerCreateEmailSubscription,Y as checkEmail,Xt as clearAccountInfoForm,Qt as clearContactForm,$t as clearCouponCodeForm,ee as clearForgotPasswordForm,oe as clearLoginForm,ae as clearNewsletterSubscriptionForm,ue as clearOrderTrackingForm,le as clearRecoverPasswordForm,fe as clearRegisterForm,_e as closeIkasStorefrontWidget,dt as createEmailSubscription,Wt as cs_getLoyaltyCustomerInfo,Mt as cs_listEarningMethods,Kt as cs_listLoyaltyProgramPointHistory,qt as cs_listLoyaltyProgramTiers,Bt as cs_listSpendingMethodsByCartId,Gt as cs_removeLoyaltyPointsFromCart,zt as cs_useLoyaltyPoints,B as customerLogin,Rt as customerStore_onProductView,R as customerToAnalyticsCustomer,ft as deactivateCustomer,D as deleteCustomerAddress,pt as exportCustomerPersonalData,Q as forgotPassword,Jt as getAccountInfoForm,Yt as getContactForm,Zt as getCouponCodeForm,wt as getCustomerAttributes,Vt as getCustomerConsentGranted,bt as getDigitalProductFileDownloadUrl,pe as getEmptyAddressForm,ot as getFavoriteProducts,it as getFavoriteProductsIds,te as getForgotPasswordForm,Lt as getLastViewedProducts,re as getLoginForm,se as getNewsletterSubscriptionForm,et as getOrder,rt as getOrderByEmail,ve as getOrderDetailsOfPage,gt as getOrderProductFiles,It as getOrderRefundSettings,ce as getOrderTrackingForm,nt as getOrderTransactions,tt as getOrders,de as getRecoverPasswordForm,me as getRegisterForm,ne as getSmsLoginForm,ie as getVerifyPhoneNumberForm,vt as handleCustomerConsentGrant,V as handleSocialLogin,Ht as hasCustomer,N as initCustomerStore,ut as isFavoriteProduct,G as logout,he as openIkasStorefrontWidget,Z as recoverPassword,M as refundOrder,W as register,Ut as removeCustomerConsent,at as removeProductFromFavorites,K as resendCustomerActivationMail,J as resendCustomerPhoneVerificationCode,X as saveContactForm,$ as saveCustomer,lt as saveCustomerFormData,mt as sendReview,Ft as setCaptchaToken,Ct as setSavedLastViewedProductsResponse,A as socialLogin,U as socialLoginToken,z as validateCustomerPhoneVerificationCode,H as validateOTPCode,_t as waitForCaptchaTokenInit,ht as waitForCustomerStoreInit};
1
+ import{__awaiter as t,__assign as e,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import n from"../../../packages/storefront-api-client/src/config/index.js";import"../../../packages/storefront-api-client/src/utils/api.js";import'./../../../ext/isomorphic-fetch/fetch-npm-node.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import{makeAutoObservable as o,observable as s}from'./../../../ext/mobx/dist/mobx.esm.js';import{Router as a}from"../../../router/index.js";import{baseStore as c}from"../../../stores/base/index.js";import{cartStore as u}from"../../../stores/cart/index.js";import{isServer as d,cloneDeep as l}from"../../../utils/helper.js";import'./../../../ext/lodash/sortBy.js';import"../../../stores/customer/index.js";import"../../../i18n/index.js";import'./../../../ext/lodash/_isFlattenable.js';import{removeCart as m,getCart as f}from"../cart/index.js";import{isCustomerSubscribed as p}from"../../models/customer/index.js";import{initAddressForm as v}from"../../models/validator/address/index.js";import{getOrderLineItemRefundQuantity as h}from"../../models/order/line-item/index.js";import"../../models/product-list/index.js";import{initAccountInfoForm as _}from"../../models/validator/account-info/index.js";import{initContactForm as w}from"../../models/validator/contact-form/index.js";import{initCouponCodeForm as S}from"../../models/validator/coupon-code-form/index.js";import{initDeactivateCustomerForm as I}from"../../models/validator/deactivate-customer/index.js";import{initForgotPasswordForm as g}from"../../models/validator/forgot-password/index.js";import{initLoginForm as b}from"../../models/validator/login/index.js";import{initNewsletterSubscriptionForm as E}from"../../models/validator/newsletter-subscription/index.js";import{initOrderTrackingForm as y}from"../../models/validator/order-tracking/index.js";import{initRecoverPasswordForm as k}from"../../models/validator/recover-password/index.js";import{initRegisterForm as x}from"../../models/validator/register/index.js";import{initSmsLoginForm as C}from"../../models/validator/sms-login/index.js";import{initVerifyPhoneNumberForm as T}from"../../models/validator/verify-phone-number/index.js";var j="customerToken",L="customerTokenExpiry",P="customerEmailSubscription",F="lastViewedProducts",R="customerConsent";function O(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return Bt(e),Yt(e),te(e),[4,Vt(e)];case 1:return t.sent(),[4,Dt(e)];case 2:return t.sent(),e._initialized=!0,[4,yt(e)];case 3:return t.sent(),e.customer?[4,import("../../../analytics/analytics-functions/customerVisit.js")]:[3,5];case 4:(0,t.sent().anl_customerVisit)(),t.label=5;case 5:return[2]}})})}function N(e,n){return t(this,arguments,void 0,function(t,e,n){var i,o;return void 0===n&&(n=[]),r(this,function(r){switch(r.label){case 0:if(Bt(t),Yt(t),te(t),!(null==e?void 0:e.customer)||!t._token)return[3,4];if(Mt(t,e.customer),t._favoriteProducts=e.favoriteProducts||[],t._isFavoriteProductsLoaded=!0,!(i=n.filter(function(t){return!(t in e.customer)})).length)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Dt(t)];case 2:return r.sent(),[3,4];case 3:return o=r.sent(),console.error("[seedCustomerSession] snapshot lacks [".concat(i.join(", "),"] and the fallback fetch failed — ")+"keeping the partial customer:",o),[3,4];case 4:return t._initialized=!0,[2]}})})}function A(t){qt(t)}function U(t){return!!t.customer&&(!(p(t.customer)||d()||t._visitorSubscribedEmail)&&!window.localStorage.getItem(P))}function D(t){return e(e({},t.customer),{consentGranted:t._customerConsentGranted})}function M(e,n){return t(this,void 0,void 0,function(){var t,e,o;return r(this,function(r){switch(r.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",e="".concat(import.meta.env.VITE_BASE_URL,"/ms/").concat(n,"/login/authenticate?redirect=").concat(t),[4,fetch(e,{headers:{"x-api-key":i.apiKey||"","x-sfid":i.storefrontId||"","x-sfrid":i.storefrontRoutingId||""}})]);case 1:return[4,r.sent().json()];case 2:return o=r.sent(),a.navigate(o.redirectUrl),[2]}})})}function V(e){return t(this,void 0,void 0,function(){var t,n,i,o,s;return r(this,function(r){switch(r.label){case 0:return t={status:"fail"},n=new URLSearchParams(window.location.search),i=n.get("socialLoginStatus"),o=n.get("socialLoginToken"),"success"===i&&o?[4,G(e,o)]:[3,2];case 1:return r.sent()?(t.status="success",[2,t]):[2,t];case 2:return s=n.get("socialLoginError"),t.message=s||void 0,[2,t]}})})}function G(e,n){return t(this,void 0,void 0,function(){var t,i,o;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSocialLogin)({code:n})];case 2:return(null==(t=r.sent())?void 0:t.isSuccess)&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(Gt(e,t.data.token,t.data.tokenExpiry),Mt(e,t.data.customer),[4,import("../../../analytics/analytics-functions/customerLogin.js")]):[2,!1];case 3:return i=r.sent().anl_customerLogin,e.customer&&i(),[2,!0]}})})}var B="miles_smiles",W="MILES_SMILES",q="c8e4b1a0-5d3f-4a9e-8b2c-1f6d9e0a7c31",z="milesSmilesStatus",K="milesSmilesError";function X(t){try{return new URL(t).searchParams.get(K)}catch(t){return null}}function H(t){var e=function(t){try{return new URL(t).searchParams.get("redirectUrl")}catch(t){return null}}(t);if(!e)return window.location.href=t,Promise.resolve({isSuccess:!0});var r=function(t){try{return new URL(t).searchParams.get("transactionId")}catch(t){return null}}(e);return new Promise(function(n){var i,o=!1,s=function(t){o||(o=!0,window.removeEventListener("message",a),i&&window.clearInterval(i),n(t))},a=function(t){var n;try{n="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){return}if(n&&!0===n.isSuccess){var i={transactionId:r,token:n.token,memberId:n.ffid||n.memberId||n.memberID,shortTokenExpireMinute:n.tokenExpireMinute,longToken:n.longToken,longTokenExpireMinute:n.longTokenExpireMinute};if(!i.memberId||!i.token)return console.error("Miles&Smiles: missing token or memberId in popup message"),void s({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"});!function(t,e){var r=document.createElement("form");r.method="POST",r.action=t,r.style.display="none";for(var n=0,i=[["transactionId",e.transactionId||""],["token",e.token||""],["memberId",e.memberId||""],["shortTokenExpireMinute",null!=e.shortTokenExpireMinute?String(e.shortTokenExpireMinute):""],["longToken",e.longToken||""],["longTokenExpireMinute",null!=e.longTokenExpireMinute?String(e.longTokenExpireMinute):""]];n<i.length;n++){var o=i[n],s=o[0],a=o[1],c=document.createElement("input");c.type="hidden",c.name=s,c.value=a,r.appendChild(c)}document.body.appendChild(r),r.submit()}(e,i);try{null==c||c.close()}catch(t){}s({isSuccess:!0})}};window.addEventListener("message",a);var c=window.open(t,"mslogin","width=480,height=720");if(!c)return window.removeEventListener("message",a),window.location.href=t,void n({isSuccess:!0});i=window.setInterval(function(){c.closed&&s({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"})},500)})}function J(e,n){return t(this,void 0,void 0,function(){var t,o,s,a,c;return r(this,function(r){switch(r.label){case 0:if(d())return[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];if(!e.customer||!e._token)return[2,{isSuccess:!1,errorCode:"AUTHORIZATION_REQUIRED"}];t=function(t){return!!t&&t.startsWith("/")&&!t.startsWith("//")&&!t.includes("://")&&!t.includes("@")}(n)?n:"",o="".concat(import.meta.env.VITE_BASE_URL,"/ms/").concat(B,"/bind/authenticate?redirect=").concat(encodeURIComponent(t)),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,fetch(o,{headers:{authorization:"Bearer ".concat(e._token),"x-api-key":i.apiKey||"","x-sfid":i.storefrontId||"","x-sfrid":i.storefrontRoutingId||""}})];case 2:return(a=r.sent()).redirected&&a.url?(window.location.href=a.url,[2,{isSuccess:!1,errorCode:X(a.url)}]):a.ok?[4,a.json()]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 3:return c=r.sent(),s=null==c?void 0:c.redirectUrl,[3,5];case 4:return r.sent(),[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 5:return s?[2,H(s)]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}]}})})}function Y(t){if(void 0===t&&(t=!0),d())return null;var e=new URL(window.location.href),r=e.searchParams.get(z);if("success"!==r&&"fail"!==r)return null;var n=e.searchParams.get(K);return t&&(e.searchParams.delete(z),e.searchParams.delete(K),window.history.replaceState(window.history.state,"",e.pathname+e.search+e.hash)),{status:r,errorCode:n}}function Q(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[2,(0,t.sent().apiGetExternalAccountLink)({provider:B})]}})})}function Z(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[2,(0,t.sent().apiUnlinkExternalAccount)({provider:B})]}})})}function $(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[2,(0,t.sent().apiGetMilesSmilesDetails)()]}})})}function tt(t){return t.paymentGatewayCode===W||t.paymentGatewayId===q}function et(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return(t=l(e.customer))&&t.addresses?-1===(i=t.addresses.findIndex(function(t){return t.id===n.id}))?[2,!1]:(t.addresses.splice(i,1),[4,vt(e,t)]):[2,!1];case 1:return[2,r.sent()]}})})}function rt(e,n,i){return t(this,void 0,void 0,function(){var t,e,o;return r(this,function(r){switch(r.label){case 0:r.label=1;case 1:return r.trys.push([1,4,,5]),t=[],n.orderLineItems.map(function(e){var r=h(e);r&&(null==t||t.push({orderLineItemId:e.id,quantity:r}))}),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiCreateOrderRefundRequest)({input:{email:i,orderId:n.id,orderLineItems:t}})];case 3:return(e=r.sent()).isSuccess&&e.data?(Object.entries(e.data).forEach(function(t){var e=t[0],r=t[1];n[e]=r}),[2,!0]):[3,5];case 4:return o=r.sent(),console.error(o),[3,5];case 5:return[2,!1]}})})}function nt(e,n,i,o){return t(this,void 0,void 0,function(){var t,s;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiLogin)({email:n,password:i,phone:o,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),t&&t.isSuccess&&t.data?(s=t.data,Gt(e,s.token,s.tokenExpiry),s.customer&&Mt(e,s.customer),e.customer?[4,import("../../../analytics/analytics-functions/customerLogin.js")]:[3,5]):[3,6];case 4:(0,r.sent().anl_customerLogin)(),r.label=5;case 5:return $t(e),[2,{isSuccess:!0,errorCodes:[],otpSend:s.otpSend,flowId:s.flowId}];case 6:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["CUSTOMER_ACCOUNT_DISABLED","EMAIL_IS_NOT_VERIFIED","CUSTOMER_NOT_FOUND","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED","WRONG_PASSWORD"].includes(t)?t:"UNKOWN"})}]}})})}function it(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return qt(e),m(u),[4,import("../../../analytics/analytics-functions/customerLogout.js")];case 1:return(0,t.sent().anl_customerLogout)(),[2]}})})}function ot(e,n,i,o,s,a,c,u,d){return t(this,void 0,void 0,function(){var t,l;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiRegister)({email:o,password:s,firstName:n,lastName:i,isAcceptMarketing:a,attributes:c,captchaToken:e._captchaToken,phone:u,flowId:d})];case 3:return t=r.sent(),zt(e),t&&t.isSuccess&&(null===(l=t.data)||void 0===l?void 0:l.customer)?(Gt(e,t.data.token,t.data.tokenExpiry),Mt(e,t.data.customer),$t(e),[4,import("../../../analytics/analytics-functions/completeRegistration.js")]):[3,5];case 4:return(0,r.sent().anl_completeRegistration)(D(e)),[2,{isSuccess:!0,errorCodes:[]}];case 5:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["EMAIL_IS_NOT_VERIFIED","CUSTOMER_EMAIL_ALREADY_EXISTS","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED"].includes(t)?t:"UNKOWN"})}]}})})}function st(e){return t(this,void 0,void 0,function(){var t,n,i;return r(this,function(r){switch(r.label){case 0:return t=new URLSearchParams(window.location.search),(n=t.get("token"))?[4,Xt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiActivateCustomer)({token:n,captchaToken:e._captchaToken})];case 3:return i=r.sent(),zt(e),[2,i.isSuccess];case 4:return[2,!1]}})})}function at(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return n?[4,Xt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiResendCustomerActivationMail)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),[2,t.isSuccess];case 4:return[2,!1]}})})}function ct(e,n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return n?[4,Xt(e)]:[3,4];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiValidateCustomerPhoneVerificationCode)({verificationCode:n,otpInfo:i,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),[2,!(!t.isSuccess||!t.data)&&t.data];case 4:return[2,!1]}})})}function ut(n,i,o){return t(this,void 0,void 0,function(){var t,s,a,c,u;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiValidateOTPCode)({verificationCode:i,otpInfo:o,captchaToken:n._captchaToken})];case 2:return t=r.sent(),zt(n),t&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(Gt(n,t.data.token,t.data.tokenExpiry),Mt(n,t.data.customer),$t(n),[4,import("../../../analytics/analytics-functions/completeRegistration.js")]):[3,4];case 3:return(0,r.sent().anl_completeRegistration)(D(n)),[2,{isSuccess:!0,errorCodes:[]}];case 4:return t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:t.errorCodes.some(function(t){return"B2B_CUSTOMER_ACCOUNT_DISABLED"===t})?[4,import("../../../analytics/analytics-functions/completeRegistration.js")]:[3,6];case 5:(0,r.sent().anl_completeRegistration)(e(e({},D(n)),{notificationsAccepted:null}),!0),r.label=6;case 6:return[2,{isSuccess:!1,errorCodes:t.errorCodes.map(function(t){return["EMAIL_IS_NOT_VERIFIED","CUSTOMER_EMAIL_ALREADY_EXISTS","B2B_CUSTOMER_ACCOUNT_DISABLED","PHONE_IS_NOT_VERIFIED"].includes(t)?t:"UNKOWN"})}];case 7:return r.sent(),[2,{isSuccess:!1,errorCodes:[]}];case 8:return[2]}})})}function dt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(e){switch(e.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,e.sent().apiResendCustomerPhoneVerificationCode)()];case 2:return[2,!(!(t=e.sent()).isSuccess||!t.data)&&t.data]}})})}function lt(n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,import("../../../analytics/analytics-functions/contactForm.js")];case 1:return(0,r.sent().anl_contactForm)(i),[4,Xt(n)];case 2:return r.sent(),[4,import("../../api/customer/index.js")];case 3:return[4,(0,r.sent().apiSendContactFormToMerchant)(e(e({},i),{captchaToken:n._captchaToken}))];case 4:return t=r.sent(),zt(n),[2,t.isSuccess]}})})}function mt(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiCheckEmail)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),[2,!!t.isSuccess&&!!(null===(i=t.data)||void 0===i?void 0:i.exists)]}})})}function ft(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiForgotPassword)({email:n,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),[2,!!t.isSuccess&&t.data]}})})}function pt(e,n,i,o){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiRecoverPassword)({password:n,passwordAgain:i,token:o,captchaToken:e._captchaToken})];case 3:return t=r.sent(),zt(e),[2,t.isSuccess]}})})}function vt(e,n){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveCustomer)({input:ne(n)})];case 2:return(t=r.sent()).isSuccess&&t.data?(Mt(e,t.data),[2,!0]):[2,!1]}})})}function ht(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,Ft(e)];case 1:return t.sent(),e.customer?[4,import("../../api/customer/index.js")]:[2,[]];case 2:return[4,(0,t.sent().apiGetOrders)({})];case 3:return[2,t.sent().data||[]]}})})}function _t(e,n){return t(this,void 0,void 0,function(){var o,s,a,c,u,d,l,m=this;return r(this,function(f){switch(f.label){case 0:return[4,Ft(e)];case 1:return f.sent(),e.customer?(o=n,!i.isPreview||o&&"orders"!==o?[3,3]:[4,ht(e)]):[2,null];case 2:(s=f.sent()).length&&(o=s[0].id),f.label=3;case 3:return[4,Promise.all([t(m,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[2,(0,t.sent().apiGetOrders)({orderId:o})]}})}),Ut(e),St(e,{orderId:o})])];case 4:return a=f.sent(),c=a[0],u=a[2],c.isSuccess&&(null===(l=c.data)||void 0===l?void 0:l.length)?((d=c.data[0]).transactions=u,[2,d]):[2,null]}})})}function wt(e,n,i){return t(this,void 0,void 0,function(){var t,o,s,a;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiGetOrderByEmail)({email:n,orderNumber:i})];case 2:return(t=r.sent()).isSuccess&&t.data?(o=t.data,[4,Promise.all([Ut(e),St(e,{orderId:o.id})])]):[2,null];case 3:return s=r.sent(),a=s[1],o.transactions=a,[2,o]}})})}function St(e){return t(this,arguments,void 0,function(t,e){var n;return void 0===e&&(e={}),r(this,function(t){switch(t.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return n=t.sent().apiListOrderTransactions,e.orderId||e.checkoutId||e.id?[4,n({checkoutId:{eq:e.checkoutId},id:{eq:e.checkoutId},orderId:{eq:e.orderId}})]:[2,[]];case 2:return[2,t.sent().data||[]]}})})}function It(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[2,[]];case 1:return[4,(0,t.sent().apiListFavoriteProducts)()];case 2:return[2,t.sent().data||[]]}})})}function gt(e){return t(this,void 0,void 0,function(){var t,n,o,a,c;return r(this,function(r){switch(r.label){case 0:return[4,yt(e)];case 1:return 0===(t=r.sent()).length?[2,[]]:[4,import("../../api/product/index.js")];case 2:return[4,(0,r.sent().apiSearchProducts)({input:{productIdList:t.map(function(t){return t.productId}),priceListId:i.priceListId,salesChannelId:i.salesChannelId,perPage:100}})];case 3:return n=r.sent(),null===(a=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===a||a.forEach(function(t){t.selectedVariantValues=t.variants[0].variantValues}),[2,s((null===(c=null==n?void 0:n.data)||void 0===c?void 0:c.data)||[])]}})})}function bt(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:if(!(null===(i=e.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveFavoriteProduct)({isFavorite:!0,productId:n})];case 2:return t=r.sent(),[4,import("../../../analytics/analytics-functions/addToWishlist.js")];case 3:return(0,r.sent().anl_addToWishlist)(n),t.isSuccess?[4,yt(e,!0)]:[3,5];case 4:r.sent(),r.label=5;case 5:return[2,t.data||!1]}})})}function Et(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:if(!(null===(i=e.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiSaveFavoriteProduct)({isFavorite:!1,productId:n})];case 2:return t=r.sent(),[4,import("../../../analytics/analytics-functions/addToWishlist.js")];case 3:return(0,r.sent().anl_addToWishlist)(n,!0),t.isSuccess?[4,yt(e,!0)]:[3,5];case 4:r.sent(),r.label=5;case 5:return[2,t.data||!1]}})})}function yt(e){return t(this,arguments,void 0,function(t,e){var n;return void 0===e&&(e=!1),r(this,function(r){switch(r.label){case 0:return[4,Ft(t)];case 1:return r.sent(),t.customer?t._isFavoriteProductsLoaded&&!e?[3,3]:[4,It(t)]:[2,[]];case 2:n=r.sent(),t._favoriteProducts=n,t._isFavoriteProductsLoaded=!0,r.label=3;case 3:return[2,t._favoriteProducts]}})})}function kt(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){return[2,e._favoriteProducts.some(function(t){return t.productId===n})]})})}function xt(e,n){return t(this,void 0,void 0,function(){var t,i;return r(this,function(r){switch(r.label){case 0:return[4,Xt(e)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiSubscribeToMarketingNotifications)({input:{email:n,captchaToken:e._captchaToken}})];case 3:return(t=r.sent()).isSuccess?(i=e.customer,window.localStorage.setItem(P,"true"),i?i.subscriptionStatus:e._visitorSubscribedEmail=!0,[4,import("../../../analytics/analytics-functions/createEmailSubscription.js")]):[3,5];case 4:(0,r.sent().anl_createEmailSubscription)(n),r.label=5;case 5:return[2,t]}})})}function Ct(n,i){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,Xt(n)];case 1:return r.sent(),[4,import("../../api/customer/index.js")];case 2:return[4,(0,r.sent().apiSaveCustomerFormData)({input:e(e({},i),{captchaToken:n._captchaToken})})];case 3:return(t=r.sent()).isSuccess?(window.localStorage.setItem(P,"true"),n.customer?n.customer.subscriptionStatus:n._visitorSubscribedEmail=!0,[4,import("../../../analytics/analytics-functions/createEmailSubscription.js")]):[3,5];case 4:(0,r.sent().anl_createEmailSubscription)(i.email),r.label=5;case 5:return[2,t.isSuccess]}})})}function Tt(n,o){return t(this,void 0,void 0,function(){var t,s,a,c,u;return r(this,function(r){switch(r.label){case 0:if(t=i.customerReviewSettings,s=i.salesChannelId,a=i.getCurrentLocale(),!t)return[2];if(!(c=null===(u=n.customer)||void 0===u?void 0:u.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiCreateCustomerReview)({input:e(e({},o),{customerId:t.customerLoginRequired?c:void 0,salesChannelId:s||"",locale:a})})];case 2:return[2,r.sent().data]}})})}function jt(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiDeactivateCustomer)({password:n})];case 2:return[2,t.sent()];case 3:return[2]}})})}function Lt(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiExportCustomerPersonalData)()];case 2:return[2,t.sent()];case 3:return[2]}})})}function Pt(t){!function(t){if(d())return;t._customerConsentGranted=!0,window.localStorage.setItem(R,"true")}(t)}function Ft(e){return t(this,void 0,void 0,function(){return r(this,function(t){return d()||e._initialized?[2]:[2,new Promise(function(t){var r=setInterval(function(){e._initialized&&(clearInterval(r),t(null))},100)})]})})}function Rt(t){return new Promise(function(e){var r=setInterval(function(){t._captchaToken&&(clearInterval(r),e(null))},100)})}function Ot(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiListCustomerAttribute)()];case 2:return t=r.sent(),e.customer&&(null===(n=e.customer.attributes)||void 0===n||n.forEach(function(e){var r,n,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.customerAttributeId}))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(n=e.customerAttribute)||void 0===n?void 0:n.options)||void 0===i?void 0:i.find(function(t){return t.id===e.customerAttributeOptionId}))||null)})),[2,t.data||[]]}})})}function Nt(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return n.length?[4,import("../../api/checkout/index.js")]:[2,[]];case 1:return[4,(0,t.sent().apiListProductFile)({id:{in:n}})];case 2:return[2,t.sent().data||[]]}})})}function At(e,n,i){return t(this,void 0,void 0,function(){var t,e,o,s,a;return r(this,function(r){switch(r.label){case 0:r.label=1;case 1:return r.trys.push([1,5,,6]),(t=n.orderLineItems.find(function(t){return t.variant.id===i.variantId}))?[4,import("../../api/customer/index.js")]:[3,4];case 2:return[4,(0,r.sent().apiGetDigitalProductFileDownloadUrl)(n.id,t.id)];case 3:e=r.sent(),(o=e.data)&&((s=document.createElement("a")).href=o,s.download=decodeURIComponent(i.name.split("/")[i.name.split("/").length-1])||"",s.click(),s.remove()),r.label=4;case 4:return[3,6];case 5:return a=r.sent(),console.error(a),[3,6];case 6:return[2]}})})}function Ut(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return e._refundSettings?[3,3]:[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiListOrderRefundSettings)({})];case 2:(t=r.sent()).isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.length)&&(e._refundSettings=t.data[0]),r.label=3;case 3:return[2]}})})}function Dt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return d()||!e._token?[2]:[4,import("../../api/customer/index.js")];case 1:return[4,(0,r.sent().apiGetCustomer)()];case 2:return(t=r.sent()).data&&Mt(e,t.data),[2]}})})}function Mt(t,e){t.customer=e}function Vt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return e._token?[4,import("../../api/customer/index.js")]:[2];case 1:return[4,(0,r.sent().apiRefreshToken)({token:e._token})];case 2:if((t=r.sent()).isSuccess&&t.data)Gt(e,t.data.token,t.data.tokenExpiry);else{if(t.isCancelled||t.isNetworkError)return[2];console.log("refreshToken error",t),e._token=null,e._tokenExpiry=null,qt(e)}return[2]}})})}function Gt(t,e,r){d()||(t._token=e,t._tokenExpiry=r,localStorage.setItem(j,e),localStorage.setItem(L,r+""),i.init({customerToken:e}),n.TOKEN=e)}function Bt(t){if(!d()){var e=localStorage.getItem(j),r=localStorage.getItem(L);e&&r?Gt(t,e,parseInt(r)):Wt(t)}}function Wt(t){localStorage.removeItem(j),localStorage.removeItem(L),t._token=null,t._tokenExpiry=null}function qt(t){Wt(t),t.customer=null,t._favoriteProducts=[],t._isFavoriteProductsLoaded=!1,i.init({customerToken:""}),n.TOKEN="",zt(t)}function zt(t){t._captchaToken=null}function Kt(t,e){t._captchaToken=e}function Xt(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),i.isCaptchaRequired()?(window.grecaptcha.execute(),[4,Rt(e)]):[3,2];case 1:r.sent(),window.grecaptcha.reset(),r.label=2;case 2:return[3,4];case 3:return t=r.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}})})}function Ht(t,e){t._savedLastViewedProducts=l(t._lastViewedProducts),t._savedLastViewedProductsResponse=e}function Jt(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return e.customer?[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetLastViewedProducts)({customerId:e.customer.id})];case 2:return t=r.sent(),e._lastViewedProducts=(null===(n=l(t.data))||void 0===n?void 0:n.reverse())||[],[3,4];case 3:Yt(e),r.label=4;case 4:return[2,e._lastViewedProducts]}})})}function Yt(t){d()||(t._lastViewedProducts=Qt(),t._lastViewedProducts=l(t._lastViewedProducts).reverse())}function Qt(){if(d())return[];try{var t=window.localStorage.getItem(F);if(t)return JSON.parse(t)}catch(t){console.error(t)}return[]}function Zt(e,n,i){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.customer?e._lastViewedProducts.find(function(t){return t.productId===n})?[2]:[4,import("../../api/customer/index.js")]:[3,3];case 1:return[4,(0,t.sent().apiSaveLastViewedProducts)({input:{customerId:e.customer.id,products:[{productId:n,variantId:i}]}})];case 2:return t.sent()&&e._lastViewedProducts.push({productId:n,variantId:i}),[3,4];case 3:e._lastViewedProducts=Qt(),e._lastViewedProducts=e._lastViewedProducts.filter(function(t){return t.productId!==n}),e._lastViewedProducts.push({productId:n,variantId:i}),e._lastViewedProducts=e._lastViewedProducts.slice(-20),function(t){d()||window.localStorage.setItem(F,JSON.stringify(t._lastViewedProducts))}(e),t.label=4;case 4:return[2]}})})}function $t(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:if(d())return[2];r.label=1;case 1:return r.trys.push([1,5,,6]),(t=Qt()).length?[4,import("../../api/customer/index.js")]:[3,4];case 2:return[4,(0,r.sent().apiSaveLastViewedProducts)({input:{customerId:e.customer.id,products:t}})];case 3:r.sent()&&(d()||window.localStorage.removeItem(F)),r.label=4;case 4:return[3,6];case 5:return n=r.sent(),console.error(n),[3,6];case 6:return[2]}})})}function te(t){d()||(t._customerConsentGranted=!!window.localStorage.getItem(R))}function ee(t){return t._customerConsentGranted}function re(t){d()||window.localStorage.removeItem(R)}function ne(t){var e;return{addresses:null===(e=t.addresses)||void 0===e?void 0:e.map(function(t){return{addressLine1:t.addressLine1,addressLine2:t.addressLine2,city:t.city,company:t.company,country:t.country,createdAt:t.createdAt,deleted:t.deleted,district:t.district,firstName:t.firstName,id:t.id,identityNumber:t.identityNumber,isDefault:t.isDefault,lastName:t.lastName,phone:t.phone,postalCode:t.postalCode,region:t.region,state:t.state,taxNumber:t.taxNumber,taxOffice:t.taxOffice,title:t.title,updatedAt:t.updatedAt}}),attributes:t.attributes,birthDate:t.birthDate,firstName:t.firstName,gender:t.gender,lastName:t.lastName,phone:t.phone,phoneSubscriptionStatus:t.phoneSubscriptionStatus,smsSubscriptionStatus:t.smsSubscriptionStatus,subscriptionStatus:t.subscriptionStatus}}function ie(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListEarningMethods)()];case 2:return[2,t.sent().data]}})})}function oe(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,Ft(e)];case 1:return r.sent(),(t=null===(n=u.cart)||void 0===n?void 0:n.id)?[4,import("../../api/loyalty/index.js")]:[2,[]];case 2:return[4,(0,r.sent().apiListSpendingMethodsByCartId)({cartId:t})];case 3:return[2,r.sent().data]}})})}function se(e){return t(this,void 0,void 0,function(){var t,n,i,o,s,a,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),[4,Ft(e)];case 1:return r.sent(),t=null===(o=u.cart)||void 0===o?void 0:o.id,n=null===(c=null===(a=null===(s=u.cart)||void 0===s?void 0:s.loyaltyLines)||void 0===a?void 0:a[0])||void 0===c?void 0:c.loyaltySpendingMethodId,t&&n?[4,import("../../api/loyalty/index.js")]:[2];case 2:return[4,(0,r.sent().apiRemoveLoyaltyPointsFromCart)({cartId:t,loyaltySpendingMethodId:n})];case 3:return r.sent().isSuccess?[4,f()]:[3,5];case 4:r.sent(),r.label=5;case 5:return[3,7];case 6:return i=r.sent(),console.error(i),[3,7];case 7:return[2]}})})}function ae(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return[4,Ft(e)];case 1:return r.sent(),le(e)?(t=null===(n=u.cart)||void 0===n?void 0:n.id,[4,import("../../api/loyalty/index.js")]):[2,null];case 2:return[4,(0,r.sent().apiGetLoyaltyCustomerInfo)({cartId:t})];case 3:return[2,r.sent().data||null]}})})}function ce(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListLoyaltyProgramTiers)()];case 2:return[2,t.sent().data]}})})}function ue(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../api/loyalty/index.js")];case 1:return[4,(0,t.sent().apiListLoyaltyProgramPointHistory)(n)];case 2:return[2,t.sent().data]}})})}function de(n,i){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return(t=null===(n=u.cart)||void 0===n?void 0:n.id)?[4,import("../../api/loyalty/index.js")]:[2,null];case 1:return[4,(0,r.sent().apiUseLoyaltyPoints)({input:e(e({},i.input),{cartId:t})})];case 2:return[2,r.sent().data||null]}})})}function le(t){return!!t.customer}function me(t){return t._accountInfoForm||(t._accountInfoForm={},_(t._accountInfoForm)),t._accountInfoForm}function fe(t){t._accountInfoForm=null}function pe(t){return t._contactForm||(t._contactForm={},w(t._contactForm)),t._contactForm}function ve(t){t._contactForm=null}function he(t){return t._couponCodeForm||(t._couponCodeForm={},S(t._couponCodeForm)),t._couponCodeForm}function _e(t){t._couponCodeForm=null}function we(t){return t._deactivateCustomerForm||(t._deactivateCustomerForm={},I(t._deactivateCustomerForm)),t._deactivateCustomerForm}function Se(t){t._deactivateCustomerForm=null}function Ie(t){return t._forgotPasswordForm||(t._forgotPasswordForm={},g(t._forgotPasswordForm)),t._forgotPasswordForm}function ge(t){t._forgotPasswordForm=null}function be(t){return t._loginForm||(t._loginForm={},b(t._loginForm)),t._loginForm}function Ee(t){return t._smsLoginForm||(t._smsLoginForm={},C(t._smsLoginForm)),t._smsLoginForm}function ye(t){return t._verifyPhoneNumberForm||(t._verifyPhoneNumberForm={},T(t._verifyPhoneNumberForm)),t._verifyPhoneNumberForm}function ke(t){t._loginForm=null}function xe(t){return t._newsletterSubscriptionForm||(t._newsletterSubscriptionForm={},E(t._newsletterSubscriptionForm)),t._newsletterSubscriptionForm}function Ce(t){t._newsletterSubscriptionForm=null}function Te(t){return t._orderTrackingForm||(t._orderTrackingForm={},y(t._orderTrackingForm)),t._orderTrackingForm}function je(t){t._orderTrackingForm=null}function Le(t){return t._recoverPasswordForm||(t._recoverPasswordForm={},k(t._recoverPasswordForm)),t._recoverPasswordForm}function Pe(t){t._recoverPasswordForm=null}function Fe(t){return t._registerForm||(t._registerForm={},x(t._registerForm)),t._registerForm}function Re(t){t._registerForm=null}function Oe(t){var e={};return v(e),o(e)}function Ne(e){return t(this,void 0,void 0,function(){var t,n;return r(this,function(r){switch(r.label){case 0:return"ORDER_DETAIL"!==c.currentPageType||"undefined"==typeof window?[3,4]:(t=a.getCurrentPath().split("/").pop(),!i.isPreview||t&&"orders"!==t?[3,2]:[4,ht(e)]);case 1:(n=r.sent()).length&&(t=n[0].id),r.label=2;case 2:return t?[4,_t(e,t)]:[3,4];case 3:return[2,r.sent()];case 4:return[2]}})})}function Ae(t){try{window.openIkasStorefrontWidget()}catch(t){console.error("Failed to open ikas storefront widget",t)}}function Ue(t){try{window.closeIkasStorefrontWidget()}catch(t){console.error("Failed to close ikas storefront widget",t)}}export{W as MILES_SMILES_PAYMENT_GATEWAY_CODE,q as MILES_SMILES_PAYMENT_GATEWAY_ID,B as MILES_SMILES_PROVIDER,st as activateCustomer,bt as addProductToFavorites,U as canCustomerCreateEmailSubscription,mt as checkEmail,fe as clearAccountInfoForm,ve as clearContactForm,_e as clearCouponCodeForm,A as clearCustomerSession,Se as clearDeactivateCustomerForm,ge as clearForgotPasswordForm,ke as clearLoginForm,Ce as clearNewsletterSubscriptionForm,je as clearOrderTrackingForm,Pe as clearRecoverPasswordForm,Re as clearRegisterForm,Ue as closeIkasStorefrontWidget,xt as createEmailSubscription,ae as cs_getLoyaltyCustomerInfo,ie as cs_listEarningMethods,ue as cs_listLoyaltyProgramPointHistory,ce as cs_listLoyaltyProgramTiers,oe as cs_listSpendingMethodsByCartId,se as cs_removeLoyaltyPointsFromCart,de as cs_useLoyaltyPoints,nt as customerLogin,Zt as customerStore_onProductView,D as customerToAnalyticsCustomer,jt as deactivateCustomer,et as deleteCustomerAddress,Lt as exportCustomerPersonalData,ft as forgotPassword,me as getAccountInfoForm,pe as getContactForm,he as getCouponCodeForm,Ot as getCustomerAttributes,ee as getCustomerConsentGranted,we as getDeactivateCustomerForm,At as getDigitalProductFileDownloadUrl,Oe as getEmptyAddressForm,gt as getFavoriteProducts,It as getFavoriteProductsIds,Ie as getForgotPasswordForm,Jt as getLastViewedProducts,be as getLoginForm,$ as getMilesSmilesDetails,Q as getMilesSmilesLink,xe as getNewsletterSubscriptionForm,_t as getOrder,wt as getOrderByEmail,Ne as getOrderDetailsOfPage,Nt as getOrderProductFiles,Ut as getOrderRefundSettings,Te as getOrderTrackingForm,St as getOrderTransactions,ht as getOrders,Le as getRecoverPasswordForm,Fe as getRegisterForm,Ee as getSmsLoginForm,ye as getVerifyPhoneNumberForm,Pt as handleCustomerConsentGrant,Y as handleMilesSmilesBind,V as handleSocialLogin,le as hasCustomer,O as initCustomerStore,kt as isFavoriteProduct,tt as isMilesSmilesTransaction,it as logout,J as milesSmilesBind,Ae as openIkasStorefrontWidget,pt as recoverPassword,rt as refundOrder,ot as register,re as removeCustomerConsent,Et as removeProductFromFavorites,at as resendCustomerActivationMail,dt as resendCustomerPhoneVerificationCode,lt as saveContactForm,vt as saveCustomer,Ct as saveCustomerFormData,N as seedCustomerSession,Tt as sendReview,Kt as setCaptchaToken,Ht as setSavedLastViewedProductsResponse,M as socialLogin,G as socialLoginToken,Z as unlinkMilesSmiles,ct as validateCustomerPhoneVerificationCode,ut as validateOTPCode,Rt as waitForCaptchaTokenInit,Ft as waitForCustomerStoreInit};
package/dist/index.d.ts CHANGED
@@ -16,13 +16,17 @@ export * from "./stores/cart";
16
16
  export * from "./stores/customer";
17
17
  export * from "./theme/infinite-scroller";
18
18
  export * from "./theme/overlay";
19
+ export * from "./theme/settings";
19
20
  export * from "./theme/slider";
20
21
  export * from "./theme/styles";
21
22
  export * from "./utils/blueprint";
22
23
  export * from "./utils/component-renderer";
24
+ export * from "./utils/currency";
23
25
  export * from "./utils/fetch";
24
26
  export * from "./utils/object-wrapper";
25
- export type { APIErrorCode, APIResponse } from "./storefront-api/src";
27
+ export * from "./utils/pay-with-ikas";
28
+ export * from "./utils/svg";
29
+ export type { APIResponse } from "./storefront-api/src";
26
30
  export * from "./storefront-api/src";
27
31
  export * from "./storefront-config/src";
28
32
  export * from "./storefront-models/src";