@ikas/storefront 2.0.42 → 2.0.45

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/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/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 e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
1
+ import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
@@ -1,4 +1,4 @@
1
- import { IkasProductDetail, IkasOrderLineItem, IkasCheckout, IkasCategory, IkasThemePageType, IkasOrderTransaction, IkasBrand } from "../models";
1
+ import { IkasProductDetail, IkasOrderLineItem, IkasCheckout, IkasCategory, IkasThemePageType, IkasOrderTransaction, IkasBrand, IkasCustomer } from "../models";
2
2
  import { CheckoutStep } from "../components/checkout/model";
3
3
  import { IkasCart } from "../models/data/cart";
4
4
  import { IkasEventSubscriber } from "./events";
@@ -24,7 +24,8 @@ export declare class Analytics {
24
24
  static disableHTML(): void;
25
25
  static addToWishlist(productId: string): void;
26
26
  static search(searchKeyword: string): void;
27
- static completeRegistration(email: string, customerId?: string): void;
27
+ static completeRegistration(customer: IkasCustomer): void;
28
+ static createEmailSubscripition(email: string): void;
28
29
  static customerLogin(): Promise<void>;
29
30
  static customerLogout(): Promise<void>;
30
31
  static customerVisit(): Promise<void>;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/index.js";import{IkasBrand as i}from"../models/data/brand/index.js";import{IkasCategory as s}from"../models/data/category/index.js";import{IkasCheckout as a}from"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/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 c}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{FacebookPixel as n}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasCart as d}from"../models/data/cart/index.js";import{IkasEventType as m}from"./events.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import p from'../ext/lodash/cloneDeep.js';import{tryForEach as b}from"../utils/helper.js";import"../utils/i18n.js";import f from"./ikas.js";import{GoogleAnalytics as h}from"./googleAnalytics.js";import{GoogleUniversal as g}from"./googleUniversal.js";var v=function(){function v(){o(this)}return v.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=l.store).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},v.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=window.location.href,[4,v.getCustomerInfo()];case 1:return o=e.sent(),u.pageView(t),f.pageView(r),b(v.subscribers,(function(e){e.callback({type:m.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,3];case 2:return i=e.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},v.productView=function(t){try{if(n.productView(t),u.productView(t),f.productView(t),h.productView(t),g.productView(t),v.subscribers.length){var e=p(t),r=new c(e.product,e.selectedVariantValues);b(v.subscribers,(function(t){t.callback({type:m.PRODUCT_VIEW,data:{productDetail:r}})}))}}catch(t){console.error(t)}},v.addToCart=function(t,e,r,o){try{if(n.addToCart(t,e,r),u.addToCart(t,e),f.addToCart(t,e,o),h.addToCart(t,e),g.addToCart(t,e),v.subscribers.length){var i=p(t),s=new d(p(o));b(v.subscribers,(function(t){t.callback({type:m.ADD_TO_CART,data:{item:i,quantity:e,cart:s}})}))}}catch(t){console.error(t)}},v.removeFromCart=function(t,e,r){try{if(u.removeFromCart(t,e),h.removeFromCart(t,e),g.removeFromCart(t,e),v.subscribers.length){var o=p(t),i=new d(p(r));b(v.subscribers,(function(t){t.callback({type:m.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:i}})}))}}catch(t){console.error(t)}},v.beginCheckout=function(t){try{var e=localStorage.getItem("gtmBeginCheckout");if(e&&t.id===e)return;if(localStorage.setItem("gtmBeginCheckout",t.id),n.beginCheckout(t),u.beginCheckout(t),f.beginCheckout(t),h.beginCheckout(t),v.subscribers.length){var r=new a(p(t));b(v.subscribers,(function(t){t.callback({type:m.BEGIN_CHECKOUT,data:{checkout:r}})}))}}catch(t){console.error(t)}},v.purchase=function(t,e){try{if(localStorage.removeItem("gtmBeginCheckout"),n.purchase(t,t.orderNumber||""),u.purchase(t,t.orderNumber||""),f.orderSuccess(t),h.purchase(t,t.orderNumber||""),g.purchase(t,t.orderNumber||""),v.subscribers.length){var r=new a(p(t)),o=p(e);b(v.subscribers,(function(t){t.callback({type:m.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(t){console.error(t)}},v.checkoutStep=function(t,e){try{if(u.checkoutStep(t,e),f.checkoutStep(t,e),h.checkoutStep(t,e),v.subscribers.length){var r=new a(p(t));b(v.subscribers,(function(t){t.callback({type:m.CHECKOUT_STEP,data:{checkout:r,step:e}})}))}}catch(t){console.error(t)}},v.disableHTML=function(){try{u.disableHTML()}catch(t){console.error(t)}},v.addToWishlist=function(t){try{n.addToWishlist(t),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},v.search=function(t){try{n.search(t),u.search(t),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},v.completeRegistration=function(t,e){try{n.completeRegistration(),u.completeRegistration(),f.customerRegister(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.CUSTOMER_REGISTER,data:{email:t}})}))}catch(t){console.error(t)}},v.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerLogin(t.email),f.customerLogin(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.CUSTOMER_LOGIN,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},v.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},v.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerVisit(t.email),f.customerVisit(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.CUSTOMER_VISIT,data:{customer:t}})})),[3,3]):[2];case 2:return r=e.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},v.viewCart=function(t){try{if(t&&(n.viewCart(t),f.viewCart(t),h.viewCart(t),v.subscribers.length)){var e=new d(p(t));b(v.subscribers,(function(t){t.callback({type:m.VIEW_CART,data:{cart:e}})}))}}catch(t){console.error(t)}},v.viewCategory=function(t,e){try{if(n.viewCategory(t),u.viewCategory(e,t),f.viewCategory(e),v.subscribers.length){var r=new s(p(e));b(v.subscribers,(function(e){e.callback({type:m.VIEW_CATEGORY,data:{categoryPath:t,category:r}})}))}}catch(t){console.error(t)}},v.viewBrand=function(t){try{if(f.viewBrand(t),v.subscribers.length){var e=new i(p(t));b(v.subscribers,(function(t){t.callback({type:m.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},v.viewSearchResults=function(t,e){try{if(v.subscribers.length){var r=p(e).map((function(t){return new c(t.product,t.selectedVariantValues)}));b(v.subscribers,(function(e){e.callback({type:m.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},v.viewListing=function(t){try{if(v.subscribers.length){var e=p(t).map((function(t){return new c(t.product,t.selectedVariantValues)}));b(v.subscribers,(function(t){t.callback({type:m.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},v.contactForm=function(t){try{if(n.contactForm(),v.subscribers.length){var e=p(t);b(v.subscribers,(function(t){t.callback({type:m.CONTACT_FORM,data:{form:e}})}))}}catch(t){console.error(t)}},v.subscribers=[],v}();export{v as Analytics};
1
+ import{__awaiter as e,__generator as t,__assign as r}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/index.js";import{IkasBrand as i}from"../models/data/brand/index.js";import{IkasCategory as s}from"../models/data/category/index.js";import{IkasCheckout as a}from"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/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 c}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{FacebookPixel as n}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasCart as d}from"../models/data/cart/index.js";import{IkasEventType as m}from"./events.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import p from'../ext/lodash/cloneDeep.js';import{tryForEach as b}from"../utils/helper.js";import"../utils/i18n.js";import f from"./ikas.js";import{GoogleAnalytics as h}from"./googleAnalytics.js";import{GoogleUniversal as g}from"./googleUniversal.js";var v=function(){function v(){o(this)}return v.getCustomerInfo=function(){return e(this,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:return[4,(e=l.store).customerStore.waitUntilInitialized()];case 1:return t.sent(),(o=e.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:e.customerStore.customerConsentGranted})]:[2,null]}}))}))},v.pageView=function(r){return e(this,void 0,void 0,(function(){var e,o,i;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=window.location.href,[4,v.getCustomerInfo()];case 1:return o=t.sent(),u.pageView(e),f.pageView(r),b(v.subscribers,(function(t){t.callback({type:m.PAGE_VIEW,data:{url:e,pageType:r,customer:o}})})),[3,3];case 2:return i=t.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},v.productView=function(e){try{if(n.productView(e),u.productView(e),f.productView(e),h.productView(e),g.productView(e),v.subscribers.length){var t=p(e),r=new c(t.product,t.selectedVariantValues);b(v.subscribers,(function(e){e.callback({type:m.PRODUCT_VIEW,data:{productDetail:r}})}))}}catch(e){console.error(e)}},v.addToCart=function(e,t,r,o){try{if(n.addToCart(e,t,r),u.addToCart(e,t),f.addToCart(e,t,o),h.addToCart(e,t),g.addToCart(e,t),v.subscribers.length){var i=p(e),s=new d(p(o));b(v.subscribers,(function(e){e.callback({type:m.ADD_TO_CART,data:{item:i,quantity:t,cart:s}})}))}}catch(e){console.error(e)}},v.removeFromCart=function(e,t,r){try{if(u.removeFromCart(e,t),h.removeFromCart(e,t),g.removeFromCart(e,t),v.subscribers.length){var o=p(e),i=new d(p(r));b(v.subscribers,(function(e){e.callback({type:m.REMOVE_FROM_CART,data:{item:o,quantity:t,cart:i}})}))}}catch(e){console.error(e)}},v.beginCheckout=function(e){try{var t=localStorage.getItem("gtmBeginCheckout");if(t&&e.id===t)return;if(localStorage.setItem("gtmBeginCheckout",e.id),n.beginCheckout(e),u.beginCheckout(e),f.beginCheckout(e),h.beginCheckout(e),v.subscribers.length){var r=new a(p(e));b(v.subscribers,(function(e){e.callback({type:m.BEGIN_CHECKOUT,data:{checkout:r}})}))}}catch(e){console.error(e)}},v.purchase=function(e,t){try{if(localStorage.removeItem("gtmBeginCheckout"),n.purchase(e,e.orderNumber||""),u.purchase(e,e.orderNumber||""),f.orderSuccess(e),h.purchase(e,e.orderNumber||""),g.purchase(e,e.orderNumber||""),v.subscribers.length){var r=new a(p(e)),o=p(t);b(v.subscribers,(function(e){e.callback({type:m.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(e){console.error(e)}},v.checkoutStep=function(e,t){try{if(u.checkoutStep(e,t),f.checkoutStep(e,t),h.checkoutStep(e,t),v.subscribers.length){var r=new a(p(e));b(v.subscribers,(function(e){e.callback({type:m.CHECKOUT_STEP,data:{checkout:r,step:t}})}))}}catch(e){console.error(e)}},v.disableHTML=function(){try{u.disableHTML()}catch(e){console.error(e)}},v.addToWishlist=function(e){try{n.addToWishlist(e),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.ADD_TO_WISHLIST,data:{productId:e}})}))}catch(e){console.error(e)}},v.search=function(e){try{n.search(e),u.search(e),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.SEARCH,data:{searchKeyword:e}})}))}catch(e){console.error(e)}},v.completeRegistration=function(e){try{n.completeRegistration(),u.completeRegistration(),f.customerRegister(),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.CUSTOMER_REGISTER,data:{email:e.email,firstName:e.firstName,lastName:e.lastName}})}))}catch(e){console.error(e)}},v.createEmailSubscripition=function(e){try{v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.EMAIL_SUBSCRIPTION,data:{email:e}})}))}catch(e){console.error(e)}},v.customerLogin=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.getCustomerInfo()];case 1:return(e=t.sent())&&e.email?(u.customerLogin(e.email),f.customerLogin(),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.CUSTOMER_LOGIN,data:{customer:e}})})),[3,3]):[2];case 2:return r=t.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},v.customerLogout=function(){return e(this,void 0,void 0,(function(){return t(this,(function(e){try{v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:m.CUSTOMER_LOGOUT,data:{}})}))}catch(e){console.error(e)}return[2]}))}))},v.customerVisit=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v.getCustomerInfo()];case 1:return(e=t.sent())&&e.email?(u.customerVisit(e.email),f.customerVisit(),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:m.CUSTOMER_VISIT,data:{customer:e}})})),[3,3]):[2];case 2:return r=t.sent(),console.error(r),[3,3];case 3:return[2]}}))}))},v.viewCart=function(e){try{if(e&&(n.viewCart(e),f.viewCart(e),h.viewCart(e),v.subscribers.length)){var t=new d(p(e));b(v.subscribers,(function(e){e.callback({type:m.VIEW_CART,data:{cart:t}})}))}}catch(e){console.error(e)}},v.viewCategory=function(e,t){try{if(n.viewCategory(e),u.viewCategory(t,e),f.viewCategory(t),v.subscribers.length){var r=new s(p(t));b(v.subscribers,(function(t){t.callback({type:m.VIEW_CATEGORY,data:{categoryPath:e,category:r}})}))}}catch(e){console.error(e)}},v.viewBrand=function(e){try{if(f.viewBrand(e),v.subscribers.length){var t=new i(p(e));b(v.subscribers,(function(e){e.callback({type:m.VIEW_BRAND,data:{brand:t}})}))}}catch(e){console.error(e)}},v.viewSearchResults=function(e,t){try{if(v.subscribers.length){var r=p(t).map((function(e){return new c(e.product,e.selectedVariantValues)}));b(v.subscribers,(function(t){t.callback({type:m.VIEW_SEARCH_RESULTS,data:{searchKeyword:e,productDetails:r}})}))}}catch(e){console.error(e)}},v.viewListing=function(e){try{if(v.subscribers.length){var t=p(e).map((function(e){return new c(e.product,e.selectedVariantValues)}));b(v.subscribers,(function(e){e.callback({type:m.VIEW_LISTING,data:{productDetails:t}})}))}}catch(e){console.error(e)}},v.contactForm=function(e){try{if(n.contactForm(),v.subscribers.length){var t=p(e);b(v.subscribers,(function(e){e.callback({type:m.CONTACT_FORM,data:{form:t}})}))}}catch(e){console.error(e)}},v.subscribers=[],v}();export{v as Analytics};
@@ -24,7 +24,8 @@ export declare enum IkasEventType {
24
24
  VIEW_BRAND = "VIEW_BRAND",
25
25
  VIEW_SEARCH_RESULTS = "VIEW_SEARCH_RESULTS",
26
26
  VIEW_LISTING = "VIEW_LISTING",
27
- CONTACT_FORM = "CONTACT_FORM"
27
+ CONTACT_FORM = "CONTACT_FORM",
28
+ EMAIL_SUBSCRIPTION = "EMAIL_SUBSCRIPTION"
28
29
  }
29
30
  export declare type IkasEventSubscriber = {
30
31
  id: string;
@@ -1 +1 @@
1
- import{Analytics as s}from"./analytics.js";function r(r){var E=function(r){if(i(r)){var E=s.subscribers.findIndex((function(s){return s.id===r.id}));-1!==E?s.subscribers[E]=r:s.subscribers.push(r)}};return r.forEach(E),{subscribe:E,unsubscribe:function(r){var E=s.subscribers.findIndex((function(s){return s.id===r}));-1!==E&&s.subscribers.splice(E,1)}}}function E(){if("undefined"!=typeof window){var s=[];try{var E=window.IkasEvents;E&&E.subscribers&&E.subscribers.length&&(s=E.subscribers)}catch(s){}window.IkasEvents=r(s)}}function n(){return"<script>\n var subscribers = [];\n var subscribe = (subscriber) => { subscribers.push(subscriber); }; \n var unsubscribe = () => {};\n \n window.IkasEvents = {\n subscribers,\n subscribe,\n unsubscribe\n };\n <\/script>"}function i(s){return!!(s&&s.id&&"string"==typeof s.id&&s.callback&&"function"==typeof s.callback)}var T;!function(s){s.PAGE_VIEW="PAGE_VIEW",s.PRODUCT_VIEW="PRODUCT_VIEW",s.ADD_TO_CART="ADD_TO_CART",s.REMOVE_FROM_CART="REMOVE_FROM_CART",s.BEGIN_CHECKOUT="BEGIN_CHECKOUT",s.CHECKOUT_STEP="CHECKOUT_STEP",s.COMPLETE_CHECKOUT="COMPLETE_CHECKOUT",s.ADD_TO_WISHLIST="ADD_TO_WISHLIST",s.SEARCH="SEARCH",s.CUSTOMER_REGISTER="CUSTOMER_REGISTER",s.CUSTOMER_LOGIN="CUSTOMER_LOGIN",s.CUSTOMER_LOGOUT="CUSTOMER_LOGOUT",s.CUSTOMER_VISIT="CUSTOMER_VISIT",s.VIEW_CART="VIEW_CART",s.VIEW_CATEGORY="VIEW_CATEGORY",s.VIEW_BRAND="VIEW_BRAND",s.VIEW_SEARCH_RESULTS="VIEW_SEARCH_RESULTS",s.VIEW_LISTING="VIEW_LISTING",s.CONTACT_FORM="CONTACT_FORM"}(T||(T={}));export{T as IkasEventType,r as IkasEvents,n as getIkasEventsScript,E as initIkasEvents,i as isValidIkasEventSubscriber};
1
+ import{Analytics as s}from"./analytics.js";function E(E){var r=function(E){if(T(E)){var r=s.subscribers.findIndex((function(s){return s.id===E.id}));-1!==r?s.subscribers[r]=E:s.subscribers.push(E)}};return E.forEach(r),{subscribe:r,unsubscribe:function(E){var r=s.subscribers.findIndex((function(s){return s.id===E}));-1!==r&&s.subscribers.splice(r,1)}}}function r(){if("undefined"!=typeof window){var s=[];try{var r=window.IkasEvents;r&&r.subscribers&&r.subscribers.length&&(s=r.subscribers)}catch(s){}window.IkasEvents=E(s)}}function n(){return"<script>\n var subscribers = [];\n var subscribe = (subscriber) => { subscribers.push(subscriber); }; \n var unsubscribe = () => {};\n \n window.IkasEvents = {\n subscribers,\n subscribe,\n unsubscribe\n };\n <\/script>"}function T(s){return!!(s&&s.id&&"string"==typeof s.id&&s.callback&&"function"==typeof s.callback)}var i;!function(s){s.PAGE_VIEW="PAGE_VIEW",s.PRODUCT_VIEW="PRODUCT_VIEW",s.ADD_TO_CART="ADD_TO_CART",s.REMOVE_FROM_CART="REMOVE_FROM_CART",s.BEGIN_CHECKOUT="BEGIN_CHECKOUT",s.CHECKOUT_STEP="CHECKOUT_STEP",s.COMPLETE_CHECKOUT="COMPLETE_CHECKOUT",s.ADD_TO_WISHLIST="ADD_TO_WISHLIST",s.SEARCH="SEARCH",s.CUSTOMER_REGISTER="CUSTOMER_REGISTER",s.CUSTOMER_LOGIN="CUSTOMER_LOGIN",s.CUSTOMER_LOGOUT="CUSTOMER_LOGOUT",s.CUSTOMER_VISIT="CUSTOMER_VISIT",s.VIEW_CART="VIEW_CART",s.VIEW_CATEGORY="VIEW_CATEGORY",s.VIEW_BRAND="VIEW_BRAND",s.VIEW_SEARCH_RESULTS="VIEW_SEARCH_RESULTS",s.VIEW_LISTING="VIEW_LISTING",s.CONTACT_FORM="CONTACT_FORM",s.EMAIL_SUBSCRIPTION="EMAIL_SUBSCRIPTION"}(i||(i={}));export{i as IkasEventType,E as IkasEvents,n as getIkasEventsScript,r as initIkasEvents,T as isValidIkasEventSubscriber};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as n}from"mobx-react-lite";import o from'../../../../ext/lodash/sortBy.js';import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}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 s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import v from"../svg/arrow-down.js";import C from"../svg/cross.js";import h from"../svg/gift.js";import f from"./style.module.scss.js";import g from"../svg/ikas.js";var k=n((function(e){var t,n,o=e.vm,c=e.allowExpand,d=o.cart,p=o.checkout,E=u().t,C=a.useState(!c),h=C[0],k=C[1],x=a.useState(!1),j=x[0],A=x[1],w=a.useState(0),P=w[0],L=w[1],R=a.useState(null),I=R[0],D=R[1],_=a.useState(!1),B=_[0],U=_[1],V=a.useState(!1),F=V[0],G=V[1];a.useEffect((function(){c&&(h?I&&L(I.getBoundingClientRect().height):L(0))}),[h,I,c,B,F,j]);var M=[f.CartSummary,h?f.Visible:"",c?f.AllowExpand:""].join(" "),O=c?{height:P+"px"}:{},z=[f.ArrowDown,h?f.Rotated:""].join(" ");return d?a.createElement("div",{className:M},!!c&&a.createElement("div",{className:f.ExpandHeader,onClick:function(){return k(!h)}},a.createElement("div",{className:f.Left},E("checkout-page:summary")),a.createElement("div",{className:f.Price},a.createElement("span",{className:f.PriceText},"".concat(s(o.finalPrice||0,d.currencyCode)," (").concat(null===(t=o.cart)||void 0===t?void 0:t.items.length," ").concat(E("checkout-page:cartItemProduct"),")")),a.createElement("span",{className:z},a.createElement(v,null)))),a.createElement("div",{className:f.DetailsContainer,style:O},a.createElement("div",{className:f.Details,ref:D},null==d?void 0:d.items.map((function(e,t){return a.createElement("div",{key:t},a.createElement(m,{vm:o,cartItem:e,currencyCode:d.currencyCode}))})),a.createElement("div",{className:f.Divider}),a.createElement("div",{className:f.SubTotalInfo},j&&a.createElement("div",{className:f.NotificationContainer},a.createElement(l,{type:"warning",title:E("checkout-page:giftCodeErrorTitle"),content:E("checkout-page:giftCodeErrorDescription"),onClose:function(){return A(!1)}})),a.createElement(N,{label:E("checkout-page:subtotal"),value:s(d.totalPrice,d.currencyCode),tooltipText:E("checkout-page:subtotalTooltip")}),!!(null===(n=p.shippingLines)||void 0===n?void 0:n.length)&&a.createElement(N,{label:E("checkout-page:cartShippingTitle"),value:p.shippingTotal?s(p.shippingTotal,d.currencyCode):E("checkout-page:free")}),!!o.checkout.totalTax&&a.createElement(N,{label:E("checkout-page:cartTaxTitle"),value:s(o.checkout.totalTax,d.currencyCode)}),!!o.installmentExtraPrice&&a.createElement(N,{label:E("checkout-page:cartInterest"),value:s(o.installmentExtraPrice,d.currencyCode)}),a.createElement(y,{vm:o}),a.createElement(S,{vm:o}),(o.step===r.SUCCESS&&(!!o.checkout.note||!!o.checkout.appliedCouponCode)||o.step!==r.SUCCESS)&&a.createElement("div",{className:f.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),a.createElement(T,{vm:o,isAddingCoupon:F,setAddingCoupon:G,setCouponError:A}),a.createElement(b,{vm:o,isAddingNote:B,setAddingNote:U})),a.createElement("div",{className:f.TotalContainer},a.createElement("div",{className:f.TitleContainer},a.createElement("div",{className:f.Title},E("checkout-page:total"))),a.createElement("div",{className:f.TotalPrice},s(o.finalPrice||0,d.currencyCode))),a.createElement("div",{className:f.PoweredBy},a.createElement("span",null,"powered by"),a.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},a.createElement(g,null)))))):null})),N=n((function(e){var t=e.label,n=e.value,o=e.tooltipText;return a.createElement("div",{className:f.InfoRow},a.createElement("div",{className:f.Label},a.createElement("span",null,t),!!o&&a.createElement(E,{text:o,style:{marginLeft:"8px"}})),a.createElement("div",{className:f.Value},n))})),y=n((function(e){var t=e.vm,n=u().t;return t.cart?a.createElement(a.Fragment,null,o(t.checkout.nonCouponAdjustments||[],"order").map((function(e,o){return a.createElement("div",{className:f.InfoRow,key:o},a.createElement("div",{className:f.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",a.createElement("span",null,s(e.amount,t.cart.currencyCode))))}))):null})),S=n((function(e){var t,n,o=e.vm,c=u().t;return o.cart?a.createElement(a.Fragment,null,o.step!==r.SUCCESS&&((null===(t=o.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(o.checkout.totalFinalPrice||0,o.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return a.createElement("div",{className:f.InfoRow,key:t},a.createElement("div",{className:f.Label},e.name),a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",a.createElement("span",null,s(e.amount,o.cart.currencyCode))))})),null===(n=o.checkout.giftPackageLines)||void 0===n?void 0:n.map((function(e,t){return a.createElement("div",{className:f.InfoRow,key:t},a.createElement("div",{className:f.Label},a.createElement("div",{className:f.GiftLabel},a.createElement(h,{style:{position:"relative",top:"-1px"}}),a.createElement("span",null,c("checkout-page:giftPackage")))),a.createElement("div",{className:f.Value},a.createElement("span",null,s(e.price,o.cart.currencyCode))))}))):null})),T=n((function(n){var o=n.vm,l=n.isAddingCoupon,i=n.setAddingCoupon,m=n.setCouponError,d=u().t,p=a.useState(""),E=p[0],v=p[1],h=a.useState(!1),g=h[0],k=h[1];if(o.step===r.SUCCESS&&!o.checkout.appliedCouponCode)return null;var N=o.checkout.couponAdjustment;return a.createElement("div",{className:f.InfoRow},!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:f.ActionTextBtn,onClick:function(){return i(!0)}},d("checkout-page:addCouponCode")),l&&a.createElement(c,{value:E,placeholder:d("checkout-page:couponCode"),buttonLabel:d("checkout-page:actions.apply"),onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return o.checkout.couponCode=E,k(!0),[4,o.onCouponCodeApply()];case 1:return e.sent(),k(!1),v(""),o.checkout.appliedCouponCode?(i(!1),m(!1)):(m(!0),o.checkout.couponCode=null),[2]}}))}))},isLoading:g,onChange:v}),!!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:[f.ActionTextBtn,f.NoUnderline,f.Light].join(" ")},d("checkout-page:couponCode"),a.createElement("span",{className:f.AppliedCoupon},a.createElement("span",{className:f.CouponCode},o.checkout.appliedCouponCode),o.step!==r.SUCCESS&&a.createElement("span",{className:f.ClearCoupon,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return o.checkout.couponCode=null,k(!0),[4,o.onCouponCodeDelete()];case 1:return e.sent(),k(!1),[2]}}))}))}},a.createElement(C,null)))),!!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===(null==N?void 0:N.type)?"- ":"")," ",a.createElement("span",null,s((null==N?void 0:N.amount)||0,o.cart.currencyCode))))})),b=n((function(e){var t=e.vm,n=e.isAddingNote,o=e.setAddingNote,c=u().t,l=a.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=a.useCallback((function(){o(!0)}),[]),s=a.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:a.createElement("div",{className:f.InfoRow},!n&&!m&&a.createElement("div",{className:f.ActionTextBtn,onClick:i},l),(n||m)&&a.createElement("div",{className:[f.CheckoutNoteContainer,m?f.Success:""].join(" ")},a.createElement("div",{className:f.Title},c("checkout-page:orderNote")),m?a.createElement("div",{className:f.CheckoutNoteDisplay},t.checkout.note):a.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s})))}));export{k as CartSummary};
1
+ import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as n}from"mobx-react-lite";import o from'../../../../ext/lodash/sortBy.js';import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}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 s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import v from"../svg/arrow-down.js";import C from"../svg/cross.js";import h from"../svg/gift.js";import f from"./style.module.scss.js";import g from"../svg/ikas.js";var k=n((function(e){var t,n,o,c=e.vm,d=e.allowExpand,p=c.cart,E=c.checkout,C=u().t,h=a.useState(!d),k=h[0],x=h[1],j=a.useState(!1),w=j[0],A=j[1],P=a.useState(0),L=P[0],R=P[1],I=a.useState(null),D=I[0],_=I[1],B=a.useState(!1),U=B[0],V=B[1],F=a.useState(!1),G=F[0],M=F[1];a.useEffect((function(){d&&(k?D&&R(D.getBoundingClientRect().height):R(0))}),[k,D,d,U,G,w]);var z=[f.CartSummary,k?f.Visible:"",d?f.AllowExpand:""].join(" "),O=d?{height:L+"px"}:{},H=[f.ArrowDown,k?f.Rotated:""].join(" ");return p?a.createElement("div",{className:z},!!d&&a.createElement("div",{className:f.ExpandHeader,onClick:function(){return x(!k)}},a.createElement("div",{className:f.Left},C("checkout-page:summary")),a.createElement("div",{className:f.Price},a.createElement("span",{className:f.PriceText},"".concat(s(c.finalPrice||0,p.currencyCode)," (").concat(null===(t=c.cart)||void 0===t?void 0:t.items.length," ").concat(C("checkout-page:cartItemProduct"),")")),a.createElement("span",{className:H},a.createElement(v,null)))),a.createElement("div",{className:f.DetailsContainer,style:O},a.createElement("div",{className:f.Details,ref:_},null==p?void 0:p.items.map((function(e,t){return a.createElement("div",{key:t},a.createElement(m,{vm:c,cartItem:e,currencyCode:p.currencyCode}))})),a.createElement("div",{className:f.Divider}),a.createElement("div",{className:f.SubTotalInfo},w&&a.createElement("div",{className:f.NotificationContainer},a.createElement(l,{type:"warning",title:C("checkout-page:giftCodeErrorTitle"),content:C("checkout-page:giftCodeErrorDescription"),onClose:function(){return A(!1)}})),a.createElement(N,{label:C("checkout-page:subtotal"),value:s(p.totalPrice,p.currencyCode),tooltipText:C("checkout-page:subtotalTooltip")}),!!(null===(n=E.shippingLines)||void 0===n?void 0:n.length)&&a.createElement(N,{label:C("checkout-page:cartShippingTitle"),value:E.shippingTotal?s(E.shippingTotal,p.currencyCode):C("checkout-page:free")}),!!c.checkout.totalTax&&!!(null===(o=c.customizationProps)||void 0===o?void 0:o.showTax)&&a.createElement(N,{label:C("checkout-page:cartTaxTitle"),value:s(c.checkout.totalTax,p.currencyCode)}),!!c.installmentExtraPrice&&a.createElement(N,{label:C("checkout-page:cartInterest"),value:s(c.installmentExtraPrice,p.currencyCode)}),a.createElement(y,{vm:c}),a.createElement(S,{vm:c}),(c.step===r.SUCCESS&&(!!c.checkout.note||!!c.checkout.appliedCouponCode)||c.step!==r.SUCCESS)&&a.createElement("div",{className:f.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),a.createElement(T,{vm:c,isAddingCoupon:G,setAddingCoupon:M,setCouponError:A}),a.createElement(b,{vm:c,isAddingNote:U,setAddingNote:V})),a.createElement("div",{className:f.TotalContainer},a.createElement("div",{className:f.TitleContainer},a.createElement("div",{className:f.Title},C("checkout-page:total"))),a.createElement("div",{className:f.TotalPrice},s(c.finalPrice||0,p.currencyCode))),a.createElement("div",{className:f.PoweredBy},a.createElement("span",null,"powered by"),a.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},a.createElement(g,null)))))):null})),N=n((function(e){var t=e.label,n=e.value,o=e.tooltipText;return a.createElement("div",{className:f.InfoRow},a.createElement("div",{className:f.Label},a.createElement("span",null,t),!!o&&a.createElement(E,{text:o,style:{marginLeft:"8px"}})),a.createElement("div",{className:f.Value},n))})),y=n((function(e){var t=e.vm,n=u().t;return t.cart?a.createElement(a.Fragment,null,o(t.checkout.nonCouponAdjustments||[],"order").map((function(e,o){return a.createElement("div",{className:f.InfoRow,key:o},a.createElement("div",{className:f.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",a.createElement("span",null,s(e.amount,t.cart.currencyCode))))}))):null})),S=n((function(e){var t,n,o=e.vm,c=u().t;return o.cart?a.createElement(a.Fragment,null,o.step!==r.SUCCESS&&((null===(t=o.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(o.checkout.totalFinalPrice||0,o.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return a.createElement("div",{className:f.InfoRow,key:t},a.createElement("div",{className:f.Label},e.name),a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",a.createElement("span",null,s(e.amount,o.cart.currencyCode))))})),null===(n=o.checkout.giftPackageLines)||void 0===n?void 0:n.map((function(e,t){return a.createElement("div",{className:f.InfoRow,key:t},a.createElement("div",{className:f.Label},a.createElement("div",{className:f.GiftLabel},a.createElement(h,{style:{position:"relative",top:"-1px"}}),a.createElement("span",null,c("checkout-page:giftPackage")))),a.createElement("div",{className:f.Value},a.createElement("span",null,s(e.price,o.cart.currencyCode))))}))):null})),T=n((function(n){var o=n.vm,l=n.isAddingCoupon,i=n.setAddingCoupon,m=n.setCouponError,d=u().t,p=a.useState(""),E=p[0],v=p[1],h=a.useState(!1),g=h[0],k=h[1];if(o.step===r.SUCCESS&&!o.checkout.appliedCouponCode)return null;var N=o.checkout.couponAdjustment;return a.createElement("div",{className:f.InfoRow},!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:f.ActionTextBtn,onClick:function(){return i(!0)}},d("checkout-page:addCouponCode")),l&&a.createElement(c,{value:E,placeholder:d("checkout-page:couponCode"),buttonLabel:d("checkout-page:actions.apply"),onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return o.checkout.couponCode=E,k(!0),[4,o.onCouponCodeApply()];case 1:return e.sent(),k(!1),v(""),o.checkout.appliedCouponCode?(i(!1),m(!1)):(m(!0),o.checkout.couponCode=null),[2]}}))}))},isLoading:g,onChange:v}),!!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:[f.ActionTextBtn,f.NoUnderline,f.Light].join(" ")},d("checkout-page:couponCode"),a.createElement("span",{className:f.AppliedCoupon},a.createElement("span",{className:f.CouponCode},o.checkout.appliedCouponCode),o.step!==r.SUCCESS&&a.createElement("span",{className:f.ClearCoupon,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return o.checkout.couponCode=null,k(!0),[4,o.onCouponCodeDelete()];case 1:return e.sent(),k(!1),[2]}}))}))}},a.createElement(C,null)))),!!o.checkout.appliedCouponCode&&!l&&a.createElement("div",{className:f.Value},a.createElement("span",null,"DECREMENT"===(null==N?void 0:N.type)?"- ":"")," ",a.createElement("span",null,s((null==N?void 0:N.amount)||0,o.cart.currencyCode))))})),b=n((function(e){var t=e.vm,n=e.isAddingNote,o=e.setAddingNote,c=u().t,l=a.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=a.useCallback((function(){o(!0)}),[]),s=a.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:a.createElement("div",{className:f.InfoRow},!n&&!m&&a.createElement("div",{className:f.ActionTextBtn,onClick:i},l),(n||m)&&a.createElement("div",{className:[f.CheckoutNoteContainer,m?f.Success:""].join(" ")},a.createElement("div",{className:f.Title},c("checkout-page:orderNote")),m?a.createElement("div",{className:f.CheckoutNoteDisplay},t.checkout.note):a.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s})))}));export{k as CartSummary};
@@ -11,6 +11,7 @@ export declare type IkasCheckoutPageProps = {
11
11
  termsOfService: string;
12
12
  };
13
13
  export declare type IkasCheckoutCustomizationProps = {
14
+ showTax?: boolean;
14
15
  buttonBgColor?: string;
15
16
  buttonTextColor?: string;
16
17
  buttonDisabledBgColor?: string;
@@ -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,{CheckoutStep as c}from"./model.js";import n from"./steps/step-info/index.js";import{CheckoutStepShipping as a}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as m}from"./steps/step-payment/index.js";import{CartSummary as l}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as d}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 u}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 p}from"./steps/step-success/index.js";import{Modal as v}from"./components/modal/index.js";import h from"./style.module.scss.js";import{IkasPageHead as E}from"../page/head.js";import{Analytics as g}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{Image as f}from"../image/index.js";import x from"next/link.js";import y,{Step as k}from"./components/step-container/index.js";import{IkasStorefrontConfig as j}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 C}from"../../utils/currency.js";import{useTranslation as N}from"../../utils/i18n.js";import{StockError as b}from"./components/error/stock-error/index.js";import F from"./components/svg/ikas.js";import P from'../../ext/react-tooltip/dist/index.es.js';import{FullscreenLoading as T}from"./components/fullscreen-loading/index.js";import S from"./components/notification-box/index.js";import{FormItem as M}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";var I=r((function(e){var t,r,n,a=e.checkout,m=e.checkoutSettings,u=e.merchantSettings,f=e.customizationProps,x=e.returnPolicy,y=e.privacyPolicy,k=e.termsOfService,C=N().t,S=i(),M=o.useState((function(){return new s(a,m,u,S,x,y,k,C)}))[0];return M.step===c.PAYMENT&&g.disableHTML(),o.useEffect((function(){M.checkoutSettings.isAccountRequired&&!M.checkout.hasCustomer&&S.push("/account/login?redirect="+encodeURIComponent(M.checkoutUrl)),g.beginCheckout(M.checkout),g.pageView(d.CHECKOUT)}),[]),o.useEffect((function(){!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")}(f)}),[f]),M.isCheckoutLoaded&&M.store.customerStore.initialized?M.checkout.hasCustomer&&(null===(t=M.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=M.checkout.customer)||void 0===r?void 0:r.id)?(S.push("/account/login?redirect="+encodeURIComponent(M.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(E,{pageType:d.CHECKOUT,pageTitle:((null===(n=M.merchantSettings)||void 0===n?void 0:n.merchantName)||"")+" - "+C("checkout-page:securePayment"),pageDescription:C("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:h.CheckoutPage},o.createElement(P,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:h.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:h.Left},o.createElement("div",{className:h.LeftContent},o.createElement("div",null,o.createElement(B,{vm:M}),M.hasStockError&&o.createElement("div",{className:h.ErrorContainer},o.createElement(b,{vm:M,error:M.error})),!M.hasStockError&&o.createElement(o.Fragment,null,o.createElement("div",{className:h.MobileCartSummary},o.createElement(l,{vm:M,allowExpand:!0})),M.step===c.SUCCESS?o.createElement(p,{vm:M}):o.createElement(L,{vm:M})),o.createElement("div",{className:h.Space})),o.createElement(U,{vm:M}))),o.createElement("div",{className:h.Right},o.createElement("div",{className:h.RightContent},o.createElement(l,{vm:M}),o.createElement("div",{className:h.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===j.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(F,null))))),!!M.policyModalText&&o.createElement(v,{title:M.policyModalTitle,modalContent:M.policyModalText,onClose:function(){M.policyModalText=""}}),M.isContactModalVisible&&o.createElement(H,{vm:M,setVisible:M.setContactModalVisible}))):o.createElement(T,null)})),B=r((function(e){var t,r,i=e.vm,s=N().t;return o.createElement("div",{className:h.Header},o.createElement(x,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logoId)?o.createElement("div",{className:h.Logo},o.createElement(f,{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:h.LoginText},o.createElement("span",{className:h.LoginCta},s("checkout-page:alreadyHaveAnAccount")),o.createElement(x,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:h.LoginBtn},s("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:h.CustomerInfo},o.createElement("div",{className:h.Name},i.checkout.customerFullName),o.createElement("div",{className:h.Email},i.checkout.customerEmail)))})),L=r((function(e){var t=e.vm,r=N().t,i=o.useMemo((function(){switch(t.step){case c.INFO:return o.createElement(n,{vm:t});case c.SHIPPING:return o.createElement(a,{vm:t});case c.PAYMENT:return o.createElement(m,{vm:t});case c.SUCCESS:return o.createElement(p,{vm:t})}}),[t,t.step]),s=[new k(r("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:h.AdressStepInfo},o.createElement(O,{vm:t}),o.createElement("div",{className:h.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:h.AddressStepInfoMobile},o.createElement(O,{vm:t})):void 0),new k(r("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:h.AdressStepInfo},o.createElement(R,{vm:t}),t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:h.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:h.AddressStepInfoMobile},o.createElement(R,{vm:t})):void 0),new k(r("checkout-page:payment"),t.step===c.PAYMENT,!1)];return o.createElement(y,{steps:s,stepContent:i})})),O=r((function(e){var t,r,i,s,c,n=e.vm;return o.createElement("div",{className:h.Address},o.createElement("div",{className:[h.Text,h.WithMBottom].join(" ")},(null===(t=n.checkout.customer)||void 0===t?void 0:t.email)||""),o.createElement("div",{className:h.Text},((null===(r=n.checkout.customer)||void 0===r?void 0:r.firstName)||"")+" "+((null===(i=n.checkout.customer)||void 0===i?void 0:i.lastName)||"")),o.createElement("div",{className:[h.Text,h.Gray].join(" ")},null===(s=n.checkout.shippingAddress)||void 0===s?void 0:s.phone),o.createElement("div",{className:[h.Text,h.Gray].join(" ")},null===(c=n.checkout.shippingAddress)||void 0===c?void 0:c.addressText))})),R=r((function(e){var t=e.vm,r=N().t;return o.createElement("div",{className:h.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:h.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):C(t.checkout.shippingLines[0].price,t.checkout.cart.currencyCode)))):r("checkout-page:standartShipping"))})),U=r((function(e){var t=e.vm,r=N().t;return o.createElement("div",{className:h.Footer},o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:h.FooterBullet},"•"),o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:h.FooterBullet},"•"),o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),H=r((function(r){var i,s,c=r.vm,n=r.setVisible,a=N().t,m=o.useState(!1),l=m[0],d=m[1],p=o.useState(!1),h=p[0],E=p[1],g=o.useState(new u({message:{requiredRule:"",emailRule:"",minRule:""},store:c.store}))[0];g.email=c.checkout.customerEmail,g.firstName=(null===(i=c.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=c.checkout.customer)||void 0===s?void 0:s.lastName)||"";var f=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return h?[2,n(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&E(!0),d(!1),[2]}}))}))}),[l]);return o.createElement(v,{title:a("checkout-page:contactForm"),modalContent:o.createElement("div",null,h&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(S,{type:"success",title:a("checkout-page:contactFormSent"),content:a("checkout-page:contactFormDescription")})),o.createElement(M,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:a("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:a(h?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:l,isDisabled:!g.message,onClick:f})),onClose:function(){return n(!1)}})}));export{I 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,{CheckoutStep as c}from"./model.js";import n from"./steps/step-info/index.js";import{CheckoutStepShipping as a}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as m}from"./steps/step-payment/index.js";import{CartSummary as l}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as d}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 u}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 p}from"./steps/step-success/index.js";import{Modal as v}from"./components/modal/index.js";import h from"./style.module.scss.js";import{IkasPageHead as E}from"../page/head.js";import{Analytics as g}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{Image as f}from"../image/index.js";import x from"next/link.js";import y,{Step as k}from"./components/step-container/index.js";import{IkasStorefrontConfig as j}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 C}from"../../utils/currency.js";import{useTranslation as N}from"../../utils/i18n.js";import{StockError as b}from"./components/error/stock-error/index.js";import F from"./components/svg/ikas.js";import P from'../../ext/react-tooltip/dist/index.es.js';import{FullscreenLoading as T}from"./components/fullscreen-loading/index.js";import S from"./components/notification-box/index.js";import{FormItem as M}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";var I=r((function(e){var t,r,n,a=e.checkout,m=e.checkoutSettings,u=e.merchantSettings,f=e.customizationProps,x=e.returnPolicy,y=e.privacyPolicy,k=e.termsOfService,C=N().t,S=i(),M=o.useState((function(){return new s(a,m,u,S,x,y,k,C,f||{})}))[0];return M.step===c.PAYMENT&&g.disableHTML(),o.useEffect((function(){M.checkoutSettings.isAccountRequired&&!M.checkout.hasCustomer&&S.push("/account/login?redirect="+encodeURIComponent(M.checkoutUrl)),g.beginCheckout(M.checkout),g.pageView(d.CHECKOUT)}),[]),o.useEffect((function(){M.customizationProps=f,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")}(f)}),[f]),M.isCheckoutLoaded&&M.store.customerStore.initialized?M.checkout.hasCustomer&&(null===(t=M.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=M.checkout.customer)||void 0===r?void 0:r.id)?(S.push("/account/login?redirect="+encodeURIComponent(M.checkoutUrl)),null):o.createElement(o.Fragment,null,o.createElement(E,{pageType:d.CHECKOUT,pageTitle:((null===(n=M.merchantSettings)||void 0===n?void 0:n.merchantName)||"")+" - "+C("checkout-page:securePayment"),pageDescription:C("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:h.CheckoutPage},o.createElement(P,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:h.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:h.Left},o.createElement("div",{className:h.LeftContent},o.createElement("div",null,o.createElement(B,{vm:M}),M.hasStockError&&o.createElement("div",{className:h.ErrorContainer},o.createElement(b,{vm:M,error:M.error})),!M.hasStockError&&o.createElement(o.Fragment,null,o.createElement("div",{className:h.MobileCartSummary},o.createElement(l,{vm:M,allowExpand:!0})),M.step===c.SUCCESS?o.createElement(p,{vm:M}):o.createElement(L,{vm:M})),o.createElement("div",{className:h.Space})),o.createElement(U,{vm:M}))),o.createElement("div",{className:h.Right},o.createElement("div",{className:h.RightContent},o.createElement(l,{vm:M}),o.createElement("div",{className:h.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===j.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(F,null))))),!!M.policyModalText&&o.createElement(v,{title:M.policyModalTitle,modalContent:M.policyModalText,onClose:function(){M.policyModalText=""}}),M.isContactModalVisible&&o.createElement(H,{vm:M,setVisible:M.setContactModalVisible}))):o.createElement(T,null)})),B=r((function(e){var t,r,i=e.vm,s=N().t;return o.createElement("div",{className:h.Header},o.createElement(x,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logoId)?o.createElement("div",{className:h.Logo},o.createElement(f,{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:h.LoginText},o.createElement("span",{className:h.LoginCta},s("checkout-page:alreadyHaveAnAccount")),o.createElement(x,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:h.LoginBtn},s("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:h.CustomerInfo},o.createElement("div",{className:h.Name},i.checkout.customerFullName),o.createElement("div",{className:h.Email},i.checkout.customerEmail)))})),L=r((function(e){var t=e.vm,r=N().t,i=o.useMemo((function(){switch(t.step){case c.INFO:return o.createElement(n,{vm:t});case c.SHIPPING:return o.createElement(a,{vm:t});case c.PAYMENT:return o.createElement(m,{vm:t});case c.SUCCESS:return o.createElement(p,{vm:t})}}),[t,t.step]),s=[new k(r("checkout-page:address"),t.step===c.INFO,t.step!==c.INFO,t.step!==c.INFO?o.createElement("div",{className:h.AdressStepInfo},o.createElement(O,{vm:t}),o.createElement("div",{className:h.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==c.INFO?o.createElement("div",{className:h.AddressStepInfoMobile},o.createElement(O,{vm:t})):void 0),new k(r("checkout-page:shipping"),t.step===c.SHIPPING,t.step===c.PAYMENT,t.step===c.PAYMENT?o.createElement("div",{className:h.AdressStepInfo},o.createElement(R,{vm:t}),t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:h.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===c.PAYMENT?o.createElement("div",{className:h.AddressStepInfoMobile},o.createElement(R,{vm:t})):void 0),new k(r("checkout-page:payment"),t.step===c.PAYMENT,!1)];return o.createElement(y,{steps:s,stepContent:i})})),O=r((function(e){var t,r,i,s,c,n=e.vm;return o.createElement("div",{className:h.Address},o.createElement("div",{className:[h.Text,h.WithMBottom].join(" ")},(null===(t=n.checkout.customer)||void 0===t?void 0:t.email)||""),o.createElement("div",{className:h.Text},((null===(r=n.checkout.customer)||void 0===r?void 0:r.firstName)||"")+" "+((null===(i=n.checkout.customer)||void 0===i?void 0:i.lastName)||"")),o.createElement("div",{className:[h.Text,h.Gray].join(" ")},null===(s=n.checkout.shippingAddress)||void 0===s?void 0:s.phone),o.createElement("div",{className:[h.Text,h.Gray].join(" ")},null===(c=n.checkout.shippingAddress)||void 0===c?void 0:c.addressText))})),R=r((function(e){var t=e.vm,r=N().t;return o.createElement("div",{className:h.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:h.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):C(t.checkout.shippingLines[0].price,t.checkout.cart.currencyCode)))):r("checkout-page:standartShipping"))})),U=r((function(e){var t=e.vm,r=N().t;return o.createElement("div",{className:h.Footer},o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:h.FooterBullet},"•"),o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:h.FooterBullet},"•"),o.createElement("div",{className:h.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),H=r((function(r){var i,s,c=r.vm,n=r.setVisible,a=N().t,m=o.useState(!1),l=m[0],d=m[1],p=o.useState(!1),h=p[0],E=p[1],g=o.useState(new u({message:{requiredRule:"",emailRule:"",minRule:""},store:c.store}))[0];g.email=c.checkout.customerEmail,g.firstName=(null===(i=c.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=c.checkout.customer)||void 0===s?void 0:s.lastName)||"";var f=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return h?[2,n(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&E(!0),d(!1),[2]}}))}))}),[l]);return o.createElement(v,{title:a("checkout-page:contactForm"),modalContent:o.createElement("div",null,h&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(S,{type:"success",title:a("checkout-page:contactFormSent"),content:a("checkout-page:contactFormDescription")})),o.createElement(M,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:a("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:a(h?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:l,isDisabled:!g.message,onClick:f})),onClose:function(){return n(!1)}})}));export{I as default};
@@ -6,6 +6,7 @@ import { IkasStorefront } from "../../models/data/storefront";
6
6
  import CreditCardData from "./components/credit-card-form/model";
7
7
  import { IkasCheckoutSettings } from "../../models/data/checkout-settings";
8
8
  import { TFunction } from "../../utils/i18n";
9
+ import { IkasCheckoutCustomizationProps } from ".";
9
10
  export default class CheckoutViewModel {
10
11
  checkout: IkasCheckout;
11
12
  checkoutSettings: IkasCheckoutSettings;
@@ -19,6 +20,7 @@ export default class CheckoutViewModel {
19
20
  isChangingShippingMethod: boolean;
20
21
  isContactModalVisible: boolean;
21
22
  step: CheckoutStep;
23
+ customizationProps?: IkasCheckoutCustomizationProps | null;
22
24
  merchantSettings?: IkasMerchantSettings;
23
25
  cardData?: CreditCardData | null;
24
26
  paymentGateways: IkasPaymentGateway[];
@@ -38,7 +40,7 @@ export default class CheckoutViewModel {
38
40
  order?: IkasOrder;
39
41
  successTransaction?: IkasOrderTransaction;
40
42
  t: TFunction;
41
- constructor(checkout: IkasCheckout, checkoutSettings: IkasCheckoutSettings, merchantSettings: IkasMerchantSettings | null, router: NextRouter, returnPolicy: string, privacyPolicy: string, termsOfService: string, t: TFunction);
43
+ constructor(checkout: IkasCheckout, checkoutSettings: IkasCheckoutSettings, merchantSettings: IkasMerchantSettings | null, router: NextRouter, returnPolicy: string, privacyPolicy: string, termsOfService: string, t: TFunction, customizationProps: IkasCheckoutCustomizationProps);
42
44
  init: () => Promise<void>;
43
45
  initStep: () => Promise<void>;
44
46
  getMerchantSettings: () => Promise<void>;
@@ -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/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/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"../../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{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as k}from"../../storefront/index.js";import{IkasCheckoutSettings as S}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import b from'../../ext/uuid/dist/esm-browser/v4.js';var C,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,R,x,E,O,T,D){var G=this;this.checkout=new o,this.checkoutSettings=new S,this.storefront=null,this.store=k.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=C.INFO,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.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(G,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.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(k.isEditor)return this.step=C.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===C.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(C.INFO)];if(this.step===C.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(C.INFO)];if(![C.INFO,C.SUCCESS,C.SHIPPING,C.PAYMENT].includes(this.step))return[2,this.changeStep(C.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==C.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==C.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=C.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==C.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==C.PAYMENT&&this.step!==C.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===C.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(C.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 10:o=e.sent(),this.successTransaction=o.length?o[0]:void 0,this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===a}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.saveCheckout=function(){return t(G,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,k.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.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:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(G,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(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(k.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=G.shippingCountryIds)||void 0===t?void 0:t.length)||(G.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(G,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:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=k.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===C.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&n.iso2&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(k.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){G.store.customerStore.customer?(G.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=G.checkoutSettings})),G.checkout.customer=new a(G.store.customerStore.customer)):G.checkout.customer||(G.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(G.checkout.shippingAddress)G.selectedShippingAddressId=G.checkout.shippingAddress.id||"-1",G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings;else{var e=null===(t=G.store.customerStore.customer)||void 0===t?void 0:t.addresses;G.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(G.useDifferentAddress=!!localStorage.getItem("sAddr"),G.useDifferentAddress?(G.checkout.billingAddress&&(G.selectedBillingAddressId=G.checkout.billingAddress.id||"-1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):G.checkout.billingAddress=new u(n(G.checkout.shippingAddress)||{}),G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onShippingMethodChange=function(i){return t(G,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.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(G,void 0,void 0,(function(){var t,s,n,r,a;return e(this,(function(e){switch(e.label){case 0:if(!this.checkout.couponCode)return[2];e.label=1;case 1:return e.trys.push([1,7,,8]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode)];case 2:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,6];case 3:return(t=e.sent())?(s=null===(a=null===(r=this.cardData)||void 0===r?void 0:r.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===C.PAYMENT&&(null==s?void 0:s.length)&&s.length>=6?[4,this.retrieveInstallmentInfo({binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:t.totalFinalPrice})]:[3,5]):[3,6];case 4:e.sent(),e.label=5;case 5:n=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:n.shippingAddress,billingAddress:n.billingAddress,customer:n.customer,selectedPaymentGateway:n.selectedPaymentGateway})),e.label=6;case 6:return[3,8];case 7:return e.sent(),[3,8];case 8:return[2]}}))}))},this.onCouponCodeDelete=function(){return t(G,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.saveCheckout()];case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(s=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:s.shippingAddress,billingAddress:s.billingAddress,customer:s.customer,selectedPaymentGateway:s.selectedPaymentGateway}))),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(G.selectedShippingAddressId=t,"-1"===t)G.checkout.shippingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.shippingAddress=new u(i))}G.checkout.shippingAddress&&(G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(G.selectedBillingAddressId=t,"-1"===t)G.checkout.billingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.billingAddress=new u(i))}G.checkout.billingAddress&&(G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){G.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(G.cardData&&(!(t.length>G.cardData.cardNumber.length)||N(t))){var e=(G.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!G.installmentInfo?G.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:G.checkout.selectedPaymentGateway.id,price:G.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(G.cardData.installmentCount=1,G.installmentInfo=void 0),G.cardData.cardNumber=w(i,4).join(" "))}},this.onCardHolderNameChange=function(t){G.cardData&&(G.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(G.cardData&&(!(t.length>G.cardData.expirationDate.length)||N(t))){if(0===(null===(e=G.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(G.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(G.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(G.cardData.expirationDate=w(a,2).join(" / "))}},this.onCvcChange=function(t){G.cardData&&(t.length>G.cardData.cvv.length&&!N(t)||t.length>4||(G.cardData.cvv=t))},this.saveAddress=function(s){return t(G,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this.shouldSaveAddress?(t=new c(i(i({},"shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:b()})),(r=n(this.store.customerStore.customer)).addresses.push(t),[4,this.store.customerStore.saveCustomer(r)]):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=t.id,this.selectedShippingAddressId=t.id||"-1"):(this.checkout.billingAddress.id=t.id,this.selectedBillingAddressId=t.id||"-1"),e.label=2;case 2:return[2]}}))}))},this.onGoToCartClick=function(){G.router.push("/cart")},this.onBackToShoppingClick=function(){G.router.push("/")},this.onProceedToShippingClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(C.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(G,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.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(C.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(G,void 0,void 0,(function(){var t;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,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(G,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.onCheckoutTransactionSuccess()]:[3,3];case 2:return e.sent(),[3,4];case 3:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=4;case 4:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(G,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(C.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){G.changeStep(C.INFO)},this.onBackToShippingClick=function(){G.changeStep(C.SHIPPING)},this.setCustomerConsentGranted=function(t){G.checkout.customer&&(G.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){G.useDifferentAddress=t,G.useDifferentAddress?(localStorage.setItem("sAddr","1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),G.checkout.billingAddress=G.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){G.shouldSaveAddress=t},this.setAddressTitle=function(t){G.addressTitle=t},this.setPaymentGateway=function(t){if(G.paymentGateways.length){var e=G.paymentGateways[t];G.checkout.selectedPaymentGateway=e,G.step!==C.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(G.cardData=new v),G.installmentInfo=void 0)}},this.setInstallmentCount=function(t){G.cardData&&(G.cardData.installmentCount=t)},this.changeStep=function(i){return t(G,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(G,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){G.isContactModalVisible=t},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=O,this.termsOfService=T,this.t=D,R&&(this.merchantSettings=R),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===C.SUCCESS?this.order?this.order.totalFinalPrice:this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.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)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)===h.CREDIT_CARD&&i.type===l.INTERNAL?null===(e=this.cardData)||void 0===e?void 0:e.isValid:!!i)},enumerable:!1,configurable:!0}),P}();function w(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(C||(C={})),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"}(I||(I={}));export{C as CheckoutStep,I as ErrorType,j 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/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/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"../../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{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as k}from"../../storefront/index.js";import{IkasCheckoutSettings as S}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import b from'../../ext/uuid/dist/esm-browser/v4.js';var C,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,R,x,E,O,T,D,G){var _=this;this.checkout=new o,this.checkoutSettings=new S,this.storefront=null,this.store=k.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=C.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.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(_,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.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(k.isEditor)return this.step=C.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===C.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(C.INFO)];if(this.step===C.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(C.INFO)];if(![C.INFO,C.SUCCESS,C.SHIPPING,C.PAYMENT].includes(this.step))return[2,this.changeStep(C.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==C.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==C.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=C.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==C.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==C.PAYMENT&&this.step!==C.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===C.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(C.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 10:o=e.sent(),this.successTransaction=o.length?o[0]:void 0,this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===a}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.saveCheckout=function(){return t(_,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,k.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.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:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(_,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(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(k.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=_.shippingCountryIds)||void 0===t?void 0:t.length)||(_.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(_,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:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=k.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===C.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&n.iso2&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(k.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){_.store.customerStore.customer?(_.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=_.checkoutSettings})),_.checkout.customer=new a(_.store.customerStore.customer)):_.checkout.customer||(_.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(_.checkout.shippingAddress)_.selectedShippingAddressId=_.checkout.shippingAddress.id||"-1",_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings;else{var e=null===(t=_.store.customerStore.customer)||void 0===t?void 0:t.addresses;_.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(_.useDifferentAddress=!!localStorage.getItem("sAddr"),_.useDifferentAddress?(_.checkout.billingAddress&&(_.selectedBillingAddressId=_.checkout.billingAddress.id||"-1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):_.checkout.billingAddress=new u(n(_.checkout.shippingAddress)||{}),_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onShippingMethodChange=function(i){return t(_,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.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(_,void 0,void 0,(function(){var t,s,n,r,a;return e(this,(function(e){switch(e.label){case 0:if(!this.checkout.couponCode)return[2];e.label=1;case 1:return e.trys.push([1,7,,8]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode)];case 2:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,6];case 3:return(t=e.sent())?(s=null===(a=null===(r=this.cardData)||void 0===r?void 0:r.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===C.PAYMENT&&(null==s?void 0:s.length)&&s.length>=6?[4,this.retrieveInstallmentInfo({binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:t.totalFinalPrice})]:[3,5]):[3,6];case 4:e.sent(),e.label=5;case 5:n=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:n.shippingAddress,billingAddress:n.billingAddress,customer:n.customer,selectedPaymentGateway:n.selectedPaymentGateway})),e.label=6;case 6:return[3,8];case 7:return e.sent(),[3,8];case 8:return[2]}}))}))},this.onCouponCodeDelete=function(){return t(_,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.saveCheckout()];case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(s=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:s.shippingAddress,billingAddress:s.billingAddress,customer:s.customer,selectedPaymentGateway:s.selectedPaymentGateway}))),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(_.selectedShippingAddressId=t,"-1"===t)_.checkout.shippingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.shippingAddress=new u(i))}_.checkout.shippingAddress&&(_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(_.selectedBillingAddressId=t,"-1"===t)_.checkout.billingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.billingAddress=new u(i))}_.checkout.billingAddress&&(_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){_.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(_.cardData&&(!(t.length>_.cardData.cardNumber.length)||N(t))){var e=(_.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!_.installmentInfo?_.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:_.checkout.selectedPaymentGateway.id,price:_.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(_.cardData.installmentCount=1,_.installmentInfo=void 0),_.cardData.cardNumber=w(i,4).join(" "))}},this.onCardHolderNameChange=function(t){_.cardData&&(_.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(_.cardData&&(!(t.length>_.cardData.expirationDate.length)||N(t))){if(0===(null===(e=_.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(_.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(_.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(_.cardData.expirationDate=w(a,2).join(" / "))}},this.onCvcChange=function(t){_.cardData&&(t.length>_.cardData.cvv.length&&!N(t)||t.length>4||(_.cardData.cvv=t))},this.saveAddress=function(s){return t(_,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this.shouldSaveAddress?(t=new c(i(i({},"shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:b()})),(r=n(this.store.customerStore.customer)).addresses.push(t),[4,this.store.customerStore.saveCustomer(r)]):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=t.id,this.selectedShippingAddressId=t.id||"-1"):(this.checkout.billingAddress.id=t.id,this.selectedBillingAddressId=t.id||"-1"),e.label=2;case 2:return[2]}}))}))},this.onGoToCartClick=function(){_.router.push("/cart")},this.onBackToShoppingClick=function(){_.router.push("/")},this.onProceedToShippingClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(C.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(_,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.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(C.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(_,void 0,void 0,(function(){var t;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,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(_,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.onCheckoutTransactionSuccess()]:[3,3];case 2:return e.sent(),[3,4];case 3:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=4;case 4:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(_,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(C.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){_.changeStep(C.INFO)},this.onBackToShippingClick=function(){_.changeStep(C.SHIPPING)},this.setCustomerConsentGranted=function(t){_.checkout.customer&&(_.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){_.useDifferentAddress=t,_.useDifferentAddress?(localStorage.setItem("sAddr","1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),_.checkout.billingAddress=_.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){_.shouldSaveAddress=t},this.setAddressTitle=function(t){_.addressTitle=t},this.setPaymentGateway=function(t){if(_.paymentGateways.length){var e=_.paymentGateways[t];_.checkout.selectedPaymentGateway=e,_.step!==C.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(_.cardData=new v),_.installmentInfo=void 0)}},this.setInstallmentCount=function(t){_.cardData&&(_.cardData.installmentCount=t)},this.changeStep=function(i){return t(_,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(_,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){_.isContactModalVisible=t},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=O,this.termsOfService=T,this.t=D,this.customizationProps=G,R&&(this.merchantSettings=R),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.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(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===C.SUCCESS?this.order?this.order.totalFinalPrice:this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.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)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)===h.CREDIT_CARD&&i.type===l.INTERNAL?null===(e=this.cardData)||void 0===e?void 0:e.isValid:!!i)},enumerable:!1,configurable:!0}),P}();function w(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(C||(C={})),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"}(I||(I={}));export{C as CheckoutStep,I as ErrorType,j as default};