@ikas/storefront 4.13.0 → 4.13.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.
|
@@ -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,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g,IkasCampaignOfferProductApplicablePriceEnum as v}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 y}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as S}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 k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as b}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 C}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 P}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as w}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 E}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import N from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import j from"../../store/checkout/index.js";import R from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as x,MFS_SCRIPT_URL as T}from"./modelMasterPass.js";import L from"../../store/product/index.js";import{IkasBaseStore as G}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as M}from"@ikas/storefront-config";import{Analytics as _}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as V,CheckStocksLineInput as U}from"@ikas/storefront-api";import F from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as B}from"../../utils/helper.js";var Z,Y,H=/^\d+$/,q="undefined"==typeof localStorage,W=function(){function H(u,b,C,H,W,X,$,J,ee,te){var ie=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=Z.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(ie,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,G.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(ie,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(M.getIsEditor())return this.step=Z.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===Z.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Z.INFO)];if(this.step!==Z.PAYMENT||this.canProceedToPayment){if(this.step===Z.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Z.INFO)];if(![Z.INFO,Z.SUCCESS,Z.SHIPPING,Z.PAYMENT].includes(this.step))return[2,this.changeStep(Z.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Z.INFO)]:[2,this.changeStep(Z.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:Y.PAYMENT_ERROR,data:r||null}),this.step!==Z.SHIPPING&&this.step!==Z.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==Z.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==Z.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Z.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Z.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Z.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Z.PAYMENT&&this.step!==Z.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length)return this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Z.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Z.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,_.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,O.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(ie,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new V(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==Z.INFO&&this.step!==Z.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===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,R.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:Y.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:Y.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(ie,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(ie,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,u,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===d.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=M.getStockLocationIds())||void 0===l?void 0:l.length)?M.getStockLocationIds():null,[4,j.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:Y.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)u=c[a],r(u);throw{type:Y.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(ie,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,G.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.getAvailableShippingCountries({salesChannelId:M.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?[4,j.listStockLocation({id:{in:M.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:Y.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,j.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:M.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:Y.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ie.shippingCountryIds)||void 0===e?void 0:e.length)||(ie.error={type:Y.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(ie.checkout.stockLocationId=null,ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones),ie.deliveryMethod=e,ie.isErrorsVisible=!1},this.initialStockCheck=function(){return e(ie,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:Y.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(ie,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=M.getPaymentGateways().map((function(e){return e.id})),[4,j.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:M.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===Z.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(M.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===Z.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=x,d.src=T,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:G.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:Y.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,j.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;ie.store.customerStore.customer?(null===(e=ie.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=ie.checkoutSettings,e.shippingZones=ie.shippingZones})),ie.checkout.customer=new P(ie.store.customerStore.customer)):ie.checkout.customer=new P(ie.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones,ie.checkout.billingAddress.countrySettings=ie.countrySettings,ie.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ie.isDigitalOnly)if(ie.isInStoreDelivery)ie.setCheckoutShippingAddressSettings();else if(ie.checkout.shippingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedShippingAddressIdChange(e.id||"-1"),void ie.setCheckoutShippingAddressSettings()}ie.checkout.shippingAddress=new F(n(ie.checkout.shippingAddress)||{}),ie.setCheckoutShippingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ie.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ie.useDifferentAddress=!!localStorage.getItem("sAddr"),ie.checkout.billingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedBillingAddressIdChange(e.id||"-1"),void ie.setCheckoutBillingAddressSettings()}ie.checkout.billingAddress=new F(n(ie.checkout.billingAddress)||{}),ie.setCheckoutBillingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())}else ie.onSelectedBillingAddressIdChange("-1"),ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(ie,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 y(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(ie,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(ie,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,R.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===Z.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new y(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(ie,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,K.getAvailableShippingZones({salesChannelId:M.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(ie.selectedShippingAddressId=e,"-1"===e)ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.shippingAddress=new F(i),ie.checkout.shippingAddress.countrySettings=ie.countrySettings)}ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ie.selectedBillingAddressId=e,"-1"===e)ie.checkout.billingAddress=new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.billingAddress=new F(i),ie.checkout.billingAddress.countrySettings=ie.countrySettings)}ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ie.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(ie.cardData&&(!(e.length>ie.cardData.cardNumber.length)||z(e))){var t=(ie.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!ie.installmentInfo?ie.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:ie.checkout.selectedPaymentGateway.id,price:ie.checkout.totalFinalPrice,currencyCode:ie.checkout.currencyCode}}):i.length<6&&t.length>i.length&&(ie.cardData.installmentCount=1,ie.installmentInfo=void 0),ie.cardData.cardNumber=Q(i,4).join(" "))}},this.onCardHolderNameChange=function(e){ie.cardData&&(ie.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ie.cardData&&(!(e.length>ie.cardData.expirationDate.length)||z(e))){if(0===(null===(t=ie.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(ie.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(ie.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(ie.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ie.cardData.expirationDate=Q(d,2).join(" / "))}},this.onCvcChange=function(e){ie.cardData&&(e.length>ie.cardData.cvv.length&&!z(e)||e.length>4||(ie.cardData.cvv=e))},this.saveAddress=function(s){return e(ie,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 k(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(){ie.router.push("/cart")},this.onBackToShoppingClick=function(){ie.router.push("/")},this.onGoToLoginClick=function(){ie.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(ie,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(Z.SHIPPING):this.changeStep(Z.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ie.canPerformPayment||(ie.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(ie,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:Y.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(ie,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:Y.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,l,p,m,f,g,v,y,S;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===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,j.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:B("_fbp"),_fbc:B("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,j.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&&[h.SUCCESS,h.AUTHORIZED].includes(r),d=r===h.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:Y.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(ie,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(Z.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){ie.changeStep(Z.INFO)},this.onBackToShippingClick=function(){ie.changeStep(Z.SHIPPING)},this.setCustomerConsentGranted=function(e){ie.checkout.customer&&(ie.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){ie.useDifferentAddress=e,ie.useDifferentAddress?(localStorage.setItem("sAddr","1"),ie.checkout.billingAddress=ie.checkout.billingAddress||new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings):(localStorage.removeItem("sAddr"),ie.checkout.billingAddress=ie.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){ie.shouldSaveAddress=e},this.setAddressTitle=function(e){ie.addressTitle=e},this.reInitPaymentMethod=function(){return e(ie,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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,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!==Z.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new N,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){ie.cardData&&(ie.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return q||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(ie,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){ie.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(ie,void 0,void 0,(function(){var e,r,o,a,c,d,u,l;return t(this,(function(h){switch(h.label){case 0:if(!(null==n?void 0:n.length))return[2];e=n.filter((function(e){var t;return e.status===p.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),r=function(e){var s,n,r,o,a,c;return t(this,(function(t){switch(t.label){case 0:return(null==e?void 0:e.campaignOffer)&&(s=e.campaignOffer.offers.find((function(t){return t.id===e.campaignOfferProductId})))?(n=[s.productId],[4,L.searchProducts({input:{productIdList:n,priceListId:M.getPriceListId(),salesChannelId:M.getSalesChannelId()}})]):[2,{value:void 0}];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)&&(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(s.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(e){return s.discountAmount?new A(i(i({},e),{prices:e.prices.map((function(e){var t=e.finalPrice,n=e.finalPrice-e.finalPrice*s.discountAmount/100;return s.applicablePrice===v.SELL_PRICE&&(t=e.sellPrice,n=e.sellPrice-e.sellPrice*s.discountAmount/100),new I(i(i({},e),{sellPrice:t,discountPrice:n}))}))})):e}))).length)?(c=a.find((function(e){return e.isActive})),[2,{value:{product:new w(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:s,campaignOffer:e}}]):[2]}}))},o=0,a=e,h.label=1;case 1:return o<a.length?(c=a[o],[5,r(c)]):[3,4];case 2:if("object"==typeof(d=h.sent()))return[2,d.value];h.label=3;case 3:return o++,[3,1];case 4:return[2,void 0]}}))}))},this.createCampaignOffer=function(){return e(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===Z.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,R.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Z.SUCCESS?Z.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(ie,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,O.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,j.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(ie,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,j.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=u,this.checkoutSettings=b,this.router=C,this.returnPolicy=H,this.privacyPolicy=W,this.termsOfService=X,this.imprint=$,this.shippingPolicy=J,this.t=ee,this.customizationProps=te,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new E({currentLocale:M.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(H.prototype,"merchantSettings",{get:function(){return new C(M.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.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(H.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=G.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(H.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(H.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"finalPrice",{get:function(){return this.step===Z.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===Y.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(H.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)!==Y.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"store",{get:function(){return G.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(H.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.filter((function(e){var t,i,s;return(null===(t=e.country)||void 0===t?void 0:t.iso2)&&(null===(s=null===(i=M.getCurrentRouting())||void 0===i?void 0:i.countryCodes)||void 0===s?void 0:s.includes(e.country.iso2))})).map((function(e){var t=new b(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===u.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isEPayKolayEnabled",{get:function(){var e=M.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPoweredByHidden",{get:function(){var e=M.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),H.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},H}();function Q(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function z(e){return e&&H.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Z||(Z={})),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"}(Y||(Y={}));export{Z as CheckoutStep,Y as ErrorType,W 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,IkasOrderPaymentStatus as l,IkasTransactionStatus as h,IkasCartCampaignOfferStatus as p,IkasCampaignOfferTargetPageType as m,IkasOrderLineItemStatus as f,IkasCustomerEmailSubscriptionStatus as g,IkasCampaignOfferProductApplicablePriceEnum as v}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 y}from"../../models/data/checkout/index.js";import{IkasCheckoutSettings as S}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 k}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as b}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 C}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 P}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as I}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as A}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as w}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 E}from"@ikas/localized-address";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/ikas-address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import N from"./components/credit-card-form/model.js";import O from"../../store/customer/api.js";import j from"../../store/checkout/index.js";import R from"../../store/cart/api.js";import D,{MFS_ELEMENT_ID as x,MFS_SCRIPT_URL as T}from"./modelMasterPass.js";import L from"../../store/product/index.js";import{IkasBaseStore as G}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as M}from"@ikas/storefront-config";import{Analytics as _}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as V,CheckStocksLineInput as U}from"@ikas/storefront-api";import F from"../../models/data/order/address/ikas-localized-order-address.js";import K from"../../store/location/index.js";import{getCookieValue as B}from"../../utils/helper.js";var Z,Y,H=/^\d+$/,q="undefined"==typeof localStorage,W=function(){function H(u,b,C,H,W,X,$,J,ee,te){var ie=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=Z.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(ie,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,G.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 3:return e.sent(),[2]}}))}))},this.initStep=function(){return e(ie,void 0,void 0,(function(){var e,s,n,r,a,c,d;return t(this,(function(t){switch(t.label){case 0:if(M.getIsEditor())return this.step=Z.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===Z.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(Z.INFO)];if(this.step!==Z.PAYMENT||this.canProceedToPayment){if(this.step===Z.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(Z.INFO)];if(![Z.INFO,Z.SUCCESS,Z.SHIPPING,Z.PAYMENT].includes(this.step))return[2,this.changeStep(Z.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(Z.INFO)]:[2,this.changeStep(Z.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return t.sent(),n&&(this.error={type:Y.PAYMENT_ERROR,data:r||null}),this.step!==Z.SHIPPING&&this.step!==Z.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new S(i(i({},this.checkoutSettings),{couponCodeRequirement:o.DEFAULT}))),this.step!==Z.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:t.sent(),this.checkShippingCountries(),t.label=4;case 4:return[4,this.getStockLocations()];case 5:return t.sent(),[4,this.getAvailableStockLocations()];case 6:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=7;case 7:return this.step!==Z.SHIPPING||1!==(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=Z.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==Z.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==Z.SUCCESS||this.checkout.orderPaymentStatus!==l.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:t.sent(),t.label=9;case 9:return this.step!==Z.PAYMENT&&this.step!==Z.SUCCESS?[3,13]:[4,this.listPaymentGateways()];case 10:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,12];case 11:t.sent(),t.label=12;case 12:if(!this.paymentGateways.length)return this.error={type:Y.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=13;case 13:return this.step===Z.SUCCESS?[3,17]:this.checkout.isComplete?[2,this.changeStep(Z.SUCCESS)]:[3,14];case 14:return[4,this.initialStockCheck()];case 15:t.sent(),t.label=16;case 16:return[3,19];case 17:return[4,this.getSuccessTransaction()];case 18:t.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),t.label=19;case 19:return this.isCheckoutLoaded=!0,_.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,O.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(ie,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new V(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(e)];case 1:e=t.sent(),t.label=2;case 2:return this.step!==Z.INFO&&this.step!==Z.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===g.SUBSCRIBED:this.checkout.customer&&(e.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),[4,R.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:Y.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:Y.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(ie,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(ie,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,u,l,h,p;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===d.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(l=M.getStockLocationIds())||void 0===l?void 0:l.length)?M.getStockLocationIds():null,[4,j.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:Y.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(p=null===(h=i.data)||void 0===h?void 0:h.lines)||void 0===p?void 0:p.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)u=c[a],r(u);throw{type:Y.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(ie,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,G.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.getAvailableShippingCountries({salesChannelId:M.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?[4,j.listStockLocation({id:{in:M.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:Y.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return M.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,j.getAvailableStockLocations({lines:e.map((function(e){return new U(e)})),stockLocationIdList:M.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:Y.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ie.shippingCountryIds)||void 0===e?void 0:e.length)||(ie.error={type:Y.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(ie.checkout.stockLocationId=null,ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones),ie.deliveryMethod=e,ie.isErrorsVisible=!1},this.initialStockCheck=function(){return e(ie,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:Y.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(ie,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=M.getPaymentGateways().map((function(e){return e.id})),[4,j.listPaymentGateway({cartId:this.isUpsellOrder?this.checkout.id:void 0,id:e?void 0:{in:i},locale:M.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===Z.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(M.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===Z.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=x,d.src=T,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:G.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:Y.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,j.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;ie.store.customerStore.customer?(null===(e=ie.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=ie.checkoutSettings,e.shippingZones=ie.shippingZones})),ie.checkout.customer=new P(ie.store.customerStore.customer)):ie.checkout.customer=new P(ie.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones,ie.checkout.shippingAddress.countrySettings=ie.countrySettings,ie.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones,ie.checkout.billingAddress.countrySettings=ie.countrySettings,ie.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ie.isDigitalOnly)if(ie.isInStoreDelivery)ie.setCheckoutShippingAddressSettings();else if(ie.checkout.shippingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedShippingAddressIdChange(e.id||"-1"),void ie.setCheckoutShippingAddressSettings()}ie.checkout.shippingAddress=new F(n(ie.checkout.shippingAddress)||{}),ie.setCheckoutShippingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ie.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ie.useDifferentAddress=!!localStorage.getItem("sAddr"),ie.checkout.billingAddress){if(ie.store.customerStore.customer){var e=null==(t=ie.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ie.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ie.onSelectedBillingAddressIdChange(e.id||"-1"),void ie.setCheckoutBillingAddressSettings()}ie.checkout.billingAddress=new F(n(ie.checkout.billingAddress)||{}),ie.setCheckoutBillingAddressSettings()}else if(ie.store.customerStore.customer){var t=ie.customerAddresses;ie.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())}else ie.onSelectedBillingAddressIdChange("-1"),ie.useDifferentAddress||!ie.checkout.shippingAddress||ie.isInStoreDelivery||(ie.checkout.billingAddress=new F(n(ie.checkout.shippingAddress)),ie.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(ie,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 y(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(ie,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(ie,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,R.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===Z.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,currencyCode:this.checkout.currencyCode}}),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,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new y(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(ie,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,K.getAvailableShippingZones({salesChannelId:M.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(ie.selectedShippingAddressId=e,"-1"===e)ie.checkout.shippingAddress=new F,ie.checkout.shippingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.shippingAddress=new F(i),ie.checkout.shippingAddress.countrySettings=ie.countrySettings)}ie.checkout.shippingAddress&&(ie.checkout.shippingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.shippingAddress.shippingZones=ie.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ie.selectedBillingAddressId=e,"-1"===e)ie.checkout.billingAddress=new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings;else{var i=null===(t=ie.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ie.checkout.billingAddress=new F(i),ie.checkout.billingAddress.countrySettings=ie.countrySettings)}ie.checkout.billingAddress&&(ie.checkout.billingAddress.checkoutSettings=ie.checkoutSettings,ie.checkout.billingAddress.shippingZones=ie.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ie.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(ie.cardData&&(!(e.length>ie.cardData.cardNumber.length)||z(e))){var t=(ie.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!ie.installmentInfo?ie.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:ie.checkout.selectedPaymentGateway.id,price:ie.checkout.totalFinalPrice,currencyCode:ie.checkout.currencyCode}}):i.length<6&&t.length>i.length&&(ie.cardData.installmentCount=1,ie.installmentInfo=void 0),ie.cardData.cardNumber=Q(i,4).join(" "))}},this.onCardHolderNameChange=function(e){ie.cardData&&(ie.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ie.cardData&&(!(e.length>ie.cardData.expirationDate.length)||z(e))){if(0===(null===(t=ie.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(ie.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(ie.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(ie.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ie.cardData.expirationDate=Q(d,2).join(" / "))}},this.onCvcChange=function(e){ie.cardData&&(e.length>ie.cardData.cvv.length&&!z(e)||e.length>4||(ie.cardData.cvv=e))},this.saveAddress=function(s){return e(ie,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 k(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(){ie.router.push("/cart")},this.onBackToShoppingClick=function(){ie.router.push("/")},this.onGoToLoginClick=function(){ie.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(ie,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(Z.SHIPPING):this.changeStep(Z.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(ie,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(Z.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:Y.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ie.canPerformPayment||(ie.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(ie,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:Y.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(ie,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:Y.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(ie,void 0,void 0,(function(){var e,i,s,n,r,o,d,u,l,p,m,f,g,v,y,S;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===(l=this.cardData)||void 0===l?void 0:l.installmentCount)?[2]:[4,j.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:B("_fbp"),_fbc:B("_fbc")}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,j.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&&[h.SUCCESS,h.AUTHORIZED].includes(r),d=r===h.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess((null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.orderId)||void 0)];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(S=null==s?void 0:s.data)||void 0===S?void 0:S.returnSlug))throw{data:s.firstErrorMessage,type:Y.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(i){return e(ie,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(Z.SUCCESS,i),[2]}}))}))},this.onBackToInfoClick=function(){ie.changeStep(Z.INFO)},this.onBackToShippingClick=function(){ie.changeStep(Z.SHIPPING)},this.setCustomerConsentGranted=function(e){ie.checkout.customer&&(ie.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){ie.useDifferentAddress=e,ie.useDifferentAddress?(localStorage.setItem("sAddr","1"),ie.checkout.billingAddress=ie.checkout.billingAddress||new F,ie.checkout.billingAddress.countrySettings=ie.countrySettings):(localStorage.removeItem("sAddr"),ie.checkout.billingAddress=ie.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){ie.shouldSaveAddress=e},this.setAddressTitle=function(e){ie.addressTitle=e},this.reInitPaymentMethod=function(){return e(ie,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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,j.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(ie,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!==Z.SUCCESS&&(e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&(this.cardData=new N,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){ie.cardData&&(ie.cardData.installmentCount=e)},this.changeStep=function(i,s){return e(ie,void 0,void 0,(function(){return t(this,(function(e){return q||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(ie,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){ie.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return e(ie,void 0,void 0,(function(){var e,r,o,a,c,d,u,l;return t(this,(function(h){switch(h.label){case 0:if(!(null==n?void 0:n.length))return[2];e=n.filter((function(e){var t;return e.status===p.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),r=function(e){var s,n,r,o,a,c;return t(this,(function(t){switch(t.label){case 0:return(null==e?void 0:e.campaignOffer)&&(s=e.campaignOffer.offers.find((function(t){return t.id===e.campaignOfferProductId})))?(n=[s.productId],[4,L.searchProducts({input:{productIdList:n,priceListId:M.getPriceListId(),salesChannelId:M.getSalesChannelId()}})]):[2,{value:void 0}];case 1:return(r=t.sent()).isSuccess&&(null===(l=null===(u=r.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.length)&&(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(s.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(e){return s.discountAmount?new A(i(i({},e),{prices:e.prices.map((function(e){var t=e.finalPrice,n=e.finalPrice-e.finalPrice*s.discountAmount/100;return s.applicablePrice===v.SELL_PRICE&&(t=e.sellPrice,n=e.sellPrice-e.sellPrice*s.discountAmount/100),new I(i(i({},e),{sellPrice:t,discountPrice:n}))}))})):e}))).length)?(c=a.find((function(e){return e.isActive})),[2,{value:{product:new w(i(i({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:s,campaignOffer:e}}]):[2]}}))},o=0,a=e,h.label=1;case 1:return o<a.length?(c=a[o],[5,r(c)]):[3,4];case 2:if("object"==typeof(d=h.sent()))return[2,d.value];h.label=3;case 3:return o++,[3,1];case 4:return[2,void 0]}}))}))},this.createCampaignOffer=function(){return e(ie,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===Z.SUCCESS?m.POST_CHECKOUT:m.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(ie,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return i.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,R.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent()).isSuccess?i.accepted?(this.changeStep(this.step===Z.SUCCESS?Z.PAYMENT:this.step,null===(s=e.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=e.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:t.sent(),this.isCampaignOfferLoaded=!0,t.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(i){return e(ie,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,O.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return e(ie,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return(e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==f.REFUNDED})).map((function(e){return e.variant.fileId}))).length?[4,j.listProductFile({id:{in:e}})]:[3,2];case 1:(i=t.sent()).isSuccess&&(this.productFiles=i.data||[]),t.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(i){return e(ie,void 0,void 0,(function(){var e,s,n,r,o;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),(e=this.checkout.orderLineItems.find((function(e){return e.variant.id===i.variantId})))?[4,j.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:e.id})]:[3,2];case 1:s=t.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(i.name),r.click(),r.remove()),t.label=2;case 2:return[3,4];case 3:return o=t.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=u,this.checkoutSettings=b,this.router=C,this.returnPolicy=H,this.privacyPolicy=W,this.termsOfService=X,this.imprint=$,this.shippingPolicy=J,this.t=ee,this.customizationProps=te,this.mpVM=new D,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new E({currentLocale:M.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(H.prototype,"merchantSettings",{get:function(){return new C(M.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.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(H.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=G.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(H.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(H.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"finalPrice",{get:function(){return this.step===Z.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===Y.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(H.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)!==Y.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"store",{get:function(){return G.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===o.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible},enumerable:!1,configurable:!0}),Object.defineProperty(H.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(H.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===d.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(H.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 b(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===u.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===u.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isEPayKolayEnabled",{get:function(){var e=M.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"isPoweredByHidden",{get:function(){var e=M.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),H.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},H}();function Q(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function z(e){return e&&H.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(Z||(Z={})),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"}(Y||(Y={}));export{Z as CheckoutStep,Y as ErrorType,W 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 i from"next/head.js";import{useRouter as a}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 r}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/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 s}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 d}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var l=o((function(o){var d,l,p,u=o.pageType,g=o.pageTitle,v=o.pageDescription,f=o.canonicals,h=o.disableIndex,j=o.pageSpecificData,x=o.merchantSettings,y=o.addOgpMetas,b=o.productReviewSummary,C=a(),k="undefined"!=typeof window,T="local"===process.env.NEXT_PUBLIC_ENV,E=C.asPath.split("?")[0].replace("/",""),w=(E="/"===E.charAt(E.length-1)?E.slice(0,-1):E).startsWith("pages/"),D=s.getCurrentRouting(),L=(null==D?void 0:D.path)?"/"+D.path:"",P=T?"http://localhost:3333":"https://"+s.getDomain(),R=null===(d=s.getIndexPageSeoSettings())||void 0===d?void 0:d.find((function(e){return e.locale===s.getCurrentLocale()})),_=R?new n(R):null;t.useEffect((function(){document.documentElement.lang=s.getCurrentLocale()}),[u,j]);var S=t.useMemo((function(){if(j&&j.href)return"".concat(P).concat(j.href)}),[j]),O=t.useMemo((function(){var e,t,o=[];if(y){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+s.getDomain()}),g&&o.push({property:"og:title",content:g}),v&&o.push({property:"og:description",content:v}),u===r.INDEX){var i=null,a=null;!g&&(null==_?void 0:_.pageTitle)&&(i=_.pageTitle),!v&&(null==_?void 0:_.description)&&(a=_.description);var n=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));n&&(i=c(j,u,n.titleTemplate||""),a=c(j,u,n.descriptionTemplate||"")),i&&o.push({property:"og:title",content:i}),a&&o.push({property:"og:description",content:a})}if(o.push({property:"og:url",content:S||(k?window.location.href:"")||"https://".concat(s.getDomain())}),j&&u===r.PRODUCT){var d=j.selectedVariant.mainImage;(null==d?void 0:d.image)&&o.push({property:"og:image",content:d.image.src})}else(null==_?void 0:_.icon)?o.push({property:"og:image",content:null===(t=null==_?void 0:_.icon)||void 0===t?void 0:t.src}):(null==x?void 0:x.logo)&&o.push({property:"og:image",content:x.logo.src});if(j&&u===r.CATEGORY){var l=j;l.image&&o.push({property:"og:image",content:l.image.src})}if(j&&u===r.BRAND){var m=j;m.image&&o.push({property:"og:image",content:m.image.src})}}return o}),[g,j,S,v,x,y,x]),I=t.useMemo((function(){var t=[];if(x){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+s.getDomain()},i=function(t){var o,i,a,r,n,d,l=(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:l,image:l,url:"https://"+s.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===(a=null===(i=t.address)||void 0===i?void 0:i.city)||void 0===a?void 0:a.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(d=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===d?void 0:d.code})}}(x);t.push(o),t.push(i)}if(j&&u===r.PRODUCT){var a=j,n=function(t,o){var i,a,r,n,d;try{var l="https://".concat(s.getDomain()).concat(t.href),m=t.selectedVariant;return e(e({"@context":"https://schema.org/","@type":"Product",name:t.name,description:null===(i=t.metaData)||void 0===i?void 0:i.description,image:null===(a=m.images)||void 0===a?void 0:a.map((function(e){return e.image?e.image.src:""})),productId:m.id,sku:m.sku,mpn:(null===(r=m.barcodeList)||void 0===r?void 0:r.length)?m.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:l,priceCurrency:m.price.currency||"TRY",price:(null!==(d=m.campaignPrice)&&void 0!==d?d: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){}}(a,b||null);if(n&&t.push(n),a.categories.length)(l=m(a.categories[0],a))&&t.push(l)}if(j&&u===r.CATEGORY){var d=function(e){var t,o;try{return{"@context":"http://schema.org","@type":"CollectionPage",url:"https://".concat(s.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){}}(j),l=m(j);d&&t.push(d),l&&t.push(l)}if(j&&u===r.BLOG){var c=function(t){var o;try{var i="https://".concat(s.getDomain()).concat(t.href),a=function(e){var t=new Date(e),o=t.getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(i,"-").concat(a)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(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:i,datePublished:a(t.createdAt),dateCreated:a(t.createdAt),dateModified:a(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(j);c&&t.push(c)}return t}),[j,x]),A=t.useMemo((function(){var e,t=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));return t?c(j,u,t.titleTemplate||""):null}),[u,j]),M=t.useMemo((function(){var e,t=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));return t?c(j,u,t.descriptionTemplate||""):null}),[u,j]),N=t.useMemo((function(){var e,t=null===(e=s.getFavicon())||void 0===e?void 0:e.id;return(null==_?void 0:_.favIcon)&&(t=_.favIcon),t||null}),[]),B=t.useCallback((function(){var e=s.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),U=[];s.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){U.push({routing:e,hrefLang:e.locale+"-"+t})})):U.push({routing:e,hrefLang:e.locale})}));var V=function(e){var t,o,i=j,a=null===(o=null===(t=null==i?void 0:i.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));return a?a.slug:""};return t.createElement(i,null,t.createElement("title",null,g||A||(null==_?void 0:_.pageTitle)||""),t.createElement("meta",{name:"description",content:v||M||(null==_?void 0:_.description)||""}),u===r.CHECKOUT&&B()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(l=s.getApiUrl())||void 0===l?void 0:l.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(p=s.getApiUrl())||void 0===p?void 0:p.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),U.length>1&&U.filter((function(e){return!w||e.routing.id===(null==D?void 0:D.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(P+(e.routing.path?"/"+e.routing.path:""),"/").concat(V(e.routing))})})),!!h&&t.createElement("meta",{name:"robots",content:"noindex"}),!!y&&O.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!f&&f.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(P).concat(L).concat(e)})})),N&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(N,"/image_180.webp"),type:"image/webp"}),t.createElement("link",{rel:"canonical",href:"".concat(P).concat(L,"/").concat(E)}),!!I.length&&I.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function m(e,t){try{var o=d.getInstance(),i=s.getCurrentRouting(),a=null==i?void 0:i.path,n=function(e){return a?"https://".concat(s.getDomain(),"/").concat(a).concat(e):"https://".concat(s.getDomain()).concat(e)},l=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return l.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&l.push({"@type":"ListItem",position:l.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:l}}catch(e){}}function c(e,t,o){var i,a,n,s=o;try{switch(t){case r.PRODUCT:var d=e,l=d.name,m=(null===(i=d.brand)||void 0===i?void 0:i.name)||"",c=d.selectedVariant.sku||"",u=(null===(a=d.selectedVariant.barcodeList)||void 0===a?void 0:a.length)?d.selectedVariant.barcodeList[0]:"",g=null!==(n=d.selectedVariant.formattedCampaignPrice)&&void 0!==n?n:d.selectedVariant.formattedFinalPrice;s.includes("{{name}}")&&(s=p(s,"{{name}}",l)),s.includes("{{brand}}")&&(s=p(s,"{{brand}}",m)),s.includes("{{sku}}")&&(s=p(s,"{{sku}}",c)),s.includes("{{barcode}}")&&(s=p(s,"{{barcode}}",u)),s.includes("{{price}}")&&(s=p(s,"{{price}}",g.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var v=e.name||"";s.includes("{{name}}")&&(s=p(s,"{{name}}",v));break;case r.BLOG:var f=e.title;s.includes("{{name}}")&&(s=p(s,"{{name}}",f))}}catch(e){}return s.trimEnd()}function p(e,t,o){var i=new RegExp(t,"g");return e.replace(i,o)}export{l 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 i}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 r}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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import{IkasIndexPageSeoSetting as n}from"../../models/data/storefront/index-page-seo-setting/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 s}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 d}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";var c=o((function(o){var d,c,p,u=o.pageType,g=o.pageTitle,v=o.pageDescription,f=o.canonicals,h=o.disableIndex,j=o.pageSpecificData,x=o.merchantSettings,y=o.addOgpMetas,b=o.productReviewSummary,C=i(),k="undefined"!=typeof window,T="local"===process.env.NEXT_PUBLIC_ENV,D=C.asPath.split("?")[0].replace("/",""),E=(D="/"===D.charAt(D.length-1)?D.slice(0,-1):D).startsWith("pages/"),w=s.getCurrentRouting(),L=(null==w?void 0:w.path)?"/"+w.path:"",P=T?"http://localhost:3333":"https://"+s.getDomain(),R=null===(d=s.getIndexPageSeoSettings())||void 0===d?void 0:d.find((function(e){return e.locale===s.getCurrentLocale()})),_=R?new n(R):null;t.useEffect((function(){document.documentElement.lang=s.getCurrentLocale()}),[u,j]);var S=t.useMemo((function(){if(j&&j.href)return"".concat(P).concat(j.href)}),[j]),O=t.useMemo((function(){var e,t,o=[];if(y){if(o.push({property:"og:type",content:"website"}),o.push({property:"og:site_name",content:"https://"+s.getDomain()}),g&&o.push({property:"og:title",content:g}),v&&o.push({property:"og:description",content:v}),u===r.INDEX){var a=null,i=null;!g&&(null==_?void 0:_.pageTitle)&&(a=_.pageTitle),!v&&(null==_?void 0:_.description)&&(i=_.description);var n=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));n&&(a=m(j,u,n.titleTemplate||""),i=m(j,u,n.descriptionTemplate||"")),a&&o.push({property:"og:title",content:a}),i&&o.push({property:"og:description",content:i})}if(o.push({property:"og:url",content:S||(k?window.location.href:"")||"https://".concat(s.getDomain())}),j&&u===r.PRODUCT){var d=j.selectedVariant.mainImage;(null==d?void 0:d.image)&&o.push({property:"og:image",content:d.image.src})}else(null==_?void 0:_.icon)?o.push({property:"og:image",content:null===(t=null==_?void 0:_.icon)||void 0===t?void 0:t.src}):(null==x?void 0:x.logo)&&o.push({property:"og:image",content:x.logo.src});if(j&&u===r.CATEGORY){var c=j;c.image&&o.push({property:"og:image",content:c.image.src})}if(j&&u===r.BRAND){var l=j;l.image&&o.push({property:"og:image",content:l.image.src})}}return o}),[g,j,S,v,x,y,x]),I=t.useMemo((function(){var t=[];if(x){var o={"@context":"https://schema.org","@type":"Website",url:"https://"+s.getDomain()},a=function(t){var o,a,i,r,n,d,c=(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:c,image:c,url:"https://"+s.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===(i=null===(a=t.address)||void 0===a?void 0:a.city)||void 0===i?void 0:i.name},t.address&&t.address.state&&{addressRegion:t.address.state.code}),{postalCode:null===(r=t.address)||void 0===r?void 0:r.postalCode,addressCountry:null===(d=null===(n=t.address)||void 0===n?void 0:n.country)||void 0===d?void 0:d.code})}}(x);t.push(o),t.push(a)}if(j&&u===r.PRODUCT){var i=j,n=function(t,o){var a,i,r,n,d;try{var c="https://".concat(s.getDomain()).concat(t.href),l=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===(i=l.images)||void 0===i?void 0:i.map((function(e){return e.image?e.image.src:""})),productId:l.id,sku:l.sku,mpn:(null===(r=l.barcodeList)||void 0===r?void 0:r.length)?l.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(n=t.brand)||void 0===n?void 0:n.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:c,priceCurrency:l.price.currency||"TRY",price:(null!==(d=l.campaignPrice)&&void 0!==d?d:l.price.finalPrice).toFixed(2),priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:l.stock>0?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(e){}}(i,b||null);if(n&&t.push(n),i.categories.length)(c=l(i.categories[0],i))&&t.push(c)}if(j&&u===r.CATEGORY){var d=function(e){var t,o;try{var a=s.getCurrentRouting(),i=null==a?void 0:a.path,r=function(e){return i?"https://".concat(s.getDomain(),"/").concat(i).concat(e):"https://".concat(s.getDomain()).concat(e)};return{"@context":"http://schema.org","@type":"CollectionPage",url:r(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){}}(j),c=l(j);d&&t.push(d),c&&t.push(c)}if(j&&u===r.BLOG){var m=function(t){var o;try{var a="https://".concat(s.getDomain()).concat(t.href),i=function(e){var t=new Date(e),o=t.getFullYear(),a=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0");return"".concat(o,"-").concat(a,"-").concat(i)},r="".concat(t.writer.firstName," ").concat(t.writer.lastName),n=(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:i(t.createdAt),dateCreated:i(t.createdAt),dateModified:i(t.updatedAt),description:t.shortDescription,articleBody:n,author:{"@type":"Person",name:r}})}catch(e){}}(j);m&&t.push(m)}return t}),[j,x]),A=t.useMemo((function(){var e,t=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));return t?m(j,u,t.titleTemplate||""):null}),[u,j]),M=t.useMemo((function(){var e,t=null===(e=s.getMetaTemplates())||void 0===e?void 0:e.find((function(e){return e.locale===s.getCurrentLocale()&&e.pageType===u}));return t?m(j,u,t.descriptionTemplate||""):null}),[u,j]),N=t.useMemo((function(){var e,t=null===(e=s.getFavicon())||void 0===e?void 0:e.id;return(null==_?void 0:_.favIcon)&&(t=_.favIcon),t||null}),[]),B=t.useCallback((function(){var e=s.getCustom();return!!e&&!!e.isEPayKolayEnabled}),[]),U=[];s.getRoutings().forEach((function(e){var t;(null===(t=e.countryCodes)||void 0===t?void 0:t.length)?e.countryCodes.forEach((function(t){U.push({routing:e,hrefLang:e.locale+"-"+t})})):U.push({routing:e,hrefLang:e.locale})}));var V=function(e){var t,o,a=j,i=null===(o=null===(t=null==a?void 0:a.metaData)||void 0===t?void 0:t.translations)||void 0===o?void 0:o.find((function(t){return t.locale===e.locale}));return i?i.slug:""};return t.createElement(a,null,t.createElement("title",null,g||A||(null==_?void 0:_.pageTitle)||""),t.createElement("meta",{name:"description",content:v||M||(null==_?void 0:_.description)||""}),u===r.CHECKOUT&&B()&&t.createElement("script",{type:"text/javascript",src:"https://cdn-epeykolay.mncdn.com/".concat((null===(c=s.getApiUrl())||void 0===c?void 0:c.includes("myikas.com"))?"epay":"epay-uat","/").concat((null===(p=s.getApiUrl())||void 0===p?void 0:p.includes("myikas.com"))?"containerServices":"containerServicesTest",".js")}),U.length>1&&U.filter((function(e){return!E||e.routing.id===(null==w?void 0:w.id)})).map((function(e){return t.createElement("link",{key:e.routing.id+e.hrefLang,rel:"alternate",hrefLang:e.hrefLang,href:"".concat(P+(e.routing.path?"/"+e.routing.path:""),"/").concat(V(e.routing))})})),!!h&&t.createElement("meta",{name:"robots",content:"noindex"}),!!y&&O.map((function(e,o){return t.createElement("meta",{key:"".concat(e.content,"-").concat(o),property:e.property,content:e.content})})),!!f&&f.map((function(e,o){return t.createElement("link",{key:o+"url",rel:"canonical",href:"".concat(P).concat(L).concat(e)})})),N&&t.createElement("link",{rel:"shortcut icon",href:"".concat(process.env.NEXT_PUBLIC_CDN_URL,"images/").concat(N,"/image_180.webp"),type:"image/webp"}),t.createElement("link",{rel:"canonical",href:"".concat(P).concat(L,"/").concat(D)}),!!I.length&&I.map((function(e,o){return t.createElement("script",{key:o,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})})))}));function l(e,t){try{var o=d.getInstance(),a=s.getCurrentRouting(),i=null==a?void 0:a.path,n=function(e){return i?"https://".concat(s.getDomain(),"/").concat(i).concat(e):"https://".concat(s.getDomain()).concat(e)},c=e.categoryPathItems.map((function(e,t){return{"@type":"ListItem",position:t+1,name:e.name,item:n(e.href)}}));return c.push({"@type":"ListItem",position:e.categoryPathItems.length+1,name:e.name,item:n(e.href)}),o.currentPageType===r.PRODUCT&&t&&c.push({"@type":"ListItem",position:c.length+1,name:t.name,item:n(t.productHref)}),{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:c}}catch(e){}}function m(e,t,o){var a,i,n,s=o;try{switch(t){case r.PRODUCT:var d=e,c=d.name,l=(null===(a=d.brand)||void 0===a?void 0:a.name)||"",m=d.selectedVariant.sku||"",u=(null===(i=d.selectedVariant.barcodeList)||void 0===i?void 0:i.length)?d.selectedVariant.barcodeList[0]:"",g=null!==(n=d.selectedVariant.formattedCampaignPrice)&&void 0!==n?n:d.selectedVariant.formattedFinalPrice;s.includes("{{name}}")&&(s=p(s,"{{name}}",c)),s.includes("{{brand}}")&&(s=p(s,"{{brand}}",l)),s.includes("{{sku}}")&&(s=p(s,"{{sku}}",m)),s.includes("{{barcode}}")&&(s=p(s,"{{barcode}}",u)),s.includes("{{price}}")&&(s=p(s,"{{price}}",g.toString()));break;case r.BRAND:case r.CATEGORY:case r.BLOG_CATEGORY:var v=e.name||"";s.includes("{{name}}")&&(s=p(s,"{{name}}",v));break;case r.BLOG:var f=e.title;s.includes("{{name}}")&&(s=p(s,"{{name}}",f))}}catch(e){}return s.trimEnd()}function p(e,t,o){var a=new RegExp(t,"g");return e.replace(a,o)}export{c as IkasPageHead};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as s,IkasCampaignType as l,IkasCustomerPriceListRuleFilterType as a}from"@ikas/storefront-models";import{IkasProductVariantFunctions as d,IkasProductPriceFunctions as p}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{saveProductBackInStockRemind as m,listProductBackInStockRemind as b}from"@ikas/storefront-api";import v from"lodash/groupBy";import h from"lodash/sortBy";import{IkasProductVariantUnit as g}from"./unit/index.js";import{formatCurrency as P}from"../../../../utils/currency.js";import{makeAutoObservable as y}from"mobx";import{IkasBaseStore as I}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var S=function(){function S(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new g(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=h(this.images,"order"),y(this)}return Object.defineProperty(S.prototype,"mainImage",{get:function(){var e=d.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasStock",{get:function(){return d.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockEnabled",{get:function(){return f.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return f.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"groupedAttributeValues",{get:function(){var e,t=v(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=I.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===a.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===a.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===a.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===a.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var s=c[u];if(s.shouldMatchAllFilters?null===(e=s.filters)||void 0===e?void 0:e.every(o):null===(t=s.filters)||void 0===t?void 0:t.some(o))return s}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"price",{get:function(){var e,t;if(f.isB2BStorefront()){var i=I.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"bundlePrice",{get:function(){var e,t;if(f.isB2BStorefront()){var i=I.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings?e=p.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=p.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case s.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case s.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case s.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPrice",{get:function(){return P(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPrice",{get:function(){return this.bundleSettings?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedSellPrice",{get:function(){return P(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedBuyPrice",{get:function(){return P(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u,c=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var s=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=c.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!s)return null;var a={type:s.type,formattedPrice:null,discountPercentage:null};return s.type===l.FIXED_AMOUNT&&(a.formattedPrice=P((null===(n=s.fixedDiscount)||void 0===n?void 0:n.amount)||0,this.price.currency||"",this.price.currencySymbol||"")),s.type===l.RATIO&&(a.discountPercentage=(null===(u=null===(o=s.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===u?void 0:u.toString())||null),a},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedCampaignPrice",{get:function(){return P(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedDiscountPrice",{get:function(){return P(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return P(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return P(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),S.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,b({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,m({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},S.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},S}();export{S as IkasProductVariant};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as s,IkasCampaignType as l,IkasCustomerPriceListRuleFilterType as a}from"@ikas/storefront-models";import{IkasProductVariantFunctions as d,IkasProductPriceFunctions as p}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{saveProductBackInStockRemind as b,listProductBackInStockRemind as m}from"@ikas/storefront-api";import v from"lodash/groupBy";import h from"lodash/sortBy";import{IkasProductVariantUnit as g}from"./unit/index.js";import{formatCurrency as y}from"../../../../utils/currency.js";import{makeAutoObservable as P}from"mobx";import{IkasBaseStore as S}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var I=function(){function I(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new g(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=h(this.images,"order"),P(this)}return Object.defineProperty(I.prototype,"mainImage",{get:function(){var e=d.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasStock",{get:function(){return d.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isBackInStockEnabled",{get:function(){return f.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return f.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"groupedAttributeValues",{get:function(){var e,t=v(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=S.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===a.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===a.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===a.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===a.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var s=c[u];if(s.shouldMatchAllFilters?null===(e=s.filters)||void 0===e?void 0:e.every(o):null===(t=s.filters)||void 0===t?void 0:t.some(o))return s}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"price",{get:function(){var e,t;if(f.isB2BStorefront()){var i=S.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"bundlePrice",{get:function(){var e,t;if(f.isB2BStorefront()){var i=S.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=p.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=p.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case s.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case s.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case s.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedFinalPrice",{get:function(){return y(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedSellPrice",{get:function(){return y(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedBuyPrice",{get:function(){return y(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u,c=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var s=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=c.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!s)return null;var a={type:s.type,formattedPrice:null,discountPercentage:null};return s.type===l.FIXED_AMOUNT&&(a.formattedPrice=y((null===(n=s.fixedDiscount)||void 0===n?void 0:n.amount)||0,this.price.currency||"",this.price.currencySymbol||"")),s.type===l.RATIO&&(a.discountPercentage=(null===(u=null===(o=s.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===u?void 0:u.toString())||null),a},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedCampaignPrice",{get:function(){return y(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedDiscountPrice",{get:function(){return y(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return y(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return y(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),I.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,m({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,b({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},I.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},I}();export{I as IkasProductVariant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from'./../ext/tslib/tslib.es6.js';import{renderComponent as e}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as a}from"../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{IkasBlog as r}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,IkasThemeJsonComponentPropType as s}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{IkasCategory as u}from"../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{IkasImage as d}from"../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/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as l}from"../models/data/product/index.js";import{IkasRaffle as p}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as m}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as c}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as f}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as g}from"../models/ui/brand-list/index.js";import{IkasCategoryList as P}from"../models/ui/category-list/index.js";import{IkasNavigationLink as V}from"../models/ui/navigation-link/index.js";import{IkasProductList as j}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as v}from"../models/ui/product-attribute-detail/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{IkasComponentRenderer as L}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as D}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as h,getPlaceholderBrand as x,getPlaceholderCategory as C,getPlaceholderProduct as T,getPlaceholderBlog as I,getPlaceholderBlogCategory as S,getPlaceholderRaffle as w}from"@ikas/storefront-providers";import b from"lodash/flatten";import{IkasBaseStore as y}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as _}from"@ikas/storefront-model-functions";var O=function(){function O(){}return O.setPageSpecificData=function(e,i,o){var s;if(this.isBrowser=o,e)switch(i){case n.PRODUCT:var d=e;O.pageSpecificData=new l(t(t({},d),{selectedVariantValues:d.selectedVariantValues||(null===(s=d.variants.find((function(t){return _.hasStock(t)})))||void 0===s?void 0:s.variantValues)||d.variants[0].variantValues})),o&&this._initProductOnBrowser(O.pageSpecificData);break;case n.CATEGORY:var m=e;O.pageSpecificData=new u(m);break;case n.BRAND:var c=e;O.pageSpecificData=new u(c);break;case n.BLOG:var f=e;O.pageSpecificData=new r(f);break;case n.BLOG_CATEGORY:var g=e;O.pageSpecificData=new a(g);break;case n.RAFFLE_DETAIL:var P=e;O.pageSpecificData=new p(P)}else this.pageSpecificData=void 0},O.isServer=function(){return"undefined"==typeof window},O.initPagePropValues=function(t,e,i,a,r){return this.flatCustomDataList=b(i.map((function(t){return t.flat}))),t.map((function(t){return O.initPageComponentPropValue(t,e,a,r)}))},O.initPageComponentPropValue=function(e,i,a,r){var o=i.find((function(t){return t.id===e.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(t){var i=e.propValues[t.name];s[t.name]=O.initPropValue(t,i,a,r)})),new h(t(t({},e),{pageComponent:new m(t(t({},e.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},O.initPropValue=function(t,e,i,a){if(null==e)return null;switch(t.type){case s.IMAGE:return O.initImagePropValue(e);case s.IMAGE_LIST:return O.initImageListPropValue(e);case s.BRAND:return O.initBrandPropValue(e);case s.BRAND_LIST:return O.initBrandListPropValue(e);case s.CATEGORY:return O.initCategoryPropValue(e);case s.CATEGORY_LIST:return O.initCategoryListPropValue(e);case s.PRODUCT_LIST:return O.initProductListPropValue(e);case s.PRODUCT_DETAIL:return O.initProductPropValue(e);case s.PRODUCT_ATTRIBUTE:return O.initAttributePropValue(e);case s.PRODUCT_ATTRIBUTE_LIST:return O.initAttributeListPropValue(e);case s.LINK:case s.LIST_OF_LINK:return O.initLinkPropValue(e);case s.COMPONENT:return O.initComponentPropValue(e,i,a);case s.COMPONENT_LIST:return O.initComponentListPropValue(e,i,a);case s.CUSTOM:return O.initCustomDataPropValue(e,i,a);case s.BLOG:return O.initBlogPropValue(e);case s.BLOG_LIST:return O.initBlogListPropValue(e);case s.BLOG_CATEGORY:return O.initBlogCategoryPropValue(e);case s.BLOG_LIST:return O.initBlogCategoryListPropValue(e);case s.RAFFLE:return O.initRafflePropValue(e);case s.RAFFLE_LIST:return O.initRaffleListPropValue(e);case s.SLIDER:return O.initSliderPropValue(e);case s.VIDEO:return O.initVideoPropValue(e);default:return e}},O.initBrandPropValue=function(t){return t.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.brand?new o(t.brand):x()},O.initBrandListPropValue=function(t){return new g(t)},O.initCategoryPropValue=function(t){return t.categoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.category?new u(t.category):C()},O.initCategoryListPropValue=function(t){return new P(t)},O.initProductListPropValue=function(t){return new j(t,y.getInstance().router)},O.initProductPropValue=function(e){var i=new l(T());if(e.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(e.productDetail){var a=e.productDetail;i=new l(t(t({},a),{selectedVariantValues:a.selectedVariantValues}))}return i},O._initProductOnBrowser=function(t){var e=new URLSearchParams(window.location.search),i=e.get("vid");if(i){var a=t.variants.find((function(t){return t.id===i}));a&&(t.selectedVariantValues=a.variantValues)}else{var r=t.variantTypes.map((function(t){return t.variantType.slug})),o=[];r.forEach((function(i,a){var r=t.variantTypes[a],n=e.get(i);if(n){var s=r.variantType.values.find((function(t){return t.slug===n}));s&&o.push(s)}})),o.length===t.selectedVariantValues.length&&(t.selectedVariantValues=o)}},O.initAttributePropValue=function(e){var i=null;if(e.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(e.productDetail){var a=e.productDetail;i=new l(t(t({},a),{selectedVariantValues:a.selectedVariantValues}))}return new v(i,e.attributePropValue)},O.initAttributeListPropValue=function(e){var a=null;if(e.attributeListPropValue.usePageData&&this.pageSpecificData)a=this.pageSpecificData;else if(e.productDetail){var r=e.productDetail;a=new l(t(t({},r),{selectedVariantValues:r.selectedVariantValues}))}return new i(a,e.attributeListPropValue)},O.initLinkPropValue=function(t){return Array.isArray(t)?t.map((function(t){return new V(t.href,t.label,t.subLinks,t.isExternal||void 0)})):t?new V(t.href,t.label,t.subLinks,t.isExternal||void 0):void 0},O.initImagePropValue=function(t){return new d(t)},O.initImageListPropValue=function(t){return t.map((function(t){return new d(t)}))},O.initCustomDataPropValue=function(t,e,i){if(t&&t.value&&t.customDataId){var a=this.flatCustomDataList.find((function(e){return e.id===t.customDataId}));if(a)return this._initCustomDataPropValue(t,a,e,i)}},O._initCustomDataPropValue=function(t,e,i,a){var r=this;if(!t)return null;var o=t.value;if(null==o)return null;switch(e.type){case s.BRAND:return this.initBrandPropValue(o);case s.BRAND_LIST:return this.initBrandListPropValue(o);case s.CATEGORY_LIST:return this.initCategoryListPropValue(o);case s.CATEGORY:return this.initCategoryPropValue(o);case s.IMAGE_LIST:return this.initImageListPropValue(o);case s.IMAGE:return this.initImagePropValue(o);case s.LINK:return this.initLinkPropValue(o);case s.PRODUCT_DETAIL:return this.initProductPropValue(o);case s.PRODUCT_LIST:return this.initProductListPropValue(o);case s.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case s.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case s.BLOG:return this.initBlogPropValue(o);case s.BLOG_LIST:return this.initBlogListPropValue(o);case s.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case s.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case s.RAFFLE:return this.initRafflePropValue(o);case s.RAFFLE_LIST:return this.initRaffleListPropValue(o);case s.SLIDER:return this.initSliderPropValue(o);case s.VIDEO:return O.initVideoPropValue(o);case s.OBJECT:for(var n={},u=function(t){var e=o[t.key],r=void 0;t.customDataId&&(r=d.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),n[t.key]=d._initCustomDataPropValue(e,r||t,i,a)},d=this,l=0,p=e.nestedData||[];l<p.length;l++){u(p[l])}return n;case s.DYNAMIC_LIST:case s.STATIC_LIST:try{if(!o||!o.length)return null;var m=[],c=e.nestedData[0];return o.forEach((function(t){var e;c.customDataId&&(e=r.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),m.push(r._initCustomDataPropValue(t,e||c,i,a))})),m}catch(t){return[]}case s.COMPONENT:return this.initComponentPropValue(o,i,a);case s.COMPONENT_LIST:return this.initComponentListPropValue(o,i,a);default:return o}},O.initComponentPropValue=function(t,e,i){return this._initComponentPropValue(t,e,i)},O._initComponentPropValue=function(t,i,a){var r=t.length?t[0]:void 0;if(r){var o=new h(r),n=O.initPageComponentPropValue(o,[o.component],i,a);if(n)return new L((function(){return e(n,i,-10)}))}},O.initComponentListPropValue=function(t,e,i){return this._initComponentListPropValue(t,e,i)},O._initComponentListPropValue=function(t,i,a){return t&&t.length?t.map((function(t){var r=new h(t),o=O.initPageComponentPropValue(r,[r.component],i,a);return new L((function(){return e(o,i,-1)}))})):[]},O.initBlogPropValue=function(t){return t.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.blog?new r(t.blog):I()},O.initBlogListPropValue=function(t){return new c(t)},O.initBlogCategoryPropValue=function(t){return t.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.blogCategory?new a(t.blogCategory):S()},O.initBlogCategoryListPropValue=function(t){return new f(t)},O.initRafflePropValue=function(t){return t.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.raffle?new p(t.raffle):new p(w())},O.initRaffleListPropValue=function(t){return new D(t)},O.initSliderPropValue=function(t){return t},O.initVideoPropValue=function(e){return t(t({},e),{thumbnailImage:e.thumbnailImage?new d(e.thumbnailImage):null})},O.pageSpecificData={},O.flatCustomDataList=[],O.isBrowser=!1,O}();export{O as IkasPageDataInit};
|
|
1
|
+
import{__assign as t}from'./../ext/tslib/tslib.es6.js';import{renderComponent as e}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as a}from"../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{IkasBlog as r}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,initIkasCategory as s,IkasThemeJsonComponentPropType as u}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{IkasCategory as d}from"../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{IkasImage as l}from"../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/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as p}from"../models/data/product/index.js";import{IkasRaffle as m}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as c}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as f}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as g}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as P}from"../models/ui/brand-list/index.js";import{IkasCategoryList as V}from"../models/ui/category-list/index.js";import{IkasNavigationLink as j}from"../models/ui/navigation-link/index.js";import{IkasProductList as v}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as L}from"../models/ui/product-attribute-detail/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{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as h}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as x,getPlaceholderBrand as C,getPlaceholderCategory as T,getPlaceholderProduct as I,getPlaceholderBlog as S,getPlaceholderBlogCategory as w,getPlaceholderRaffle as b}from"@ikas/storefront-providers";import y from"lodash/flatten";import{IkasBaseStore as _}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as O}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as B}from"@ikas/storefront-config";var R=function(){function R(){}return R.setPageSpecificData=function(e,i,u){var l;if(this.isBrowser=u,e)switch(i){case n.PRODUCT:var c=e;R.pageSpecificData=new p(t(t({},c),{selectedVariantValues:c.selectedVariantValues||(null===(l=c.variants.find((function(t){return O.hasStock(t)})))||void 0===l?void 0:l.variantValues)||c.variants[0].variantValues})),u&&this._initProductOnBrowser(R.pageSpecificData);break;case n.CATEGORY:var f=e;s(f,B.getCurrentLocale()),R.pageSpecificData=new d(f);break;case n.BRAND:var g=e;R.pageSpecificData=new o(g);break;case n.BLOG:var P=e;R.pageSpecificData=new r(P);break;case n.BLOG_CATEGORY:var V=e;R.pageSpecificData=new a(V);break;case n.RAFFLE_DETAIL:var j=e;R.pageSpecificData=new m(j)}else this.pageSpecificData=void 0},R.isServer=function(){return"undefined"==typeof window},R.initPagePropValues=function(t,e,i,a,r){return this.flatCustomDataList=y(i.map((function(t){return t.flat}))),t.map((function(t){return R.initPageComponentPropValue(t,e,a,r)}))},R.initPageComponentPropValue=function(e,i,a,r){var o=i.find((function(t){return t.id===e.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(t){var i=e.propValues[t.name];s[t.name]=R.initPropValue(t,i,a,r)})),new x(t(t({},e),{pageComponent:new c(t(t({},e.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},R.initPropValue=function(t,e,i,a){if(null==e)return null;switch(t.type){case u.IMAGE:return R.initImagePropValue(e);case u.IMAGE_LIST:return R.initImageListPropValue(e);case u.BRAND:return R.initBrandPropValue(e);case u.BRAND_LIST:return R.initBrandListPropValue(e);case u.CATEGORY:return R.initCategoryPropValue(e);case u.CATEGORY_LIST:return R.initCategoryListPropValue(e);case u.PRODUCT_LIST:return R.initProductListPropValue(e);case u.PRODUCT_DETAIL:return R.initProductPropValue(e);case u.PRODUCT_ATTRIBUTE:return R.initAttributePropValue(e);case u.PRODUCT_ATTRIBUTE_LIST:return R.initAttributeListPropValue(e);case u.LINK:case u.LIST_OF_LINK:return R.initLinkPropValue(e);case u.COMPONENT:return R.initComponentPropValue(e,i,a);case u.COMPONENT_LIST:return R.initComponentListPropValue(e,i,a);case u.CUSTOM:return R.initCustomDataPropValue(e,i,a);case u.BLOG:return R.initBlogPropValue(e);case u.BLOG_LIST:return R.initBlogListPropValue(e);case u.BLOG_CATEGORY:return R.initBlogCategoryPropValue(e);case u.BLOG_LIST:return R.initBlogCategoryListPropValue(e);case u.RAFFLE:return R.initRafflePropValue(e);case u.RAFFLE_LIST:return R.initRaffleListPropValue(e);case u.SLIDER:return R.initSliderPropValue(e);case u.VIDEO:return R.initVideoPropValue(e);default:return e}},R.initBrandPropValue=function(t){return t.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.brand?new o(t.brand):C()},R.initBrandListPropValue=function(t){return new P(t)},R.initCategoryPropValue=function(t){return t.categoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.category?new d(t.category):T()},R.initCategoryListPropValue=function(t){return new V(t)},R.initProductListPropValue=function(t){return new v(t,_.getInstance().router)},R.initProductPropValue=function(e){var i=new p(I());if(e.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(e.productDetail){var a=e.productDetail;i=new p(t(t({},a),{selectedVariantValues:a.selectedVariantValues}))}return i},R._initProductOnBrowser=function(t){var e=new URLSearchParams(window.location.search),i=e.get("vid");if(i){var a=t.variants.find((function(t){return t.id===i}));a&&(t.selectedVariantValues=a.variantValues)}else{var r=t.variantTypes.map((function(t){return t.variantType.slug})),o=[];r.forEach((function(i,a){var r=t.variantTypes[a],n=e.get(i);if(n){var s=r.variantType.values.find((function(t){return t.slug===n}));s&&o.push(s)}})),o.length===t.selectedVariantValues.length&&(t.selectedVariantValues=o)}},R.initAttributePropValue=function(e){var i=null;if(e.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(e.productDetail){var a=e.productDetail;i=new p(t(t({},a),{selectedVariantValues:a.selectedVariantValues}))}return new L(i,e.attributePropValue)},R.initAttributeListPropValue=function(e){var a=null;if(e.attributeListPropValue.usePageData&&this.pageSpecificData)a=this.pageSpecificData;else if(e.productDetail){var r=e.productDetail;a=new p(t(t({},r),{selectedVariantValues:r.selectedVariantValues}))}return new i(a,e.attributeListPropValue)},R.initLinkPropValue=function(t){return Array.isArray(t)?t.map((function(t){return new j(t.href,t.label,t.subLinks,t.isExternal||void 0)})):t?new j(t.href,t.label,t.subLinks,t.isExternal||void 0):void 0},R.initImagePropValue=function(t){return new l(t)},R.initImageListPropValue=function(t){return t.map((function(t){return new l(t)}))},R.initCustomDataPropValue=function(t,e,i){if(t&&t.value&&t.customDataId){var a=this.flatCustomDataList.find((function(e){return e.id===t.customDataId}));if(a)return this._initCustomDataPropValue(t,a,e,i)}},R._initCustomDataPropValue=function(t,e,i,a){var r=this;if(!t)return null;var o=t.value;if(null==o)return null;switch(e.type){case u.BRAND:return this.initBrandPropValue(o);case u.BRAND_LIST:return this.initBrandListPropValue(o);case u.CATEGORY_LIST:return this.initCategoryListPropValue(o);case u.CATEGORY:return this.initCategoryPropValue(o);case u.IMAGE_LIST:return this.initImageListPropValue(o);case u.IMAGE:return this.initImagePropValue(o);case u.LINK:return this.initLinkPropValue(o);case u.PRODUCT_DETAIL:return this.initProductPropValue(o);case u.PRODUCT_LIST:return this.initProductListPropValue(o);case u.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case u.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case u.BLOG:return this.initBlogPropValue(o);case u.BLOG_LIST:return this.initBlogListPropValue(o);case u.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case u.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case u.RAFFLE:return this.initRafflePropValue(o);case u.RAFFLE_LIST:return this.initRaffleListPropValue(o);case u.SLIDER:return this.initSliderPropValue(o);case u.VIDEO:return R.initVideoPropValue(o);case u.OBJECT:for(var n={},s=function(t){var e=o[t.key],r=void 0;t.customDataId&&(r=d.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),n[t.key]=d._initCustomDataPropValue(e,r||t,i,a)},d=this,l=0,p=e.nestedData||[];l<p.length;l++){s(p[l])}return n;case u.DYNAMIC_LIST:case u.STATIC_LIST:try{if(!o||!o.length)return null;var m=[],c=e.nestedData[0];return o.forEach((function(t){var e;c.customDataId&&(e=r.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),m.push(r._initCustomDataPropValue(t,e||c,i,a))})),m}catch(t){return[]}case u.COMPONENT:return this.initComponentPropValue(o,i,a);case u.COMPONENT_LIST:return this.initComponentListPropValue(o,i,a);default:return o}},R.initComponentPropValue=function(t,e,i){return this._initComponentPropValue(t,e,i)},R._initComponentPropValue=function(t,i,a){var r=t.length?t[0]:void 0;if(r){var o=new x(r),n=R.initPageComponentPropValue(o,[o.component],i,a);if(n)return new D((function(){return e(n,i,-10)}))}},R.initComponentListPropValue=function(t,e,i){return this._initComponentListPropValue(t,e,i)},R._initComponentListPropValue=function(t,i,a){return t&&t.length?t.map((function(t){var r=new x(t),o=R.initPageComponentPropValue(r,[r.component],i,a);return new D((function(){return e(o,i,-1)}))})):[]},R.initBlogPropValue=function(t){return t.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.blog?new r(t.blog):S()},R.initBlogListPropValue=function(t){return new f(t)},R.initBlogCategoryPropValue=function(t){return t.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.blogCategory?new a(t.blogCategory):w()},R.initBlogCategoryListPropValue=function(t){return new g(t)},R.initRafflePropValue=function(t){return t.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:t.raffle?new m(t.raffle):new m(b())},R.initRaffleListPropValue=function(t){return new h(t)},R.initSliderPropValue=function(t){return t},R.initVideoPropValue=function(e){return t(t({},e),{thumbnailImage:e.thumbnailImage?new l(e.thumbnailImage):null})},R.pageSpecificData={},R.flatCustomDataList=[],R.isBrowser=!1,R}();export{R as IkasPageDataInit};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.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.13.
|
|
21
|
-
"@ikas/storefront-config": "^4.13.
|
|
22
|
-
"@ikas/storefront-model-functions": "^4.13.
|
|
23
|
-
"@ikas/storefront-models": "^4.13.
|
|
24
|
-
"@ikas/storefront-providers": "^4.13.
|
|
20
|
+
"@ikas/storefront-api": "^4.13.2",
|
|
21
|
+
"@ikas/storefront-config": "^4.13.2",
|
|
22
|
+
"@ikas/storefront-model-functions": "^4.13.2",
|
|
23
|
+
"@ikas/storefront-models": "^4.13.2",
|
|
24
|
+
"@ikas/storefront-providers": "^4.13.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.13.
|
|
59
|
-
"@ikas/storefront-config": "^4.13.
|
|
60
|
-
"@ikas/storefront-model-functions": "^4.13.
|
|
61
|
-
"@ikas/storefront-models": "^4.13.
|
|
62
|
-
"@ikas/storefront-providers": "^4.13.
|
|
58
|
+
"@ikas/storefront-api": "^4.13.2",
|
|
59
|
+
"@ikas/storefront-config": "^4.13.2",
|
|
60
|
+
"@ikas/storefront-model-functions": "^4.13.2",
|
|
61
|
+
"@ikas/storefront-models": "^4.13.2",
|
|
62
|
+
"@ikas/storefront-providers": "^4.13.2",
|
|
63
63
|
"mobx": "^6.1.3",
|
|
64
64
|
"mobx-react-lite": "^3.1.5",
|
|
65
65
|
"next": "12.2.0",
|