@ikas/storefront 3.0.0-alpha.46 → 3.0.0-alpha.47

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.
@@ -1 +1 @@
1
- import e from'../ext/safe-buffer/index.js';export{default}from"../node_modules/safe-buffer/index.js";
1
+ import e from'../ext/inline-style-parser/index.js';export{default}from"../node_modules/inline-style-parser/index.js";
@@ -1 +1 @@
1
- import e from'../ext/inline-style-parser/index.js';export{default}from"../node_modules/inline-style-parser/index.js";
1
+ import e from'../ext/safe-buffer/index.js';export{default}from"../node_modules/safe-buffer/index.js";
@@ -1 +1 @@
1
- import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
1
+ import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
@@ -1 +1 @@
1
- import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
1
+ import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as a}from"../../../../utils/currency.js";import{useTranslation as r}from"../../../../utils/i18n.js";import{Button as c}from"../button/index.js";import n from"./select/index.js";import o from"../svg/cross.js";import i from"./style.module.scss.js";var d=function(t){var a=t.seconds,c=t.rejectOffer,n=r().t,o=e.useState(a),d=o[0],s=o[1];e.useEffect((function(){var e=d>0&&setInterval((function(){return s(d-1)}),1e3);return 0===d&&c(),function(){return clearInterval(e)}}),[d]);return e.createElement("div",{className:i.CountdownContainer},e.createElement("div",{className:i.CountdownText},n("checkout-page:timeRemaining",{value:function(e){var t=Math.floor(e/60/60),a=Math.floor(e/60)-60*t,r=e%60;return 0!==t?t.toString().padStart(2,"0")+":":a.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")}(d)})))},s=t((function(t){var s,l=t.vm,u=t.campaignOffer,m=r().t,f=e.useState(u.productDetail.selectedVariant.id),p=f[0],v=f[1],g=function(){l.updateCartCampaignOffer({accepted:!1,cartId:l.checkout.id,campaignOfferId:u.campaignOffer.id,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p})};return e.createElement("div",{className:i.Container},u.offer.countdownMinutes&&e.createElement(d,{seconds:60*u.offer.countdownMinutes,rejectOffer:g}),e.createElement("div",{className:i.ContentContainer},e.createElement("div",{className:i.Header},e.createElement("div",{className:i.Title},u.offer.title),e.createElement("div",{className:i.RejectButton,onClick:g},e.createElement(o,null))),e.createElement("div",{className:i.ProductContainer},e.createElement("div",{className:i.ImageContainer},e.createElement("img",{className:i.Image,src:null===(s=u.productDetail.selectedVariant.mainImage)||void 0===s?void 0:s.thumbnailSrc})),e.createElement("div",{className:i.ProductDetails},e.createElement("div",{className:i.ProductName},u.productDetail.product.name),u.productDetail.product.brand&&e.createElement("div",{className:i.Brand},u.productDetail.product.brand.name),e.createElement("div",{className:i.ProductPrice},e.createElement("span",{className:i.Discount},a(u.productDetail.selectedVariant.price.finalPrice,l.checkout.currencyCode))," ",a(u.productDetail.selectedVariant.price.finalPrice-u.productDetail.selectedVariant.price.finalPrice*(u.offer.discountAmount||100)/100,l.checkout.currencyCode)),e.createElement("div",{className:i.Actions},u.productDetail.product.hasVariant&&u.productDetail.hasStock&&e.createElement(n,{value:p,onSelectChange:function(e){v(e)},options:u.productDetail.product.variants.filter((function(e){return e.hasStock})).map((function(e){return{label:e.variantValues.map((function(e){return e.name})).join(", "),value:e.id}}))}),e.createElement(c,{style:{width:"100%",height:44,fontSize:14},isDisabled:!u.productDetail.hasStock,text:m("checkout-page:actions.addToCart"),onClick:function(){l.updateCartCampaignOffer({accepted:!0,cartId:l.checkout.id,campaignOfferId:u.campaignOffer.id,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p})}}))))))}));export{s as default};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as a}from"../../../../utils/currency.js";import{useTranslation as r}from"../../../../utils/i18n.js";import{Button as n}from"../button/index.js";import c from"./select/index.js";import o from"../svg/cross.js";import i from"./style.module.scss.js";var d=function(t){var a=t.seconds,n=t.rejectOffer,c=r().t,o=e.useState(a),d=o[0],s=o[1];e.useEffect((function(){var e=d>0&&setInterval((function(){return s(d-1)}),1e3);return 0===d&&n(),function(){return clearInterval(e)}}),[d]);return e.createElement("div",{className:i.CountdownContainer},e.createElement("div",{className:i.CountdownText},c("checkout-page:timeRemaining",{value:function(e){var t=Math.floor(e/60/60),a=Math.floor(e/60)-60*t,r=e%60;return 0!==t?t.toString().padStart(2,"0")+":":a.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")}(d)})))},s=t((function(t){var s,m=t.vm,u=t.campaignOffer,l=r().t,f=e.useState(u.productDetail.selectedVariant),p=f[0],v=f[1],g=function(){m.updateCartCampaignOffer({accepted:!1,cartId:m.checkout.id,campaignOfferId:u.campaignOffer.campaignOfferId,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p.id})},h=Math.round(((new Date).getTime()-new Date(u.campaignOffer.offerStartDate).getTime())/1e3);return e.createElement("div",{className:i.Container},u.offer.countdownMinutes&&e.createElement(d,{seconds:h>60*u.offer.countdownMinutes?0:60*u.offer.countdownMinutes-h,rejectOffer:g}),e.createElement("div",{className:i.ContentContainer},e.createElement("div",{className:i.Header},e.createElement("div",{className:i.Title},u.offer.title),e.createElement("div",{className:i.RejectButton,onClick:g},e.createElement(o,null))),e.createElement("div",{className:i.ProductContainer},e.createElement("div",{className:i.ImageContainer},e.createElement("img",{className:i.Image,src:null===(s=p.mainImage)||void 0===s?void 0:s.thumbnailSrc})),e.createElement("div",{className:i.ProductDetails},e.createElement("div",{className:i.ProductName},u.productDetail.product.name),u.productDetail.product.brand&&e.createElement("div",{className:i.Brand},u.productDetail.product.brand.name),e.createElement("div",{className:i.ProductPrice},e.createElement("span",{className:i.Discount},a(p.price.finalPrice,m.checkout.currencyCode))," ",a(p.price.finalPrice-p.price.finalPrice*(u.offer.discountAmount||100)/100,m.checkout.currencyCode)),e.createElement("div",{className:i.Actions},u.productDetail.product.hasVariant&&u.productDetail.hasStock&&e.createElement(c,{value:p.id,onSelectChange:function(e){var t=u.productDetail.product.variants.find((function(t){return t.id===e}));t&&v(t)},options:u.productDetail.product.variants.filter((function(e){return e.hasStock})).map((function(e){return{label:e.variantValues.map((function(e){return e.name})).join(", "),value:e.id}}))}),e.createElement(n,{style:{width:"100%",height:44,fontSize:14},isDisabled:!u.productDetail.hasStock,text:l("checkout-page:actions.addToCart"),onClick:function(){m.updateCartCampaignOffer({accepted:!0,cartId:m.checkout.id,campaignOfferId:u.campaignOffer.campaignOfferId,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p.id})}}))))))}));export{s as default};
@@ -1 +1 @@
1
- import n from'../../../../ext/style-inject/dist/style-inject.es.js';var e={Container:"style-module_Container__3zW3x",CountdownContainer:"style-module_CountdownContainer__2-1gy",CountdownText:"style-module_CountdownText__X4H5U",ContentContainer:"style-module_ContentContainer__2Xs-1",Header:"style-module_Header__3xT0y",Title:"style-module_Title__2BmRm",RejectButton:"style-module_RejectButton__2ph9e",ProductContainer:"style-module_ProductContainer__1oWuO",ImageContainer:"style-module_ImageContainer__3HIYg",Image:"style-module_Image__3CWsj",ProductDetails:"style-module_ProductDetails__3qkC5",ProductName:"style-module_ProductName__hjoHz",Brand:"style-module_Brand__3LHOL",ProductPrice:"style-module_ProductPrice__2NcwT",Discount:"style-module_Discount__2mg3j",Actions:"style-module_Actions__1lwfq"};n(".style-module_Container__3zW3x {\n margin-top: 32px;\n margin-bottom: 48px;\n background-color: var(--checkout-card-bg-color);\n border-radius: 8px;\n}\n\n.style-module_CountdownContainer__2-1gy {\n display: flex;\n justify-content: center;\n padding: 6px;\n background-color: #cfced3;\n border-radius: 8px 8px 0 0;\n}\n\n.style-module_CountdownText__X4H5U {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_ContentContainer__2Xs-1 {\n padding: 24px;\n width: 100%;\n}\n\n.style-module_Header__3xT0y {\n display: flex;\n justify-content: space-between;\n}\n\n.style-module_Title__2BmRm {\n margin-bottom: 24px;\n font-size: 22px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n}\n\n.style-module_RejectButton__2ph9e {\n height: 35px;\n width: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 20px;\n margin-left: 12px;\n cursor: pointer;\n}\n\n.style-module_ProductContainer__1oWuO {\n display: flex;\n}\n\n.style-module_ImageContainer__3HIYg {\n height: 136px;\n width: 136px;\n position: relative;\n background-color: #fff;\n margin-right: 24px;\n border-radius: 8px;\n flex: 0 0 136px;\n}\n\n.style-module_Image__3CWsj {\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 8px;\n}\n\n.style-module_ProductDetails__3qkC5 {\n flex: 1;\n}\n\n.style-module_ProductName__hjoHz {\n margin-bottom: 2px;\n font-size: 16px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n line-height: 24px;\n}\n\n.style-module_Brand__3LHOL {\n margin-bottom: 2px;\n font-size: 14px;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_ProductPrice__2NcwT {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_Discount__2mg3j {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-secondary-text-color);\n text-decoration: line-through;\n}\n\n.style-module_Actions__1lwfq {\n display: flex;\n margin-top: 24px;\n}");export{e as default};
1
+ import n from'../../../../ext/style-inject/dist/style-inject.es.js';var e={Container:"style-module_Container__3zW3x",CountdownContainer:"style-module_CountdownContainer__2-1gy",CountdownText:"style-module_CountdownText__X4H5U",ContentContainer:"style-module_ContentContainer__2Xs-1",Header:"style-module_Header__3xT0y",Title:"style-module_Title__2BmRm",RejectButton:"style-module_RejectButton__2ph9e",ProductContainer:"style-module_ProductContainer__1oWuO",ImageContainer:"style-module_ImageContainer__3HIYg",Image:"style-module_Image__3CWsj",ProductDetails:"style-module_ProductDetails__3qkC5",ProductName:"style-module_ProductName__hjoHz",Brand:"style-module_Brand__3LHOL",ProductPrice:"style-module_ProductPrice__2NcwT",Discount:"style-module_Discount__2mg3j",Actions:"style-module_Actions__1lwfq"};n(".style-module_Container__3zW3x {\n margin: 32px 0 48px 0;\n background-color: var(--checkout-card-bg-color);\n border-radius: 8px;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_Container__3zW3x {\n margin: 24px 0 24px 0;\n border-radius: 0;\n }\n}\n\n.style-module_CountdownContainer__2-1gy {\n display: flex;\n justify-content: center;\n padding: 6px;\n background-color: #cfced3;\n border-radius: 8px 8px 0 0;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_CountdownContainer__2-1gy {\n border-radius: 0;\n }\n}\n\n.style-module_CountdownText__X4H5U {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_ContentContainer__2Xs-1 {\n padding: 24px;\n width: 100%;\n}\n\n.style-module_Header__3xT0y {\n display: flex;\n justify-content: space-between;\n}\n\n.style-module_Title__2BmRm {\n margin-bottom: 24px;\n font-size: 22px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n}\n\n.style-module_RejectButton__2ph9e {\n height: 35px;\n width: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 20px;\n margin-left: 12px;\n cursor: pointer;\n}\n\n.style-module_ProductContainer__1oWuO {\n display: flex;\n}\n\n.style-module_ImageContainer__3HIYg {\n height: 136px;\n width: 136px;\n position: relative;\n background-color: #fff;\n margin-right: 24px;\n border-radius: 8px;\n flex: 0 0 136px;\n}\n\n.style-module_Image__3CWsj {\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 8px;\n}\n\n.style-module_ProductDetails__3qkC5 {\n flex: 1;\n}\n\n.style-module_ProductName__hjoHz {\n margin-bottom: 2px;\n font-size: 16px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n line-height: 24px;\n}\n\n.style-module_Brand__3LHOL {\n margin-bottom: 2px;\n font-size: 14px;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_ProductPrice__2NcwT {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_Discount__2mg3j {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-secondary-text-color);\n text-decoration: line-through;\n}\n\n.style-module_Actions__1lwfq {\n display: flex;\n margin-top: 24px;\n}");export{e as default};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import m,{CheckoutStep as n}from"./model.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}from"../../storefront/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as E}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/register.js";import{ContactForm as f}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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as M}from"../image/index.js";import N,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import P from"./components/notification-box/index.js";import{FormItem as V}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as L}from"../page/head.js";import I from"./components/offer-product/index.js";import B from"./components/svg/ikas.js";import O from"./style.module.scss.js";var R=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,f=e.returnPolicy,M=e.privacyPolicy,N=e.termsOfService,F=p().t,P=i(),V=o.useState((function(){return new m(d,u,v,P,f,M,N,F,h||{})}))[0];return V.step===n.PAYMENT&&l.disableHTML(),o.useEffect((function(){V.checkoutSettings.isAccountRequired&&!V.checkout.hasCustomer&&P.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),l.beginCheckout(V.checkout),l.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){V.customizationProps=h,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")}(h)}),[h]),V.isCheckoutLoaded&&V.store.customerStore.initialized?V.checkout.hasCustomer&&(null===(t=V.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=V.checkout.customer)||void 0===r?void 0:r.id)?(P.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",V.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(L,{pageType:E.CHECKOUT,pageTitle:((null===(s=V.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+F("checkout-page:securePayment"),pageDescription:F("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:O.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:O.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:O.Left},o.createElement("div",{className:O.LeftContent},o.createElement("div",null,o.createElement(U,{vm:V}),V.hasStockError&&o.createElement("div",{className:O.ErrorContainer},o.createElement(T,{vm:V,error:V.error})),V.checkoutCampaignOffer&&V.step!==n.SUCCESS&&o.createElement(I,{vm:V,campaignOffer:V.checkoutCampaignOffer}),!V.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:V,allowExpand:!0}),V.step===n.SUCCESS?o.createElement(x,{vm:V}):o.createElement(H,{vm:V})),o.createElement("div",{className:O.Space})),o.createElement(G,{vm:V}))),o.createElement("div",{className:O.Right},o.createElement("div",{className:O.RightContent},o.createElement(g,{vm:V}),o.createElement("div",{className:O.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!V.policyModalText&&o.createElement(j,{title:V.policyModalTitle,modalContent:V.policyModalText,onClose:function(){V.policyModalText=""}}),V.isContactModalVisible&&o.createElement(Y,{vm:V,setVisible:V.setContactModalVisible}),V.mpVM.isLinkCardToClientModalVisible&&o.createElement(y,{visible:V.mpVM.isLinkCardToClientModalVisible,vm:V,onClose:V.mpVM.hideLinkCardToClientModal}),V.mpVM.isOtpModalVisible&&o.createElement(k,{vm:V,visible:V.mpVM.isOtpModalVisible,type:V.mpVM.otpModalType,onClose:V.mpVM.hideOtpModal}),V.mpVM.isResponseModalVisible&&o.createElement(C,{visible:V.mpVM.isResponseModalVisible,text:V.mpVM.mfsResponseModalText,onClose:V.mpVM.onResponseModalClose}),V.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:V.mpVM.isSuccessModalVisible,type:V.mpVM.successModalType,onClose:V.mpVM.onSuccessModalClose})))):o.createElement(S,null)})),U=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:O.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:O.Logo},o.createElement(M,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:O.LoginText},o.createElement("span",{className:O.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:O.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:O.CustomerInfo},o.createElement("div",{className:O.Name},i.checkout.customerFullName),o.createElement("div",{className:O.Email},i.checkout.customerEmail)))})),H=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case n.INFO:return o.createElement(u,{vm:t});case n.SHIPPING:return o.createElement(v,{vm:t});case n.PAYMENT:return o.createElement(h,{vm:t});case n.SUCCESS:return o.createElement(x,{vm:t})}}),[t,t.step]),s=[new F(r("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?o.createElement("div",{className:O.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:O.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==n.INFO?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new F(r("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new F(r("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?o.createElement("div",{className:O.AdressStepInfo},o.createElement(D,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:O.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===n.PAYMENT?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(D,{vm:t})):void 0)),o.createElement(N,{steps:s,stepContent:i})})),_=r((function(e){var t,r,i,s,a,m=e.vm,n=p().t,l=((null===(t=m.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=m.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:O.Address},o.createElement("div",{className:[O.Text,O.WithMBottom].join(" ")},(null===(i=m.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===m.deliveryMethod?o.createElement("div",{className:O.Text},l):o.createElement(o.Fragment,null,o.createElement("div",{className:O.Text},n("checkout-page:receiver")),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},l)),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(s=m.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===m.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[O.Text,O.WithMTop].join(" ")},n("checkout-page:pickUpLocation"))),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(a=m.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),D=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.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:O.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),G=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Footer},o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),Y=r((function(r){var i,s,a=r.vm,m=r.setVisible,n=p().t,l=o.useState(!1),c=l[0],d=l[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var E=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,m(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:n("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(P,{type:"success",title:n("checkout-page:contactFormSent"),content:n("checkout-page:contactFormDescription")})),o.createElement(V,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:n("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:n(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:E})),onClose:function(){return m(!1)}})}));export{R as default};
1
+ import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import m,{CheckoutStep as n}from"./model.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}from"../../storefront/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as E}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/register.js";import{ContactForm as f}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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as M}from"../image/index.js";import N,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as P}from"./components/fullscreen-loading/index.js";import S from"./components/notification-box/index.js";import{FormItem as V}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as L}from"../page/head.js";import I from"./components/offer-product/index.js";import B from"./components/svg/ikas.js";import O from"./style.module.scss.js";var R=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,f=e.returnPolicy,M=e.privacyPolicy,N=e.termsOfService,F=p().t,S=i(),V=o.useState((function(){return new m(d,u,v,S,f,M,N,F,h||{})}))[0];return V.step===n.PAYMENT&&l.disableHTML(),o.useEffect((function(){V.checkoutSettings.isAccountRequired&&!V.checkout.hasCustomer&&S.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),l.beginCheckout(V.checkout),l.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){V.customizationProps=h,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")}(h)}),[h]),V.isCheckoutLoaded&&V.store.customerStore.initialized?V.checkout.hasCustomer&&(null===(t=V.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=V.checkout.customer)||void 0===r?void 0:r.id)?(S.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",V.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(L,{pageType:E.CHECKOUT,pageTitle:((null===(s=V.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+F("checkout-page:securePayment"),pageDescription:F("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:O.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:O.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:O.Left},o.createElement("div",{className:O.LeftContent},o.createElement("div",null,o.createElement(U,{vm:V}),V.hasStockError&&o.createElement("div",{className:O.ErrorContainer},o.createElement(T,{vm:V,error:V.error})),!V.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:V,allowExpand:!0}),V.step===n.SUCCESS?o.createElement(x,{vm:V}):o.createElement(o.Fragment,null,V.checkoutCampaignOffer&&o.createElement(I,{vm:V,campaignOffer:V.checkoutCampaignOffer}),o.createElement(H,{vm:V}))),o.createElement("div",{className:O.Space})),o.createElement(G,{vm:V}))),o.createElement("div",{className:O.Right},o.createElement("div",{className:O.RightContent},o.createElement(g,{vm:V}),o.createElement("div",{className:O.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!V.policyModalText&&o.createElement(j,{title:V.policyModalTitle,modalContent:V.policyModalText,onClose:function(){V.policyModalText=""}}),V.isContactModalVisible&&o.createElement(Y,{vm:V,setVisible:V.setContactModalVisible}),V.mpVM.isLinkCardToClientModalVisible&&o.createElement(y,{visible:V.mpVM.isLinkCardToClientModalVisible,vm:V,onClose:V.mpVM.hideLinkCardToClientModal}),V.mpVM.isOtpModalVisible&&o.createElement(k,{vm:V,visible:V.mpVM.isOtpModalVisible,type:V.mpVM.otpModalType,onClose:V.mpVM.hideOtpModal}),V.mpVM.isResponseModalVisible&&o.createElement(C,{visible:V.mpVM.isResponseModalVisible,text:V.mpVM.mfsResponseModalText,onClose:V.mpVM.onResponseModalClose}),V.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:V.mpVM.isSuccessModalVisible,type:V.mpVM.successModalType,onClose:V.mpVM.onSuccessModalClose})))):o.createElement(P,null)})),U=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:O.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:O.Logo},o.createElement(M,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:O.LoginText},o.createElement("span",{className:O.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:O.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:O.CustomerInfo},o.createElement("div",{className:O.Name},i.checkout.customerFullName),o.createElement("div",{className:O.Email},i.checkout.customerEmail)))})),H=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case n.INFO:return o.createElement(u,{vm:t});case n.SHIPPING:return o.createElement(v,{vm:t});case n.PAYMENT:return o.createElement(h,{vm:t});case n.SUCCESS:return o.createElement(x,{vm:t})}}),[t,t.step]),s=[new F(r("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?o.createElement("div",{className:O.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:O.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==n.INFO?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new F(r("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new F(r("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?o.createElement("div",{className:O.AdressStepInfo},o.createElement(D,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:O.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===n.PAYMENT?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(D,{vm:t})):void 0)),o.createElement(N,{steps:s,stepContent:i})})),_=r((function(e){var t,r,i,s,a,m=e.vm,n=p().t,l=((null===(t=m.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=m.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:O.Address},o.createElement("div",{className:[O.Text,O.WithMBottom].join(" ")},(null===(i=m.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===m.deliveryMethod?o.createElement("div",{className:O.Text},l):o.createElement(o.Fragment,null,o.createElement("div",{className:O.Text},n("checkout-page:receiver")),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},l)),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(s=m.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===m.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[O.Text,O.WithMTop].join(" ")},n("checkout-page:pickUpLocation"))),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(a=m.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),D=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.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:O.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),G=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Footer},o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),Y=r((function(r){var i,s,a=r.vm,m=r.setVisible,n=p().t,l=o.useState(!1),c=l[0],d=l[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var E=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,m(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:n("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(S,{type:"success",title:n("checkout-page:contactFormSent"),content:n("checkout-page:contactFormDescription")})),o.createElement(V,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:n("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:n(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:E})),onClose:function(){return m(!1)}})}));export{R as default};
@@ -16,8 +16,8 @@ import { CreateStripePaymentIntentResponse } from "../../__api/models/CreateStri
16
16
  import { IkasCheckoutCustomizationProps } from ".";
17
17
  import MasterPassModel from "./modelMasterPass";
18
18
  import { CampaignOfferTargetPageTypeEnum, UpdateCartCampaignOfferInput } from "src/__api/types";
19
- import { CampaignOffer } from "src/__api/models/CampaignOffer";
20
19
  import { CampaignOfferProduct } from "src/__api/models/CampaignOfferProduct";
20
+ import { CartV2CampaignOffer } from "src/__api/models/CartV2CampaignOffer";
21
21
  export default class CheckoutViewModel {
22
22
  checkout: IkasCheckout;
23
23
  checkoutSettings: IkasCheckoutSettings;
@@ -130,7 +130,7 @@ export default class CheckoutViewModel {
130
130
  getProduct: (productId: string) => Promise<IkasProductDetail | null>;
131
131
  getCampaignOfferProducts: (tagetPage: CampaignOfferTargetPageTypeEnum) => Promise<{
132
132
  productDetail: IkasProductDetail;
133
- campaignOffer: import("src/__api/models/CampaignOffer").CampaignOfferData;
133
+ campaignOffer: IkasCartCampaignOffer;
134
134
  offer: import("src/__api/models/CampaignOfferProduct").CampaignOfferProductData;
135
135
  } | undefined>;
136
136
  getCampaignOffer: () => Promise<void>;
@@ -160,6 +160,6 @@ export declare type StockErrorData = {
160
160
  };
161
161
  export declare type CampaignOfferType = {
162
162
  productDetail: IkasProductDetail;
163
- campaignOffer: CampaignOffer;
163
+ campaignOffer: CartV2CampaignOffer;
164
164
  offer: CampaignOfferProduct;
165
165
  };
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as c}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as d}from"../../models/ui/product-detail/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import u from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as h}from"../../models/data/checkout-settings/index.js";import{Analytics as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import m from"../../models/data/checkout/index.js";import f from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import g from"../../store/checkout/index.js";import{CheckStocksLineInput as y}from"../../__api/models/CheckStocksLineInput.js";import S from"../../store/cart/api.js";import{SaveCartInput as k}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as b,PaymentGatewayTypeEnum as C,CartCampaignOfferStatus as I,TransactionStatusEnum as P,CampaignOfferTargetPageTypeEnum as A}from"../../__api/types/index.js";import w from"./modelMasterPass.js";import j from"../../store/product/index.js";import N from'../../ext/uuid/dist/esm-node/v4.js';var O,R,x=/^\d+$/,E="undefined"==typeof localStorage,T=function(){function x(x,T,G,_,L,U,V,F,H){var Y=this;this.checkout=new m,this.checkoutSettings=new h,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=O.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],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.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,c;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=O.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===O.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(O.INFO)];if(this.step!==O.PAYMENT||this.canProceedToPayment){if(![O.INFO,O.SUCCESS,O.SHIPPING,O.PAYMENT].includes(this.step))return[2,this.changeStep(O.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(O.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:R.PAYMENT_ERROR,data:n||null}),this.step!==O.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==O.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=O.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==O.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==O.PAYMENT&&this.step!==O.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===O.PAYMENT&&this.isInStoreDelivery&&(this.checkout.billingAddress=new a),this.step===O.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(O.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,p.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,f.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new k(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step===O.INFO&&(t.billingAddress=null),[4,S.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:R.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:R.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.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(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.checkStocks({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.stockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:R.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:R.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,g.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,g.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:R.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.getAvailableStockLocations({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:R.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:R.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,g.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(d=s.data)||void 0===d?void 0:d.length)?(n=s.data,this.step===O.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===O.PAYMENT&&(console.log("2",{paymentGateways:n}),(c=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=c,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:R.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,g.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Y.store.customerStore.customer?(null===(t=Y.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new c(Y.store.customerStore.customer)):Y.checkout.customer||(Y.checkout.customer=new c({}))},this.createShippingAddress=function(){var t;if(Y.checkout.shippingAddress)Y.selectedShippingAddressId=Y.checkout.shippingAddress.id||"-1",Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings;else{var e=null===(t=Y.store.customerStore.customer)||void 0===t?void 0:t.addresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.useDifferentAddress?(Y.checkout.billingAddress&&(Y.selectedBillingAddressId=Y.checkout.billingAddress.id||"-1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):Y.isInStoreDelivery?Y.checkout.billingAddress=new a(n(Y.checkout.billingAddress)||{}):Y.checkout.billingAddress=new a(n(Y.checkout.shippingAddress)||{}),Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onShippingMethodChange=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new m(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,S.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===O.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new m(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.shippingAddress=new a(s))}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.billingAddress=new a(s))}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||M(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||M(t))){if(0===(null===(e=Y.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(Y.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!M(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,a,c,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(d=this.store.customerStore.customer.addresses)||void 0===d?void 0:d.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:N()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return c=e.sent(),console.error(c),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onProceedToShippingClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(O.SHIPPING):this.changeStep(O.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(O.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h,p,m,f;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(c=this.mpVM.selectedCard)||void 0===c?void 0:c.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(d=this.cardData)||void 0===d?void 0:d.installmentCount)?[2]:[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name},paymentGatewayId:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.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===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===b.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===C.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[P.SUCCESS,P.AUTHORIZED].includes(r),a=r===P.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(f=null==s?void 0:s.data)||void 0===f?void 0:f.returnSlug))throw{type:R.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(O.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(O.INFO)},this.onBackToShippingClick=function(){Y.changeStep(O.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,g.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==O.SUCCESS&&(t.paymentMethodType===b.CREDIT_CARD&&t.type===C.INTERNAL&&(this.cardData=new u),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return E||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){Y.isContactModalVisible=t},this.getWaitingForActionCampaignOffer=function(t){if(Y.checkout.campaignOffers&&Y.checkout.campaignOffers.length){var e=Y.checkout.campaignOffers.filter((function(e){var i;return e.status===I.WAITING_FOR_ACTION&&(null===(i=e.campaignOffer)||void 0===i?void 0:i.targetPageTypes.some((function(e){return e===t})))}));if(e.length)return e[0]}return null},this.getOffer=function(t){return t.campaignOffer?t.campaignOffer.offers.find((function(e){return e.id===t.campaignOfferProductId})):null},this.getProduct=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,j.searchProducts({input:{productIdList:[i]}})];case 1:return(t=e.sent()).isSuccess&&t.data&&t.data.data&&t.data.data.length?(s=t.data.data[0],n=s.variants.find((function(t){return t.isActive})),[2,new d(s,(n||s.variants[0]).variantValues)]):[2,null]}}))}))},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=this.getWaitingForActionCampaignOffer(i))&&t.campaignOffer&&(s=this.getOffer(t))?[4,this.getProduct(s.productId)]:[3,2];case 1:if(n=e.sent())return[2,{productDetail:n,campaignOffer:t.campaignOffer,offer:s}];e.label=2;case 2:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(A.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(A.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,S.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(s=new m(t.data),[4,this.getCampaignOffer()]):[3,4];case 2:return e.sent(),this.checkout=s,[4,this.init()];case 3:e.sent(),e.label=4;case 4:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=x,this.checkoutSettings=T,this.router=_,this.returnPolicy=L,this.privacyPolicy=U,this.termsOfService=V,this.t=F,this.customizationProps=H,this.mpVM=new w,G&&(this.merchantSettings=G),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(x.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"finalPrice",{get:function(){return this.step===O.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===R.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==R.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===b.CREDIT_CARD&&i.type===C.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),x}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function M(t){return t&&x.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(O||(O={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(R||(R={}));export{O as CheckoutStep,R as ErrorType,T as default};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as c}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as d}from"../../models/ui/product-detail/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import u from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as h}from"../../models/data/checkout-settings/index.js";import{Analytics as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import m from"../../models/data/checkout/index.js";import f from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import g from"../../store/checkout/index.js";import{CheckStocksLineInput as y}from"../../__api/models/CheckStocksLineInput.js";import S from"../../store/cart/api.js";import{SaveCartInput as k}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as b,PaymentGatewayTypeEnum as C,CartCampaignOfferStatus as I,TransactionStatusEnum as P,CampaignOfferTargetPageTypeEnum as A}from"../../__api/types/index.js";import w from"./modelMasterPass.js";import j from"../../store/product/index.js";import N from'../../ext/uuid/dist/esm-node/v4.js';var O,R,x=/^\d+$/,E="undefined"==typeof localStorage,T=function(){function x(x,T,G,_,L,U,V,F,H){var Y=this;this.checkout=new m,this.checkoutSettings=new h,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=O.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],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.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,c;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=O.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===O.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(O.INFO)];if(this.step!==O.PAYMENT||this.canProceedToPayment){if(![O.INFO,O.SUCCESS,O.SHIPPING,O.PAYMENT].includes(this.step))return[2,this.changeStep(O.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(O.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:R.PAYMENT_ERROR,data:n||null}),this.step!==O.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==O.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=O.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==O.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==O.PAYMENT&&this.step!==O.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===O.PAYMENT&&this.isInStoreDelivery&&(this.checkout.billingAddress=new a),this.step===O.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(O.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,p.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,f.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new k(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step===O.INFO&&(t.billingAddress=null),[4,S.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:R.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:R.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.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(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.checkStocks({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.stockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:R.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:R.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,g.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,g.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:R.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.getAvailableStockLocations({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:R.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:R.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,g.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(d=s.data)||void 0===d?void 0:d.length)?(n=s.data,this.step===O.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===O.PAYMENT&&(console.log("2",{paymentGateways:n}),(c=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=c,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:R.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,g.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Y.store.customerStore.customer?(null===(t=Y.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new c(Y.store.customerStore.customer)):Y.checkout.customer||(Y.checkout.customer=new c({}))},this.createShippingAddress=function(){var t;if(Y.checkout.shippingAddress)Y.selectedShippingAddressId=Y.checkout.shippingAddress.id||"-1",Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings;else{var e=null===(t=Y.store.customerStore.customer)||void 0===t?void 0:t.addresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.useDifferentAddress?(Y.checkout.billingAddress&&(Y.selectedBillingAddressId=Y.checkout.billingAddress.id||"-1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):Y.isInStoreDelivery?Y.checkout.billingAddress=new a(n(Y.checkout.billingAddress)||{}):Y.checkout.billingAddress=new a(n(Y.checkout.shippingAddress)||{}),Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onShippingMethodChange=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new m(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,S.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===O.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new m(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.shippingAddress=new a(s))}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.billingAddress=new a(s))}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||M(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||M(t))){if(0===(null===(e=Y.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.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(Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(Y.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!M(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,a,c,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(d=this.store.customerStore.customer.addresses)||void 0===d?void 0:d.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:N()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return c=e.sent(),console.error(c),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onProceedToShippingClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(O.SHIPPING):this.changeStep(O.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(O.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h,p,m,f;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(c=this.mpVM.selectedCard)||void 0===c?void 0:c.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(d=this.cardData)||void 0===d?void 0:d.installmentCount)?[2]:[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name},paymentGatewayId:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.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===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===b.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===C.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[P.SUCCESS,P.AUTHORIZED].includes(r),a=r===P.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(f=null==s?void 0:s.data)||void 0===f?void 0:f.returnSlug))throw{type:R.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.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===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(O.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(O.INFO)},this.onBackToShippingClick=function(){Y.changeStep(O.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,g.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==O.SUCCESS&&(t.paymentMethodType===b.CREDIT_CARD&&t.type===C.INTERNAL&&(this.cardData=new u),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return E||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){Y.isContactModalVisible=t},this.getWaitingForActionCampaignOffer=function(t){if(Y.checkout.campaignOffers&&Y.checkout.campaignOffers.length){var e=Y.checkout.campaignOffers.filter((function(e){var i;return e.status===I.WAITING_FOR_ACTION&&(null===(i=e.campaignOffer)||void 0===i?void 0:i.targetPageTypes.some((function(e){return e===t})))}));if(e.length)return e[0]}return null},this.getOffer=function(t){return t.campaignOffer?t.campaignOffer.offers.find((function(e){return e.id===t.campaignOfferProductId})):null},this.getProduct=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,j.searchProducts({input:{productIdList:[i]}})];case 1:return(t=e.sent()).isSuccess&&t.data&&t.data.data&&t.data.data.length?(s=t.data.data[0],n=s.variants.find((function(t){return t.isActive})),[2,new d(s,(n||s.variants[0]).variantValues)]):[2,null]}}))}))},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=this.getWaitingForActionCampaignOffer(i))&&t.campaignOffer&&(s=this.getOffer(t))?[4,this.getProduct(s.productId)]:[3,2];case 1:if(n=e.sent())return[2,{productDetail:n,campaignOffer:t,offer:s}];e.label=2;case 2:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(A.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(A.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,S.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(this.checkout=new m(t.data),[4,this.init()]):[3,3];case 2:e.sent(),e.label=3;case 3:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=x,this.checkoutSettings=T,this.router=_,this.returnPolicy=L,this.privacyPolicy=U,this.termsOfService=V,this.t=F,this.customizationProps=H,this.mpVM=new w,G&&(this.merchantSettings=G),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(x.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"finalPrice",{get:function(){return this.step===O.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===R.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==R.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===b.CREDIT_CARD&&i.type===C.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),x}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function M(t){return t&&x.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(O||(O={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(R||(R={}));export{O as CheckoutStep,R as ErrorType,T as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "3.0.0-alpha.46",
3
+ "version": "3.0.0-alpha.47",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.js",
6
6
  "author": "Umut Ozan Yıldırım",