@ikas/bp-storefront 1.4.0-beta.2 → 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 (145) 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/helpers.js +1 -1
  10. package/dist/analytics/analytics-functions/pageView.js +1 -1
  11. package/dist/analytics/analytics-functions/productView.js +1 -1
  12. package/dist/analytics/analytics-functions/removeFromCart.js +1 -1
  13. package/dist/analytics/analytics-functions/search.js +1 -1
  14. package/dist/analytics/analytics-functions/viewBrand.js +1 -1
  15. package/dist/analytics/analytics-functions/viewCart.js +1 -1
  16. package/dist/analytics/analytics-functions/viewCategory.js +1 -1
  17. package/dist/analytics/analytics-functions/viewListing.js +1 -1
  18. package/dist/analytics/analytics-functions/viewSearchResults.js +1 -1
  19. package/dist/analytics/analytics-functions/viewStorefrontPopup.js +1 -1
  20. package/dist/analytics/analytics.js +1 -1
  21. package/dist/analytics/events.d.ts +8 -0
  22. package/dist/analytics/events.js +1 -1
  23. package/dist/analytics/google-tag-manager/productView.js +1 -1
  24. package/dist/analytics/google-tag-manager/viewCategory.js +1 -1
  25. package/dist/analytics/ikas/analytics.js +1 -1
  26. package/dist/analytics/openai/addToCart.d.ts +2 -0
  27. package/dist/analytics/openai/addToCart.js +1 -0
  28. package/dist/analytics/openai/completeRegistration.d.ts +1 -0
  29. package/dist/analytics/openai/completeRegistration.js +1 -0
  30. package/dist/analytics/openai/contactForm.d.ts +1 -0
  31. package/dist/analytics/openai/contactForm.js +1 -0
  32. package/dist/analytics/openai/initAdvancedMatching.d.ts +12 -0
  33. package/dist/analytics/openai/initAdvancedMatching.js +1 -0
  34. package/dist/analytics/openai/pageView.d.ts +1 -0
  35. package/dist/analytics/openai/pageView.js +1 -0
  36. package/dist/analytics/openai/productView.d.ts +2 -0
  37. package/dist/analytics/openai/productView.js +1 -0
  38. package/dist/analytics/openai/utils.d.ts +26 -0
  39. package/dist/analytics/openai/utils.js +1 -0
  40. package/dist/analytics/utils.d.ts +1 -0
  41. package/dist/analytics/utils.js +1 -1
  42. package/dist/ext/lodash/flatten.js +1 -0
  43. package/dist/functions/api/cart/index.d.ts +2 -0
  44. package/dist/functions/api/cart/index.js +1 -1
  45. package/dist/functions/api/customer/index.d.ts +5 -0
  46. package/dist/functions/api/customer/index.js +1 -1
  47. package/dist/functions/api/loyalty/index.d.ts +2 -1
  48. package/dist/functions/api/loyalty/index.js +1 -1
  49. package/dist/functions/api/product/index.js +1 -1
  50. package/dist/functions/models/attribute-detail/index.d.ts +3 -0
  51. package/dist/functions/models/attribute-list/index.d.ts +3 -0
  52. package/dist/functions/models/category/index.js +1 -1
  53. package/dist/functions/models/image/index.d.ts +71 -21
  54. package/dist/functions/models/image/index.js +1 -1
  55. package/dist/functions/models/index.d.ts +1 -0
  56. package/dist/functions/models/order/index.d.ts +21 -0
  57. package/dist/functions/models/order/index.js +1 -1
  58. package/dist/functions/models/product/attribute-value/index.d.ts +5 -0
  59. package/dist/functions/models/product/option-set/index.d.ts +18 -0
  60. package/dist/functions/models/product/option-set/index.js +1 -1
  61. package/dist/functions/models/product/variant/index.d.ts +96 -6
  62. package/dist/functions/models/product/variant/index.js +1 -1
  63. package/dist/functions/models/product-list/index.js +1 -1
  64. package/dist/functions/models/validator/account-info/index.js +1 -1
  65. package/dist/functions/models/validator/address/index.d.ts +70 -2
  66. package/dist/functions/models/validator/contact-form/index.js +1 -1
  67. package/dist/functions/models/validator/coupon-code-form/index.js +1 -1
  68. package/dist/functions/models/validator/customer-review/index.js +1 -1
  69. package/dist/functions/models/validator/deactivate-customer/index.d.ts +54 -0
  70. package/dist/functions/models/validator/deactivate-customer/index.js +1 -0
  71. package/dist/functions/models/validator/forgot-password/index.js +1 -1
  72. package/dist/functions/models/validator/login/index.js +1 -1
  73. package/dist/functions/models/validator/newsletter-subscription/index.js +1 -1
  74. package/dist/functions/models/validator/order-tracking/index.js +1 -1
  75. package/dist/functions/models/validator/recover-password/index.js +1 -1
  76. package/dist/functions/models/validator/register/index.js +1 -1
  77. package/dist/functions/models/validator/sms-login/index.js +1 -1
  78. package/dist/functions/models/validator/verify-phone-number/index.js +1 -1
  79. package/dist/functions/stores/base/index.d.ts +143 -1
  80. package/dist/functions/stores/base/index.js +1 -1
  81. package/dist/functions/stores/cart/index.d.ts +46 -2
  82. package/dist/functions/stores/cart/index.js +1 -1
  83. package/dist/functions/stores/customer/index.d.ts +278 -27
  84. package/dist/functions/stores/customer/index.js +1 -1
  85. package/dist/index.d.ts +5 -1
  86. package/dist/index.js +1 -1
  87. package/dist/packages/storefront-api/src/__api/mutations/removeGiftCardFromCart.js +1 -0
  88. package/dist/packages/storefront-api/src/__api/mutations/unlinkExternalAccount.js +1 -0
  89. package/dist/packages/storefront-api/src/__api/queries/getExternalAccountLink.js +1 -0
  90. package/dist/packages/storefront-api/src/__api/queries/getLoyaltyProgram.js +1 -0
  91. package/dist/packages/storefront-api/src/__api/queries/getMilesSmilesDetails.js +1 -0
  92. package/dist/packages/storefront-api-client/src/utils/api.js +1 -1
  93. package/dist/packages/storefront-config/src/index.js +1 -1
  94. package/dist/packages/storefront-config/src/theme-globals.js +1 -0
  95. package/dist/router/index.d.ts +28 -0
  96. package/dist/router/index.js +1 -1
  97. package/dist/storefront-api/src/__api/mutations/removeGiftCardFromCart.d.ts +7 -0
  98. package/dist/storefront-api/src/__api/mutations/unlinkExternalAccount.d.ts +6 -0
  99. package/dist/storefront-api/src/__api/queries/getExternalAccountLink.d.ts +6 -0
  100. package/dist/storefront-api/src/__api/queries/getLoyaltyProgram.d.ts +3 -0
  101. package/dist/storefront-api/src/__api/queries/getMilesSmilesDetails.d.ts +3 -0
  102. package/dist/storefront-api/src/__api/types/index.d.ts +68 -6
  103. package/dist/storefront-api-client/src/utils/api.d.ts +7 -0
  104. package/dist/storefront-config/src/index.d.ts +6 -0
  105. package/dist/storefront-config/src/theme-globals.d.ts +328 -0
  106. package/dist/storefront-models/src/index.d.ts +3 -0
  107. package/dist/storefront-models/src/models/blueprint/prop-value/attribute-list.d.ts +2 -0
  108. package/dist/storefront-models/src/models/blueprint/prop-value/attribute.d.ts +2 -0
  109. package/dist/storefront-models/src/models/blueprint/prop-value/color.d.ts +2 -0
  110. package/dist/storefront-models/src/models/blueprint/prop-value/index.d.ts +3 -0
  111. package/dist/storefront-models/src/models/blueprint/prop-value/svg-list.d.ts +3 -0
  112. package/dist/storefront-models/src/models/blueprint/prop-value/svg.d.ts +3 -0
  113. package/dist/storefront-models/src/models/blueprint/prop-value/variable-binding.d.ts +16 -0
  114. package/dist/storefront-models/src/models/image/index.d.ts +7 -0
  115. package/dist/storefront-models/src/models/loyalty-program/customer-info/index.d.ts +2 -0
  116. package/dist/storefront-models/src/models/loyalty-program/earning-method/index.d.ts +1 -0
  117. package/dist/storefront-models/src/models/loyalty-program/index.d.ts +1 -0
  118. package/dist/storefront-models/src/models/loyalty-program/point-history/index.d.ts +1 -0
  119. package/dist/storefront-models/src/models/order/gift-card-line/index.d.ts +15 -0
  120. package/dist/storefront-models/src/models/order/index.d.ts +2 -0
  121. package/dist/storefront-models/src/models/order/line-item/index.d.ts +1 -1
  122. package/dist/storefront-models/src/models/order/package/index.d.ts +1 -1
  123. package/dist/storefront-models/src/models/payment-gateway/index.d.ts +3 -1
  124. package/dist/storefront-models/src/models/product/attribute/index.d.ts +6 -1
  125. package/dist/storefront-models/src/models/product/campaign/data/index.d.ts +2 -0
  126. package/dist/storefront-models/src/models/product/campaign/filter/index.d.ts +1 -1
  127. package/dist/storefront-models/src/models/product/campaign/product-tiered-discount/index.d.ts +13 -0
  128. package/dist/storefront-models/src/models/product/image/index.d.ts +5 -0
  129. package/dist/storefront-models/src/models/product/variant/index.d.ts +17 -0
  130. package/dist/storefront-models/src/models/storefront/index.d.ts +1 -0
  131. package/dist/storefront-models/src/models/validator/deactivate-customer/index.d.ts +4 -0
  132. package/dist/stores/customer/index.d.ts +2 -1
  133. package/dist/stores/customer/index.js +1 -1
  134. package/dist/theme/settings/index.d.ts +51 -0
  135. package/dist/theme/settings/index.js +1 -0
  136. package/dist/utils/component-renderer.d.ts +3 -1
  137. package/dist/utils/component-renderer.js +1 -1
  138. package/dist/utils/currency.d.ts +36 -3
  139. package/dist/utils/helper.d.ts +1 -0
  140. package/dist/utils/helper.js +1 -1
  141. package/dist/utils/pay-with-ikas.d.ts +553 -0
  142. package/dist/utils/pay-with-ikas.js +1 -0
  143. package/dist/utils/svg.d.ts +15 -0
  144. package/dist/utils/svg.js +1 -0
  145. package/package.json +1 -1
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as r,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../stores/base/index.js";import"../../../../packages/storefront-config/src/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import'./../../../../ext/lodash/sortBy.js';import{getOrderByEmail as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as m}from"../index.js";function n(r){r.email=e(e({},t),{label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),r.orderNumber=e(e({},t),{label:i.translate("label.order_number"),placeholder:i.translate("placeholder.order_number")}),r.isSubmitted=!1,r.isSubmitting=!1,r.isSuccess=void 0,r.isFailure=void 0,r.responseMessage=void 0}function l(e,r){e.email.value=r,e.isSubmitted&&c(e)}function u(e,r){e.orderNumber.value=r,e.isSubmitted&&c(e)}function d(e){return r(this,void 0,void 0,function(){var r;return s(this,function(s){switch(s.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,c(e)?[2,null]:(e.isSubmitting=!0,[4,a(o,e.email.value,e.orderNumber.value)]);case 1:return r=s.sent(),e.isSubmitting=!1,r?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.order_tracking"),[2,r]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.order_tracking"),[2,null])}})})}function c(e){var r=m(e.email.value,{required:!0,email:!0});r.hasError?(e.email.hasError=!0,e.email.message=r.message):(e.email.hasError=!1,e.email.message=void 0);var s=m(e.orderNumber.value,{required:!0});return s.hasError?(e.orderNumber.hasError=!0,e.orderNumber.message=s.message):(e.orderNumber.hasError=!1,e.orderNumber.message=void 0),r.hasError||s.hasError}export{n as initOrderTrackingForm,l as setOrderTrackingFormEmail,u as setOrderTrackingFormOrderNumber,d as submitOrderTrackingForm};
1
+ import{__assign as e,__awaiter as r,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{getOrderByEmail as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as m}from"../index.js";function l(r){r.email=e(e({},t),{label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),r.orderNumber=e(e({},t),{label:i.translate("label.order_number"),placeholder:i.translate("placeholder.order_number")}),r.isSubmitted=!1,r.isSubmitting=!1,r.isSuccess=void 0,r.isFailure=void 0,r.responseMessage=void 0}function n(e,r){e.email.value=r,e.isSubmitted&&c(e)}function u(e,r){e.orderNumber.value=r,e.isSubmitted&&c(e)}function d(e){return r(this,void 0,void 0,function(){var r;return s(this,function(s){switch(s.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,c(e)?[2,null]:(e.isSubmitting=!0,[4,a(o,e.email.value,e.orderNumber.value)]);case 1:return r=s.sent(),e.isSubmitting=!1,r?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.order_tracking"),[2,r]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.order_tracking"),[2,null])}})})}function c(e){var r=m(e.email.value,{required:!0,email:!0});r.hasError?(e.email.hasError=!0,e.email.message=r.message):(e.email.hasError=!1,e.email.message=void 0);var s=m(e.orderNumber.value,{required:!0});return s.hasError?(e.orderNumber.hasError=!0,e.orderNumber.message=s.message):(e.orderNumber.hasError=!1,e.orderNumber.message=void 0),r.hasError||s.hasError}export{l as initOrderTrackingForm,n as setOrderTrackingFormEmail,u as setOrderTrackingFormOrderNumber,d as submitOrderTrackingForm};
@@ -1 +1 @@
1
- import{__assign as s,__awaiter as r,__generator as e}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as o}from"../../../../i18n/index.js";import{customerStore as a}from"../../../../stores/customer/index.js";import"../../../../stores/base/index.js";import"../../../../packages/storefront-config/src/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import'./../../../../ext/lodash/sortBy.js';import{recoverPassword as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as n}from"../index.js";function d(r){r.password=s(s({},t),{label:o.translate("label.password"),placeholder:o.translate("placeholder.password")}),r.passwordAgain=s(s({},t),{label:o.translate("label.password_again"),placeholder:o.translate("placeholder.password_again")}),r.isSubmitted=!1,r.isSubmitting=!1,r.isSuccess=void 0,r.isFailure=void 0,r.responseMessage=void 0}function p(s,r){s.password.value=r,s.isSubmitted&&m(s)}function u(s,r){s.passwordAgain.value=r,s.isSubmitted&&m(s)}function l(s){return r(this,void 0,void 0,function(){var r,t,n;return e(this,function(e){switch(e.label){case 0:return s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,m(s)?[2,!1]:(r="","undefined"!=typeof window&&(t=new URLSearchParams(window.location.search),r=t.get("token")||""),s.isSubmitting=!0,[4,i(a,s.password.value,s.passwordAgain.value,r)]);case 1:return n=e.sent(),s.isSubmitting=!1,n?(s.isSuccess=!0,s.responseMessage=o.translate("notification.success.recover_password"),[2,!0]):(s.isFailure=!0,s.responseMessage=o.translate("notification.failure.recover_password"),[2,!1])}})})}function m(s){var r=n(s.password.value,{required:!0,min:6});r.hasError?(s.password.hasError=!0,s.password.message=r.message):(s.password.hasError=!1,s.password.message=void 0);var e=n(s.passwordAgain.value,{required:!0,equals:s.password.value});return e.hasError?(s.passwordAgain.hasError=!0,s.passwordAgain.message=e.message):(s.passwordAgain.hasError=!1,s.passwordAgain.message=void 0),r.hasError||e.hasError}export{d as initRecoverPasswordForm,p as setRecoverPasswordFormPassword,u as setRecoverPasswordFormPasswordAgain,l as submitRecoverPasswordForm};
1
+ import{__assign as s,__awaiter as e,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as o}from"../../../../i18n/index.js";import{customerStore as a}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{recoverPassword as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as n}from"../index.js";function d(e){e.password=s(s({},t),{label:o.translate("label.password"),placeholder:o.translate("placeholder.password")}),e.passwordAgain=s(s({},t),{label:o.translate("label.password_again"),placeholder:o.translate("placeholder.password_again")}),e.isSubmitted=!1,e.isSubmitting=!1,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0}function l(s,e){s.password.value=e,s.isSubmitted&&m(s)}function p(s,e){s.passwordAgain.value=e,s.isSubmitted&&m(s)}function u(s){return e(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,m(s)?[2,!1]:(e="","undefined"!=typeof window&&(t=new URLSearchParams(window.location.search),e=t.get("token")||""),s.isSubmitting=!0,[4,i(a,s.password.value,s.passwordAgain.value,e)]);case 1:return n=r.sent(),s.isSubmitting=!1,n?(s.isSuccess=!0,s.responseMessage=o.translate("notification.success.recover_password"),[2,!0]):(s.isFailure=!0,s.responseMessage=o.translate("notification.failure.recover_password"),[2,!1])}})})}function m(s){var e=n(s.password.value,{required:!0,min:6});e.hasError?(s.password.hasError=!0,s.password.message=e.message):(s.password.hasError=!1,s.password.message=void 0);var r=n(s.passwordAgain.value,{required:!0,equals:s.password.value});return r.hasError?(s.passwordAgain.hasError=!0,s.passwordAgain.message=r.message):(s.passwordAgain.hasError=!1,s.passwordAgain.message=void 0),e.hasError||r.hasError}export{d as initRecoverPasswordForm,l as setRecoverPasswordFormPassword,p as setRecoverPasswordFormPasswordAgain,u as submitRecoverPasswordForm};
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import"../../../../analytics/analytics.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import'./../../../../ext/animejs/lib/anime.esm.js';import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../../../packages/storefront-api/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{I18n as i}from"../../../../i18n/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as o}from"../index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../router/index.js";import"../../../../stores/cart/index.js";import{getCustomerAttributes as n,register as l}from"../../../stores/customer/index.js";import"../../../../stores/base/index.js";import'./../../../../ext/uuid/dist/esm-browser/stringify.js';import'./../../../../ext/uuid/dist/esm-browser/v3.js';import'./../../../../ext/uuid/dist/esm-browser/native.js';import'./../../../../ext/uuid/dist/esm-browser/v5.js';import{getCustomerAttributeRegisterPageRequirement as d}from"../../customer/attribute/index.js";import"../../product-list/index.js";import"../../../../theme/styles/index.js";import'./../../../../ext/preact/dist/preact.mjs.js';import'./../../../../ext/preact/hooks/dist/hooks.mjs.js';import"../../../../utils/fetch.js";import"../../../../packages/storefront-models/src/models/merchant-settings/index.js";function u(o){o.firstName=e(e({},a),{isRequired:!0,label:i.translate("label.first_name"),placeholder:i.translate("placeholder.first_name")}),o.lastName=e(e({},a),{isRequired:!0,label:i.translate("label.last_name"),placeholder:i.translate("placeholder.last_name")}),o.email=e(e({},a),{isRequired:!0,label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),o.password=e(e({},a),{isRequired:!0,label:i.translate("label.password"),placeholder:i.translate("placeholder.password")}),o.phone=e(e({},a),{label:i.translate("label.phone"),placeholder:i.translate("placeholder.phone")}),o.isMarketingAccepted=T,o.isMembershipAgreementAccepted=e(e({},T),{isRequired:!0}),function(i){s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return i.attributes=[],i.isInitialized=!1,[4,n(t)];case 1:return s=r.sent(),i.isInitialized=!0,s.length?(i.attributes=s.filter(function(e){return"INVISIBLE"!==d(e)}).map(function(s){var r;return e(e({},a),{id:s.id,label:s.name,placeholder:s.description||"",isRequired:"MANDATORY"===d(s),type:s.type,options:"CHOICE"===s.type||"MULTIPLE_CHOICE"===s.type?(null===(r=s.options)||void 0===r?void 0:r.map(function(e){return{value:e.id,label:e.name}}))||[]:void 0,isChecked:void 0,value:void 0,selectedIdList:void 0})}),[2]):[2]}})})}(o),o.isSubmitted=!1,o.isSubmitting=!1,o.isSuccess=void 0,o.isFailure=void 0,o.responseMessage=void 0}function m(e,s,r){"string"!=typeof r&&"TEXT"!==s.type||(s.value=r)}function p(e,s,r){"string"!=typeof r&&"DATETIME"!==s.type||(s.value=r)}function c(e,s,r){"string"!=typeof r&&"DATE"!==s.type||(s.value=r)}function h(e,s,r){"string"!=typeof r&&"CHOICE"!==s.type||(s.value=r)}function v(e,s,r){"string"!=typeof r&&"NUMERIC"!==s.type||(Number.isInteger(Number(r))?s.value=r:s.value=r.slice(0,-1))}function f(e,s,r){"boolean"!=typeof r&&"CHOICE"!==s.type||(s.isChecked=r)}function g(e,s,r){"object"!=typeof r&&"MULTIPLE_CHOICE"!==s.type||(s.selectedIdList=r)}function E(e,s){e.firstName.value=s,e.isSubmitted&&N(e)}function b(e,s){e.lastName.value=s,e.isSubmitted&&N(e)}function y(e,s){e.email.value=s,e.isSubmitted&&N(e)}function I(e,s){e.password.value=s,e.isSubmitted&&N(e)}function A(e,s){e.phone.value=s,e.isSubmitted&&N(e)}function j(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&N(e)}function C(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&N(e)}function M(e){return s(this,void 0,void 0,function(){var s,a;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,N(e)?[2,!1]:(s=function(e){for(var s=[],r=0,t=e.attributes;r<t.length;r++){var i=t[r];if(!i.hasError)if(i.selectedIdList&&"MULTIPLE_CHOICE"===i.type)for(var a=0,o=i.selectedIdList;a<o.length;a++){var n=o[a];s.push({customerAttributeId:i.id,customerAttributeOptionId:n})}else"BOOLEAN"!==i.type?!i.value||"TEXT"!==i.type&&"NUMERIC"!==i.type?i.value&&"CHOICE"===i.type?s.push({customerAttributeId:i.id,customerAttributeOptionId:i.value}):!i.value||"DATE"!==i.type&&"DATETIME"!==i.type||s.push({customerAttributeId:i.id,value:new Date(i.value).getTime().toString()}):s.push({customerAttributeId:i.id,value:i.value}):s.push({customerAttributeId:i.id,value:i.isChecked?i.isChecked.toString():"false"})}return s}(e),e.isSubmitting=!0,[4,l(t,e.firstName.value,e.lastName.value,e.email.value,e.password.value,e.isMarketingAccepted.value,s,e.phone.value)]);case 1:return a=r.sent(),e.isSubmitting=!1,a.isSuccess?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.register"),[2,!0]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.register"),[2,!1])}})})}function N(e){var s=o(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var r=o(e.lastName.value,{required:!0});r.hasError?(e.lastName.hasError=!0,e.lastName.message=r.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var t=o(e.email.value,{required:!0,email:!0});t.hasError?(e.email.hasError=!0,e.email.message=t.message):(e.email.hasError=!1,e.email.message=void 0);var i=o(e.password.value,{required:!0,min:6});i.hasError?(e.password.hasError=!0,e.password.message=i.message):(e.password.hasError=!1,e.password.message=void 0);var a=o(e.isMembershipAgreementAccepted.value,{required:!0});a.hasError?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=a.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0);for(var n=0,l=e.attributes;n<l.length;n++){var d=l[n];if("BOOLEAN"!==d.type){if(d.isRequired){if("TEXT"===d.type||"DATETIME"===d.type||"DATE"===d.type||"CHOICE"===d.type||"NUMERIC"===d.type){(u=o(d.value||"",{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}if("MULTIPLE_CHOICE"===d.type){var u;(u=o(d.selectedIdList||[],{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}}d.hasError=!1,d.message=void 0}else void 0===d.isChecked&&(d.isChecked=!1),d.hasError=!1,d.message=void 0}return s.hasError||r.hasError||t.hasError||i.hasError||a.hasError||!1}var T={value:!1,hasError:!1,message:void 0};export{u as initRegisterForm,f as setRegisterFormBooleanAttribute,h as setRegisterFormChoiceAttribute,c as setRegisterFormDateAttribute,p as setRegisterFormDateTimeAttribute,y as setRegisterFormEmail,E as setRegisterFormFirstName,j as setRegisterFormIsMarketingAccepted,C as setRegisterFormIsMembershipAgreementAccepted,b as setRegisterFormLastName,g as setRegisterFormMultipleChoiceAttribute,v as setRegisterFormNumericAttribute,I as setRegisterFormPassword,A as setRegisterFormPhone,m as setRegisterFormTextAttribute,M as submitRegisterForm};
1
+ import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import"../../../../analytics/analytics.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import'./../../../../ext/animejs/lib/anime.esm.js';import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../../../packages/storefront-api/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{I18n as i}from"../../../../i18n/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as o}from"../index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../router/index.js";import"../../../../stores/cart/index.js";import{getCustomerAttributes as n,register as l}from"../../../stores/customer/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import"../../../../stores/base/index.js";import'./../../../../ext/uuid/dist/esm-browser/stringify.js';import'./../../../../ext/uuid/dist/esm-browser/v3.js';import'./../../../../ext/uuid/dist/esm-browser/native.js';import'./../../../../ext/uuid/dist/esm-browser/v5.js';import{getCustomerAttributeRegisterPageRequirement as d}from"../../customer/attribute/index.js";import"../../product-list/index.js";import"../../../../theme/styles/index.js";import'./../../../../ext/preact/dist/preact.mjs.js';import'./../../../../ext/preact/hooks/dist/hooks.mjs.js';import"../../../../utils/fetch.js";import"../../../../packages/storefront-models/src/models/merchant-settings/index.js";function u(o){o.firstName=e(e({},a),{isRequired:!0,label:i.translate("label.first_name"),placeholder:i.translate("placeholder.first_name")}),o.lastName=e(e({},a),{isRequired:!0,label:i.translate("label.last_name"),placeholder:i.translate("placeholder.last_name")}),o.email=e(e({},a),{isRequired:!0,label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),o.password=e(e({},a),{isRequired:!0,label:i.translate("label.password"),placeholder:i.translate("placeholder.password")}),o.phone=e(e({},a),{label:i.translate("label.phone"),placeholder:i.translate("placeholder.phone")}),o.isMarketingAccepted=T,o.isMembershipAgreementAccepted=e(e({},T),{isRequired:!0}),function(i){s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return i.attributes=[],i.isInitialized=!1,[4,n(t)];case 1:return s=r.sent(),i.isInitialized=!0,s.length?(i.attributes=s.filter(function(e){return"INVISIBLE"!==d(e)}).map(function(s){var r;return e(e({},a),{id:s.id,label:s.name,placeholder:s.description||"",isRequired:"MANDATORY"===d(s),type:s.type,options:"CHOICE"===s.type||"MULTIPLE_CHOICE"===s.type?(null===(r=s.options)||void 0===r?void 0:r.map(function(e){return{value:e.id,label:e.name}}))||[]:void 0,isChecked:void 0,value:void 0,selectedIdList:void 0})}),[2]):[2]}})})}(o),o.isSubmitted=!1,o.isSubmitting=!1,o.isSuccess=void 0,o.isFailure=void 0,o.responseMessage=void 0}function m(e,s,r){"string"!=typeof r&&"TEXT"!==s.type||(s.value=r)}function p(e,s,r){"string"!=typeof r&&"DATETIME"!==s.type||(s.value=r)}function c(e,s,r){"string"!=typeof r&&"DATE"!==s.type||(s.value=r)}function h(e,s,r){"string"!=typeof r&&"CHOICE"!==s.type||(s.value=r)}function v(e,s,r){"string"!=typeof r&&"NUMERIC"!==s.type||(Number.isInteger(Number(r))?s.value=r:s.value=r.slice(0,-1))}function f(e,s,r){"boolean"!=typeof r&&"CHOICE"!==s.type||(s.isChecked=r)}function g(e,s,r){"object"!=typeof r&&"MULTIPLE_CHOICE"!==s.type||(s.selectedIdList=r)}function E(e,s){e.firstName.value=s,e.isSubmitted&&N(e)}function b(e,s){e.lastName.value=s,e.isSubmitted&&N(e)}function y(e,s){e.email.value=s,e.isSubmitted&&N(e)}function I(e,s){e.password.value=s,e.isSubmitted&&N(e)}function A(e,s){e.phone.value=s,e.isSubmitted&&N(e)}function j(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&N(e)}function C(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&N(e)}function M(e){return s(this,void 0,void 0,function(){var s,a;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,N(e)?[2,!1]:(s=function(e){for(var s=[],r=0,t=e.attributes;r<t.length;r++){var i=t[r];if(!i.hasError)if(i.selectedIdList&&"MULTIPLE_CHOICE"===i.type)for(var a=0,o=i.selectedIdList;a<o.length;a++){var n=o[a];s.push({customerAttributeId:i.id,customerAttributeOptionId:n})}else"BOOLEAN"!==i.type?!i.value||"TEXT"!==i.type&&"NUMERIC"!==i.type?i.value&&"CHOICE"===i.type?s.push({customerAttributeId:i.id,customerAttributeOptionId:i.value}):!i.value||"DATE"!==i.type&&"DATETIME"!==i.type||s.push({customerAttributeId:i.id,value:new Date(i.value).getTime().toString()}):s.push({customerAttributeId:i.id,value:i.value}):s.push({customerAttributeId:i.id,value:i.isChecked?i.isChecked.toString():"false"})}return s}(e),e.isSubmitting=!0,[4,l(t,e.firstName.value,e.lastName.value,e.email.value,e.password.value,e.isMarketingAccepted.value,s,e.phone.value)]);case 1:return a=r.sent(),e.isSubmitting=!1,a.isSuccess?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.register"),[2,!0]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.register"),[2,!1])}})})}function N(e){var s=o(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var r=o(e.lastName.value,{required:!0});r.hasError?(e.lastName.hasError=!0,e.lastName.message=r.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var t=o(e.email.value,{required:!0,email:!0});t.hasError?(e.email.hasError=!0,e.email.message=t.message):(e.email.hasError=!1,e.email.message=void 0);var i=o(e.password.value,{required:!0,min:6});i.hasError?(e.password.hasError=!0,e.password.message=i.message):(e.password.hasError=!1,e.password.message=void 0);var a=o(e.isMembershipAgreementAccepted.value,{required:!0});a.hasError?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=a.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0);for(var n=0,l=e.attributes;n<l.length;n++){var d=l[n];if("BOOLEAN"!==d.type){if(d.isRequired){if("TEXT"===d.type||"DATETIME"===d.type||"DATE"===d.type||"CHOICE"===d.type||"NUMERIC"===d.type){(u=o(d.value||"",{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}if("MULTIPLE_CHOICE"===d.type){var u;(u=o(d.selectedIdList||[],{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}}d.hasError=!1,d.message=void 0}else void 0===d.isChecked&&(d.isChecked=!1),d.hasError=!1,d.message=void 0}return s.hasError||r.hasError||t.hasError||i.hasError||a.hasError||!1}var T={value:!1,hasError:!1,message:void 0};export{u as initRegisterForm,f as setRegisterFormBooleanAttribute,h as setRegisterFormChoiceAttribute,c as setRegisterFormDateAttribute,p as setRegisterFormDateTimeAttribute,y as setRegisterFormEmail,E as setRegisterFormFirstName,j as setRegisterFormIsMarketingAccepted,C as setRegisterFormIsMembershipAgreementAccepted,b as setRegisterFormLastName,g as setRegisterFormMultipleChoiceAttribute,v as setRegisterFormNumericAttribute,I as setRegisterFormPassword,A as setRegisterFormPhone,m as setRegisterFormTextAttribute,M as submitRegisterForm};
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as r,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as t}from"../../../../i18n/index.js";import{customerStore as i}from"../../../../stores/customer/index.js";import"../../../../stores/base/index.js";import"../../../../packages/storefront-config/src/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import'./../../../../ext/lodash/sortBy.js';import{register as a,validateOTPCode as o,customerLogin as n}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as l,validateValue as m}from"../index.js";var d=null;function u(r){r.phone=e(e({},l),{label:t.translate("label.phone"),placeholder:t.translate("placeholder.phone")}),r.code=e(e({},l),{label:t.translate("label.code"),placeholder:t.translate("placeholder.code")}),r.firstName=e(e({},l),{label:t.translate("label.first_name"),placeholder:t.translate("placeholder.first_name")}),r.lastName=e(e({},l),{label:t.translate("label.last_name"),placeholder:t.translate("placeholder.last_name")}),r.email=e(e({},l),{label:t.translate("label.email"),placeholder:t.translate("placeholder.email")}),r.isMarketingAccepted={value:!1,hasError:!1,message:void 0},r.isMembershipAgreementAccepted={value:!1,hasError:!1,message:void 0,isRequired:!0},r.step="Enter Phone Number",r.time=void 0,r.formattedTime=void 0,r.isSubmitted=!1,r.isSubmitting=!1,r.isSuccess=void 0,r.isFailure=void 0,r.responseMessage=void 0}function c(e,r){e.phone.value=r,e.isSubmitted&&"Enter Phone Number"===e.step&&M(e)}function p(e,r){e.code.value=r,e.isSubmitted&&"Verify Code"===e.step&&M(e)}function f(e,r){e.firstName.value=r,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function h(e,r){e.lastName.value=r,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function v(e,r){e.email.value=r,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function g(e,r){e.isMarketingAccepted.value=r,e.isSubmitted&&M(e)}function b(e,r){e.isMembershipAgreementAccepted.value=r,e.isSubmitted&&M(e)}function E(e){void 0===e&&(e=120);var r=Math.floor(e/60),s=e%60;return"".concat(r.toString().padStart(2,"0"),":").concat(s.toString().padStart(2,"0"))}function S(e){return r(this,void 0,void 0,function(){var r;return s(this,function(s){switch(s.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,M(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,N(e)];case 1:return s.sent()?(e.step="Verify Code",[3,6]):[2,!1];case 2:return"Verify Code"!==e.step?[3,4]:(e.isSubmitting=!0,[4,o(i,e.code.value,e.phone.value)]);case 3:return r=s.sent(),e.isSubmitting=!1,r.isSuccess?(d&&clearInterval(d),e.time=void 0,e.formattedTime=void 0,r.flowId?(e.flowId=r.flowId,e.step="Complete Profile",[2,!0]):(e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),e.step="Completed",[3,6])):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1]);case 4:return"Complete Profile"!==e.step?[3,6]:(e.isSubmitting=!0,[4,a(i,e.firstName.value,e.lastName.value,e.email.value,void 0,e.isMarketingAccepted.value,void 0,e.phone.value,e.flowId)]);case 5:if(r=s.sent(),e.isSubmitting=!1,!r.isSuccess)return e.isFailure=!0,e.responseMessage=t.translate("notification.failure.register"),[2,!1];e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),s.label=6;case 6:return[2,!0]}})})}function N(e){return r(this,void 0,void 0,function(){var r;return s(this,function(s){switch(s.label){case 0:return e.isSubmitting=!0,[4,n(i,void 0,void 0,e.phone.value)];case 1:return r=s.sent(),e.isSubmitting=!1,r&&r.isSuccess?(d&&clearInterval(d),e.time=120,e.formattedTime=E(),d=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=E(e.time)):(e.time=void 0,e.formattedTime=void 0,d&&clearInterval(d))},1e3),e.otpSend=r.otpSend,e.flowId=r.flowId,[2,!0]):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1])}})})}function C(e){return r(this,void 0,void 0,function(){return s(this,function(r){switch(r.label){case 0:return"Verify Code"!==e.step?[2]:[4,N(e)];case 1:return r.sent(),[2]}})})}function M(e){var r=m(e.phone.value,{required:!0,phone:!0});r.hasError&&"Enter Phone Number"===e.step?(e.phone.hasError=!0,e.phone.message=r.message):(e.phone.hasError=!1,e.phone.message=void 0);var s=m(e.code.value,{required:!0});s.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=s.message):(e.code.hasError=!1,e.code.message=void 0);var t=m(e.firstName.value,{required:!0});t.hasError&&"Complete Profile"===e.step?(e.firstName.hasError=!0,e.firstName.message=t.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var i=m(e.lastName.value,{required:!0});i.hasError&&"Complete Profile"===e.step?(e.lastName.hasError=!0,e.lastName.message=i.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var a=m(e.email.value,{required:!0,email:!0});a.hasError&&"Complete Profile"===e.step?(e.email.hasError=!0,e.email.message=a.message):(e.email.hasError=!1,e.email.message=void 0);var o=m(e.isMembershipAgreementAccepted.value,{required:!0});return o.hasError&&"Complete Profile"===e.step?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=o.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0),r.hasError&&"Enter Phone Number"===e.step||s.hasError&&"Verify Code"===e.step||t.hasError&&"Complete Profile"===e.step||i.hasError&&"Complete Profile"===e.step||a.hasError&&"Complete Profile"===e.step||o.hasError&&"Complete Profile"===e.step}export{u as initSmsLoginForm,C as resendSmsLoginFormCode,p as setSmsLoginFormCode,v as setSmsLoginFormEmail,f as setSmsLoginFormFirstName,g as setSmsLoginFormIsMarketingAccepted,b as setSmsLoginFormIsMembershipAgreementAccepted,h as setSmsLoginFormLastName,c as setSmsLoginFormPhone,S as submitSmsLoginForm};
1
+ import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as t}from"../../../../i18n/index.js";import{customerStore as i}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{register as a,validateOTPCode as o,customerLogin as l}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as n,validateValue as m}from"../index.js";var d=null;function u(s){s.phone=e(e({},n),{label:t.translate("label.phone"),placeholder:t.translate("placeholder.phone")}),s.code=e(e({},n),{label:t.translate("label.code"),placeholder:t.translate("placeholder.code")}),s.firstName=e(e({},n),{label:t.translate("label.first_name"),placeholder:t.translate("placeholder.first_name")}),s.lastName=e(e({},n),{label:t.translate("label.last_name"),placeholder:t.translate("placeholder.last_name")}),s.email=e(e({},n),{label:t.translate("label.email"),placeholder:t.translate("placeholder.email")}),s.isMarketingAccepted={value:!1,hasError:!1,message:void 0},s.isMembershipAgreementAccepted={value:!1,hasError:!1,message:void 0,isRequired:!0},s.step="Enter Phone Number",s.time=void 0,s.formattedTime=void 0,s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function c(e,s){e.phone.value=s,e.isSubmitted&&"Enter Phone Number"===e.step&&M(e)}function p(e,s){e.code.value=s,e.isSubmitted&&"Verify Code"===e.step&&M(e)}function f(e,s){e.firstName.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function h(e,s){e.lastName.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function v(e,s){e.email.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function g(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&M(e)}function b(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&M(e)}function E(e){void 0===e&&(e=120);var s=Math.floor(e/60),r=e%60;return"".concat(s.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))}function S(e){return s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,M(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,N(e)];case 1:return r.sent()?(e.step="Verify Code",[3,6]):[2,!1];case 2:return"Verify Code"!==e.step?[3,4]:(e.isSubmitting=!0,[4,o(i,e.code.value,e.phone.value)]);case 3:return s=r.sent(),e.isSubmitting=!1,s.isSuccess?(d&&clearInterval(d),e.time=void 0,e.formattedTime=void 0,s.flowId?(e.flowId=s.flowId,e.step="Complete Profile",[2,!0]):(e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),e.step="Completed",[3,6])):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1]);case 4:return"Complete Profile"!==e.step?[3,6]:(e.isSubmitting=!0,[4,a(i,e.firstName.value,e.lastName.value,e.email.value,void 0,e.isMarketingAccepted.value,void 0,e.phone.value,e.flowId)]);case 5:if(s=r.sent(),e.isSubmitting=!1,!s.isSuccess)return e.isFailure=!0,e.responseMessage=t.translate("notification.failure.register"),[2,!1];e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),r.label=6;case 6:return[2,!0]}})})}function N(e){return s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return e.isSubmitting=!0,[4,l(i,void 0,void 0,e.phone.value)];case 1:return s=r.sent(),e.isSubmitting=!1,s&&s.isSuccess?(d&&clearInterval(d),e.time=120,e.formattedTime=E(),d=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=E(e.time)):(e.time=void 0,e.formattedTime=void 0,d&&clearInterval(d))},1e3),e.otpSend=s.otpSend,e.flowId=s.flowId,[2,!0]):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1])}})})}function C(e){return s(this,void 0,void 0,function(){return r(this,function(s){switch(s.label){case 0:return"Verify Code"!==e.step?[2]:[4,N(e)];case 1:return s.sent(),[2]}})})}function M(e){var s=m(e.phone.value,{required:!0,phone:!0});s.hasError&&"Enter Phone Number"===e.step?(e.phone.hasError=!0,e.phone.message=s.message):(e.phone.hasError=!1,e.phone.message=void 0);var r=m(e.code.value,{required:!0});r.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=r.message):(e.code.hasError=!1,e.code.message=void 0);var t=m(e.firstName.value,{required:!0});t.hasError&&"Complete Profile"===e.step?(e.firstName.hasError=!0,e.firstName.message=t.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var i=m(e.lastName.value,{required:!0});i.hasError&&"Complete Profile"===e.step?(e.lastName.hasError=!0,e.lastName.message=i.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var a=m(e.email.value,{required:!0,email:!0});a.hasError&&"Complete Profile"===e.step?(e.email.hasError=!0,e.email.message=a.message):(e.email.hasError=!1,e.email.message=void 0);var o=m(e.isMembershipAgreementAccepted.value,{required:!0});return o.hasError&&"Complete Profile"===e.step?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=o.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0),s.hasError&&"Enter Phone Number"===e.step||r.hasError&&"Verify Code"===e.step||t.hasError&&"Complete Profile"===e.step||i.hasError&&"Complete Profile"===e.step||a.hasError&&"Complete Profile"===e.step||o.hasError&&"Complete Profile"===e.step}export{u as initSmsLoginForm,C as resendSmsLoginFormCode,p as setSmsLoginFormCode,v as setSmsLoginFormEmail,f as setSmsLoginFormFirstName,g as setSmsLoginFormIsMarketingAccepted,b as setSmsLoginFormIsMembershipAgreementAccepted,h as setSmsLoginFormLastName,c as setSmsLoginFormPhone,S as submitSmsLoginForm};
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as t,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as s}from"../../../../stores/customer/index.js";import"../../../../stores/base/index.js";import"../../../../packages/storefront-config/src/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import'./../../../../ext/lodash/sortBy.js';import{validateCustomerPhoneVerificationCode as o,waitForCustomerStoreInit as n,resendCustomerPhoneVerificationCode as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as d,validateValue as u}from"../index.js";var c=null;function m(t){t.code=e(e({},d),{label:r.translate("label.code"),placeholder:r.translate("placeholder.code")}),t.step="Enter Phone Number",t.time=void 0,t.formattedTime=void 0,t.isSubmitted=!1,t.isSubmitting=!1,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0}function l(e,t){e.code&&(e.code.value=t),e.isSubmitted&&h(e)}function f(e){void 0===e&&(e=120);var t=Math.floor(e/60),i=e%60;return"".concat(t.toString().padStart(2,"0"),":").concat(i.toString().padStart(2,"0"))}function v(e){return t(this,void 0,void 0,function(){var t,a,d;return i(this,function(i){switch(i.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,h(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,b(e)];case 1:return i.sent()?(e.step="Verify Code",[3,5]):[2,!1];case 2:return"Verify Code"!==e.step?[3,5]:(e.isSubmitting=!0,[4,n(s)]);case 3:return i.sent(),t=(null===(d=s.customer)||void 0===d?void 0:d.phone)||"",[4,o(s,e.code.value,t)];case 4:if(a=i.sent(),e.isSubmitting=!1,!a)return e.isFailure=!0,e.responseMessage=r.translate("notification.failure.verify_phone_number"),[2,!1];c&&clearInterval(c),e.time=void 0,e.formattedTime=void 0,e.isSuccess=!0,e.responseMessage=r.translate("notification.success.verify_phone_number"),e.step="Completed",s.customer&&(s.customer.isPhoneVerified=!0),i.label=5;case 5:return[2,!0]}})})}function p(e){return t(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return"Verify Code"!==e.step?[2]:[4,b(e)];case 1:return t.sent(),[2]}})})}function b(e){return t(this,void 0,void 0,function(){var t;return i(this,function(i){switch(i.label){case 0:return e.isSubmitting=!0,[4,a()];case 1:return t=i.sent(),e.isSubmitting=!1,t?(e.step="Verify Code",c&&clearInterval(c),e.time=120,e.formattedTime=f(),c=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=f(e.time)):(e.time=void 0,e.formattedTime=void 0,c&&clearInterval(c))},1e3),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.account_info"),[2,!1])}})})}function h(e){var t=u(e.code.value,{required:!0});return t.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=t.message):(e.code.hasError=!1,e.code.message=void 0),t.hasError&&"Verify Code"===e.step}export{m as initVerifyPhoneNumberForm,p as resendVerifyPhoneNumberFormCode,l as setVerifyPhoneNumberFormCode,v as submitVerifyPhoneNumberForm};
1
+ import{__assign as e,__awaiter as t,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as s}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{validateCustomerPhoneVerificationCode as o,waitForCustomerStoreInit as n,resendCustomerPhoneVerificationCode as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as d,validateValue as u}from"../index.js";var c=null;function m(t){t.code=e(e({},d),{label:r.translate("label.code"),placeholder:r.translate("placeholder.code")}),t.step="Enter Phone Number",t.time=void 0,t.formattedTime=void 0,t.isSubmitted=!1,t.isSubmitting=!1,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0}function l(e,t){e.code&&(e.code.value=t),e.isSubmitted&&h(e)}function f(e){void 0===e&&(e=120);var t=Math.floor(e/60),i=e%60;return"".concat(t.toString().padStart(2,"0"),":").concat(i.toString().padStart(2,"0"))}function p(e){return t(this,void 0,void 0,function(){var t,a,d;return i(this,function(i){switch(i.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,h(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,b(e)];case 1:return i.sent()?(e.step="Verify Code",[3,5]):[2,!1];case 2:return"Verify Code"!==e.step?[3,5]:(e.isSubmitting=!0,[4,n(s)]);case 3:return i.sent(),t=(null===(d=s.customer)||void 0===d?void 0:d.phone)||"",[4,o(s,e.code.value,t)];case 4:if(a=i.sent(),e.isSubmitting=!1,!a)return e.isFailure=!0,e.responseMessage=r.translate("notification.failure.verify_phone_number"),[2,!1];c&&clearInterval(c),e.time=void 0,e.formattedTime=void 0,e.isSuccess=!0,e.responseMessage=r.translate("notification.success.verify_phone_number"),e.step="Completed",s.customer&&(s.customer.isPhoneVerified=!0),i.label=5;case 5:return[2,!0]}})})}function v(e){return t(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return"Verify Code"!==e.step?[2]:[4,b(e)];case 1:return t.sent(),[2]}})})}function b(e){return t(this,void 0,void 0,function(){var t;return i(this,function(i){switch(i.label){case 0:return e.isSubmitting=!0,[4,a()];case 1:return t=i.sent(),e.isSubmitting=!1,t?(e.step="Verify Code",c&&clearInterval(c),e.time=120,e.formattedTime=f(),c=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=f(e.time)):(e.time=void 0,e.formattedTime=void 0,c&&clearInterval(c))},1e3),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.account_info"),[2,!1])}})})}function h(e){var t=u(e.code.value,{required:!0});return t.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=t.message):(e.code.hasError=!1,e.code.message=void 0),t.hasError&&"Verify Code"===e.step}export{m as initVerifyPhoneNumberForm,v as resendVerifyPhoneNumberFormCode,l as setVerifyPhoneNumberFormCode,p as submitVerifyPhoneNumberForm};
@@ -1,4 +1,4 @@
1
- import { IkasProduct, IkasThemePageType } from "../../../storefront-models/src";
1
+ import { IkasLanguageOption, IkasLocaleOption, IkasProduct, IkasThemePageType } from "../../../storefront-models/src";
2
2
  import { BaseStore } from "../../../stores/base";
3
3
  /**
4
4
  * Initializes the base store by setting the current page type.
@@ -17,12 +17,154 @@ import { BaseStore } from "../../../stores/base";
17
17
  * ```
18
18
  */
19
19
  export declare function initBaseStore(pageType: IkasThemePageType): void;
20
+ /**
21
+ * Switches the storefront to the routing associated with `localeOption` and redirects the browser
22
+ * to the equivalent URL under that routing.
23
+ *
24
+ * Reads the routing directly from `localeOption.routing`, then performs a full-page redirect via
25
+ * `window.location.replace`. For CATEGORY/BRAND/PRODUCT pages, the localized slug from the page's
26
+ * metadata translations is used when available; otherwise the visitor stays on the current path
27
+ * (with the current routing prefix swapped for the new one). Query string and hash are preserved.
28
+ *
29
+ * @ai-category BaseStore, Store
30
+ *
31
+ * @param baseStore - The base store instance (used to read the current page type for slug
32
+ * resolution on detail pages).
33
+ * @param localeOption - The locale option the visitor selected. Render `baseStore.localeOptions`
34
+ * as a list (e.g. a country/region picker) and pass the chosen entry directly to this function.
35
+ * @returns void.
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * import { setLocalization, baseStore } from "@ikas/bp-storefront";
40
+ *
41
+ * function LocalizationSwitcher() {
42
+ * return (
43
+ * <ul>
44
+ * {baseStore.localeOptions.map(option => (
45
+ * <li key={option.id}>
46
+ * <button onClick={() => setLocalization(baseStore, option)}>
47
+ * {option.countryName}
48
+ * </button>
49
+ * </li>
50
+ * ))}
51
+ * </ul>
52
+ * );
53
+ * }
54
+ * ```
55
+ */
56
+ export declare function setLocalization(baseStore: BaseStore, localeOption: IkasLocaleOption): void;
57
+ /**
58
+ * Switches the storefront to the routing identified by `language` and redirects the browser to
59
+ * the equivalent URL under that routing.
60
+ *
61
+ * Looks up the routing by `language.id`, then performs a full-page redirect via
62
+ * `window.location.replace`. For CATEGORY/BRAND/PRODUCT pages, the localized slug from the
63
+ * page's metadata translations is used when available; otherwise the visitor stays on the
64
+ * current path (with the current routing prefix swapped for the new one). Query string and
65
+ * hash are preserved.
66
+ *
67
+ * @ai-category BaseStore, Store
68
+ *
69
+ * @param baseStore - The base store instance (used to read the current page type for slug
70
+ * resolution on detail pages).
71
+ * @param language - The language option the visitor selected. Render `baseStore.languageOptions`
72
+ * as a list (e.g. a dropdown) and pass the chosen entry directly to this function.
73
+ * @returns void. No-op if no routing matches `language.id`.
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * import { setLanguage, baseStore } from "@ikas/bp-storefront";
78
+ *
79
+ * function LanguageSwitcher() {
80
+ * return (
81
+ * <ul>
82
+ * {baseStore.languageOptions.map(option => (
83
+ * <li key={option.id}>
84
+ * <button onClick={() => setLanguage(baseStore, option)}>
85
+ * {option.language}
86
+ * </button>
87
+ * </li>
88
+ * ))}
89
+ * </ul>
90
+ * );
91
+ * }
92
+ * ```
93
+ */
94
+ export declare function setLanguage(baseStore: BaseStore, language: IkasLanguageOption): void;
95
+ /**
96
+ * Fetches a single product by id and returns it as a full `IkasProduct`.
97
+ *
98
+ * Use this when a lightweight reference (e.g. a cart line's `IkasOrderLineVariant`, which carries
99
+ * neither `salesChannels` nor `stock`) needs product-level data: the returned product includes
100
+ * `salesChannels` filtered to the active sales channel (with `minQuantityPerCart` /
101
+ * `maxQuantityPerCart`) and per-variant `stock` (summed over the sales channel's configured
102
+ * stock locations). `selectedVariantValues` is seeded from the first active variant (or the
103
+ * first variant when none is active). For multiple ids, prefer `bs_searchProductsById` — one
104
+ * batched request.
105
+ *
106
+ * @ai-category Product, Search
107
+ * @ai-related bs_searchProductsById
108
+ *
109
+ * @param baseStore - The base store instance
110
+ * @param params - `{ productId }` — id of the product to fetch
111
+ * @returns `{ isSuccess, product }` — `product` is null when not found or on failure
112
+ *
113
+ * @example
114
+ * ```tsx
115
+ * import { baseStore, bs_searchProductById, IkasStorefrontConfig } from "@ikas/bp-storefront";
116
+ *
117
+ * const { isSuccess, product } = await bs_searchProductById(baseStore, { productId });
118
+ * if (isSuccess && product) {
119
+ * const channel = product.salesChannels?.find(sc => sc.id === IkasStorefrontConfig.salesChannelId);
120
+ * console.log(channel?.maxQuantityPerCart);
121
+ * }
122
+ * ```
123
+ */
20
124
  export declare function bs_searchProductById(baseStore: BaseStore, params: {
21
125
  productId: string;
22
126
  }): Promise<{
23
127
  isSuccess: boolean;
24
128
  product: IkasProduct | null;
25
129
  }>;
130
+ /**
131
+ * Batch-fetches products by id in a single request and returns them as full `IkasProduct` objects.
132
+ *
133
+ * The go-to function when cart lines (or any lightweight reference) need product-level data they
134
+ * do not carry: `IkasOrderLineVariant` has neither `salesChannels` nor `stock`, while the products
135
+ * returned here include `salesChannels` filtered to the active sales channel (with
136
+ * `minQuantityPerCart` / `maxQuantityPerCart`) and per-variant `stock` (summed over the sales
137
+ * channel's configured stock locations). Collect the distinct `productId`s of the lines and
138
+ * fetch them in ONE call instead of one request per line. Called with an empty `productIds`,
139
+ * it returns `{ isSuccess: true, products: [] }` without a network request.
140
+ *
141
+ * @ai-category Product, Cart, Search
142
+ * @ai-related bs_searchProductById, changeItemQuantity
143
+ *
144
+ * @param baseStore - The base store instance
145
+ * @param params - `{ productIds }` — product ids to fetch (deduplicate before calling)
146
+ * @returns `{ isSuccess, products }` — `products` is null on failure
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * import { baseStore, bs_searchProductsById, cartStore, IkasStorefrontConfig } from "@ikas/bp-storefront";
151
+ *
152
+ * // Enforce per-cart quantity limits on cart lines:
153
+ * const productIds = [
154
+ * ...new Set(
155
+ * (cartStore.cart?.orderLineItems ?? [])
156
+ * .map(item => item.variant.productId)
157
+ * .filter((id): id is string => !!id)
158
+ * ),
159
+ * ];
160
+ * const { products } = await bs_searchProductsById(baseStore, { productIds });
161
+ * const maxByProductId = new Map<string, number | null>();
162
+ * for (const p of products ?? []) {
163
+ * const channel = p.salesChannels?.find(sc => sc.id === IkasStorefrontConfig.salesChannelId);
164
+ * maxByProductId.set(p.id, channel?.maxQuantityPerCart ?? null);
165
+ * }
166
+ * ```
167
+ */
26
168
  export declare function bs_searchProductsById(baseStore: BaseStore, params: {
27
169
  productIds: string[];
28
170
  }): Promise<{
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../../ext/tslib/tslib.es6.mjs.js';import{baseStore as n}from"../../../stores/base/index.js";function r(t){n.currentPageType=t}function s(n,r){return t(this,void 0,void 0,function(){var t,n,s,e,u;return i(this,function(i){switch(i.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,i.sent().apiSearchProducts)({input:{productIdList:[r.productId]}})];case 2:return t=i.sent(),(n=(null===(u=null===(e=t.data)||void 0===e?void 0:e.data)||void 0===u?void 0:u[0])||null)&&(s=n.variants.find(function(t){return t.isActive}),n.selectedVariantValues=(s||n.variants[0]).variantValues),[2,{isSuccess:t.isSuccess,product:n}]}})})}function e(n,r){return t(this,void 0,void 0,function(){var t,n,s;return i(this,function(i){switch(i.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,i.sent().apiSearchProducts)({input:{productIdList:r.productIds}})];case 2:return t=i.sent(),(n=(null===(s=t.data)||void 0===s?void 0:s.data)||null)&&n.forEach(function(t){var i=t.variants.find(function(t){return t.isActive});t.selectedVariantValues=(i||t.variants[0]).variantValues}),[2,{isSuccess:t.isSuccess,products:n}]}})})}export{s as bs_searchProductById,e as bs_searchProductsById,r as initBaseStore};
1
+ import{__awaiter as n,__generator as o}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import t from'./../../../ext/lodash/flatten.js';import e from'./../../../ext/lodash/sortBy.js';import{baseStore as r}from"../../../stores/base/index.js";function c(c){r.currentPageType=c,function(){n(this,void 0,void 0,function(){var n,c,a,u,s,d,l,v;return o(this,function(o){switch(o.label){case 0:return[4,import("../../api/location/index.js")];case 1:return[4,(0,o.sent().apiGetMyCountry)()];case 2:return n=o.sent(),c=n.data,n.isSuccess&&c?(a=i.routings.filter(function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)}),a.length?(u=t(i.routings.map(function(n){return n.countryCodes||[]})),[4,import("../../api/location/index.js")]):[2]):[2];case 3:return[4,(0,o.sent().apiListCountry)({iso2:{in:u}})];case 4:return(s=o.sent()).isSuccess?(d=s.data||[],l=[],v=[],i.routings.forEach(function(n){var o;if(null===(o=n.countryCodes)||void 0===o?void 0:o.length)n.countryCodes.forEach(function(o){var i=d.find(function(n){return n.iso2===o});if(!v.some(function(n){return n.iso2===(null==i?void 0:i.iso2)})){var t={id:(null==i?void 0:i.iso2)||(null==i?void 0:i.iso3)||Date.now()+"",countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",iso2:(null==i?void 0:i.iso2)||void 0,iso3:(null==i?void 0:i.iso3)||void 0,routing:n,isRecommended:o===c};v.push(t)}});else{var t={id:n.id,routing:n,isRecommended:!i.routings.some(function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)})};v.push(t)}}),i.routings.forEach(function(n){var o;if(a.some(function(o){return o.id===n.id})){var t={id:n.id,currencyCode:n.currencyCode,currencySymbol:n.currencySymbol,language:"undefined"!=typeof Intl&&void 0!==Intl.DisplayNames&&new Intl.DisplayNames([],{type:"language"}).of(n.locale)||n.locale,locale:n.locale,isSelected:n.id===(null===(o=i.getCurrentRouting())||void 0===o?void 0:o.id)||!1};l.push(t)}}),r.languageOptions=e(l,"language"),r.localeOptions=e(v,"countryName"),[2]):[2]}})})}()}function a(n,o){var i=s(o.routing);window.location.replace(i)}function u(n,o){var t=i.routings.find(function(n){return n.id===o.id});if(t){var e=s(t);window.location.replace(e)}}function s(n){var o,t,e,c;if(n.domain)return"https://".concat(n.domain);var a=window.location,u=a.origin,s=a.pathname,d=a.search,l=a.hash,v=n.path?"/".concat(n.path):"",f=r.currentPageType;if("CATEGORY"===f||"BRAND"===f||"PRODUCT"===f){var p=null===(o=window.__IKAS_DATA__)||void 0===o?void 0:o.pageSpecificData,m=null===(e=null===(t=null==p?void 0:p.metaData)||void 0===t?void 0:t.translations)||void 0===e?void 0:e.find(function(o){return o.locale===n.locale});if(null==m?void 0:m.slug)return"".concat(u).concat(v,"/").concat(m.slug).concat(d).concat(l)}var g=null===(c=i.getCurrentRouting())||void 0===c?void 0:c.path,h=s;if(g){var y="/".concat(g);s===y?h="/":s.startsWith("".concat(y,"/"))&&(h=s.slice(y.length))}return"".concat(u).concat(v).concat(h).concat(d).concat(l)}function d(i,t){return n(this,void 0,void 0,function(){var n,i,e,r;return o(this,function(o){switch(o.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,o.sent().apiSearchProducts)({input:{productIdList:[t.productId]}})];case 2:return n=o.sent(),(i=(null===(r=null===(e=n.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r[0])||null)&&l(i),[2,{isSuccess:n.isSuccess,product:i}]}})})}function l(n){var o=n.variants.find(function(n){return n.isActive})||n.variants[0];o&&(n.selectedVariantValues=o.variantValues)}function v(i,t){return n(this,void 0,void 0,function(){var n,i,e;return o(this,function(o){switch(o.label){case 0:return t.productIds.length?[4,import("../../api/product/index.js")]:[2,{isSuccess:!0,products:[]}];case 1:return[4,(0,o.sent().apiSearchProducts)({input:{productIdList:t.productIds}})];case 2:return n=o.sent(),(i=(null===(e=n.data)||void 0===e?void 0:e.data)||null)&&i.forEach(l),[2,{isSuccess:n.isSuccess,products:i}]}})})}export{d as bs_searchProductById,v as bs_searchProductsById,c as initBaseStore,u as setLanguage,a as setLocalization};
@@ -26,6 +26,13 @@ export declare function getCheckoutUrlFromCartStore(cartStore: IkasCartStore): s
26
26
  /**
27
27
  * Add a product variant to the shopping cart.
28
28
  *
29
+ * Clamps the quantity to the sales channel's `minQuantityPerCart`/`maxQuantityPerCart` only
30
+ * when it creates a new cart line. When the variant already has a line in the cart, the add
31
+ * is delegated to `changeItemQuantity` (existing quantity + `initialQuantity`) with no
32
+ * client-side clamp — a quantity past `maxQuantityPerCart` is then rejected by the API with
33
+ * the `MAX_QUANTITY_PER_CART_LIMIT_REACHED` code in `result.response.errorCodes`, never as a
34
+ * `validationError`. See `changeItemQuantity` for the handling pattern.
35
+ *
29
36
  * @ai-category ProductDetail, Cart
30
37
  * @ai-related getSelectedProductVariant, findExistingCartItem, hasProductVariantStock
31
38
  *
@@ -85,6 +92,11 @@ export declare function addSelectedtedVariantToCart(product: IkasProduct, initia
85
92
  * Change the quantity of an item in the cart.
86
93
  * Use quantity=0 to remove the item.
87
94
  *
95
+ * Performs no client-side clamping or validation: a quantity above the sales channel's
96
+ * `maxQuantityPerCart` is rejected by the API with the `MAX_QUANTITY_PER_CART_LIMIT_REACHED`
97
+ * code in `result.response.errorCodes` (never as a `validationError`). Prevent violations in
98
+ * the stepper and treat the error code as the fallback.
99
+ *
88
100
  * @ai-category Cart
89
101
  * @ai-related removeItem, findExistingCartItem
90
102
  *
@@ -96,7 +108,7 @@ export declare function addSelectedtedVariantToCart(product: IkasProduct, initia
96
108
  *
97
109
  * @example
98
110
  * ```typescript
99
- * import { cartStore, changeItemQuantity } from "@ikas/bp-storefront";
111
+ * import { APIErrorCode, cartStore, changeItemQuantity } from "@ikas/bp-storefront";
100
112
  *
101
113
  * // Increment quantity
102
114
  * async function handleIncrement(itemId: string) {
@@ -104,7 +116,10 @@ export declare function addSelectedtedVariantToCart(product: IkasProduct, initia
104
116
  * if (item) {
105
117
  * const result = await changeItemQuantity(item, item.quantity + 1);
106
118
  * if (!result.success) {
107
- * showToast("Failed to update quantity");
119
+ * const limitHit = result.response?.errorCodes?.includes(
120
+ * APIErrorCode.MAX_QUANTITY_PER_CART_LIMIT_REACHED
121
+ * );
122
+ * showToast(limitHit ? "Per-cart quantity limit reached" : "Failed to update quantity");
108
123
  * }
109
124
  * }
110
125
  * }
@@ -353,6 +368,35 @@ export declare function saveCouponCode(cart: IkasCart, couponCode?: string | nul
353
368
  * ```
354
369
  */
355
370
  export declare function removeCouponCode(cart: IkasCart): Promise<IkasCartOperationResult>;
371
+ /**
372
+ * Remove a gift card (or store credit) line from the cart.
373
+ *
374
+ * Gift cards are applied through `saveCouponCode` with the gift card code, and the applied
375
+ * cards are listed on `cart.giftCardLines`. Pass the `giftCardId` of the line to remove; when
376
+ * omitted, every gift card line is removed from the cart.
377
+ *
378
+ * @ai-category Cart
379
+ * @ai-related saveCouponCode, getIkasOrderGiftCardTotalPrice
380
+ *
381
+ * @param cart - The cart object
382
+ * @param giftCardId - The gift card to remove, or null/undefined to remove all of them
383
+ * @returns Result with success flag
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * import { cartStore, removeGiftCardLine } from "@ikas/bp-storefront";
388
+ *
389
+ * async function handleRemoveGiftCard(giftCardId: string) {
390
+ * if (!cartStore.cart) return;
391
+ *
392
+ * const result = await removeGiftCardLine(cartStore.cart, giftCardId);
393
+ * if (result.success) {
394
+ * showToast("Gift card removed");
395
+ * }
396
+ * }
397
+ * ```
398
+ */
399
+ export declare function removeGiftCardLine(cart: IkasCart, giftCardId?: string | null): Promise<IkasCartOperationResult>;
356
400
  /**
357
401
  * Fetch the cart from the API and persist it to the cart store.
358
402
  * Resolves the cart using the localStorage cart ID or the logged-in customer ID.
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as r}from"../../../packages/storefront-config/src/index.js";import{CART_LS_KEY as e,cartStore as i}from"../../../stores/cart/index.js";import{customerStore as a}from"../../../stores/customer/index.js";import{getCookieValue as o}from"../../../utils/helper.js";import{getIkasOrderDistinctItemCount as s}from"../../models/order/index.js";import{getSelectedProductVariant as u,hasProductValidOptionValues as c}from"../../models/product/index.js";import{isProductOfferAccepted as d}from"../../models/product/campaign-offer/index.js";import{initProductOptionSetValues as l}from"../../models/product/option-set/index.js";import{hasProductVariantStock as f}from"../../models/product/variant/index.js";function v(t){var n,e=null===(n=t.cart)||void 0===n?void 0:n.id;if(e){var i=r.getCurrentRouting();return"".concat((null==i?void 0:i.path)?"/".concat(i.path):"","/checkout?id=").concat(e,"&step=info")}return""}function p(a,s){return t(this,arguments,void 0,function(t,a,s,d){var v,p,m,I,g,y,b,C,L,_,j,P,T,w,x,E,U;return void 0===s&&(s=1),n(this,function(n){switch(n.label){case 0:v=null!==(P=null==d?void 0:d.isPayWithIkas)&&void 0!==P&&P,n.label=1;case 1:return n.trys.push([1,10,,11]),v||!a.productOptionSetId||a.productOptionSet?c(a)?f(t)||t.sellIfOutOfStock?(p=void 0,v?[3,3]:[4,k()]):[2,{success:!1,validationError:"INSUFFICIENT_STOCK"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}];case 2:if(n.sent(),i.cart&&(p=O(i.cart,t,a))){if(a.productOptionSet&&l(a.productOptionSet),!t.bundleSettings)return[2,h(p,p.quantity+s,a.offers,a)];if(!S())return[2,h(p,p.quantity+s,a.offers,a)]}n.label=3;case 3:return m=F(a),I=s,(null==(g=null===(T=a.salesChannels)||void 0===T?void 0:T.find(function(t){return t.id===r.salesChannelId}))?void 0:g.minQuantityPerCart)&&s<g.minQuantityPerCart&&(I=g.minQuantityPerCart),(null==g?void 0:g.maxQuantityPerCart)&&s>g.maxQuantityPerCart&&(I=g.maxQuantityPerCart),y=v?null:(null===(w=i.cart)||void 0===w?void 0:w.id)||localStorage.getItem(e),[4,import("../../api/cart/index.js")];case 4:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:y,item:{id:null!==(x=null==p?void 0:p.id)&&void 0!==x?x:null,quantity:null!==(E=null==p?void 0:p.quantity)&&void 0!==E?E:I,variant:{id:t.id,name:a.name,bundleProducts:null===(U=t.bundleSettings)||void 0===U?void 0:U.products.map(function(t){var n;return{id:t.id,productId:(null===(n=t.product)||void 0===n?void 0:n.id)||"",variantId:t.product?u(t.product).id:"",quantity:t.quantity}})}},acceptedOffers:q(a.offers),options:m.length?m:null,priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc")}}})];case 5:return b=n.sent(),v?[3,7]:b.isSuccess&&b.data?[4,A(b.data)]:[3,7];case 6:n.sent(),n.label=7;case 7:return(C=v?b.data:i.cart)?(L="".concat(C.id,"-").concat(C.updatedAt),(_=C.orderLineItems.find(function(n){return n.variant.id===t.id}))?[4,import("../../../analytics/analytics-functions/addToCart.js")]:[3,9]):[3,9];case 8:(0,n.sent().anl_addToCart)(_,s,L,C,a),n.label=9;case 9:return a.productOptionSet&&l(a.productOptionSet),[2,{success:b.isSuccess,response:b}];case 10:return j=n.sent(),console.log(j),[2,{success:!1}];case 11:return[2]}})})}function m(r){return t(this,arguments,void 0,function(t,r){return void 0===r&&(r=1),n(this,function(n){switch(n.label){case 0:return[4,p(u(t),t,r)];case 1:return[2,n.sent()]}})})}function h(e,a,s,u){return t(this,void 0,void 0,function(){var t,c,d,l,f,v;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,k()];case 1:return n.sent(),[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(f=i.cart)||void 0===f?void 0:f.id)||null,item:{id:e.id,quantity:a,variant:{id:e.variant.id,name:e.variant.name,bundleProducts:null===(v=e.variant.bundleProducts)||void 0===v?void 0:v.map(function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}})}},acceptedOffers:s?q(s):void 0,options:E(e),priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc")}}})];case 3:return(t=n.sent()).isSuccess&&t.data?[4,A(t.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return i.cart?(c="".concat(i.cart.id,"-").concat(i.cart.updatedAt),(d=e.quantity)>a?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(e,d-a,i.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(e,a-d,c,i.cart,u),n.label=9;case 9:return T(i),[2,{success:t.isSuccess,response:t}];case 10:return l=n.sent(),console.log(l),[2,{success:!1}];case 11:return[2]}})})}function I(r,e,i,a,o){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,h(e,i,a,o)];case 1:return[2,t.sent()]}})})}function g(t,n){for(var r=0,e=(null==t?void 0:t.orderAdjustments)||[];r<e.length;r++)for(var i=0,a=e[r].appliedOrderLines||[];i<a.length;i++){var o=a[i];if(o.orderLineId===n.id)return o.isAutoCreated||!1}return!1}function y(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,h(r,0)];case 1:return[2,t.sent()]}})})}function b(t){localStorage.removeItem(e),t.cart=null}function C(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){var n=setInterval(function(){r.isCartInitialLoadFinished&&(clearInterval(n),t(null))},100)})];case 1:return[2,t.sent()]}})})}function S(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""}function O(t,n,r){var e,i,a;if(!r.productOptionSetId&&!n.bundleSettings)return t.orderLineItems.find(function(t){return t.variant.id===n.id});if(n.bundleSettings){var o=S();if(o)if(g=t.orderLineItems.find(function(t){return t.id===o}))return g}var s=t.orderLineItems.filter(function(t){return t.variant.id===n.id})||[];if(r.productOptionSetId)for(var u=F(r),c=s.filter(function(t){var n;return(null===(n=t.options)||void 0===n?void 0:n.length)===u.length})||[],d=0,l=c;d<l.length;d++){if((g=l[d]).options){for(var f=!0,v=function(t){var n=t.values.map(function(t){return t.value}),o=null===(a=null===(i=null===(e=r.productOptionSet)||void 0===e?void 0:e.options)||void 0===i?void 0:i.find(function(n){return n.id===t.productOptionId}))||void 0===a?void 0:a.values;if(!(f=f&&n.length===(null==o?void 0:o.length)&&n.every(function(t){return null==o?void 0:o.includes(t)})))return"break"},p=0,m=g.options;p<m.length;p++){if("break"===v(m[p]))break}if(f){if(!n.bundleSettings)return g;if(_(n,g))return g}}}else if(n.bundleSettings)for(var h=0,I=s;h<I.length;h++){var g=I[h];if(_(n,g))return g}}function L(t,n){return O(t,u(n),n)}function _(t,n){var r,e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products,i=n.variant.bundleProducts;return!!e&&((null==e?void 0:e.length)===(null==i?void 0:i.length)&&(null==e?void 0:e.every(function(t){return!!(null==i?void 0:i.find(function(n){return n.id===t.id&&n.quantity===t.quantity&&t.product&&n.variant.id===u(t.product).id}))})))}function j(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiSaveCartCouponCode)({cartId:r.id,couponCode:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(i.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function P(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,j(r,null)];case 1:return[2,t.sent()]}})})}function T(t){t.cart&&0===s(t.cart)&&b(t)}function w(){return t(this,void 0,void 0,function(){var t,r,o,s,u,c;return n(this,function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,7,8,9]),i.isCartLoading=!0,t=null===(u=a.customer)||void 0===u?void 0:u.id,(r=(null===(c=i.cart)||void 0===c?void 0:c.id)||localStorage.getItem(e))||t?[4,import("../../api/cart/index.js")]:[2];case 2:return[4,(0,n.sent().apiGetCartById)({id:r})];case 3:return(o=n.sent()).isSuccess&&o.data?[4,A(o.data)]:[3,5];case 4:return n.sent(),[3,6];case 5:if(o.isCancelled||o.isNetworkError)return[2];b(i),n.label=6;case 6:return[3,9];case 7:return s=n.sent(),console.log(s),[3,9];case 8:return i.isCartLoading=!1,i.isCartInitialLoadFinished=!0,[7];case 9:return[2]}})})}function q(t){var n=t.filter(function(t){return t.isSelected&&!d(t)}).map(function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:u(t.product).id}})||[];return n.length?n:void 0}function x(e,i){return t(this,arguments,void 0,function(t,e,i){var a,o,s,c,d,l,f,v,m,h,I,g,y,b,C;return void 0===i&&(i=1),n(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),a=r.salesChannelId,o=r.storefrontThemeId,a&&o?(s=u(e))?[4,p(s,e,i,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}];case 1:return(c=t.sent()).success&&(null===(m=null===(v=c.response)||void 0===v?void 0:v.data)||void 0===m?void 0:m.id)?(d=c.response.data.id,[4,import("../../api/cart/index.js")]):[2,{success:!1,error:(null===(g=null===(I=null===(h=c.response)||void 0===h?void 0:h.graphQLErrors)||void 0===I?void 0:I[0])||void 0===g?void 0:g.message)||"Failed to create cart"}];case 2:return[4,(0,t.sent().apiCreatePayWithIkasSessionUrl)({cartId:d})];case 3:return!(l=t.sent()).data||(null===(y=l.graphQLErrors)||void 0===y?void 0:y.length)?[2,{success:!1,error:(null===(C=null===(b=l.graphQLErrors)||void 0===b?void 0:b[0])||void 0===C?void 0:C.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:l.data.payUrl,expiresAt:l.data.expiresAt}];case 4:return f=t.sent(),console.log("error",f),[2,{success:!1,error:f instanceof Error?f.message:"Unknown error occurred"}];case 5:return[2]}})})}function A(r){return t(this,void 0,void 0,function(){return n(this,function(t){return localStorage.setItem(e,r.id),i.cart=r,[2]})})}function k(){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return t=localStorage.getItem(e),!i.cart||t?[3,1]:(b(i),[3,3]);case 1:return i.cart||!t?[3,3]:[4,w()];case 2:n.sent(),n.label=3;case 3:return[2]}})})}function E(t){if(t&&t.options){for(var n=[],r=0,e=t.options;r<e.length;r++){var i=e[r],a={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map(function(t){return t.value})};n.push(a)}return n}return null}function F(t){var n,r=[];return null===(n=t.productOptionSet)||void 0===n||n.options.forEach(function(t){t.values.length&&r.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})}),r}function U(e){return t(this,void 0,void 0,function(){var t,a,s,u,c,d,l,f,v,p,m;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,k()];case 1:return n.sent(),t=e.itemId?null===(v=i.cart)||void 0===v?void 0:v.orderLineItems.find(function(t){return t.id===e.itemId}):null,[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(p=i.cart)||void 0===p?void 0:p.id)||null,item:{id:e.itemId||null,quantity:e.quantity,variant:{id:e.variantId}},priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId,metadata:{_fbp:o("_fbp"),_fbc:o("_fbc")}}})];case 3:return(a=n.sent()).isSuccess&&a.data?(e.itemId||(s=(null===(m=i.cart)||void 0===m?void 0:m.orderLineItems.map(function(t){return t.id}))||[],u=a.data.orderLineItems.map(function(t){return t.id}),(c=u.find(function(t){return!s.includes(t)}))&&(t=a.data.orderLineItems.find(function(t){return t.id===c}))),[4,A(a.data)]):[3,5];case 4:n.sent(),n.label=5;case 5:return i.cart&&t?(d="".concat(i.cart.id,"-").concat(i.cart.updatedAt),(l=e.quantity)>e.quantity?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(t,l-e.quantity,i.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(t,e.quantity-l,d,i.cart),n.label=9;case 9:return T(i),[2,{success:a.isSuccess,response:a}];case 10:return f=n.sent(),console.log(f),[2,{success:!1}];case 11:return[2]}})})}function Q(t){var n;return!!t.cart&&(null===(n=t.cart.orderLineItems)||void 0===n?void 0:n.length)>0}export{p as addItemToCart,m as addSelectedtedVariantToCart,I as changeCartItemQuantity,h as changeItemQuantity,x as createPayWithIkasSession,O as findExistingCartItem,L as findExistingCartItemWithProduct,q as getAcceptedOffers,w as getCart,v as getCheckoutUrlFromCartStore,Q as hasCart,g as isOrderLineItemAutoCreated,b as removeCart,P as removeCouponCode,y as removeItem,j as saveCouponCode,A as setCart,C as waitForCartStoreInit,U as windowAddToCart};
1
+ import{__awaiter as t,__generator as n,__assign as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as e}from"../../../packages/storefront-config/src/index.js";import{CART_LS_KEY as i,cartStore as a}from"../../../stores/cart/index.js";import{customerStore as o}from"../../../stores/customer/index.js";import{getCookieValue as s,getOpenAiAttributionMetadata as u}from"../../../utils/helper.js";import{getIkasOrderDistinctItemCount as c}from"../../models/order/index.js";import{getSelectedProductVariant as d,hasProductValidOptionValues as l}from"../../models/product/index.js";import{isProductOfferAccepted as f}from"../../models/product/campaign-offer/index.js";import{initProductOptionSetValues as v}from"../../models/product/option-set/index.js";import{hasProductVariantStock as p}from"../../models/product/variant/index.js";import{waitForCustomerStoreInit as m}from"../customer/index.js";function h(t){var n,r=null===(n=t.cart)||void 0===n?void 0:n.id;if(r){var i=e.getCurrentRouting();return"".concat((null==i?void 0:i.path)?"/".concat(i.path):"","/checkout?id=").concat(r,"&step=info")}return""}function I(o,c){return t(this,arguments,void 0,function(t,o,c,f){var m,h,I,g,y,C,S,O,_,w,x,P,T,q,A,E,F;return void 0===c&&(c=1),n(this,function(n){switch(n.label){case 0:m=null!==(P=null==f?void 0:f.isPayWithIkas)&&void 0!==P&&P,n.label=1;case 1:return n.trys.push([1,10,,11]),m||!o.productOptionSetId||o.productOptionSet?l(o)?p(t)||t.sellIfOutOfStock?(h=void 0,m?[3,3]:[4,Q()]):[2,{success:!1,validationError:"INSUFFICIENT_STOCK"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}]:[2,{success:!1,validationError:"INVALID_PRODUCT_OPTION_VALUES"}];case 2:if(n.sent(),a.cart&&(h=j(a.cart,t,o))){if(o.productOptionSet&&v(o.productOptionSet),!t.bundleSettings)return[2,b(h,h.quantity+c,o.offers,o)];if(!L())return[2,b(h,h.quantity+c,o.offers,o)]}n.label=3;case 3:return I=D(o),g=c,(null==(y=null===(T=o.salesChannels)||void 0===T?void 0:T.find(function(t){return t.id===e.salesChannelId}))?void 0:y.minQuantityPerCart)&&c<y.minQuantityPerCart&&(g=y.minQuantityPerCart),(null==y?void 0:y.maxQuantityPerCart)&&c>y.maxQuantityPerCart&&(g=y.maxQuantityPerCart),C=m?null:(null===(q=a.cart)||void 0===q?void 0:q.id)||localStorage.getItem(i),[4,import("../../api/cart/index.js")];case 4:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:C,item:{id:null!==(A=null==h?void 0:h.id)&&void 0!==A?A:null,quantity:null!==(E=null==h?void 0:h.quantity)&&void 0!==E?E:g,variant:{id:t.id,name:o.name,bundleProducts:null===(F=t.bundleSettings)||void 0===F?void 0:F.products.map(function(t){var n;return{id:t.id,productId:(null===(n=t.product)||void 0===n?void 0:n.id)||"",variantId:t.product?d(t.product).id:"",quantity:t.quantity}})}},acceptedOffers:k(o.offers),options:I.length?I:null,priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 5:return S=n.sent(),m?[3,7]:S.isSuccess&&S.data?[4,U(S.data)]:[3,7];case 6:n.sent(),n.label=7;case 7:return(O=m?S.data:a.cart)?(_="".concat(O.id,"-").concat(O.updatedAt),(w=O.orderLineItems.find(function(n){return n.variant.id===t.id}))?[4,import("../../../analytics/analytics-functions/addToCart.js")]:[3,9]):[3,9];case 8:(0,n.sent().anl_addToCart)(w,c,_,O,o),n.label=9;case 9:return o.productOptionSet&&v(o.productOptionSet),[2,{success:S.isSuccess,response:S}];case 10:return x=n.sent(),console.log(x),[2,{success:!1}];case 11:return[2]}})})}function g(r){return t(this,arguments,void 0,function(t,r){return void 0===r&&(r=1),n(this,function(n){switch(n.label){case 0:return[4,I(d(t),t,r)];case 1:return[2,n.sent()]}})})}function b(i,o,c,d){return t(this,void 0,void 0,function(){var t,l,f,v,p,m;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,Q()];case 1:return n.sent(),[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(p=a.cart)||void 0===p?void 0:p.id)||null,item:{id:i.id,quantity:o,variant:{id:i.variant.id,name:i.variant.name,bundleProducts:null===(m=i.variant.bundleProducts)||void 0===m?void 0:m.map(function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}})}},acceptedOffers:c?k(c):void 0,options:N(i),priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 3:return(t=n.sent()).isSuccess&&t.data?[4,U(t.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return a.cart?(l="".concat(a.cart.id,"-").concat(a.cart.updatedAt),(f=i.quantity)>o?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(i,f-o,a.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(i,o-f,l,a.cart,d),n.label=9;case 9:return A(a),[2,{success:t.isSuccess,response:t}];case 10:return v=n.sent(),console.log(v),[2,{success:!1}];case 11:return[2]}})})}function y(r,e,i,a,o){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,b(e,i,a,o)];case 1:return[2,t.sent()]}})})}function C(t,n){for(var r=0,e=(null==t?void 0:t.orderAdjustments)||[];r<e.length;r++)for(var i=0,a=e[r].appliedOrderLines||[];i<a.length;i++){var o=a[i];if(o.orderLineId===n.id)return o.isAutoCreated||!1}return!1}function S(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,b(r,0)];case 1:return[2,t.sent()]}})})}function O(t){localStorage.removeItem(i),t.cart=null}function _(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){var n=setInterval(function(){r.isCartInitialLoadFinished&&(clearInterval(n),t(null))},100)})];case 1:return[2,t.sent()]}})})}function L(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""}function j(t,n,r){var e;if(!r.productOptionSetId&&!n.bundleSettings)return t.orderLineItems.find(function(t){return t.variant.id===n.id});if(n.bundleSettings){var i=L();if(i)if(h=t.orderLineItems.find(function(t){return t.id===i}))return h}var a=t.orderLineItems.filter(function(t){return t.variant.id===n.id})||[];if(r.productOptionSetId)for(var o=D(r),s=a.filter(function(t){var n;return(null===(n=t.options)||void 0===n?void 0:n.length)===o.length})||[],u=0,c=s;u<c.length;u++){if((h=c[u]).options){for(var d=!0,l=function(t){var n=t.values.map(function(t){return t.value}),r=null===(e=o.find(function(n){return n.productOptionId===t.productOptionId}))||void 0===e?void 0:e.values;if(!(d=d&&n.length===(null==r?void 0:r.length)&&n.every(function(t){return null==r?void 0:r.includes(t)})))return"break"},f=0,v=h.options;f<v.length;f++){if("break"===l(v[f]))break}if(d){if(!n.bundleSettings)return h;if(x(n,h))return h}}}else if(n.bundleSettings)for(var p=0,m=a;p<m.length;p++){var h=m[p];if(x(n,h))return h}}function w(t,n){return j(t,d(n),n)}function x(t,n){var r,e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products,i=n.variant.bundleProducts;return!!e&&((null==e?void 0:e.length)===(null==i?void 0:i.length)&&(null==e?void 0:e.every(function(t){return!!(null==i?void 0:i.find(function(n){return n.id===t.id&&n.quantity===t.quantity&&t.product&&n.variant.id===d(t.product).id}))})))}function P(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiSaveCartCouponCode)({cartId:r.id,couponCode:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(a.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function T(r){return t(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,P(r,null)];case 1:return[2,t.sent()]}})})}function q(r,e){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return[4,import("../../api/cart/index.js")];case 1:return[4,(0,n.sent().apiRemoveGiftCardFromCart)({cartId:r.id,giftCardId:e})];case 2:return(t=n.sent()).isSuccess&&t.data&&(a.cart=t.data),[2,{success:t.isSuccess,response:t}]}})})}function A(t){t.cart&&0===c(t.cart)&&O(t)}function E(){return t(this,void 0,void 0,function(){var t,r,e,s,u,c;return n(this,function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,8,9,10]),a.isCartLoading=!0,[4,m(o)];case 2:return n.sent(),t=null===(u=o.customer)||void 0===u?void 0:u.id,(r=(null===(c=a.cart)||void 0===c?void 0:c.id)||localStorage.getItem(i))||t?[4,import("../../api/cart/index.js")]:[2];case 3:return[4,(0,n.sent().apiGetCartById)({id:r})];case 4:return(e=n.sent()).isSuccess&&e.data?[4,U(e.data)]:[3,6];case 5:return n.sent(),[3,7];case 6:if(e.isCancelled||e.isNetworkError)return[2];O(a),n.label=7;case 7:return[3,10];case 8:return s=n.sent(),console.log(s),[3,10];case 9:return a.isCartLoading=!1,a.isCartInitialLoadFinished=!0,[7];case 10:return[2]}})})}function k(t){var n=t.filter(function(t){return t.isSelected&&!f(t)}).map(function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:d(t.product).id}})||[];return n.length?n:void 0}function F(r,i){return t(this,arguments,void 0,function(t,r,i){var a,o,s,u,c,l,f,v,p,m,h,g,b,y,C;return void 0===i&&(i=1),n(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,5]),a=e.salesChannelId,o=e.storefrontThemeId,a&&o?(s=d(r))?[4,I(s,r,i,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}];case 1:return(u=t.sent()).success&&(null===(p=null===(v=u.response)||void 0===v?void 0:v.data)||void 0===p?void 0:p.id)?(c=u.response.data.id,[4,import("../../api/cart/index.js")]):[2,{success:!1,error:(null===(g=null===(h=null===(m=u.response)||void 0===m?void 0:m.graphQLErrors)||void 0===h?void 0:h[0])||void 0===g?void 0:g.message)||"Failed to create cart"}];case 2:return[4,(0,t.sent().apiCreatePayWithIkasSessionUrl)({cartId:c})];case 3:return!(l=t.sent()).data||(null===(b=l.graphQLErrors)||void 0===b?void 0:b.length)?[2,{success:!1,error:(null===(C=null===(y=l.graphQLErrors)||void 0===y?void 0:y[0])||void 0===C?void 0:C.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:l.data.payUrl,expiresAt:l.data.expiresAt}];case 4:return f=t.sent(),console.log("error",f),[2,{success:!1,error:f instanceof Error?f.message:"Unknown error occurred"}];case 5:return[2]}})})}function U(r){return t(this,void 0,void 0,function(){return n(this,function(t){return localStorage.setItem(i,r.id),a.cart=r,[2]})})}function Q(){return t(this,void 0,void 0,function(){var t;return n(this,function(n){switch(n.label){case 0:return t=localStorage.getItem(i),!a.cart||t?[3,1]:(O(a),[3,3]);case 1:return a.cart||!t?[3,3]:[4,E()];case 2:n.sent(),n.label=3;case 3:return[2]}})})}function N(t){if(t&&t.options){for(var n=[],r=0,e=t.options;r<e.length;r++){var i=e[r],a={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map(function(t){return t.value})};n.push(a)}return n}return null}function D(t){var n,r=[],e=new Set,i=function(t){var n;e.has(t.id)||(e.add(t.id),t.values.length&&r.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values}),null===(n=t.childOptions)||void 0===n||n.forEach(i))};return null===(n=t.productOptionSet)||void 0===n||n.options.filter(function(t){return!t.requiredOptionId}).forEach(i),r}function R(i){return t(this,void 0,void 0,function(){var t,o,c,d,l,f,v,p,m,h,I;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,10,,11]),[4,Q()];case 1:return n.sent(),t=i.itemId?null===(m=a.cart)||void 0===m?void 0:m.orderLineItems.find(function(t){return t.id===i.itemId}):null,[4,import("../../api/cart/index.js")];case 2:return[4,(0,n.sent().apiAddItemToCart)({input:{cartId:(null===(h=a.cart)||void 0===h?void 0:h.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:e.priceListId||null,salesChannelId:e.salesChannelId,storefrontThemeId:e.storefrontThemeId,metadata:r({_fbp:s("_fbp"),_fbc:s("_fbc"),_ga:s("_ga")},u())}})];case 3:return(o=n.sent()).isSuccess&&o.data?(i.itemId||(c=(null===(I=a.cart)||void 0===I?void 0:I.orderLineItems.map(function(t){return t.id}))||[],d=o.data.orderLineItems.map(function(t){return t.id}),(l=d.find(function(t){return!c.includes(t)}))&&(t=o.data.orderLineItems.find(function(t){return t.id===l}))),[4,U(o.data)]):[3,5];case 4:n.sent(),n.label=5;case 5:return a.cart&&t?(f="".concat(a.cart.id,"-").concat(a.cart.updatedAt),(v=i.quantity)>i.quantity?[4,import("../../../analytics/analytics-functions/removeFromCart.js")]:[3,7]):[3,9];case 6:return(0,n.sent().anl_removeFromCart)(t,v-i.quantity,a.cart),[3,9];case 7:return[4,import("../../../analytics/analytics-functions/addToCart.js")];case 8:(0,n.sent().anl_addToCart)(t,i.quantity-v,f,a.cart),n.label=9;case 9:return A(a),[2,{success:o.isSuccess,response:o}];case 10:return p=n.sent(),console.log(p),[2,{success:!1}];case 11:return[2]}})})}function V(t){var n;return!!t.cart&&(null===(n=t.cart.orderLineItems)||void 0===n?void 0:n.length)>0}export{I as addItemToCart,g as addSelectedtedVariantToCart,y as changeCartItemQuantity,b as changeItemQuantity,F as createPayWithIkasSession,j as findExistingCartItem,w as findExistingCartItemWithProduct,k as getAcceptedOffers,E as getCart,h as getCheckoutUrlFromCartStore,V as hasCart,C as isOrderLineItemAutoCreated,O as removeCart,T as removeCouponCode,q as removeGiftCardLine,S as removeItem,P as saveCouponCode,U as setCart,_ as waitForCartStoreInit,R as windowAddToCart};