@ikas/storefront 4.9.0 → 4.9.2

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.
@@ -12,6 +12,10 @@ export declare class Analytics {
12
12
  lastName: string | null;
13
13
  email: string | null;
14
14
  phone: string | null;
15
+ isEmailVerified: boolean | null;
16
+ isPhoneVerified: boolean | null;
17
+ orderCount: number | null;
18
+ subscriptionStatus: import("@ikas/storefront-models/build-cjs/models/customer").IkasCustomerEmailSubscriptionStatus | null;
15
19
  } | null>;
16
20
  static pageView(pageType: IkasThemeJsonPageType): Promise<void>;
17
21
  static productView(productDetail: IkasProduct): void;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as s}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as r}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import{IkasThemeJsonPageType as o}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../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";var n,a;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW"}(n||(n={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(a||(a={}));var d=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",c=function(){function c(){}return c.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/generate-id/1"))];case 1:return[4,t.sent().json()];case 2:return[2,t.sent().data[0]]}}))}))},c.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return s=e.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},c.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(s=JSON.parse(t)).expiry<Date.now()||s.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=s.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return r=e.sent(),console.error(r),[3,8];case 8:return[2]}}))}))},c.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return s=this,[4,this.createUUID()];case 2:s.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},c.getPageType=function(t){switch(t){case o.INDEX:return a.INDEX;case o.CATEGORY:return a.CATEGORY;case o.BRAND:return a.BRAND;case o.PRODUCT:return a.PRODUCT;case o.CUSTOM:return a.CUSTOM;case o.ACCOUNT:return a.ACCOUNT;case o.ADDRESSES:return a.ADDRESSES;case o.ORDERS:return a.ORDERS;case o.ORDER_DETAIL:return a.ORDER_DETAIL;case o.LOGIN:return a.LOGIN;case o.REGISTER:return a.REGISTER;case o.FORGOT_PASSWORD:return a.FORGOT_PASSWORD;case o.RECOVER_PASSWORD:return a.RECOVER_PASSWORD;case o.ACTIVATE_CUSTOMER:return a.ACTIVATE_CUSTOMER;case o.CART:return a.CART;case o.FAVORITE_PRODUCTS:return a.FAVORITE_PRODUCTS;case o.SEARCH:return a.SEARCH;case o.NOT_FOUND:return a.NOT_FOUND;case o.BLOG:return a.BLOG;case o.BLOG_INDEX:return a.BLOG_INDEX;case o.BLOG_CATEGORY:return a.BLOG_CATEGORY;case o.CHECKOUT:return a.CHECKOUT}},c.getCustomerData=function(){var t=r.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},c.getCommonEventData=function(){var t=r.getInstance();return{u:window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0}},c.sendEvents=function(s){var o;return t(this,void 0,void 0,(function(){var t,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,this.checkSessionId()];case 1:return e.sent(),[4,this.checkVisitorId()];case 2:return e.sent(),t=r.getInstance(),n={e:s,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,vid:this.visitorId,cid:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},[4,fetch(d,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 3:return e.sent(),[3,5];case 4:return a=e.sent(),console.error(a),[3,5];case 5:return[2]}}))}))},c.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.SESSION_START,ts:Date.now(),d:s({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.pageView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PAGE_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.productView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PRODUCT_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{pr:{id:i.id,vid:i.selectedVariant.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.addToCart=function(i,r,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ADD_TO_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:o.id,c:o.itemCount},crtItm:{id:i.id,c:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCart=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.VIEW_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.itemCount}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.orderSuccess=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ORDER_SUCCESS,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success"}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[4,this.createSessionId()];case 2:return e.sent(),[2]}}))}))},c.beginCheckout=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BEGIN_CHECKOUT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.checkoutStep=function(i,r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CHECKOUT_STEP,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerRegister=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_REGISTER,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_LOGIN,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_VISIT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BRAND_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCategory=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CATEGORY_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.SESSION_ID_KEY="ikas_session_id",c.VISITOR_ID_KEY="ikas_visitor_id",c.EXPIRY_LENGTH=18e5,c}();export{c as default};
1
+ import{__awaiter as t,__generator as e,__assign as s}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as r}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import{IkasThemeJsonPageType as o}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../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";var n,a;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW"}(n||(n={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(a||(a={}));var d=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",c=function(){function c(){}return c.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,fetch("".concat(process.env.NEXT_PUBLIC_BASE_URL,"/generate-id/1"))];case 1:return[4,t.sent().json()];case 2:return[2,t.sent().data[0]]}}))}))},c.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return s=e.sent(),console.error(s),[3,4];case 4:return[2]}}))}))},c.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(s=JSON.parse(t)).expiry<Date.now()||s.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=s.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return r=e.sent(),console.error(r),[3,8];case 8:return[2]}}))}))},c.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,s,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return s=this,[4,this.createUUID()];case 2:s.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},c.getPageType=function(t){switch(t){case o.INDEX:return a.INDEX;case o.CATEGORY:return a.CATEGORY;case o.BRAND:return a.BRAND;case o.PRODUCT:return a.PRODUCT;case o.CUSTOM:return a.CUSTOM;case o.ACCOUNT:return a.ACCOUNT;case o.ADDRESSES:return a.ADDRESSES;case o.ORDERS:return a.ORDERS;case o.ORDER_DETAIL:return a.ORDER_DETAIL;case o.LOGIN:return a.LOGIN;case o.REGISTER:return a.REGISTER;case o.FORGOT_PASSWORD:return a.FORGOT_PASSWORD;case o.RECOVER_PASSWORD:return a.RECOVER_PASSWORD;case o.ACTIVATE_CUSTOMER:return a.ACTIVATE_CUSTOMER;case o.CART:return a.CART;case o.FAVORITE_PRODUCTS:return a.FAVORITE_PRODUCTS;case o.SEARCH:return a.SEARCH;case o.NOT_FOUND:return a.NOT_FOUND;case o.BLOG:return a.BLOG;case o.BLOG_INDEX:return a.BLOG_INDEX;case o.BLOG_CATEGORY:return a.BLOG_CATEGORY;case o.CHECKOUT:return a.CHECKOUT}},c.getCustomerData=function(){var t=r.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},c.getCommonEventData=function(){var t=r.getInstance();return{u:window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0}},c.sendEvents=function(s){var o;return t(this,void 0,void 0,(function(){var t,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,(t=r.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),[4,this.checkSessionId()];case 2:return e.sent(),[4,this.checkVisitorId()];case 3:return e.sent(),n={e:s,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,vid:this.visitorId,cid:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},[4,fetch(d,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 4:return e.sent(),[3,6];case 5:return a=e.sent(),console.error(a),[3,6];case 6:return[2]}}))}))},c.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.SESSION_START,ts:Date.now(),d:s({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.pageView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PAGE_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.productView=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.PRODUCT_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{pr:{id:i.id,vid:i.selectedVariant.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.addToCart=function(i,r,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ADD_TO_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:o.id,c:o.itemCount},crtItm:{id:i.id,c:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCart=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.VIEW_CART,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.itemCount}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.orderSuccess=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.ORDER_SUCCESS,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success"}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[4,this.createSessionId()];case 2:return e.sent(),[2]}}))}))},c.beginCheckout=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BEGIN_CHECKOUT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.checkoutStep=function(i,r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CHECKOUT_STEP,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{chk:{id:i.id,s:r}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerRegister=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_REGISTER,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_LOGIN,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CUSTOMER_VISIT,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.BRAND_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.viewCategory=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:n.CATEGORY_VIEW,ts:Date.now(),d:s(s({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},c.SESSION_ID_KEY="ikas_session_id",c.VISITOR_ID_KEY="ikas_visitor_id",c.EXPIRY_LENGTH=18e5,c}();export{c as default};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCouponCodeRequirement as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasTransactionStatus as l,IkasCartCampaignOfferStatus as h,IkasCampaignOfferTargetPageType as p}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as m}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as f}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as g}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as v}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as y}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as S}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as k}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as b}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import C from"./components/credit-card-form/model.js";import P from"../../store/customer/api.js";import I from"../../store/checkout/index.js";import A from"../../store/cart/api.js";import w,{MFS_ELEMENT_ID as N,MFS_SCRIPT_URL as j}from"./modelMasterPass.js";import O from"../../store/product/index.js";import{IkasBaseStore as E}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as R}from"@ikas/storefront-config";import{Analytics as x}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as D,CheckStocksLineInput as T}from"@ikas/storefront-api";import G from"../../models/data/order/address/ikas-localized-order-address.js";import L from"../../store/location/index.js";import{getCookieValue as M}from"../../utils/helper.js";var V,_,U=/^\d+$/,F="undefined"==typeof localStorage,K=function(){function U(d,u,v,y,U,K,Y,H,q,W){var Q=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=V.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(Q,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,E.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(Q,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(R.getIsEditor())return this.step=V.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===V.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(V.INFO)];if(this.step!==V.PAYMENT||this.canProceedToPayment){if(this.step===V.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(V.INFO)];if(![V.INFO,V.SUCCESS,V.SHIPPING,V.PAYMENT].includes(this.step))return[2,this.changeStep(V.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(V.INFO)]:[2,this.changeStep(V.SHIPPING)];this.deliveryMethod="in-store"}}return n&&(this.error={type:_.PAYMENT_ERROR,data:r||null}),this.step!==V.SHIPPING&&this.step!==V.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new f(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==V.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==V.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=V.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==V.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==V.PAYMENT&&this.step!==V.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:_.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:_.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===V.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(V.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,x.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,P.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(Q,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new D(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==V.INFO&&this.step!==V.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),[4,A.saveCart({input:e})];case 3:if((null==(i=t.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:_.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:_.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(Q,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(Q,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,I.checkStocks({lines:e.map((function(e){return new T(e)})),stockLocationIdList:(null===(u=R.getStockLocationIds())||void 0===u?void 0:u.length)?R.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:_.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:_.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(Q,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(Q,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,E.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,I.getAvailableShippingCountries({salesChannelId:R.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return R.getPickupStockLocationIds()?[4,I.listStockLocation({id:{in:R.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:_.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return R.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,I.getAvailableStockLocations({lines:e.map((function(e){return new T(e)})),stockLocationIdList:R.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:_.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=Q.shippingCountryIds)||void 0===e?void 0:e.length)||(Q.error={type:_.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(Q.checkout.stockLocationId=null),Q.deliveryMethod=e,Q.isErrorsVisible=!1},this.initialStockCheck=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:_.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(Q,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=R.getPaymentGateways().map((function(e){return e.id})),[4,I.listPaymentGateway({id:e?void 0:{in:i},locale:R.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===V.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(R.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===V.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=N,d.src=j,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:E.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:_.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(Q,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,I.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;Q.store.customerStore.customer?(null===(e=Q.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=Q.checkoutSettings,e.shippingZones=Q.shippingZones})),Q.checkout.customer=new S(Q.store.customerStore.customer)):Q.checkout.customer=new S(Q.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){Q.checkout.shippingAddress&&(Q.checkout.shippingAddress.checkoutSettings=Q.checkoutSettings,Q.checkout.shippingAddress.shippingZones=Q.shippingZones,Q.checkout.shippingAddress.countrySettings=Q.countrySettings,Q.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){Q.checkout.billingAddress&&(Q.checkout.billingAddress.checkoutSettings=Q.checkoutSettings,Q.checkout.billingAddress.shippingZones=Q.shippingZones,Q.checkout.billingAddress.countrySettings=Q.countrySettings,Q.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!Q.isDigitalOnly)if(Q.isInStoreDelivery)Q.setCheckoutShippingAddressSettings();else if(Q.checkout.shippingAddress){if(Q.store.customerStore.customer){var e=null==(t=Q.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=Q.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return Q.onSelectedShippingAddressIdChange(e.id||"-1"),void Q.setCheckoutShippingAddressSettings()}Q.checkout.shippingAddress=new G(n(Q.checkout.shippingAddress)||{}),Q.setCheckoutShippingAddressSettings()}else if(Q.store.customerStore.customer){var t=Q.customerAddresses;Q.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else Q.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(Q.useDifferentAddress=!!localStorage.getItem("sAddr"),Q.checkout.billingAddress){if(Q.store.customerStore.customer){var e=null==(t=Q.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=Q.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return Q.onSelectedBillingAddressIdChange(e.id||"-1"),void Q.setCheckoutBillingAddressSettings()}Q.checkout.billingAddress=new G(n(Q.checkout.billingAddress)||{}),Q.setCheckoutBillingAddressSettings()}else if(Q.store.customerStore.customer){var t=Q.customerAddresses;Q.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||Q.useDifferentAddress||!Q.checkout.shippingAddress||Q.isInStoreDelivery||(Q.checkout.billingAddress=new G(n(Q.checkout.shippingAddress)),Q.setCheckoutBillingAddressSettings())}else Q.onSelectedBillingAddressIdChange("-1"),Q.useDifferentAddress||!Q.checkout.shippingAddress||Q.isInStoreDelivery||(Q.checkout.billingAddress=new G(n(Q.checkout.shippingAddress)),Q.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(e=t.sent())&&(this.checkout=new m(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(Q,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(Q,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,A.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===V.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new m(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,L.getAvailableShippingZones({salesChannelId:R.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(Q.selectedShippingAddressId=e,"-1"===e)Q.checkout.shippingAddress=new G,Q.checkout.shippingAddress.countrySettings=Q.countrySettings;else{var i=null===(t=Q.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(Q.checkout.shippingAddress=new G(i),Q.checkout.shippingAddress.countrySettings=Q.countrySettings)}Q.checkout.shippingAddress&&(Q.checkout.shippingAddress.checkoutSettings=Q.checkoutSettings,Q.checkout.shippingAddress.shippingZones=Q.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(Q.selectedBillingAddressId=e,"-1"===e)Q.checkout.billingAddress=new G,Q.checkout.billingAddress.countrySettings=Q.countrySettings;else{var i=null===(t=Q.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(Q.checkout.billingAddress=new G(i),Q.checkout.billingAddress.countrySettings=Q.countrySettings)}Q.checkout.billingAddress&&(Q.checkout.billingAddress.checkoutSettings=Q.checkoutSettings,Q.checkout.billingAddress.shippingZones=Q.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){Q.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(Q.cardData&&(!(e.length>Q.cardData.cardNumber.length)||Z(e))){var t=(Q.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!Q.installmentInfo?Q.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Q.checkout.selectedPaymentGateway.id,price:Q.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(Q.cardData.installmentCount=1,Q.installmentInfo=void 0),Q.cardData.cardNumber=B(i,4).join(" "))}},this.onCardHolderNameChange=function(e){Q.cardData&&(Q.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(Q.cardData&&(!(e.length>Q.cardData.expirationDate.length)||Z(e))){if(0===(null===(t=Q.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(Q.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(Q.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(Q.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(Q.cardData.expirationDate=B(d,2).join(" / "))}},this.onCvcChange=function(e){Q.cardData&&(e.length>Q.cardData.cvv.length&&!Z(e)||e.length>4||(Q.cardData.cvv=e))},this.saveAddress=function(s){return e(Q,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,v=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new g(i(i({},e),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:t.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=v.checkoutSettings,e.shippingZones=v.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Q.router.push("/cart")},this.onBackToShoppingClick=function(){Q.router.push("/")},this.onGoToLoginClick=function(){Q.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),"address"===this.deliveryMethod?this.changeStep(V.SHIPPING):this.changeStep(V.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:_.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(V.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:_.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(V.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:_.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!Q.canPerformPayment||(Q.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:_.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:_.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(Q,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,h,p,m,f,g,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,I.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)},metadata:{_fbp:M("_fbp"),_fbc:M("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,I.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[l.SUCCESS,l.AUTHORIZED].includes(r),d=r===l.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:_.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(V.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Q.changeStep(V.INFO)},this.onBackToShippingClick=function(){Q.changeStep(V.SHIPPING)},this.setCustomerConsentGranted=function(e){Q.checkout.customer&&(Q.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){Q.useDifferentAddress=e,Q.useDifferentAddress?(localStorage.setItem("sAddr","1"),Q.checkout.billingAddress=Q.checkout.billingAddress||new G,Q.checkout.billingAddress.countrySettings=Q.countrySettings):(localStorage.removeItem("sAddr"),Q.checkout.billingAddress=Q.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){Q.shouldSaveAddress=e},this.setAddressTitle=function(e){Q.addressTitle=e},this.reInitPaymentMethod=function(){return e(Q,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenClientToken(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,I.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.stripeResponse=e.data),[2]}}))}))},this.createKlarnaClientToken=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,I.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.klarnaResponse=e.data),[2]}}))}))},this.createAdyenClientToken=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,I.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,I.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(Q,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||!(null===(s=e.settings)||void 0===s?void 0:s.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenClientToken(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==V.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new C,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){Q.cardData&&(Q.cardData.installmentCount=e)},this.changeStep=function(i){return e(Q,void 0,void 0,(function(){return t(this,(function(e){return F||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(Q,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){Q.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(Q,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===h.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,O.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new k(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(Q,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(p.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(p.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(Q,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,A.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new m(e.data,this.countrySettings),i.accepted&&this.step===V.SUCCESS?this.changeStep(V.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(Q,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,P.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=d,this.checkoutSettings=u,this.router=v,this.returnPolicy=y,this.privacyPolicy=U,this.termsOfService=K,this.imprint=Y,this.shippingPolicy=H,this.t=q,this.customizationProps=W,this.mpVM=new w,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new b({currentLocale:R.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(U.prototype,"merchantSettings",{get:function(){return new y(R.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=E.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"finalPrice",{get:function(){return this.step===V.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===_.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==_.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isCustomFlowStripe",{get:function(){var e,t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&(null===(e=t.settings)||void 0===e?void 0:e.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"store",{get:function(){return E.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"customerAddresses",{get:function(){var e,t,s=this;return null===(t=null===(e=this.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){var t=new v(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isEPayKolayEnabled",{get:function(){var e=R.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"isPoweredByHidden",{get:function(){var e=R.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),U.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},U}();function B(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function Z(e){return e&&U.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(V||(V={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(_||(_={}));export{V as CheckoutStep,_ as ErrorType,K as default};
1
+ import{__awaiter as e,__generator as t,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCouponCodeRequirement as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasOrderShippingMethod as d,IkasCartCreatedBy as u,IkasTransactionStatus as l,IkasCartCampaignOfferStatus as h,IkasCampaignOfferTargetPageType as p,IkasCustomerEmailSubscriptionStatus as m}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as f}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as g}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as v}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as y}from"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as S}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as k}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as b}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import{LocalizedAddressModel as C}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import P from"./components/credit-card-form/model.js";import I from"../../store/customer/api.js";import A from"../../store/checkout/index.js";import w from"../../store/cart/api.js";import N,{MFS_ELEMENT_ID as j,MFS_SCRIPT_URL as O}from"./modelMasterPass.js";import E from"../../store/product/index.js";import{IkasBaseStore as R}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as D}from"@ikas/storefront-config";import{Analytics as x}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as T,CheckStocksLineInput as G}from"@ikas/storefront-api";import L from"../../models/data/order/address/ikas-localized-order-address.js";import M from"../../store/location/index.js";import{getCookieValue as V}from"../../utils/helper.js";var _,U,F=/^\d+$/,K="undefined"==typeof localStorage,B=function(){function F(d,u,y,S,F,B,H,q,W,Q){var z=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isEPayKolayPayment=!1,this.step=_.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(z,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return e.sent(),[4,R.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(z,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(D.getIsEditor())return this.step=_.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),s=e.get("step"),n=e.get("failed"),r=e.get("error"),s){if(this.step=s,this.step===_.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(_.INFO)];if(this.step!==_.PAYMENT||this.canProceedToPayment){if(this.step===_.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(_.INFO)];if(![_.INFO,_.SUCCESS,_.SHIPPING,_.PAYMENT].includes(this.step))return[2,this.changeStep(_.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(_.INFO)]:[2,this.changeStep(_.SHIPPING)];this.deliveryMethod="in-store"}}return n&&(this.error={type:U.PAYMENT_ERROR,data:r||null}),this.step!==_.SHIPPING&&this.step!==_.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new g(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==_.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==_.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=_.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==_.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==_.PAYMENT&&this.step!==_.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:U.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:U.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===_.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(_.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,x.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,I.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=t.sent(),this.successTransaction=e.isSuccess&&(null===(i=e.data)||void 0===i?void 0:i.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.saveCart=function(){return e(z,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new T(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==_.INFO&&this.step!==_.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),e.customer&&(this.store.customerStore.customer?e.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,w.saveCart({input:e})];case 3:if((null==(i=t.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:U.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:U.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(z,void 0,void 0,(function(){var e,s,n=this;return t(this,(function(t){return e=i,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&e.shippingAddress&&s.address&&(e.shippingAddress.country=s.address.country,e.shippingAddress.city=s.address.city,e.shippingAddress.state=s.address.state,e.shippingAddress.district=s.address.district,e.shippingAddress.postalCode=s.address.postalCode,e.shippingAddress.addressLine1=s.address.address||"",e.shippingAddress.addressLine2=null),[2,e]}))}))},this.checkStocks=function(){return e(z,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,A.checkStocks({lines:e.map((function(e){return new G(e)})),stockLocationIdList:(null===(u=D.getStockLocationIds())||void 0===u?void 0:u.length)?D.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:U.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:U.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(z,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(z,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:e=0,s=i,t.label=1;case 1:return e<s.length?(n=s[e],[4,R.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:t.sent(),t.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,A.getAvailableShippingCountries({salesChannelId:D.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return D.getPickupStockLocationIds()?[4,A.listStockLocation({id:{in:D.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=t.sent()).isSuccess||!(null===(i=e.data)||void 0===i?void 0:i.length))return this.error={type:U.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return D.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,A.getAvailableStockLocations({lines:e.map((function(e){return new G(e)})),stockLocationIdList:D.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:U.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=z.shippingCountryIds)||void 0===e?void 0:e.length)||(z.error={type:U.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(z.checkout.stockLocationId=null),z.deliveryMethod=e,z.isErrorsVisible=!1},this.initialStockCheck=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return t.sent(),[3,3];case 2:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:U.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(z,void 0,void 0,(function(){var e,i,s,n,o,a,c,d,u,l,h=this;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,i=D.getPaymentGateways().map((function(e){return e.id})),[4,A.listPaymentGateway({id:e?void 0:{in:i},locale:D.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=t.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===_.PAYMENT&&(n=n.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(o.iso2||"")})))),a=[],r(D.getPaymentGateways(),"order").forEach((function(e){var t=null==n?void 0:n.find((function(t){return t.id===e.id}));t&&a.push(t)})),this.paymentGateways=e?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===_.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=j,d.src=O,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:R.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:U.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(z,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,A.retrieveInstallmentInfo(i)];case 1:return e=t.sent(),s=e.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(e,t){return(e.installmentCount||-1)>(t.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var e;z.store.customerStore.customer?(null===(e=z.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=z.checkoutSettings,e.shippingZones=z.shippingZones})),z.checkout.customer=new k(z.store.customerStore.customer)):z.checkout.customer=new k(z.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){z.checkout.shippingAddress&&(z.checkout.shippingAddress.checkoutSettings=z.checkoutSettings,z.checkout.shippingAddress.shippingZones=z.shippingZones,z.checkout.shippingAddress.countrySettings=z.countrySettings,z.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){z.checkout.billingAddress&&(z.checkout.billingAddress.checkoutSettings=z.checkoutSettings,z.checkout.billingAddress.shippingZones=z.shippingZones,z.checkout.billingAddress.countrySettings=z.countrySettings,z.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!z.isDigitalOnly)if(z.isInStoreDelivery)z.setCheckoutShippingAddressSettings();else if(z.checkout.shippingAddress){if(z.store.customerStore.customer){var e=null==(t=z.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=z.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return z.onSelectedShippingAddressIdChange(e.id||"-1"),void z.setCheckoutShippingAddressSettings()}z.checkout.shippingAddress=new L(n(z.checkout.shippingAddress)||{}),z.setCheckoutShippingAddressSettings()}else if(z.store.customerStore.customer){var t=z.customerAddresses;z.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else z.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(z.useDifferentAddress=!!localStorage.getItem("sAddr"),z.checkout.billingAddress){if(z.store.customerStore.customer){var e=null==(t=z.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=z.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return z.onSelectedBillingAddressIdChange(e.id||"-1"),void z.setCheckoutBillingAddressSettings()}z.checkout.billingAddress=new L(n(z.checkout.billingAddress)||{}),z.setCheckoutBillingAddressSettings()}else if(z.store.customerStore.customer){var t=z.customerAddresses;z.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||z.useDifferentAddress||!z.checkout.shippingAddress||z.isInStoreDelivery||(z.checkout.billingAddress=new L(n(z.checkout.shippingAddress)),z.setCheckoutBillingAddressSettings())}else z.onSelectedBillingAddressIdChange("-1"),z.useDifferentAddress||!z.checkout.shippingAddress||z.isInStoreDelivery||(z.checkout.billingAddress=new L(n(z.checkout.shippingAddress)),z.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(e=t.sent())&&(this.checkout=new f(e,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return e(z,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(z,void 0,void 0,(function(){var e,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,w.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(e=t.sent()).isSuccess&&e.data?(s=e.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.couponError=null,this.step===_.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new f(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),t.label=4;case 4:return e.isSuccess||(this.couponError=e.errorCodes[0]),[3,6];case 5:return t.sent(),[3,6];case 6:return[2]}}))}))},this.getAvailableShippingZones=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,M.getAvailableShippingZones({salesChannelId:D.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingZones=e.data||null,[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(e){var t;if(z.selectedShippingAddressId=e,"-1"===e)z.checkout.shippingAddress=new L,z.checkout.shippingAddress.countrySettings=z.countrySettings;else{var i=null===(t=z.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(z.checkout.shippingAddress=new L(i),z.checkout.shippingAddress.countrySettings=z.countrySettings)}z.checkout.shippingAddress&&(z.checkout.shippingAddress.checkoutSettings=z.checkoutSettings,z.checkout.shippingAddress.shippingZones=z.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(z.selectedBillingAddressId=e,"-1"===e)z.checkout.billingAddress=new L,z.checkout.billingAddress.countrySettings=z.countrySettings;else{var i=null===(t=z.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(z.checkout.billingAddress=new L(i),z.checkout.billingAddress.countrySettings=z.countrySettings)}z.checkout.billingAddress&&(z.checkout.billingAddress.checkoutSettings=z.checkoutSettings,z.checkout.billingAddress.shippingZones=z.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){z.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(z.cardData&&(!(e.length>z.cardData.cardNumber.length)||Y(e))){var t=(z.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!z.installmentInfo?z.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:z.checkout.selectedPaymentGateway.id,price:z.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(z.cardData.installmentCount=1,z.installmentInfo=void 0),z.cardData.cardNumber=Z(i,4).join(" "))}},this.onCardHolderNameChange=function(e){z.cardData&&(z.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(z.cardData&&(!(e.length>z.cardData.expirationDate.length)||Y(e))){if(0===(null===(t=z.cardData.expirationDate)||void 0===t?void 0:t.length)){var i=e.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(z.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(z.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(z.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(z.cardData.expirationDate=Z(d,2).join(" / "))}},this.onCvcChange=function(e){z.cardData&&(e.length>z.cardData.cvv.length&&!Y(e)||e.length>4||(z.cardData.cvv=e))},this.saveAddress=function(s){return e(z,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,m,f,g=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new v(i(i({},e),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:t.sent(),null===(m=this.customerAddresses)||void 0===m||m.forEach((function(e){e.checkoutSettings=g.checkoutSettings,e.shippingZones=g.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){z.router.push("/cart")},this.onBackToShoppingClick=function(){z.router.push("/")},this.onGoToLoginClick=function(){z.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:t.sent(),t.label=3;case 3:return[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),"address"===this.deliveryMethod?this.changeStep(_.SHIPPING):this.changeStep(_.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:U.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.changeStep(_.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:U.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=1;case 1:return t.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return t.sent(),[4,this.saveCart()];case 3:return t.sent(),this.error=void 0,this.changeStep(_.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:U.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!z.canPerformPayment||(z.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]):(this.isErrorsVisible=!0,[2]);case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,5];case 4:t.sent(),t.label=5;case 5:return[4,this.saveCart()];case 6:return t.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:U.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return t.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return t.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return t.sent(),[4,this.saveCart()];case 4:return t.sent(),this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):this.isPayPal?[2]:[4,this.createSaleTransaction()];case 5:return t.sent(),[3,7];case 6:return(i=t.sent()).type?this.error=i:this.error={type:U.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(z,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,h,p,m,f,g,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,A.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:e,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)},metadata:{_fbp:V("_fbp"),_fbc:V("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,A.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=t.sent(),t.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,o=r&&[l.SUCCESS,l.AUTHORIZED].includes(r),d=r===l.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:U.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(_.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){z.changeStep(_.INFO)},this.onBackToShippingClick=function(){z.changeStep(_.SHIPPING)},this.setCustomerConsentGranted=function(e){z.checkout.customer&&(z.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){z.useDifferentAddress=e,z.useDifferentAddress?(localStorage.setItem("sAddr","1"),z.checkout.billingAddress=z.checkout.billingAddress||new L,z.checkout.billingAddress.countrySettings=z.countrySettings):(localStorage.removeItem("sAddr"),z.checkout.billingAddress=z.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){z.shouldSaveAddress=e},this.setAddressTitle=function(e){z.addressTitle=e},this.reInitPaymentMethod=function(){return e(z,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,6];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenClientToken(this.checkout.selectedPaymentGateway)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.isPayPal?[4,this.getPayPalClientId(this.checkout.selectedPaymentGateway)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},this.createStripePaymentIntent=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,A.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.stripeResponse=e.data),[2]}}))}))},this.createKlarnaClientToken=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,A.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.klarnaResponse=e.data),[2]}}))}))},this.createAdyenClientToken=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,A.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.adyenResponse=e.data),[2]}}))}))},this.getPayPalClientId=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,A.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:i.id||""}})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.payPalClientIdResponse=e.data),[2]}}))}))},this.setPaymentGateway=function(i){return e(z,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||!(null===(s=e.settings)||void 0===s?void 0:s.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))||this.stripeResponse?[3,2]:[4,this.createStripePaymentIntent(e)]:[2];case 1:t.sent(),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,this.createKlarnaClientToken(e)];case 3:t.sent(),t.label=4;case 4:return"ADYEN"!==e.code||this.adyenResponse?[3,6]:[4,this.createAdyenClientToken(e)];case 5:t.sent(),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,this.getPayPalClientId(e)];case 7:t.sent(),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==_.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new P,e.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(e){z.cardData&&(z.cardData.installmentCount=e)},this.changeStep=function(i){return e(z,void 0,void 0,(function(){return t(this,(function(e){return K||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(z,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return e.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(e){z.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(z,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===h.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,E.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new b(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(z,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(p.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(p.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(z,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,w.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new f(e.data,this.countrySettings),i.accepted&&this.step===_.SUCCESS?this.changeStep(_.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(z,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(t){switch(t.label){case 0:return this.checkout.customer?(e=this.checkout.customer,s=e.firstName,n=e.lastName,r=e.email,s&&n&&r?[4,I.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=d,this.checkoutSettings=u,this.router=y,this.returnPolicy=S,this.privacyPolicy=F,this.termsOfService=B,this.imprint=H,this.shippingPolicy=q,this.t=W,this.customizationProps=Q,this.mpVM=new N,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new C({currentLocale:D.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(F.prototype,"merchantSettings",{get:function(){return new S(D.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"selectedPaymentGatewayIndex",{get:function(){var e=this;return this.paymentGateways.findIndex((function(t){var i;return t.id===(null===(i=e.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"selectedInstallmentIndex",{get:function(){var e,t,i=this;return(null===(t=null===(e=this.installmentInfo)||void 0===e?void 0:e.installmentPrices)||void 0===t?void 0:t.findIndex((function(e){var t;return e.installmentCount===(null===(t=i.cardData)||void 0===t?void 0:t.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=R.getInstance().customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){return{label:e.title+" - "+e.addressText,value:e.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"installmentPrice",{get:function(){var e,t,i,s=this;if(this.installmentInfo&&(null===(e=this.cardData)||void 0===e?void 0:e.installmentCount))return null===(i=null===(t=this.installmentInfo.installmentPrices)||void 0===t?void 0:t.find((function(e){var t;return e.installmentCount===(null===(t=s.cardData)||void 0===t?void 0:t.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"finalPrice",{get:function(){return this.step===_.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===U.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"canProceedToShipping",{get:function(){var e,t,i;return(this.isDigitalOnly?null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress:null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==U.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"canProceedToInStoreDelivery",{get:function(){var e,t,i;return!!((null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.firstName)&&(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!(!this.isInStoreDelivery&&!this.isDigitalOnly)||this.checkout.shippingSettingsId&&this.checkout.shippingZoneRateId&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.some((function(e){return e.shippingSettingsId===t.checkout.shippingSettingsId&&e.shippingZoneRateId===t.checkout.shippingZoneRateId})))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"klarnaPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"payPalPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isCustomFlowStripe",{get:function(){var e,t=this.checkout.selectedPaymentGateway;return t&&"STRIPE"===t.code&&(null===(e=t.settings)||void 0===e?void 0:e.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"store",{get:function(){return R.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"canPerformPayment",{get:function(){var e,t;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),r=!!this.isFree||(!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!(!this.isKlarna&&!this.isPayPal)||(null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"customerAddresses",{get:function(){var e,t,s=this;return null===(t=null===(e=this.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===t?void 0:t.map((function(e){var t=new y(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isEPayKolayEnabled",{get:function(){var e=D.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(F.prototype,"isPoweredByHidden",{get:function(){var e=D.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),F.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},F}();function Z(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function Y(e){return e&&F.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(_||(_={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.API_ERROR=1]="API_ERROR",e[e.STOCK_ERROR=2]="STOCK_ERROR",e[e.PAYMENT_ERROR=3]="PAYMENT_ERROR",e[e.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",e[e.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(U||(U={}));export{_ as CheckoutStep,U as ErrorType,B as default};
@@ -1 +1 @@
1
- import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import a from"next/head.js";import{useRouter as r}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../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{IkasStorefrontConfig as n}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as s}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var d=o((function(o){var s,d,l=o.pageType,p=o.pageTitle,u=o.pageDescription,g=o.canonicals,f=o.disableIndex,h=o.pageSpecificData,v=o.merchantSettings,j=o.addOgpMetas,x=o.productReviewSummary,y=r(),b="undefined"!=typeof window,k="local"===process.env.NEXT_PUBLIC_ENV,C=y.asPath.split("?")[0].replace("/",""),E=(C="/"===C.charAt(C.length-1)?C.slice(0,-1):C).startsWith("pages/"),T=n.getCurrentRouting(),D=(null==T?void 0:T.path)?"/"+T.path:"",L=k?"http://localhost:3333":"https://"+n.getDomain();t.useEffect((function(){document.documentElement.lang=n.getCurrentLocale()}),[l,h]);var w=t.useMemo((function(){if(h&&h.href)return"".concat(L).concat(h.href)}),[h]),O=t.useMemo((function(){var e,t=[];if(j){if(t.push({property:"og:type",content:"website"}),t.push({property:"og:site_name",content:"https://"+n.getDomain()}),p&&t.push({property:"og:title",content:p}),u&&t.push({property:"og:description",content:u}),l===i.INDEX){var o=null,a=null,r=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));r&&(o=c(h,l,r.titleTemplate||""),a=c(h,l,r.descriptionTemplate||"")),o&&t.push({property:"og:title",content:o}),a&&t.push({property:"og:description",content:a})}if(t.push({property:"og:url",content:w||(b?window.location.href:"")||"https://".concat(n.getDomain())}),h&&l===i.PRODUCT){var s=h.selectedVariant.mainImage;(null==s?void 0:s.image)&&t.push({property:"og:image",content:s.image.src})}else(null==v?void 0:v.logo)&&t.push({property:"og:image",content:v.logo.src});if(h&&l===i.CATEGORY){var d=h;d.image&&t.push({property:"og:image",content:d.image.src})}if(h&&l===i.BRAND){var m=h;m.image&&t.push({property:"og:image",content:m.image.src})}}return t}),[p,h,w,u,v,j,v]),P=t.useMemo((function(){var t=[];if(v){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+n.getDomain()},a=function(t){var o,a,r,i,s,d,m=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:m,image:m,url:"https://"+n.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(r=null===(a=t.address)||void 0===a?void 0:a.city)||void 0===r?void 0:r.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(i=t.address)||void 0===i?void 0:i.postalCode,addressCountry:null===(d=null===(s=t.address)||void 0===s?void 0:s.country)||void 0===d?void 0:d.code})}}(v);t.push(o),t.push(a)}if(h&&l===i.PRODUCT){var r=h,s=function(t,o){var a,r,i,s;try{var d="https://".concat(n.getDomain()).concat(t.href),m=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(a=t.metaData)||void 0===a?void 0:a.description,image:null===(r=m.images)||void 0===r?void 0:r.map((function(e){return e.image?e.image.src:""})),productId:m.id,sku:m.sku,mpn:(null===(i=m.barcodeList)||void 0===i?void 0:i.length)?m.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(s=t.brand)||void 0===s?void 0:s.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:d,priceCurrency:m.price.currency||"TRY",price:m.price.finalPrice,priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:m.stock>0?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(r,x||null);if(s&&t.push(s),r.categories.length)(c=m(r.categories[0]))&&t.push(c)}if(h&&l===i.CATEGORY){var d=function(e){var t,o;try{return{"@context":"http://schema.org","@type":"CollectionPage",url:"https://".concat(n.getDomain()).concat(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(h),c=m(h);d&&t.push(d),c&&t.push(c)}if(h&&l===i.BLOG){var p=function(t){var o;try{var a="https://".concat(n.getDomain()).concat(t.href),r=function(e){var t=new Date(e),o=t.getFullYear(),a=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(a,"-").concat(r)},i="".concat(t.writer.firstName," ").concat(t.writer.lastName),s=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:a,datePublished:r(t.createdAt),dateCreated:r(t.createdAt),dateModified:r(t.updatedAt),description:t.shortDescription,articleBody:s,author:{"@type":"Person",name:i}})}catch(e){}}(h);p&&t.push(p)}return t}),[h,v]),R=t.useMemo((function(){var e,t=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));return t?c(h,l,t.titleTemplate||""):null}),[l,h]),_=t.useMemo((function(){var e,t=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));return t?c(h,l,t.descriptionTemplate||""):null}),[l,h]),A=t.useCallback((function(){var e=n.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),S=[];return n.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){S.push({routing:e,hrefLang:e.locale+"-"+t})})):S.push({routing:e,hrefLang:e.locale})})),t.createElement(a,null,t.createElement("title",null,p||R||""),t.createElement("meta",{name:"description",content:u||_||""}),l===i.CHECKOUT&&A()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(s=n.getApiUrl())||void 0===s?void 0:s.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(d=n.getApiUrl())||void 0===d?void 0:d.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),S.length>1&&S.filter((function(e){return!E||e.routing.id===(null==T?void 0:T.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(L+(e.routing.path?"/"+e.routing.path:""),"/").concat(C)})})),!!f&&t.createElement("meta",{name:"robots",content:"noindex"}),!!j&&O.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!g&&g.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(L).concat(D).concat(e)})})),t.createElement("link",{rel:"canonical",href:"".concat(L).concat(D,"/").concat(C)}),!!P.length&&P.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e){try{var t=s.getInstance(),o=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:"https://"+n.getDomain()+e.href}}));return t.currentPageType===i.CATEGORY&&o.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:"https://"+n.getDomain()+e.href}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:e.categoryPathItems.length?o:[{"@type":"ListItem",position:1,name:e.name,item:"https://"+n.getDomain()+e.href}]}}catch(e){}}function c(e,t,o){var a,r,n=o;try{switch(t){case i.PRODUCT:var s=e,d=s.name,m=(null===(a=s.brand)||void 0===a?void 0:a.name)||"",c=s.selectedVariant.sku||"",l=(null===(r=s.selectedVariant.barcodeList)||void 0===r?void 0:r.length)?s.selectedVariant.barcodeList[0]:"";n.includes("{{name}}")&&(n=n.replace("{{name}}",d)),n.includes("{{brand}}")&&(n=n.replace("{{brand}}",m)),n.includes("{{sku}}")&&(n=n.replace("{{sku}}",c)),n.includes("{{barcode}}")&&(n=n.replace("{{barcode}}",l));break;case i.BRAND:case i.CATEGORY:case i.BLOG_CATEGORY:var p=e.name||"";n.includes("{{name}}")&&(n=n.replace("{{name}}",p));break;case i.BLOG:var u=e.title;n.includes("{{name}}")&&(n=n.replace("{{name}}",u))}}catch(e){}return n.trimEnd()}export{d as IkasPageHead};
1
+ import{__assign as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import a from"next/head.js";import{useRouter as r}from"next/router";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import"mobx";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../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{IkasStorefrontConfig as n}from"@ikas/storefront-config";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"./index.js";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"../page-editor/loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import"../../pages/account/activate.js";import{IkasBaseStore as s}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var d=o((function(o){var s,d,l=o.pageType,p=o.pageTitle,u=o.pageDescription,g=o.canonicals,f=o.disableIndex,h=o.pageSpecificData,v=o.merchantSettings,j=o.addOgpMetas,x=o.productReviewSummary,y=r(),b="undefined"!=typeof window,k="local"===process.env.NEXT_PUBLIC_ENV,C=y.asPath.split("?")[0].replace("/",""),E=(C="/"===C.charAt(C.length-1)?C.slice(0,-1):C).startsWith("pages/"),T=n.getCurrentRouting(),D=(null==T?void 0:T.path)?"/"+T.path:"",L=k?"http://localhost:3333":"https://"+n.getDomain();t.useEffect((function(){document.documentElement.lang=n.getCurrentLocale()}),[l,h]);var w=t.useMemo((function(){if(h&&h.href)return"".concat(L).concat(h.href)}),[h]),O=t.useMemo((function(){var e,t=[];if(j){if(t.push({property:"og:type",content:"website"}),t.push({property:"og:site_name",content:"https://"+n.getDomain()}),p&&t.push({property:"og:title",content:p}),u&&t.push({property:"og:description",content:u}),l===i.INDEX){var o=null,a=null,r=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));r&&(o=c(h,l,r.titleTemplate||""),a=c(h,l,r.descriptionTemplate||"")),o&&t.push({property:"og:title",content:o}),a&&t.push({property:"og:description",content:a})}if(t.push({property:"og:url",content:w||(b?window.location.href:"")||"https://".concat(n.getDomain())}),h&&l===i.PRODUCT){var s=h.selectedVariant.mainImage;(null==s?void 0:s.image)&&t.push({property:"og:image",content:s.image.src})}else(null==v?void 0:v.logo)&&t.push({property:"og:image",content:v.logo.src});if(h&&l===i.CATEGORY){var d=h;d.image&&t.push({property:"og:image",content:d.image.src})}if(h&&l===i.BRAND){var m=h;m.image&&t.push({property:"og:image",content:m.image.src})}}return t}),[p,h,w,u,v,j,v]),P=t.useMemo((function(){var t=[];if(v){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+n.getDomain()},a=function(t){var o,a,r,i,s,d,m=(null==t?void 0:t.logo)?t.logo.src:void 0;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:m,image:m,url:"https://"+n.getDomain(),telephone:null==t?void 0:t.phone,address:e(e({"@type":"PostalAddress",streetAddress:null===(o=t.address)||void 0===o?void 0:o.addressLine1,addressLocality:null===(r=null===(a=t.address)||void 0===a?void 0:a.city)||void 0===r?void 0:r.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(i=t.address)||void 0===i?void 0:i.postalCode,addressCountry:null===(d=null===(s=t.address)||void 0===s?void 0:s.country)||void 0===d?void 0:d.code})}}(v);t.push(o),t.push(a)}if(h&&l===i.PRODUCT){var r=h,s=function(t,o){var a,r,i,s;try{var d="https://".concat(n.getDomain()).concat(t.href),m=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(a=t.metaData)||void 0===a?void 0:a.description,image:null===(r=m.images)||void 0===r?void 0:r.map((function(e){return e.image?e.image.src:""})),productId:m.id,sku:m.sku,mpn:(null===(i=m.barcodeList)||void 0===i?void 0:i.length)?m.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(s=t.brand)||void 0===s?void 0:s.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:d,priceCurrency:m.price.currency||"TRY",price:m.price.finalPrice.toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:m.stock>0?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(r,x||null);if(s&&t.push(s),r.categories.length)(c=m(r.categories[0]))&&t.push(c)}if(h&&l===i.CATEGORY){var d=function(e){var t,o;try{return{"@context":"http://schema.org","@type":"CollectionPage",url:"https://".concat(n.getDomain()).concat(e.href),name:null===(t=e.metaData)||void 0===t?void 0:t.pageTitle,description:null===(o=e.metaData)||void 0===o?void 0:o.description,image:e.image?e.image.src:void 0}}catch(e){}}(h),c=m(h);d&&t.push(d),c&&t.push(c)}if(h&&l===i.BLOG){var p=function(t){var o;try{var a="https://".concat(n.getDomain()).concat(t.href),r=function(e){var t=new Date(e),o=t.getFullYear(),a=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(a,"-").concat(r)},i="".concat(t.writer.firstName," ").concat(t.writer.lastName),s=(new DOMParser).parseFromString(t.blogContent.content,"text/html").body.textContent;return e(e({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,image:null===(o=t.image)||void 0===o?void 0:o.src},t.category&&{genre:t.category.name}),{url:a,datePublished:r(t.createdAt),dateCreated:r(t.createdAt),dateModified:r(t.updatedAt),description:t.shortDescription,articleBody:s,author:{"@type":"Person",name:i}})}catch(e){}}(h);p&&t.push(p)}return t}),[h,v]),R=t.useMemo((function(){var e,t=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));return t?c(h,l,t.titleTemplate||""):null}),[l,h]),_=t.useMemo((function(){var e,t=null===(e=n.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===n.getCurrentLocale()&&e.pageType===l}));return t?c(h,l,t.descriptionTemplate||""):null}),[l,h]),A=t.useCallback((function(){var e=n.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),S=[];return n.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){S.push({routing:e,hrefLang:e.locale+"-"+t})})):S.push({routing:e,hrefLang:e.locale})})),t.createElement(a,null,t.createElement("title",null,p||R||""),t.createElement("meta",{name:"description",content:u||_||""}),l===i.CHECKOUT&&A()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(s=n.getApiUrl())||void 0===s?void 0:s.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(d=n.getApiUrl())||void 0===d?void 0:d.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),S.length>1&&S.filter((function(e){return!E||e.routing.id===(null==T?void 0:T.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(L+(e.routing.path?"/"+e.routing.path:""),"/").concat(C)})})),!!f&&t.createElement("meta",{name:"robots",content:"noindex"}),!!j&&O.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!g&&g.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(L).concat(D).concat(e)})})),t.createElement("link",{rel:"canonical",href:"".concat(L).concat(D,"/").concat(C)}),!!P.length&&P.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e){try{var t=s.getInstance(),o=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:"https://"+n.getDomain()+e.href}}));return t.currentPageType===i.CATEGORY&&o.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:"https://"+n.getDomain()+e.href}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:e.categoryPathItems.length?o:[{"@type":"ListItem",position:1,name:e.name,item:"https://"+n.getDomain()+e.href}]}}catch(e){}}function c(e,t,o){var a,r,n=o;try{switch(t){case i.PRODUCT:var s=e,d=s.name,m=(null===(a=s.brand)||void 0===a?void 0:a.name)||"",c=s.selectedVariant.sku||"",l=(null===(r=s.selectedVariant.barcodeList)||void 0===r?void 0:r.length)?s.selectedVariant.barcodeList[0]:"";n.includes("{{name}}")&&(n=n.replace("{{name}}",d)),n.includes("{{brand}}")&&(n=n.replace("{{brand}}",m)),n.includes("{{sku}}")&&(n=n.replace("{{sku}}",c)),n.includes("{{barcode}}")&&(n=n.replace("{{barcode}}",l));break;case i.BRAND:case i.CATEGORY:case i.BLOG_CATEGORY:var p=e.name||"";n.includes("{{name}}")&&(n=n.replace("{{name}}",p));break;case i.BLOG:var u=e.title;n.includes("{{name}}")&&(n=n.replace("{{name}}",u))}}catch(e){}return n.trimEnd()}export{d as IkasPageHead};
@@ -1 +1 @@
1
- import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import n from"lodash/sortBy";import{IkasCategory as r}from"../category/index.js";import{IkasProductVariant as a}from"./variant/index.js";import{IkasProductAttributeValue as o}from"./attribute-value/index.js";import{IkasProductVariantType as s}from"./variant-type/index.js";import{IkasBrand as u}from"../brand/index.js";import{IkasHTMLMetaData as c}from"../html-meta-data/index.js";import{IkasProductTag as l}from"./tag/index.js";import{IkasProductType as d}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as p}from"./option-set/index.js";import{makeObservable as f,observable as m,computed as h}from"mobx";import{IkasProductFunctions as v}from"@ikas/storefront-model-functions";import{IkasProductCampaign as g}from"./campaign/index.js";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{Analytics as y}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as V}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as P}from"./base-unit/index.js";import{formatCurrency as S}from"../../../utils/currency.js";import"lodash/get";import j from"../../../store/product/index.js";import{IkasCustomerReviewList as w}from"../../ui/customer-review-list/index.js";import{IkasProductStar as I}from"./star/index.js";var T=function(){function T(v){void 0===v&&(v={});var O,T,x,C=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.selectVariantValue=function(e,i){var n,r=C.metaData,a=C.selectedVariantValues.map((function(t){return t.variantTypeId===e.variantTypeId?e:t})),o=C.variants.find((function(t){return t.isActive&&a.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(o)C.selectedVariantValues=a;else{var s=C.variantTypes.findIndex((function(t){return t.variantType.id===e.variantTypeId}));if(s>0){var u=C.variantTypes.slice(0,s),c=C.selectedVariantValues.filter((function(t){return u.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],c,!0),[e],!1);o=C.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var d=a.slice(0,a.length-1);(o=C.variants.find((function(t){return t.isActive&&d.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(o=C.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===e.id}))})))}if(!o)return;C.selectedVariantValues=o.variantValues}var p=C.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return C.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})).filter((function(t){return!!t})).join("&");if(!i){var f="/".concat(r.slug);if(p&&(f="/".concat(r.slug,"?").concat(p)),f===window.location.pathname)return;null===(n=V.getInstance().router)||void 0===n||n.replace(f,void 0,{shallow:!1,scroll:!1})}y.productView(C)},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&C.baseUnit){var r=C.baseUnit.baseAmount,a=(null===(i=null===(e=C.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(S(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return e(C,void 0,void 0,(function(){var t,e,n,r,a,o=this;return i(this,(function(i){switch(i.label){case 0:return t=V.getInstance(),e=t.customerStore.customer,n=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,j.getProductCampaigns({input:{customerGroupIds:n,salesChannelId:b.getSalesChannelId()||"",variantIds:r}})];case 1:return a=i.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return e(C,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=b.getPickupStockLocationIds(),[4,j.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return e(C,void 0,void 0,(function(){var e;return i(this,(function(i){switch(i.label){case 0:return[4,(e=new w({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page})).getInitial()];case 1:return i.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return e(C,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,j.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.setOptionPrices=function(){var t,e=C.variants[0];if(e){var i=e.price.currency;null===(t=C.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=v.id||Date.now()+"",this.name=v.name||"",this.type=v.type||d.PHYSICAL,this.description=v.description||"",this.shortDescription=v.shortDescription||"",this.metaData=v.metaData?new c(v.metaData):null,this.brand=v.brand?new u(v.brand):null,this.categories=v.categories?v.categories.map((function(t){return new r(t)})):[],this.deleted=v.deleted||null,this.tags=v.tags?v.tags.map((function(t){return new l(t)})):[],this.variants=v.variants?v.variants.map((function(t){return new a(t)})):[],this.attributes=v.attributes?v.attributes.map((function(t){return new o(t)})):[],this.variantTypes=v.variantTypes?v.variantTypes.map((function(t){return new s(t)})):[],this.productOptionSetId=v.productOptionSetId||null,this.averageRating=null!==(O=v.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(T=v.reviewCount)&&void 0!==T?T:null,this.stars=v.stars?v.stars.map((function(t){return new I(t)})):null,this.baseUnit=v.baseUnit?new P(v.baseUnit):null,this.productOptionSet=v.productOptionSet?new p(v.productOptionSet):null,this.campaigns=(null===(x=v.campaigns)||void 0===x?void 0:x.map((function(t){return new g(t)})))||null,this.selectedVariantValues=v.selectedVariantValues||[],this.variantTypes=n(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=v.groupVariantsByVariantTypeId||null,this.setOptionPrices(),f(this,{selectedVariantValues:m,isFiltered:m,isStatic:m,hasVariant:h,hasStock:h,hasValidProductOptionValues:h,href:h,productHref:h,mainVariantType:h,mainVariantValue:h,selectedVariant:h,displayedVariantTypes:h,isCustomerReviewEnabled:h,isCustomerReviewLoginRequired:h,isAddToCartEnabled:h,groupedAttributeValues:h,selectedVariantUnitPriceText:h})}return Object.defineProperty(T.prototype,"hasVariant",{get:function(){return v.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:v.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"href",{get:function(){return v.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:v.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"mainVariantType",{get:function(){return v.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"mainVariantValue",{get:function(){return v.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"displayedVariantTypes",{get:function(){return v.getDisplayedVariantTypes(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isCustomerReviewEnabled",{get:function(){return b.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isCustomerReviewLoginRequired",{get:function(){return b.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isAddToCartEnabled",{get:function(){return this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),T}();export{T as IkasProduct};
1
+ import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import{IkasCategory as a}from"../category/index.js";import{IkasProductVariant as o}from"./variant/index.js";import{IkasProductAttributeValue as s}from"./attribute-value/index.js";import{IkasProductVariantType as u}from"./variant-type/index.js";import{IkasBrand as c}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as d}from"./tag/index.js";import{IkasProductType as p}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as f}from"./option-set/index.js";import{makeObservable as m,observable as h,computed as v}from"mobx";import{IkasProductFunctions as g}from"@ikas/storefront-model-functions";import{IkasProductCampaign as b}from"./campaign/index.js";import{IkasStorefrontConfig as y}from"@ikas/storefront-config";import{Analytics as V}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as O}from"../../../store/base.js";import P from"lodash/groupBy";import{IkasProductBaseUnit as S}from"./base-unit/index.js";import{formatCurrency as j}from"../../../utils/currency.js";import"lodash/get";import w from"../../../store/product/index.js";import{IkasCustomerReviewList as T}from"../../ui/customer-review-list/index.js";import{IkasProductStar as I}from"./star/index.js";var x=function(){function x(g){void 0===g&&(g={});var P,x,C,k=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.selectVariantValue=function(i,n){var r,a=k.metaData,o=k.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=k.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)k.selectedVariantValues=o;else{var u=k.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=k.variantTypes.slice(0,u),l=k.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),d=t(t([],l,!0),[i],!1);s=k.variants.find((function(t){return t.isActive&&d.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=k.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=k.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;k.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;f=e(e({},f),((n={})[i]=t,n))})),k.variantTypes.map((function(t){delete f[t.variantType.slug]}));var m=t(t([],k.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return k.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0).filter((function(t){return!!t})).join("&");if(!n){var h="/".concat(a.slug);if(m&&(h="/".concat(a.slug,"?").concat(m)),h===window.location.pathname)return;null===(r=O.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}V.productView(k)},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&k.baseUnit){var r=k.baseUnit.baseAmount,a=(null===(i=null===(e=k.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(j(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(k,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=O.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,w.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:y.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(k,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=y.getPickupStockLocationIds(),[4,w.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(k,void 0,void 0,(function(){var e;return n(this,(function(i){switch(i.label){case 0:return[4,(e=new T({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page})).getInitial()];case 1:return i.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return i(k,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,w.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.setOptionPrices=function(){var t,e=k.variants[0];if(e){var i=e.price.currency;null===(t=k.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=g.id||Date.now()+"",this.name=g.name||"",this.type=g.type||p.PHYSICAL,this.description=g.description||"",this.shortDescription=g.shortDescription||"",this.metaData=g.metaData?new l(g.metaData):null,this.brand=g.brand?new c(g.brand):null,this.categories=g.categories?g.categories.map((function(t){return new a(t)})):[],this.deleted=g.deleted||null,this.tags=g.tags?g.tags.map((function(t){return new d(t)})):[],this.variants=g.variants?g.variants.map((function(t){return new o(t)})):[],this.attributes=g.attributes?g.attributes.map((function(t){return new s(t)})):[],this.variantTypes=g.variantTypes?g.variantTypes.map((function(t){return new u(t)})):[],this.productOptionSetId=g.productOptionSetId||null,this.averageRating=null!==(P=g.averageRating)&&void 0!==P?P:null,this.reviewCount=null!==(x=g.reviewCount)&&void 0!==x?x:null,this.stars=g.stars?g.stars.map((function(t){return new I(t)})):null,this.baseUnit=g.baseUnit?new S(g.baseUnit):null,this.productOptionSet=g.productOptionSet?new f(g.productOptionSet):null,this.campaigns=(null===(C=g.campaigns)||void 0===C?void 0:C.map((function(t){return new b(t)})))||null,this.selectedVariantValues=g.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=g.groupVariantsByVariantTypeId||null,this.setOptionPrices(),m(this,{selectedVariantValues:h,isFiltered:h,isStatic:h,hasVariant:v,hasStock:v,hasValidProductOptionValues:v,href:v,productHref:v,mainVariantType:v,mainVariantValue:v,selectedVariant:v,displayedVariantTypes:v,isCustomerReviewEnabled:v,isCustomerReviewLoginRequired:v,isAddToCartEnabled:v,groupedAttributeValues:v,selectedVariantUnitPriceText:v})}return Object.defineProperty(x.prototype,"hasVariant",{get:function(){return g.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:g.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"href",{get:function(){return g.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:g.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"mainVariantType",{get:function(){return g.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"mainVariantValue",{get:function(){return g.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"displayedVariantTypes",{get:function(){return g.getDisplayedVariantTypes(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomerReviewEnabled",{get:function(){return y.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomerReviewLoginRequired",{get:function(){return y.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isAddToCartEnabled",{get:function(){return this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"groupedAttributeValues",{get:function(){var t,e=P(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),x}();export{x as IkasProduct};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import r from"./api.js";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{Analytics as o}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as s}from"@ikas/storefront-api";import{getCookieValue as a}from"../../utils/helper.js";var c,u="cartId",d=function(){function u(u){var d=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,s,u){return void 0===u&&(u=1),t(d,void 0,void 0,(function(){var t,d,l,h,f,v,p,I,m,C;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),s.hasValidProductOptionValues?i.hasStock||i.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:c.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:c.INVALID_PRODUCT_OPTION_VALUES}];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(i,s))?(null===(I=s.productOptionSet)||void 0===I||I.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(d=this.getOptionValues(s),l=(null===(m=this.cart)||void 0===m?void 0:m.id)||localStorage.getItem("cartId"),[4,r.addItemToCart({input:{cartId:l,item:{id:null,quantity:u,variant:{id:i.id,name:s.name}},options:d.length?d:null,priceListId:n.getPriceListId()||null,salesChannelId:n.getSalesChannelId(),storefrontThemeId:n.getStorefrontThemeId(),metadata:{_fbp:a("_fbp"),_fbc:a("_fbc")}}})]);case 2:return(h=e.sent()).isSuccess&&h.data?[4,this.setCart(h.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(f="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(v=this.cart.items.find((function(t){return t.variant.id===i.id})))&&o.addToCart(v,u,f,this.cart)),null===(C=s.productOptionSet)||void 0===C||C.initOptionValues(),[2,{success:h.isSuccess,response:h}];case 5:return p=e.sent(),console.log(p),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,s){return t(d,void 0,void 0,(function(){var t,c,u,d,l;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,r.addItemToCart({input:{cartId:(null===(l=this.cart)||void 0===l?void 0:l.id)||null,item:{id:i.id,quantity:s,variant:{id:i.variant.id,name:i.variant.name}},options:this.createCartLineOptions(i),priceListId:n.getPriceListId()||null,salesChannelId:n.getSalesChannelId(),storefrontThemeId:n.getStorefrontThemeId(),metadata:{_fbp:a("_fbp"),_fbc:a("_fbc")}}})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(c="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(u=i.quantity)>s?o.removeFromCart(i,u-s,this.cart):o.addToCart(i,s-u,c,this.cart)),[2,{success:t.isSuccess,response:t}];case 5:return d=e.sent(),console.log(d),[2,{success:!1}];case 6:return[2]}}))}))},this.removeItem=function(i){return t(d,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),d.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){d.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,r,n,o,s;if(!e.productOptionSetId)return null===(i=d.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));for(var a=d.getOptionValues(e),c=(null===(r=d.cart)||void 0===r?void 0:r.orderLineItems.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===a.length})))||[],u=0,l=c;u<l.length;u++){var h=l[u];if(h.options){for(var f=!0,v=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(o=null===(n=e.productOptionSet)||void 0===n?void 0:n.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(f=f&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},p=0,I=h.options;p<I.length;p++){if("break"===v(I[p]))break}if(f)return h}}},this.saveCouponCode=function(i){return t(d,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,r.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:c.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(d,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.saveCart=function(i){return t(d,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return t=new s(i),[4,r.saveCart({input:t})];case 1:return[2,{success:(n=e.sent()).isSuccess,response:n}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=d.cart)||void 0===t?void 0:t.itemCount)&&d.removeCart()},this.getCart=function(){return t(d,void 0,void 0,(function(){var t,i,n,o,s,a;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(s=this.baseStore.customerStore.customer)||void 0===s?void 0:s.id,(i=(null===(a=this.cart)||void 0===a?void 0:a.id)||localStorage.getItem("cartId"))||t?[4,r.getCartById({id:i})]:[2];case 2:return(n=e.sent()).isSuccess&&n.data?[4,this.setCart(n.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return o=e.sent(),console.log(o),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(d,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(d,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var n=r[i],o={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(o)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this.baseStore=u,i(this)}return Object.defineProperty(u.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),u}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(c||(c={}));export{u as CART_LS_KEY,c as IkasCartOperationValidationError,d as IkasCartStore};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import r from"./api.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as o}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{Analytics as s}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as n}from"@ikas/storefront-api";import{getCookieValue as d}from"../../utils/helper.js";var c,u="cartId",l=function(){function u(u){var l=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,o,n){return void 0===n&&(n=1),t(l,void 0,void 0,(function(){var t,u,l,m,p,h,f,v,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),o.hasValidProductOptionValues?i.hasStock||i.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:c.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:c.INVALID_PRODUCT_OPTION_VALUES}];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(i,o))?(null===(v=o.productOptionSet)||void 0===v||v.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(u=this.getOptionValues(o),l=(null===(I=this.cart)||void 0===I?void 0:I.id)||localStorage.getItem("cartId"),[4,r.addItemToCart({input:{cartId:l,item:{id:null,quantity:n,variant:{id:i.id,name:o.name}},options:u.length?u:null,priceListId:a.getPriceListId()||null,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc")}}})]);case 2:return(m=e.sent()).isSuccess&&m.data?[4,this.setCart(m.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(p="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(h=this.cart.items.find((function(t){return t.variant.id===i.id})))&&s.addToCart(h,n,p,this.cart)),null===(g=o.productOptionSet)||void 0===g||g.initOptionValues(),[2,{success:m.isSuccess,response:m}];case 5:return f=e.sent(),console.log(f),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,o){return t(l,void 0,void 0,(function(){var t,n,c,u,l;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,r.addItemToCart({input:{cartId:(null===(l=this.cart)||void 0===l?void 0:l.id)||null,item:{id:i.id,quantity:o,variant:{id:i.variant.id,name:i.variant.name}},options:this.createCartLineOptions(i),priceListId:a.getPriceListId()||null,salesChannelId:a.getSalesChannelId(),storefrontThemeId:a.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc")}}})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(n="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(c=i.quantity)>o?s.removeFromCart(i,c-o,this.cart):s.addToCart(i,o-c,n,this.cart)),[2,{success:t.isSuccess,response:t}];case 5:return u=e.sent(),console.log(u),[2,{success:!1}];case 6:return[2]}}))}))},this.removeItem=function(i){return t(l,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),l.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){l.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,r,o,a,s;if(!e.productOptionSetId)return null===(i=l.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));for(var n=l.getOptionValues(e),d=(null===(r=l.cart)||void 0===r?void 0:r.orderLineItems.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===n.length})))||[],c=0,u=d;c<u.length;c++){var m=u[c];if(m.options){for(var p=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(a=null===(o=e.productOptionSet)||void 0===o?void 0:o.options)||void 0===a?void 0:a.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(p=p&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},f=0,v=m.options;f<v.length;f++){if("break"===h(v[f]))break}if(p)return m}}},this.saveCouponCode=function(i){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,r.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:c.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(l,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.saveCart=function(i){return t(l,void 0,void 0,(function(){var t,a;return e(this,(function(e){switch(e.label){case 0:return(t=new n(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===o.SUBSCRIBED),[4,r.saveCart({input:t})];case 1:return[2,{success:(a=e.sent()).isSuccess,response:a}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=l.cart)||void 0===t?void 0:t.itemCount)&&l.removeCart()},this.getCart=function(){return t(l,void 0,void 0,(function(){var t,i,o,a,s,n;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(s=this.baseStore.customerStore.customer)||void 0===s?void 0:s.id,(i=(null===(n=this.cart)||void 0===n?void 0:n.id)||localStorage.getItem("cartId"))||t?[4,r.getCartById({id:i})]:[2];case 2:return(o=e.sent()).isSuccess&&o.data?[4,this.setCart(o.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return a=e.sent(),console.log(a),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(l,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var o=r[i],a={productOptionId:o.productOptionId,productOptionsSetId:o.productOptionsSetId,values:o.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this.baseStore=u,i(this)}return Object.defineProperty(u.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),u}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(c||(c={}));export{u as CART_LS_KEY,c as IkasCartOperationValidationError,l as IkasCartStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.9.0",
3
+ "version": "4.9.2",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,11 +17,11 @@
17
17
  "build": "rm -rf build && rollup -c"
18
18
  },
19
19
  "devDependencies": {
20
- "@ikas/storefront-api": "^4.9.0",
21
- "@ikas/storefront-config": "^4.9.0",
22
- "@ikas/storefront-model-functions": "^4.9.0",
23
- "@ikas/storefront-models": "^4.9.0",
24
- "@ikas/storefront-providers": "^4.9.0",
20
+ "@ikas/storefront-api": "^4.9.2",
21
+ "@ikas/storefront-config": "^4.9.2",
22
+ "@ikas/storefront-model-functions": "^4.9.2",
23
+ "@ikas/storefront-models": "^4.9.2",
24
+ "@ikas/storefront-providers": "^4.9.2",
25
25
  "@ikas/localized-address": "^1.0.0-beta.3",
26
26
  "@adyen/adyen-web": "^5.28.2",
27
27
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@ikas/localized-address": "^1.0.0-beta.3",
58
- "@ikas/storefront-api": "^4.9.0",
59
- "@ikas/storefront-config": "^4.9.0",
60
- "@ikas/storefront-model-functions": "^4.9.0",
61
- "@ikas/storefront-models": "^4.9.0",
62
- "@ikas/storefront-providers": "^4.9.0",
58
+ "@ikas/storefront-api": "^4.9.2",
59
+ "@ikas/storefront-config": "^4.9.2",
60
+ "@ikas/storefront-model-functions": "^4.9.2",
61
+ "@ikas/storefront-models": "^4.9.2",
62
+ "@ikas/storefront-providers": "^4.9.2",
63
63
  "mobx": "^6.1.3",
64
64
  "mobx-react-lite": "^3.1.5",
65
65
  "next": "12.2.0",