@ikas/storefront 6.1.0-beta.372 → 6.1.0-beta.374

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.
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import { IkasImage } from "../../../../models";
3
+ export declare type CheckoutLoadFailedProps = {
4
+ logo?: IkasImage | null;
5
+ merchantName?: string | null;
6
+ backHref: string;
7
+ returnPolicy: string;
8
+ privacyPolicy: string;
9
+ termsOfService: string;
10
+ imprint?: string;
11
+ shippingPolicy?: string;
12
+ };
13
+ export declare const CheckoutLoadFailed: React.FC<CheckoutLoadFailedProps>;
14
+ export declare const getCheckoutHomeHref: () => string;
@@ -0,0 +1 @@
1
+ import*as e from"react";import{IkasStorefrontConfig as t}from"@ikas/storefront-config";import{Image as a}from"../../../image/index.js";import{Button as c}from"../button/index.js";import{Modal as o}from"../modal/index.js";import r from"../svg/refresh.js";import{useTranslation as i}from"../../../../utils/i18n.js";import l from"./style.module.scss.js";var n=function(t){var n=t.logo,m=t.merchantName,s=t.backHref,u=t.returnPolicy,p=t.privacyPolicy,d=t.termsOfService,g=t.imprint,f=t.shippingPolicy,v=i().t,h=e.useState(""),k=h[0],E=h[1],N=e.useState(""),y=N[0],F=N[1];return e.createElement("div",{id:"Checkout",className:l.Page},e.createElement("div",{className:l.Header},e.createElement("a",{href:s},n?e.createElement("div",{className:l.Logo},e.createElement(a,{layout:"fill",image:n,sizes:"360px"})):e.createElement("div",{className:[l.Logo,l.MerchantName].join(" ")},m||""))),e.createElement("div",{className:l.Content},e.createElement("div",{className:l.IconCircle},e.createElement(r,null)),e.createElement("div",{className:l.Title},v("checkout-page:pageLoadFailedTitle")),e.createElement("div",{className:l.Description},v("checkout-page:pageLoadFailedDescription")),e.createElement(c,{classes:l.RefreshButton,text:v("checkout-page:actions.refreshPage"),onClick:function(){window.location.reload()}}),e.createElement("a",{href:s,className:l.BackLink},v("checkout-page:actions.backToStore"))),e.createElement("div",{className:l.Footer},e.createElement("div",{className:l.FooterItem,onClick:function(){E(v("checkout-page:returnPolicy")),F(u)}},v("checkout-page:returnPolicy")),e.createElement("div",{className:l.FooterBullet},"•"),e.createElement("div",{className:l.FooterItem,onClick:function(){E(v("checkout-page:privacyPolicy")),F(p)}},v("checkout-page:privacyPolicy")),e.createElement("div",{className:l.FooterBullet},"•"),e.createElement("div",{className:l.FooterItem,onClick:function(){E(v("checkout-page:termsOfService")),F(d)}},v("checkout-page:termsOfService")),!!g&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FooterBullet},"•"),e.createElement("div",{className:l.FooterItem,onClick:function(){E(v("checkout-page:imprint")),F(g||"")}},v("checkout-page:imprint"))),!!f&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FooterBullet},"•"),e.createElement("div",{className:l.FooterItem,onClick:function(){E(v("checkout-page:shippingPolicy")),F(f||"")}},v("checkout-page:shippingPolicy")))),!!y&&e.createElement(o,{title:k,modalContent:y,onClose:function(){return F("")},isPolicyModal:!0}))},m=function(){var e=t.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):"/"};export{n as CheckoutLoadFailed,m as getCheckoutHomeHref};
@@ -0,0 +1 @@
1
+ import e from'./../../../../ext/style-inject/dist/style-inject.es.js';var n={Page:"style-module_Page__w4JUS",Header:"style-module_Header__JEV7O",Logo:"style-module_Logo__l2guu",MerchantName:"style-module_MerchantName__9mQ9g",Content:"style-module_Content__tQJMn",IconCircle:"style-module_IconCircle__x2HKK",Title:"style-module_Title__ZXbeP",Description:"style-module_Description__QMX6n",RefreshButton:"style-module_RefreshButton__C-5Es",BackLink:"style-module_BackLink__RfOES",Footer:"style-module_Footer__Nz1wq",FooterItem:"style-module_FooterItem__K0oS7",FooterBullet:"style-module_FooterBullet__yKuLy"};e('.style-module_Page__w4JUS {\n all: unset;\n box-sizing: border-box;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n width: 100%;\n min-height: 100dvh;\n display: flex;\n flex-direction: column;\n color: var(--checkout-primary-text-color);\n background-color: var(--checkout-primary-bg-color);\n}\n.style-module_Page__w4JUS * {\n box-sizing: border-box;\n font-family: inherit;\n line-height: unset;\n margin: 0;\n padding: 0;\n}\n.style-module_Page__w4JUS a,\n.style-module_Page__w4JUS a:hover,\n.style-module_Page__w4JUS a:focus,\n.style-module_Page__w4JUS a:active {\n text-decoration: none;\n}\n\n.style-module_Header__JEV7O {\n width: 100%;\n padding: 0px 24px;\n flex: 0 0 auto;\n}\n@media only screen and (min-width: 769px) {\n .style-module_Header__JEV7O {\n padding: 24px 48px 0;\n }\n}\n\n.style-module_Logo__l2guu {\n width: calc(100% - 24px);\n max-width: 200px;\n height: 64px;\n position: relative;\n user-select: none;\n cursor: pointer;\n font-size: 16px;\n display: flex;\n align-items: center;\n}\n.style-module_Logo__l2guu img {\n object-fit: contain;\n object-position: left;\n pointer-events: none;\n}\n\n.style-module_MerchantName__9mQ9g {\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_Content__tQJMn {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 0px 24px;\n text-align: center;\n width: 100%;\n max-width: 480px;\n margin: 0 auto;\n}\n\n.style-module_IconCircle__x2HKK {\n width: 64px;\n height: 64px;\n border-radius: 50%;\n background-color: var(--checkout-secondary-bg-color);\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 24px;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_Title__ZXbeP {\n color: var(--checkout-primary-text-color);\n font-size: 22px;\n font-weight: 500;\n line-height: 32px;\n margin-bottom: 8px;\n}\n\n.style-module_Description__QMX6n {\n color: var(--checkout-secondary-text-color);\n font-size: 16px;\n line-height: 24px;\n margin-bottom: 32px;\n text-wrap: balance;\n}\n\n.style-module_RefreshButton__C-5Es {\n width: 100%;\n max-width: 320px;\n}\n\n.style-module_BackLink__RfOES {\n margin-top: 16px;\n color: var(--checkout-secondary-text-color);\n font-size: 14px;\n line-height: 20px;\n cursor: pointer;\n background: none;\n border: none;\n padding: 0;\n text-decoration: none;\n}\n.style-module_BackLink__RfOES:hover {\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_Footer__Nz1wq {\n flex: 0 0 auto;\n width: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n flex-wrap: wrap;\n padding: 12.205px 0;\n}\n\n.style-module_FooterItem__K0oS7 {\n font-size: 14px;\n color: var(--checkout-secondary-text-color);\n cursor: pointer;\n user-select: none;\n}\n.style-module_FooterItem__K0oS7:hover {\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_FooterBullet__yKuLy {\n margin: 0 12px;\n color: var(--checkout-secondary-text-color);\n}');export{n as default};
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare type Props = {
3
+ className?: string;
4
+ };
5
+ declare const SVGRefresh: React.FC<Props>;
6
+ export default SVGRefresh;
@@ -0,0 +1 @@
1
+ import*as e from"react";var r=function(r){var t=r.className;return e.createElement("svg",{className:t,width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M24.5 14.0001C24.5021 16.4294 23.6618 18.7843 22.1223 20.6635C20.5827 22.5428 18.4391 23.83 16.0569 24.3059C13.6746 24.7817 11.201 24.4168 9.0576 23.2733C6.91421 22.1298 5.23365 20.2785 4.30229 18.0348C3.37093 15.791 3.24641 13.2938 3.94994 10.9685C4.65347 8.64329 6.14152 6.63393 8.16052 5.28287C10.1795 3.93181 12.6045 3.32265 15.0223 3.55918C17.4401 3.79572 19.7011 4.86331 21.42 6.58005L24.5 9.33338",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"}),e.createElement("path",{d:"M24.4993 3.5V9.33333H18.666",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",strokeLinejoin:"round"}))};export{r as default};
@@ -1 +1 @@
1
- import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as r}from"mobx-react-lite";var n=r((function(r){var n,o=r.vm;r.isSelected;var a=t.useRef(null),i=null===(n=o.tkPayResponse)||void 0===n?void 0:n.paymentPageUrl;return t.useEffect((function(){if(i){var e=function(e){console.log("event",e);var t=e.data||{};if("tkpay:resize"===t.type){console.log("data",t);var r=Number(t.height||0);a.current&&r>0&&(console.log("height",r),console.log("iframeRef.current",a.current),a.current.style.height="".concat(r,"px"))}};return window.addEventListener("message",e),function(){return window.removeEventListener("message",e)}}}),[i]),i?t.createElement("div",{style:e({},!o.showTkPayContainer&&{display:"none"})},t.createElement("iframe",{ref:a,src:i,id:"tkpay-payment-page",className:"responsive",title:"TKPay Payment",style:{width:"100%",height:"600px",border:"none"}})):null}));export{n as TkPay};
1
+ import{__assign as e,__awaiter as t,__generator as r}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as a}from"mobx-react-lite";var s=["https://sandbox-app.tkpay.com","https://app.tkpay.com"],i=a((function(a){var i,o,c=a.vm;a.isSelected;var l=n.useRef(null),u=n.useRef(!1),p=null===(i=c.tkPayResponse)||void 0===i?void 0:i.paymentPageUrl,d=null===(o=c.tkPayResponse)||void 0===o?void 0:o.callbackUrl;return n.useEffect((function(){u.current=!1}),[p,d]),n.useEffect((function(){if(p){var e=function(e){if(s.includes(e.origin)){var n=e.data||{};if("tkpay:resize"!==n.type){var a;"tkpay:success"===n.type&&n.payload&&(a=n.payload,t(void 0,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:if(!d||u.current)return[2];if(a.status&&"SUCCESS"!==a.status)return[2];u.current=!0,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:return t.sent(),[3,4];case 3:return e=t.sent(),u.current=!1,console.error("TkPay callback post failed",e),[3,4];case 4:return[2]}}))})))}else{var i=Number(n.height||0);l.current&&i>0&&(l.current.style.height="".concat(i,"px"))}}};return window.addEventListener("message",e),function(){return window.removeEventListener("message",e)}}}),[p,d]),p?n.createElement("div",{style:e({},!c.showTkPayContainer&&{display:"none"})},n.createElement("iframe",{ref:l,src:p,id:"tkpay-payment-page",className:"responsive",title:"TKPay Payment",style:{width:"100%",height:"600px",border:"none"}})):null}));export{i as TkPay};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import n from"react-tooltip";import a,{CheckoutStep as s}from"./model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as l}from"../../utils/currency.js";import{useTranslation as m}from"../../utils/i18n.js";import d from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as f,Coupon as g,CartSummary as v}from"./components/cart-summary/index.js";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{IkasThemeJsonPageType as h}from"@ikas/storefront-models";import"mobx";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"../../models/data/checkout/index.js";import"../../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"../../models/data/customer/address/index.js";import"../../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"../../models/data/order/address/region/index.js";import"../../models/data/order/address/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"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../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"@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{ContactForm as E}from"../../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{StepSuccess as y}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as P}from"../image/index.js";import N,{Step as O}from"./components/step-container/index.js";import{StockError as b}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import M from"./components/notification-box/index.js";import{FormItem as F}from"./components/form-item/index.js";import{FormItemType as T}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as I}from"../page/head.js";import A from"./components/offer-product/index.js";import L from"./components/offer-product/placeholder-offer-product.js";import B from"./components/svg/ikas.js";import D from"./style.module.scss.js";import{Analytics as U}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import V from"./components/svg/success-circle.js";import R from"./components/offer-product/offer-dots/index.js";import _ from"./components/offer-product/offer-arrows/index.js";import z from"./components/offer-product/useCampaignOffer.js";import G from"../../hooks/useDimension.js";var H=i((function(e){var t,i,l,d,p,u,f,g=e.checkout,E=e.checkoutSettings,N=e.customizationProps,O=e.returnPolicy,M=e.privacyPolicy,F=e.termsOfService,T=e.imprint,A=e.shippingPolicy,R=m().t,_=r(),G=o.useState(Date.now()),H=G[0],X=G[1],K=o.useState((function(){return new a(g,E,_,O,M,F,T,A,R,N||{})}))[0];o.useEffect((function(){X(Date.now())}),[g.campaignOffers,K.campaignOffers,K.isCampaignOfferLoaded]);var ee=z(K),te=ee.setShowDetailPage,oe=ee.isPopupShowIndexPage,ie=ee.isShowSuccessPageMiddlePhase;o.useMemo((function(){return Date.now()}),[]);return K.step,s.PAYMENT,o.useEffect((function(){var e;K.checkoutSettings.isAccountRequired&&!K.checkout.hasCustomer&&_.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),new URLSearchParams(window.location.search).get("step")!==s.SUCCESS&&(K.checkoutSettings.isAccountRequired&&(null===(e=K.checkout.customer)||void 0===e?void 0:e.isGuestCheckout)||U.beginCheckout(K.checkout)),U.pageView(h.CHECKOUT)}),[]),o.useEffect((function(){K.customizationProps=N,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==e?void 0:e.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==e?void 0:e.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==e?void 0:e.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==e?void 0:e.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==e?void 0:e.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==e?void 0:e.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==e?void 0:e.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==e?void 0:e.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==e?void 0:e.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==e?void 0:e.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==e?void 0:e.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==e?void 0:e.campaignOffersMiddlePhaseOverlayColor)||"#292727ad")}(N)}),[N]),o.useEffect((function(){var e=document.querySelector(".ikas-storefront-widget");e&&e.remove()}),[]),K.isCheckoutLoaded&&K.store.customerStore.initialized?K.checkout.hasCustomer&&(null===(t=K.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(i=K.checkout.customer)||void 0===i?void 0:i.id)?(_.push("/account/login?redirect="+encodeURIComponent(K.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(I,{pageType:h.CHECKOUT,pageTitle:((null===(l=K.merchantSettings)||void 0===l?void 0:l.merchantName)||"")+" - "+R("checkout-page:securePayment"),pageDescription:R("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:D.CheckoutPage},ie?o.createElement("div",{className:D.FullPageOfferMain},o.createElement("div",{className:D.FullPageOfferContainer},o.createElement("div",{className:D.LogoMain},(null===(d=K.customizationProps)||void 0===d?void 0:d.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.customizationProps.logo,sizes:"360px"})):(null===(p=K.merchantSettings)||void 0===p?void 0:p.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:K.merchantSettings.logo,sizes:"360px"})):(null===(u=K.merchantSettings)||void 0===u?void 0:u.merchantName)||""),o.createElement("div",{className:D.OfferSuccessInfo},o.createElement("div",null,o.createElement("div",{className:D.OfferSuccessHeader},o.createElement(V,{className:D.SuccessCircle}),o.createElement("span",{className:D.SuccessTitle},R("checkout-page:orderSuccessShortTitle"))),o.createElement("div",{className:D.OfferOrderInfoMain},o.createElement("div",{className:D.InfoTitle},R("checkout-page:orderNoAndDate"),":"),o.createElement("div",{className:D.InfoText},"#"+(K.checkout.orderNumber||"")," ",K.checkout.dateStr))),o.createElement("div",null,o.createElement(w,{classes:D.OfferButton,isLine:!0,text:R("checkout-page:actions.goOrderDetailPage"),onClick:function(){te(!1)}}))),o.createElement("div",null,o.createElement(Z,{vm:K,key:H})))):null,o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:D.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[D.Left].join(" ")},o.createElement("div",{className:D.LeftContent},o.createElement("div",null,o.createElement(W,{vm:K}),K.hasStockError&&o.createElement("div",{className:D.ErrorContainer},o.createElement(b,{vm:K,error:K.error})),!K.hasStockError&&o.createElement(o.Fragment,null,K.step!==s.SUCCESS&&o.createElement(v,{vm:K,allowExpand:!0}),K.step===s.SUCCESS?o.createElement(y,{vm:K}):o.createElement(o.Fragment,null,!!(null===(f=K.customizationProps)||void 0===f?void 0:f.showCampaignOffersDesign)&&c.getIsEditor()&&o.createElement(L,{vm:K}),oe&&o.createElement("div",{className:[D.MiddlePhaseOverlay,oe?D.MiddlePhaseOverlayPopup:""].join(" ")}),K.campaignOffers&&!!K.campaignOffers.length&&K.isCampaignOfferLoaded&&o.createElement($,{key:H,vm:K}),K.isCouponCodeRequirementOpen&&o.createElement(q,{vm:K}),o.createElement(Y,{vm:K}))),o.createElement("div",{className:D.Space})),o.createElement(J,{vm:K}))),o.createElement("div",{className:D.Right},o.createElement("div",{className:D.RightContent},o.createElement(v,{vm:K}),!K.isPoweredByHidden&&o.createElement("div",{className:D.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!K.policyModalText&&o.createElement(x,{title:K.policyModalTitle,modalContent:K.policyModalText,onClose:function(){K.policyModalText=""},isPolicyModal:!0}),K.isContactModalVisible&&o.createElement(Q,{vm:K,setVisible:K.setContactModalVisible}),K.mpVM.isOtpModalVisible&&o.createElement(k,{vm:K,visible:K.mpVM.isOtpModalVisible,type:K.mpVM.otpModalType,onClose:K.mpVM.hideOtpModal}),K.mpVM.isResponseModalVisible&&o.createElement(C,{visible:K.mpVM.isResponseModalVisible,text:K.mpVM.mfsResponseModalText,onClose:K.mpVM.onResponseModalClose}),K.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:K.mpVM.isSuccessModalVisible,type:K.mpVM.successModalType,onClose:K.mpVM.onSuccessModalClose}))):o.createElement(S,null)})),W=i((function(e){var t,i,r,n,a=e.vm,s=c.getCurrentRouting(),l=(null==s?void 0:s.path)?"/".concat(s.path):"/",d=m().t;return o.createElement("div",{className:D.Header},o.createElement("a",{href:l},(null===(t=a.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.customizationProps.logo,sizes:"360px"})):(null===(i=a.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:D.Logo},o.createElement(P,{layout:"fill",image:a.merchantSettings.logo,sizes:"360px"})):(null===(r=a.merchantSettings)||void 0===r?void 0:r.merchantName)||""),!a.checkout.hasCustomer&&!a.isOpenEditOrderWithTransaction&&!a.checkout.edited&&o.createElement("div",{className:D.LoginText},o.createElement("span",{className:D.LoginCta},d("checkout-page:alreadyHaveAnAccount")),o.createElement("a",{href:a.getGoToLoginHref(),className:D.LoginBtn},d("checkout-page:actions.login"))),(a.checkout.hasCustomer||a.isOpenEditOrderWithTransaction||a.checkout.edited)&&o.createElement("div",{className:D.CustomerInfo},o.createElement("div",{className:D.Name},a.checkout.customerFullName),o.createElement("div",{className:D.Email},null===(n=a.checkout.customer)||void 0===n?void 0:n.email)))})),q=i((function(e){var t=e.vm,i=m().t,r=o.useState(!1),n=r[0],a=r[1],s=o.useState(null),c=s[0],l=s[1],d=G().isMobile,p=o.useMemo((function(){switch(c){case f.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case f.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");case f.COUPON_APPLIED_WITHOUT_DISCOUNT:return i("checkout-page:couponInvalidForCartItems");case f.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return i("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[c]);return o.createElement("div",{className:D.CouponContainer},n&&o.createElement("div",{className:D.NotificationContainer},o.createElement(M,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:p,onClose:function(){a(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:n?12:0}},o.createElement(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:a,setCouponErrorCode:l,showOnlyMobile:!0,isMobile:d})))})),Y=i((function(e){var t=e.vm,i=m().t,r=o.useMemo((function(){switch(t.step){case s.INFO:return o.createElement(d,{vm:t});case s.SHIPPING:return o.createElement(p,{vm:t});case s.PAYMENT:return o.createElement(u,{vm:t});case s.SUCCESS:return o.createElement(y,{vm:t})}}),[t,t.step]),n=G().isMobile,a=[new O(i("checkout-page:address"),t.step===s.INFO,t.step!==s.INFO,t.step!==s.INFO?o.createElement("div",{className:D.AdressStepInfo},o.createElement(X,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==s.INFO?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(X,{vm:t})):void 0),new O(i("checkout-page:payment"),t.step===s.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new O(i("checkout-page:shipping"),t.step===s.SHIPPING,t.step===s.PAYMENT,t.step===s.PAYMENT?o.createElement("div",{className:D.AdressStepInfo},o.createElement(K,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&!t.isManualOrderWithShippingLines&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:D.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===s.PAYMENT?o.createElement("div",{className:D.AddressStepInfoMobile},o.createElement(K,{vm:t})):void 0)),o.createElement(N,{steps:a,stepContent:r,step:t.step,hasTopMargin:t.isCouponCodeRequirementOpen||t.campaignOffers&&!!t.campaignOffers.length&&t.isCampaignOfferLoaded,vm:t,isMobile:n})})),X=i((function(e){var t,i,r,n,a,s,c,l,d,p=e.vm,u=m().t,f=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(n=p.checkout.shippingAddress)||void 0===n?void 0:n.lastName)||"");return o.createElement("div",{className:D.Address},o.createElement("div",{className:[D.Text,D.WithMBottom].join(" ")},(null===(a=p.checkout.customer)||void 0===a?void 0:a.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:D.Text},f):o.createElement(o.Fragment,null,o.createElement("div",{className:D.Text},u("checkout-page:receiver")),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},f)),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(s=p.checkout.billingAddress)||void 0===s?void 0:s.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[D.Text,D.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[D.Text,D.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(d=p.checkout.shippingAddress)||void 0===d?void 0:d.addressText))})),K=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:D.LightText}," / "+(0===t.checkout.shippingLines[0].finalPrice?i("checkout-page:free"):l(t.checkout.shippingLines[0].finalPrice,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),J=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:D.Footer},o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:D.FooterBullet},"•"),o.createElement("div",{className:D.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),Q=i((function(i){var r,n,a,s=i.vm,c=i.setVisible,l=m().t,d=o.useState(!1),p=d[0],u=d[1],f=o.useState(!1),g=f[0],v=f[1],h=o.useState(new E({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];h.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",h.firstName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.firstName)||"",h.lastName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.lastName)||"";var y=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return g?[2,c(!1)]:(u(!0),[4,h.saveContactForm()]);case 1:return e.sent()&&v(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(x,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,g&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(M,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(F,{name:"message",type:T.TEXT_AREA,label:"",value:h.message||"",onChange:h.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:l(g?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!h.message,onClick:y})),onClose:function(){return c(!1)}})})),Z=i((function(e){var t=e.vm,i=z(t),r=i.setActiveIndex,n=i.handlePrev,a=i.handleNext,s=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:D.CampaignOfferMain},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var c;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:s,offersLength:(null===(c=t.campaignOffers)||void 0===c?void 0:c.length)||0,handlePrev:n,handleNext:a,setActiveIndex:function(e){return r(e)},desktopMiddlePhase:!0,step:t.step})}))),t.campaignOffers.length>1&&o.createElement(_,{handlePrev:n,handleNext:a}),t.campaignOffers.length>1&&o.createElement(R,{vm:t,activeIndex:s})):null})),$=i((function(e){var t=e.vm,i=z(t),r=i.setActiveIndex,n=i.setIsActiveOverlay,a=i.handlePrev,s=i.handleNext,c=i.isPopupClosedIndexPage,l=i.isPopupShowIndexPage,m=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:[D.CampaignOfferMain,l?D.OverlayPopupMain:""].join(" ")},o.createElement("div",{className:D.OfferSlider},t.campaignOffers.map((function(e,i){var d;return o.createElement(A,{vm:t,campaignOffer:e,index:i,activeIndex:m,offersLength:(null===(d=t.campaignOffers)||void 0===d?void 0:d.length)||0,handlePrev:a,handleNext:s,setActiveIndex:function(e){return r(e)},step:t.step,isPopupClosed:c,isPopupShow:l,closePopup:function(){return n(!1)},showPopup:function(){return n(!0)}})}))),t.campaignOffers.length>1&&o.createElement(_,{handlePrev:a,handleNext:s}),t.campaignOffers.length>1&&o.createElement(R,{isPopupShow:l,vm:t,activeIndex:m})):null}));export{H as default};
1
+ import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import n from"react-tooltip";import a,{CheckoutStep as s}from"./model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as l}from"../../utils/currency.js";import{useTranslation as m}from"../../utils/i18n.js";import d from"./steps/step-info/index.js";import{CheckoutStepShipping as p}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as u}from"./steps/step-payment/index.js";import{CouponErrorCode as f,Coupon as g,CartSummary as v}from"./components/cart-summary/index.js";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{IkasThemeJsonPageType as h}from"@ikas/storefront-models";import"mobx";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"../../models/data/checkout/index.js";import"../../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"../../models/data/customer/address/index.js";import"../../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"../../models/data/order/address/region/index.js";import"../../models/data/order/address/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"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../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"@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{ContactForm as E}from"../../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{StepSuccess as y}from"./steps/step-success/index.js";import{Modal as x}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import C from"./components/master-pass/modal-response/index.js";import j from"./components/master-pass/modal-success/index.js";import{Image as P}from"../image/index.js";import N,{Step as O}from"./components/step-container/index.js";import{StockError as S}from"./components/error/stock-error/index.js";import{FullscreenLoading as b}from"./components/fullscreen-loading/index.js";import{CheckoutLoadFailed as M,getCheckoutHomeHref as F}from"./components/checkout-load-failed/index.js";import T from"./components/notification-box/index.js";import{FormItem as w}from"./components/form-item/index.js";import{FormItemType as I}from"./components/form-item/model.js";import{Button as A}from"./components/button/index.js";import{IkasPageHead as L}from"../page/head.js";import B from"./components/offer-product/index.js";import D from"./components/offer-product/placeholder-offer-product.js";import U from"./components/svg/ikas.js";import V from"./style.module.scss.js";import{Analytics as R}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import _ from"./components/svg/success-circle.js";import z from"./components/offer-product/offer-dots/index.js";import H from"./components/offer-product/offer-arrows/index.js";import G from"./components/offer-product/useCampaignOffer.js";import W from"../../hooks/useDimension.js";var q=i((function(e){var t,i,l,d,p,u,f,g,E,N,O=e.checkout,T=e.checkoutSettings,w=e.customizationProps,I=e.returnPolicy,B=e.privacyPolicy,z=e.termsOfService,H=e.imprint,W=e.shippingPolicy,q=m().t,J=r(),Q=o.useState(Date.now()),oe=Q[0],ie=Q[1],re=o.useState((function(){return new a(O,T,J,I,B,z,H,W,q,w||{})}))[0];o.useEffect((function(){ie(Date.now())}),[O.campaignOffers,re.campaignOffers,re.isCampaignOfferLoaded]);var ne=G(re),ae=ne.setShowDetailPage,se=ne.isPopupShowIndexPage,ce=ne.isShowSuccessPageMiddlePhase;o.useMemo((function(){return Date.now()}),[]);return re.step,s.PAYMENT,o.useEffect((function(){var e;re.checkoutSettings.isAccountRequired&&!re.checkout.hasCustomer&&J.push("/account/login?redirect="+encodeURIComponent(re.checkoutUrl)),new URLSearchParams(window.location.search).get("step")!==s.SUCCESS&&(re.checkoutSettings.isAccountRequired&&(null===(e=re.checkout.customer)||void 0===e?void 0:e.isGuestCheckout)||R.beginCheckout(re.checkout)),R.pageView(h.CHECKOUT)}),[]),o.useEffect((function(){re.customizationProps=w,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==e?void 0:e.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==e?void 0:e.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==e?void 0:e.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==e?void 0:e.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==e?void 0:e.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==e?void 0:e.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==e?void 0:e.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==e?void 0:e.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==e?void 0:e.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==e?void 0:e.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==e?void 0:e.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==e?void 0:e.campaignOffersMiddlePhaseOverlayColor)||"#292727ad")}(w)}),[w]),o.useEffect((function(){var e=document.querySelector(".ikas-storefront-widget");e&&e.remove()}),[]),re.isCheckoutLoadFailed?o.createElement(M,{logo:(null===(t=re.customizationProps)||void 0===t?void 0:t.logo)||(null===(i=re.merchantSettings)||void 0===i?void 0:i.logo),merchantName:null===(l=re.merchantSettings)||void 0===l?void 0:l.merchantName,backHref:F(),returnPolicy:re.returnPolicy,privacyPolicy:re.privacyPolicy,termsOfService:re.termsOfService,imprint:re.imprint,shippingPolicy:re.shippingPolicy}):re.isCheckoutLoaded&&re.store.customerStore.initialized?re.checkout.hasCustomer&&(null===(d=re.store.customerStore.customer)||void 0===d?void 0:d.id)!==(null===(p=re.checkout.customer)||void 0===p?void 0:p.id)?(J.push("/account/login?redirect="+encodeURIComponent(re.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(L,{pageType:h.CHECKOUT,pageTitle:((null===(u=re.merchantSettings)||void 0===u?void 0:u.merchantName)||"")+" - "+q("checkout-page:securePayment"),pageDescription:q("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:V.CheckoutPage},ce?o.createElement("div",{className:V.FullPageOfferMain},o.createElement("div",{className:V.FullPageOfferContainer},o.createElement("div",{className:V.LogoMain},(null===(f=re.customizationProps)||void 0===f?void 0:f.logo)?o.createElement("div",{className:V.Logo},o.createElement(P,{layout:"fill",image:re.customizationProps.logo,sizes:"360px"})):(null===(g=re.merchantSettings)||void 0===g?void 0:g.logo)?o.createElement("div",{className:V.Logo},o.createElement(P,{layout:"fill",image:re.merchantSettings.logo,sizes:"360px"})):(null===(E=re.merchantSettings)||void 0===E?void 0:E.merchantName)||""),o.createElement("div",{className:V.OfferSuccessInfo},o.createElement("div",null,o.createElement("div",{className:V.OfferSuccessHeader},o.createElement(_,{className:V.SuccessCircle}),o.createElement("span",{className:V.SuccessTitle},q("checkout-page:orderSuccessShortTitle"))),o.createElement("div",{className:V.OfferOrderInfoMain},o.createElement("div",{className:V.InfoTitle},q("checkout-page:orderNoAndDate"),":"),o.createElement("div",{className:V.InfoText},"#"+(re.checkout.orderNumber||"")," ",re.checkout.dateStr))),o.createElement("div",null,o.createElement(A,{classes:V.OfferButton,isLine:!0,text:q("checkout-page:actions.goOrderDetailPage"),onClick:function(){ae(!1)}}))),o.createElement("div",null,o.createElement(ee,{vm:re,key:oe})))):null,o.createElement(n,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:V.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:[V.Left].join(" ")},o.createElement("div",{className:V.LeftContent},o.createElement("div",null,o.createElement(Y,{vm:re}),re.hasStockError&&o.createElement("div",{className:V.ErrorContainer},o.createElement(S,{vm:re,error:re.error})),!re.hasStockError&&o.createElement(o.Fragment,null,re.step!==s.SUCCESS&&o.createElement(v,{vm:re,allowExpand:!0}),re.step===s.SUCCESS?o.createElement(y,{vm:re}):o.createElement(o.Fragment,null,!!(null===(N=re.customizationProps)||void 0===N?void 0:N.showCampaignOffersDesign)&&c.getIsEditor()&&o.createElement(D,{vm:re}),se&&o.createElement("div",{className:[V.MiddlePhaseOverlay,se?V.MiddlePhaseOverlayPopup:""].join(" ")}),re.campaignOffers&&!!re.campaignOffers.length&&re.isCampaignOfferLoaded&&o.createElement(te,{key:oe,vm:re}),re.isCouponCodeRequirementOpen&&o.createElement(X,{vm:re}),o.createElement(K,{vm:re}))),o.createElement("div",{className:V.Space})),o.createElement(Z,{vm:re}))),o.createElement("div",{className:V.Right},o.createElement("div",{className:V.RightContent},o.createElement(v,{vm:re}),!re.isPoweredByHidden&&o.createElement("div",{className:V.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(U,null))))),!!re.policyModalText&&o.createElement(x,{title:re.policyModalTitle,modalContent:re.policyModalText,onClose:function(){re.policyModalText=""},isPolicyModal:!0}),re.isContactModalVisible&&o.createElement($,{vm:re,setVisible:re.setContactModalVisible}),re.mpVM.isOtpModalVisible&&o.createElement(k,{vm:re,visible:re.mpVM.isOtpModalVisible,type:re.mpVM.otpModalType,onClose:re.mpVM.hideOtpModal}),re.mpVM.isResponseModalVisible&&o.createElement(C,{visible:re.mpVM.isResponseModalVisible,text:re.mpVM.mfsResponseModalText,onClose:re.mpVM.onResponseModalClose}),re.mpVM.isSuccessModalVisible&&o.createElement(j,{visible:re.mpVM.isSuccessModalVisible,type:re.mpVM.successModalType,onClose:re.mpVM.onSuccessModalClose}))):o.createElement(b,null)})),Y=i((function(e){var t,i,r,n,a=e.vm,s=c.getCurrentRouting(),l=(null==s?void 0:s.path)?"/".concat(s.path):"/",d=m().t;return o.createElement("div",{className:V.Header},o.createElement("a",{href:l},(null===(t=a.customizationProps)||void 0===t?void 0:t.logo)?o.createElement("div",{className:V.Logo},o.createElement(P,{layout:"fill",image:a.customizationProps.logo,sizes:"360px"})):(null===(i=a.merchantSettings)||void 0===i?void 0:i.logo)?o.createElement("div",{className:V.Logo},o.createElement(P,{layout:"fill",image:a.merchantSettings.logo,sizes:"360px"})):(null===(r=a.merchantSettings)||void 0===r?void 0:r.merchantName)||""),!a.checkout.hasCustomer&&!a.isOpenEditOrderWithTransaction&&!a.checkout.edited&&o.createElement("div",{className:V.LoginText},o.createElement("span",{className:V.LoginCta},d("checkout-page:alreadyHaveAnAccount")),o.createElement("a",{href:a.getGoToLoginHref(),className:V.LoginBtn},d("checkout-page:actions.login"))),(a.checkout.hasCustomer||a.isOpenEditOrderWithTransaction||a.checkout.edited)&&o.createElement("div",{className:V.CustomerInfo},o.createElement("div",{className:V.Name},a.checkout.customerFullName),o.createElement("div",{className:V.Email},null===(n=a.checkout.customer)||void 0===n?void 0:n.email)))})),X=i((function(e){var t=e.vm,i=m().t,r=o.useState(!1),n=r[0],a=r[1],s=o.useState(null),c=s[0],l=s[1],d=W().isMobile,p=o.useMemo((function(){switch(c){case f.COUPON_CODE_NOT_EXIST:return i("checkout-page:giftCodeErrorDescription");case f.COUPON_CODE_NOT_EXIST_FOR_GUESS:return i("checkout-page:mustBeSignInToApplyCampaign");case f.COUPON_APPLIED_WITHOUT_DISCOUNT:return i("checkout-page:couponInvalidForCartItems");case f.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return i("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[c]);return o.createElement("div",{className:V.CouponContainer},n&&o.createElement("div",{className:V.NotificationContainer},o.createElement(T,{type:"warning",title:i("checkout-page:giftCodeErrorTitle"),content:p,onClose:function(){a(!1),l(null)},ignoreScroll:!0})),o.createElement("div",{style:{marginTop:n?12:0}},o.createElement(g,{vm:t,isOpenCouponCode:!0,isAddingCoupon:!0,setAddingCoupon:function(){},setCouponError:a,setCouponErrorCode:l,showOnlyMobile:!0,isMobile:d})))})),K=i((function(e){var t=e.vm,i=m().t,r=o.useMemo((function(){switch(t.step){case s.INFO:return o.createElement(d,{vm:t});case s.SHIPPING:return o.createElement(p,{vm:t});case s.PAYMENT:return o.createElement(u,{vm:t});case s.SUCCESS:return o.createElement(y,{vm:t})}}),[t,t.step]),n=W().isMobile,a=[new O(i("checkout-page:address"),t.step===s.INFO,t.step!==s.INFO,t.step!==s.INFO?o.createElement("div",{className:V.AdressStepInfo},o.createElement(J,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&o.createElement("div",{className:V.EditBtn,onClick:t.onBackToInfoClick},i("checkout-page:actions.edit"))):void 0,t.step!==s.INFO?o.createElement("div",{className:V.AddressStepInfoMobile},o.createElement(J,{vm:t})):void 0),new O(i("checkout-page:payment"),t.step===s.PAYMENT,!1)];return"address"!==t.deliveryMethod||t.isDigitalOnly||a.splice(1,0,new O(i("checkout-page:shipping"),t.step===s.SHIPPING,t.step===s.PAYMENT,t.step===s.PAYMENT?o.createElement("div",{className:V.AdressStepInfo},o.createElement(Q,{vm:t}),!(t.isUpsellOrder||t.isOpenEditOrderWithTransaction)&&!t.isManualOrderWithShippingLines&&(t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1||t.checkoutSettings.isGiftPackageEnabled)&&o.createElement("div",{className:V.EditBtn,onClick:t.onBackToShippingClick},i("checkout-page:actions.edit"))):void 0,t.step===s.PAYMENT?o.createElement("div",{className:V.AddressStepInfoMobile},o.createElement(Q,{vm:t})):void 0)),o.createElement(N,{steps:a,stepContent:r,step:t.step,hasTopMargin:t.isCouponCodeRequirementOpen||t.campaignOffers&&!!t.campaignOffers.length&&t.isCampaignOfferLoaded,vm:t,isMobile:n})})),J=i((function(e){var t,i,r,n,a,s,c,l,d,p=e.vm,u=m().t,f=p.isDigitalOnly?((null===(t=p.checkout.billingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(i=p.checkout.billingAddress)||void 0===i?void 0:i.lastName)||""):((null===(r=p.checkout.shippingAddress)||void 0===r?void 0:r.firstName)||"")+" "+((null===(n=p.checkout.shippingAddress)||void 0===n?void 0:n.lastName)||"");return o.createElement("div",{className:V.Address},o.createElement("div",{className:[V.Text,V.WithMBottom].join(" ")},(null===(a=p.checkout.customer)||void 0===a?void 0:a.email)||""),"address"===p.deliveryMethod?o.createElement("div",{className:V.Text},f):o.createElement(o.Fragment,null,o.createElement("div",{className:V.Text},u("checkout-page:receiver")),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},f)),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},p.isDigitalOnly?null===(s=p.checkout.billingAddress)||void 0===s?void 0:s.phone:null===(c=p.checkout.shippingAddress)||void 0===c?void 0:c.phone),"in-store"===p.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[V.Text,V.WithMTop].join(" ")},u("checkout-page:pickUpLocation"))),o.createElement("div",{className:[V.Text,V.Gray].join(" ")},p.isDigitalOnly?null===(l=p.checkout.billingAddress)||void 0===l?void 0:l.addressText:null===(d=p.checkout.shippingAddress)||void 0===d?void 0:d.addressText))})),Q=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:V.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:V.LightText}," / "+(0===t.checkout.shippingLines[0].finalPrice?i("checkout-page:free"):l(t.checkout.shippingLines[0].finalPrice,t.checkout.currencyCode,t.checkout.currencySymbol)))):i("checkout-page:standartShipping"))})),Z=i((function(e){var t=e.vm,i=m().t;return o.createElement("div",{className:V.Footer},o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},i("checkout-page:returnPolicy")),o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},i("checkout-page:privacyPolicy")),o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},i("checkout-page:termsOfService")),t.imprint&&o.createElement(o.Fragment,null,o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:imprint"),t.policyModalText=t.imprint}},i("checkout-page:imprint"))),t.shippingPolicy&&o.createElement(o.Fragment,null,o.createElement("div",{className:V.FooterBullet},"•"),o.createElement("div",{className:V.FooterItem,onClick:function(){t.policyModalTitle=i("checkout-page:shippingPolicy"),t.policyModalText=t.shippingPolicy}},i("checkout-page:shippingPolicy"))))})),$=i((function(i){var r,n,a,s=i.vm,c=i.setVisible,l=m().t,d=o.useState(!1),p=d[0],u=d[1],f=o.useState(!1),g=f[0],v=f[1],h=o.useState(new E({message:{requiredRule:"",emailRule:"",minRule:""}}))[0];h.email=(null===(r=s.checkout.customer)||void 0===r?void 0:r.email)||"",h.firstName=(null===(n=s.checkout.customer)||void 0===n?void 0:n.firstName)||"",h.lastName=(null===(a=s.checkout.customer)||void 0===a?void 0:a.lastName)||"";var y=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return g?[2,c(!1)]:(u(!0),[4,h.saveContactForm()]);case 1:return e.sent()&&v(!0),u(!1),[2]}}))}))}),[p]);return o.createElement(x,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,g&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(T,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(w,{name:"message",type:I.TEXT_AREA,label:"",value:h.message||"",onChange:h.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(A,{style:{width:"100%",marginTop:"24px"},text:l(g?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:p,isDisabled:!h.message,onClick:y})),onClose:function(){return c(!1)}})})),ee=i((function(e){var t=e.vm,i=G(t),r=i.setActiveIndex,n=i.handlePrev,a=i.handleNext,s=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:V.CampaignOfferMain},o.createElement("div",{className:V.OfferSlider},t.campaignOffers.map((function(e,i){var c;return o.createElement(B,{vm:t,campaignOffer:e,index:i,activeIndex:s,offersLength:(null===(c=t.campaignOffers)||void 0===c?void 0:c.length)||0,handlePrev:n,handleNext:a,setActiveIndex:function(e){return r(e)},desktopMiddlePhase:!0,step:t.step})}))),t.campaignOffers.length>1&&o.createElement(H,{handlePrev:n,handleNext:a}),t.campaignOffers.length>1&&o.createElement(z,{vm:t,activeIndex:s})):null})),te=i((function(e){var t=e.vm,i=G(t),r=i.setActiveIndex,n=i.setIsActiveOverlay,a=i.handlePrev,s=i.handleNext,c=i.isPopupClosedIndexPage,l=i.isPopupShowIndexPage,m=i.activeIndex;return t.campaignOffers&&t.campaignOffers.length&&t.isCampaignOfferLoaded?o.createElement("div",{className:[V.CampaignOfferMain,l?V.OverlayPopupMain:""].join(" ")},o.createElement("div",{className:V.OfferSlider},t.campaignOffers.map((function(e,i){var d;return o.createElement(B,{vm:t,campaignOffer:e,index:i,activeIndex:m,offersLength:(null===(d=t.campaignOffers)||void 0===d?void 0:d.length)||0,handlePrev:a,handleNext:s,setActiveIndex:function(e){return r(e)},step:t.step,isPopupClosed:c,isPopupShow:l,closePopup:function(){return n(!1)},showPopup:function(){return n(!0)}})}))),t.campaignOffers.length>1&&o.createElement(H,{handlePrev:a,handleNext:s}),t.campaignOffers.length>1&&o.createElement(z,{isPopupShow:l,vm:t,activeIndex:m})):null}));export{q as default};
@@ -35,6 +35,7 @@ export default class CheckoutViewModel {
35
35
  storefront?: IkasStorefront | null;
36
36
  router: NextRouter;
37
37
  isCheckoutLoaded: boolean;
38
+ isCheckoutLoadFailed: boolean;
38
39
  isErrorsVisible: boolean;
39
40
  isStepLoading: boolean;
40
41
  isTermsAndConditionsChecked: boolean;
@@ -114,6 +115,7 @@ export default class CheckoutViewModel {
114
115
  t: TFunction;
115
116
  constructor(checkout: IkasCheckout, checkoutSettings: IkasCheckoutSettings, router: NextRouter, returnPolicy: string, privacyPolicy: string, termsOfService: string, imprint: string, shippingPolicy: string, t: TFunction, customizationProps: IkasCheckoutCustomizationProps);
116
117
  init: () => Promise<void>;
118
+ private waitForCountrySettingsOrFail;
117
119
  initStep: () => Promise<void>;
118
120
  getOpenEditOrderTransaction: () => Promise<void>;
119
121
  getSuccessTransaction: () => Promise<void>;
@@ -1 +1 @@
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{IkasCartCreatedBy as a,IkasCouponCodeRequirement as c,IkasCorporateInvoiceRequirement as d,IkasPaymentMethodType as u,IkasPaymentGatewayType as l,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 k}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 I}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 C}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 R}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as M}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}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 L from"../../store/customer/api.js";import G from"../../store/checkout/index.js";import j from"../../store/cart/api.js";import _,{MFS_ELEMENT_ID as D,MFS_SCRIPT_URL as x}from"./modelMasterPass.js";import U from"../../store/product/index.js";import{MILES_SMILES_CURRENCY_CODE as F,TransactionCardAssociationEnum as V,MILES_SMILES_CARD_GATEWAY_CODE as B,SaveCartInput as Y,CheckStocksLineInput as H,getLoyaltyCustomerInfo as K,listSpendingMethodsByCartId as Z,LoyaltyProgramPointEarningTypeEnum as W,listEarningMethods as z,getMilesSmilesDetails as q,CampaignOfferTargetPageTypeEnum as Q}from"@ikas/storefront-api";import{IkasBaseStore as X}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as J}from"@ikas/storefront-config";import{Analytics as $}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import ee from"../../models/data/order/address/ikas-localized-order-address.js";import te from"../../store/location/index.js";import{isEqual as ie,getCookieValue as se,getOpenAiAttributionMetadata as ne}from"../../utils/helper.js";import{readMilesSmilesBindResult as re}from"../../utils/miles-smiles.js";import oe from"../../analytics/ikasV3.js";import{suggestEmailCorrection as ae}from"@ikas/storefront-model-functions";var ce,de,ue,le=/^\d+$/,he=/^3[47]/,pe="undefined"==typeof localStorage,me=((ce={})[F]=.25,ce),fe=["miles_smiles_rate","miles_rate"],ge=["UNAUTHORIZED","AUTHORIZATION_REQUIRED","MILES_SMILES_LOGIN_REQUIRED","MILES_SMILES_MEMBER_MISMATCH","EXTERNAL_ACCOUNT_MEMBER_MISMATCH"],ye=["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"],ve=function(e){return!!e&&(e.startsWith("MILES_")||e.startsWith("EXTERNAL_ACCOUNT_")||"INVALID_MILES"===e)},Se=function(){function ce(a,d,p,A,E,F,V,B,ae,ce){var le=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=de.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.milesToRedeem=0,this.isMilesSmilesLoginRequired=!1,this.isMilesSmilesUnavailable=!1,this.isMilesSmilesBindLoading=!1,this.milesSmilesDetails=null,this.milesSmilesError=null,this.milesSmilesBindLanding=null,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.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(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,X.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,4];case 3:t.sent(),t.label=4;case 4:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 5:return t.sent(),[2]}}))}))},this.initStep=function(){return t(le,void 0,void 0,(function(){var t,s,n,r,o,a,d;return i(this,(function(i){switch(i.label){case 0:if(J.getIsEditor())return this.step=de.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.milesSmilesBindLanding=re(),s){if(this.step=s,this.step===de.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(de.INFO)];if(this.step!==de.PAYMENT||this.canProceedToPayment){if(this.step===de.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(de.INFO)];if(![de.INFO,de.SUCCESS,de.SHIPPING,de.PAYMENT].includes(this.step))return[2,this.changeStep(de.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(de.INFO)]:[2,this.changeStep(de.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==de.SHIPPING&&this.step!==de.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new I(e(e({},this.checkoutSettings),{couponCodeRequirement:c.DEFAULT}))),this.step!==de.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:return this.step!==de.SHIPPING||1!==(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=de.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==de.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==de.SUCCESS||this.checkout.orderPaymentStatus!==f.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ue.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==de.PAYMENT&&this.step!==de.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:ue.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ue.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===de.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(de.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&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),i.label=25;case 25:return n&&(this.error={type:ue.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,$.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,L.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(le,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,L.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.saveCart=function(){return t(le,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,h,p,f,g,y,v;return i(this,(function(i){switch(i.label){case 0:return e=new Y(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!==de.INFO&&this.step!==de.SHIPPING&&this.step!==de.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===de.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===(u=null===(d=e.shippingAddress)||void 0===d?void 0:d.city)||void 0===u?void 0:u.name)&&(e.shippingAddress.city.name="-"),null===(null===(h=null===(l=e.billingAddress)||void 0===l?void 0:l.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,j.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:ue.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(y=s.extensions)||void 0===y?void 0:y.code)?{type:ue.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(v=s.extensions)||void 0===v?void 0:v.code)?{type:ue.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:ue.API_ERROR,data:t.firstErrorMessage};return[2,t.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(le,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(le,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,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=J.getStockLocationIds())||void 0===p?void 0:p.length)?J.getStockLocationIds():null,[4,G.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:ue.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,u=r;d<u.length;d++)l=u[d],a(l);throw{type:ue.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(le,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){le.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(le,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,X.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(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,G.getAvailableShippingCountries({salesChannelId:J.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(le,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return J.getPickupStockLocationIds()?[4,G.listStockLocation({id:{in:J.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:ue.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(le,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return J.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,G.getAvailableStockLocations({lines:e.map((function(e){return new H(e)})),stockLocationIdList:J.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ue.API_ERROR},[2];s=J.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=le.shippingCountryIds)||void 0===e?void 0:e.length)||(le.error={type:ue.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;le.deliveryMethod!==e&&("address"===e&&(le.checkout.stockLocationId=null,(null===(t=le.customerAddresses)||void 0===t?void 0:t.length)?le.onSelectedShippingAddressIdChange(le.customerAddresses[0].id||"-1"):(le.checkout.shippingAddress=new ee,le.checkout.shippingAddress.countrySettings=le.countrySettings,le.checkout.shippingAddress.checkoutSettings=le.checkoutSettings,le.checkout.shippingAddress.shippingZones=le.shippingZones)),le.deliveryMethod=e,le.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(le,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:ue.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,G.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,K({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,Z({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(le,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,z()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===W.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(le,void 0,void 0,(function(){var e,t,s,n,r,a,c,d,u,l,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,t=J.getPaymentGateways().map((function(e){return e.id})),[4,G.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:J.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===de.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(J.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,u=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.step===de.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!==u?u:0),[3,4]))):(this.error={type:ue.NO_SHIPPING_ERROR},[2]):(this.error={type:ue.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==de.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===de.PAYMENT&&(l=r.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=l,(h=document.createElement("script")).id=D,h.src=x,h.onload=function(){y.mpVM.checkMasterPass({checkout:y.checkout,store:X.getInstance()})},document.head.appendChild(h)),this.isMilesSmilesActive()?[4,this.loadMilesSmilesDetails()]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},this.loadMilesSmilesDetails=function(){return t(le,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,q()]:(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?[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,ge.some((function(e){return s.includes(e)}))?(this.isMilesSmilesLoginRequired=!0,this.milesSmilesDetails=null,[2]):ye.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=le.getRoutingPath();return"".concat(e,"/checkout?id=").concat(le.checkout.id,"&step=").concat(de.PAYMENT)},this.getMilesSmilesLoginRedirectUrl=function(){var e=le.getRoutingPath();return"".concat(e,"/account/login?redirect=").concat(encodeURIComponent(le.getMilesSmilesBindRedirect()))},this.startMilesSmilesBind=function(){return t(le,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(le,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.useMilesSmiles=e,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,3];case 1:i.sent(),this.mpVM.selectedCard=void 0,i.label=2;case 2:return this.milesToRedeem||(this.milesToRedeem=this.milesSmilesMaxRedeemable),[3,4];case 3:this.milesToRedeem=0,i.label=4;case 4:return[4,this.onMilesSmilesSelectionChange()];case 5:return i.sent(),[2]}}))}))},this.setMilesToRedeem=function(e){le.milesToRedeem=Math.max(0,Math.floor(e||0))},this.clampMilesToRedeem=function(){return t(le,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.onMilesSmilesSelectionChange=function(){return t(le,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.isTkPay&&this.checkout.selectedPaymentGateway?(this.tkPayResponse=null,[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)]):[2];case 1:return e.sent(),[2]}}))}))},this.handleMilesSmilesSaleError=function(e){var t,i,n=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).filter(ve);if(!n.length)return null;var r=n[0];return ge.includes(r)?(le.isMilesSmilesLoginRequired=!0,le.milesSmilesDetails=null,le.useMilesSmiles=!1,le.milesToRedeem=0):ye.includes(r)&&(le.isMilesSmilesUnavailable=!0,le.useMilesSmiles=!1,le.milesToRedeem=0),le.milesSmilesError=r,le.getMilesSmilesErrorMessage(r)},this.getMilesSmilesErrorMessage=function(e){var t="checkout-page:milesSmilesErrors.".concat(e),i=e?le.t(t):"";return i&&i!==t?i:le.t("checkout-page:milesSmilesErrors.default")},this.retrieveInstallmentInfo=function(e){return t(le,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,G.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;le.store.customerStore.customer?(null===(t=le.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=le.checkoutSettings,e.shippingZones=le.shippingZones})),le.checkout.customer=new w(e(e({},le.store.customerStore.customer),{notificationsAccepted:le.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED}))):le.checkout.customer=new w(le.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){le.checkout.shippingAddress&&(le.checkout.shippingAddress.checkoutSettings=le.checkoutSettings,le.checkout.shippingAddress.shippingZones=le.shippingZones,le.checkout.shippingAddress.countrySettings=le.countrySettings,le.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){le.checkout.billingAddress&&(le.checkout.billingAddress.checkoutSettings=le.checkoutSettings,le.checkout.billingAddress.shippingZones=le.shippingZones,le.checkout.billingAddress.countrySettings=le.countrySettings,le.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!le.isDigitalOnly)if(le.isInStoreDelivery)le.setCheckoutShippingAddressSettings();else if(le.checkout.shippingAddress){if(le.store.customerStore.customer){var e=null==(t=le.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=le.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return le.onSelectedShippingAddressIdChange(e.id||"-1"),void le.setCheckoutShippingAddressSettings()}le.checkout.shippingAddress=new ee(r(le.checkout.shippingAddress)||{}),le.setCheckoutShippingAddressSettings()}else if(le.store.customerStore.customer){var t=le.customerAddresses;le.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else le.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(le.useDifferentAddress=!!localStorage.getItem("sAddr"),le.checkout.billingAddress){if(le.store.customerStore.customer){var e=null==(t=le.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=le.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return le.onSelectedBillingAddressIdChange(e.id||"-1"),void le.setCheckoutBillingAddressSettings()}le.checkout.billingAddress=new ee(r(le.checkout.billingAddress)||{}),le.setCheckoutBillingAddressSettings()}else if(le.store.customerStore.customer){var t=le.customerAddresses;le.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||le.useDifferentAddress||!le.checkout.shippingAddress||le.isInStoreDelivery||(le.checkout.billingAddress=new ee(r(le.checkout.shippingAddress)),le.setCheckoutBillingAddressSettings())}else le.onSelectedBillingAddressIdChange("-1"),le.useDifferentAddress||!le.checkout.shippingAddress||le.isInStoreDelivery||(le.checkout.billingAddress=new ee(r(le.checkout.shippingAddress)),le.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(le,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(le,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(le,void 0,void 0,(function(){var t,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,j.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(c=null===(a=this.cardData)||void 0===a?void 0:a.cardNumber)||void 0===c?void 0:c.split(" ").join(""),this.couponError=null,this.step===de.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==de.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?$.addCouponCode(n):$.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(le,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,j.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.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===de.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==de.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(le,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,j.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.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===de.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==de.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,$.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(le,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,te.getAvailableShippingZones({salesChannelId:J.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(le.selectedShippingAddressId=e,"-1"===e)le.checkout.shippingAddress=new ee,le.checkout.shippingAddress.countrySettings=le.countrySettings;else{var i=null===(t=le.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(le.checkout.shippingAddress=new ee(i),le.checkout.shippingAddress.countrySettings=le.countrySettings)}le.checkout.shippingAddress&&(le.checkout.shippingAddress.checkoutSettings=le.checkoutSettings,le.checkout.shippingAddress.shippingZones=le.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(le.selectedBillingAddressId=e,"-1"===e)le.checkout.billingAddress=new ee,le.checkout.billingAddress.countrySettings=le.countrySettings;else{var i=null===(t=le.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(le.checkout.billingAddress=new ee(i),le.checkout.billingAddress.countrySettings=le.countrySettings)}le.checkout.billingAddress&&(le.checkout.billingAddress.checkoutSettings=le.checkoutSettings,le.checkout.billingAddress.shippingZones=le.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){le.isTermsAndConditionsChecked=e,le.isIyzico&&(le.showIyzicoContainer=e),le.isTkPay&&(le.showTkPayContainer=e,le.saveCart())},this.onCardNumberChange=function(e){if(le.cardData){var t=(e||"").replace(/\D/g,""),i=le.previousRawValue,s=t.slice(0,8),n=le.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(le.getRetrieveInstallmentInfo(t),le.previousBin=s),t.length<8&&i.length>=8&&(le.cardData.installmentCount=1,le.installmentInfo=void 0,le.previousBin=null),le.isAmexCard(t)?le.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(" "):le.cardData.cardNumber=be(t,4).join(" "),le.previousRawValue=t}}},this.getRetrieveInstallmentInfo=function(e){return t(le,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){le.cardData&&(le.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(le.cardData&&(!(e.length>le.cardData.expirationDate.length)||ke(e))){if(0===(null===(t=le.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(le.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(le.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(le.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(le.cardData.expirationDate=be(d,2).join(" / "))}},this.onCvcChange=function(e){if(le.cardData&&(!(e.length>le.cardData.cvv.length)||ke(e))){if(le.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;le.cardData.cvv=e}},this.saveAddress=function(s){return t(le,void 0,void 0,(function(){var t,n,o,a,c,d,u,l,h,p,m,f,g=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,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(n=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new C(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=r(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:i.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==n?void 0:n.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"),i.label=2;case 2:return[3,4];case 3:return l=i.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=J.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=le.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=le.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=le.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(le.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(le,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 ee(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new ee(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(le,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(de.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(de.SHIPPING):this.changeStep(de.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ue.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(le,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(de.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ue.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(le,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(de.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ue.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!le.canPerformPayment||(le.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){le.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(le,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.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);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:[],!ie(t,s))?(this.changeStep(de.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:ue.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(le,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.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:ue.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(le,void 0,void 0,(function(){var t,s,n,r,o,a,c,d,h,p,m,f,y,v,S,b,k,P,I,C,A,E,w,O,R,M,T;return i(this,(function(i){switch(i.label){case 0:return s=this.mpVM.selectedCard,r=this.milesSmilesInput,!this.isFree&&s&&(null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.Name)?((o=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=o),void 0===(null===(f=this.cardData)||void 0===f?void 0:f.installmentCount)?[2]:[4,G.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(y=this.mpVM.selectedCard)||void 0===y?void 0:y.Name},paymentGatewayId:null===(v=this.mpVM.selectedCard)||void 0===v?void 0:v.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===(S=this.cardData)||void 0===S?void 0:S.threeDSecure)},metadata:e({_fbp:se("_fbp"),_fbc:se("_fbc"),_ga:se("_ga")},ne()),milesSmiles:(null===(b=this.mpVM.selectedCard)||void 0===b?void 0:b.paymentGatewayId)===(null===(k=this.milesSmilesPaymentGateway)||void 0===k?void 0:k.id)?r:void 0}})]):[3,2];case 1:return n=i.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway||this.isFree?[4,G.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:s&&t?{phoneNumber:t,savedCardName:null===(P=this.mpVM.selectedCard)||void 0===P?void 0:P.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":this.isMilesSmilesFullPayment?null===(I=this.milesSmilesPaymentGateway)||void 0===I?void 0:I.id:null===(C=this.checkout.selectedPaymentGateway)||void 0===C?void 0:C.id,paymentMethodDetail:this.isFree||s?void 0:(null===(A=this.checkout.selectedPaymentGateway)||void 0===A?void 0:A.paymentMethodType)===u.CREDIT_CARD&&(null===(E=this.checkout.selectedPaymentGateway)||void 0===E?void 0:E.type)===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:e({_fbp:se("_fbp"),_fbc:se("_fbc"),_ga:se("_ga")},ne()),milesSmiles:r}})]:[2];case 3:n=i.sent(),i.label=4;case 4:return a=null===(w=null==n?void 0:n.data)||void 0===w?void 0:w.transactionStatus,c=a&&[g.SUCCESS,g.AUTHORIZED].includes(a),d=a===g.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(O=null==n?void 0:n.data)||void 0===O?void 0:O.orderId)||void 0)];case 6:return i.sent(),[3,8];case 7:if(!d||!(null===(R=null==n?void 0:n.data)||void 0===R?void 0:R.returnSlug))throw h=n.firstErrorMessage,"IKAS_WALLET_501"===(null===(T=null===(M=n.data)||void 0===M?void 0:M.error)||void 0===T?void 0:T.code)&&(h=this.t("checkout-page:errorContactStore")),(p=this.handleMilesSmilesSaleError(n))&&(h=p),{data:h,type:ue.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+n.data.returnSlug,i.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(le,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 oe.refreshJourneyId(),this.changeStep(de.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){le.changeStep(de.INFO)},this.onBackToShippingClick=function(){le.changeStep(de.SHIPPING)},this.setCustomerConsentGranted=function(e){le.checkout.customer&&(le.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;le.useDifferentAddress=t,le.useDifferentAddress?(localStorage.setItem("sAddr","1"),le.checkout.billingAddress=le.checkout.billingAddress||new ee,le.checkout.billingAddress.countrySettings=le.countrySettings):(localStorage.removeItem("sAddr"),le.checkout.billingAddress=new ee(e({},le.checkout.shippingAddress)),le.store.customerStore.customer&&(null===(s=le.customerAddresses)||void 0===s?void 0:s.length)&&i&&le.isShowBillingAddressOnShippingStep&&le.onSelectedBillingAddressIdChange(le.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){le.shouldSaveAddress=e},this.setAddressTitle=function(e){le.addressTitle=e},this.reInitPaymentMethod=function(){return t(le,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(le,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,G.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:ue.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(le,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,G.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:ue.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(le,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,G.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(le,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,G.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(le,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,G.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(le,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]),this.isIyzicoLoading=!0,[4,G.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:s.id||"",metadata:e({_fbp:se("_fbp"),_fbc:se("_fbc"),_ga:se("_ga")},ne())}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.iyzicoResponse=t.data),[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(le,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]),this.isTkPayLoading=!0,[4,G.createTkPayCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||"",milesSmiles:this.milesSmilesInput}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.tkPayResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return this.isTkPayLoading=!1,[7];case 4:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(le,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,G.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(le,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,G.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){le.showIyzicoContainer=e},this.setShowTkPayContainer=function(e){le.showTkPayContainer=e},this.setPaymentGateway=function(e){return t(le,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==de.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.checkout.selectedPaymentGateway=t,this.step!==de.SUCCESS&&(t.paymentMethodType===u.CREDIT_CARD&&t.type===l.INTERNAL&&(this.cardData=new N,this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0),[2]}}))}))},this.updatePaymentGateway=function(s){return t(le,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,j.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:Q.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){le.cardData&&(le.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(le,void 0,void 0,(function(){return i(this,(function(t){return pe||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(le,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){le.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(le,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,u,l;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})))?(n=[t.productId],[4,U.searchProducts({input:{productIdList:n,priceListId:J.getPriceListId(),salesChannelId:J.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.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(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 R(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===k.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 M(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(le,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===de.SUCCESS?v.POST_CHECKOUT:v.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(le,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,j.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===de.SUCCESS?de.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(le,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,L.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(le,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}))).length?[4,G.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(le,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})))?[4,G.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=a,this.checkoutSettings=d,this.router=p,this.returnPolicy=A,this.privacyPolicy=E,this.termsOfService=F,this.imprint=V,this.shippingPolicy=B,this.t=ae,this.customizationProps=ce,this.mpVM=new _,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new T({currentLocale:J.getCurrentLocale()}),this.init(),n(this)}return ce.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===V.AMERICAN_EXPRESS||he.test(i)},Object.defineProperty(ce.prototype,"merchantSettings",{get:function(){return new E(J.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.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(ce.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=X.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(ce.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(ce.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(ce.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(ce.prototype,"finalPrice",{get:function(){var e;if(this.step===de.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(ce.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ue.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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)!==ue.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.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(ce.prototype,"isManualOrderWithoutShippingLines",{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(ce.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.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(ce.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"milesSmilesPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return e.code===B&&!!e.milesSmilesEnabled}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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 fe.includes(e.label)})),s=(null==i?void 0:i.value)?parseFloat(i.value):NaN;return!isNaN(s)&&s>0?s:me[this.checkout.currencyCode]||0},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.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(ce.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(ce.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"milesSmilesInput",{get:function(){if(this.useMilesSmiles&&this.isMilesSmilesActive()){var e=Math.floor(this.milesToRedeem||0);if(!(e<1))return{miles:e}}},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"store",{get:function(){return X.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===a.UPSELL||this.checkout.createdBy===a.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==d.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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||this.isHepsiPay)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=J.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(ce.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===a.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===a.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ce.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(ce.prototype,"isEPayKolayEnabled",{get:function(){var e=J.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"isPoweredByHidden",{get:function(){var e=J.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"hasCorrectableEmailTypo",{get:function(){var e;return!this.checkout.hasCustomer&&!!ae((null===(e=this.checkout.customer)||void 0===e?void 0:e.email)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(ce.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&(!this.checkout.hasValidCustomerEmail||this.hasCorrectableEmailTypo)},enumerable:!1,configurable:!0}),ce.prototype.isMilesSmilesActive=function(){return!this.isMilesSmilesUnavailable&&!!this.milesSmilesPaymentGateway&&this.checkout.currencyCode===F},ce.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},ce}();function be(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function ke(e){return e&&le.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(de||(de={})),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"}(ue||(ue={}));export{de as CheckoutStep,ue as ErrorType,ge as MILES_SMILES_LOGIN_REQUIRED_CODES,me as MILES_SMILES_RATE_PER_POINT,ye as MILES_SMILES_UNAVAILABLE_CODES,Se 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{IkasCartCreatedBy as a,IkasCouponCodeRequirement as c,IkasCorporateInvoiceRequirement as d,IkasPaymentMethodType as u,IkasPaymentGatewayType as l,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 k}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 I}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 C}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 R}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as M}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 j from"./components/credit-card-form/model.js";import G from"../../store/customer/api.js";import _ from"../../store/checkout/index.js";import D from"../../store/cart/api.js";import x,{MFS_ELEMENT_ID as F,MFS_SCRIPT_URL as U}from"./modelMasterPass.js";import V from"../../store/product/index.js";import{MILES_SMILES_CURRENCY_CODE as B,TransactionCardAssociationEnum as Y,MILES_SMILES_CARD_GATEWAY_CODE as H,SaveCartInput as K,CheckStocksLineInput as Z,getLoyaltyCustomerInfo as W,listSpendingMethodsByCartId as z,LoyaltyProgramPointEarningTypeEnum as q,listEarningMethods as Q,getMilesSmilesDetails as X,CampaignOfferTargetPageTypeEnum as J}from"@ikas/storefront-api";import{IkasBaseStore as $}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as ee}from"@ikas/storefront-config";import{Analytics as te}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import ie from"../../models/data/order/address/ikas-localized-order-address.js";import se from"../../store/location/index.js";import{isEqual as ne,getCookieValue as re,getOpenAiAttributionMetadata as oe}from"../../utils/helper.js";import{readMilesSmilesBindResult as ae}from"../../utils/miles-smiles.js";import ce from"../../analytics/ikasV3.js";import{suggestEmailCorrection as de}from"@ikas/storefront-model-functions";var ue,le,he,pe=/^\d+$/,me=/^3[47]/,fe="undefined"==typeof localStorage,ge=((ue={})[B]=.25,ue),ye=["miles_smiles_rate","miles_rate"],ve=["UNAUTHORIZED","AUTHORIZATION_REQUIRED","MILES_SMILES_LOGIN_REQUIRED","MILES_SMILES_MEMBER_MISMATCH","EXTERNAL_ACCOUNT_MEMBER_MISMATCH"],Se=["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"],be=function(e){return!!e&&(e.startsWith("MILES_")||e.startsWith("EXTERNAL_ACCOUNT_")||"INVALID_MILES"===e)},ke=function(){function ue(a,d,p,A,E,B,Y,H,de,ue){var pe=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=le.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.milesToRedeem=0,this.isMilesSmilesLoginRequired=!1,this.isMilesSmilesUnavailable=!1,this.isMilesSmilesBindLoading=!1,this.milesSmilesDetails=null,this.milesSmilesError=null,this.milesSmilesBindLanding=null,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.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(pe,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.waitForCountrySettingsOrFail()];case 1:return t.sent(),[3,3];case 2:return t.sent(),this.isCheckoutLoadFailed=!0,[2];case 3:return[4,$.getInstance().customerStore.waitUntilInitialized()];case 4:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,6];case 5:t.sent(),t.label=6;case 6:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 7:return t.sent(),[2]}}))}))},this.waitForCountrySettingsOrFail=function(){return new Promise((function(e,s){var n=!1,r=function(){n=!0,clearInterval(o),clearTimeout(a)},o=setInterval((function(){pe.countrySettings.initialized&&(r(),e())}),100),a=setTimeout((function(){n||(r(),s(new Error("timeout")))}),1e4);t(pe,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=ee.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(pe,void 0,void 0,(function(){var t,s,n,r,o,a,d;return i(this,(function(i){switch(i.label){case 0:if(ee.getIsEditor())return this.step=le.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.milesSmilesBindLanding=ae(),s){if(this.step=s,this.step===le.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(le.INFO)];if(this.step!==le.PAYMENT||this.canProceedToPayment){if(this.step===le.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(le.INFO)];if(![le.INFO,le.SUCCESS,le.SHIPPING,le.PAYMENT].includes(this.step))return[2,this.changeStep(le.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(le.INFO)]:[2,this.changeStep(le.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==le.SHIPPING&&this.step!==le.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new I(e(e({},this.checkoutSettings),{couponCodeRequirement:c.DEFAULT}))),this.step!==le.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:return this.step!==le.SHIPPING||1!==(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=le.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==le.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==le.SUCCESS||this.checkout.orderPaymentStatus!==f.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:he.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==le.PAYMENT&&this.step!==le.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:he.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:he.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===le.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(le.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&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===o}))),i.label=25;case 25:return n&&(this.error={type:he.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,te.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,G.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(pe,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,G.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.saveCart=function(){return t(pe,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,h,p,f,g,y,v;return i(this,(function(i){switch(i.label){case 0:return e=new K(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!==le.INFO&&this.step!==le.SHIPPING&&this.step!==le.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===le.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===(u=null===(d=e.shippingAddress)||void 0===d?void 0:d.city)||void 0===u?void 0:u.name)&&(e.shippingAddress.city.name="-"),null===(null===(h=null===(l=e.billingAddress)||void 0===l?void 0:l.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,D.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:he.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(y=s.extensions)||void 0===y?void 0:y.code)?{type:he.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(v=s.extensions)||void 0===v?void 0:v.code)?{type:he.ARGUMENT_VALIDATION_ERROR,data:s.extensions.validationErrors}:{type:he.API_ERROR,data:t.firstErrorMessage};return[2,t.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(pe,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(pe,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,u,l,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=ee.getStockLocationIds())||void 0===p?void 0:p.length)?ee.getStockLocationIds():null,[4,_.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:he.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,u=r;d<u.length;d++)l=u[d],a(l);throw{type:he.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(pe,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){pe.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(pe,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,$.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(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,_.getAvailableShippingCountries({salesChannelId:ee.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(pe,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return ee.getPickupStockLocationIds()?[4,_.listStockLocation({id:{in:ee.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:he.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(pe,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return ee.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,_.getAvailableStockLocations({lines:e.map((function(e){return new Z(e)})),stockLocationIdList:ee.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:he.API_ERROR},[2];s=ee.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=pe.shippingCountryIds)||void 0===e?void 0:e.length)||(pe.error={type:he.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;pe.deliveryMethod!==e&&("address"===e&&(pe.checkout.stockLocationId=null,(null===(t=pe.customerAddresses)||void 0===t?void 0:t.length)?pe.onSelectedShippingAddressIdChange(pe.customerAddresses[0].id||"-1"):(pe.checkout.shippingAddress=new ie,pe.checkout.shippingAddress.countrySettings=pe.countrySettings,pe.checkout.shippingAddress.checkoutSettings=pe.checkoutSettings,pe.checkout.shippingAddress.shippingZones=pe.shippingZones)),pe.deliveryMethod=e,pe.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(pe,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:he.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,_.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,W({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,z({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(pe,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,Q()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===q.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(pe,void 0,void 0,(function(){var e,t,s,n,r,a,c,d,u,l,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,t=ee.getPaymentGateways().map((function(e){return e.id})),[4,_.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:ee.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===le.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(ee.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,u=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.step===le.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!==u?u:0),[3,4]))):(this.error={type:he.NO_SHIPPING_ERROR},[2]):(this.error={type:he.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==le.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===le.PAYMENT&&(l=r.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=l,(h=document.createElement("script")).id=F,h.src=U,h.onload=function(){y.mpVM.checkMasterPass({checkout:y.checkout,store:$.getInstance()})},document.head.appendChild(h)),this.isMilesSmilesActive()?[4,this.loadMilesSmilesDetails()]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},this.loadMilesSmilesDetails=function(){return t(pe,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,X()]:(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?[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,ve.some((function(e){return s.includes(e)}))?(this.isMilesSmilesLoginRequired=!0,this.milesSmilesDetails=null,[2]):Se.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=pe.getRoutingPath();return"".concat(e,"/checkout?id=").concat(pe.checkout.id,"&step=").concat(le.PAYMENT)},this.getMilesSmilesLoginRedirectUrl=function(){var e=pe.getRoutingPath();return"".concat(e,"/account/login?redirect=").concat(encodeURIComponent(pe.getMilesSmilesBindRedirect()))},this.startMilesSmilesBind=function(){return t(pe,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(pe,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.useMilesSmiles=e,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,3];case 1:i.sent(),this.mpVM.selectedCard=void 0,i.label=2;case 2:return this.milesToRedeem||(this.milesToRedeem=this.milesSmilesMaxRedeemable),[3,4];case 3:this.milesToRedeem=0,i.label=4;case 4:return[4,this.onMilesSmilesSelectionChange()];case 5:return i.sent(),[2]}}))}))},this.setMilesToRedeem=function(e){pe.milesToRedeem=Math.max(0,Math.floor(e||0))},this.clampMilesToRedeem=function(){return t(pe,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.onMilesSmilesSelectionChange=function(){return t(pe,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.isTkPay&&this.checkout.selectedPaymentGateway?(this.tkPayResponse=null,[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)]):[2];case 1:return e.sent(),[2]}}))}))},this.handleMilesSmilesSaleError=function(e){var t,i,n=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).filter(be);if(!n.length)return null;var r=n[0];return ve.includes(r)?(pe.isMilesSmilesLoginRequired=!0,pe.milesSmilesDetails=null,pe.useMilesSmiles=!1,pe.milesToRedeem=0):Se.includes(r)&&(pe.isMilesSmilesUnavailable=!0,pe.useMilesSmiles=!1,pe.milesToRedeem=0),pe.milesSmilesError=r,pe.getMilesSmilesErrorMessage(r)},this.getMilesSmilesErrorMessage=function(e){var t="checkout-page:milesSmilesErrors.".concat(e),i=e?pe.t(t):"";return i&&i!==t?i:pe.t("checkout-page:milesSmilesErrors.default")},this.retrieveInstallmentInfo=function(e){return t(pe,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,_.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;pe.store.customerStore.customer?(null===(t=pe.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=pe.checkoutSettings,e.shippingZones=pe.shippingZones})),pe.checkout.customer=new w(e(e({},pe.store.customerStore.customer),{notificationsAccepted:pe.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED}))):pe.checkout.customer=new w(pe.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){pe.checkout.shippingAddress&&(pe.checkout.shippingAddress.checkoutSettings=pe.checkoutSettings,pe.checkout.shippingAddress.shippingZones=pe.shippingZones,pe.checkout.shippingAddress.countrySettings=pe.countrySettings,pe.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){pe.checkout.billingAddress&&(pe.checkout.billingAddress.checkoutSettings=pe.checkoutSettings,pe.checkout.billingAddress.shippingZones=pe.shippingZones,pe.checkout.billingAddress.countrySettings=pe.countrySettings,pe.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!pe.isDigitalOnly)if(pe.isInStoreDelivery)pe.setCheckoutShippingAddressSettings();else if(pe.checkout.shippingAddress){if(pe.store.customerStore.customer){var e=null==(t=pe.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=pe.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return pe.onSelectedShippingAddressIdChange(e.id||"-1"),void pe.setCheckoutShippingAddressSettings()}pe.checkout.shippingAddress=new ie(r(pe.checkout.shippingAddress)||{}),pe.setCheckoutShippingAddressSettings()}else if(pe.store.customerStore.customer){var t=pe.customerAddresses;pe.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else pe.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(pe.useDifferentAddress=!!localStorage.getItem("sAddr"),pe.checkout.billingAddress){if(pe.store.customerStore.customer){var e=null==(t=pe.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=pe.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return pe.onSelectedBillingAddressIdChange(e.id||"-1"),void pe.setCheckoutBillingAddressSettings()}pe.checkout.billingAddress=new ie(r(pe.checkout.billingAddress)||{}),pe.setCheckoutBillingAddressSettings()}else if(pe.store.customerStore.customer){var t=pe.customerAddresses;pe.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||pe.useDifferentAddress||!pe.checkout.shippingAddress||pe.isInStoreDelivery||(pe.checkout.billingAddress=new ie(r(pe.checkout.shippingAddress)),pe.setCheckoutBillingAddressSettings())}else pe.onSelectedBillingAddressIdChange("-1"),pe.useDifferentAddress||!pe.checkout.shippingAddress||pe.isInStoreDelivery||(pe.checkout.billingAddress=new ie(r(pe.checkout.shippingAddress)),pe.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(pe,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(pe,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(pe,void 0,void 0,(function(){var t,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,D.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=null===(c=null===(a=this.cardData)||void 0===a?void 0:a.cardNumber)||void 0===c?void 0:c.split(" ").join(""),this.couponError=null,this.step===le.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==le.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?te.addCouponCode(n):te.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(pe,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,D.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.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===le.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==le.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(pe,void 0,void 0,(function(){var t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,D.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.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===le.PAYMENT&&(null==r?void 0:r.length)&&r.length>=8&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r.slice(0,8),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!==le.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,te.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(pe,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,se.getAvailableShippingZones({salesChannelId:ee.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(pe.selectedShippingAddressId=e,"-1"===e)pe.checkout.shippingAddress=new ie,pe.checkout.shippingAddress.countrySettings=pe.countrySettings;else{var i=null===(t=pe.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(pe.checkout.shippingAddress=new ie(i),pe.checkout.shippingAddress.countrySettings=pe.countrySettings)}pe.checkout.shippingAddress&&(pe.checkout.shippingAddress.checkoutSettings=pe.checkoutSettings,pe.checkout.shippingAddress.shippingZones=pe.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(pe.selectedBillingAddressId=e,"-1"===e)pe.checkout.billingAddress=new ie,pe.checkout.billingAddress.countrySettings=pe.countrySettings;else{var i=null===(t=pe.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(pe.checkout.billingAddress=new ie(i),pe.checkout.billingAddress.countrySettings=pe.countrySettings)}pe.checkout.billingAddress&&(pe.checkout.billingAddress.checkoutSettings=pe.checkoutSettings,pe.checkout.billingAddress.shippingZones=pe.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){pe.isTermsAndConditionsChecked=e,pe.isIyzico&&(pe.showIyzicoContainer=e),pe.isTkPay&&(pe.showTkPayContainer=e,pe.saveCart())},this.onCardNumberChange=function(e){if(pe.cardData){var t=(e||"").replace(/\D/g,""),i=pe.previousRawValue,s=t.slice(0,8),n=pe.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(pe.getRetrieveInstallmentInfo(t),pe.previousBin=s),t.length<8&&i.length>=8&&(pe.cardData.installmentCount=1,pe.installmentInfo=void 0,pe.previousBin=null),pe.isAmexCard(t)?pe.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(" "):pe.cardData.cardNumber=Pe(t,4).join(" "),pe.previousRawValue=t}}},this.getRetrieveInstallmentInfo=function(e){return t(pe,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){pe.cardData&&(pe.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(pe.cardData&&(!(e.length>pe.cardData.expirationDate.length)||Ie(e))){if(0===(null===(t=pe.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(pe.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(pe.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(pe.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(pe.cardData.expirationDate=Pe(d,2).join(" / "))}},this.onCvcChange=function(e){if(pe.cardData&&(!(e.length>pe.cardData.cvv.length)||Ie(e))){if(pe.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;pe.cardData.cvv=e}},this.saveAddress=function(s){return t(pe,void 0,void 0,(function(){var t,n,o,a,c,d,u,l,h,p,m,f,g=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,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(n=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new C(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=r(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:i.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==n?void 0:n.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"),i.label=2;case 2:return[3,4];case 3:return l=i.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=ee.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=pe.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=pe.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=pe.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(pe.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(pe,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 ie(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new ie(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(pe,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(le.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(le.SHIPPING):this.changeStep(le.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:he.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(pe,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(le.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:he.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(pe,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(le.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:he.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!pe.canPerformPayment||(pe.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){pe.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(pe,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.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);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:[],!ne(t,s))?(this.changeStep(le.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:he.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(pe,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.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:he.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(pe,void 0,void 0,(function(){var t,s,n,r,o,a,c,d,h,p,m,f,y,v,S,b,k,P,I,C,A,E,w,O,R,M,T;return i(this,(function(i){switch(i.label){case 0:return s=this.mpVM.selectedCard,r=this.milesSmilesInput,!this.isFree&&s&&(null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.Name)?((o=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=o),void 0===(null===(f=this.cardData)||void 0===f?void 0:f.installmentCount)?[2]:[4,_.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(y=this.mpVM.selectedCard)||void 0===y?void 0:y.Name},paymentGatewayId:null===(v=this.mpVM.selectedCard)||void 0===v?void 0:v.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===(S=this.cardData)||void 0===S?void 0:S.threeDSecure)},metadata:e({_fbp:re("_fbp"),_fbc:re("_fbc"),_ga:re("_ga")},oe()),milesSmiles:(null===(b=this.mpVM.selectedCard)||void 0===b?void 0:b.paymentGatewayId)===(null===(k=this.milesSmilesPaymentGateway)||void 0===k?void 0:k.id)?r:void 0}})]):[3,2];case 1:return n=i.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway||this.isFree?[4,_.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:s&&t?{phoneNumber:t,savedCardName:null===(P=this.mpVM.selectedCard)||void 0===P?void 0:P.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":this.isMilesSmilesFullPayment?null===(I=this.milesSmilesPaymentGateway)||void 0===I?void 0:I.id:null===(C=this.checkout.selectedPaymentGateway)||void 0===C?void 0:C.id,paymentMethodDetail:this.isFree||s?void 0:(null===(A=this.checkout.selectedPaymentGateway)||void 0===A?void 0:A.paymentMethodType)===u.CREDIT_CARD&&(null===(E=this.checkout.selectedPaymentGateway)||void 0===E?void 0:E.type)===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0,metadata:e({_fbp:re("_fbp"),_fbc:re("_fbc"),_ga:re("_ga")},oe()),milesSmiles:r}})]:[2];case 3:n=i.sent(),i.label=4;case 4:return a=null===(w=null==n?void 0:n.data)||void 0===w?void 0:w.transactionStatus,c=a&&[g.SUCCESS,g.AUTHORIZED].includes(a),d=a===g.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(O=null==n?void 0:n.data)||void 0===O?void 0:O.orderId)||void 0)];case 6:return i.sent(),[3,8];case 7:if(!d||!(null===(R=null==n?void 0:n.data)||void 0===R?void 0:R.returnSlug))throw h=n.firstErrorMessage,"IKAS_WALLET_501"===(null===(T=null===(M=n.data)||void 0===M?void 0:M.error)||void 0===T?void 0:T.code)&&(h=this.t("checkout-page:errorContactStore")),(p=this.handleMilesSmilesSaleError(n))&&(h=p),{data:h,type:he.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+n.data.returnSlug,i.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(pe,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 ce.refreshJourneyId(),this.changeStep(le.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){pe.changeStep(le.INFO)},this.onBackToShippingClick=function(){pe.changeStep(le.SHIPPING)},this.setCustomerConsentGranted=function(e){pe.checkout.customer&&(pe.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;pe.useDifferentAddress=t,pe.useDifferentAddress?(localStorage.setItem("sAddr","1"),pe.checkout.billingAddress=pe.checkout.billingAddress||new ie,pe.checkout.billingAddress.countrySettings=pe.countrySettings):(localStorage.removeItem("sAddr"),pe.checkout.billingAddress=new ie(e({},pe.checkout.shippingAddress)),pe.store.customerStore.customer&&(null===(s=pe.customerAddresses)||void 0===s?void 0:s.length)&&i&&pe.isShowBillingAddressOnShippingStep&&pe.onSelectedBillingAddressIdChange(pe.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){pe.shouldSaveAddress=e},this.setAddressTitle=function(e){pe.addressTitle=e},this.reInitPaymentMethod=function(){return t(pe,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(pe,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,_.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:he.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(pe,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,_.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:he.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(pe,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,_.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(pe,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,_.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(pe,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,_.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(pe,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]),this.isIyzicoLoading=!0,[4,_.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:s.id||"",metadata:e({_fbp:re("_fbp"),_fbc:re("_fbc"),_ga:re("_ga")},oe())}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.iyzicoResponse=t.data),[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(pe,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]),this.isTkPayLoading=!0,[4,_.createTkPayCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||"",milesSmiles:this.milesSmilesInput}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.tkPayResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return this.isTkPayLoading=!1,[7];case 4:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(pe,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,_.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(pe,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,_.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){pe.showIyzicoContainer=e},this.setShowTkPayContainer=function(e){pe.showTkPayContainer=e},this.setPaymentGateway=function(e){return t(pe,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==le.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.checkout.selectedPaymentGateway=t,this.step!==le.SUCCESS&&(t.paymentMethodType===u.CREDIT_CARD&&t.type===l.INTERNAL&&(this.cardData=new j,this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0),[2]}}))}))},this.updatePaymentGateway=function(s){return t(pe,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,D.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:J.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){pe.cardData&&(pe.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(pe,void 0,void 0,(function(){return i(this,(function(t){return fe||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(pe,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){pe.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(pe,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,u,l;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})))?(n=[t.productId],[4,V.searchProducts({input:{productIdList:n,priceListId:ee.getPriceListId(),salesChannelId:ee.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.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(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 R(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===k.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 M(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(pe,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===le.SUCCESS?v.POST_CHECKOUT:v.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(pe,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,D.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===le.SUCCESS?le.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(pe,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,G.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(pe,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}))).length?[4,_.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(pe,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})))?[4,_.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=a,this.checkoutSettings=d,this.router=p,this.returnPolicy=A,this.privacyPolicy=E,this.termsOfService=B,this.imprint=Y,this.shippingPolicy=H,this.t=de,this.customizationProps=ue,this.mpVM=new x,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new T({currentLocale:ee.getCurrentLocale()}),this.init(),n(this)}return ue.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===Y.AMERICAN_EXPRESS||me.test(i)},Object.defineProperty(ue.prototype,"merchantSettings",{get:function(){return new E(ee.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.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(ue.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=$.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(ue.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(ue.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(ue.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(ue.prototype,"finalPrice",{get:function(){var e;if(this.step===le.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(ue.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===he.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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)!==he.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.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(ue.prototype,"isManualOrderWithoutShippingLines",{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(ue.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.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(ue.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"milesSmilesPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return e.code===H&&!!e.milesSmilesEnabled}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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 ye.includes(e.label)})),s=(null==i?void 0:i.value)?parseFloat(i.value):NaN;return!isNaN(s)&&s>0?s:ge[this.checkout.currencyCode]||0},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.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(ue.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(ue.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"milesSmilesInput",{get:function(){if(this.useMilesSmiles&&this.isMilesSmilesActive()){var e=Math.floor(this.milesToRedeem||0);if(!(e<1))return{miles:e}}},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"store",{get:function(){return $.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===c.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===a.UPSELL||this.checkout.createdBy===a.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==d.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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||this.isHepsiPay)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=ee.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(ue.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===a.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===a.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(ue.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(ue.prototype,"isEPayKolayEnabled",{get:function(){var e=ee.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"isPoweredByHidden",{get:function(){var e=ee.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"hasCorrectableEmailTypo",{get:function(){var e;return!this.checkout.hasCustomer&&!!de((null===(e=this.checkout.customer)||void 0===e?void 0:e.email)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&(!this.checkout.hasValidCustomerEmail||this.hasCorrectableEmailTypo)},enumerable:!1,configurable:!0}),ue.prototype.isMilesSmilesActive=function(){return!this.isMilesSmilesUnavailable&&!!this.milesSmilesPaymentGateway&&this.checkout.currencyCode===B},ue.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},ue}();function Pe(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function Ie(e){return e&&pe.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(le||(le={})),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"}(he||(he={}));export{le as CheckoutStep,he as ErrorType,ve as MILES_SMILES_LOGIN_REQUIRED_CODES,ge as MILES_SMILES_RATE_PER_POINT,Se as MILES_SMILES_UNAVAILABLE_CODES,ke as default};
@@ -1 +1 @@
1
- import{__rest as o,__awaiter as e,__generator as t,__assign as r}from'./../ext/tslib/tslib.es6.js';import*as s from"react";import{observer as i}from"mobx-react-lite";import d from"../components/checkout/index.js";import{useRouter as n}from"next/router.js";import{FullscreenLoading as a}from"../components/checkout/components/fullscreen-loading/index.js";import{CheckoutStep as m}from"../components/checkout/model.js";import{setAPIClientConfig as l,getCartById as c,CampaignOfferTargetPageTypeEnum as u}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import"../analytics/analytics.js";import"../analytics/head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../components/paypal-express-checkout/index.js";import{IkasBaseStore as j}from"../store/base.js";import"mobx";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"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as g}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import{IkasCheckout as f}from"../models/data/checkout/index.js";import"../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"../models/data/customer/address/index.js";import"../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"../models/data/order/address/region/index.js";import"../models/data/order/address/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"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../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{LocalizedAddressConfig as x}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"./home.js";import"./_slug_/index.js";import"./pages/_slug_.js";import"./account/index.js";import"./account/addresses.js";import"./account/orders/index.js";import"./account/orders/_id_.js";import"./account/login.js";import"./account/register.js";import"./account/forgot-password.js";import"./account/recover-password.js";import"./cart.js";import"./editor.js";import"./account/favorite-products.js";import"./search.js";import"next/error.js";import"./blog/index.js";import"./blog/_slug_.js";import"./raffle/_slug_.js";import"./raffle/index.js";import"./account/raffles.js";import"./account/activate.js";import"../store/customer/index.js";import"../store/cart/index.js";import"lodash/get";import{initIkasEvents as y}from"../analytics/events.js";import{APIErrorCode as v}from'./../ext/@ikas/fe-api-client/build/utils/api.js';import'./../ext/axios/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 h from"../store/checkout/index.js";var C=i((function(i){var C=i.customizationProps,E=i.configJson,b=o(i,["customizationProps","configJson"]),k=n(),F=s.useState(),P=F[0],w=F[1],_=s.useState(b.checkoutSettings),B=_[0],T=_[1];p.init(E),x.setCDNUrl(process.env.NEXT_PUBLIC_SETTINGS_CDN_URL),l(),s.useEffect((function(){!function(o){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==o?void 0:o.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==o?void 0:o.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==o?void 0:o.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==o?void 0:o.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==o?void 0:o.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==o?void 0:o.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==o?void 0:o.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==o?void 0:o.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==o?void 0:o.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==o?void 0:o.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==o?void 0:o.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==o?void 0:o.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==o?void 0:o.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==o?void 0:o.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==o?void 0:o.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==o?void 0:o.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==o?void 0:o.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==o?void 0:o.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==o?void 0:o.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==o?void 0:o.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==o?void 0:o.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==o?void 0:o.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==o?void 0:o.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==o?void 0:o.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==o?void 0:o.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==o?void 0:o.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==o?void 0:o.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==o?void 0:o.campaignOffersMiddlePhaseOverlayColor)||"#292727ad"),document.documentElement.style.lineHeight="1.5"}(C)}),[C]),s.useEffect((function(){j.getInstance().checkLocalization(),S(),y()}),[]);var S=s.useCallback((function(){return e(void 0,void 0,void 0,(function(){var o,e,r,s,i,d,n,a,l,x,y,C,E,b,F,P,_,S,I;return t(this,(function(t){switch(t.label){case 0:if(o=new URLSearchParams(window.location.search),e=o.get("id"),r=o.get("step"),s=o.get("lines"),i=o.get("couponCode"),!s)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),(d=j.getInstance().cartStore).removeCart(),n=s.split(","),a=n.map((function(o){var e=o.split(":"),t=e[0],r=e[1];return{variantId:t,quantity:parseInt(r)}})),l={variantLines:a,couponCode:i||void 0},[4,d.createCart(l)];case 2:return(x=t.sent()).success&&(y=p.getCurrentRouting(),C=(null==y?void 0:y.path)?"/".concat(y.path):"",window.location.href="".concat(C,"/checkout?id=").concat(null===(S=x.response.data)||void 0===S?void 0:S.id,"&step=info")),[3,4];case 3:return E=t.sent(),console.error("Error creating cart:",E),[3,4];case 4:return[2];case 5:return e?(b=!1,r&&r===m.SUCCESS&&(b=!0),[4,c({id:e,getCompletedCart:b,targetPageType:u.CHECKOUT})]):[2,k.replace("/")];case 6:return F=t.sent(),B?[3,8]:[4,h.listCheckoutSettings({})];case 7:(P=t.sent()).isSuccess&&(null===(I=P.data)||void 0===I?void 0:I.length)?T(P.data[0]):(console.error("CHECKOUT SETTINGS FETCH FAILED!"),console.error(P),console.error(P.graphQLErrors),console.error(P.errorCodes)),t.label=8;case 8:return F.isSuccess&&F.data?(_=F.data,w(new f(_)),j.getInstance().cartStore.setCart(new g(_))):F.errorCodes.some((function(o){return o===v.LOGIN_REQUIRED}))?k.replace("/account/login?redirect="+encodeURIComponent(window.location.href)):k.replace("/"),[2]}}))}))}),[]);return P&&B?s.createElement(d,r({checkout:P,customizationProps:C},b,{checkoutSettings:B})):s.createElement(a,null)}));export{C as default};
1
+ import{__rest as o,__awaiter as e,__generator as t,__assign as r}from'./../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as s}from"mobx-react-lite";import n from"../components/checkout/index.js";import{useRouter as d}from"next/router.js";import{FullscreenLoading as a}from"../components/checkout/components/fullscreen-loading/index.js";import{CheckoutLoadFailed as m,getCheckoutHomeHref as c}from"../components/checkout/components/checkout-load-failed/index.js";import{CheckoutStep as l}from"../components/checkout/model.js";import{setAPIClientConfig as u,getCartById as p,CampaignOfferTargetPageTypeEnum as f}from"@ikas/storefront-api";import{IkasStorefrontConfig as j}from"@ikas/storefront-config";import"../analytics/analytics.js";import"../analytics/head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../components/paypal-express-checkout/index.js";import{IkasBaseStore as g}from"../store/base.js";import"mobx";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"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as x}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import{IkasCheckout as y}from"../models/data/checkout/index.js";import"../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"../models/data/customer/address/index.js";import"../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"../models/data/order/address/region/index.js";import"../models/data/order/address/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"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../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{LocalizedAddressConfig as v}from"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../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"./home.js";import"./_slug_/index.js";import"./pages/_slug_.js";import"./account/index.js";import"./account/addresses.js";import"./account/orders/index.js";import"./account/orders/_id_.js";import"./account/login.js";import"./account/register.js";import"./account/forgot-password.js";import"./account/recover-password.js";import"./cart.js";import"./editor.js";import"./account/favorite-products.js";import"./search.js";import"next/error.js";import"./blog/index.js";import"./blog/_slug_.js";import"./raffle/_slug_.js";import"./raffle/index.js";import"./account/raffles.js";import"./account/activate.js";import"../store/customer/index.js";import"../store/cart/index.js";import"lodash/get";import{initIkasEvents as h}from"../analytics/events.js";import{APIErrorCode as E}from'./../ext/@ikas/fe-api-client/build/utils/api.js';import'./../ext/axios/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 C from"../store/checkout/index.js";var k=s((function(s){var k=s.customizationProps,b=s.configJson,P=o(s,["customizationProps","configJson"]),F=d(),w=i.useState(),_=w[0],T=w[1],S=i.useState(P.checkoutSettings),B=S[0],O=S[1],I=i.useState(!1),D=I[0],L=I[1];j.init(b),v.setCDNUrl(process.env.NEXT_PUBLIC_SETTINGS_CDN_URL),u(),i.useEffect((function(){!function(o){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==o?void 0:o.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==o?void 0:o.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==o?void 0:o.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==o?void 0:o.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==o?void 0:o.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==o?void 0:o.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==o?void 0:o.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==o?void 0:o.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==o?void 0:o.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==o?void 0:o.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==o?void 0:o.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==o?void 0:o.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==o?void 0:o.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==o?void 0:o.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==o?void 0:o.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==o?void 0:o.successLightColor)||"#F6FFED"),document.documentElement.style.setProperty("--checkout-secondary-button-bg-color",(null==o?void 0:o.secondaryButtonBgColor)||"#ffffff0"),document.documentElement.style.setProperty("--checkout-secondary-button-text-color",(null==o?void 0:o.secondaryButtonTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-button-border-color",(null==o?void 0:o.secondaryButtonBorderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-campaign-title-color",(null==o?void 0:o.campaignOffersTitleColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-description-color",(null==o?void 0:o.campaignOffersDescriptionColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-container-bg-color",(null==o?void 0:o.campaignOffersContainerBgColor)||"#ffffff"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-color",(null==o?void 0:o.campaignOffersDiscountPercentageColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-discount-percentage-bg-color",(null==o?void 0:o.campaignOffersDiscountPercentageBgColor)||"#FFF1BD"),document.documentElement.style.setProperty("--checkout-campaign-countdown-text-color",(null==o?void 0:o.campaignOffersCountdownTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-campaign-countdown-time-color",(null==o?void 0:o.campaignOffersCountdownTimeColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-campaign-countdown-bg-color",(null==o?void 0:o.campaignOffersCountdownBgColor)||"#FFF5F6"),document.documentElement.style.setProperty("--checkout-campaign-middle-phase-overlay-color",(null==o?void 0:o.campaignOffersMiddlePhaseOverlayColor)||"#292727ad"),document.documentElement.style.lineHeight="1.5"}(k)}),[k]),i.useEffect((function(){g.getInstance().checkLocalization(),U(),h()}),[]);var U=i.useCallback((function(){return e(void 0,void 0,void 0,(function(){var o,e,r,i,s,n,d,a,m,c,u,v,h,k,b,P,w,_,S,I;return t(this,(function(t){switch(t.label){case 0:if(o=new URLSearchParams(window.location.search),e=o.get("id"),r=o.get("step"),i=o.get("lines"),s=o.get("couponCode"),!i)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),(n=g.getInstance().cartStore).removeCart(),d=i.split(","),a=d.map((function(o){var e=o.split(":"),t=e[0],r=e[1];return{variantId:t,quantity:parseInt(r)}})),m={variantLines:a,couponCode:s||void 0},[4,n.createCart(m)];case 2:return(c=t.sent()).success&&(u=j.getCurrentRouting(),v=(null==u?void 0:u.path)?"/".concat(u.path):"",window.location.href="".concat(v,"/checkout?id=").concat(null===(S=c.response.data)||void 0===S?void 0:S.id,"&step=info")),[3,4];case 3:return h=t.sent(),console.error("Error creating cart:",h),[3,4];case 4:return[2];case 5:return e?(k=!1,r&&r===l.SUCCESS&&(k=!0),[4,p({id:e,getCompletedCart:k,targetPageType:f.CHECKOUT})]):[2,F.replace("/")];case 6:if(b=t.sent(),B)return[3,10];t.label=7;case 7:return t.trys.push([7,9,,10]),[4,Promise.race([C.listCheckoutSettings({}),new Promise((function(o,e){return setTimeout((function(){return e(new Error("timeout"))}),1e4)}))])];case 8:return(P=t.sent()).isSuccess&&(null===(I=P.data)||void 0===I?void 0:I.length)?(O(P.data[0]),[3,10]):(console.error("CHECKOUT SETTINGS FETCH FAILED!"),L(!0),[2]);case 9:return w=t.sent(),console.error("CHECKOUT SETTINGS FETCH FAILED!",w),L(!0),[2];case 10:return b.isSuccess&&b.data?(_=b.data,T(new y(_)),g.getInstance().cartStore.setCart(new x(_))):b.errorCodes.some((function(o){return o===E.LOGIN_REQUIRED}))?F.replace("/account/login?redirect="+encodeURIComponent(window.location.href)):F.replace("/"),[2]}}))}))}),[]);if(D){var N=j.getMerchantSettings();return i.createElement(m,{logo:(null==k?void 0:k.logo)||(null==N?void 0:N.logo),merchantName:null==N?void 0:N.merchantName,backHref:c(),returnPolicy:P.returnPolicy,privacyPolicy:P.privacyPolicy,termsOfService:P.termsOfService,imprint:P.imprint,shippingPolicy:P.shippingPolicy})}return _&&B?i.createElement(n,r({checkout:_,customizationProps:k},P,{checkoutSettings:B})):i.createElement(a,null)}));export{k as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import o from"lodash/xorBy";import s from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";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 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"../../models/data/checkout/index.js";import"../../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"../../models/data/customer/address/index.js";import"../../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-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"../../models/data/order/address/region/index.js";import"../../models/data/order/address/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"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import{IkasRaffleParticipant as u}from"../../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"@ikas/localized-address";import d from"../raffle/index.js";import{APIResponse as l}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/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 h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g,MILES_SMILES_PROVIDER as w}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as C}from"@ikas/storefront-providers";import S from"../checkout/index.js";import{formatCurrency as k}from"../../utils/currency.js";var b=function(t){try{return new URL(t).searchParams.get("milesSmilesError")}catch(t){return null}},I=function(t){var e=function(t){try{return new URL(t).searchParams.get("redirectUrl")}catch(t){return null}}(t);if(!e)return window.location.href=t,Promise.resolve({isSuccess:!0});var r=function(t){try{return new URL(t).searchParams.get("transactionId")}catch(t){return null}}(e);return new Promise((function(i){var o,s=!1,n=function(t){s||(s=!0,window.removeEventListener("message",a),o&&window.clearInterval(o),i(t))},a=function(t){var i;try{i="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){return}if(i&&!0===i.isSuccess){var o={transactionId:r,token:i.token,memberId:i.ffid||i.memberId||i.memberID,shortTokenExpireMinute:i.tokenExpireMinute,longToken:i.longToken,longTokenExpireMinute:i.longTokenExpireMinute};if(!o.memberId||!o.token)return console.error("Miles&Smiles: missing token or memberId in popup message"),void n({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"});!function(t,e){var r=document.createElement("form");r.method="POST",r.action=t,r.style.display="none";for(var i=0,o=[["transactionId",e.transactionId||""],["token",e.token||""],["memberId",e.memberId||""],["shortTokenExpireMinute",null!=e.shortTokenExpireMinute?String(e.shortTokenExpireMinute):""],["longToken",e.longToken||""],["longTokenExpireMinute",null!=e.longTokenExpireMinute?String(e.longTokenExpireMinute):""]];i<o.length;i++){var s=o[i],n=s[0],a=s[1],c=document.createElement("input");c.type="hidden",c.name=n,c.value=a,r.appendChild(c)}document.body.appendChild(r),r.submit()}(e,o);try{null==c||c.close()}catch(t){}n({isSuccess:!0})}};window.addEventListener("message",a);var c=window.open(t,"mslogin","width=480,height=720");if(!c)return window.removeEventListener("message",a),window.location.href=t,void i({isSuccess:!0});o=window.setInterval((function(){c.closed&&n({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"})}),500)}))},y="undefined"==typeof localStorage,P=function(){function P(o){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,i){return t(a,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,i,o){return t(a,void 0,void 0,(function(){var t,s,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken,phone:o})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(s=t.data,this.setToken(s.token,s.tokenExpiry),s.customer&&this.setCustomer(s.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(i,o,s,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:s,password:c,firstName:i,lastName:o,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:s,firstName:i,lastName:o,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return i=e.sent(),this.clearCaptchaToken(),[2,i.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(i,o){return t(a,void 0,void 0,(function(){var t,s,a,c,u;return e(this,(function(e){switch(e.label){case 0:return i?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:i,captchaToken:this._captchaToken,otpInfo:o})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(i),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},i),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(i=t.data)||void 0===i?void 0:i.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,i,o){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:i,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(i=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderByEmail=function(r,i){return t(a,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:i})];case 1:return(t=e.sent()).isSuccess&&t.data?(o=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),o.refundSettings=this._refundSettings,[2,o]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,i,o,s,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(s=null===(o=r.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},i),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(i.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(i){return t(a,void 0,void 0,(function(){var t,o,s,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),o=p.getSalesChannelId(),s=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},i),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:o||"",locale:s})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(i){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer(r({},i&&{password:i}))]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,C(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,i,o;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(i=e.customerAttribute)||void 0===i?void 0:i.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,S.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,i){return t(a,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===i.variantId})),t?[4,S.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:o=e.sent(),(s=o.data)&&((n=document.createElement("a")).href=s,n.download=decodeURIComponent(i.name.split("/")[i.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,S.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:i}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,S.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:i=(null===(o=t.data)||void 0===o?void 0:o.amount)||0,formattedAmount:k(i,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=s(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=o,i(this)}return Object.defineProperty(P.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||y||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===o(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),P.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},P.prototype.socialLoginToken=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(i=t.data)||void 0===i?void 0:i.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},P.prototype.startMilesSmilesBind=function(r){return t(this,void 0,void 0,(function(){var t,i,o,s,n;return e(this,(function(e){switch(e.label){case 0:if("undefined"==typeof window)return[2,{isSuccess:!1}];if(!this.customer||!this.token)return[2,{isSuccess:!1,errorCode:"AUTHORIZATION_REQUIRED"}];t=function(t){return!!t&&t.startsWith("/")&&!t.startsWith("//")&&!t.includes("://")&&!t.includes("@")}(r)?r:"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(w,"/bind/authenticate?redirect=").concat(encodeURIComponent(t)),e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(i,{headers:{authorization:"Bearer ".concat(this.token),"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})];case 2:return(s=e.sent()).redirected&&s.url?(window.location.href=s.url,[2,{isSuccess:!1,errorCode:b(s.url)}]):s.ok?[4,s.json()]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 3:return n=e.sent(),o=null==n?void 0:n.redirectUrl,[3,5];case 4:return e.sent(),[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 5:return o?[2,I(o)]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}]}}))}))},P.prototype.getMilesSmilesLink=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,n.getExternalAccountLink({provider:w})]}))}))},P.prototype.unlinkMilesSmiles=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,n.unlinkExternalAccount({provider:w})]}))}))},P.prototype.refundOrder=function(r,i){return t(this,void 0,void 0,(function(){var t,o,s=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:i,orderId:r.id,orderLineItems:t}})];case 1:return(o=e.sent()).isSuccess&&o.data?(Object.entries(o.data).forEach((function(t){var e=t[0],r=t[1];s[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},P.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},P.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},P.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return y||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},P.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},P.prototype.setCustomer=function(t){this.customer=new a(t)},P.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=s(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},P.prototype.saveLastViewedProducts=function(){y||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},P.prototype.loadLastViewedProducts=function(){y||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=s(this._lastViewedProducts).reverse())},P.prototype.getLocalLastViewedProducts=function(){if(y)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},P.prototype.removeLastViewedProducts=function(){y||window.localStorage.removeItem("lastViewedProducts")},P.prototype.onProductView=function(r,i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:i}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},P.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(y)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},P.prototype.saveCustomerConsent=function(){y||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},P.prototype.loadCustomerConsent=function(){y||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},P.prototype.removeCustomerConsent=function(){y||window.localStorage.removeItem("customerConsent")},P.prototype.setToken=function(t,e){y||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},P.prototype.loadToken=function(){if(!y){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},P.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},P.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},P.prototype.clearCaptchaToken=function(){this._captchaToken=null},P.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},P}();export{P as IkasCustomerStore};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import o from"lodash/xorBy";import s from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";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 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"../../models/data/checkout/index.js";import"../../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"../../models/data/customer/address/index.js";import"../../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-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"../../models/data/order/address/region/index.js";import"../../models/data/order/address/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"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import{IkasRaffleParticipant as u}from"../../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"@ikas/localized-address";import d from"../raffle/index.js";import{APIResponse as l}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/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 h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g,MILES_SMILES_PROVIDER as w}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as C}from"@ikas/storefront-providers";import S from"../checkout/index.js";import{formatCurrency as k}from"../../utils/currency.js";var b=function(t){try{return new URL(t).searchParams.get("milesSmilesError")}catch(t){return null}},I=function(t){var e=function(t){try{return new URL(t).searchParams.get("redirectUrl")}catch(t){return null}}(t);if(!e)return window.location.href=t,Promise.resolve({isSuccess:!0});var r=function(t){try{return new URL(t).searchParams.get("transactionId")}catch(t){return null}}(e);return new Promise((function(i){var o,s=!1,n=function(t){s||(s=!0,window.removeEventListener("message",a),o&&window.clearInterval(o),i(t))},a=function(t){var i;try{i="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){return}if(i&&!0===i.isSuccess){var o={transactionId:r,token:i.token,memberId:i.ffid||i.memberId||i.memberID,shortTokenExpireMinute:i.tokenExpireMinute,longToken:i.longToken,longTokenExpireMinute:i.longTokenExpireMinute};if(!o.memberId||!o.token)return console.error("Miles&Smiles: missing token or memberId in popup message"),void n({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"});!function(t,e){var r=document.createElement("form");r.method="POST",r.action=t,r.style.display="none";for(var i=0,o=[["transactionId",e.transactionId||""],["token",e.token||""],["memberId",e.memberId||""],["shortTokenExpireMinute",null!=e.shortTokenExpireMinute?String(e.shortTokenExpireMinute):""],["longToken",e.longToken||""],["longTokenExpireMinute",null!=e.longTokenExpireMinute?String(e.longTokenExpireMinute):""]];i<o.length;i++){var s=o[i],n=s[0],a=s[1],c=document.createElement("input");c.type="hidden",c.name=n,c.value=a,r.appendChild(c)}document.body.appendChild(r),r.submit()}(e,o);try{null==c||c.close()}catch(t){}n({isSuccess:!0})}};window.addEventListener("message",a);var c=window.open(t,"mslogin","width=480,height=720");if(!c)return window.removeEventListener("message",a),window.location.href=t,void i({isSuccess:!0});o=window.setInterval((function(){c.closed&&n({isSuccess:!1,errorCode:"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"})}),500)}))},y="undefined"==typeof localStorage,P=function(){function P(o){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,i){return t(a,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,i,o){return t(a,void 0,void 0,(function(){var t,s,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken,phone:o})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(s=t.data,this.setToken(s.token,s.tokenExpiry),s.customer&&this.setCustomer(s.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(i,o,s,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:s,password:c,firstName:i,lastName:o,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:s,firstName:i,lastName:o,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return i=e.sent(),this.clearCaptchaToken(),[2,i.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(i,o){return t(a,void 0,void 0,(function(){var t,s,a,c,u;return e(this,(function(e){switch(e.label){case 0:return i?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:i,captchaToken:this._captchaToken,otpInfo:o})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(i),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},i),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(i=t.data)||void 0===i?void 0:i.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,i,o){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:i,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(i=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderByEmail=function(r,i){return t(a,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:i})];case 1:return(t=e.sent()).isSuccess&&t.data?(o=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),o.refundSettings=this._refundSettings,[2,o]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,i,o,s,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(s=null===(o=r.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},i),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(i.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(i){return t(a,void 0,void 0,(function(){var t,o,s,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),o=p.getSalesChannelId(),s=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},i),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:o||"",locale:s})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(i){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer(r({},i&&{password:i}))]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,C(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,i,o;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(i=e.customerAttribute)||void 0===i?void 0:i.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,S.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,i){return t(a,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===i.variantId})),t?[4,S.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:o=e.sent(),(s=o.data)&&((n=document.createElement("a")).href=s,n.download=decodeURIComponent(i.name.split("/")[i.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,S.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:i}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,S.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:i=(null===(o=t.data)||void 0===o?void 0:o.amount)||0,formattedAmount:k(i,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=s(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=o,i(this)}return Object.defineProperty(P.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||y||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===o(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),P.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},P.prototype.socialLoginToken=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(i=t.data)||void 0===i?void 0:i.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},P.prototype.startMilesSmilesBind=function(r){return t(this,void 0,void 0,(function(){var t,i,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:if("undefined"==typeof window)return[2,{isSuccess:!1}];if(!this.customer||!this.token)return[2,{isSuccess:!1,errorCode:"AUTHORIZATION_REQUIRED"}];t=function(t){return!!t&&t.startsWith("/")&&!t.startsWith("//")&&!t.includes("://")&&!t.includes("@")}(r)?r:"",i="local"===process.env.NEXT_PUBLIC_ENV?process.env.NEXT_PUBLIC_BASE_URL:window.location.origin+"/api/sf",o="".concat(i,"/ms/").concat(w,"/bind/authenticate?redirect=").concat(encodeURIComponent(t)),e.label=1;case 1:return e.trys.push([1,4,,5]),[4,fetch(o,{headers:{authorization:"Bearer ".concat(this.token),"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})];case 2:return(n=e.sent()).redirected&&n.url?(window.location.href=n.url,[2,{isSuccess:!1,errorCode:b(n.url)}]):n.ok?[4,n.json()]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 3:return a=e.sent(),s=null==a?void 0:a.redirectUrl,[3,5];case 4:return e.sent(),[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}];case 5:return s?[2,I(s)]:[2,{isSuccess:!1,errorCode:"UNEXPECTED_ERROR"}]}}))}))},P.prototype.getMilesSmilesLink=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,n.getExternalAccountLink({provider:w})]}))}))},P.prototype.unlinkMilesSmiles=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,n.unlinkExternalAccount({provider:w})]}))}))},P.prototype.refundOrder=function(r,i){return t(this,void 0,void 0,(function(){var t,o,s=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:i,orderId:r.id,orderLineItems:t}})];case 1:return(o=e.sent()).isSuccess&&o.data?(Object.entries(o.data).forEach((function(t){var e=t[0],r=t[1];s[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},P.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},P.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},P.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return y||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},P.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},P.prototype.setCustomer=function(t){this.customer=new a(t)},P.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=s(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},P.prototype.saveLastViewedProducts=function(){y||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},P.prototype.loadLastViewedProducts=function(){y||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=s(this._lastViewedProducts).reverse())},P.prototype.getLocalLastViewedProducts=function(){if(y)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},P.prototype.removeLastViewedProducts=function(){y||window.localStorage.removeItem("lastViewedProducts")},P.prototype.onProductView=function(r,i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:i}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},P.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(y)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},P.prototype.saveCustomerConsent=function(){y||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},P.prototype.loadCustomerConsent=function(){y||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},P.prototype.removeCustomerConsent=function(){y||window.localStorage.removeItem("customerConsent")},P.prototype.setToken=function(t,e){y||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},P.prototype.loadToken=function(){if(!y){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},P.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},P.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},P.prototype.clearCaptchaToken=function(){this._captchaToken=null},P.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},P}();export{P as IkasCustomerStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.372",
3
+ "version": "6.1.0-beta.374",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^6.1.0-beta.372",
27
- "@ikas/storefront-config": "^6.1.0-beta.372",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.372",
29
- "@ikas/storefront-models": "^6.1.0-beta.372",
30
- "@ikas/storefront-providers": "^6.1.0-beta.372",
26
+ "@ikas/storefront-api": "^6.1.0-beta.374",
27
+ "@ikas/storefront-config": "^6.1.0-beta.374",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.374",
29
+ "@ikas/storefront-models": "^6.1.0-beta.374",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.374",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^6.1.0-beta.372",
66
- "@ikas/storefront-config": "^6.1.0-beta.372",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.372",
68
- "@ikas/storefront-models": "^6.1.0-beta.372",
69
- "@ikas/storefront-providers": "^6.1.0-beta.372",
65
+ "@ikas/storefront-api": "^6.1.0-beta.374",
66
+ "@ikas/storefront-config": "^6.1.0-beta.374",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.374",
68
+ "@ikas/storefront-models": "^6.1.0-beta.374",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.374",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",