@ikas/storefront 6.1.0-beta.39 → 6.1.0-beta.391
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.
- package/build/analytics/analytics.d.ts +8 -3
- package/build/analytics/analytics.js +1 -1
- package/build/analytics/events.d.ts +4 -1
- package/build/analytics/events.js +1 -1
- package/build/analytics/facebookPixel.d.ts +13 -0
- package/build/analytics/facebookPixel.js +1 -1
- package/build/analytics/googleAnalytics.d.ts +3 -2
- package/build/analytics/googleAnalytics.js +1 -1
- package/build/analytics/googleTagManager.d.ts +5 -3
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/head/index.d.ts +17 -2
- package/build/analytics/head/index.js +1 -1
- package/build/analytics/ikasV3.d.ts +2 -1
- package/build/analytics/ikasV3.js +1 -1
- package/build/analytics/openAiPixel.d.ts +31 -0
- package/build/analytics/openAiPixel.js +1 -0
- package/build/components/checkout/components/address-form/index.js +1 -1
- package/build/components/checkout/components/address-form/model.d.ts +5 -0
- package/build/components/checkout/components/address-form/model.js +1 -1
- package/build/components/checkout/components/adyen/index.js +1 -1
- package/build/components/checkout/components/button/index.d.ts +1 -0
- package/build/components/checkout/components/button/index.js +1 -1
- package/build/components/checkout/components/button/style.module.scss.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/style.module.scss.js +1 -1
- package/build/components/checkout/components/cart-summary/index.d.ts +3 -1
- package/build/components/checkout/components/cart-summary/index.js +1 -1
- package/build/components/checkout/components/cart-summary/loyalty/icons.d.ts +4 -0
- package/build/components/checkout/components/cart-summary/loyalty/icons.js +1 -0
- package/build/components/checkout/components/cart-summary/loyalty/index.d.ts +13 -0
- package/build/components/checkout/components/cart-summary/loyalty/index.js +1 -0
- package/build/components/checkout/components/cart-summary/loyalty/style.module.scss.js +1 -0
- package/build/components/checkout/components/cart-summary/style.module.scss.js +1 -1
- package/build/components/checkout/components/checkbox/index.d.ts +1 -0
- package/build/components/checkout/components/checkbox/index.js +1 -1
- package/build/components/checkout/components/checkout-load-failed/index.d.ts +14 -0
- package/build/components/checkout/components/checkout-load-failed/index.js +1 -0
- package/build/components/checkout/components/checkout-load-failed/style.module.scss.js +1 -0
- package/build/components/checkout/components/credit-card-form/model.js +1 -1
- package/build/components/checkout/components/customer-addresses/index.d.ts +1 -0
- package/build/components/checkout/components/customer-addresses/index.js +1 -1
- package/build/components/checkout/components/customer-addresses/model.js +1 -1
- package/build/components/checkout/components/error/stock-error/index.js +1 -1
- package/build/components/checkout/components/form-item/index.js +1 -1
- package/build/components/checkout/components/form-item/model.d.ts +5 -3
- package/build/components/checkout/components/form-item/model.js +1 -1
- package/build/components/checkout/components/form-item/style.module.scss.js +1 -1
- package/build/components/checkout/components/hepsipay/index.d.ts +9 -0
- package/build/components/checkout/components/hepsipay/index.js +1 -0
- package/build/components/checkout/components/input-with-button/style.module.scss.js +1 -1
- package/build/components/checkout/components/iyzico/index.d.ts +8 -0
- package/build/components/checkout/components/iyzico/index.js +1 -0
- package/build/components/checkout/components/master-pass/credit-card-form/index.js +1 -1
- package/build/components/checkout/components/modal/index.d.ts +1 -0
- package/build/components/checkout/components/modal/index.js +1 -1
- package/build/components/checkout/components/modal/style.module.scss.js +1 -1
- package/build/components/checkout/components/offer-product/index.js +1 -1
- package/build/components/checkout/components/offer-product/style.module.scss.js +1 -1
- package/build/components/checkout/components/phone-number-input/index.d.ts +3 -1
- package/build/components/checkout/components/phone-number-input/index.js +1 -1
- package/build/components/checkout/components/quick-registration/completed.js +1 -1
- package/build/components/checkout/components/quick-registration/index.js +1 -1
- package/build/components/checkout/components/quick-registration/model.js +1 -1
- package/build/components/checkout/components/secure-card-form/index.d.ts +13 -0
- package/build/components/checkout/components/secure-card-form/index.js +1 -0
- package/build/components/checkout/components/secure-card-form/masterpass-bridge-model.d.ts +33 -0
- package/build/components/checkout/components/secure-card-form/masterpass-bridge-model.js +1 -0
- package/build/components/checkout/components/secure-card-form/model.d.ts +67 -0
- package/build/components/checkout/components/secure-card-form/model.js +1 -0
- package/build/components/checkout/components/secure-card-form/protocol.d.ts +222 -0
- package/build/components/checkout/components/secure-card-form/protocol.js +1 -0
- package/build/components/checkout/components/secure-card-form/style.module.scss.js +1 -0
- package/build/components/checkout/components/select-box/index.d.ts +3 -0
- package/build/components/checkout/components/select-box/index.js +1 -1
- package/build/components/checkout/components/step-container/index.d.ts +5 -0
- package/build/components/checkout/components/step-container/index.js +1 -1
- package/build/components/checkout/components/step-container/style.module.scss.js +1 -1
- package/build/components/checkout/components/stripe/checkout-form.js +1 -1
- package/build/components/checkout/components/stripe-express/index.d.ts +7 -0
- package/build/components/checkout/components/stripe-express/index.js +1 -0
- package/build/components/checkout/components/stripe-express/style.module.scss.js +1 -0
- package/build/components/checkout/components/svg/coupon-code-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/coupon-code-tag.js +1 -0
- package/build/components/checkout/components/svg/credit-balance.d.ts +6 -0
- package/build/components/checkout/components/svg/credit-balance.js +1 -0
- package/build/components/checkout/components/svg/gift-cart-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/gift-cart-tag.js +1 -0
- package/build/components/checkout/components/svg/gift-loyalty.d.ts +6 -0
- package/build/components/checkout/components/svg/gift-loyalty.js +1 -0
- package/build/components/checkout/components/svg/info.d.ts +6 -0
- package/build/components/checkout/components/svg/info.js +1 -0
- package/build/components/checkout/components/svg/package-loyalty.d.ts +6 -0
- package/build/components/checkout/components/svg/package-loyalty.js +1 -0
- package/build/components/checkout/components/svg/percentage-loyalty.d.ts +6 -0
- package/build/components/checkout/components/svg/percentage-loyalty.js +1 -0
- package/build/components/checkout/components/svg/refresh.d.ts +6 -0
- package/build/components/checkout/components/svg/refresh.js +1 -0
- package/build/components/checkout/components/svg/star-loyalty.d.ts +6 -0
- package/build/components/checkout/components/svg/star-loyalty.js +1 -0
- package/build/components/checkout/components/svg/store-credit-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/store-credit-tag.js +1 -0
- package/build/components/checkout/components/svg/subscription.d.ts +6 -0
- package/build/components/checkout/components/svg/subscription.js +1 -0
- package/build/components/checkout/components/tkpay/index.d.ts +8 -0
- package/build/components/checkout/components/tkpay/index.js +1 -0
- package/build/components/checkout/components/toggle/index.d.ts +2 -0
- package/build/components/checkout/components/toggle/index.js +1 -1
- package/build/components/checkout/components/toggle/style.module.scss.js +1 -1
- package/build/components/checkout/index.d.ts +2 -0
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +230 -8
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/modelMasterPass.d.ts +6 -2
- package/build/components/checkout/modelMasterPass.js +1 -1
- package/build/components/checkout/steps/step-info/index.js +1 -1
- package/build/components/checkout/steps/step-info/style.module.scss.js +1 -0
- package/build/components/checkout/steps/step-payment/billing-address/index.js +1 -1
- package/build/components/checkout/steps/step-payment/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/installments/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/header.d.ts +4 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/header.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/index.d.ts +14 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/index.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/login-required.d.ts +13 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/login-required.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/miles-smiles-logo.d.ts +7 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/miles-smiles-logo.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/miles-smiles/style.module.scss.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/saved-cards/index.d.ts +10 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/saved-cards/index.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/saved-cards/style.module.scss.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.d.ts +7 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/style.module.scss.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/style.module.scss.js +1 -1
- package/build/components/checkout/steps/step-shipping/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/checkout/style.module.scss.js +1 -1
- package/build/components/image/index.d.ts +1 -0
- package/build/components/image/index.js +1 -1
- package/build/components/index.d.ts +3 -0
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.d.ts +1 -1
- package/build/components/page/index.js +1 -1
- package/build/components/page/widgets/common.d.ts +2 -0
- package/build/components/page/widgets/common.js +1 -0
- package/build/components/page/widgets/loyaltyWidget.d.ts +13 -0
- package/build/components/page/widgets/loyaltyWidget.js +1 -0
- package/build/components/page/widgets/popupWidget.d.ts +16 -0
- package/build/components/page/widgets/popupWidget.js +1 -0
- package/build/components/page-editor/ThemeComponentEditor.js +1 -1
- package/build/components/page-editor/model.d.ts +2 -0
- package/build/components/page-editor/model.js +1 -1
- package/build/components/pay-with-ikas/index.d.ts +9 -0
- package/build/components/pay-with-ikas/index.js +1 -0
- package/build/components/paypal-express-checkout/index.d.ts +9 -0
- package/build/components/paypal-express-checkout/index.js +1 -0
- package/build/components/plain-image/index.d.ts +13 -0
- package/build/components/plain-image/index.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/config/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/formatIncompletePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/getCountries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/formatIncompletePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountryCallingCode.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/isSupportedCountry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/parsePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/ObserverComponent.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/observer.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/useObserver.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/UniversalFinalizationRegistry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/assertEnvironment.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerBatching.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerFinalizationRegistry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/printDebugValue.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/button-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/checkbox-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/input-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/get-countries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-column-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/product-list-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/social-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/form-settings/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js +1 -1
- package/build/hooks/useCustomerReviews.d.ts +2 -0
- package/build/hooks/useCustomerReviews.js +1 -1
- package/build/hooks/useDimension.js +1 -1
- package/build/hooks/useStore.js +1 -1
- package/build/index.js +1 -1
- package/build/models/data/checkout-settings/address-field-restriction/index.d.ts +10 -0
- package/build/models/data/checkout-settings/address-field-restriction/index.js +1 -0
- package/build/models/data/checkout-settings/index.d.ts +3 -0
- package/build/models/data/checkout-settings/index.js +1 -1
- package/build/models/data/customer/address/ikas-localized-customer-address.d.ts +1 -0
- package/build/models/data/customer/address/ikas-localized-customer-address.js +1 -1
- package/build/models/data/customer/review/index.d.ts +4 -1
- package/build/models/data/customer/review/index.js +1 -1
- package/build/models/data/index.d.ts +6 -0
- package/build/models/data/order/address/ikas-localized-order-address.d.ts +1 -0
- package/build/models/data/order/address/ikas-localized-order-address.js +1 -1
- package/build/models/data/order/adjustment/index.d.ts +3 -1
- package/build/models/data/order/adjustment/index.js +1 -1
- package/build/models/data/order/gift-card-line/index.d.ts +2 -1
- package/build/models/data/order/gift-card-line/index.js +1 -1
- package/build/models/data/order/index.d.ts +21 -2
- package/build/models/data/order/index.js +1 -1
- package/build/models/data/order/line-item/bundle-product-settings/index.d.ts +7 -0
- package/build/models/data/order/line-item/bundle-product-settings/index.js +1 -0
- package/build/models/data/order/line-item/index.d.ts +9 -1
- package/build/models/data/order/line-item/index.js +1 -1
- package/build/models/data/order/line-item/order-line-item-subscription-plan/index.d.ts +8 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/index.js +1 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.d.ts +6 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.js +1 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.d.ts +14 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.js +1 -0
- package/build/models/data/order/loyalty-line/index.d.ts +9 -0
- package/build/models/data/order/loyalty-line/index.js +1 -0
- package/build/models/data/order/order-transaction-with-prices/index.d.ts +1 -0
- package/build/models/data/order/order-transaction-with-prices/index.js +1 -1
- package/build/models/data/order/refund/reason/index.d.ts +8 -0
- package/build/models/data/order/refund/reason/index.js +1 -0
- package/build/models/data/order/refund/reason/translation/index.d.ts +6 -0
- package/build/models/data/order/refund/reason/translation/index.js +1 -0
- package/build/models/data/order/refund/refundable-line/index.d.ts +10 -0
- package/build/models/data/order/refund/refundable-line/index.js +1 -0
- package/build/models/data/order/refund/refundable-lines/index.d.ts +10 -0
- package/build/models/data/order/refund/refundable-lines/index.js +1 -0
- package/build/models/data/order/refund/settings/index.d.ts +1 -0
- package/build/models/data/order/refund/settings/index.js +1 -1
- package/build/models/data/order/refund/settings/translation/index.d.ts +6 -0
- package/build/models/data/order/refund/settings/translation/index.js +1 -0
- package/build/models/data/payment-gateway/index.d.ts +1 -0
- package/build/models/data/payment-gateway/index.js +1 -1
- package/build/models/data/product/campaign-offer/index.d.ts +2 -0
- package/build/models/data/product/campaign-offer/index.js +1 -1
- package/build/models/data/product/filter/index.d.ts +2 -0
- package/build/models/data/product/filter/index.js +1 -1
- package/build/models/data/product/index.d.ts +10 -0
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product/translations/index.d.ts +7 -0
- package/build/models/data/product/translations/index.js +1 -0
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.js +1 -1
- package/build/models/data/product/variant/index.d.ts +3 -0
- package/build/models/data/product/variant/index.js +1 -1
- package/build/models/data/product/variant/subscription-plan/index.d.ts +12 -0
- package/build/models/data/product/variant/subscription-plan/index.js +1 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-discount/index.d.ts +6 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.d.ts +23 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.js +1 -0
- package/build/models/data/store-credit-balance/index.d.ts +26 -0
- package/build/models/data/store-credit-balance/index.js +1 -0
- package/build/models/data/storefront/index.d.ts +1 -0
- package/build/models/data/storefront/index.js +1 -1
- package/build/models/data/storefront-popup/index.d.ts +1 -0
- package/build/models/data/storefront-popup/index.js +1 -1
- package/build/models/data/storefront-popup/storefront-popup-display-filter/index.d.ts +4 -7
- package/build/models/data/storefront-popup/storefront-popup-display-filter/index.js +1 -1
- package/build/models/data/theme-json/component/prop/index.d.ts +1 -0
- package/build/models/data/theme-json/component/prop/index.js +1 -1
- package/build/models/data/theme-json/custom-data/index.d.ts +1 -0
- package/build/models/data/theme-json/custom-data/index.js +1 -1
- package/build/models/data/theme-json/index.js +1 -1
- package/build/models/ui/blog-category-list/index.js +1 -1
- package/build/models/ui/blog-list/index.d.ts +10 -1
- package/build/models/ui/blog-list/index.js +1 -1
- package/build/models/ui/brand-list/index.js +1 -1
- package/build/models/ui/category-list/index.js +1 -1
- package/build/models/ui/customer-review-list/index.d.ts +8 -0
- package/build/models/ui/customer-review-list/index.js +1 -1
- package/build/models/ui/customer-review-summary-list/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +25 -2
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/raffle-list/index.js +1 -1
- package/build/models/ui/validator/form/account-info.js +1 -1
- package/build/models/ui/validator/form/address.js +1 -1
- package/build/models/ui/validator/form/ikas-address.js +1 -1
- package/build/models/ui/validator/form/login.d.ts +20 -6
- package/build/models/ui/validator/form/login.js +1 -1
- package/build/models/ui/validator/form/register.d.ts +15 -6
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/page-data-init/index.d.ts +22 -0
- package/build/page-data-init/index.js +1 -1
- package/build/pages/checkout.js +1 -1
- package/build/store/blog/index.js +1 -1
- package/build/store/brand/index.js +1 -1
- package/build/store/cart/api.d.ts +3 -1
- package/build/store/cart/api.js +1 -1
- package/build/store/cart/index.d.ts +28 -2
- package/build/store/cart/index.js +1 -1
- package/build/store/category/index.js +1 -1
- package/build/store/checkout/index.d.ts +10 -1
- package/build/store/checkout/index.js +1 -1
- package/build/store/customer/api.d.ts +37 -13
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.d.ts +100 -9
- package/build/store/customer/index.js +1 -1
- package/build/store/html-meta-data/index.js +1 -1
- package/build/store/index.d.ts +2 -0
- package/build/store/location/index.js +1 -1
- package/build/store/product/index.d.ts +2 -1
- package/build/store/product/index.js +1 -1
- package/build/utils/helper.d.ts +2 -0
- package/build/utils/helper.js +1 -1
- package/build/utils/miles-smiles.d.ts +19 -0
- package/build/utils/miles-smiles.js +1 -0
- package/package.json +18 -16
- package/build/components/popup/index.d.ts +0 -2
- package/build/components/popup/index.js +0 -1
- package/build/components/popup/renderer/index.d.ts +0 -8
- package/build/components/popup/renderer/index.js +0 -1
- package/build/components/popup/renderer/model.d.ts +0 -24
- package/build/components/popup/renderer/model.js +0 -1
- package/build/components/popup/utils/index.d.ts +0 -13
- package/build/components/popup/utils/index.js +0 -1
- package/build/store/storefront-popup/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as o,IkasCartCreatedBy as a,IkasCouponCodeRequirement as c,IkasCorporateInvoiceRequirement as d,IkasPaymentMethodType as u,IkasPaymentGatewayType as l,IkasOrderShippingMethod as h,IkasOrderPaymentStatus as p,IkasTransactionStatus as m,IkasCartCampaignOfferStatus as f,IkasCampaignOfferTargetPageType as g,IkasOrderLineItemStatus as v,IkasAmountType as y,IkasCampaignOfferProductApplicablePriceEnum as S}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as k}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as b}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as P}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as C}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as I}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as A}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as w}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as E}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as O}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as R}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"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import N from"./components/credit-card-form/model.js";import j from"../../store/customer/api.js";import T from"../../store/checkout/index.js";import D from"../../store/cart/api.js";import G,{MFS_ELEMENT_ID as M,MFS_SCRIPT_URL as L}from"./modelMasterPass.js";import x from"../../store/product/index.js";import{TransactionCardAssociationEnum as _,SaveCartInput as V,CheckStocksLineInput as U}from"@ikas/storefront-api";import{IkasBaseStore as F}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as B}from"@ikas/storefront-config";import{Analytics as K}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import Y from"../../models/data/order/address/ikas-localized-order-address.js";import Z from"../../store/location/index.js";import{getCookieValue as H}from"../../utils/helper.js";import q from"../../analytics/ikasV3.js";var W,Q,z=/^\d+$/,X="undefined"==typeof localStorage,J=function(){function z(a,d,C,I,z,J,te,ie,se,ne){var re=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=W.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.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,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=function(){return e(re,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,F.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(re,void 0,void 0,(function(){var e,s,n,r,o,a,d;return t(this,(function(t){switch(t.label){case 0:if(B.getIsEditor())return this.step=W.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===W.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(W.INFO)];if(this.step!==W.PAYMENT||this.canProceedToPayment){if(this.step===W.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(W.INFO)];if(![W.INFO,W.SUCCESS,W.SHIPPING,W.PAYMENT].includes(this.step))return[2,this.changeStep(W.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(W.INFO)]:[2,this.changeStep(W.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:Q.PAYMENT_ERROR,data:r||null}),this.step!==W.SHIPPING&&this.step!==W.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new b(i(i({},this.checkoutSettings),{couponCodeRequirement:c.DEFAULT}))),this.step!==W.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==W.SHIPPING||1!==(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=W.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==W.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==W.SUCCESS||this.checkout.orderPaymentStatus!==p.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:Q.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==W.PAYMENT&&this.step!==W.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:Q.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===W.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(W.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,K.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(re,void 0,void 0,(function(){var e,i,s;return t(this,(function(t){switch(t.label){case 0:return[4,j.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransactions=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(re,void 0,void 0,(function(){var e,i,s,n,r,a;return t(this,(function(t){switch(t.label){case 0:return e=new V(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==W.INFO&&this.step!==W.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===o.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,D.saveCart({input:e})];case 3:if((null==(i=t.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:Q.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(r=s.extensions)||void 0===r?void 0:r.code)?{type:Q.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(a=s.extensions)||void 0===a?void 0:a.code)?{type:Q.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:Q.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(re,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&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),[2,e]}))}))},this.checkStocks=function(){return e(re,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===h.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(u=B.getStockLocationIds())||void 0===u?void 0:u.length)?B.getStockLocationIds():null,[4,T.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:Q.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===p?void 0:p.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:Q.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(re,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(re,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,F.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,T.getAvailableShippingCountries({salesChannelId:B.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(re,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return B.getPickupStockLocationIds()?[4,T.listStockLocation({id:{in:B.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:Q.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(re,void 0,void 0,(function(){var e,i,s,n=this;return t(this,(function(t){switch(t.label){case 0:return B.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,T.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:B.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:Q.API_ERROR},[2];s=B.getCurrentRouting(),this.availableStockLocations=(i.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=re.shippingCountryIds)||void 0===e?void 0:e.length)||(re.error={type:Q.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;re.deliveryMethod!==e&&("address"===e&&(re.checkout.stockLocationId=null,(null===(t=re.customerAddresses)||void 0===t?void 0:t.length)?re.onSelectedShippingAddressIdChange(re.customerAddresses[0].id||"-1"):(re.checkout.shippingAddress=new Y,re.checkout.shippingAddress.countrySettings=re.countrySettings,re.checkout.shippingAddress.checkoutSettings=re.checkoutSettings,re.checkout.shippingAddress.shippingZones=re.shippingZones)),re.deliveryMethod=e,re.isErrorsVisible=!1)},this.initialStockCheck=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Q.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(re,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h,p,m,f=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=B.getPaymentGateways().map((function(e){return e.id})),[4,T.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:i},locale:B.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess?(null===(h=s.data)||void 0===h?void 0:h.length)||this.isFree?(this.error=void 0,n=s.data||[],this.step===W.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(f.checkout.currencyCode)})),(o=null===(p=this.checkout.shippingAddress)||void 0===p?void 0:p.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")}))),a=null===(m=this.checkout.billingAddress)||void 0===m?void 0:m.country,!o&&a&&a.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")})))),c=[],r(B.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&c.push(t)})),this.paymentGateways=e?n:c,d=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=f.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==d?d:0),[3,4])):(this.error={type:Q.NO_SHIPPING_ERROR},[2]):(this.error={type:Q.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==W.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:t.sent(),t.label=4;case 4:return this.step===W.PAYMENT&&(u=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=u,(l=document.createElement("script")).id=M,l.src=L,l.onload=function(){f.mpVM.checkMasterPass({checkout:f.checkout,store:F.getInstance()})},document.head.appendChild(l)),[2]}}))}))},this.retrieveInstallmentInfo=function(i){return e(re,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,T.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;re.store.customerStore.customer?(null===(e=re.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=re.checkoutSettings,e.shippingZones=re.shippingZones})),re.checkout.customer=new A(i(i({},re.store.customerStore.customer),{notificationsAccepted:re.store.customerStore.customer.subscriptionStatus===o.SUBSCRIBED}))):re.checkout.customer=new A(re.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){re.checkout.shippingAddress&&(re.checkout.shippingAddress.checkoutSettings=re.checkoutSettings,re.checkout.shippingAddress.shippingZones=re.shippingZones,re.checkout.shippingAddress.countrySettings=re.countrySettings,re.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){re.checkout.billingAddress&&(re.checkout.billingAddress.checkoutSettings=re.checkoutSettings,re.checkout.billingAddress.shippingZones=re.shippingZones,re.checkout.billingAddress.countrySettings=re.countrySettings,re.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!re.isDigitalOnly)if(re.isInStoreDelivery)re.setCheckoutShippingAddressSettings();else if(re.checkout.shippingAddress){if(re.store.customerStore.customer){var e=null==(t=re.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=re.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return re.onSelectedShippingAddressIdChange(e.id||"-1"),void re.setCheckoutShippingAddressSettings()}re.checkout.shippingAddress=new Y(n(re.checkout.shippingAddress)||{}),re.setCheckoutShippingAddressSettings()}else if(re.store.customerStore.customer){var t=re.customerAddresses;re.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else re.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(re.useDifferentAddress=!!localStorage.getItem("sAddr"),re.checkout.billingAddress){if(re.store.customerStore.customer){var e=null==(t=re.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=re.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return re.onSelectedBillingAddressIdChange(e.id||"-1"),void re.setCheckoutBillingAddressSettings()}re.checkout.billingAddress=new Y(n(re.checkout.billingAddress)||{}),re.setCheckoutBillingAddressSettings()}else if(re.store.customerStore.customer){var t=re.customerAddresses;re.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||re.useDifferentAddress||!re.checkout.shippingAddress||re.isInStoreDelivery||(re.checkout.billingAddress=new Y(n(re.checkout.shippingAddress)),re.setCheckoutBillingAddressSettings())}else re.onSelectedBillingAddressIdChange("-1"),re.useDifferentAddress||!re.checkout.shippingAddress||re.isInStoreDelivery||(re.checkout.billingAddress=new Y(n(re.checkout.shippingAddress)),re.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(e=t.sent())&&(this.checkout=new k(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(re,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(re,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,8,,9]),[4,D.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===W.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:t.sent(),t.label=3;case 3:return s?(r=this.checkout,this.checkout=new k(i(i({},s),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==W.PAYMENT||this.checkout.totalFinalPrice===r.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:t.sent(),t.label=5;case 5:return this.checkout.campaignOffers=s.campaignOffers,console.log("this.checkout.campaignOffers **",this.checkout.campaignOffers),this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:t.sent(),this.isCampaignOfferLoaded=!0,t.label=7;case 7:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,9];case 8:return t.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return e(re,void 0,void 0,(function(){var e,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,8,,9]),[4,D.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(e=t.sent()).isSuccess&&e.data?(n=e.data,r=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===W.PAYMENT&&(null==r?void 0:r.length)&&r.length>=6&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:t.sent(),t.label=3;case 3:return n?(this.checkout,this.checkout=new k(i(i({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==W.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:t.sent(),t.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:t.sent(),this.isCampaignOfferLoaded=!0,t.label=7;case 7:return[3,9];case 8:return t.sent(),[3,9];case 9:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Z.getAvailableShippingZones({salesChannelId:B.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(re.selectedShippingAddressId=e,"-1"===e)re.checkout.shippingAddress=new Y,re.checkout.shippingAddress.countrySettings=re.countrySettings;else{var i=null===(t=re.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(re.checkout.shippingAddress=new Y(i),re.checkout.shippingAddress.countrySettings=re.countrySettings)}re.checkout.shippingAddress&&(re.checkout.shippingAddress.checkoutSettings=re.checkoutSettings,re.checkout.shippingAddress.shippingZones=re.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(re.selectedBillingAddressId=e,"-1"===e)re.checkout.billingAddress=new Y,re.checkout.billingAddress.countrySettings=re.countrySettings;else{var i=null===(t=re.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(re.checkout.billingAddress=new Y(i),re.checkout.billingAddress.countrySettings=re.countrySettings)}re.checkout.billingAddress&&(re.checkout.billingAddress.checkoutSettings=re.checkoutSettings,re.checkout.billingAddress.shippingZones=re.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){re.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){var t;if(re.cardData&&(!(e.length>re.cardData.cardNumber.length)||ee(e))){var i=(re.cardData.cardNumber||"").split(" ").join(""),s=e.split(" ").join("");s.length>16||(i.length<6&&s.length>=6&&!re.installmentInfo?re.getRetrieveInstallmentInfo(s):s.length<6&&i.length>s.length&&(re.cardData.installmentCount=1,re.installmentInfo=void 0),(null===(t=re.installmentInfo)||void 0===t?void 0:t.cardAssociation)===_.AMERICAN_EXPRESS?re.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(s).join(" "):re.cardData.cardNumber=$(s,4).join(" "))}},this.getRetrieveInstallmentInfo=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:i.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return t.sent(),(null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){re.cardData&&(re.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(re.cardData&&(!(e.length>re.cardData.expirationDate.length)||ee(e))){if(0===(null===(t=re.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(re.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(re.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(re.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(re.cardData.expirationDate=$(d,2).join(" / "))}},this.onCvcChange=function(e){if(re.cardData&&(!(e.length>re.cardData.cvv.length)||ee(e))){if(re.installmentInfo){if(re.installmentInfo.cardAssociation===_.AMERICAN_EXPRESS&&e.length>4)return;if(re.installmentInfo.cardAssociation!==_.AMERICAN_EXPRESS&&e.length>3)return}else if(e.length>3)return;re.cardData.cvv=e}},this.saveAddress=function(s){return e(re,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new P(i(i({},e),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:t.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){re.router.push("/cart")},this.onBackToShoppingClick=function(){re.router.push("/")},this.onGoToLoginClick=function(){re.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(W.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(W.SHIPPING):this.changeStep(W.PAYMENT),[3,7]);case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Q.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(W.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Q.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(W.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Q.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!re.canPerformPayment||(re.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){re.error={type:e,data:t}},this.onCompletePaymentClick=function(){return e(re,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:Q.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(re,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:Q.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(re,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,h,p,f,g,v,y,S,k,b,P;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(c=this.mpVM.selectedCard)||void 0===c?void 0:c.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(d=this.cardData)||void 0===d?void 0:d.installmentCount)?[2]:[4,T.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(h=this.mpVM.selectedCard)||void 0===h?void 0:h.Name},paymentGatewayId:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.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:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)},metadata:{_fbp:H("_fbp"),_fbc:H("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway||this.isFree?[4,T.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.isFree?"9d41af41-4793-4879-a19c-e9a66c929726":null===(v=this.checkout.selectedPaymentGateway)||void 0===v?void 0:v.id,paymentMethodDetail:this.isFree||i?void 0:(null===(y=this.checkout.selectedPaymentGateway)||void 0===y?void 0:y.paymentMethodType)===u.CREDIT_CARD&&(null===(S=this.checkout.selectedPaymentGateway)||void 0===S?void 0:S.type)===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:{_fbp:H("_fbp"),_fbc:H("_fbc")}}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(k=null==s?void 0:s.data)||void 0===k?void 0:k.transactionStatus,o=r&&[m.SUCCESS,m.AUTHORIZED].includes(r),a=r===m.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(b=null==s?void 0:s.data)||void 0===b?void 0:b.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!a||!(null===(P=null==s?void 0:s.data)||void 0===P?void 0:P.returnSlug))throw{data:s.firstErrorMessage,type:Q.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(re,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return q.refreshJourneyId(),this.changeStep(W.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){re.changeStep(W.INFO)},this.onBackToShippingClick=function(){re.changeStep(W.SHIPPING)},this.setCustomerConsentGranted=function(e){re.checkout.customer&&(re.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){re.useDifferentAddress=e,re.useDifferentAddress?(localStorage.setItem("sAddr","1"),re.checkout.billingAddress=re.checkout.billingAddress||new Y,re.checkout.billingAddress.countrySettings=re.countrySettings):(localStorage.removeItem("sAddr"),re.checkout.billingAddress=new Y(i({},re.checkout.shippingAddress)))},this.setShouldSaveAddress=function(e){re.shouldSaveAddress=e},this.setAddressTitle=function(e){re.addressTitle=e},this.reInitPaymentMethod=function(){return e(re,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,T.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.stripeResponse=e.data,this.stripeError=null):this.stripeError={type:Q.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,T.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data?(this.klarnaResponse=e.data,this.klarnaError=null):this.klarnaError={type:Q.API_ERROR,data:e.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,T.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,T.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(re,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?(e=this.paymentGateways[i],s=!0,this.step!==W.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==e.code?[3,2]:[4,this.updatePaymentGateway(e)]):[2];case 1:s=t.sent(),t.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(e)];case 4:return s=t.sent(),[3,7];case 5:return"CUSTOM"!==e.code?[3,7]:[4,this.updatePaymentGateway(e)];case 6:s=t.sent(),t.label=7;case 7:return s?"STRIPE"!==e.code&&"STRIPE_EU"!==e.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(e)]:[2];case 8:t.sent(),t.label=9;case 9:return"KLARNA"!==e.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(e)];case 10:t.sent(),t.label=11;case 11:return"ADYEN_PLATFORM"!==e.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(e)];case 12:t.sent(),t.label=13;case 13:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(e)];case 14:t.sent(),t.label=15;case 15:return this.checkout.selectedPaymentGateway=e,this.step!==W.SUCCESS&&(e.paymentMethodType===u.CREDIT_CARD&&e.type===l.INTERNAL&&(this.cardData=new N,e.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0),[2]}}))}))},this.updatePaymentGateway=function(s){return e(re,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return this.isPaymentMethodVisible=!1,[4,D.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id})];case 1:return(e=t.sent()).isSuccess?((n=e.data)&&(r=this.checkout,this.checkout=new k(i(i({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){re.cardData&&(re.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(re,void 0,void 0,(function(){return t(this,(function(e){return X||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(re,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){re.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(re,void 0,void 0,(function(){var r,o,a=this;return t(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===f.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return e(a,void 0,void 0,(function(){var e,n,r,o,a,c,d,u,l;return t(this,(function(t){switch(t.label){case 0:return(e=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})))?(n=[e.productId],[4,x.searchProducts({input:{productIdList:n,priceListId:B.getPriceListId(),salesChannelId:B.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)?(o=r.data.data[0],(a=o.variants.filter((function(t){return t.hasStock&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var s=!1;return e.discountType===y.AMOUNT&&(s=!0),new E(i(i({},t),{prices:t.prices.map((function(t){var n=t.finalPrice,r=t.finalPrice-(s?e.discountAmount:t.finalPrice*e.discountAmount/100);return e.applicablePrice===S.SELL_PRICE&&(n=t.sellPrice,r=t.sellPrice-(s?e.discountAmount:t.sellPrice*e.discountAmount/100)),new w(i(i({},t),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new O(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:e,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return e(re,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===W.SUCCESS?g.POST_CHECKOUT:g.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),console.log("this.campaignOffers",this.campaignOffers),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(re,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,D.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===W.SUCCESS?W.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(re,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,j.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return e(re,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==v.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,T.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(re,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,T.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=a,this.checkoutSettings=d,this.router=C,this.returnPolicy=I,this.privacyPolicy=z,this.termsOfService=J,this.imprint=te,this.shippingPolicy=ie,this.t=se,this.customizationProps=ne,this.mpVM=new G,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new R({currentLocale:B.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(z.prototype,"merchantSettings",{get:function(){return new I(B.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=F.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-(this.checkout.totalFinalPrice-this.giftCardTotalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"finalPrice",{get:function(){return this.step===W.SUCCESS?this.checkout.totalFinalPrice-this.giftCardTotalPrice:this.installmentPrice?this.installmentPrice:this.checkout.totalFinalPrice-this.giftCardTotalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===Q.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&(null===(i=this.error)||void 0===i?void 0:i.type)!==Q.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===a.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"store",{get:function(){return F.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==d.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===u.CREDIT_CARD&&i.type===l.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"customerAddresses",{get:function(){var e,t,s,n=this,r=null===(e=B.getCurrentRouting())||void 0===e?void 0:e.countryCodes;return null===(s=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(e){var t=new C(i({countrySettings:n.countrySettings},e));return t.checkoutSettings=n.checkoutSettings,t.shippingZones=n.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===a.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===a.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isEPayKolayEnabled",{get:function(){var e=B.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isPoweredByHidden",{get:function(){var e=B.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),z.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},z}();function $(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function ee(e){return e&&z.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(W||(W={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(Q||(Q={}));export{W as CheckoutStep,Q as ErrorType,J as default};
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i,__spreadArray as s}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as n}from"mobx";import r from"lodash/cloneDeep";import o from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasCartCreatedBy as d,IkasCouponCodeRequirement as l,IkasCorporateInvoiceRequirement as u,IkasOrderShippingMethod as h,IkasOrderStatus as p,IkasCustomerEmailSubscriptionStatus as m,IkasOrderPaymentStatus as f,IkasTransactionStatus as g,IkasCartCampaignOfferStatus as y,IkasCampaignOfferTargetPageType as v,IkasOrderLineItemStatus as S,IkasAmountType as b,IkasCampaignOfferProductApplicablePriceEnum as C}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as P}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as I}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as A}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as E}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as w}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as O}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as M}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as R}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as T,COUNTRY_FORMS_LOCALES as N,LocalizedAddressConfig as L}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"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import _ from"./components/credit-card-form/model.js";import j from"./components/secure-card-form/model.js";import G from"./components/secure-card-form/masterpass-bridge-model.js";import D from"../../store/customer/api.js";import x from"../../store/checkout/index.js";import F from"../../store/cart/api.js";import V,{MFS_ELEMENT_ID as U,MFS_SCRIPT_URL as B}from"./modelMasterPass.js";import{APIResponse as Y}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import H from'./../../ext/@ikas/fe-api-client/build/config/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import K from"../../store/product/index.js";import{MILES_SMILES_CURRENCY_CODE as Z,TransactionCardAssociationEnum as W,MILES_SMILES_CARD_GATEWAY_CODE as z,SaveCartInput as q,CheckStocksLineInput as Q,getLoyaltyCustomerInfo as X,listSpendingMethodsByCartId as $,LoyaltyProgramPointEarningTypeEnum as J,listEarningMethods as ee,getMilesSmilesDetails as te,CampaignOfferTargetPageTypeEnum as ie}from"@ikas/storefront-api";import{IkasBaseStore as se}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as ne}from"@ikas/storefront-config";import{Analytics as re}from"../../analytics/analytics.js";import{isPaymentScriptPolicyEnabled as oe}from"../../analytics/head/index.js";import ae from"../../models/data/order/address/ikas-localized-order-address.js";import ce from"../../store/location/index.js";import{isEqual as de,getCookieValue as le,getOpenAiAttributionMetadata as ue}from"../../utils/helper.js";import{readMilesSmilesBindResult as he}from"../../utils/miles-smiles.js";import pe from"../../analytics/ikasV3.js";import{suggestEmailCorrection as me}from"@ikas/storefront-model-functions";var fe,ge,ye,ve=/^\d+$/,Se=/^3[47]/,be="undefined"==typeof localStorage,Ce=((fe={})[Z]=.35,fe),Pe=["UNAUTHORIZED","AUTHORIZATION_REQUIRED","MILES_SMILES_LOGIN_REQUIRED","MILES_SMILES_MEMBER_MISMATCH","EXTERNAL_ACCOUNT_MEMBER_MISMATCH"],ke=["MILES_SMILES_NOT_ENABLED","MILES_SMILES_GATEWAY_NOT_SUPPORTED","MILES_SMILES_CURRENCY_NOT_SUPPORTED","MILES_SMILES_RATE_NOT_CONFIGURED","MILES_SMILES_OAUTH_NOT_CONFIGURED","PAYMENT_GATEWAY_NOT_FOUND"],Ie=function(e){return!!e&&(e.startsWith("MILES_")||e.startsWith("EXTERNAL_ACCOUNT_")||"INVALID_MILES"===e)},Ae=function(){function fe(d,u,p,A,E,Z,W,z,me,fe){var ve=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isCheckoutLoadFailed=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=ge.INFO,this.customizationProps=null,this.cardData=null,this.storeCard=!1,this.savedCards=[],this.savedCardsGatewayId=null,this.selectedSavedCardId=null,this.savedCardCvv="",this.secureCard=new j({onBinChange:function(e){return ve.onCardBinChange(e)},onMasterPassConsentChange:function(e){return ve.mpVM.onSaveCardToMasterPassCheckedChange(e)}}),this.masterPassBridge=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.isMilesSmilesTermsAccepted=!1,this.milesToRedeem=0,this.isMilesSmilesLoginRequired=!1,this.isMilesSmilesUnavailable=!1,this.isMilesSmilesBindLoading=!1,this.milesSmilesDetails=null,this.milesSmilesError=null,this.milesSmilesBindLanding=null,this.isMiniCartOpenOnLoad=!1,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.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.hepsipayFrameInitResponse=null,this.iyzicoResponse=null,this.isIyzicoLoading=!1,this.showIyzicoContainer=!1,this.tkPayResponse=null,this.isTkPayLoading=!1,this.showTkPayContainer=!1,this.tkPayFormMiles=null,this.isTkPayPaymentCompleted=!1,this.stripeExpressCheckoutSessionResponse=null,this.isStripeExpressCheckoutSessionVisible=!1,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.storeCreditBalance=null,this.loyaltyCustomerInfo=null,this.loyaltySpendingMethods=null,this.loyaltySpendingMethodsAll=null,this.loyaltyEarningMethod=null,this.isLoyaltyPointsVisible=!1,this.showTestModal=!1,this.openEditOrderTransaction=null,this.previousRawValue="",this.previousBin=null,this.init=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(this.redirectTopIfInsideIframe())return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.waitForCountrySettingsOrFail()];case 2:return t.sent(),[3,4];case 3:return t.sent(),this.isCheckoutLoadFailed=!0,[2];case 4:return[4,se.getInstance().customerStore.waitUntilInitialized()];case 5:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,7];case 6:t.sent(),t.label=7;case 7:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 8:return t.sent(),[2]}}))}))},this.redirectTopIfInsideIframe=function(){if(be||ne.getIsEditor())return!1;try{return!(window.self===window.top||!window.top)&&(window.top.location.origin===window.location.origin&&(window.top.location.replace(window.location.href),!0))}catch(e){return!1}},this.waitForCountrySettingsOrFail=function(){return new Promise((function(e,s){var n=!1,r=function(){n=!0,clearInterval(o),clearTimeout(a)},o=setInterval((function(){ve.countrySettings.initialized&&(r(),e())}),100),a=setTimeout((function(){n||(r(),s(new Error("timeout")))}),1e4);t(ve,void 0,void 0,(function(){var e,t,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=ne.getCurrentLocale(),N.includes(e)||(e="en"),t="".concat(L.getCDNUrl(),"sf/static/location/settings.json"),o="https://eu.myikas.com/sf/static/location/".concat(e,".json"),[4,Promise.all([fetch(t),fetch(o)])];case 1:return a=i.sent(),n?[2]:(a.some((function(e){return!e.ok}))&&(r(),s(new Error("fetch failed"))),[3,3]);case 2:return c=i.sent(),n?[2]:(r(),s(c),[3,3]);case 3:return[2]}}))}))}))},this.initStep=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,a,c,d;return i(this,(function(i){switch(i.label){case 0:if(ne.getIsEditor())return this.step=ge.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),s=t.get("step"),n=t.get("failed"),r=t.get("error"),this.isMiniCartOpenOnLoad="open"===t.get("miniCart"),this.milesSmilesBindLanding=he(),s){if(this.step=s,this.step===ge.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(ge.INFO)];if(this.step!==ge.PAYMENT||this.canProceedToPayment){if(this.step===ge.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(ge.INFO)];if(![ge.INFO,ge.SUCCESS,ge.SHIPPING,ge.PAYMENT].includes(this.step))return[2,this.changeStep(ge.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(ge.INFO)]:[2,this.changeStep(ge.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new k(e(e({},this.checkoutSettings),{couponCodeRequirement:l.DEFAULT}))),this.step!==ge.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return i.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:i.sent(),this.checkShippingCountries(),i.label=4;case 4:return[4,this.getStockLocations()];case 5:return i.sent(),[4,this.getAvailableStockLocations()];case 6:i.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),i.label=7;case 7:if(this.step===ge.SHIPPING&&1===(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)&&!this.checkoutSettings.isGiftPackageEnabled){if(oe())return this.changeStep(ge.PAYMENT),[2];this.step=ge.PAYMENT,o=this.getRoutingPath(),this.router.replace("".concat(o,"/checkout?id=").concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})}return this.step!==ge.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==ge.SUCCESS||this.checkout.orderPaymentStatus!==f.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ye.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==ge.PAYMENT&&this.step!==ge.SUCCESS?[3,15]:[4,this.listPaymentGateways()];case 10:return i.sent(),this.checkout.hasCustomer?[4,this.getStoreCreditBalance()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,14];case 13:i.sent(),i.label=14;case 14:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:ye.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===ge.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(ge.SUCCESS)]:[3,16];case 16:return[4,this.initialStockCheck()];case 17:i.sent(),i.label=18;case 18:return this.checkout.hasCustomer?[4,this.getLoyaltyCustomerInfo()]:[3,22];case 19:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 20:return i.sent(),[4,this.listEarningMethods()];case 21:i.sent(),i.label=22;case 22:return[3,25];case 23:return[4,this.getSuccessTransaction()];case 24:i.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),i.label=25;case 25:return n&&(this.error={type:ye.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,re.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,D.listOrderTransactionsWithPrices({input:{orderId:this.checkout.id}})];case 1:return(e=t.sent()).isSuccess&&e.data&&e.data.chargedAmount&&(this.openEditOrderTransaction=e.data),[2]}}))}))},this.getSuccessTransaction=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,D.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=i.sent(),this.successTransactions=e.isSuccess&&(null===(t=e.data)||void 0===t?void 0:t.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.isCardStorageGateway=function(e){var t,i;return!!e&&"PAYTR"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"card_storage_enabled"===e.label})))||void 0===i?void 0:i.value)&&!!ve.store.customerStore.customer},this.saveCart=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,l,u,h,p,f,g,y,v;return i(this,(function(i){switch(i.label){case 0:return e=new q(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=i.sent(),i.label=2;case 2:return this.step!==ge.INFO&&this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===ge.PAYMENT||(e.billingAddress=null),e.billingAddress&&(this.isShowBillingAddressOnShippingStep&&this.useDifferentAddress||this.useDifferentAddress&&!this.isShowBillingAddressOnShippingStep&&this.checkoutSettings.showCompanyInfoInShippingAddress)&&(e.billingAddress.company=(null===(n=e.shippingAddress)||void 0===n?void 0:n.company)||null,e.billingAddress.taxNumber=(null===(r=e.shippingAddress)||void 0===r?void 0:r.taxNumber)||null,e.billingAddress.taxOffice=(null===(o=e.shippingAddress)||void 0===o?void 0:o.taxOffice)||null)),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),null===(null===(c=null===(a=e.shippingAddress)||void 0===a?void 0:a.city)||void 0===c?void 0:c.code)&&""===(null===(l=null===(d=e.shippingAddress)||void 0===d?void 0:d.city)||void 0===l?void 0:l.name)&&(e.shippingAddress.city.name="-"),null===(null===(h=null===(u=e.billingAddress)||void 0===u?void 0:u.city)||void 0===h?void 0:h.code)&&""===(null===(f=null===(p=e.billingAddress)||void 0===p?void 0:p.city)||void 0===f?void 0:f.name)&&(e.billingAddress.city.name="-"),[4,F.saveCart({input:e})];case 3:if((null==(t=i.sent())?void 0:t.graphQLErrors)&&t.graphQLErrors.length)throw s=t.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(g=s.extensions)||void 0===g?void 0:g.code)?{type:ye.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(y=s.extensions)||void 0===y?void 0:y.code)?{type:ye.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(v=s.extensions)||void 0===v?void 0:v.code)?{type:ye.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:ye.API_ERROR,data:t.firstErrorMessage};return[2,t.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(ve,void 0,void 0,(function(){var t,s,n=this;return i(this,(function(i){return t=e,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,l,u,p,m,f;return i(this,(function(i){switch(i.label){case 0:return this.isManualOrder||this.isOpenEditOrderWithTransaction?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===h.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(p=ne.getStockLocationIds())||void 0===p?void 0:p.length)?ne.getStockLocationIds():null,[4,x.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(t=i.sent()).isSuccess)throw s="UPSELL"===this.checkout.createdBy,n=s?this.t("checkout-page:upsellTimeErrorMessage"):t.firstErrorMessage,{type:ye.API_ERROR,data:n};if(null==(r=null===(f=null===(m=t.data)||void 0===m?void 0:m.lines)||void 0===f?void 0:f.filter((function(e){return!e.isAvailable})))?void 0:r.length){for(o=[],a=function(e){var t=c.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&o.push({item:t,stockCount:e.stockCount})},c=this,d=0,l=r;d<l.length;d++)u=l[d],a(u);throw{type:ye.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){ve.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:t=0,s=e,i.label=1;case 1:return t<s.length?(n=s[t],[4,se.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getAvailableShippingCountries({salesChannelId:ne.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?[4,x.listStockLocation({id:{in:ne.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=i.sent()).isSuccess||!(null===(t=e.data)||void 0===t?void 0:t.length))return this.error={type:ye.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,x.getAvailableStockLocations({lines:e.map((function(e){return new Q(e)})),stockLocationIdList:ne.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ye.API_ERROR},[2];s=ne.getCurrentRouting(),this.availableStockLocations=(t.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),i.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ve.shippingCountryIds)||void 0===e?void 0:e.length)||(ve.error={type:ye.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;ve.deliveryMethod!==e&&("address"===e&&(ve.checkout.stockLocationId=null,(null===(t=ve.customerAddresses)||void 0===t?void 0:t.length)?ve.onSelectedShippingAddressIdChange(ve.customerAddresses[0].id||"-1"):(ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)),ve.deliveryMethod=e,ve.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,X({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,$({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltySpendingMethods=e.data.filter((function(e){return e.isAvailable})),this.loyaltySpendingMethodsAll=e.data),[2]}}))}))},this.listEarningMethods=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,ee()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===J.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return this.resetMilesSmilesIfNothingToPay(),e="local"===process.env.NEXT_PUBLIC_ENV,t=ne.getPaymentGateways().map((function(e){return e.id})),[4,x.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:ne.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=i.sent()).isSuccess?(null===(p=s.data)||void 0===p?void 0:p.length)||this.isFree?(this.error=void 0,n=null===(m=s.data)||void 0===m?void 0:m.some((function(e){return"IKAS_WALLET"===e.code})),this.isMinTransactionError=n&&this.finalPrice<200&&!this.isDigitalOnly,this.isMinTransactionError?[2]:(r=s.data||[],this.step===ge.PAYMENT&&(r=r.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(y.checkout.currencyCode)})),(a=null===(f=this.checkout.shippingAddress)||void 0===f?void 0:f.country)&&a.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")}))),c=null===(g=this.checkout.billingAddress)||void 0===g?void 0:g.country,!a&&c&&c.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(c.iso2||"")})))),d=[],o(ne.getPaymentGateways(),"order").forEach((function(e){var t=null==r?void 0:r.find((function(t){return t.id===e.id}));t&&d.push(t)})),this.paymentGateways=e?r:d,l=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.step===ge.SUCCESS?[3,4]:this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=y.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==l?l:0),[3,4]))):(this.error={type:ye.NO_SHIPPING_ERROR},[2]):(this.error={type:ye.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==ge.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===ge.PAYMENT&&((u=r.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=u),u&&!this.masterPassBridge&&((h=document.createElement("script")).id=U,h.src=B,h.onload=function(){y.mpVM.checkMasterPass({checkout:y.checkout,store:se.getInstance()})},document.head.appendChild(h))),this.isMilesSmilesActive()?[4,this.loadMilesSmilesDetails()]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},this.resetMilesSmilesIfNothingToPay=function(){ve.isMilesSmilesNothingToPay&&(ve.useMilesSmiles=!1,ve.milesToRedeem=0,ve.isMilesSmilesTermsAccepted=!1)},this.loadMilesSmilesDetails=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return this.isMilesSmilesActive()?(e=this.milesSmilesBindLanding,this.milesSmilesBindLanding=null,"fail"===(null==e?void 0:e.status)&&(this.milesSmilesError=e.errorCode||"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"),this.store.customerStore.customer?[4,te()]:(this.isMilesSmilesLoginRequired=!0,this.milesSmilesDetails=null,[2])):[2];case 1:return(t=i.sent()).isSuccess&&t.data?(this.milesSmilesDetails=t.data,this.isMilesSmilesLoginRequired=!1,"success"!==(null==e?void 0:e.status)||this.useMilesSmiles||this.isMilesSmilesNothingToPay?[3,3]:[4,this.setUseMilesSmiles(!0)]):[3,4];case 2:i.sent(),i.label=3;case 3:return[2];case 4:return s=t.errorCodes,Pe.some((function(e){return s.includes(e)}))?(this.isMilesSmilesLoginRequired=!0,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesDetails=null,[2]):ke.some((function(e){return s.includes(e)}))?(this.isMilesSmilesUnavailable=!0,this.milesSmilesDetails=null,this.useMilesSmiles=!1,this.milesToRedeem=0,[2]):(this.milesSmilesDetails=null,this.milesSmilesError=s[0]||"MILES_MEMBER_DETAILS_FAILED",[2])}}))}))},this.getMilesSmilesBindRedirect=function(){var e=ve.getRoutingPath();return"".concat(e,"/checkout?id=").concat(ve.checkout.id,"&step=").concat(ge.PAYMENT)},this.getMilesSmilesLoginRedirectUrl=function(){var e=ve.getRoutingPath();return"".concat(e,"/account/login?redirect=").concat(encodeURIComponent(ve.getMilesSmilesBindRedirect()))},this.startMilesSmilesBind=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.milesSmilesError=null,this.store.customerStore.customer?(this.isMilesSmilesBindLoading=!0,[4,this.store.customerStore.startMilesSmilesBind(this.getMilesSmilesBindRedirect())]):(window.location.href=this.getMilesSmilesLoginRedirectUrl(),[2]);case 1:return(e=t.sent()).isSuccess||(this.isMilesSmilesBindLoading=!1,this.milesSmilesError=e.errorCode||"UNEXPECTED_ERROR"),[2]}}))}))},this.setUseMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.useMilesSmiles=e,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesError=null,e?(t=this.milesSmilesPaymentGateway,-1===(s=t?this.paymentGateways.findIndex((function(e){return e.id===t.id})):-1)||this.selectedPaymentGatewayIndex===s?[3,2]:[4,this.setPaymentGateway(s)]):[3,2];case 1:i.sent(),this.mpVM.selectedCard=void 0,i.label=2;case 2:return this.milesToRedeem=0,[4,this.onMilesSmilesSelectionChange()];case 3:return i.sent(),[2]}}))}))},this.setMilesSmilesTermsAccepted=function(e){ve.isMilesSmilesTermsAccepted=e},this.setMilesToRedeem=function(e){ve.milesToRedeem=Math.max(0,Math.floor(e||0))},this.clampMilesToRedeem=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this.milesSmilesMaxRedeemable,this.milesToRedeem>e&&(this.milesToRedeem=e),[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.selectMilesSmilesChip=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e>this.milesSmilesMaxRedeemable?[2]:(this.milesToRedeem=e,[4,this.onMilesSmilesSelectionChange()]);case 1:return t.sent(),[2]}}))}))},this.setUseAllMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.milesToRedeem=e?this.milesSmilesMaxRedeemable:0,[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.onMilesSmilesSelectionChange=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return this.isTkPay&&this.checkout.selectedPaymentGateway?this.isTkPayPaymentCompleted?[2]:(e=(null===(t=this.milesSmilesInput)||void 0===t?void 0:t.miles)||0,this.tkPayResponse&&this.tkPayFormMiles===e?[2]:(this.tkPayResponse=null,[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)])):[2];case 1:return i.sent(),[2]}}))}))},this.handleMilesSmilesSaleError=function(e){var t,i;return ve.handleMilesSmilesErrorCodes(s(s([],e.errorCodes||[],!0),[null===(i=null===(t=e.data)||void 0===t?void 0:t.error)||void 0===i?void 0:i.code],!1))},this.handleMilesSmilesErrorCodes=function(e){var t=e.filter(Ie);if(!t.length)return null;var i=t[0];return Pe.includes(i)?(ve.isMilesSmilesLoginRequired=!0,ve.isMilesSmilesTermsAccepted=!1,ve.milesSmilesDetails=null,ve.useMilesSmiles=!1,ve.milesToRedeem=0):ke.includes(i)&&(ve.isMilesSmilesUnavailable=!0,ve.useMilesSmiles=!1,ve.milesToRedeem=0),ve.milesSmilesError=i,ve.getMilesSmilesErrorMessage(i)},this.getMilesSmilesErrorMessage=function(e){var t="checkout-page:milesSmilesErrors.".concat(e),i=e?ve.t(t):"";return i&&i!==t?i:ve.t("checkout-page:milesSmilesErrors.default")},this.retrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,x.retrieveInstallmentInfo(e)];case 1:return t=i.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;ve.store.customerStore.customer?(null===(t=ve.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=ve.checkoutSettings,e.shippingZones=ve.shippingZones})),ve.checkout.customer=new w(e(e({},ve.store.customerStore.customer),{notificationsAccepted:ve.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED}))):ve.checkout.customer=new w(ve.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones,ve.checkout.billingAddress.countrySettings=ve.countrySettings,ve.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ve.isDigitalOnly)if(ve.isInStoreDelivery)ve.setCheckoutShippingAddressSettings();else if(ve.checkout.shippingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedShippingAddressIdChange(e.id||"-1"),void ve.setCheckoutShippingAddressSettings()}ve.checkout.shippingAddress=new ae(r(ve.checkout.shippingAddress)||{}),ve.setCheckoutShippingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ve.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ve.useDifferentAddress=!!localStorage.getItem("sAddr"),ve.checkout.billingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedBillingAddressIdChange(e.id||"-1"),void ve.setCheckoutBillingAddressSettings()}ve.checkout.billingAddress=new ae(r(ve.checkout.billingAddress)||{}),ve.setCheckoutBillingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())}else ve.onSelectedBillingAddressIdChange("-1"),ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=e.shippingSettingsId,this.checkout.shippingZoneRateId=e.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=i.sent())&&(this.checkout=new P(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(ve,void 0,void 0,(function(){var t,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(o=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT||this.checkout.totalFinalPrice===o.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,s?re.addCouponCode(n):re.removeCouponCode(n),i.label=7;case 7:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,i.label=7;case 7:return[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeLoyaltyPointsFromCart=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,F.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,9];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,9];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:return i.sent(),this.isCampaignOfferLoaded=!0,re.removeLoyaltyPoints(n),[4,this.getLoyaltyCustomerInfo()];case 7:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return i.sent(),[3,11];case 11:return[2]}}))}))},this.getAvailableShippingZones=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ce.getAvailableShippingZones({salesChannelId:ne.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(ve.selectedShippingAddressId=e,"-1"===e)ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.shippingAddress=new ae(i),ve.checkout.shippingAddress.countrySettings=ve.countrySettings)}ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ve.selectedBillingAddressId=e,"-1"===e)ve.checkout.billingAddress=new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.billingAddress=new ae(i),ve.checkout.billingAddress.countrySettings=ve.countrySettings)}ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ve.isTermsAndConditionsChecked=e,ve.isIyzico&&(ve.showIyzicoContainer=e),ve.isTkPay&&(ve.showTkPayContainer=e,ve.saveCart())},this.onCardNumberChange=function(e){if(ve.cardData){var t=(e||"").replace(/\D/g,""),i=ve.previousRawValue,s=t.slice(0,8),n=ve.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(ve.getRetrieveInstallmentInfo(t),ve.previousBin=s),t.length<8&&i.length>=8&&(ve.cardData.installmentCount=1,ve.installmentInfo=void 0,ve.previousBin=null),ve.isAmexCard(t)?ve.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(t).join(" "):ve.cardData.cardNumber=Ee(t,4).join(" "),ve.previousRawValue=t}}},this.onCardBinChange=function(e){if(ve.cardData&&ve.checkout.selectedPaymentGateway)return e?void ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,binNumber:e,paymentGatewayId:ve.checkout.selectedPaymentGateway.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}}):(ve.cardData.installmentCount=1,void(ve.installmentInfo=void 0))},this.getRetrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:e.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return i.sent(),(null===(t=this.cardData)||void 0===t?void 0:t.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){ve.cardData&&(ve.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ve.cardData&&(!(e.length>ve.cardData.expirationDate.length)||we(e))){if(0===(null===(t=ve.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(ve.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(ve.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(ve.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ve.cardData.expirationDate=Ee(d,2).join(" / "))}},this.onCvcChange=function(e){if(ve.cardData&&(!(e.length>ve.cardData.cvv.length)||we(e))){if(ve.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;ve.cardData.cvv=e}},this.saveAddress=function(s){return t(ve,void 0,void 0,(function(){var t,n,o,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,n=null===(p=this.customerAddresses)||void 0===p?void 0:p.find((function(e){return e.id===(null==t?void 0:t.id)})),n?[2]:(o=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(e){return e.id})),a=new I(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(c=r(this.store.customerStore.customer)).addresses||(c.addresses=[]),c.addresses.push(a),[4,this.store.customerStore.saveCustomer(c)])):[3,2];case 1:i.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(e){e.checkoutSettings=y.checkoutSettings,e.shippingZones=y.shippingZones})),d=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(e){return e.id})),l=null==d?void 0:d.filter((function(e){return!(null==o?void 0:o.includes(e))})),u=(null==l?void 0:l.length)?l[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),i.label=2;case 2:return[3,4];case 3:return h=i.sent(),console.error(h),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=ne.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=ve.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(ve.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isShowBillingAddressOnShippingStep&&!this.useDifferentAddress&&("address"===this.deliveryMethod&&this.checkout.shippingAddress?this.checkout.billingAddress=new ae(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new ae(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,10,,11]),this.isStepLoading=!0,"address"!==this.deliveryMethod||this.isShowBillingAddressOnShippingStep?[3,5]:[4,this.saveAddress("shipping")];case 4:t.sent(),t.label=5;case 5:return this.isShowBillingAddressOnShippingStep?[4,this.saveAddress("billing")]:[3,7];case 6:t.sent(),t.label=7;case 7:return[4,this.checkStocks()];case 8:return t.sent(),[4,this.saveCart()];case 9:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(ge.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(ge.SHIPPING):this.changeStep(ge.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,6,,7]),this.isStepLoading=!0,[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.changeStep(ge.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(ge.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ve.canPerformPayment||(ve.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){ve.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return!this.canPerformPayment||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]);case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return this.isFree||!this.isIyzico?[3,4]:[4,this.saveCart()];case 3:return i.sent(),[2];case 4:if(this.isFree||!this.isHepsiPay)return[3,11];i.label=5;case 5:return i.trys.push([5,9,,10]),window.HepsipaySdk&&(null===(o=this.hepsipayFrameInitResponse)||void 0===o?void 0:o.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,7];case 6:return i.sent(),window.HepsipaySdk.initPayment(),[3,8];case 7:console.error("HepsipaySdk is not available"),i.label=8;case 8:return[3,10];case 9:return i.sent(),this.isStepLoading=!1,[2];case 10:return[2];case 11:return i.trys.push([11,17,,18]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 12:return i.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,14];case 13:i.sent(),i.label=14;case 14:return[4,this.saveCart()];case 15:return e=i.sent(),this.checkout.shippingMethod===h.SHIPMENT&&(t=null!==(a=null==e?void 0:e.availableShippingMethods)&&void 0!==a?a:[],s=null!==(c=this.checkout.availableShippingMethods)&&void 0!==c?c:[],!de(t,s))?(this.changeStep(ge.SHIPPING),[2]):!this.isFree&&this.isCustomFlowStripe?((n=document.querySelector("#stripe-form-btn"))&&n.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 16:return i.sent(),[3,18];case 17:return void 0!==typeof(r=i.sent()).type?this.error=r:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:if(this.isFree||!this.isHepsiPay)return[3,9];i.label=3;case 3:return i.trys.push([3,7,,8]),window.HepsipaySdk&&(null===(s=this.hepsipayFrameInitResponse)||void 0===s?void 0:s.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,5];case 4:return i.sent(),window.HepsipaySdk.initPayment(),[3,6];case 5:console.error("HepsipaySdk is not available"),i.label=6;case 6:return[3,8];case 7:return i.sent(),this.isStepLoading=!1,[2];case 8:return[2];case 9:return i.trys.push([9,13,,14]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 10:return i.sent(),[4,this.saveCart()];case 11:return i.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 12:return i.sent(),[3,14];case 13:return(t=i.sent()).type?this.error=t:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,d,l,u,h,p,m,f,y,v,S,b,C,P,k,I,A,E,w,O,M,R,T,N,L,_,j,G,D,F;return i(this,(function(i){switch(i.label){case 0:return s=this.mpVM.selectedCard,r=this.milesSmilesInput,!this.isFree&&s&&(null===(P=this.mpVM.selectedCard)||void 0===P?void 0:P.Name)?((o=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=o),void 0===(null===(k=this.cardData)||void 0===k?void 0:k.installmentCount)?[2]:[4,x.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(I=this.mpVM.selectedCard)||void 0===I?void 0:I.Name},paymentGatewayId:null===(A=this.mpVM.selectedCard)||void 0===A?void 0:A.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:!!(null===(E=this.cardData)||void 0===E?void 0:E.threeDSecure)},metadata:e({_fbp:le("_fbp"),_fbc:le("_fbc"),_ga:le("_ga")},ue()),milesSmiles:(null===(w=this.mpVM.selectedCard)||void 0===w?void 0:w.paymentGatewayId)===(null===(O=this.milesSmilesPaymentGateway)||void 0===O?void 0:O.id)?r:void 0}})]):[3,2];case 1:return n=i.sent(),[3,10];case 2:return this.checkout.selectedPaymentGateway||this.isFree?(d=this.isFree||s?void 0:this.selectedSavedCard,l=!this.isFree&&!s&&!d&&this.storeCard&&this.isCardStorageEnabled,u=!(this.isFree||s||d||(null===(M=this.checkout.selectedPaymentGateway)||void 0===M?void 0:M.paymentMethodType)!==a.CREDIT_CARD||(null===(R=this.checkout.selectedPaymentGateway)||void 0===R?void 0:R.type)!==c.INTERNAL||!this.cardData),h=e({cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:s&&t?{phoneNumber:t,savedCardName:null===(T=this.mpVM.selectedCard)||void 0===T?void 0:T.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":this.isMilesSmilesFullPayment?null===(N=this.milesSmilesPaymentGateway)||void 0===N?void 0:N.id:null===(L=this.checkout.selectedPaymentGateway)||void 0===L?void 0:L.id,metadata:e({_fbp:le("_fbp"),_fbc:le("_fbc"),_ga:le("_ga")},ue()),milesSmiles:r},l?{storeCard:!0}:{}),d?[4,this.createSaleTransactionWithSavedCard(h,d)]:[3,4]):[2];case 3:return p=i.sent(),[3,9];case 4:return u&&this.isSecureCardEnabled?[4,this.createSaleTransactionWithSecureCard(h)]:[3,6];case 5:return m=i.sent(),[3,8];case 6:return[4,x.createSaleTransactionWithCart({input:e(e({},h),{paymentMethodDetail:u?this.cardData.toInput():void 0})})];case 7:m=i.sent(),i.label=8;case 8:p=m,i.label=9;case 9:n=p,i.label=10;case 10:return f=null===(_=null==n?void 0:n.data)||void 0===_?void 0:_.transactionStatus,y=f&&[g.SUCCESS,g.AUTHORIZED].includes(f),v=f===g.PENDING,y?[4,this.getSuccessTransaction()]:[3,13];case 11:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(j=null==n?void 0:n.data)||void 0===j?void 0:j.orderId)||void 0)];case 12:return i.sent(),[3,14];case 13:if(!v||!(null===(G=null==n?void 0:n.data)||void 0===G?void 0:G.returnSlug))throw b=n.firstErrorMessage,"IKAS_WALLET_501"===(null===(F=null===(D=n.data)||void 0===D?void 0:D.error)||void 0===F?void 0:F.code)&&(b=this.t("checkout-page:errorContactStore")),(C=this.handleMilesSmilesSaleError(n))&&(b=C),{data:b,type:ye.UNKNOWN};S="local"===process.env.NEXT_PUBLIC_ENV?process.env.NEXT_PUBLIC_BASE_URL:window.location.origin+"/api/sf",window.location.href=S+n.data.returnSlug,i.label=14;case 14:return[2]}}))}))},this.createSaleTransactionWithSavedCard=function(s,n){return t(ve,void 0,void 0,(function(){var t,r,o,a;return i(this,(function(i){switch(i.label){case 0:return t=(null===(o=null===(r=this.installmentInfo)||void 0===r?void 0:r.installmentPrices)||void 0===o?void 0:o.length)&&(null===(a=this.cardData)||void 0===a?void 0:a.installmentCount)||1,[4,x.createSaleTransactionWithCart({input:e(e({},s),{savedCardDetail:e(e({savedCardId:n.id},n.requireCvv?{cvv:this.savedCardCvv}:{}),{installmentCount:t})})})];case 1:return[2,i.sent()]}}))}))},this.createSaleTransactionWithSecureCard=function(s){return t(ve,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.secureCard.submitSale(e(e({},s),{paymentMethodDetail:{installmentCount:this.cardData.installmentCount,threeDSecure:!!this.cardData.threeDSecure}}))];case 1:if(!(t=i.sent()).ok)throw"INVALID_CARD"===t.errorCode&&(this.isErrorsVisible=!0),{type:ye.UNKNOWN};return n=t.errors,r=new Y(t.data||void 0,n),null===(a=null===(o=H.ON_ERROR)||void 0===o?void 0:o.errorCodes)||void 0===a||a.forEach((function(e){var t=e.errorCode,i=e.callback;r.errorCodes.includes(t)&&i({graphQLErrors:n,operationName:"createSaleTransactionWithCart"})})),[2,r]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:i.sent(),i.label=2;case 2:return pe.refreshJourneyId(),this.changeStep(ge.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){ve.changeStep(ge.INFO)},this.onBackToShippingClick=function(){ve.changeStep(ge.SHIPPING)},this.setCustomerConsentGranted=function(e){ve.checkout.customer&&(ve.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;ve.useDifferentAddress=t,ve.useDifferentAddress?(localStorage.setItem("sAddr","1"),ve.checkout.billingAddress=ve.checkout.billingAddress||new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings):(localStorage.removeItem("sAddr"),ve.checkout.billingAddress=new ae(e({},ve.checkout.shippingAddress)),ve.store.customerStore.customer&&(null===(s=ve.customerAddresses)||void 0===s?void 0:s.length)&&i&&ve.isShowBillingAddressOnShippingStep&&ve.onSelectedBillingAddressIdChange(ve.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){ve.shouldSaveAddress=e},this.setAddressTitle=function(e){ve.addressTitle=e},this.reInitPaymentMethod=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,12];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return this.isHepsiPay?[4,this.hepsipayFrameInit(this.checkout.selectedPaymentGateway)]:[3,8];case 7:e.sent(),e.label=8;case 8:return this.isIyzico?[4,this.createIyzicoCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,10];case 9:e.sent(),e.label=10;case 10:return this.isTkPay?[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,12];case 11:e.sent(),e.label=12;case 12:return[2]}}))}))},this.createStripePaymentIntent=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.stripeResponse=t.data,this.stripeError=null):this.stripeError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.klarnaResponse=t.data,this.klarnaError=null):this.klarnaError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.adyenResponse=t.data),[2]}}))}))},this.getPayPalClientId=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.payPalClientIdResponse=t.data),[2]}}))}))},this.hepsipayFrameInit=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.hepsipayFrameInit({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.hepsipayFrameInitResponse=t.data),[2]}}))}))},this.createIyzicoCheckoutForm=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this.isIyzicoLoading=!0,[4,x.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:s.id||"",metadata:e({_fbp:le("_fbp"),_fbc:le("_fbc"),_ga:le("_ga")},ue())}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.iyzicoResponse=t.data,[2]):(((null===(n=t.errorCodes)||void 0===n?void 0:n.includes("ORDER_LINE_STOCK_NOT_AVAILABLE"))||(null===(r=t.graphQLErrors)||void 0===r?void 0:r.some((function(e){var t;return"ORDER_LINE_STOCK_NOT_AVAILABLE"===(null===(t=e.extensions)||void 0===t?void 0:t.code)}))))&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:iyzicoStockReservationError")}),[3,4]);case 2:return i.sent(),[3,4];case 3:return this.isIyzicoLoading=!1,[7];case 4:return[2]}}))}))},this.createTkPayCheckoutForm=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:if(this.isTkPayPaymentCompleted||this.step===ge.SUCCESS)return[2];if(this.isFree)return this.tkPayResponse=null,[2];t=!1,i.label=1;case 1:return i.trys.push([1,3,4,5]),this.isTkPayLoading=!0,s=this.milesSmilesInput,[4,x.createTkPayCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||"",milesSmiles:s}})];case 2:return n=i.sent(),this.isTkPayPaymentCompleted?[2]:(n.isSuccess&&n.data?(this.tkPayResponse=n.data,this.tkPayFormMiles=(null==s?void 0:s.miles)||0):s&&(t=!!this.handleMilesSmilesErrorCodes(n.errorCodes||[])),[3,5]);case 3:return i.sent(),[3,5];case 4:return this.isTkPayLoading=!1,[7];case 5:return!t||this.milesSmilesInput?[3,7]:[4,this.createTkPayCheckoutForm(e)];case 6:i.sent(),i.label=7;case 7:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.stripeExpressCheckoutSessionResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return[7];case 4:return[2]}}))}))},this.updateStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:if(!this.stripeExpressCheckoutSessionResponse)return[2,null];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,x.updateStripeExpressCheckoutSession({input:{cartId:this.checkout.id,sessionId:"",transactionId:"",address:e.address||null,shippingSettingsId:e.shippingSettingsId||null,shippingZoneRateId:e.shippingZoneRateId||null}})];case 2:return(t=i.sent()).isSuccess&&t.data?[2,t.data]:[2,null];case 3:return i.sent(),[2,null];case 4:return[2]}}))}))},this.setShowIyzicoContainer=function(e){ve.showIyzicoContainer=e},this.onTkPayPaymentSuccess=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.isTkPayPaymentCompleted?[2]:(this.isTkPayPaymentCompleted=!0,this.isStepLoading=!0,[4,e()]);case 1:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 2:return t.sent(),[2]}}))}))},this.setShowTkPayContainer=function(e){ve.showTkPayContainer=e},this.setPaymentGateway=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==ge.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==t.code?[3,2]:[4,this.updatePaymentGateway(t)]):[2];case 1:s=i.sent(),i.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(t)];case 4:return s=i.sent(),[3,7];case 5:return"CUSTOM"!==t.code?[3,7]:[4,this.updatePaymentGateway(t)];case 6:s=i.sent(),i.label=7;case 7:return s?"STRIPE"!==t.code&&"STRIPE_EU"!==t.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(t)]:[2];case 8:i.sent(),i.label=9;case 9:return"KLARNA"!==t.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(t)];case 10:i.sent(),i.label=11;case 11:return"ADYEN_PLATFORM"!==t.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(t)];case 12:i.sent(),i.label=13;case 13:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(t)];case 14:i.sent(),i.label=15;case 15:return"HEPSIPAY"!==t.code||this.hepsipayFrameInitResponse?[3,17]:[4,this.hepsipayFrameInit(t)];case 16:i.sent(),i.label=17;case 17:return"IYZICO"!==t.code||this.iyzicoResponse?[3,19]:[4,this.createIyzicoCheckoutForm(t)];case 18:i.sent(),i.label=19;case 19:return"TK_PAY"!==t.code||this.tkPayResponse||"true"!==(null===(r=null===(n=t.settings)||void 0===n?void 0:n.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===r?void 0:r.value)?[3,21]:[4,this.createTkPayCheckoutForm(t)];case 20:i.sent(),i.label=21;case 21:return this.isCardStorageGateway(t)?[4,this.listSavedCards(t)]:[3,23];case 22:i.sent(),i.label=23;case 23:return this.checkout.selectedPaymentGateway=t,this.step!==ge.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new _,this.secureCard.reset(),this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0,this.selectedSavedCardId=null,this.selectSavedCard((null===(o=this.visibleSavedCards[0])||void 0===o?void 0:o.id)||null)),[2]}}))}))},this.listSavedCards=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isSecureCardEnabled||this.savedCardsGatewayId===e.id?[2]:[4,x.listPaymentSavedCard({paymentGatewayId:e.id})];case 1:return t=i.sent(),this.savedCards=t.isSuccess&&t.data||[],this.savedCardsGatewayId=e.id||null,[2]}}))}))},this.selectSavedCard=function(e){var t=ve.selectedSavedCardId!==e;if(ve.selectedSavedCardId=e,t){ve.savedCardCvv="",ve.installmentInfo=void 0,ve.cardData=new _,ve.previousRawValue="",ve.previousBin=null;var i=ve.selectedSavedCard,s=ve.checkout.selectedPaymentGateway;i&&(null==s?void 0:s.id)&&ve.checkout.totalFinalPrice&&ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,savedCardId:i.id,paymentGatewayId:s.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}})}},this.onSavedCardCvvChange=function(e){var t=(e||"").replace(/\D/g,"");t.length>4||(ve.savedCardCvv=t)},this.setStoreCard=function(e){ve.storeCard=e},this.updatePaymentGateway=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,F.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:ie.CHECKOUT})];case 1:return(t=i.sent()).isSuccess?((n=t.data)&&(r=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){ve.cardData&&(ve.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return be||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){ve.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(ve,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===y.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return t(a,void 0,void 0,(function(){var t,n,r,o,a,c,d,l,u;return i(this,(function(i){switch(i.label){case 0:return t=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})),t?(n=[t.productId],[4,K.searchProducts({input:{productIdList:n,priceListId:ne.getPriceListId(),salesChannelId:ne.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.sent()).isSuccess&&(null===(u=null===(l=r.data)||void 0===l?void 0:l.data)||void 0===u?void 0:u.length)?(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(t.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(i){if(!t.discountAmount)return i;var s=!1;return t.discountType===b.AMOUNT&&(s=!0),new M(e(e({},i),{prices:i.prices.map((function(i){var n=i.finalPrice,r=i.finalPrice-(s?t.discountAmount:i.finalPrice*t.discountAmount/100);return t.applicablePrice===C.SELL_PRICE&&(n=i.sellPrice,r=i.sellPrice-(s?t.discountAmount:i.sellPrice*t.discountAmount/100)),new O(e(e({},i),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new R(e(e({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:t,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===ge.SUCCESS?v.POST_CHECKOUT:v.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return e.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,F.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===ge.SUCCESS?ge.PAYMENT:this.step,null===(s=t.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=t.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:i.sent(),this.isCampaignOfferLoaded=!0,i.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,D.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:e})]:[3,2]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==S.REFUNDED})).map((function(e){return e.variant.fileId})),e.length?[4,x.listProductFile({id:{in:e}})]:[3,2];case 1:(t=i.sent()).isSuccess&&(this.productFiles=t.data||[]),i.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=this.checkout.orderLineItems.find((function(t){return t.variant.id===e.variantId})),t?[4,x.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:t.id})]:[3,2];case 1:s=i.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(e.name),r.click(),r.remove()),i.label=2;case 2:return[3,4];case 3:return o=i.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=d,this.checkoutSettings=u,this.router=p,this.returnPolicy=A,this.privacyPolicy=E,this.termsOfService=Z,this.imprint=W,this.shippingPolicy=z,this.t=me,this.customizationProps=fe,this.mpVM=new V,j.isEnabled&&(this.masterPassBridge=new G(this.secureCard),this.mpVM.setBridge(this.masterPassBridge),this.secureCard.onReady((function(){ve.checkout.masterPassPaymentGateway&&ve.mpVM.checkMasterPass({checkout:ve.checkout,store:ve.store})}))),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new T({currentLocale:ne.getCurrentLocale()}),this.init(),n(this)}return fe.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===W.AMERICAN_EXPRESS||Se.test(i)},Object.defineProperty(fe.prototype,"merchantSettings",{get:function(){return new E(ne.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=se.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"installmentExtraPrice",{get:function(){var e;if(this.installmentPrice&&this.checkout.totalFinalPrice){var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice-t}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"finalPrice",{get:function(){var e;if(this.step===ge.SUCCESS)return this.checkout.totalFinalPrice-this.giftCardTotalPrice;var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice?this.installmentPrice:t},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ye.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasMasterPassGateway",{get:function(){return this.paymentGateways.some((function(e){return!!e.masterPassClientId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"secureCardGatewayId",{get:function(){var e,t=function(e){return e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&"STRIPE"!==e.code&&"STRIPE_EU"!==e.code},i=this.checkout.selectedPaymentGateway;if(i&&t(i))return i.id;var s=this.paymentGateways.filter(t);return null===(e=s.find((function(e){return!!e.masterPassClientId}))||s[0])||void 0===e?void 0:e.id},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"masterPassSavePhoneNumber",{get:function(){return this.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?this.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({withPlus:!0,store:this.store,checkout:this.checkout}):this.mpVM.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToShipping",{get:function(){var e,t,i,s=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),n=!!(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress);return(this.isDigitalOnly?s:this.isShowBillingAddressOnShippingStep?"address"===this.deliveryMethod&&this.useDifferentAddress?n&&s:s:n)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&!this.hasCorrectableEmailTypo&&(null===(i=this.error)||void 0===i?void 0:i.type)!==ye.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!(!(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)||!(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)||!(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||this.hasCorrectableEmailTypo||!this.checkout.stockLocationId)&&(!this.isShowBillingAddressOnShippingStep||this.canProceedToShipping)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrderWithoutShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&!(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGatewayIndex",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));return e},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isTkPay",{get:function(){var e,t,i=this.checkout.selectedPaymentGateway;return i&&"TK_PAY"===i.code&&"true"===(null===(t=null===(e=i.settings)||void 0===e?void 0:e.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===t?void 0:t.value)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCardStorageEnabled",{get:function(){return this.isCardStorageGateway(this.checkout.selectedPaymentGateway)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canUseSavedCards",{get:function(){return this.isCardStorageEnabled&&!this.isSecureCardEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"visibleSavedCards",{get:function(){var e;return this.canUseSavedCards&&this.savedCardsGatewayId===(null===(e=this.checkout.selectedPaymentGateway)||void 0===e?void 0:e.id)?this.savedCards:[]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"selectedSavedCard",{get:function(){var e=this;return this.visibleSavedCards.find((function(t){return t.id===e.selectedSavedCardId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isSavedCardCvvValid",{get:function(){return/^\d{3,4}$/.test(this.savedCardCvv)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return e.code===z&&!!e.milesSmilesEnabled}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRate",{get:function(){var e,t,i=null===(t=null===(e=this.milesSmilesPaymentGateway)||void 0===e?void 0:e.settings)||void 0===t?void 0:t.find((function(e){return"miles_smiles_try_per_1000"===e.label})),s=(null==i?void 0:i.value)?parseFloat(i.value):NaN;return isFinite(s)&&s>0?s/1e3:Ce[this.checkout.currencyCode]||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAvailableMiles",{get:function(){var e;return(null===(e=this.milesSmilesDetails)||void 0===e?void 0:e.availableMiles)||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesMaxRedeemable",{get:function(){var e=this.milesSmilesAvailableMiles,t=this.milesSmilesRate,i=this.finalPrice||0;return!t||i<=0?e:Math.min(e,Math.ceil(i/t))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRedeemValue",{get:function(){if(!this.useMilesSmiles)return 0;var e=this.milesSmilesRate;return e?(this.milesToRedeem||0)*e:0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAppliedValue",{get:function(){return this.milesToRedeem>this.milesSmilesAvailableMiles?0:Math.min(this.milesSmilesRedeemValue,this.finalPrice||0)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAmountToPay",{get:function(){return Math.max(0,(this.finalPrice||0)-this.milesSmilesAppliedValue)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesAllMilesUsed",{get:function(){return this.milesToRedeem>0&&this.milesToRedeem===this.milesSmilesMaxRedeemable},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesNothingToPay",{get:function(){return this.checkout.totalFinalPrice<=0||this.finalPrice<=0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesInput",{get:function(){if(!this.isMilesSmilesNothingToPay&&this.useMilesSmiles&&this.isMilesSmilesActive()){var e=Math.floor(this.milesToRedeem||0);if(!(e<1))return{miles:e}}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"store",{get:function(){return se.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===d.UPSELL||this.checkout.createdBy===d.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==u.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(this.selectedSavedCard?!this.selectedSavedCard.requireCvv||this.isSavedCardCvvValid:!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!(this.isKlarna||this.isPayPal||this.isHepsiPay)||(this.isSecureCardEnabled?this.secureCard.isValid:null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=ne.getCurrentRouting())||void 0===t?void 0:t.countryCodes;return null===(s=null===(i=this.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(t){var i=new A(e({countrySettings:n.countrySettings},t));return i.checkoutSettings=n.checkoutSettings,i.shippingZones=n.shippingZones,i.getValidatedCustomerAddress(),i}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===d.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrderWithTransaction",{get:function(){var e,t;return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber&&!!(null===(e=this.openEditOrderTransaction)||void 0===e?void 0:e.chargedAmount)&&(null===(t=this.openEditOrderTransaction)||void 0===t?void 0:t.chargedAmount)>0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isEPayKolayEnabled",{get:function(){var e=ne.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPoweredByHidden",{get:function(){var e=ne.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasCorrectableEmailTypo",{get:function(){var e;return!this.checkout.hasCustomer&&!!me((null===(e=this.checkout.customer)||void 0===e?void 0:e.email)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&(!this.checkout.hasValidCustomerEmail||this.hasCorrectableEmailTypo)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesTermsMissing",{get:function(){return this.useMilesSmiles&&this.isMilesSmilesActive()&&!this.isMilesSmilesNothingToPay&&this.milesToRedeem>0&&!this.isMilesSmilesTermsAccepted},enumerable:!1,configurable:!0}),fe.prototype.isMilesSmilesActive=function(){return!this.isMilesSmilesUnavailable&&!!this.milesSmilesPaymentGateway&&this.checkout.currencyCode===Z},Object.defineProperty(fe.prototype,"isSecureCardEnabled",{get:function(){return j.isEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"cardBin",{get:function(){var e,t;if(this.isSecureCardEnabled)return this.secureCard.bin||void 0;var i=null===(t=null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)||void 0===t?void 0:t.split(" ").join("");return i&&i.length>=8?i.slice(0,8):void 0},enumerable:!1,configurable:!0}),fe.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},fe}();function Ee(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function we(e){return e&&ve.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(ge||(ge={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(ye||(ye={}));export{ge as CheckoutStep,ye as ErrorType,Pe as MILES_SMILES_LOGIN_REQUIRED_CODES,Ce as MILES_SMILES_RATE_PER_POINT,ke as MILES_SMILES_UNAVAILABLE_CODES,Ae as default};
|
|
@@ -3,6 +3,7 @@ import { SuccessModalType } from "./components/master-pass/modal-success";
|
|
|
3
3
|
import { IkasBaseStore } from "../../store";
|
|
4
4
|
import { IkasCheckout, IkasPaymentGateway } from "../../models";
|
|
5
5
|
import { MasterPassOperationTypeEnum } from "@ikas/storefront-api";
|
|
6
|
+
import MasterPassBridgeViewModel from "./components/secure-card-form/masterpass-bridge-model";
|
|
6
7
|
export declare const MFS_ELEMENT_ID = "ikasMasterPass";
|
|
7
8
|
export declare const MFS_SCRIPT_URL = "https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js";
|
|
8
9
|
declare type MFS_CB_HOC_TYPE_SOURCE = "checkMasterPass" | "register" | "resendOtp" | "linkCardToClient" | "validateTransaction" | "listCards" | "deleteCard";
|
|
@@ -12,7 +13,7 @@ declare type MFS_CB_HOC_TYPE = (params: {
|
|
|
12
13
|
checkout: IkasCheckout;
|
|
13
14
|
callback?: () => void;
|
|
14
15
|
}) => MFS_CB_TYPE;
|
|
15
|
-
declare type MFS_CB_TYPE = (status: any, response: {
|
|
16
|
+
export declare type MFS_CB_TYPE = (status: any, response: {
|
|
16
17
|
responseCode: /* register success */ "0000" | /* register success */ "" | /* banka tarafindan otp dogrulamasi yapilir */ "5001" | /* masterpass tarafindan otp dogrulamasi yapilir*/ "5008" | /* Bu kredi kartı bu kullanıcıya daha önceden kaydedilmiştir. */ "5196" | /* Tek kullanımlık şifre doğrulanamadı. */ "1409" | /* External hesap bulunamadı. */ "1999" | string;
|
|
17
18
|
responseDescription?: string;
|
|
18
19
|
transactionId: string;
|
|
@@ -20,7 +21,7 @@ declare type MFS_CB_TYPE = (status: any, response: {
|
|
|
20
21
|
url3D: string;
|
|
21
22
|
cards: number | Array<Card>;
|
|
22
23
|
}) => void;
|
|
23
|
-
declare type MFS = {
|
|
24
|
+
export declare type MFS = {
|
|
24
25
|
checkMasterPass: (formData: FormData, cb: MFS_CB_TYPE) => void;
|
|
25
26
|
setClientId: (a: string) => void;
|
|
26
27
|
register: (formData: FormData, cb: MFS_CB_TYPE) => void;
|
|
@@ -65,7 +66,10 @@ export default class MasterPassModel {
|
|
|
65
66
|
mfsResponseModalText?: string;
|
|
66
67
|
cards: Card[];
|
|
67
68
|
selectedCard?: Card;
|
|
69
|
+
/** Set when secure card fields are on: the SDK runs in the bridge iframe. */
|
|
70
|
+
bridge: MasterPassBridgeViewModel | null;
|
|
68
71
|
constructor();
|
|
72
|
+
setBridge: (bridge: MasterPassBridgeViewModel) => void;
|
|
69
73
|
get isSaveCardToMasterPassPhoneNumberInputVisible(): boolean;
|
|
70
74
|
get isSaveCardToMasterPassPhoneNumberInputDisabled(): boolean;
|
|
71
75
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__rest as s}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as a}from"mobx";import{useTranslation as o}from"../../utils/i18n.js";import{getMasterPassRequestToken as r,MasterPassOperationTypeEnum as n}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";var c="ikasMasterPass",u="https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js",d="undefined"==typeof localStorage,l=/000000[0|1]{10}/g,h=/[0|1]1100[0|1]{11}/g,p=/[0|1]11100[0|1]{10}/g,m=function(){function c(){var c=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.saveCardToMasterPassPhoneNumberDisabledInputValue=function(e){var t=e.store,s=e.checkout,a=e.withPlus;return c.phoneNumber({store:t,checkout:s,withPlus:a})||""},this.onSaveCardToMasterPassCheckedChange=function(e){c.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){c.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){c.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var t=e.creditCard,s=e.store,a=e.checkout,o=e.paymentGateway,r=e.callback;c.register({creditCard:t,store:s,checkout:a,paymentGateway:o,callback:r})},this.showLinkCardToClient=function(){c.visibleModal="linkCardToClient"},this.hideLinkCardToClient=function(){c.visibleModal=void 0},this.showOtpModal=function(e){c.otpResponse.text="",c.otpResponse.status="",c.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank"},this.hideOtpModal=function(){c.visibleModal=void 0,c.otpResponse.text="",c.otpResponse.status="",c.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){c.visibleModal=void 0,c.mfsResponseModalText=""},this.onSuccessModalClose=function(){c.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){c.linkCardToClient(e)},this.onOtpFormSubmit=function(e){c.otpResponse.text="",c.otpResponse.status="",c.validateTransaction(e)},this.MFS=function(){var e;if(!d){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId)){var t=window.MFS;return t.setAddress("https://ui.masterpassturkiye.com/v2"),t}console.error("MFS can not use.")}},this.getToken=function(s){var a=s.cartId,o=s.paymentGatewayId,n=s.operationType,i=s.phoneNumber;return e(c,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r({cartId:a,paymentGatewayId:o,operationType:n,phoneNumber:i})];case 1:return(e=t.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var t,s,a=e.store,o=e.checkout,r=e.withPlus,n=void 0!==r&&r,i=(null===(t=a.customerStore.customer)||void 0===t?void 0:t.phone)||(null===(s=o.shippingAddress)||void 0===s?void 0:s.phone);return i&&i.includes("+")&&!n&&(i=i.replace("+","")),i},this.sendSmsLanguage=function(e){var t,s="tur";if(e.localeOptions.length){var a=e.localeOptions.find((function(e){return e.routing.locale===i.getCurrentLocale()}));a&&a.iso3&&(s=null===(t=a.iso3)||void 0===t?void 0:t.toLowerCase())}return s},this.clearSaveCardToMasterPassForm=function(){c.saveCardToMasterPass.isCheckboxChecked=!1,c.saveCardToMasterPass.phoneNumber="",c.saveCardToMasterPass.cardName="",c.saveCardToMasterPass.isSendConfirmationButtonPending=!1},this.mfsResponseHandler=function(e){return function(t,s){e.callback&&e.callback();var a,o=function(e){var t;return null===(t=null==s?void 0:s.accountStatus)||void 0===t?void 0:t.match(e)};o(l)&&(c.checkMasterPassData.status="noMasterPassAccount",(a=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=a));o(h)&&(c.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",c.showLinkCardToClient(),(a=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=a));if(o(p)&&(c.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&c.listCards({store:e.store,checkout:e.checkout})),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!s.responseDescription||(c.otpResponse.text=s.responseDescription,"1409"===s.responseCode&&(c.otpResponse.status="error")),"0000"!=s.responseCode&&""!=s.responseCode||("deleteCard"===e.source&&c.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===c.checkMasterPassData.status?c.visibleModal="linkCardToClientModalSuccess":c.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,c.clearSaveCardToMasterPassForm(),c.listCards({store:e.store,checkout:e.checkout}))),"5196"===s.responseCode&&s.responseDescription&&(c.visibleModal="mfsResponseModal",c.mfsResponseModalText=s.responseDescription),"5001"==s.responseCode||"5008"==s.responseCode){var r="5001"===s.responseCode?"bankOtp":"masterPassOtp";c.showOtpModal(r)}"5010"!=s.responseCode||"undefined"==typeof window||window.location.assign(s.url3D+"&returnUrl="+window.location.href)}},this.showTokenErrorWithModal=function(){var e=o().t;c.visibleModal="mfsResponseModal",c.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(a){return e(c,void 0,void 0,(function(){var e,o,r,i,c,u,d=a.checkout,l=a.store;return s(a,["checkout","store"]),t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())?(o=this.phoneNumber({store:l,checkout:d}),r=d.masterPassPaymentGateway,o&&r&&r.masterPassClientId?[4,this.getToken({cartId:d.id,paymentGatewayId:r.id,operationType:n.CHECK_MASTER_PASS_USER,phoneNumber:o})]:[2]):[2];case 1:return(i=t.sent())?(e.setClientId(r.masterPassClientId),c=this.sendSmsLanguage(l),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:o}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:d,store:l})),[2]):[2]}}))}))},this.register=function(s){var a=s.creditCard,o=s.store,r=s.checkout,i=s.paymentGateway,u=s.callback;return e(c,void 0,void 0,(function(){var e,s,c,d;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=a.phoneNumber)&&i.masterPassClientId)?[4,this.getToken({cartId:r.id,paymentGatewayId:i.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(null==(c=t.sent())?void 0:c.token)?(d=this.prepareFormData({msisdn:s,token:null==c?void 0:c.token,referenceNo:c.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),rtaPan:a.rtaPan,expiryDate:a.expiryDate,cvc:a.cvc,accountAliasName:a.accountAliasName,timeZone:c.timeZone,sendSms:"Y",actionType:"A",clientIp:"",delinkReason:"",eActionType:"A",cardTypeFlag:"05",cpinFlag:"Y",defaultAccount:"Y",mmrpConfig:"110010",identityVerificationFlag:"Y",mobileAccountConfig:"MWA",uiChannelType:"6"}),e.setClientId(i.masterPassClientId),e.register(d,this.mfsResponseHandler({source:"register",store:o,checkout:r,callback:u})),[2]):[2]}}))}))},this.resendOtp=function(s){var a=s.store,o=s.checkout,r=s.callback;return e(c,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(s=e.getLastToken(),n=this.sendSmsLanguage(a),e.resendOtp(s,n,this.mfsResponseHandler({source:"resendOtp",store:a,checkout:o,callback:r})),[2]):[2]}))}))},this.linkCardToClient=function(s){var a=s.store,o=s.checkout,r=s.callback;return e(c,void 0,void 0,(function(){var e,s,i,c,u;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:a,checkout:o}))&&(null==(i=o.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:o.id,paymentGatewayId:i.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(c=t.sent())?(u=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:s}),e.linkCardToClient(u,this.mfsResponseHandler({source:"linkCardToClient",store:a,checkout:o,callback:r})),[2]):(r&&r(),[2])}}))}))},this.validateTransaction=function(s){var a=s.validationCode,o=s.store,r=s.checkout,i=s.callback;return e(c,void 0,void 0,(function(){var e,s,c,u,d;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:o,checkout:r}))&&(c=r.masterPassPaymentGateway))?[4,this.getToken({cartId:r.id,paymentGatewayId:c.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(u=t.sent())?(d=this.prepareFormData({pinType:"otp",validationCode:a,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:u.token,referenceNo:u.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(d,this.mfsResponseHandler({source:"validateTransaction",store:o,checkout:r,callback:i})),[2]):[2]}}))}))},this.listCards=function(s){var a=s.store,o=s.checkout;return e(c,void 0,void 0,(function(){var e,s,r,i,c,u,d=this;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:a,checkout:o}))&&(r=null===(u=o.masterPassPaymentGateway)||void 0===u?void 0:u.id))?[4,this.getToken({cartId:o.id,paymentGatewayId:r,operationType:n.LIST_CARDS,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=function(e,t){"0000"!=t.responseCode&&""!=t.responseCode&&console.error({source:"mfs response.responseDescription",responseDescription:t.responseDescription,response:t});var s=[];if(Array.isArray(t.cards)&&t.cards.length)for(var a=0;a<t.cards.length;a++){var o=t.cards[a];o.paymentGatewayId=r,s.push(o)}d.cards=s},e.listCards(s,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(s){var a=s.store,o=s.checkout,r=s.card;return e(c,void 0,void 0,(function(){var e,s,i,c;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:a,checkout:o}))?[4,this.getToken({cartId:o.id,paymentGatewayId:r.paymentGatewayId,operationType:n.DELETE_CARD,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:s,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),accountAliasName:r.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:a,checkout:o})),[2]):[2]}}))}))},a(this)}return Object.defineProperty(c.prototype,"isSaveCardToMasterPassPhoneNumberInputVisible",{get:function(){return("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||this.checkMasterPassData.status,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isSaveCardToMasterPassPhoneNumberInputDisabled",{get:function(){return!("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)||("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||"noMasterPassAccount"===this.checkMasterPassData.status)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isSendConfirmationButtonDisabled",{get:function(){return this.isSaveCardToMasterPassPhoneNumberInputVisible?this.isSaveCardToMasterPassPhoneNumberInputDisabled?!this.saveCardToMasterPass.cardName:!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber:!this.saveCardToMasterPass.cardName},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isLinkCardToClientVisible",{get:function(){return"linkCardToClient"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),c.prototype.prepareFormData=function(e){var t=new FormData;return Object.entries(e).forEach((function(e){var s=e[0],a=e[1];return t.append(s,a)})),t},c}();export{c as MFS_ELEMENT_ID,u as MFS_SCRIPT_URL,m as default};
|
|
1
|
+
import{__awaiter as e,__generator as t,__rest as s}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as a}from"mobx";import{useTranslation as o}from"../../utils/i18n.js";import{getMasterPassRequestToken as r,MasterPassOperationTypeEnum as n}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{SECURE_MASTERPASS_ERROR_PREFIX as c}from"./components/secure-card-form/masterpass-bridge-model.js";var u="ikasMasterPass",d="https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js",l="undefined"==typeof localStorage,h=/000000[0|1]{10}/g,p=/[0|1]1100[0|1]{11}/g,m=/[0|1]11100[0|1]{10}/g,f=function(){function u(){var u=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.bridge=null,this.setBridge=function(e){u.bridge=e},this.saveCardToMasterPassPhoneNumberDisabledInputValue=function(e){var t=e.store,s=e.checkout,a=e.withPlus;return u.phoneNumber({store:t,checkout:s,withPlus:a})||""},this.onSaveCardToMasterPassCheckedChange=function(e){u.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){u.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){u.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var t=e.creditCard,s=e.store,a=e.checkout,o=e.paymentGateway,r=e.callback;u.register({creditCard:t,store:s,checkout:a,paymentGateway:o,callback:r})},this.showLinkCardToClient=function(){u.visibleModal="linkCardToClient"},this.hideLinkCardToClient=function(){u.visibleModal=void 0},this.showOtpModal=function(e){u.otpResponse.text="",u.otpResponse.status="",u.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank"},this.hideOtpModal=function(){u.visibleModal=void 0,u.otpResponse.text="",u.otpResponse.status="",u.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){u.visibleModal=void 0,u.mfsResponseModalText=""},this.onSuccessModalClose=function(){u.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){u.linkCardToClient(e)},this.onOtpFormSubmit=function(e){u.otpResponse.text="",u.otpResponse.status="",u.validateTransaction(e)},this.MFS=function(){var e;if(!l){if(u.bridge)return u.bridge;if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId)){var t=window.MFS;return t.setAddress("https://ui.masterpassturkiye.com/v2"),t}console.error("MFS can not use.")}},this.getToken=function(s){var a=s.cartId,o=s.paymentGatewayId,n=s.operationType,i=s.phoneNumber;return e(u,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r({cartId:a,paymentGatewayId:o,operationType:n,phoneNumber:i})];case 1:return(e=t.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var t,s,a=e.store,o=e.checkout,r=e.withPlus,n=void 0!==r&&r,i=(null===(t=a.customerStore.customer)||void 0===t?void 0:t.phone)||(null===(s=o.shippingAddress)||void 0===s?void 0:s.phone);return i&&i.includes("+")&&!n&&(i=i.replace("+","")),i},this.sendSmsLanguage=function(e){var t,s="tur";if(e.localeOptions.length){var a=e.localeOptions.find((function(e){return e.routing.locale===i.getCurrentLocale()}));a&&a.iso3&&(s=null===(t=a.iso3)||void 0===t?void 0:t.toLowerCase())}return s},this.clearSaveCardToMasterPassForm=function(){var e;u.saveCardToMasterPass.isCheckboxChecked=!1,u.saveCardToMasterPass.phoneNumber="",u.saveCardToMasterPass.cardName="",u.saveCardToMasterPass.isSendConfirmationButtonPending=!1,null===(e=u.bridge)||void 0===e||e.resetFrame()},this.mfsResponseHandler=function(e){return function(t,s){var a;if(e.callback&&e.callback(),null===(a=null==s?void 0:s.responseCode)||void 0===a?void 0:a.startsWith(c))return console.error("MasterPass bridge: ".concat(s.responseCode)),void("checkMasterPass"!==e.source&&"listCards"!==e.source&&u.showTokenErrorWithModal());var o,r=function(e){var t;return null===(t=null==s?void 0:s.accountStatus)||void 0===t?void 0:t.match(e)};r(h)&&(u.checkMasterPassData.status="noMasterPassAccount",(o=u.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(u.saveCardToMasterPass.phoneNumber=o));r(p)&&(u.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",u.showLinkCardToClient(),(o=u.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(u.saveCardToMasterPass.phoneNumber=o));if(r(m)&&(u.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&u.listCards({store:e.store,checkout:e.checkout})),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!s.responseDescription||(u.otpResponse.text=s.responseDescription,"1409"===s.responseCode&&(u.otpResponse.status="error")),"0000"!=s.responseCode&&""!=s.responseCode||("deleteCard"===e.source&&u.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===u.checkMasterPassData.status?u.visibleModal="linkCardToClientModalSuccess":u.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,u.clearSaveCardToMasterPassForm(),u.listCards({store:e.store,checkout:e.checkout}))),"5196"===s.responseCode&&s.responseDescription&&(u.visibleModal="mfsResponseModal",u.mfsResponseModalText=s.responseDescription),"5001"==s.responseCode||"5008"==s.responseCode){var n="5001"===s.responseCode?"bankOtp":"masterPassOtp";u.showOtpModal(n)}"5010"!=s.responseCode||"undefined"==typeof window||window.location.assign(s.url3D+"&returnUrl="+window.location.href)}},this.showTokenErrorWithModal=function(){var e=o().t;u.visibleModal="mfsResponseModal",u.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(a){return e(u,void 0,void 0,(function(){var e,o,r,i,c,u,d=a.checkout,l=a.store;return s(a,["checkout","store"]),t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())?(o=this.phoneNumber({store:l,checkout:d}),r=d.masterPassPaymentGateway,o&&r&&r.masterPassClientId?[4,this.getToken({cartId:d.id,paymentGatewayId:r.id,operationType:n.CHECK_MASTER_PASS_USER,phoneNumber:o})]:[2]):[2];case 1:return(i=t.sent())?(e.setClientId(r.masterPassClientId),c=this.sendSmsLanguage(l),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:o}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:d,store:l})),[2]):[2]}}))}))},this.register=function(s){var a=s.creditCard,o=s.store,r=s.checkout,i=s.paymentGateway,c=s.callback;return e(u,void 0,void 0,(function(){var e,s,u,d;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=a.phoneNumber)&&i.masterPassClientId)?[4,this.getToken({cartId:r.id,paymentGatewayId:i.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(null==(u=t.sent())?void 0:u.token)?(d=this.prepareFormData({msisdn:s,token:null==u?void 0:u.token,referenceNo:u.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),rtaPan:a.rtaPan,expiryDate:a.expiryDate,cvc:a.cvc,accountAliasName:a.accountAliasName,timeZone:u.timeZone,sendSms:"Y",actionType:"A",clientIp:"",delinkReason:"",eActionType:"A",cardTypeFlag:"05",cpinFlag:"Y",defaultAccount:"Y",mmrpConfig:"110010",identityVerificationFlag:"Y",mobileAccountConfig:"MWA",uiChannelType:"6"}),e.setClientId(i.masterPassClientId),e.register(d,this.mfsResponseHandler({source:"register",store:o,checkout:r,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(s){var a=s.store,o=s.checkout,r=s.callback;return e(u,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(s=e.getLastToken(),n=this.sendSmsLanguage(a),e.resendOtp(s,n,this.mfsResponseHandler({source:"resendOtp",store:a,checkout:o,callback:r})),[2]):[2]}))}))},this.linkCardToClient=function(s){var a=s.store,o=s.checkout,r=s.callback;return e(u,void 0,void 0,(function(){var e,s,i,c,u;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:a,checkout:o}))&&(null==(i=o.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:o.id,paymentGatewayId:i.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(c=t.sent())?(u=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:s}),e.linkCardToClient(u,this.mfsResponseHandler({source:"linkCardToClient",store:a,checkout:o,callback:r})),[2]):(r&&r(),[2])}}))}))},this.validateTransaction=function(s){var a=s.validationCode,o=s.store,r=s.checkout,i=s.callback;return e(u,void 0,void 0,(function(){var e,s,c,u,d;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:o,checkout:r}))&&(c=r.masterPassPaymentGateway))?[4,this.getToken({cartId:r.id,paymentGatewayId:c.id,operationType:n.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(u=t.sent())?(d=this.prepareFormData({pinType:"otp",validationCode:a,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:u.token,referenceNo:u.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(d,this.mfsResponseHandler({source:"validateTransaction",store:o,checkout:r,callback:i})),[2]):[2]}}))}))},this.listCards=function(s){var a=s.store,o=s.checkout;return e(u,void 0,void 0,(function(){var e,s,r,i,c,u,d=this;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:a,checkout:o}))&&(r=null===(u=o.masterPassPaymentGateway)||void 0===u?void 0:u.id))?[4,this.getToken({cartId:o.id,paymentGatewayId:r,operationType:n.LIST_CARDS,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=function(e,t){"0000"!=t.responseCode&&""!=t.responseCode&&console.error({source:"mfs response.responseDescription",responseDescription:t.responseDescription,response:t});var s=[];if(Array.isArray(t.cards)&&t.cards.length)for(var a=0;a<t.cards.length;a++){var o=t.cards[a];o.paymentGatewayId=r,s.push(o)}d.cards=s},e.listCards(s,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(s){var a=s.store,o=s.checkout,r=s.card;return e(u,void 0,void 0,(function(){var e,s,i,c;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:a,checkout:o}))?[4,this.getToken({cartId:o.id,paymentGatewayId:r.paymentGatewayId,operationType:n.DELETE_CARD,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:s,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),accountAliasName:r.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:a,checkout:o})),[2]):[2]}}))}))},a(this,{bridge:!1})}return Object.defineProperty(u.prototype,"isSaveCardToMasterPassPhoneNumberInputVisible",{get:function(){return("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||this.checkMasterPassData.status,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isSaveCardToMasterPassPhoneNumberInputDisabled",{get:function(){return!("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)||("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||"noMasterPassAccount"===this.checkMasterPassData.status)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isSendConfirmationButtonDisabled",{get:function(){return this.isSaveCardToMasterPassPhoneNumberInputVisible?this.isSaveCardToMasterPassPhoneNumberInputDisabled?!this.saveCardToMasterPass.cardName:!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber:!this.saveCardToMasterPass.cardName},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isLinkCardToClientVisible",{get:function(){return"linkCardToClient"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),u.prototype.prepareFormData=function(e){var t=new FormData;return Object.entries(e).forEach((function(e){var s=e[0],a=e[1];return t.append(s,a)})),t},u}();export{u as MFS_ELEMENT_ID,d as MFS_SCRIPT_URL,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import{
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import{suggestEmailCorrection as o}from"@ikas/storefront-model-functions";import{FormItem as i}from"../../components/form-item/index.js";import{FormItemType as n,FormItemInputMode as r}from"../../components/form-item/model.js";import{Button as s}from"../../components/button/index.js";import{Checkbox as l}from"../../components/checkbox/index.js";import c from"../../components/error/index.js";import a from"../../styles/common.module.scss.js";import m from"./style.module.scss.js";import u from"../../components/customer-addresses/index.js";import p from"../../components/customer-addresses/model.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";var f=t((function(t){var f,g,h=t.vm,E=d().t,k=e.useRef(null),v=e.useState(0),S=v[0],C=v[1],b=e.useState(null),y=b[0],x=b[1],T=(null===(f=h.checkout.customer)||void 0===f?void 0:f.email)||"";e.useEffect((function(){h.hasEmailError&&k.current&&k.current.scrollIntoView({behavior:"smooth",block:"center"})}),[h.hasEmailError,S]),e.useEffect((function(){var e=window.setTimeout((function(){x(o(T))}),500);return function(){window.clearTimeout(e)}}),[T]);var w=e.useCallback((function(e){h.checkout.customer&&(h.checkout.customer.email=e?e.trim():e)}),[h]),A=e.useCallback((function(e){e.preventDefault(),y&&(w(y),x(null))}),[w,y]),j=e.useMemo((function(){if(!y)return null;var t=E("checkout-page:emailSuggestion",{email:"\0"}).split("\0"),o=t[0],i=t[1],n=void 0===i?"":i,r=y.indexOf("@"),s=-1===r?"".concat(y).concat(n):e.createElement(e.Fragment,null,y.slice(0,r+1),e.createElement("wbr",null),"".concat(y.slice(r+1)).concat(n));return e.createElement(e.Fragment,null,o,e.createElement("button",{type:"button",className:m.EmailSuggestionLink,onClick:A},s))}),[y,A,E]),D=e.useMemo((function(){return h.isDigitalOnly?new p(h,"billing"):new p(h,"shipping")}),[h]),O=e.useCallback((function(e){e.preventDefault(),C((function(e){return e+1})),h.isStepLoading||D.editingCustomerAddress||(h.isDigitalOnly?h.onProceedToDigitalOnlyPaymentClick():h.onProceedToShippingClick())}),[h,D.editingCustomerAddress]);return e.createElement("form",{onSubmit:O,autoComplete:"on"},e.createElement(c,{vm:h}),!h.checkout.hasCustomer&&e.createElement("div",{style:{marginTop:"8px",marginBottom:"40px"}},e.createElement("div",{className:a.FormSectionTitle},e.createElement("div",{className:a.Title},E("checkout-page:contactInfo"))),e.createElement("div",{ref:k},e.createElement(i,{name:"email",type:n.TEXT,inputMode:r.EMAIL,label:E("checkout-page:email"),autocomplete:"shipping email",value:T,onChange:w,hasError:h.hasEmailError,errorText:y||h.hasCorrectableEmailTypo?void 0:E("checkout-page:emailError"),tooltipText:E("checkout-page:guestEmailTooltip"),autocapitalize:"off",autocorrect:"off",spellcheck:"false"}),!!j&&e.createElement("div",{className:m.EmailSuggestion},j)),e.createElement(l,{value:(null===(g=h.checkout.customer)||void 0===g?void 0:g.notificationsAccepted)||!1,label:E("checkout-page:customerConsentCta"),onChange:h.setCustomerConsentGranted,id:"marketingCheckbox"})),e.createElement(u,{vm:D}),h.isShowBillingAddressOnShippingStep&&"address"===h.deliveryMethod&&!h.isDigitalOnly&&e.createElement(l,{value:!h.useDifferentAddress,hasError:h.isErrorsVisible&&!h.isTermsAndConditionsChecked,label:E("checkout-page:useShippingForBilling"),onChange:function(e){return h.setUseDifferentAddress(!e,!0)}}),h.isShowBillingAddressOnShippingStep&&(h.useDifferentAddress||"in-store"===h.deliveryMethod)&&e.createElement(u,{vm:new p(h,"billing"),showBillingAddressOnShippingStep:!0}),!D.editingCustomerAddress&&e.createElement(s,{type:"submit",style:{width:"100%",marginTop:h.store.customerStore.customer&&!h.isShowBillingAddressOnShippingStep?"0px":"32px"},text:"address"!==h.deliveryMethod||h.isDigitalOnly?E("checkout-page:actions.continueWithPayment"):E("checkout-page:actions.continueWithShipping"),isLoading:h.isStepLoading}))}));export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from'./../../../../ext/style-inject/dist/style-inject.es.js';var e={EmailSuggestion:"style-module_EmailSuggestion__McKUz",EmailSuggestionLink:"style-module_EmailSuggestionLink__Uo2PG"};n(".style-module_EmailSuggestion__McKUz {\n color: var(--checkout-secondary-text-color);\n font-size: 12px;\n margin-top: 8px;\n line-height: 16px;\n overflow-wrap: anywhere;\n word-break: break-word;\n}\n\n.style-module_EmailSuggestionLink__Uo2PG {\n color: var(--checkout-primary-text-color);\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n font: inherit;\n font-size: inherit;\n line-height: inherit;\n text-decoration: underline;\n cursor: pointer;\n display: inline;\n white-space: normal;\n overflow-wrap: anywhere;\n word-break: break-word;\n text-align: left;\n}");export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as r}from"mobx-react-lite";import{Checkbox as
|
|
1
|
+
import*as e from"react";import{observer as r}from"mobx-react-lite";import{Checkbox as s}from"../../../components/checkbox/index.js";import i from"../../../components/customer-addresses/model.js";import t from"../../../components/customer-addresses/index.js";import"@ikas/storefront-config";import{useTranslation as n}from"../../../../../utils/i18n.js";var o=r((function(r){var o=r.vm,m=n().t,d=e.useMemo((function(){return new i(o,"billing")}),[o]);return e.useEffect((function(){"in-store"===o.deliveryMethod&&o.setUseDifferentAddress(!0)}),[o]),e.createElement(e.Fragment,null,e.createElement("div",{style:{marginTop:"32px",marginBottom:o.useDifferentAddress?"24px":"0px"}},"address"===o.deliveryMethod&&!o.isDigitalOnly&&o.isCorporateInvoiceVisible&&!o.isShowBillingAddressOnShippingStep&&e.createElement(s,{value:!o.useDifferentAddress,hasError:o.isErrorsVisible&&!o.isTermsAndConditionsChecked,label:m("checkout-page:useShippingForBilling"),onChange:function(e){return o.setUseDifferentAddress(!e)}})),o.useDifferentAddress&&!o.isShowBillingAddressOnShippingStep&&e.createElement(t,{vm:d}))}));export{o as BillingAddress};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as
|
|
1
|
+
import*as e from"react";import{observer as i}from"mobx-react-lite";import{IkasStorefrontConfig as t}from"@ikas/storefront-config";import{Checkbox as o}from"../../components/checkbox/index.js";import s from"../../components/error/index.js";import{PaymentGateways as n}from"./payment-gateways/index.js";import{BillingAddress as r}from"./billing-address/index.js";import{Button as a}from"../../components/button/index.js";import l from"../../components/master-pass/link-card-to-client/index.js";import{PayPal as m}from"../../components/paypal/index.js";import c from"../../components/notification-box/index.js";import{createTranslationInputData as p,useTranslation as d}from"../../../../utils/i18n.js";import y from"../../components/svg/lock.js";import u from"./style.module.scss.js";import{StoreCredit as g}from"./payment-gateways/store-credit/index.js";import{MilesSmiles as k}from"./payment-gateways/miles-smiles/index.js";import{MilesSmilesLoginRequired as f}from"./payment-gateways/miles-smiles/login-required.js";var v=i((function(i){var v=i.vm,P=d().t,E=e.useCallback((function(e){e.stopPropagation(),v.policyModalTitle=P("checkout-page:privacyPolicy"),v.policyModalText=v.privacyPolicy}),[v,v.privacyPolicy]),h=e.useCallback((function(e){e.stopPropagation(),v.policyModalTitle=P("checkout-page:termsOfService"),v.policyModalText=v.termsOfService}),[v,v.termsOfService]),C=t.getTranslations()["checkout-page"],x=p(C.ackPoliciesSentence).map((function(i){return i.isVariable?e.createElement("span",{className:[u.TermsLabelSpan,v.isErrorsVisible&&!v.isTermsAndConditionsChecked?u.Error:""].join(" "),onClick:"{{ ackPrivacyPolicy }}"===i.value?E:h},"{{ ackPrivacyPolicy }}"===i.value?P("checkout-page:ackPrivacyPolicy"):P("checkout-page:ackTermsOfService")):i.value}));return e.createElement("div",{className:[u.StepPayment,v.isPaymentMethodVisible?"":u.Disabled].join(" ")},e.createElement(s,{vm:v}),e.createElement(g,{vm:v}),!v.isMilesSmilesActive()||v.isMilesSmilesNothingToPay?null:v.isMilesSmilesLoginRequired||!v.milesSmilesDetails?v.isMilesSmilesLoginRequired||v.milesSmilesError?e.createElement(f,{vm:v}):null:e.createElement(k,{vm:v}),v.isFree&&(v.isMilesSmilesFullPayment?e.createElement(c,{type:"success",title:P("checkout-page:milesSmilesFullPaymentTitle"),content:P("checkout-page:milesSmilesFullPaymentDescription"),ignoreScroll:!0}):e.createElement(c,{type:"success",content:P("checkout-page:freeOrderDescription")})),!v.isFree&&e.createElement(e.Fragment,null,v.mpVM.isLinkCardToClientVisible&&e.createElement(l,{vm:v}),e.createElement(n,{vm:v})),e.createElement(r,{vm:v}),v.checkoutSettings.showTermsAndConditionsCheckbox&&(!v.isIyzico&&!v.isTkPay||v.isFree)&&e.createElement("div",{style:{marginTop:v.useDifferentAddress?"12px":"0px"}},e.createElement(o,{value:v.isTermsAndConditionsChecked,hasError:v.isErrorsVisible&&!v.isTermsAndConditionsChecked,label:e.createElement(e.Fragment,null,x),onChange:v.onTermsAndConditionsCheckedChange})),!v.isFree&&v.isPayPal?e.createElement("div",{className:u.PayPalContainer},e.createElement(m,{vm:v})):!v.isIyzico&&!v.isTkPay||v.isFree?e.createElement(a,{style:{width:"100%",marginTop:"24px"},text:P("checkout-page:actions.completeOrder"),isLoading:v.isStepLoading,onClick:v.isDigitalOnly?v.onCompleteDigitalOnlyPaymentClick:v.onCompletePaymentClick}):null,!!P("checkout-page:securePaymentTooltip")&&e.createElement("div",{className:u.SecurePaymentContainer},e.createElement("span",{className:u.Lock},e.createElement(y,null)),e.createElement("span",null,P("checkout-page:securePaymentTooltip"))))}));export{v as CheckoutStepPayment};
|