@ikas/storefront 5.0.0-beta.33 → 5.0.0-beta.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/build/_virtual/lodash.js +1 -0
  2. package/build/analytics/analytics.js +1 -1
  3. package/build/analytics/googleAnalytics.js +1 -1
  4. package/build/analytics/googleTagManager.js +1 -1
  5. package/build/analytics/ikas.js +1 -1
  6. package/build/analytics/tiktokPixel.js +1 -1
  7. package/build/components/checkout/components/address-form/index.js +1 -1
  8. package/build/components/checkout/components/address-form/model.js +1 -1
  9. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  10. package/build/components/checkout/components/customer-addresses/model.js +1 -1
  11. package/build/components/checkout/components/phone-number-input/get-countries.js +1 -1
  12. package/build/components/checkout/components/phone-number-input/index.js +1 -1
  13. package/build/components/checkout/components/quick-registration/model.js +1 -1
  14. package/build/components/checkout/index.js +1 -1
  15. package/build/components/checkout/model.js +1 -1
  16. package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
  17. package/build/components/checkout/steps/step-success/index.js +1 -1
  18. package/build/components/google-captcha/index.js +1 -1
  19. package/build/components/page/ThemeComponent.js +1 -1
  20. package/build/components/page/head.js +1 -1
  21. package/build/components/page/index.js +1 -1
  22. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  23. package/build/components/page-editor/model.js +1 -1
  24. package/build/hooks/useCustomerReviews.js +1 -1
  25. package/build/index.js +1 -1
  26. package/build/models/data/customer/address/ikas-localized-customer-address.js +1 -1
  27. package/build/models/data/order/address/ikas-localized-order-address.js +1 -1
  28. package/build/models/data/product/campaign-offer/index.js +1 -1
  29. package/build/models/data/product/variant/index.js +1 -1
  30. package/build/models/ui/blog-category-list/index.js +1 -1
  31. package/build/models/ui/brand-list/index.js +1 -1
  32. package/build/models/ui/category-list/index.js +1 -1
  33. package/build/models/ui/customer-review-list/index.js +1 -1
  34. package/build/models/ui/customer-review-summary-list/index.js +1 -1
  35. package/build/models/ui/product-list/index.js +1 -1
  36. package/build/models/ui/raffle-list/index.js +1 -1
  37. package/build/models/ui/validator/form/account-info.js +1 -1
  38. package/build/models/ui/validator/form/address.js +1 -1
  39. package/build/models/ui/validator/form/contact-form.js +1 -1
  40. package/build/models/ui/validator/form/customer-review.js +1 -1
  41. package/build/models/ui/validator/form/forgot-password.js +1 -1
  42. package/build/models/ui/validator/form/ikas-address.js +1 -1
  43. package/build/models/ui/validator/form/login.js +1 -1
  44. package/build/models/ui/validator/form/raffle-form.js +1 -1
  45. package/build/models/ui/validator/form/recover-password.js +1 -1
  46. package/build/models/ui/validator/form/register.js +1 -1
  47. package/build/node_modules/@ikas/localized-address/build/_virtual/_tslib.js +1 -0
  48. package/build/node_modules/@ikas/localized-address/build/models/address/index.js +1 -0
  49. package/build/node_modules/@ikas/localized-address/build/models/address/model.js +1 -0
  50. package/build/node_modules/libphonenumber-js/es6/AsYouType.js +1 -0
  51. package/build/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternMatcher.js +1 -0
  52. package/build/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternParser.js +1 -0
  53. package/build/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.complete.js +1 -0
  54. package/build/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.js +1 -0
  55. package/build/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.util.js +1 -0
  56. package/build/node_modules/libphonenumber-js/es6/AsYouTypeParser.js +1 -0
  57. package/build/node_modules/libphonenumber-js/es6/AsYouTypeState.js +1 -0
  58. package/build/node_modules/libphonenumber-js/es6/ParseError.js +1 -0
  59. package/build/node_modules/libphonenumber-js/es6/PhoneNumber.js +1 -0
  60. package/build/node_modules/libphonenumber-js/es6/constants.js +1 -0
  61. package/build/node_modules/libphonenumber-js/es6/format.js +1 -0
  62. package/build/node_modules/libphonenumber-js/es6/formatIncompletePhoneNumber.js +1 -0
  63. package/build/node_modules/libphonenumber-js/es6/getCountries.js +1 -0
  64. package/build/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +1 -0
  65. package/build/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +1 -0
  66. package/build/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +1 -0
  67. package/build/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +1 -0
  68. package/build/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +1 -0
  69. package/build/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +1 -0
  70. package/build/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +1 -0
  71. package/build/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +1 -0
  72. package/build/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +1 -0
  73. package/build/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +1 -0
  74. package/build/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +1 -0
  75. package/build/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +1 -0
  76. package/build/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +1 -0
  77. package/build/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +1 -0
  78. package/build/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +1 -0
  79. package/build/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +1 -0
  80. package/build/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +1 -0
  81. package/build/node_modules/libphonenumber-js/es6/helpers/isObject.js +1 -0
  82. package/build/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +1 -0
  83. package/build/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +1 -0
  84. package/build/node_modules/libphonenumber-js/es6/helpers/mergeArrays.js +1 -0
  85. package/build/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +1 -0
  86. package/build/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +1 -0
  87. package/build/node_modules/libphonenumber-js/es6/isPossible.js +1 -0
  88. package/build/node_modules/libphonenumber-js/es6/isValid.js +1 -0
  89. package/build/node_modules/libphonenumber-js/es6/metadata.js +1 -0
  90. package/build/node_modules/libphonenumber-js/es6/normalizeArguments.js +1 -0
  91. package/build/node_modules/libphonenumber-js/es6/parse.js +1 -0
  92. package/build/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +1 -0
  93. package/build/node_modules/libphonenumber-js/es6/parsePhoneNumber.js +1 -0
  94. package/build/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +1 -0
  95. package/build/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +1 -0
  96. package/build/node_modules/libphonenumber-js/es6/tools/semver-compare.js +1 -0
  97. package/build/node_modules/libphonenumber-js/metadata.min.json.js +1 -0
  98. package/build/node_modules/libphonenumber-js/min/exports/formatIncompletePhoneNumber.js +1 -0
  99. package/build/node_modules/libphonenumber-js/min/exports/getCountries.js +1 -0
  100. package/build/node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js +1 -0
  101. package/build/node_modules/libphonenumber-js/min/exports/isSupportedCountry.js +1 -0
  102. package/build/node_modules/libphonenumber-js/min/exports/parsePhoneNumber.js +1 -0
  103. package/build/node_modules/libphonenumber-js/min/exports/withMetadataArgument.js +1 -0
  104. package/build/node_modules/lodash/lodash.js +9 -0
  105. package/build/pages/checkout/index.page.js +1 -1
  106. package/build/providers/page-data-init.js +1 -1
  107. package/build/providers/prop-value/blog-category-list.js +1 -1
  108. package/build/providers/prop-value/blog-list.js +1 -1
  109. package/build/providers/prop-value/brand-list.js +1 -1
  110. package/build/providers/prop-value/category-list.js +1 -1
  111. package/build/providers/prop-value/product-list.js +1 -1
  112. package/build/providers/prop-value/raffle-list.js +1 -1
  113. package/build/store/blog/index.js +1 -1
  114. package/build/store/brand/index.js +1 -1
  115. package/build/store/cart/index.js +1 -1
  116. package/build/store/category/index.js +1 -1
  117. package/build/store/checkout/index.js +1 -1
  118. package/build/store/customer/api.js +1 -1
  119. package/build/store/customer/index.js +1 -1
  120. package/build/store/html-meta-data/index.js +1 -1
  121. package/build/store/location/index.js +1 -1
  122. package/build/store/product/index.js +1 -1
  123. package/package.json +12 -14
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as s from"react";import{observer as d}from"mobx-react-lite";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../../node_modules/lodash/sortBy.js";import{IkasProductOptionType as t}from"../../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../../node_modules/lodash/_baseClone.js";import"mobx";import"../../../../../models/data/brand/index.js";import"../../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/category/conditions/index.js";import{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/localized-address";import"../../../../../node_modules/lodash/_defineProperty.js";import"../../../../../node_modules/lodash/isArguments.js";import"../../../../../node_modules/lodash/isBuffer.js";import"../../../../../node_modules/lodash/isTypedArray.js";import"../../../../../node_modules/lodash/_baseGetTag.js";import"../../../../../node_modules/lodash/_Stack.js";import"../../../../../node_modules/lodash/_SetCache.js";import"../../../../../node_modules/lodash/_equalByTag.js";import"../../../../../node_modules/lodash/_getTag.js";import"../../../../../node_modules/lodash/_stringToPath.js";import"../../../../../node_modules/lodash/_baseToString.js";import"../../../../../store/base.js";import"../../../../../node_modules/lodash/xorBy.js";import"../../../../../analytics/analytics.js";import"../../../../../analytics/head/index.js";import"../../../../../store/cart/index.js";import{useTranslation as r}from"../../../../../utils/i18n.js";import"../../../../../node_modules/lodash/_isFlattenable.js";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/validator/rules/index.js";import{Modal as l}from"../../modal/index.js";import{BundleProductItem as n}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import a from"./svg/arrow-down.js";import u from"./style.module.scss.js";const c=d((({vm:d,currencyCode:c,cartItem:p,stockErrorItem:j,onChange:h})=>{const{t:f}=r(),b=!j,_=s.useRef(null),[x,k]=s.useState(0),[v,g]=s.useState(!1),[y,N]=s.useState(!1);s.useEffect((()=>{if(_.current){let e=24;Array.from(_.current.children).map((o=>e=e+o.clientHeight+12)),k(e)}}),[]),s.useEffect((()=>{_.current&&(_.current.style.maxHeight=y?`${x}px`:"0")}),[y]);const C=s.useMemo((()=>e("div",{children:p.options?.map((s=>{switch(s.type){case t.TEXT:case t.TEXT_AREA:case t.CHOICE:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>e.name||e.value)).join(", ")})]});case t.DATE_PICKER:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>(e=>{const o=i(new Date(e)).split(" ");return o.splice(-1),o.join(" ")})(e.value))).join(", ")})]});case t.FILE:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>{return o=e.value,decodeURIComponent(o.split("/")[o.split("/").length-1]);var o})).join(", ")})]});case t.CHECKBOX:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.length&&"true"===s.values[0].value?f("checkout-page:yes"):f("checkout-page:no")})]});case t.COLOR_PICKER:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionsHorContainer,children:s.values.map(((o,s)=>e("div",{className:u.OptionColorValue,style:{backgroundColor:o.value}},s)))})]})}}))})),[]),O=[u.BundleProductsContainer,y?u.VisibleBundleProducts:""].join(" ");return o(s.Fragment,{children:[o("div",{className:u.CheckoutItem,children:[o("div",{className:u.ImageContainer,children:[e("img",{className:u.Image,src:p.variant.mainImage?.thumbnailSrc}),e("div",{className:u.QuantityCircle,children:p.quantity})]}),o("div",{className:u.Center,children:[!!j&&o("div",{className:u.StockErrorItemMain,children:[o("span",{children:[p.quantity," ",f("checkout-page:quantity")]}),e("span",{children:e(m,{})}),o("span",{children:[j.stockCount<0?0:j.stockCount," ",f("checkout-page:quantity")]})]}),e("div",{className:u.Name,children:p.variant.name}),e("div",{className:[u.LightText,u.Small].join(" "),children:p.variant.variantValues?.map((e=>e.variantValueName)).join(" / ")}),!!p.options?.length&&e("div",{className:u.OptionsText,onClick:()=>g(!0),children:f("checkout-page:customizedProduct")}),p.variant.bundleProducts&&0!==p.variant.bundleProducts.length&&o("div",{className:u.BundleProducts,onClick:()=>{N(!y),h&&setTimeout((()=>{h(!y)}),200)},children:[f("checkout-page:bundleProductsQuantity",{value:p.variant.bundleProducts.length}),e("span",{style:{paddingTop:2,transform:y?void 0:"rotate(180deg)"},children:e(a,{})})]}),!!v&&e(l,{title:p.variant.name,modalContent:C,onClose:()=>g(!1)})]}),b&&o("div",{className:u.Right,children:[o("div",{className:u.Price,children:[!!p.overridenPriceWithQuantity&&e("span",{className:u.GrayPrice,children:p.formattedOverridenPriceWithQuantity}),p.formattedFinalPriceWithQuantity]}),p.unitPriceText&&e("div",{className:[u.LightText,u.Small].join(" "),children:p.unitPriceText})]})]}),e("div",{ref:_,className:O,children:p.variant.bundleProducts?.map((o=>e(n,{bundleProduct:o})))})]})}));export{c as CartItem};
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as s from"react";import{observer as d}from"mobx-react-lite";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../../node_modules/lodash/sortBy.js";import{IkasProductOptionType as i}from"../../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../../node_modules/lodash/_baseClone.js";import"mobx";import"../../../../../models/data/brand/index.js";import"../../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/category/conditions/index.js";import{formatDate as t}from"../../../../../utils/helper.js";import"../../../../../node_modules/@ikas/localized-address/build/models/address/index.js";import"../../../../../node_modules/@ikas/localized-address/build/models/address/model.js";import"../../../../../node_modules/lodash/_defineProperty.js";import"../../../../../node_modules/lodash/isArguments.js";import"../../../../../node_modules/lodash/isBuffer.js";import"../../../../../node_modules/lodash/isTypedArray.js";import"../../../../../node_modules/lodash/_baseGetTag.js";import"../../../../../node_modules/lodash/_Stack.js";import"../../../../../node_modules/lodash/_SetCache.js";import"../../../../../node_modules/lodash/_equalByTag.js";import"../../../../../node_modules/lodash/_getTag.js";import"../../../../../node_modules/lodash/_stringToPath.js";import"../../../../../node_modules/lodash/_baseToString.js";import"../../../../../store/base.js";import"../../../../../node_modules/lodash/xorBy.js";import"../../../../../analytics/analytics.js";import"../../../../../analytics/head/index.js";import"../../../../../store/cart/index.js";import{useTranslation as r}from"../../../../../utils/i18n.js";import"../../../../../node_modules/lodash/_isFlattenable.js";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/validator/rules/index.js";import{Modal as l}from"../../modal/index.js";import{BundleProductItem as n}from"./bundle-product-item/index.js";import m from"./svg/arrow-right.js";import a from"./svg/arrow-down.js";import u from"./style.module.scss.js";const c=d((({vm:d,currencyCode:c,cartItem:p,stockErrorItem:j,onChange:h})=>{const{t:f}=r(),b=!j,_=s.useRef(null),[x,k]=s.useState(0),[v,g]=s.useState(!1),[y,N]=s.useState(!1);s.useEffect((()=>{if(_.current){let e=24;Array.from(_.current.children).map((o=>e=e+o.clientHeight+12)),k(e)}}),[]),s.useEffect((()=>{_.current&&(_.current.style.maxHeight=y?`${x}px`:"0")}),[y]);const C=s.useMemo((()=>e("div",{children:p.options?.map((s=>{switch(s.type){case i.TEXT:case i.TEXT_AREA:case i.CHOICE:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>e.name||e.value)).join(", ")})]});case i.DATE_PICKER:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>(e=>{const o=t(new Date(e)).split(" ");return o.splice(-1),o.join(" ")})(e.value))).join(", ")})]});case i.FILE:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.map((e=>{return o=e.value,decodeURIComponent(o.split("/")[o.split("/").length-1]);var o})).join(", ")})]});case i.CHECKBOX:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionValue,children:s.values.length&&"true"===s.values[0].value?f("checkout-page:yes"):f("checkout-page:no")})]});case i.COLOR_PICKER:return o("div",{className:u.OptionRow,children:[e("div",{className:u.OptionName,children:s.name}),e("div",{className:u.OptionsHorContainer,children:s.values.map(((o,s)=>e("div",{className:u.OptionColorValue,style:{backgroundColor:o.value}},s)))})]})}}))})),[]),O=[u.BundleProductsContainer,y?u.VisibleBundleProducts:""].join(" ");return o(s.Fragment,{children:[o("div",{className:u.CheckoutItem,children:[o("div",{className:u.ImageContainer,children:[e("img",{className:u.Image,src:p.variant.mainImage?.thumbnailSrc}),e("div",{className:u.QuantityCircle,children:p.quantity})]}),o("div",{className:u.Center,children:[!!j&&o("div",{className:u.StockErrorItemMain,children:[o("span",{children:[p.quantity," ",f("checkout-page:quantity")]}),e("span",{children:e(m,{})}),o("span",{children:[j.stockCount<0?0:j.stockCount," ",f("checkout-page:quantity")]})]}),e("div",{className:u.Name,children:p.variant.name}),e("div",{className:[u.LightText,u.Small].join(" "),children:p.variant.variantValues?.map((e=>e.variantValueName)).join(" / ")}),!!p.options?.length&&e("div",{className:u.OptionsText,onClick:()=>g(!0),children:f("checkout-page:customizedProduct")}),p.variant.bundleProducts&&0!==p.variant.bundleProducts.length&&o("div",{className:u.BundleProducts,onClick:()=>{N(!y),h&&setTimeout((()=>{h(!y)}),200)},children:[f("checkout-page:bundleProductsQuantity",{value:p.variant.bundleProducts.length}),e("span",{style:{paddingTop:2,transform:y?void 0:"rotate(180deg)"},children:e(a,{})})]}),!!v&&e(l,{title:p.variant.name,modalContent:C,onClose:()=>g(!1)})]}),b&&o("div",{className:u.Right,children:[o("div",{className:u.Price,children:[!!p.overridenPriceWithQuantity&&e("span",{className:u.GrayPrice,children:p.formattedOverridenPriceWithQuantity}),p.formattedFinalPriceWithQuantity]}),p.unitPriceText&&e("div",{className:[u.LightText,u.Small].join(" "),children:p.unitPriceText})]})]}),e("div",{ref:_,className:O,children:p.variant.bundleProducts?.map((o=>e(n,{bundleProduct:o})))})]})}));export{c as CartItem};
@@ -1 +1 @@
1
- import{makeAutoObservable as s}from"mobx";import e from"../../../../node_modules/lodash/cloneDeep.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../node_modules/lodash/sortBy.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../models/data/brand/index.js";import"../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/category/conditions/index.js";import"@ikas/localized-address";import{IkasCustomerAddress as o}from"../../../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as d}from"../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../node_modules/lodash/_defineProperty.js";import"../../../../node_modules/lodash/isArguments.js";import"../../../../node_modules/lodash/isBuffer.js";import"../../../../node_modules/lodash/isTypedArray.js";import"../../../../node_modules/lodash/_baseGetTag.js";import"../../../../node_modules/lodash/_Stack.js";import"../../../../node_modules/lodash/_SetCache.js";import"../../../../node_modules/lodash/_equalByTag.js";import"../../../../node_modules/lodash/_getTag.js";import"../../../../node_modules/lodash/_stringToPath.js";import"../../../../node_modules/lodash/_baseToString.js";import"../../../../store/base.js";import"../../../../node_modules/lodash/xorBy.js";import"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";import"../../../../store/cart/index.js";import"fs";import"path";import"../../../../node_modules/lodash/_isFlattenable.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/validator/rules/index.js";class t{constructor(t,i){this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=s=>{("shipping"===this.addressType?this.vm.onSelectedShippingAddressIdChange:this.vm.onSelectedBillingAddressIdChange)(s?.id||"-1")},this.onEditAddressClick=s=>{const o=new d(e(s));o.countrySettings=this.vm.countrySettings,o.checkoutSettings=this.vm.checkoutSettings,this.editingCustomerAddress=o},this.onCancelEditAddressClick=()=>{this.isDeleteAddressLoading||this.isEditAddressLoading||(this.editingCustomerAddress=null)},this.onDeleteAddressClick=async()=>{const s=this.vm.store.customerStore.customer?.addresses?.findIndex((s=>s.id===this.editingCustomerAddress?.id));if(-1!==s&&void 0!==s){const o=e(this.vm.store.customerStore.customer);o.addresses?.splice(s,1);try{this.isDeleteAddressLoading=!0;await this.vm.store.customerStore.saveCustomer(o)&&(this.editingCustomerAddress=null)}catch{}finally{this.isDeleteAddressLoading=!1}}},this.onSaveAddressClick=async()=>{if(this.isDeleteAddressLoading||this.isEditAddressLoading)return;if(!this.editingCustomerAddress?.isValidAddress)return void(this.isEditAddressErrorsVisible=!0);const s=this.vm.store.customerStore.customer?.addresses?.findIndex((s=>s.id===this.editingCustomerAddress?.id));if(-1!==s&&void 0!==s){const d=e(this.vm.store.customerStore.customer);d.addresses[s]=new o(e(this.editingCustomerAddress));try{this.isEditAddressLoading=!0;await this.vm.store.customerStore.saveCustomer(d)&&(this.vm.store.customerStore.customer?.addresses?.forEach((s=>s.checkoutSettings=this.vm.checkoutSettings)),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1)}catch{}finally{this.isEditAddressLoading=!1}}},this.firstNameChangeCallback=s=>{(!this.vm.checkout.hasCustomer&&"shipping"===this.addressType||this.vm.isDigitalOnly)&&(this.vm.checkout.customer.firstName=s)},this.lastNameChangeCallback=s=>{(!this.vm.checkout.hasCustomer&&"shipping"===this.addressType||this.vm.isDigitalOnly)&&(this.vm.checkout.customer.lastName=s)},this.vm=t,this.addressType=i,s(this)}get address(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress}get selectedAddressId(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId}}export{t as default};
1
+ import{makeAutoObservable as s}from"mobx";import e from"../../../../node_modules/lodash/cloneDeep.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../node_modules/lodash/sortBy.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../models/data/brand/index.js";import"../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/category/conditions/index.js";import"../../../../node_modules/@ikas/localized-address/build/models/address/index.js";import"../../../../node_modules/@ikas/localized-address/build/models/address/model.js";import{IkasCustomerAddress as o}from"../../../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as d}from"../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../node_modules/lodash/_defineProperty.js";import"../../../../node_modules/lodash/isArguments.js";import"../../../../node_modules/lodash/isBuffer.js";import"../../../../node_modules/lodash/isTypedArray.js";import"../../../../node_modules/lodash/_baseGetTag.js";import"../../../../node_modules/lodash/_Stack.js";import"../../../../node_modules/lodash/_SetCache.js";import"../../../../node_modules/lodash/_equalByTag.js";import"../../../../node_modules/lodash/_getTag.js";import"../../../../node_modules/lodash/_stringToPath.js";import"../../../../node_modules/lodash/_baseToString.js";import"../../../../store/base.js";import"../../../../node_modules/lodash/xorBy.js";import"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";import"../../../../store/cart/index.js";import"fs";import"path";import"../../../../node_modules/lodash/_isFlattenable.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/validator/rules/index.js";class t{constructor(t,i){this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=s=>{("shipping"===this.addressType?this.vm.onSelectedShippingAddressIdChange:this.vm.onSelectedBillingAddressIdChange)(s?.id||"-1")},this.onEditAddressClick=s=>{const o=new d(e(s));o.countrySettings=this.vm.countrySettings,o.checkoutSettings=this.vm.checkoutSettings,this.editingCustomerAddress=o},this.onCancelEditAddressClick=()=>{this.isDeleteAddressLoading||this.isEditAddressLoading||(this.editingCustomerAddress=null)},this.onDeleteAddressClick=async()=>{const s=this.vm.store.customerStore.customer?.addresses?.findIndex((s=>s.id===this.editingCustomerAddress?.id));if(-1!==s&&void 0!==s){const o=e(this.vm.store.customerStore.customer);o.addresses?.splice(s,1);try{this.isDeleteAddressLoading=!0;await this.vm.store.customerStore.saveCustomer(o)&&(this.editingCustomerAddress=null)}catch{}finally{this.isDeleteAddressLoading=!1}}},this.onSaveAddressClick=async()=>{if(this.isDeleteAddressLoading||this.isEditAddressLoading)return;if(!this.editingCustomerAddress?.isValidAddress)return void(this.isEditAddressErrorsVisible=!0);const s=this.vm.store.customerStore.customer?.addresses?.findIndex((s=>s.id===this.editingCustomerAddress?.id));if(-1!==s&&void 0!==s){const d=e(this.vm.store.customerStore.customer);d.addresses[s]=new o(e(this.editingCustomerAddress));try{this.isEditAddressLoading=!0;await this.vm.store.customerStore.saveCustomer(d)&&(this.vm.store.customerStore.customer?.addresses?.forEach((s=>s.checkoutSettings=this.vm.checkoutSettings)),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1)}catch{}finally{this.isEditAddressLoading=!1}}},this.firstNameChangeCallback=s=>{(!this.vm.checkout.hasCustomer&&"shipping"===this.addressType||this.vm.isDigitalOnly)&&(this.vm.checkout.customer.firstName=s)},this.lastNameChangeCallback=s=>{(!this.vm.checkout.hasCustomer&&"shipping"===this.addressType||this.vm.isDigitalOnly)&&(this.vm.checkout.customer.lastName=s)},this.vm=t,this.addressType=i,s(this)}get address(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress}get selectedAddressId(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId}}export{t as default};
@@ -1 +1 @@
1
- import{IkasStorefrontConfig as t}from"../../../../node_modules/@ikas/storefront-config/build/index.js";import{getCountries as e}from"libphonenumber-js";import o from"./compare-strings.js";const r=async()=>{const r=(()=>{let e=t.getCurrentLocale();return["de","el","en","es","fi","fr","it","nb","pl","pt-BR","pt","ru","sv","tr","ua","vi"].some((t=>t===e))||(e="en"),`https://cdn.myikas.com/sf/static/locale/country/${e}.json`})(),s=await fetch(r),n=await s.json();return e().map((t=>({value:t,label:n[t]}))).sort(((t,e)=>o(t.label,e.label)))};export{r as default};
1
+ import{IkasStorefrontConfig as e}from"../../../../node_modules/@ikas/storefront-config/build/index.js";import t from"./compare-strings.js";import{getCountries as o}from"../../../../node_modules/libphonenumber-js/min/exports/getCountries.js";const s=async()=>{const s=(()=>{let t=e.getCurrentLocale();return["de","el","en","es","fi","fr","it","nb","pl","pt-BR","pt","ru","sv","tr","ua","vi"].some((e=>e===t))||(t="en"),`https://cdn.myikas.com/sf/static/locale/country/${t}.json`})(),r=await fetch(s),n=await r.json();return o().map((e=>({value:e,label:n[e]}))).sort(((e,o)=>t(e.label,o.label)))};export{s as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import*as a from"react";import{observer as l}from"mobx-react-lite";import s,{isSupportedCountry as r,formatIncompletePhoneNumber as o,getCountryCallingCode as c,parseIncompletePhoneNumber as n}from"libphonenumber-js";import i from"./get-countries.js";import m from"./style.module.scss.js";const u=l((({defaultCountry:l,disabled:u=!1,placeholder:d,value:g,onChange:v})=>{const[p,f]=a.useState([]),[h,y]=a.useState(l||"TR"),[b,N]=a.useState("");a.useEffect((()=>{C();let e=h;if(r(e)||(e="US"),g){const t=s(g);t&&t.country&&(e=t.country),N(o(g,e))}else S(e);y(e)}),[l]);const C=async()=>{const e=await i();f(e)},S=e=>{const t=c(e);N(`+${t}`)},F=e=>o(e,h);return e(a.Fragment,{children:[t("div",{className:m.SelectFlag,children:e("div",{className:m.FlagContainer,children:[e("div",{className:m.Flag,children:[t("img",{className:m.FlagImage,alt:h,src:`https://cdn.myikas.com/sf/assets/flags/3x2/${h}.svg`}),t("div",{className:m.Arrow})]}),t("select",{className:m.Select,value:h,onChange:e=>{if(e.target.value){const t=e.target.value;y(t),S(t)}},disabled:u,children:p.map((e=>t("option",{value:e.value,children:e.label},e.value)))})]})}),t("input",{type:"tel",autoComplete:"tel",className:m.Input,value:b,onChange:e=>{const t=p.find((t=>t.value===s(e.target.value)?.country));t&&y(t.value);const a=F(e.target.value);N(a),v(a?n(a):e.target.value)},placeholder:d,disabled:u})]})}));export{u as PhoneNumberInput};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import*as o from"react";import{observer as s}from"mobx-react-lite";import a from"./get-countries.js";import r from"./style.module.scss.js";import{isSupportedCountry as l}from"../../../../node_modules/libphonenumber-js/min/exports/isSupportedCountry.js";import{parsePhoneNumber as n}from"../../../../node_modules/libphonenumber-js/min/exports/parsePhoneNumber.js";import{formatIncompletePhoneNumber as m}from"../../../../node_modules/libphonenumber-js/min/exports/formatIncompletePhoneNumber.js";import{getCountryCallingCode as i}from"../../../../node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js";import u from"../../../../node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js";const c=s((({defaultCountry:s,disabled:c=!1,placeholder:p,value:d,onChange:g})=>{const[h,f]=o.useState([]),[b,v]=o.useState(s||"TR"),[j,y]=o.useState("");o.useEffect((()=>{C();let e=b;if(l(e)||(e="US"),d){const t=n(d);t&&t.country&&(e=t.country),y(m(d,e))}else N(e);v(e)}),[s]);const C=async()=>{const e=await a();f(e)},N=e=>{const t=i(e);y(`+${t}`)},x=e=>m(e,b);return e(o.Fragment,{children:[t("div",{className:r.SelectFlag,children:e("div",{className:r.FlagContainer,children:[e("div",{className:r.Flag,children:[t("img",{className:r.FlagImage,alt:b,src:`https://cdn.myikas.com/sf/assets/flags/3x2/${b}.svg`}),t("div",{className:r.Arrow})]}),t("select",{className:r.Select,value:b,onChange:e=>{if(e.target.value){const t=e.target.value;v(t),N(t)}},disabled:c,children:h.map((e=>t("option",{value:e.value,children:e.label},e.value)))})]})}),t("input",{type:"tel",autoComplete:"tel",className:r.Input,value:j,onChange:e=>{const t=h.find((t=>t.value===n(e.target.value)?.country));t&&v(t.value);const o=x(e.target.value);y(o),g(o?u(o):e.target.value)},placeholder:p,disabled:c})]})}));export{c as PhoneNumberInput};
@@ -1 +1 @@
1
- import{makeAutoObservable as o,observable as e}from"mobx";import"../../../../models/data/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../node_modules/lodash/sortBy.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../node_modules/lodash/_baseClone.js";import"../../../../models/data/brand/index.js";import"../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/category/conditions/index.js";import"@ikas/localized-address";import"../../../../node_modules/lodash/_defineProperty.js";import"../../../../node_modules/lodash/isArguments.js";import"../../../../node_modules/lodash/isBuffer.js";import"../../../../node_modules/lodash/isTypedArray.js";import"../../../../node_modules/lodash/_baseGetTag.js";import"../../../../node_modules/lodash/_Stack.js";import"../../../../node_modules/lodash/_SetCache.js";import"../../../../node_modules/lodash/_equalByTag.js";import"../../../../node_modules/lodash/_getTag.js";import"../../../../node_modules/lodash/_stringToPath.js";import"../../../../node_modules/lodash/_baseToString.js";import"../../../../store/base.js";import"../../../../node_modules/lodash/xorBy.js";import"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";import"../../../../store/cart/index.js";import"fs";import"path";import"../../../../node_modules/lodash/_isFlattenable.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import{Validator as s}from"../../../../models/ui/validator/index.js";import{RequiredRule as d,MinRule as t}from"../../../../models/ui/validator/rules/index.js";class i{constructor(i,r){this.model={password:""},this._isLoading=!1,this._isRegisteredCustomer=!1,this.onPasswordChange=o=>{this.model.password=o},this.validateAll=()=>this.validator.validateAll(),this.onSubmit=async()=>{if(!await this.validateAll()){this._isLoading=!0;const o=await this.vm.registerCustomer(this.password);o?.isSuccess&&(this._isRegisteredCustomer=!0),this._isLoading=!1}},o(this,{model:e}),this.vm=i,this.t=r,this.validator=new s(this.model,[new d({fieldKey:"password",valuePath:"password",message:r("checkout-page:passwordRequiredError")}),new t({fieldKey:"password",valuePath:"password",minValue:6,message:r("checkout-page:passwordMinError",{value:6})})])}get password(){return this.model.password}get isLoading(){return this._isLoading}get isRegisteredCustomer(){return this._isRegisteredCustomer}get hasError(){return this.validator.hasError}get passwordErrorMessage(){return this.validator.results.password.errorMessage}}export{i as QuickRegistrationViewModel};
1
+ import{makeAutoObservable as o,observable as e}from"mobx";import"../../../../models/data/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../../../node_modules/lodash/sortBy.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../../../node_modules/@ikas/storefront-config/build/index.js";import"../../../../node_modules/lodash/_baseClone.js";import"../../../../models/data/brand/index.js";import"../../../../node_modules/@ikas/storefront-api/build/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/category/conditions/index.js";import"../../../../node_modules/@ikas/localized-address/build/models/address/index.js";import"../../../../node_modules/@ikas/localized-address/build/models/address/model.js";import"../../../../node_modules/lodash/_defineProperty.js";import"../../../../node_modules/lodash/isArguments.js";import"../../../../node_modules/lodash/isBuffer.js";import"../../../../node_modules/lodash/isTypedArray.js";import"../../../../node_modules/lodash/_baseGetTag.js";import"../../../../node_modules/lodash/_Stack.js";import"../../../../node_modules/lodash/_SetCache.js";import"../../../../node_modules/lodash/_equalByTag.js";import"../../../../node_modules/lodash/_getTag.js";import"../../../../node_modules/lodash/_stringToPath.js";import"../../../../node_modules/lodash/_baseToString.js";import"../../../../store/base.js";import"../../../../node_modules/lodash/xorBy.js";import"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";import"../../../../store/cart/index.js";import"fs";import"path";import"../../../../node_modules/lodash/_isFlattenable.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import{Validator as s}from"../../../../models/ui/validator/index.js";import{RequiredRule as d,MinRule as t}from"../../../../models/ui/validator/rules/index.js";class i{constructor(i,r){this.model={password:""},this._isLoading=!1,this._isRegisteredCustomer=!1,this.onPasswordChange=o=>{this.model.password=o},this.validateAll=()=>this.validator.validateAll(),this.onSubmit=async()=>{if(!await this.validateAll()){this._isLoading=!0;const o=await this.vm.registerCustomer(this.password);o?.isSuccess&&(this._isRegisteredCustomer=!0),this._isLoading=!1}},o(this,{model:e}),this.vm=i,this.t=r,this.validator=new s(this.model,[new d({fieldKey:"password",valuePath:"password",message:r("checkout-page:passwordRequiredError")}),new t({fieldKey:"password",valuePath:"password",minValue:6,message:r("checkout-page:passwordMinError",{value:6})})])}get password(){return this.model.password}get isLoading(){return this._isLoading}get isRegisteredCustomer(){return this._isRegisteredCustomer}get hasError(){return this.validator.hasError}get passwordErrorMessage(){return this.validator.results.password.errorMessage}}export{i as QuickRegistrationViewModel};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as o,Fragment as t}from"react/jsx-runtime";import*as s from"react";import{observer as i}from"mobx-react-lite";import r from"../../node_modules/react-tooltip/dist/index.es.js";import d,{CheckoutStep as n}from"./model.js";import{IkasStorefrontConfig as l}from"../../node_modules/@ikas/storefront-config/build/index.js";import{formatCurrency as c}from"../../utils/currency.js";import{useTranslation as m}from"../../utils/i18n.js";import a from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as h,Coupon as g,CartSummary as k}from"./components/cart-summary/index.js";import"../../models/data/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../node_modules/lodash/sortBy.js";import"../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import{IkasThemeJsonPageType as y}from"../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../node_modules/lodash/_baseClone.js";import"mobx";import"../../models/data/brand/index.js";import"../../node_modules/@ikas/storefront-api/build/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/category/conditions/index.js";import"@ikas/localized-address";import"../../node_modules/lodash/_defineProperty.js";import"../../node_modules/lodash/isArguments.js";import"../../node_modules/lodash/isBuffer.js";import"../../node_modules/lodash/isTypedArray.js";import"../../node_modules/lodash/_baseGetTag.js";import"../../node_modules/lodash/_Stack.js";import"../../node_modules/lodash/_SetCache.js";import"../../node_modules/lodash/_equalByTag.js";import"../../node_modules/lodash/_getTag.js";import"../../node_modules/lodash/_stringToPath.js";import"../../node_modules/lodash/_baseToString.js";import"../../store/base.js";import"../../node_modules/lodash/xorBy.js";import{Analytics as f}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../../store/cart/index.js";import"../../node_modules/lodash/_isFlattenable.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/validator/rules/index.js";import{ContactForm as b}from"../../models/ui/validator/form/contact-form.js";import{StepSuccess as x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import v from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import _ from"./components/master-pass/modal-success/index.js";import N,{Step as E}from"./components/step-container/index.js";import{StockError as S}from"./components/error/stock-error/index.js";import{FullscreenLoading as P}from"./components/fullscreen-loading/index.js";import T from"./components/notification-box/index.js";import{FormItem as F}from"./components/form-item/index.js";import{FormItemType as M}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import A from"./components/offer-product/index.js";import O from"./components/svg/ikas.js";import I from"./style.module.scss.js";import B from"./components/epaykolay-button/index.js";var L=i((({checkout:t,checkoutSettings:i,customizationProps:c,returnPolicy:a,privacyPolicy:p,termsOfService:u,imprint:h,shippingPolicy:g})=>{const{t:b}=m(),[N]=s.useState((()=>new d(t,i,a,p,u,h,g,b,c||{}))),E=s.useMemo((()=>Date.now()),[]);N.step===n.PAYMENT&&f.disableHTML();const T=async(e,o,t,s,i)=>{const r=`${process.env.PUBLIC_ENV__BASE_URL}/os/e-pay-kolay/get-basket`;return(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()},body:JSON.stringify({cartId:N.checkout.id,customerNumber:e,sessionsState:E,addressDto:t,paymentType:s,totalPrice:i})})).json()};s.useEffect((()=>{N.checkoutSettings.isAccountRequired&&!N.checkout.hasCustomer&&(window.location.href="/account/login?redirect="+encodeURIComponent(N.checkoutUrl)),f.beginCheckout(N.checkout),f.pageView(y.CHECKOUT)}),[]),s.useEffect((()=>{N.customizationProps=c,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",e?.buttonBgColor||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",e?.buttonTextColor||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",e?.buttonDisabledBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",e?.buttonDisabledTextColor||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",e?.primaryTextColor||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",e?.secondaryTextColor||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",e?.primaryBgColor||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",e?.secondaryBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",e?.borderColor||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",e?.cardBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",e?.errorColor||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",e?.errorLightColor||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",e?.warningColor||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",e?.warningLightColor||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",e?.successColor||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",e?.successLightColor||"#F6FFED")}(c)}),[c]),s.useEffect((()=>{if(N.isEPayKolayEnabled){const e=setInterval((()=>{window.setContainerService&&N.isCheckoutLoaded&&(window.setContainerService(l.getMerchantSettings()?.merchantId,T,(async e=>await F(e)),(()=>{console.log("Switching to epaykolay"),N.isEPayKolayPayment=!0}),`https://cdn-epeykolay.mncdn.com/${l.getApiUrl()?.includes("myikas.com")?"epay":"epay-uat"}/`),clearInterval(e))}),100)}}),[]);const F=s.useCallback((async e=>{const o=await fetch(`${process.env.PUBLIC_ENV__BASE_URL}/os/e-pay-kolay/complete-payment`,{method:"POST",body:JSON.stringify({data:e,cartId:N.checkout.id}),headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()}}),t=await o.json();return{redirectUrl:`${window.location.pathname}?id=${N.checkout.id}&step=${t.success?"success":"info"}`,orderId:t.orderNumber||null}}),[]);if(!N.isCheckoutLoaded||!N.store.customerStore.initialized)return o(P,{});if(N.checkout.hasCustomer&&N.store.customerStore.customer?.id!==N.checkout.customer?.id)return window.location.href="/account/login?redirect="+encodeURIComponent(N.checkoutUrl),null;return o(s.Fragment,{children:e("div",{id:"Checkout",className:I.CheckoutPage,children:[o(r,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:I.ReactTooltipWrap,globalEventOff:"touchstart"}),e("div",{className:[I.Left,N.isEPayKolayPayment?I.epaykolay:""].join(" "),children:[N.isEPayKolayEnabled&&o("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!N.isEPayKolayPayment&&e("div",{className:I.LeftContent,children:[e("div",{children:[o(V,{vm:N}),N.hasStockError&&o("div",{className:I.ErrorContainer,children:o(S,{vm:N,error:N.error})}),!N.hasStockError&&e(s.Fragment,{children:[o(k,{vm:N,allowExpand:!0}),o("div",{children:N.step!==n.SUCCESS&&N.isEPayKolayEnabled&&o(B,{onClick:()=>{window.frictionless()}})}),N.step===n.SUCCESS?o(x,{vm:N}):e(s.Fragment,{children:[N.campaignOffer&&N.isCampaignOfferLoaded&&o(A,{vm:N,campaignOffer:N.campaignOffer}),N.isCouponCodeRequirementOpen&&o(U,{vm:N}),o(R,{vm:N})]})]}),o("div",{className:I.Space})]}),o(G,{vm:N})]})]}),o("div",{className:I.Right,children:e("div",{className:I.RightContent,children:[o(k,{vm:N}),!N.isPoweredByHidden&&e("div",{className:I.PoweredBy,children:[o("span",{children:"powered by"}),o("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank",children:o(O,{})})]})]})}),!!N.policyModalText&&o(j,{title:N.policyModalTitle,modalContent:N.policyModalText,onClose:()=>{N.policyModalText=""}}),N.isContactModalVisible&&o(H,{vm:N,setVisible:N.setContactModalVisible}),N.mpVM.isOtpModalVisible&&o(v,{vm:N,visible:N.mpVM.isOtpModalVisible,type:N.mpVM.otpModalType,onClose:N.mpVM.hideOtpModal}),N.mpVM.isResponseModalVisible&&o(C,{visible:N.mpVM.isResponseModalVisible,text:N.mpVM.mfsResponseModalText,onClose:N.mpVM.onResponseModalClose}),N.mpVM.isSuccessModalVisible&&o(_,{visible:N.mpVM.isSuccessModalVisible,type:N.mpVM.successModalType,onClose:N.mpVM.onSuccessModalClose})]})})}));const V=i((({vm:t})=>{const{t:s}=m();return e("div",{className:I.Header,children:[o("a",{href:"/",children:t.customizationProps?.logo?o("div",{className:I.Logo,children:o("img",{src:t.customizationProps.logo.getSrc(360)})}):t.merchantSettings?.logo?o("div",{className:I.Logo,children:o("img",{src:t.merchantSettings.logo.getSrc(360)})}):t.merchantSettings?.merchantName||""}),!t.checkout.hasCustomer&&e("div",{className:I.LoginText,children:[o("span",{className:I.LoginCta,children:s("checkout-page:alreadyHaveAnAccount")}),o("a",{href:"/account/login?redirect="+encodeURIComponent(t.checkoutUrl),className:I.LoginBtn,children:s("checkout-page:actions.login")})]}),t.checkout.hasCustomer&&e("div",{className:I.CustomerInfo,children:[o("div",{className:I.Name,children:t.checkout.customerFullName}),o("div",{className:I.Email,children:t.checkout.customer?.email})]})]})})),U=i((({vm:t})=>{const{t:i}=m(),[r,d]=s.useState(!1),[n,l]=s.useState(null),c=s.useMemo((()=>{switch(n){case h.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case h.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[n]);return e("div",{className:I.CouponContainer,children:[r&&o("div",{className:I.NotificationContainer,children:o(T,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:c,onClose:()=>{d(!1),l(null)},ignoreScroll:!0})}),o("div",{style:{marginTop:r?12:0},children:o(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:()=>{},setCouponError:d,setCouponErrorCode:l})})]})})),R=i((({vm:t})=>{const{t:i}=m(),r=s.useMemo((()=>{switch(t.step){case n.INFO:return o(a,{vm:t});case n.SHIPPING:return o(p,{vm:t});case n.PAYMENT:return o(u,{vm:t});case n.SUCCESS:return o(x,{vm:t})}}),[t,t.step]),d=[new E(i("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?e("div",{className:I.AdressStepInfo,children:[o(D,{vm:t}),!t.isUpsellOrder&&o("div",{className:I.EditBtn,onClick:t.onBackToInfoClick,children:i("checkout-page:actions.edit")})]}):void 0,t.step!==n.INFO?o("div",{className:I.AddressStepInfoMobile,children:o(D,{vm:t})}):void 0),new E(i("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||d.splice(1,0,new E(i("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?e("div",{className:I.AdressStepInfo,children:[o(K,{vm:t}),!t.isUpsellOrder&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o("div",{className:I.EditBtn,onClick:t.onBackToShippingClick,children:i("checkout-page:actions.edit")})]}):void 0,t.step===n.PAYMENT?o("div",{className:I.AddressStepInfoMobile,children:o(K,{vm:t})}):void 0)),o(N,{steps:d,stepContent:r})})),D=i((({vm:s})=>{const{t:i}=m(),r=s.isDigitalOnly?(s.checkout.billingAddress?.firstName||"")+" "+(s.checkout.billingAddress?.lastName||""):(s.checkout.shippingAddress?.firstName||"")+" "+(s.checkout.shippingAddress?.lastName||"");return e("div",{className:I.Address,children:[o("div",{className:[I.Text,I.WithMBottom].join(" "),children:s.checkout.customer?.email||""}),"address"===s.deliveryMethod?o("div",{className:I.Text,children:r}):e(t,{children:[o("div",{className:I.Text,children:i("checkout-page:receiver")}),o("div",{className:[I.Text,I.Gray].join(" "),children:r})]}),o("div",{className:[I.Text,I.Gray].join(" "),children:s.isDigitalOnly?s.checkout.billingAddress?.phone:s.checkout.shippingAddress?.phone}),"in-store"===s.deliveryMethod&&o(t,{children:o("div",{className:[I.Text,I.WithMTop].join(" "),children:i("checkout-page:pickUpLocation")})}),o("div",{className:[I.Text,I.Gray].join(" "),children:s.isDigitalOnly?s.checkout.billingAddress?.addressText:s.checkout.shippingAddress?.addressText})]})})),K=i((({vm:t})=>{const{t:i}=m();return o("div",{className:I.Address,children:t.checkout.shippingLines&&t.checkout.shippingLines.length?e(s.Fragment,{children:[o("span",{children:t.checkout.shippingLines[0].title}),o("span",{className:I.LightText,children:" / "+(0===t.checkout.shippingLines[0].price?i("checkout-page:free"):c(t.checkout.shippingLines[0].price,t.checkout.currencyCode,t.checkout.currencySymbol))})]}):i("checkout-page:standartShipping")})})),G=i((({vm:t})=>{const{t:i}=m();return e("div",{className:I.Footer,children:[o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy},children:i("checkout-page:returnPolicy")}),o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy},children:i("checkout-page:privacyPolicy")}),o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService},children:i("checkout-page:termsOfService")}),t.imprint&&e(s.Fragment,{children:[o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint},children:i("checkout-page:imprint")})]}),t.shippingPolicy&&e(s.Fragment,{children:[o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy},children:i("checkout-page:shippingPolicy")})]})]})})),H=i((({vm:t,setVisible:i})=>{const{t:r}=m(),[d,n]=s.useState(!1),[l,c]=s.useState(!1),[a]=s.useState(new b({message:{requiredRule:"",emailRule:"",minRule:""}}));a.email=t.checkout.customer?.email||"",a.firstName=t.checkout.customer?.firstName||"",a.lastName=t.checkout.customer?.lastName||"";const p=s.useCallback((async()=>{if(l)return i(!1);n(!0);await a.saveContactForm()&&c(!0),n(!1)}),[d]);return o(j,{title:r("checkout-page:contactForm"),modalContent:e("div",{children:[l&&o("div",{style:{marginBottom:"12px",maxWidth:"352px"},children:o(T,{type:"success",title:r("checkout-page:contactFormSent"),content:r("checkout-page:contactFormDescription")})}),o(F,{type:M.TEXT_AREA,label:"",value:a.message||"",onChange:a.onMessageChange,textAreaPlaceholder:r("checkout-page:contactFormCta")}),o(w,{style:{width:"100%",marginTop:"24px"},text:r(l?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:d,isDisabled:!a.message,onClick:p})]}),onClose:()=>i(!1)})}));export{L as default};
1
+ import{jsxs as e,jsx as o,Fragment as t}from"react/jsx-runtime";import*as s from"react";import{observer as i}from"mobx-react-lite";import r from"../../node_modules/react-tooltip/dist/index.es.js";import d,{CheckoutStep as n}from"./model.js";import{IkasStorefrontConfig as l}from"../../node_modules/@ikas/storefront-config/build/index.js";import{formatCurrency as m}from"../../utils/currency.js";import{useTranslation as c}from"../../utils/i18n.js";import a from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as h,Coupon as g,CartSummary as k}from"./components/cart-summary/index.js";import"../../models/data/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/index.js";import"../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../node_modules/lodash/sortBy.js";import"../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import{IkasThemeJsonPageType as y}from"../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import"../../node_modules/lodash/_baseClone.js";import"mobx";import"../../models/data/brand/index.js";import"../../node_modules/@ikas/storefront-api/build/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/category/conditions/index.js";import"../../node_modules/@ikas/localized-address/build/models/address/index.js";import"../../node_modules/@ikas/localized-address/build/models/address/model.js";import"../../node_modules/lodash/_defineProperty.js";import"../../node_modules/lodash/isArguments.js";import"../../node_modules/lodash/isBuffer.js";import"../../node_modules/lodash/isTypedArray.js";import"../../node_modules/lodash/_baseGetTag.js";import"../../node_modules/lodash/_Stack.js";import"../../node_modules/lodash/_SetCache.js";import"../../node_modules/lodash/_equalByTag.js";import"../../node_modules/lodash/_getTag.js";import"../../node_modules/lodash/_stringToPath.js";import"../../node_modules/lodash/_baseToString.js";import"../../store/base.js";import"../../node_modules/lodash/xorBy.js";import{Analytics as f}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../../store/cart/index.js";import"../../node_modules/lodash/_isFlattenable.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/validator/rules/index.js";import{ContactForm as b}from"../../models/ui/validator/form/contact-form.js";import{StepSuccess as x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import v from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import _ from"./components/master-pass/modal-success/index.js";import N,{Step as E}from"./components/step-container/index.js";import{StockError as S}from"./components/error/stock-error/index.js";import{FullscreenLoading as P}from"./components/fullscreen-loading/index.js";import T from"./components/notification-box/index.js";import{FormItem as F}from"./components/form-item/index.js";import{FormItemType as M}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import A from"./components/offer-product/index.js";import O from"./components/svg/ikas.js";import I from"./style.module.scss.js";import B from"./components/epaykolay-button/index.js";var L=i((({checkout:t,checkoutSettings:i,customizationProps:m,returnPolicy:a,privacyPolicy:p,termsOfService:u,imprint:h,shippingPolicy:g})=>{const{t:b}=c(),[N]=s.useState((()=>new d(t,i,a,p,u,h,g,b,m||{}))),E=s.useMemo((()=>Date.now()),[]);N.step===n.PAYMENT&&f.disableHTML();const T=async(e,o,t,s,i)=>{const r=`${process.env.PUBLIC_ENV__BASE_URL}/os/e-pay-kolay/get-basket`;return(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()},body:JSON.stringify({cartId:N.checkout.id,customerNumber:e,sessionsState:E,addressDto:t,paymentType:s,totalPrice:i})})).json()};s.useEffect((()=>{N.checkoutSettings.isAccountRequired&&!N.checkout.hasCustomer&&(window.location.href="/account/login?redirect="+encodeURIComponent(N.checkoutUrl)),f.beginCheckout(N.checkout),f.pageView(y.CHECKOUT)}),[]),s.useEffect((()=>{N.customizationProps=m,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",e?.buttonBgColor||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",e?.buttonTextColor||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",e?.buttonDisabledBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",e?.buttonDisabledTextColor||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",e?.primaryTextColor||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",e?.secondaryTextColor||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",e?.primaryBgColor||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",e?.secondaryBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",e?.borderColor||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",e?.cardBgColor||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",e?.errorColor||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",e?.errorLightColor||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",e?.warningColor||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",e?.warningLightColor||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",e?.successColor||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",e?.successLightColor||"#F6FFED")}(m)}),[m]),s.useEffect((()=>{if(N.isEPayKolayEnabled){const e=setInterval((()=>{window.setContainerService&&N.isCheckoutLoaded&&(window.setContainerService(l.getMerchantSettings()?.merchantId,T,(async e=>await F(e)),(()=>{console.log("Switching to epaykolay"),N.isEPayKolayPayment=!0}),`https://cdn-epeykolay.mncdn.com/${l.getApiUrl()?.includes("myikas.com")?"epay":"epay-uat"}/`),clearInterval(e))}),100)}}),[]);const F=s.useCallback((async e=>{const o=await fetch(`${process.env.PUBLIC_ENV__BASE_URL}/os/e-pay-kolay/complete-payment`,{method:"POST",body:JSON.stringify({data:e,cartId:N.checkout.id}),headers:{"Content-Type":"application/json","x-api-key":l.getApiKey()}}),t=await o.json();return{redirectUrl:`${window.location.pathname}?id=${N.checkout.id}&step=${t.success?"success":"info"}`,orderId:t.orderNumber||null}}),[]);if(!N.isCheckoutLoaded||!N.store.customerStore.initialized)return o(P,{});if(N.checkout.hasCustomer&&N.store.customerStore.customer?.id!==N.checkout.customer?.id)return window.location.href="/account/login?redirect="+encodeURIComponent(N.checkoutUrl),null;return o(s.Fragment,{children:e("div",{id:"Checkout",className:I.CheckoutPage,children:[o(r,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:I.ReactTooltipWrap,globalEventOff:"touchstart"}),e("div",{className:[I.Left,N.isEPayKolayPayment?I.epaykolay:""].join(" "),children:[N.isEPayKolayEnabled&&o("div",{id:"plateau_ui_placeholder",style:{width:"100%"}}),!N.isEPayKolayPayment&&e("div",{className:I.LeftContent,children:[e("div",{children:[o(V,{vm:N}),N.hasStockError&&o("div",{className:I.ErrorContainer,children:o(S,{vm:N,error:N.error})}),!N.hasStockError&&e(s.Fragment,{children:[o(k,{vm:N,allowExpand:!0}),o("div",{children:N.step!==n.SUCCESS&&N.isEPayKolayEnabled&&o(B,{onClick:()=>{window.frictionless()}})}),N.step===n.SUCCESS?o(x,{vm:N}):e(s.Fragment,{children:[N.campaignOffer&&N.isCampaignOfferLoaded&&o(A,{vm:N,campaignOffer:N.campaignOffer}),N.isCouponCodeRequirementOpen&&o(U,{vm:N}),o(R,{vm:N})]})]}),o("div",{className:I.Space})]}),o(G,{vm:N})]})]}),o("div",{className:I.Right,children:e("div",{className:I.RightContent,children:[o(k,{vm:N}),!N.isPoweredByHidden&&e("div",{className:I.PoweredBy,children:[o("span",{children:"powered by"}),o("a",{href:"https://ikas.com"+("tr"===l.getCurrentLocale()?"/tr":""),target:"_blank",children:o(O,{})})]})]})}),!!N.policyModalText&&o(j,{title:N.policyModalTitle,modalContent:N.policyModalText,onClose:()=>{N.policyModalText=""}}),N.isContactModalVisible&&o(z,{vm:N,setVisible:N.setContactModalVisible}),N.mpVM.isOtpModalVisible&&o(v,{vm:N,visible:N.mpVM.isOtpModalVisible,type:N.mpVM.otpModalType,onClose:N.mpVM.hideOtpModal}),N.mpVM.isResponseModalVisible&&o(C,{visible:N.mpVM.isResponseModalVisible,text:N.mpVM.mfsResponseModalText,onClose:N.mpVM.onResponseModalClose}),N.mpVM.isSuccessModalVisible&&o(_,{visible:N.mpVM.isSuccessModalVisible,type:N.mpVM.successModalType,onClose:N.mpVM.onSuccessModalClose})]})})}));const V=i((({vm:t})=>{const{t:s}=c();return e("div",{className:I.Header,children:[o("a",{href:"/",children:t.customizationProps?.logo?o("div",{className:I.Logo,children:o("img",{src:t.customizationProps.logo.getSrc(360)})}):t.merchantSettings?.logo?o("div",{className:I.Logo,children:o("img",{src:t.merchantSettings.logo.getSrc(360)})}):t.merchantSettings?.merchantName||""}),!t.checkout.hasCustomer&&e("div",{className:I.LoginText,children:[o("span",{className:I.LoginCta,children:s("checkout-page:alreadyHaveAnAccount")}),o("a",{href:"/account/login?redirect="+encodeURIComponent(t.checkoutUrl),className:I.LoginBtn,children:s("checkout-page:actions.login")})]}),t.checkout.hasCustomer&&e("div",{className:I.CustomerInfo,children:[o("div",{className:I.Name,children:t.checkout.customerFullName}),o("div",{className:I.Email,children:t.checkout.customer?.email})]})]})})),U=i((({vm:t})=>{const{t:i}=c(),[r,d]=s.useState(!1),[n,l]=s.useState(null),m=s.useMemo((()=>{switch(n){case h.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case h.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[n]);return e("div",{className:I.CouponContainer,children:[r&&o("div",{className:I.NotificationContainer,children:o(T,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:m,onClose:()=>{d(!1),l(null)},ignoreScroll:!0})}),o("div",{style:{marginTop:r?12:0},children:o(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:()=>{},setCouponError:d,setCouponErrorCode:l})})]})})),R=i((({vm:t})=>{const{t:i}=c(),r=s.useMemo((()=>{switch(t.step){case n.INFO:return o(a,{vm:t});case n.SHIPPING:return o(p,{vm:t});case n.PAYMENT:return o(u,{vm:t});case n.SUCCESS:return o(x,{vm:t})}}),[t,t.step]),d=[new E(i("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?e("div",{className:I.AdressStepInfo,children:[o(D,{vm:t}),!t.isUpsellOrder&&o("div",{className:I.EditBtn,onClick:t.onBackToInfoClick,children:i("checkout-page:actions.edit")})]}):void 0,t.step!==n.INFO?o("div",{className:I.AddressStepInfoMobile,children:o(D,{vm:t})}):void 0),new E(i("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||d.splice(1,0,new E(i("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?e("div",{className:I.AdressStepInfo,children:[o(K,{vm:t}),!t.isUpsellOrder&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o("div",{className:I.EditBtn,onClick:t.onBackToShippingClick,children:i("checkout-page:actions.edit")})]}):void 0,t.step===n.PAYMENT?o("div",{className:I.AddressStepInfoMobile,children:o(K,{vm:t})}):void 0)),o(N,{steps:d,stepContent:r})})),D=i((({vm:s})=>{const{t:i}=c(),r=s.isDigitalOnly?(s.checkout.billingAddress?.firstName||"")+" "+(s.checkout.billingAddress?.lastName||""):(s.checkout.shippingAddress?.firstName||"")+" "+(s.checkout.shippingAddress?.lastName||"");return e("div",{className:I.Address,children:[o("div",{className:[I.Text,I.WithMBottom].join(" "),children:s.checkout.customer?.email||""}),"address"===s.deliveryMethod?o("div",{className:I.Text,children:r}):e(t,{children:[o("div",{className:I.Text,children:i("checkout-page:receiver")}),o("div",{className:[I.Text,I.Gray].join(" "),children:r})]}),o("div",{className:[I.Text,I.Gray].join(" "),children:s.isDigitalOnly?s.checkout.billingAddress?.phone:s.checkout.shippingAddress?.phone}),"in-store"===s.deliveryMethod&&o(t,{children:o("div",{className:[I.Text,I.WithMTop].join(" "),children:i("checkout-page:pickUpLocation")})}),o("div",{className:[I.Text,I.Gray].join(" "),children:s.isDigitalOnly?s.checkout.billingAddress?.addressText:s.checkout.shippingAddress?.addressText})]})})),K=i((({vm:t})=>{const{t:i}=c();return o("div",{className:I.Address,children:t.checkout.shippingLines&&t.checkout.shippingLines.length?e(s.Fragment,{children:[o("span",{children:t.checkout.shippingLines[0].title}),o("span",{className:I.LightText,children:" / "+(0===t.checkout.shippingLines[0].price?i("checkout-page:free"):m(t.checkout.shippingLines[0].price,t.checkout.currencyCode,t.checkout.currencySymbol))})]}):i("checkout-page:standartShipping")})})),G=i((({vm:t})=>{const{t:i}=c();return e("div",{className:I.Footer,children:[o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy},children:i("checkout-page:returnPolicy")}),o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy},children:i("checkout-page:privacyPolicy")}),o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService},children:i("checkout-page:termsOfService")}),t.imprint&&e(s.Fragment,{children:[o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint},children:i("checkout-page:imprint")})]}),t.shippingPolicy&&e(s.Fragment,{children:[o("div",{className:I.FooterBullet,children:"•"}),o("div",{className:I.FooterItem,onClick:()=>{t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy},children:i("checkout-page:shippingPolicy")})]})]})})),z=i((({vm:t,setVisible:i})=>{const{t:r}=c(),[d,n]=s.useState(!1),[l,m]=s.useState(!1),[a]=s.useState(new b({message:{requiredRule:"",emailRule:"",minRule:""}}));a.email=t.checkout.customer?.email||"",a.firstName=t.checkout.customer?.firstName||"",a.lastName=t.checkout.customer?.lastName||"";const p=s.useCallback((async()=>{if(l)return i(!1);n(!0);await a.saveContactForm()&&m(!0),n(!1)}),[d]);return o(j,{title:r("checkout-page:contactForm"),modalContent:e("div",{children:[l&&o("div",{style:{marginBottom:"12px",maxWidth:"352px"},children:o(T,{type:"success",title:r("checkout-page:contactFormSent"),content:r("checkout-page:contactFormDescription")})}),o(F,{type:M.TEXT_AREA,label:"",value:a.message||"",onChange:a.onMessageChange,textAreaPlaceholder:r("checkout-page:contactFormCta")}),o(w,{style:{width:"100%",marginTop:"24px"},text:r(l?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:d,isDisabled:!a.message,onClick:p})]}),onClose:()=>i(!1)})}));export{L as default};
@@ -1 +1 @@
1
- import{makeAutoObservable as t}from"mobx";import e from"../../node_modules/lodash/cloneDeep.js";import s from"../../node_modules/lodash/sortBy.js";import"../../models/data/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import{IkasCampaignOfferProductApplicablePriceEnum as i}from"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import{IkasCampaignOfferTargetPageType as o}from"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import{IkasCartCampaignOfferStatus as n}from"../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import{IkasCartCreatedBy as a}from"../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/index.js";import{IkasCouponCodeRequirement as r}from"../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import{IkasCustomerEmailSubscriptionStatus as d}from"../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import{IkasOrderLineItemStatus as c}from"../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import{IkasTransactionStatus as h}from"../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import{IkasOrderPaymentStatus as l,IkasOrderShippingMethod as u}from"../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import{IkasPaymentMethodType as p,IkasPaymentGatewayType as m}from"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import{IkasStorefrontConfig as g}from"../../node_modules/@ikas/storefront-config/build/index.js";import"../../models/data/brand/index.js";import{IkasCheckoutSettings as y}from"../../models/data/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-api/build/index.js";import{IkasOrderCustomer as k}from"../../models/data/order/customer/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/category/conditions/index.js";import{IkasCheckout as f}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as S}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as C}from"../../models/data/customer/address/ikas-localized-customer-address.js";import{IkasProduct as I}from"../../models/data/product/index.js";import{IkasMerchantSettings as A}from"../../models/data/merchant-settings/index.js";import P from"../../store/product/index.js";import{IkasBaseStore as w}from"../../store/base.js";import"../../node_modules/lodash/xorBy.js";import b from"../../store/customer/api.js";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import R from"../../store/checkout/index.js";import"../../store/cart/index.js";import{IkasProductPrice as _}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as N}from"../../models/data/product/variant/index.js";import"../../node_modules/lodash/_isFlattenable.js";import{LocalizedAddressModel as v}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../node_modules/lodash/_defineProperty.js";import"../../node_modules/lodash/isArguments.js";import"../../node_modules/lodash/isBuffer.js";import"../../node_modules/lodash/isTypedArray.js";import"../../node_modules/lodash/_baseGetTag.js";import"../../node_modules/lodash/_Stack.js";import"../../node_modules/lodash/_SetCache.js";import"../../node_modules/lodash/_equalByTag.js";import"../../node_modules/lodash/_getTag.js";import"../../node_modules/lodash/_stringToPath.js";import"../../node_modules/lodash/_baseToString.js";import"../../models/ui/validator/rules/index.js";import D from"../../store/location/index.js";import{getCookieValue as T}from"../../utils/helper.js";import O from"./components/credit-card-form/model.js";import j from"../../store/cart/api.js";import x,{MFS_ELEMENT_ID as L,MFS_SCRIPT_URL as G}from"./modelMasterPass.js";import M from"../../models/data/order/address/ikas-localized-order-address.js";import{SaveCartInput as V}from"../../node_modules/@ikas/storefront-api/build/__api/models/SaveCartInput.js";import{CheckStocksLineInput as U}from"../../node_modules/@ikas/storefront-api/build/__api/models/CheckStocksLineInput.js";import{TransactionCardAssociationEnum as F}from"../../node_modules/@ikas/storefront-api/build/__api/types/index.js";const B=/^\d+$/,K="sAddr",Z="undefined"==typeof localStorage;class Y{constructor(a,C,A,B,Y,Q,z,X,J){this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=$.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=async()=>{await this.countrySettings.waitUntilInitialized(),await w.getInstance().customerStore.waitUntilInitialized(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),await this.initStep()},this.initStep=async()=>{if(g.getIsEditor())return this.step=$.INFO,void(this.isCheckoutLoaded=!0);const t=new URLSearchParams(window.location.search),e=t.get("step"),s=t.get("failed"),i=t.get("error");if(e){if(this.step=e,this.step===$.SHIPPING&&!this.canProceedToShipping)return this.changeStep($.INFO);if(this.step!==$.PAYMENT||this.canProceedToPayment){if(this.step===$.SUCCESS&&!this.canProceedToPayment)return this.changeStep($.INFO);if(![$.INFO,$.SUCCESS,$.SHIPPING,$.PAYMENT].includes(this.step))return this.changeStep($.INFO)}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?this.changeStep($.INFO):this.changeStep($.SHIPPING);this.deliveryMethod="in-store"}}if(await this.createCampaignOffer(),s&&(this.error={type:W.PAYMENT_ERROR,data:i||null}),this.step!==$.SHIPPING&&this.step!==$.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new y({...this.checkoutSettings,couponCodeRequirement:r.DEFAULT})),this.step===$.INFO&&(this.isDigitalOnly||(await this.getAvailableShippingZones(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),await this.getShippingCountries(),this.checkShippingCountries()),await this.getStockLocations(),await this.getAvailableStockLocations(),this.isInStoreDelivery&&(this.deliveryMethod="in-store")),this.step!==$.SHIPPING||1!==this.checkout.availableShippingMethods?.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=$.PAYMENT,window.location.href=`/checkout?id=${this.checkout.id}&step=${this.step}`),this.step===$.SHIPPING&&!this.checkout.availableShippingMethods?.length)return this.error={type:W.NO_SHIPPING_ERROR},void(this.isCheckoutLoaded=!0);if(this.step===$.SUCCESS&&this.checkout.orderPaymentStatus===l.PAID&&await this.listProductFile(),(this.step===$.PAYMENT||this.step===$.SUCCESS)&&(await this.listPaymentGateways(),this.isInStoreDelivery&&(this.deliveryMethod="in-store",await this.getStockLocations()),!this.paymentGateways.length))return this.error={type:W.NO_SHIPPING_ERROR},void(this.isCheckoutLoaded=!0);if(this.step!==$.SUCCESS){if(this.checkout.isComplete)return this.changeStep($.SUCCESS);await this.initialStockCheck()}else if(await this.getSuccessTransaction(),this.successTransaction){const t=this.successTransaction.paymentGatewayId;this.checkout.selectedPaymentGateway=this.paymentGateways.find((e=>e.id===t))}this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step)},this.getSuccessTransaction=async()=>{const t=await b.listOrderTransactions({orderId:{eq:this.checkout.id}});this.successTransaction=t.isSuccess&&t.data?.length?t.data[t.data.length-1]:void 0},this.saveCart=async()=>{let t=new V(this.checkout);"in-store"===this.deliveryMethod&&(t=await this.inStockDeliveryInputData(t)),this.step!==$.INFO&&this.step!==$.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),t.customer&&(this.store.customerStore.customer?t.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===d.SUBSCRIBED:this.checkout.customer&&(t.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1));const e=await j.saveCart({input:t});if(e?.graphQLErrors&&e.graphQLErrors.length){const t=e.graphQLErrors[0];throw"CUSTOMER_LOGIN_REQUIRED"===t.extensions?.code?{type:W.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===t.extensions?.code?{type:W.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:W.API_ERROR,data:e.firstErrorMessage}}return e.data},this.inStockDeliveryInputData=async t=>{const e=t,s=this.stockLocations.find((t=>t.id===this.checkout.stockLocationId));return s&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),e},this.checkStocks=async()=>{if(this.isManualOrder)return;const t=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:g.getStockLocationIds()?.length?g.getStockLocationIds():null,e=await R.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:t});if(!e.isSuccess)throw{type:W.API_ERROR,data:e.firstErrorMessage};const s=e.data?.lines?.filter((t=>!t.isAvailable));if(s?.length){const t=[];for(const e of s){const s=this.checkout.items.find((t=>t.variant.id===e.variantId));s&&t.push({item:s,stockCount:e.stockCount})}throw{type:W.STOCK_ERROR,data:t}}},this.setIsKlarnaPaymentCompleted=async t=>{this.isKlarnaPaymentCompleted=t},this.removeUnavailableItems=async t=>{for(const e of t)await w.getInstance().cartStore.changeItemQuantity(e.item,e.stockCount<0?0:e.stockCount)},this.getShippingCountries=async()=>{const t=await R.getAvailableShippingCountries({salesChannelId:g.getSalesChannelId()});this.shippingCountryIds=t.data},this.getStockLocations=async()=>{if(g.getPickupStockLocationIds()){const t=await R.listStockLocation({id:{in:g.getPickupStockLocationIds()}});if(!t.isSuccess||!t.data?.length)return void(this.error={type:W.API_ERROR,data:t.firstErrorMessage});this.stockLocations=t.data}},this.getAvailableStockLocations=async()=>{if(g.getPickupStockLocationIds()){const t=this.checkout.items.map((t=>({quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}))),e=await R.getAvailableStockLocations({lines:t.map((t=>new U(t))),stockLocationIdList:g.getPickupStockLocationIds()});if(!e.isSuccess)return void(this.error={type:W.API_ERROR});this.availableStockLocations=e.data||[]}},this.checkShippingCountries=()=>{this.shippingCountryIds?.length||(this.error={type:W.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=t=>{this.deliveryMethod!==t&&("address"===t&&(this.checkout.stockLocationId=null,this.customerAddresses?.length?this.onSelectedShippingAddressIdChange(this.customerAddresses[0].id||"-1"):(this.checkout.shippingAddress=new M,this.checkout.shippingAddress.countrySettings=this.countrySettings,this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones)),this.deliveryMethod=t,this.isErrorsVisible=!1)},this.initialStockCheck=async()=>{try{await this.checkStocks()}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN})}},this.listPaymentGateways=async()=>{const t="local"===process.env.PUBLIC_ENV__ENV,e=g.getPaymentGateways().map((t=>t.id)),i=await R.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:t?void 0:{in:e},locale:g.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice});if(!i.isSuccess||!i.data?.length)return void(this.error={type:W.API_ERROR,data:i.firstErrorMessage});let o=i.data;if(this.step===$.PAYMENT){o=o.filter((t=>!t.supportedCurrencies?.length||t.supportedCurrencies.includes(this.checkout.currencyCode)));const t=this.checkout.shippingAddress?.country;t&&t.iso2&&(o=o.filter((e=>!e.availableCountries?.length||e.availableCountries.includes(t.iso2||""))))}const n=[];if(s(g.getPaymentGateways(),"order").forEach((t=>{const e=o?.find((e=>e.id===t.id));e&&n.push(e)})),this.paymentGateways=t?o:n,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===$.PAYMENT){const t=o.find((t=>!!t.masterPassClientId));if(t){this.checkout.masterPassPaymentGateway=t;const e=document.createElement("script");e.id=L,e.src=G,e.onload=()=>{this.mpVM.checkMasterPass({checkout:this.checkout,store:w.getInstance()})},document.head.appendChild(e)}}},this.retrieveInstallmentInfo=async t=>{const e=(await R.retrieveInstallmentInfo(t)).data;e?.installmentPrices?.sort(((t,e)=>(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1)),this.installmentInfo=e},this.createCustomer=()=>{this.store.customerStore.customer?(this.customerAddresses?.forEach((t=>{t.checkoutSettings=this.checkoutSettings,t.shippingZones=this.shippingZones})),this.checkout.customer=new k(this.store.customerStore.customer)):this.checkout.customer=new k(this.checkout.customer||{})},this.setCheckoutShippingAddressSettings=()=>{this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones,this.checkout.shippingAddress.countrySettings=this.countrySettings,this.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=()=>{this.checkout.billingAddress&&(this.checkout.billingAddress.checkoutSettings=this.checkoutSettings,this.checkout.billingAddress.shippingZones=this.shippingZones,this.checkout.billingAddress.countrySettings=this.countrySettings,this.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=()=>{if(!this.isDigitalOnly)if(this.isInStoreDelivery)this.setCheckoutShippingAddressSettings();else if(this.checkout.shippingAddress){if(this.store.customerStore.customer){const t=this.customerAddresses,e=t?.find((t=>t.id===this.checkout.shippingAddress?.id));if(e)return this.onSelectedShippingAddressIdChange(e.id||"-1"),void this.setCheckoutShippingAddressSettings()}this.checkout.shippingAddress=new M(e(this.checkout.shippingAddress)||{}),this.setCheckoutShippingAddressSettings()}else if(this.store.customerStore.customer){const t=this.customerAddresses;this.onSelectedShippingAddressIdChange(t?.length?t[0].id:"-1")}else this.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=()=>{if("undefined"!=typeof localStorage)if(this.useDifferentAddress=!!localStorage.getItem(K),this.checkout.billingAddress){if(this.store.customerStore.customer){const t=this.customerAddresses,e=t?.find((t=>t.id===this.checkout.billingAddress?.id));if(e)return this.onSelectedBillingAddressIdChange(e.id||"-1"),void this.setCheckoutBillingAddressSettings()}this.checkout.billingAddress=new M(e(this.checkout.billingAddress)||{}),this.setCheckoutBillingAddressSettings()}else if(this.store.customerStore.customer){const t=this.customerAddresses;this.onSelectedBillingAddressIdChange(t?.length?t[0].id:"-1"),t?.length||this.useDifferentAddress||!this.checkout.shippingAddress||this.isInStoreDelivery||(this.checkout.billingAddress=new M(e(this.checkout.shippingAddress)),this.setCheckoutBillingAddressSettings())}else this.onSelectedBillingAddressIdChange("-1"),this.useDifferentAddress||!this.checkout.shippingAddress||this.isInStoreDelivery||(this.checkout.billingAddress=new M(e(this.checkout.shippingAddress)),this.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=async t=>{if(this.isChangingShippingMethod)return;this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=t.shippingSettingsId,this.checkout.shippingZoneRateId=t.shippingZoneRateId;const e=await this.saveCart();e&&(this.checkout=new f(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1},this.onStockLocationChange=async t=>{this.checkout.stockLocationId=t.id},this.onCouponCodeApply=async()=>{try{const t=await j.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null});if(t.isSuccess&&t.data){const e=t.data,s=this.cardData?.cardNumber?.split(" ").join("");if(this.couponError=null,this.step===$.PAYMENT&&s?.length&&s.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:e.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1&&await this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:e.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),e){const t=this.checkout;this.checkout=new f({...e,shippingAddress:t.shippingAddress,billingAddress:t.billingAddress,customer:t.customer,selectedPaymentGateway:t.selectedPaymentGateway},this.countrySettings)}}t.isSuccess||(this.couponError=t.errorCodes[0])}catch(t){}},this.getAvailableShippingZones=async()=>{try{const t=await D.getAvailableShippingZones({salesChannelId:g.getSalesChannelId()});this.shippingZones=t.data||null}catch(t){}},this.onSelectedShippingAddressIdChange=t=>{if(this.selectedShippingAddressId=t,"-1"===t)this.checkout.shippingAddress=new M,this.checkout.shippingAddress.countrySettings=this.countrySettings;else{const e=this.customerAddresses?.find((e=>e.id===t));e&&(this.checkout.shippingAddress=new M(e),this.checkout.shippingAddress.countrySettings=this.countrySettings)}this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones)},this.onSelectedBillingAddressIdChange=t=>{if(this.selectedBillingAddressId=t,"-1"===t)this.checkout.billingAddress=new M,this.checkout.billingAddress.countrySettings=this.countrySettings;else{const e=this.customerAddresses?.find((e=>e.id===t));e&&(this.checkout.billingAddress=new M(e),this.checkout.billingAddress.countrySettings=this.countrySettings)}this.checkout.billingAddress&&(this.checkout.billingAddress.checkoutSettings=this.checkoutSettings,this.checkout.billingAddress.shippingZones=this.shippingZones)},this.onTermsAndConditionsCheckedChange=t=>{this.isTermsAndConditionsChecked=t},this.onCardNumberChange=t=>{if(!this.cardData)return;if(t.length>this.cardData.cardNumber.length&&!q(t))return;const e=(this.cardData.cardNumber||"").split(" ").join(""),s=t.split(" ").join("");s.length>16||(e.length<6&&s.length>=6&&!this.installmentInfo?this.getRetrieveInstallmentInfo(s):s.length<6&&e.length>s.length&&(this.cardData.installmentCount=1,this.installmentInfo=void 0),this.installmentInfo?.cardAssociation===F.AMERICAN_EXPRESS?this.cardData.cardNumber=function(t){let e=[];const s=t.slice(0,4),i=t.slice(4,10),o=t.slice(10,15);s&&e.push(s);i&&e.push(i);o&&e.push(o);return e}(s).join(" "):this.cardData.cardNumber=H(s,4).join(" "))},this.getRetrieveInstallmentInfo=async t=>{await this.retrieveInstallmentInfo({input:{binNumber:t.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.cardData?.cardNumber&&this.onCardNumberChange(this.cardData.cardNumber)},this.onCardHolderNameChange=t=>{this.cardData&&(this.cardData.cardHolderName=t)},this.onExpirationDateChange=t=>{if(!this.cardData)return;if(t.length>this.cardData.expirationDate.length&&!q(t))return;if(0===this.cardData.expirationDate?.length){const e=t.replace(".","/").split("/");if(2===e.length){const t=e[0].trim(),s=e[1].trim();if(4===t.length&&2===s.length){const e=parseInt(t.slice(2)),i=parseInt(s);if(!isNaN(e)&&!isNaN(i))return void(this.cardData.expirationDate=`${i<10?"0"+i:i} / ${e<10?"0"+e:e}`)}if(2===t.length&&4===s.length){const e=parseInt(t),i=parseInt(s.slice(2));if(!isNaN(i)&&!isNaN(e))return void(this.cardData.expirationDate=`${e<10?"0"+e:e} / ${i<10?"0"+i:i}`)}if(2===t.length&&2===s.length){const e=parseInt(t),i=parseInt(s),o=e<=12?e:i,n=i>12?i:e;if(!isNaN(n)&&!isNaN(o))return void(this.cardData.expirationDate=`${o<10?"0"+o:o} / ${n<10?"0"+n:n}`)}}}const e=t.split(" / ").join("");e.length>4||(this.cardData.expirationDate=H(e,2).join(" / "))},this.onCvcChange=t=>{if(this.cardData&&(!(t.length>this.cardData.cvv.length)||q(t))){if(this.installmentInfo){if(this.installmentInfo.cardAssociation===F.AMERICAN_EXPRESS&&t.length>4)return;if(this.installmentInfo.cardAssociation!==F.AMERICAN_EXPRESS&&t.length>3)return}else if(t.length>3)return;this.cardData.cvv=t}},this.saveAddress=async t=>{try{if(this.shouldSaveAddress&&this.store.customerStore.customer){const s="shipping"===t?this.checkout.shippingAddress:this.checkout.billingAddress,i=this.customerAddresses?.find((t=>t.id===s?.id));if(i)return;const o=this.customerAddresses?.map((t=>t.id)),n=new S({...s,title:this.addressTitle||this.t("checkout-page:newAddress")}),a=e(this.store.customerStore.customer);a.addresses||(a.addresses=[]),a.addresses.push(n),await this.store.customerStore.saveCustomer(a),this.customerAddresses?.forEach((t=>{t.checkoutSettings=this.checkoutSettings,t.shippingZones=this.shippingZones}));const r=this.customerAddresses?.map((t=>t.id)),d=r?.filter((t=>!o?.includes(t))),c=d?.length?d[0]:void 0;"shipping"===t?(this.checkout.shippingAddress.id=c||"",this.selectedShippingAddressId=c||"-1"):(this.checkout.billingAddress.id=c||"",this.selectedBillingAddressId=c||"-1")}}catch(t){console.error(t)}},this.onGoToCartClick=()=>{window.location.href="/cart"},this.onBackToShoppingClick=()=>{window.location.href="/"},this.onGoToLoginClick=()=>{window.location.href="/account/login"},this.onProceedToShippingClick=async()=>{if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return void(this.isErrorsVisible=!0)}else if(!this.canProceedToInStoreDelivery)return void(this.isErrorsVisible=!0);this.isErrorsVisible=!1;try{this.isStepLoading=!0,"address"===this.deliveryMethod&&await this.saveAddress("shipping"),await this.checkStocks(),await this.saveCart(),"address"===this.deliveryMethod?this.changeStep($.SHIPPING):this.changeStep($.PAYMENT)}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}},this.onProceedToDigitalOnlyPaymentClick=async()=>{if(this.canProceedToPayment){this.isErrorsVisible=!1;try{this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.changeStep($.PAYMENT)}catch(t){t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.onProceedToPaymentClick=async()=>{if(this.canProceedToPayment){this.isErrorsVisible=!1;try{this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.error=void 0,this.changeStep($.PAYMENT)}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.checkPaypalButtonAvailable=()=>!!this.canPerformPayment||(this.isErrorsVisible=!0,!1),this.onCompletePaymentClick=async()=>{if(this.canPerformPayment){if(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),!this.isFree&&this.isKlarna)return await this.saveCart(),void this.setIsKlarnaPaymentCompleted(!0);try{if(this.isErrorsVisible=!1,this.isStepLoading=!0,await this.checkStocks(),"address"===this.deliveryMethod&&this.useDifferentAddress&&await this.saveAddress("billing"),await this.saveCart(),!this.isFree&&this.isCustomFlowStripe){const t=document.querySelector("#stripe-form-btn");return void(t&&t.click())}if(!this.isFree&&this.isAdyen)return this.adyenDropinElement.submit(),void(this.adyenDropinElement.isValid||(this.isStepLoading=!1));if(!this.isFree&&this.isPayPal)return;await this.createSaleTransaction()}catch(t){void 0!==typeof t.type?this.error=t:this.error={type:W.UNKNOWN},this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.onCompleteDigitalOnlyPaymentClick=async()=>{if(!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)this.isErrorsVisible=!0;else{if(this.isKlarna)return await this.saveCart(),void this.setIsKlarnaPaymentCompleted(!0);try{if(this.isErrorsVisible=!1,this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.isCustomFlowStripe){const t=document.querySelector("#stripe-form-btn");return void(t&&t.click())}if(this.isAdyen)return this.adyenDropinElement.submit(),void(this.adyenDropinElement.isValid||(this.isStepLoading=!1));if(this.isPayPal)return;await this.createSaleTransaction()}catch(t){t.type?this.error=t:this.error={type:W.UNKNOWN},this.isStepLoading=!1}}},this.createSaleTransaction=async()=>{let t;const e=this.mpVM.selectedCard;let s;if(!this.isFree&&e&&this.mpVM.selectedCard?.Name){const e=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout});if(e&&(t=e),void 0===this.cardData?.installmentCount)return;s=await R.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:this.mpVM.selectedCard?.Name},paymentGatewayId:this.mpVM.selectedCard?.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!this.cardData?.threeDSecure},metadata:{_fbp:T("_fbp"),_fbc:T("_fbc")}}})}else{if(!this.checkout.selectedPaymentGateway)return;s=await R.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:e&&t?{phoneNumber:t,savedCardName:this.mpVM.selectedCard?.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||e?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===p.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===m.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})}const i=s?.data?.transactionStatus,o=i&&[h.SUCCESS,h.AUTHORIZED].includes(i),n=i===h.PENDING;if(o)await this.getSuccessTransaction(),await this.onCheckoutTransactionSuccess(s?.data?.orderId||void 0);else{if(!n||!s?.data?.returnSlug)throw{data:s.firstErrorMessage,type:W.UNKNOWN};window.location.href=process.env.PUBLIC_ENV__BASE_URL+s.data.returnSlug}},this.onCheckoutTransactionSuccess=async t=>{localStorage.removeItem(K),this.checkout.customer?.notificationsAccepted&&await this.store.customerStore.createEmailSubscription(this.checkout.customer?.email||""),this.changeStep($.SUCCESS,t)},this.onBackToInfoClick=()=>{this.changeStep($.INFO)},this.onBackToShippingClick=()=>{this.changeStep($.SHIPPING)},this.setCustomerConsentGranted=t=>{this.checkout.customer&&(this.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=t=>{this.useDifferentAddress=t,this.useDifferentAddress?(localStorage.setItem(K,"1"),this.checkout.billingAddress=this.checkout.billingAddress||new M,this.checkout.billingAddress.countrySettings=this.countrySettings):(localStorage.removeItem(K),this.checkout.billingAddress=this.checkout.shippingAddress)},this.setShouldSaveAddress=t=>{this.shouldSaveAddress=t},this.setAddressTitle=t=>{this.addressTitle=t},this.reInitPaymentMethod=async()=>{this.checkout.selectedPaymentGateway&&(this.isCustomFlowStripe&&await this.createStripePaymentIntent(this.checkout.selectedPaymentGateway),this.isKlarna&&window.location.reload(),this.isAdyen&&await this.createAdyenClientToken(this.checkout.selectedPaymentGateway),this.isPayPal&&await this.getPayPalClientId(this.checkout.selectedPaymentGateway))},this.createStripePaymentIntent=async t=>{const e=await R.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.stripeResponse=e.data)},this.createKlarnaClientToken=async t=>{const e=await R.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.klarnaResponse=e.data)},this.createAdyenClientToken=async t=>{const e=await R.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.adyenResponse=e.data)},this.getPayPalClientId=async t=>{const e=await R.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.payPalClientIdResponse=e.data)},this.setPaymentGateway=async t=>{if(!this.paymentGateways.length)return;const e=this.paymentGateways[t];if("STRIPE"===e.code&&e.settings?.find((t=>"allow_custom_flow"===t.label&&"1"===t.value))&&!this.stripeResponse&&await this.createStripePaymentIntent(e),"KLARNA"!==e.code||this.klarnaResponse||await this.createKlarnaClientToken(e),"ADYEN"!==e.code||this.adyenResponse||await this.createAdyenClientToken(e),"PAYPAL"!==e.code||this.payPalClientIdResponse||await this.getPayPalClientId(e),this.checkout.selectedPaymentGateway=e,this.step!==$.SUCCESS){if(e.paymentMethodType===p.CREDIT_CARD&&e.type===m.INTERNAL){this.cardData=new O;e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))}this.installmentInfo=void 0}},this.setInstallmentCount=t=>{this.cardData&&(this.cardData.installmentCount=t)},this.changeStep=async(t,e)=>{Z||window.location.replace(`${window.location.pathname}?id=${e||this.checkout.id}&step=${t}`)},this.logout=async()=>{this.checkout.customer=null,this.store.customerStore.logout();try{await this.saveCart()}catch(t){}this.createCustomer()},this.setContactModalVisible=t=>{this.isContactModalVisible=t},this.getCampaignOffer=async(t,e)=>{if(!e?.length)return;const s=e.filter((e=>e.status===n.WAITING_FOR_ACTION&&e.campaignOffer?.targetPageTypes.some((e=>e===t))));for(const t of s){if(!t?.campaignOffer)return;const e=t.campaignOffer.offers.find((e=>e.id===t.campaignOfferProductId));if(!e)return;const s=[e.productId],o=await P.searchProducts({input:{productIdList:s,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId()}});if(o.isSuccess&&o.data?.data?.length){const s=o.data.data[0];let n=s.variants.filter((t=>t.hasStock&&!(e.excludedVariantIdList||[]).some((e=>e===t.id)))).map((t=>e.discountAmount?new N({...t,prices:t.prices.map((t=>{let s=t.finalPrice,o=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===i.SELL_PRICE&&(s=t.sellPrice,o=t.sellPrice-t.sellPrice*e.discountAmount/100),new _({...t,sellPrice:s,discountPrice:o})}))}):t));if(n.length){const i=n.find((t=>t.isActive));return{product:new I({...s,selectedVariantValues:(i||n[0]).variantValues,variants:n}),offer:e,campaignOffer:t}}}}},this.createCampaignOffer=async()=>{this.campaignOffer=await this.getCampaignOffer(this.step===$.SUCCESS?o.POST_CHECKOUT:o.CHECKOUT,this.checkout.campaignOffers)},this.updateCartCampaignOffer=async t=>{t.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1;const e=await j.updateCartCampaignOffer({input:t});e.isSuccess&&(t.accepted?this.changeStep(this.step===$.SUCCESS?$.PAYMENT:this.step,e.data?.id):(this.checkout.campaignOffers=e.data?.campaignOffers||[],await this.createCampaignOffer(),this.isCampaignOfferLoaded=!0))},this.registerCustomer=async t=>{if(this.checkout.customer){const{firstName:e,lastName:s,email:i}=this.checkout.customer;if(e&&s&&i){return await b.register({orderId:this.checkout.id,firstName:e,lastName:s,email:i,password:t})}}},this.listProductFile=async()=>{let t=this.checkout.orderLineItems.filter((t=>!!t.variant.fileId&&t.status!==c.REFUNDED)).map((t=>t.variant.fileId));if(t.length){const e=await R.listProductFile({id:{in:t}});e.isSuccess&&(this.productFiles=e.data||[])}},this.getDigitalProductFileDownloadUrl=async t=>{try{const e=this.checkout.orderLineItems.find((e=>e.variant.id===t.variantId));if(e){const s=(await R.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})).data;if(s){const e=document.createElement("a");e.href=s,e.download=function(t){try{return decodeURIComponent(t.split("/")[t.split("/").length-1])}catch{return""}}(t.name),e.click(),e.remove()}}}catch(t){console.error(t)}},this.checkout=a,this.checkoutSettings=C,this.returnPolicy=A,this.privacyPolicy=B,this.termsOfService=Y,this.imprint=Q,this.shippingPolicy=z,this.t=X,this.customizationProps=J,this.mpVM=new x,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new v({currentLocale:g.getCurrentLocale()}),this.init(),t(this)}get merchantSettings(){return new A(g.getMerchantSettings())}get selectedPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>t.id===this.checkout.selectedPaymentGateway?.id))}get selectedInstallmentIndex(){return this.installmentInfo?.installmentPrices?.findIndex((t=>t.installmentCount===this.cardData?.installmentCount))||0}get checkoutUrl(){return`/checkout?id=${this.checkout.id}&step=info`}get customerAddressOptions(){const t={label:this.t("checkout-page:newAddress"),value:"-1"},e=w.getInstance().customerStore.customer?.addresses?.map((t=>({label:t.title+" - "+t.addressText,value:t.id})))||[];return[t].concat(e)}get installmentPrice(){if(this.installmentInfo&&this.cardData?.installmentCount)return this.installmentInfo.installmentPrices?.find((t=>t.installmentCount===this.cardData?.installmentCount))?.totalPrice}get installmentExtraPrice(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice}get finalPrice(){return this.step===$.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice}get hasStockError(){return this.error?.type===W.STOCK_ERROR}get isPaymentGatewayHasMasterPass(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)}get hasQuickRegistration(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout}get canProceedToShipping(){return(this.isDigitalOnly?this.checkout.billingAddress?.isValidAddress:this.checkout.shippingAddress?.isValidAddress)&&this.checkout.hasValidCustomerEmail&&this.error?.type!==W.NO_SHIPPING_ERROR}get canProceedToInStoreDelivery(){return!!(this.checkout.shippingAddress?.firstName&&this.checkout.shippingAddress?.lastName&&this.checkout.customer?.email&&this.checkout.stockLocationId)}get canProceedToPayment(){return this.canProceedToShipping&&this.isValidShippingSettings}get isValidShippingSettings(){return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&this.checkout.shippingLines?.some((t=>t.shippingSettingsId===this.checkout.shippingSettingsId&&t.shippingZoneRateId===this.checkout.shippingZoneRateId))}get isInStoreDelivery(){return!!this.checkout.stockLocationId}get klarnaPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"KLARNA"===t.code));if(-1!==t)return this.paymentGateways[t]}get klarnaPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"KLARNA"===t.code))}get adyenPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"ADYEN"===t.code));if(-1!==t)return this.paymentGateways[t]}get adyenPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"ADYEN"===t.code))}get payPalPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"PAYPAL"===t.code));if(-1!==t)return this.paymentGateways[t]}get payPalPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"PAYPAL"===t.code))}get isCustomFlowStripe(){const t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&t.settings?.find((t=>"allow_custom_flow"===t.label&&"1"===t.value))}get isKlarna(){const t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code}get isAdyen(){const t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code}get isPayPal(){const t=this.checkout.selectedPaymentGateway;return t&&"PAYPAL"===t.code}get isFree(){return 0===this.checkout.totalFinalPrice}get store(){return w.getInstance()}get isCouponCodeRequirementDefult(){return this.checkoutSettings.couponCodeRequirement===r.DEFAULT||null===this.checkoutSettings.couponCodeRequirement}get isCouponCodeRequirementOpen(){return this.checkoutSettings.couponCodeRequirement===r.OPEN}get isCouponCodeRequirementInvisible(){return this.checkoutSettings.couponCodeRequirement===r.INVISIBLE}get isCouponCodeVisible(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible}get canPerformPayment(){if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;const t=this.checkout.selectedPaymentGateway,e=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,s=!!this.checkout.billingAddress?.isValidAddress,i=!!this.isFree||(!!this.mpVM.selectedCard||(t?.paymentMethodType===p.CREDIT_CARD&&t.type===m.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||this.cardData?.isValid):!!t));return e&&s&&i}get isDigitalOnly(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY}get customerAddresses(){const t=g.getCurrentRouting()?.countryCodes;return this.store.customerStore.customer?.addresses?.filter((e=>!t?.length||e.country?.iso2&&t.includes(e.country.iso2))).map((t=>{const e=new C({countrySettings:this.countrySettings,...t});return e.checkoutSettings=this.checkoutSettings,e.shippingZones=this.shippingZones,e.getValidatedCustomerAddress(),e}))}get isManualOrder(){return this.checkout.createdBy===a.ADMIN}get isUpsellOrder(){return this.checkout.createdBy===a.UPSELL}get isEPayKolayEnabled(){const t=g.getCustom();return!!t&&!!t.isEPayKolayEnabled}get isPoweredByHidden(){const t=g.getCustom();return!!t&&!!t.hidePoweredBy}setAdyenDropinElement(t){this.adyenDropinElement=t}}function H(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function q(t){return t&&B.test(t.charAt(t.length-1))}var $,W;!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}($||($={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",t[t.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(W||(W={}));export{$ as CheckoutStep,W as ErrorType,Y as default};
1
+ import{makeAutoObservable as t}from"mobx";import e from"../../node_modules/lodash/cloneDeep.js";import s from"../../node_modules/lodash/sortBy.js";import"../../models/data/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/blog/meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/brand/index.js";import{IkasCampaignOfferProductApplicablePriceEnum as i}from"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/product/index.js";import{IkasCampaignOfferTargetPageType as o}from"../../node_modules/@ikas/storefront-models/build/models/campaign-offer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/estimated-delivery-time/index.js";import"../../node_modules/@ikas/storefront-models/build/models/cart/available-shipping-method/index.js";import{IkasCartCampaignOfferStatus as n}from"../../node_modules/@ikas/storefront-models/build/models/cart/campaign-offer/index.js";import{IkasCartCreatedBy as a}from"../../node_modules/@ikas/storefront-models/build/models/cart/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/conditions/index.js";import"../../node_modules/@ikas/storefront-models/build/models/category/index.js";import{IkasCouponCodeRequirement as r}from"../../node_modules/@ikas/storefront-models/build/models/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/sales-channel/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/price-list-rule/index.js";import"../../node_modules/@ikas/storefront-models/build/models/customer/review/index.js";import{IkasCustomerEmailSubscriptionStatus as d}from"../../node_modules/@ikas/storefront-models/build/models/customer/index.js";import"../../node_modules/@ikas/storefront-models/build/models/html-meta-data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/merchant-settings/address/type/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/adjustment/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/invoice/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/line-item/base-unit/index.js";import{IkasOrderLineItemStatus as c}from"../../node_modules/@ikas/storefront-models/build/models/order/line-item/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/package/index.js";import"../../node_modules/@ikas/storefront-models/build/models/order/transaction/payment-method-detail/index.js";import{IkasTransactionStatus as h}from"../../node_modules/@ikas/storefront-models/build/models/order/transaction/index.js";import{IkasOrderPaymentStatus as l,IkasOrderShippingMethod as u}from"../../node_modules/@ikas/storefront-models/build/models/order/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/additional-price/index.js";import"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/settings/index.js";import{IkasPaymentMethodType as p,IkasPaymentGatewayType as m}from"../../node_modules/@ikas/storefront-models/build/models/payment-gateway/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/attribute/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/data/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/campaign/filter/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/option-set/option/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/product/index.js";import"../../node_modules/@ikas/storefront-models/build/models/raffle/index.js";import"../../node_modules/@ikas/storefront-models/build/models/stock-location/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/b2b-settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/theme/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/meta-templates/index.js";import"../../node_modules/@ikas/storefront-models/build/models/storefront/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/component/prop/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/page/index.js";import"../../node_modules/@ikas/storefront-models/build/models/theme-json/settings/index.js";import"../../node_modules/@ikas/storefront-models/build/models/variant-type/index.js";import{IkasStorefrontConfig as g}from"../../node_modules/@ikas/storefront-config/build/index.js";import"../../models/data/brand/index.js";import{IkasCheckoutSettings as y}from"../../models/data/checkout-settings/index.js";import"../../node_modules/@ikas/storefront-api/build/index.js";import{IkasOrderCustomer as k}from"../../models/data/order/customer/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/category/conditions/index.js";import{IkasCheckout as f}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as S}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as C}from"../../models/data/customer/address/ikas-localized-customer-address.js";import{IkasProduct as I}from"../../models/data/product/index.js";import{IkasMerchantSettings as A}from"../../models/data/merchant-settings/index.js";import P from"../../store/product/index.js";import{IkasBaseStore as w}from"../../store/base.js";import"../../node_modules/lodash/xorBy.js";import b from"../../store/customer/api.js";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import _ from"../../store/checkout/index.js";import"../../store/cart/index.js";import{IkasProductPrice as R}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as N}from"../../models/data/product/variant/index.js";import"../../node_modules/lodash/_isFlattenable.js";import"../../node_modules/@ikas/localized-address/build/models/address/index.js";import{LocalizedAddressModel as v}from"../../node_modules/@ikas/localized-address/build/models/address/model.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../node_modules/lodash/_defineProperty.js";import"../../node_modules/lodash/isArguments.js";import"../../node_modules/lodash/isBuffer.js";import"../../node_modules/lodash/isTypedArray.js";import"../../node_modules/lodash/_baseGetTag.js";import"../../node_modules/lodash/_Stack.js";import"../../node_modules/lodash/_SetCache.js";import"../../node_modules/lodash/_equalByTag.js";import"../../node_modules/lodash/_getTag.js";import"../../node_modules/lodash/_stringToPath.js";import"../../node_modules/lodash/_baseToString.js";import"../../models/ui/validator/rules/index.js";import D from"../../store/location/index.js";import{getCookieValue as T}from"../../utils/helper.js";import O from"./components/credit-card-form/model.js";import j from"../../store/cart/api.js";import x,{MFS_ELEMENT_ID as L,MFS_SCRIPT_URL as G}from"./modelMasterPass.js";import M from"../../models/data/order/address/ikas-localized-order-address.js";import{SaveCartInput as V}from"../../node_modules/@ikas/storefront-api/build/__api/models/SaveCartInput.js";import{CheckStocksLineInput as U}from"../../node_modules/@ikas/storefront-api/build/__api/models/CheckStocksLineInput.js";import{TransactionCardAssociationEnum as F}from"../../node_modules/@ikas/storefront-api/build/__api/types/index.js";const B=/^\d+$/,K="sAddr",Z="undefined"==typeof localStorage;class Y{constructor(a,C,A,B,Y,Q,z,X,J){this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=$.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=async()=>{await this.countrySettings.waitUntilInitialized(),await w.getInstance().customerStore.waitUntilInitialized(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),await this.initStep()},this.initStep=async()=>{if(g.getIsEditor())return this.step=$.INFO,void(this.isCheckoutLoaded=!0);const t=new URLSearchParams(window.location.search),e=t.get("step"),s=t.get("failed"),i=t.get("error");if(e){if(this.step=e,this.step===$.SHIPPING&&!this.canProceedToShipping)return this.changeStep($.INFO);if(this.step!==$.PAYMENT||this.canProceedToPayment){if(this.step===$.SUCCESS&&!this.canProceedToPayment)return this.changeStep($.INFO);if(![$.INFO,$.SUCCESS,$.SHIPPING,$.PAYMENT].includes(this.step))return this.changeStep($.INFO)}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?this.changeStep($.INFO):this.changeStep($.SHIPPING);this.deliveryMethod="in-store"}}if(await this.createCampaignOffer(),s&&(this.error={type:W.PAYMENT_ERROR,data:i||null}),this.step!==$.SHIPPING&&this.step!==$.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new y({...this.checkoutSettings,couponCodeRequirement:r.DEFAULT})),this.step===$.INFO&&(this.isDigitalOnly||(await this.getAvailableShippingZones(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),await this.getShippingCountries(),this.checkShippingCountries()),await this.getStockLocations(),await this.getAvailableStockLocations(),this.isInStoreDelivery&&(this.deliveryMethod="in-store")),this.step!==$.SHIPPING||1!==this.checkout.availableShippingMethods?.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=$.PAYMENT,window.location.href=`/checkout?id=${this.checkout.id}&step=${this.step}`),this.step===$.SHIPPING&&!this.checkout.availableShippingMethods?.length)return this.error={type:W.NO_SHIPPING_ERROR},void(this.isCheckoutLoaded=!0);if(this.step===$.SUCCESS&&this.checkout.orderPaymentStatus===l.PAID&&await this.listProductFile(),(this.step===$.PAYMENT||this.step===$.SUCCESS)&&(await this.listPaymentGateways(),this.isInStoreDelivery&&(this.deliveryMethod="in-store",await this.getStockLocations()),!this.paymentGateways.length))return this.error={type:W.NO_SHIPPING_ERROR},void(this.isCheckoutLoaded=!0);if(this.step!==$.SUCCESS){if(this.checkout.isComplete)return this.changeStep($.SUCCESS);await this.initialStockCheck()}else if(await this.getSuccessTransaction(),this.successTransaction){const t=this.successTransaction.paymentGatewayId;this.checkout.selectedPaymentGateway=this.paymentGateways.find((e=>e.id===t))}this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step)},this.getSuccessTransaction=async()=>{const t=await b.listOrderTransactions({orderId:{eq:this.checkout.id}});this.successTransaction=t.isSuccess&&t.data?.length?t.data[t.data.length-1]:void 0},this.saveCart=async()=>{let t=new V(this.checkout);"in-store"===this.deliveryMethod&&(t=await this.inStockDeliveryInputData(t)),this.step!==$.INFO&&this.step!==$.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),t.customer&&(this.store.customerStore.customer?t.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===d.SUBSCRIBED:this.checkout.customer&&(t.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1));const e=await j.saveCart({input:t});if(e?.graphQLErrors&&e.graphQLErrors.length){const t=e.graphQLErrors[0];throw"CUSTOMER_LOGIN_REQUIRED"===t.extensions?.code?{type:W.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===t.extensions?.code?{type:W.CUSTOMER_ACCOUNT_DISABLED_ERROR}:{type:W.API_ERROR,data:e.firstErrorMessage}}return e.data},this.inStockDeliveryInputData=async t=>{const e=t,s=this.stockLocations.find((t=>t.id===this.checkout.stockLocationId));return s&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),e},this.checkStocks=async()=>{if(this.isManualOrder)return;const t=this.checkout.stockLocationId&&this.checkout.shippingMethod===u.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:g.getStockLocationIds()?.length?g.getStockLocationIds():null,e=await _.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:t});if(!e.isSuccess)throw{type:W.API_ERROR,data:e.firstErrorMessage};const s=e.data?.lines?.filter((t=>!t.isAvailable));if(s?.length){const t=[];for(const e of s){const s=this.checkout.items.find((t=>t.variant.id===e.variantId));s&&t.push({item:s,stockCount:e.stockCount})}throw{type:W.STOCK_ERROR,data:t}}},this.setIsKlarnaPaymentCompleted=async t=>{this.isKlarnaPaymentCompleted=t},this.removeUnavailableItems=async t=>{for(const e of t)await w.getInstance().cartStore.changeItemQuantity(e.item,e.stockCount<0?0:e.stockCount)},this.getShippingCountries=async()=>{const t=await _.getAvailableShippingCountries({salesChannelId:g.getSalesChannelId()});this.shippingCountryIds=t.data},this.getStockLocations=async()=>{if(g.getPickupStockLocationIds()){const t=await _.listStockLocation({id:{in:g.getPickupStockLocationIds()}});if(!t.isSuccess||!t.data?.length)return void(this.error={type:W.API_ERROR,data:t.firstErrorMessage});this.stockLocations=t.data}},this.getAvailableStockLocations=async()=>{if(g.getPickupStockLocationIds()){const t=this.checkout.items.map((t=>({quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}))),e=await _.getAvailableStockLocations({lines:t.map((t=>new U(t))),stockLocationIdList:g.getPickupStockLocationIds()});if(!e.isSuccess)return void(this.error={type:W.API_ERROR});this.availableStockLocations=e.data||[]}},this.checkShippingCountries=()=>{this.shippingCountryIds?.length||(this.error={type:W.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=t=>{this.deliveryMethod!==t&&("address"===t&&(this.checkout.stockLocationId=null,this.customerAddresses?.length?this.onSelectedShippingAddressIdChange(this.customerAddresses[0].id||"-1"):(this.checkout.shippingAddress=new M,this.checkout.shippingAddress.countrySettings=this.countrySettings,this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones)),this.deliveryMethod=t,this.isErrorsVisible=!1)},this.initialStockCheck=async()=>{try{await this.checkStocks()}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN})}},this.listPaymentGateways=async()=>{const t="local"===process.env.PUBLIC_ENV__ENV,e=g.getPaymentGateways().map((t=>t.id)),i=await _.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:t?void 0:{in:e},locale:g.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice});if(!i.isSuccess||!i.data?.length)return void(this.error={type:W.API_ERROR,data:i.firstErrorMessage});let o=i.data;if(this.step===$.PAYMENT){o=o.filter((t=>!t.supportedCurrencies?.length||t.supportedCurrencies.includes(this.checkout.currencyCode)));const t=this.checkout.shippingAddress?.country;t&&t.iso2&&(o=o.filter((e=>!e.availableCountries?.length||e.availableCountries.includes(t.iso2||""))))}const n=[];if(s(g.getPaymentGateways(),"order").forEach((t=>{const e=o?.find((e=>e.id===t.id));e&&n.push(e)})),this.paymentGateways=t?o:n,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===$.PAYMENT){const t=o.find((t=>!!t.masterPassClientId));if(t){this.checkout.masterPassPaymentGateway=t;const e=document.createElement("script");e.id=L,e.src=G,e.onload=()=>{this.mpVM.checkMasterPass({checkout:this.checkout,store:w.getInstance()})},document.head.appendChild(e)}}},this.retrieveInstallmentInfo=async t=>{const e=(await _.retrieveInstallmentInfo(t)).data;e?.installmentPrices?.sort(((t,e)=>(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1)),this.installmentInfo=e},this.createCustomer=()=>{this.store.customerStore.customer?(this.customerAddresses?.forEach((t=>{t.checkoutSettings=this.checkoutSettings,t.shippingZones=this.shippingZones})),this.checkout.customer=new k(this.store.customerStore.customer)):this.checkout.customer=new k(this.checkout.customer||{})},this.setCheckoutShippingAddressSettings=()=>{this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones,this.checkout.shippingAddress.countrySettings=this.countrySettings,this.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=()=>{this.checkout.billingAddress&&(this.checkout.billingAddress.checkoutSettings=this.checkoutSettings,this.checkout.billingAddress.shippingZones=this.shippingZones,this.checkout.billingAddress.countrySettings=this.countrySettings,this.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=()=>{if(!this.isDigitalOnly)if(this.isInStoreDelivery)this.setCheckoutShippingAddressSettings();else if(this.checkout.shippingAddress){if(this.store.customerStore.customer){const t=this.customerAddresses,e=t?.find((t=>t.id===this.checkout.shippingAddress?.id));if(e)return this.onSelectedShippingAddressIdChange(e.id||"-1"),void this.setCheckoutShippingAddressSettings()}this.checkout.shippingAddress=new M(e(this.checkout.shippingAddress)||{}),this.setCheckoutShippingAddressSettings()}else if(this.store.customerStore.customer){const t=this.customerAddresses;this.onSelectedShippingAddressIdChange(t?.length?t[0].id:"-1")}else this.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=()=>{if("undefined"!=typeof localStorage)if(this.useDifferentAddress=!!localStorage.getItem(K),this.checkout.billingAddress){if(this.store.customerStore.customer){const t=this.customerAddresses,e=t?.find((t=>t.id===this.checkout.billingAddress?.id));if(e)return this.onSelectedBillingAddressIdChange(e.id||"-1"),void this.setCheckoutBillingAddressSettings()}this.checkout.billingAddress=new M(e(this.checkout.billingAddress)||{}),this.setCheckoutBillingAddressSettings()}else if(this.store.customerStore.customer){const t=this.customerAddresses;this.onSelectedBillingAddressIdChange(t?.length?t[0].id:"-1"),t?.length||this.useDifferentAddress||!this.checkout.shippingAddress||this.isInStoreDelivery||(this.checkout.billingAddress=new M(e(this.checkout.shippingAddress)),this.setCheckoutBillingAddressSettings())}else this.onSelectedBillingAddressIdChange("-1"),this.useDifferentAddress||!this.checkout.shippingAddress||this.isInStoreDelivery||(this.checkout.billingAddress=new M(e(this.checkout.shippingAddress)),this.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=async t=>{if(this.isChangingShippingMethod)return;this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=t.shippingSettingsId,this.checkout.shippingZoneRateId=t.shippingZoneRateId;const e=await this.saveCart();e&&(this.checkout=new f(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1},this.onStockLocationChange=async t=>{this.checkout.stockLocationId=t.id},this.onCouponCodeApply=async()=>{try{const t=await j.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null});if(t.isSuccess&&t.data){const e=t.data,s=this.cardData?.cardNumber?.split(" ").join("");if(this.couponError=null,this.step===$.PAYMENT&&s?.length&&s.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:e.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1&&await this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:e.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),e){const t=this.checkout;this.checkout=new f({...e,shippingAddress:t.shippingAddress,billingAddress:t.billingAddress,customer:t.customer,selectedPaymentGateway:t.selectedPaymentGateway},this.countrySettings)}}t.isSuccess||(this.couponError=t.errorCodes[0])}catch(t){}},this.getAvailableShippingZones=async()=>{try{const t=await D.getAvailableShippingZones({salesChannelId:g.getSalesChannelId()});this.shippingZones=t.data||null}catch(t){}},this.onSelectedShippingAddressIdChange=t=>{if(this.selectedShippingAddressId=t,"-1"===t)this.checkout.shippingAddress=new M,this.checkout.shippingAddress.countrySettings=this.countrySettings;else{const e=this.customerAddresses?.find((e=>e.id===t));e&&(this.checkout.shippingAddress=new M(e),this.checkout.shippingAddress.countrySettings=this.countrySettings)}this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones)},this.onSelectedBillingAddressIdChange=t=>{if(this.selectedBillingAddressId=t,"-1"===t)this.checkout.billingAddress=new M,this.checkout.billingAddress.countrySettings=this.countrySettings;else{const e=this.customerAddresses?.find((e=>e.id===t));e&&(this.checkout.billingAddress=new M(e),this.checkout.billingAddress.countrySettings=this.countrySettings)}this.checkout.billingAddress&&(this.checkout.billingAddress.checkoutSettings=this.checkoutSettings,this.checkout.billingAddress.shippingZones=this.shippingZones)},this.onTermsAndConditionsCheckedChange=t=>{this.isTermsAndConditionsChecked=t},this.onCardNumberChange=t=>{if(!this.cardData)return;if(t.length>this.cardData.cardNumber.length&&!q(t))return;const e=(this.cardData.cardNumber||"").split(" ").join(""),s=t.split(" ").join("");s.length>16||(e.length<6&&s.length>=6&&!this.installmentInfo?this.getRetrieveInstallmentInfo(s):s.length<6&&e.length>s.length&&(this.cardData.installmentCount=1,this.installmentInfo=void 0),this.installmentInfo?.cardAssociation===F.AMERICAN_EXPRESS?this.cardData.cardNumber=function(t){let e=[];const s=t.slice(0,4),i=t.slice(4,10),o=t.slice(10,15);s&&e.push(s);i&&e.push(i);o&&e.push(o);return e}(s).join(" "):this.cardData.cardNumber=H(s,4).join(" "))},this.getRetrieveInstallmentInfo=async t=>{await this.retrieveInstallmentInfo({input:{binNumber:t.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.cardData?.cardNumber&&this.onCardNumberChange(this.cardData.cardNumber)},this.onCardHolderNameChange=t=>{this.cardData&&(this.cardData.cardHolderName=t)},this.onExpirationDateChange=t=>{if(!this.cardData)return;if(t.length>this.cardData.expirationDate.length&&!q(t))return;if(0===this.cardData.expirationDate?.length){const e=t.replace(".","/").split("/");if(2===e.length){const t=e[0].trim(),s=e[1].trim();if(4===t.length&&2===s.length){const e=parseInt(t.slice(2)),i=parseInt(s);if(!isNaN(e)&&!isNaN(i))return void(this.cardData.expirationDate=`${i<10?"0"+i:i} / ${e<10?"0"+e:e}`)}if(2===t.length&&4===s.length){const e=parseInt(t),i=parseInt(s.slice(2));if(!isNaN(i)&&!isNaN(e))return void(this.cardData.expirationDate=`${e<10?"0"+e:e} / ${i<10?"0"+i:i}`)}if(2===t.length&&2===s.length){const e=parseInt(t),i=parseInt(s),o=e<=12?e:i,n=i>12?i:e;if(!isNaN(n)&&!isNaN(o))return void(this.cardData.expirationDate=`${o<10?"0"+o:o} / ${n<10?"0"+n:n}`)}}}const e=t.split(" / ").join("");e.length>4||(this.cardData.expirationDate=H(e,2).join(" / "))},this.onCvcChange=t=>{if(this.cardData&&(!(t.length>this.cardData.cvv.length)||q(t))){if(this.installmentInfo){if(this.installmentInfo.cardAssociation===F.AMERICAN_EXPRESS&&t.length>4)return;if(this.installmentInfo.cardAssociation!==F.AMERICAN_EXPRESS&&t.length>3)return}else if(t.length>3)return;this.cardData.cvv=t}},this.saveAddress=async t=>{try{if(this.shouldSaveAddress&&this.store.customerStore.customer){const s="shipping"===t?this.checkout.shippingAddress:this.checkout.billingAddress,i=this.customerAddresses?.find((t=>t.id===s?.id));if(i)return;const o=this.customerAddresses?.map((t=>t.id)),n=new S({...s,title:this.addressTitle||this.t("checkout-page:newAddress")}),a=e(this.store.customerStore.customer);a.addresses||(a.addresses=[]),a.addresses.push(n),await this.store.customerStore.saveCustomer(a),this.customerAddresses?.forEach((t=>{t.checkoutSettings=this.checkoutSettings,t.shippingZones=this.shippingZones}));const r=this.customerAddresses?.map((t=>t.id)),d=r?.filter((t=>!o?.includes(t))),c=d?.length?d[0]:void 0;"shipping"===t?(this.checkout.shippingAddress.id=c||"",this.selectedShippingAddressId=c||"-1"):(this.checkout.billingAddress.id=c||"",this.selectedBillingAddressId=c||"-1")}}catch(t){console.error(t)}},this.onGoToCartClick=()=>{window.location.href="/cart"},this.onBackToShoppingClick=()=>{window.location.href="/"},this.onGoToLoginClick=()=>{window.location.href="/account/login"},this.onProceedToShippingClick=async()=>{if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return void(this.isErrorsVisible=!0)}else if(!this.canProceedToInStoreDelivery)return void(this.isErrorsVisible=!0);this.isErrorsVisible=!1;try{this.isStepLoading=!0,"address"===this.deliveryMethod&&await this.saveAddress("shipping"),await this.checkStocks(),await this.saveCart(),"address"===this.deliveryMethod?this.changeStep($.SHIPPING):this.changeStep($.PAYMENT)}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}},this.onProceedToDigitalOnlyPaymentClick=async()=>{if(this.canProceedToPayment){this.isErrorsVisible=!1;try{this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.changeStep($.PAYMENT)}catch(t){t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.onProceedToPaymentClick=async()=>{if(this.canProceedToPayment){this.isErrorsVisible=!1;try{this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.error=void 0,this.changeStep($.PAYMENT)}catch(t){void 0!==typeof t.type?this.error=t:(console.log(t),this.error={type:W.UNKNOWN}),this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.checkPaypalButtonAvailable=()=>!!this.canPerformPayment||(this.isErrorsVisible=!0,!1),this.onCompletePaymentClick=async()=>{if(this.canPerformPayment){if(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),!this.isFree&&this.isKlarna)return await this.saveCart(),void this.setIsKlarnaPaymentCompleted(!0);try{if(this.isErrorsVisible=!1,this.isStepLoading=!0,await this.checkStocks(),"address"===this.deliveryMethod&&this.useDifferentAddress&&await this.saveAddress("billing"),await this.saveCart(),!this.isFree&&this.isCustomFlowStripe){const t=document.querySelector("#stripe-form-btn");return void(t&&t.click())}if(!this.isFree&&this.isAdyen)return this.adyenDropinElement.submit(),void(this.adyenDropinElement.isValid||(this.isStepLoading=!1));if(!this.isFree&&this.isPayPal)return;await this.createSaleTransaction()}catch(t){void 0!==typeof t.type?this.error=t:this.error={type:W.UNKNOWN},this.isStepLoading=!1}}else this.isErrorsVisible=!0},this.onCompleteDigitalOnlyPaymentClick=async()=>{if(!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)this.isErrorsVisible=!0;else{if(this.isKlarna)return await this.saveCart(),void this.setIsKlarnaPaymentCompleted(!0);try{if(this.isErrorsVisible=!1,this.isStepLoading=!0,await this.checkStocks(),await this.saveCart(),this.isCustomFlowStripe){const t=document.querySelector("#stripe-form-btn");return void(t&&t.click())}if(this.isAdyen)return this.adyenDropinElement.submit(),void(this.adyenDropinElement.isValid||(this.isStepLoading=!1));if(this.isPayPal)return;await this.createSaleTransaction()}catch(t){t.type?this.error=t:this.error={type:W.UNKNOWN},this.isStepLoading=!1}}},this.createSaleTransaction=async()=>{let t;const e=this.mpVM.selectedCard;let s;if(!this.isFree&&e&&this.mpVM.selectedCard?.Name){const e=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout});if(e&&(t=e),void 0===this.cardData?.installmentCount)return;s=await _.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:this.mpVM.selectedCard?.Name},paymentGatewayId:this.mpVM.selectedCard?.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!this.cardData?.threeDSecure},metadata:{_fbp:T("_fbp"),_fbc:T("_fbc")}}})}else{if(!this.checkout.selectedPaymentGateway)return;s=await _.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:e&&t?{phoneNumber:t,savedCardName:this.mpVM.selectedCard?.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||e?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===p.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===m.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})}const i=s?.data?.transactionStatus,o=i&&[h.SUCCESS,h.AUTHORIZED].includes(i),n=i===h.PENDING;if(o)await this.getSuccessTransaction(),await this.onCheckoutTransactionSuccess(s?.data?.orderId||void 0);else{if(!n||!s?.data?.returnSlug)throw{data:s.firstErrorMessage,type:W.UNKNOWN};window.location.href=process.env.PUBLIC_ENV__BASE_URL+s.data.returnSlug}},this.onCheckoutTransactionSuccess=async t=>{localStorage.removeItem(K),this.checkout.customer?.notificationsAccepted&&await this.store.customerStore.createEmailSubscription(this.checkout.customer?.email||""),this.changeStep($.SUCCESS,t)},this.onBackToInfoClick=()=>{this.changeStep($.INFO)},this.onBackToShippingClick=()=>{this.changeStep($.SHIPPING)},this.setCustomerConsentGranted=t=>{this.checkout.customer&&(this.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=t=>{this.useDifferentAddress=t,this.useDifferentAddress?(localStorage.setItem(K,"1"),this.checkout.billingAddress=this.checkout.billingAddress||new M,this.checkout.billingAddress.countrySettings=this.countrySettings):(localStorage.removeItem(K),this.checkout.billingAddress=this.checkout.shippingAddress)},this.setShouldSaveAddress=t=>{this.shouldSaveAddress=t},this.setAddressTitle=t=>{this.addressTitle=t},this.reInitPaymentMethod=async()=>{this.checkout.selectedPaymentGateway&&(this.isCustomFlowStripe&&await this.createStripePaymentIntent(this.checkout.selectedPaymentGateway),this.isKlarna&&window.location.reload(),this.isAdyen&&await this.createAdyenClientToken(this.checkout.selectedPaymentGateway),this.isPayPal&&await this.getPayPalClientId(this.checkout.selectedPaymentGateway))},this.createStripePaymentIntent=async t=>{const e=await _.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.stripeResponse=e.data)},this.createKlarnaClientToken=async t=>{const e=await _.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.klarnaResponse=e.data)},this.createAdyenClientToken=async t=>{const e=await _.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.adyenResponse=e.data)},this.getPayPalClientId=async t=>{const e=await _.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}});e.isSuccess&&e.data&&(this.payPalClientIdResponse=e.data)},this.setPaymentGateway=async t=>{if(!this.paymentGateways.length)return;const e=this.paymentGateways[t];if("STRIPE"===e.code&&e.settings?.find((t=>"allow_custom_flow"===t.label&&"1"===t.value))&&!this.stripeResponse&&await this.createStripePaymentIntent(e),"KLARNA"!==e.code||this.klarnaResponse||await this.createKlarnaClientToken(e),"ADYEN"!==e.code||this.adyenResponse||await this.createAdyenClientToken(e),"PAYPAL"!==e.code||this.payPalClientIdResponse||await this.getPayPalClientId(e),this.checkout.selectedPaymentGateway=e,this.step!==$.SUCCESS){if(e.paymentMethodType===p.CREDIT_CARD&&e.type===m.INTERNAL){this.cardData=new O;e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))}this.installmentInfo=void 0}},this.setInstallmentCount=t=>{this.cardData&&(this.cardData.installmentCount=t)},this.changeStep=async(t,e)=>{Z||window.location.replace(`${window.location.pathname}?id=${e||this.checkout.id}&step=${t}`)},this.logout=async()=>{this.checkout.customer=null,this.store.customerStore.logout();try{await this.saveCart()}catch(t){}this.createCustomer()},this.setContactModalVisible=t=>{this.isContactModalVisible=t},this.getCampaignOffer=async(t,e)=>{if(!e?.length)return;const s=e.filter((e=>e.status===n.WAITING_FOR_ACTION&&e.campaignOffer?.targetPageTypes.some((e=>e===t))));for(const t of s){if(!t?.campaignOffer)return;const e=t.campaignOffer.offers.find((e=>e.id===t.campaignOfferProductId));if(!e)return;const s=[e.productId],o=await P.searchProducts({input:{productIdList:s,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId()}});if(o.isSuccess&&o.data?.data?.length){const s=o.data.data[0];let n=s.variants.filter((t=>t.hasStock&&!(e.excludedVariantIdList||[]).some((e=>e===t.id)))).map((t=>e.discountAmount?new N({...t,prices:t.prices.map((t=>{let s=t.finalPrice,o=t.finalPrice-t.finalPrice*e.discountAmount/100;return e.applicablePrice===i.SELL_PRICE&&(s=t.sellPrice,o=t.sellPrice-t.sellPrice*e.discountAmount/100),new R({...t,sellPrice:s,discountPrice:o})}))}):t));if(n.length){const i=n.find((t=>t.isActive));return{product:new I({...s,selectedVariantValues:(i||n[0]).variantValues,variants:n}),offer:e,campaignOffer:t}}}}},this.createCampaignOffer=async()=>{this.campaignOffer=await this.getCampaignOffer(this.step===$.SUCCESS?o.POST_CHECKOUT:o.CHECKOUT,this.checkout.campaignOffers)},this.updateCartCampaignOffer=async t=>{t.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1;const e=await j.updateCartCampaignOffer({input:t});e.isSuccess&&(t.accepted?this.changeStep(this.step===$.SUCCESS?$.PAYMENT:this.step,e.data?.id):(this.checkout.campaignOffers=e.data?.campaignOffers||[],await this.createCampaignOffer(),this.isCampaignOfferLoaded=!0))},this.registerCustomer=async t=>{if(this.checkout.customer){const{firstName:e,lastName:s,email:i}=this.checkout.customer;if(e&&s&&i){return await b.register({orderId:this.checkout.id,firstName:e,lastName:s,email:i,password:t})}}},this.listProductFile=async()=>{let t=this.checkout.orderLineItems.filter((t=>!!t.variant.fileId&&t.status!==c.REFUNDED)).map((t=>t.variant.fileId));if(t.length){const e=await _.listProductFile({id:{in:t}});e.isSuccess&&(this.productFiles=e.data||[])}},this.getDigitalProductFileDownloadUrl=async t=>{try{const e=this.checkout.orderLineItems.find((e=>e.variant.id===t.variantId));if(e){const s=(await _.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})).data;if(s){const e=document.createElement("a");e.href=s,e.download=function(t){try{return decodeURIComponent(t.split("/")[t.split("/").length-1])}catch{return""}}(t.name),e.click(),e.remove()}}}catch(t){console.error(t)}},this.checkout=a,this.checkoutSettings=C,this.returnPolicy=A,this.privacyPolicy=B,this.termsOfService=Y,this.imprint=Q,this.shippingPolicy=z,this.t=X,this.customizationProps=J,this.mpVM=new x,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new v({currentLocale:g.getCurrentLocale()}),this.init(),t(this)}get merchantSettings(){return new A(g.getMerchantSettings())}get selectedPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>t.id===this.checkout.selectedPaymentGateway?.id))}get selectedInstallmentIndex(){return this.installmentInfo?.installmentPrices?.findIndex((t=>t.installmentCount===this.cardData?.installmentCount))||0}get checkoutUrl(){return`/checkout?id=${this.checkout.id}&step=info`}get customerAddressOptions(){const t={label:this.t("checkout-page:newAddress"),value:"-1"},e=w.getInstance().customerStore.customer?.addresses?.map((t=>({label:t.title+" - "+t.addressText,value:t.id})))||[];return[t].concat(e)}get installmentPrice(){if(this.installmentInfo&&this.cardData?.installmentCount)return this.installmentInfo.installmentPrices?.find((t=>t.installmentCount===this.cardData?.installmentCount))?.totalPrice}get installmentExtraPrice(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice}get finalPrice(){return this.step===$.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice}get hasStockError(){return this.error?.type===W.STOCK_ERROR}get isPaymentGatewayHasMasterPass(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)}get hasQuickRegistration(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout}get canProceedToShipping(){return(this.isDigitalOnly?this.checkout.billingAddress?.isValidAddress:this.checkout.shippingAddress?.isValidAddress)&&this.checkout.hasValidCustomerEmail&&this.error?.type!==W.NO_SHIPPING_ERROR}get canProceedToInStoreDelivery(){return!!(this.checkout.shippingAddress?.firstName&&this.checkout.shippingAddress?.lastName&&this.checkout.customer?.email&&this.checkout.stockLocationId)}get canProceedToPayment(){return this.canProceedToShipping&&this.isValidShippingSettings}get isValidShippingSettings(){return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&this.checkout.shippingLines?.some((t=>t.shippingSettingsId===this.checkout.shippingSettingsId&&t.shippingZoneRateId===this.checkout.shippingZoneRateId))}get isInStoreDelivery(){return!!this.checkout.stockLocationId}get klarnaPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"KLARNA"===t.code));if(-1!==t)return this.paymentGateways[t]}get klarnaPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"KLARNA"===t.code))}get adyenPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"ADYEN"===t.code));if(-1!==t)return this.paymentGateways[t]}get adyenPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"ADYEN"===t.code))}get payPalPaymentGateway(){const t=this.paymentGateways.findIndex((t=>"PAYPAL"===t.code));if(-1!==t)return this.paymentGateways[t]}get payPalPaymentGatewayIndex(){return this.paymentGateways.findIndex((t=>"PAYPAL"===t.code))}get isCustomFlowStripe(){const t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&t.settings?.find((t=>"allow_custom_flow"===t.label&&"1"===t.value))}get isKlarna(){const t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code}get isAdyen(){const t=this.checkout.selectedPaymentGateway;return t&&"ADYEN"===t.code}get isPayPal(){const t=this.checkout.selectedPaymentGateway;return t&&"PAYPAL"===t.code}get isFree(){return 0===this.checkout.totalFinalPrice}get store(){return w.getInstance()}get isCouponCodeRequirementDefult(){return this.checkoutSettings.couponCodeRequirement===r.DEFAULT||null===this.checkoutSettings.couponCodeRequirement}get isCouponCodeRequirementOpen(){return this.checkoutSettings.couponCodeRequirement===r.OPEN}get isCouponCodeRequirementInvisible(){return this.checkoutSettings.couponCodeRequirement===r.INVISIBLE}get isCouponCodeVisible(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible}get canPerformPayment(){if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;const t=this.checkout.selectedPaymentGateway,e=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,s=!!this.checkout.billingAddress?.isValidAddress,i=!!this.isFree||(!!this.mpVM.selectedCard||(t?.paymentMethodType===p.CREDIT_CARD&&t.type===m.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||this.cardData?.isValid):!!t));return e&&s&&i}get isDigitalOnly(){return this.checkout.shippingMethod===u.DIGITAL_DELIVERY}get customerAddresses(){const t=g.getCurrentRouting()?.countryCodes;return this.store.customerStore.customer?.addresses?.filter((e=>!t?.length||e.country?.iso2&&t.includes(e.country.iso2))).map((t=>{const e=new C({countrySettings:this.countrySettings,...t});return e.checkoutSettings=this.checkoutSettings,e.shippingZones=this.shippingZones,e.getValidatedCustomerAddress(),e}))}get isManualOrder(){return this.checkout.createdBy===a.ADMIN}get isUpsellOrder(){return this.checkout.createdBy===a.UPSELL}get isEPayKolayEnabled(){const t=g.getCustom();return!!t&&!!t.isEPayKolayEnabled}get isPoweredByHidden(){const t=g.getCustom();return!!t&&!!t.hidePoweredBy}setAdyenDropinElement(t){this.adyenDropinElement=t}}function H(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function q(t){return t&&B.test(t.charAt(t.length-1))}var $,W;!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}($||($={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",t[t.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR"}(W||(W={}));export{$ as CheckoutStep,W as ErrorType,Y as default};