@ikas/storefront 4.7.2 → 4.7.3
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}from'./../../../../ext/tslib/tslib.es6.js';import*as
|
|
1
|
+
import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import c from"../input-with-button/index.js";import r from"../notification-box/index.js";import{CheckoutStep as l}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as u}from"../../../../utils/currency.js";import{useTranslation as s}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import C from"../svg/arrow-down.js";import v from"../svg/cross.js";import h from"../svg/gift.js";import f from"./style.module.scss.js";import k from"../svg/ikas.js";var N;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS"}(N||(N={}));var g=o((function(e){var t,o,a=e.vm,c=e.allowExpand,d=a.checkout,p=s().t,E=n.useState(!c),v=E[0],h=E[1],g=n.useState(!1),x=g[0],_=g[1],P=n.useState(null),I=P[0],j=P[1],w=n.useState(0),A=w[0],R=w[1],D=n.useState(null),U=D[0],L=D[1],B=n.useState(!1),F=B[0],X=B[1],M=n.useState(!1),G=M[0],V=M[1];n.useEffect((function(){c&&(v?U&&R(U.getBoundingClientRect().height):R(0))}),[v,U,c,F,G,x]);var z=n.useMemo((function(){switch(I){case N.COUPON_CODE_NOT_EXIST:return p("checkout-page:giftCodeErrorDescription");case N.COUPON_CODE_NOT_EXIST_FOR_GUESS:return p("checkout-page:mustBeSignInToApplyCampaign");default:return""}}),[I]),H=[f.CartSummary,c?f.HideOnDesktop:""].join(" "),$=c?{height:A+"px"}:void 0,Q=[f.ArrowDown,v?f.Rotated:""].join(" ");return d?n.createElement(n.Fragment,null,!!c&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:f.ExpandHeader,onClick:function(){if(!v){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}h(!v)}},n.createElement("div",{className:f.Left},p("checkout-page:summary")),n.createElement("div",{className:f.Price},n.createElement("span",{className:f.PriceText},"".concat(u(a.finalPrice||0,d.currencyCode,d.currencySymbol)," (").concat(d.itemQuantity," ").concat(p("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:Q},n.createElement(C,null))))),n.createElement("div",{className:H},n.createElement("div",{className:f.DetailsContainer,style:$},n.createElement("div",{className:f.Details,ref:L},n.createElement("div",{className:f.ItemsContainer},d.items.map((function(e,t){return n.createElement(m,{key:t,vm:a,cartItem:e,currencyCode:d.currencyCode})}))),n.createElement("div",{className:f.Divider}),n.createElement("div",{className:f.SubTotalInfo},x&&n.createElement("div",{className:f.NotificationContainer},n.createElement(r,{type:"warning",title:p("checkout-page:giftCodeErrorTitle"),content:z,onClose:function(){_(!1),j(null)}})),n.createElement(y,{label:p("checkout-page:subtotal"),value:d.formattedTotalPrice,tooltipText:p("checkout-page:subtotalTooltip")}),!!(null===(t=d.shippingLines)||void 0===t?void 0:t.length)&&n.createElement(y,{label:p("checkout-page:cartShippingTitle"),value:d.shippingTotal?d.formattedShippingTotal:p("checkout-page:free")}),!!a.installmentExtraPrice&&n.createElement(y,{label:p("checkout-page:cartInterest"),value:u(a.installmentExtraPrice,d.currencyCode,d.currencySymbol)}),n.createElement(S,{vm:a}),n.createElement(T,{vm:a}),(a.step===l.SUCCESS&&(!!a.checkout.note||!!a.checkout.appliedCouponCode)||a.step!==l.SUCCESS)&&n.createElement("div",{className:f.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(b,{vm:a,isAddingCoupon:G,setAddingCoupon:V,setCouponError:_,setCouponErrorCode:j}),n.createElement(O,{vm:a,isAddingNote:F,setAddingNote:X})),n.createElement("div",{className:f.TotalContainer},n.createElement("div",{className:f.TitleContainer},n.createElement("div",{className:f.Title},p("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:f.TotalPricesContainer},n.createElement("div",{className:f.TotalPrice},u(a.finalPrice||0,d.currencyCode,d.currencySymbol)),!!d.$totalTax&&!!(null===(o=a.customizationProps)||void 0===o?void 0:o.showTax)&&n.createElement("div",{className:[f.TotalTax].join(" ")},p("checkout-page:cartTaxTitle")+" "+d.$formattedTotalTax)))),n.createElement("div",{className:f.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(k,null))))))):null})),y=o((function(e){var t=e.label,o=e.value,a=e.tooltipText;return n.createElement("div",{className:f.InfoRow},n.createElement("div",{className:f.Label},n.createElement("span",null,t),!!a&&n.createElement(E,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:f.Value},o))})),S=o((function(e){var t=e.vm,o=s().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").map((function(e,a){return n.createElement("div",{className:f.InfoRow,key:a},n.createElement("div",{className:f.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:f.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),T=o((function(e){var t,o,a=e.vm,c=s().t;return a.checkout?n.createElement(n.Fragment,null,a.step!==l.SUCCESS&&((null===(t=a.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(a.checkout.totalFinalPrice||0,a.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return n.createElement("div",{className:f.InfoRow,key:t},n.createElement("div",{className:f.Label},e.name),n.createElement("div",{className:f.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,a.checkout.currencyCode,a.checkout.currencySymbol))))})),null===(o=a.checkout.giftPackageLines)||void 0===o?void 0:o.map((function(e,t){return n.createElement("div",{className:f.InfoRow,key:t},n.createElement("div",{className:f.Label},n.createElement("div",{className:f.GiftLabel},n.createElement(h,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,c("checkout-page:giftPackage")))),n.createElement("div",{className:f.Value},n.createElement("span",null,u(e.price,a.checkout.currencyCode,a.checkout.currencySymbol))))}))):null})),b=o((function(o){var a=o.vm,r=o.isAddingCoupon,i=o.setAddingCoupon,m=o.setCouponError,d=o.setCouponErrorCode,p=s().t,E=n.useState(""),C=E[0],h=E[1],k=n.useState(!1),N=k[0],g=k[1],y=n.useRef(null);n.useEffect((function(){r&&y.current&&y.current.focus()}),[r]);if(a.step===l.SUCCESS&&!a.checkout.appliedCouponCode)return null;var S=a.checkout.couponAdjustment;return n.createElement("div",{className:f.InfoRow},!a.checkout.appliedCouponCode&&!r&&n.createElement("div",{className:f.ActionTextBtn,onClick:function(){return i(!0)}},p("checkout-page:addCouponCode")),r&&n.createElement(c,{value:C,placeholder:p("checkout-page:couponCode"),buttonLabel:p("checkout-page:actions.apply"),inputRef:y,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=C,g(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),g(!1),h(""),!a.checkout.appliedCouponCode||a.couponError?[3,3]:(i(!1),m(!1),d(null),[4,a.reInitPaymentMethod()]);case 2:return e.sent(),[3,4];case 3:a.checkout.couponCode=null,m(!0),d(a.couponError),e.label=4;case 4:return[2]}}))}))},isLoading:N,onChange:h}),!!a.checkout.appliedCouponCode&&!r&&n.createElement("div",{className:[f.ActionTextBtn,f.NoUnderline,f.Light].join(" ")},p("checkout-page:couponCode"),n.createElement("span",{className:f.AppliedCoupon},n.createElement("span",{className:f.CouponCode},a.checkout.appliedCouponCode),a.step!==l.SUCCESS&&n.createElement("span",{className:f.ClearCoupon,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=null,g(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),g(!1),[2]}}))}))}},n.createElement(v,null)))),!!a.checkout.appliedCouponCode&&!r&&n.createElement("div",{className:f.Value},n.createElement("span",null,"DECREMENT"===(null==S?void 0:S.type)?"- ":"")," ",n.createElement("span",null,u((null==S?void 0:S.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol))))})),O=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=s().t,r=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),u=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===l.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:f.InfoRow},!o&&!m&&n.createElement("div",{className:f.ActionTextBtn,onClick:i},r),(o||m)&&n.createElement("div",{className:[f.CheckoutNoteContainer,m?f.Success:""].join(" ")},n.createElement("div",{className:f.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:f.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:u})))}));export{g as CartSummary,N as CouponErrorCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as o,__generator as r}from'./../../../../ext/tslib/tslib.es6.js';import*as e from"react";import{observer as t}from"mobx-react-lite";import{Elements as i}from"@stripe/react-stripe-js";import{loadStripe as
|
|
1
|
+
import{__awaiter as o,__generator as r}from'./../../../../ext/tslib/tslib.es6.js';import*as e from"react";import{observer as t}from"mobx-react-lite";import{Elements as i}from"@stripe/react-stripe-js";import{loadStripe as s}from"@stripe/stripe-js";import{CheckoutForm as n}from"./checkout-form.js";var l=t((function(t){var l,p,a,c,u,d,m,v,b,f=t.vm;if(!f.stripeResponse)return null;var x=e.useState(null),E=x[0],z=x[1];e.useEffect((function(){!function(){o(this,void 0,void 0,(function(){var o;return r(this,(function(r){switch(r.label){case 0:return f.stripeResponse?[4,s(f.stripeResponse.apiKey,{stripeAccount:f.stripeResponse.accountId})]:[3,2];case 1:o=r.sent(),z(o),r.label=2;case 2:return[2]}}))}))}()}),[f.stripeResponse]);var C={clientSecret:f.stripeResponse.clientSecret,appearance:{variables:{borderRadius:"8px"},labels:"floating",rules:{".Input":{lineHeight:"16px",boxShadow:"0 0 0 1px transparent",transition:"padding .1s, border-color .5s, box-shadow .5s",padding:"8px 16px",border:"1px solid ".concat((null===(l=f.customizationProps)||void 0===l?void 0:l.borderColor)||"#E5E4E9")},".Input::placeholder":{fontSize:"14px",color:(null===(p=f.customizationProps)||void 0===p?void 0:p.secondaryTextColor)||"#8A8B94"},".Input:focus":{boxShadow:"0 0 0 1px ".concat((null===(a=f.customizationProps)||void 0===a?void 0:a.buttonBgColor)||"##272727"),borderColor:(null===(c=f.customizationProps)||void 0===c?void 0:c.buttonBgColor)||"##272727"},".Input--invalid":{boxShadow:"0 0 0 1px ".concat((null===(u=f.customizationProps)||void 0===u?void 0:u.errorColor)||"#FB4E4E"),borderColor:(null===(d=f.customizationProps)||void 0===d?void 0:d.errorColor)||"#FB4E4E",color:(null===(m=f.customizationProps)||void 0===m?void 0:m.errorColor)||"#FB4E4E"},".Label":{fontSize:"14px",color:(null===(v=f.customizationProps)||void 0===v?void 0:v.secondaryTextColor)||"#8A8B94"},".Error":{fontSize:"12px",marginTop:"8px",color:(null===(b=f.customizationProps)||void 0===b?void 0:b.errorColor)||"#FB4E4E"}}}};return e.createElement(e.Fragment,null,e.createElement(i,{key:f.stripeResponse.clientSecret,stripe:E,options:C},e.createElement(n,{callbackUrl:f.stripeResponse.callbackUrl,vm:f})))}));export{l as default};
|
|
@@ -154,6 +154,11 @@ export default class CheckoutViewModel {
|
|
|
154
154
|
setUseDifferentAddress: (value: boolean) => void;
|
|
155
155
|
setShouldSaveAddress: (value: boolean) => void;
|
|
156
156
|
setAddressTitle: (value: string) => void;
|
|
157
|
+
reInitPaymentMethod: () => Promise<void>;
|
|
158
|
+
createStripePaymentIntent: (paymentGateway: IkasPaymentGateway) => Promise<void>;
|
|
159
|
+
createKlarnaClientToken: (paymentGateway: IkasPaymentGateway) => Promise<void>;
|
|
160
|
+
createAdyenClientToken: (paymentGateway: IkasPaymentGateway) => Promise<void>;
|
|
161
|
+
getPayPalClientId: (paymentGateway: IkasPaymentGateway) => Promise<void>;
|
|
157
162
|
setPaymentGateway: (index: number) => Promise<void>;
|
|
158
163
|
setInstallmentCount: (count: number) => void;
|
|
159
164
|
changeStep: (step: CheckoutStep) => Promise<void>;
|
|
@@ -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{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as p}from"../../models/data/checkout/index.js";import"../../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 m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as g}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 f}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 v}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}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 S}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 k from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import C from"../../store/checkout/index.js";import P from"../../store/cart/api.js";import I,{MFS_ELEMENT_ID as A,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as j}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as O}from"@ikas/storefront-config";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as x}from"@ikas/storefront-api";import D from"../../models/data/order/address/ikas-localized-order-address.js";import T from"../../store/location/index.js";var G,L,M=/^\d+$/,V="undefined"==typeof localStorage,_=function(){function M(c,d,g,f,M,_,F,Z,B,Y){var H=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=G.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(H,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,j.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:if(O.getIsEditor())return this.step=G.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),i=e.get("step"),s=e.get("failed"),n=e.get("error"),i){if(this.step=i,this.step===G.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(G.INFO)];if(this.step!==G.PAYMENT||this.canProceedToPayment){if(this.step===G.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(G.INFO)];if(![G.INFO,G.SUCCESS,G.SHIPPING,G.PAYMENT].includes(this.step))return[2,this.changeStep(G.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(G.INFO)]:[2,this.changeStep(G.SHIPPING)];this.deliveryMethod="in-store"}}return s&&(this.error={type:L.PAYMENT_ERROR,data:n||null}),this.step!==G.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==G.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=G.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==G.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==G.PAYMENT&&this.step!==G.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===G.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(G.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===r}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,b.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(H,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new R(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!==G.INFO&&this.step!==G.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),[4,P.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:L.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:L.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(H,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(H,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,C.checkStocks({lines:e.map((function(e){return new x(e)})),stockLocationIdList:(null===(u=O.getStockLocationIds())||void 0===u?void 0:u.length)?O.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:L.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:L.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(H,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,j.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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,C.getAvailableShippingCountries({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?[4,C.listStockLocation({id:{in:O.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:L.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,C.getAvailableStockLocations({lines:e.map((function(e){return new x(e)})),stockLocationIdList:O.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:L.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=H.shippingCountryIds)||void 0===e?void 0:e.length)||(H.error={type:L.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(H.checkout.stockLocationId=null),H.deliveryMethod=e,H.isErrorsVisible=!1},this.initialStockCheck=function(){return e(H,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:L.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(H,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=O.getPaymentGateways().map((function(e){return e.id})),[4,C.listPaymentGateway({id:e?void 0:{in:i},locale:O.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===G.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(O.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===G.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=A,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:j.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:L.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,C.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;H.store.customerStore.customer?(null===(e=H.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=H.checkoutSettings,e.shippingZones=H.shippingZones})),H.checkout.customer=new v(H.store.customerStore.customer)):H.checkout.customer=new v(H.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones,H.checkout.shippingAddress.countrySettings=H.countrySettings,H.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones,H.checkout.billingAddress.countrySettings=H.countrySettings,H.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!H.isDigitalOnly)if(H.isInStoreDelivery)H.setCheckoutShippingAddressSettings();else if(H.checkout.shippingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedShippingAddressIdChange(e.id||"-1"),void H.setCheckoutShippingAddressSettings()}H.checkout.shippingAddress=new D(n(H.checkout.shippingAddress)||{}),H.setCheckoutShippingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else H.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(H.useDifferentAddress=!!localStorage.getItem("sAddr"),H.checkout.billingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedBillingAddressIdChange(e.id||"-1"),void H.setCheckoutBillingAddressSettings()}H.checkout.billingAddress=new D(n(H.checkout.billingAddress)||{}),H.setCheckoutBillingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())}else H.onSelectedBillingAddressIdChange("-1"),H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(H,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 p(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(H,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(H,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,P.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===G.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(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(H,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,T.getAvailableShippingZones({salesChannelId:O.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(H.selectedShippingAddressId=e,"-1"===e)H.checkout.shippingAddress=new D,H.checkout.shippingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.shippingAddress=new D(i),H.checkout.shippingAddress.countrySettings=H.countrySettings)}H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(H.selectedBillingAddressId=e,"-1"===e)H.checkout.billingAddress=new D,H.checkout.billingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.billingAddress=new D(i),H.checkout.billingAddress.countrySettings=H.countrySettings)}H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){H.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(H.cardData&&(!(e.length>H.cardData.cardNumber.length)||K(e))){var t=(H.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!H.installmentInfo?H.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:H.checkout.selectedPaymentGateway.id,price:H.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(H.cardData.installmentCount=1,H.installmentInfo=void 0),H.cardData.cardNumber=U(i,4).join(" "))}},this.onCardHolderNameChange=function(e){H.cardData&&(H.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(H.cardData&&(!(e.length>H.cardData.expirationDate.length)||K(e))){if(0===(null===(t=H.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(H.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(H.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(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(H.cardData.expirationDate=U(d,2).join(" / "))}},this.onCvcChange=function(e){H.cardData&&(e.length>H.cardData.cvv.length&&!K(e)||e.length>4||(H.cardData.cvv=e))},this.saveAddress=function(s){return e(H,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,g,f,v=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new m(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===(g=this.customerAddresses)||void 0===g||g.forEach((function(e){e.checkoutSettings=v.checkoutSettings,e.shippingZones=v.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){H.router.push("/cart")},this.onBackToShoppingClick=function(){H.router.push("/")},this.onGoToLoginClick=function(){H.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(H,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(G.SHIPPING):this.changeStep(G.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(H,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(G.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(H,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(G.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!H.canPerformPayment||(H.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(H,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.isKlarna?[4,this.saveCart()]:[3,2]):(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.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 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(H,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:L.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,c,d,l,h,p,m,g,f,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,C.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===(g=this.cardData)||void 0===g?void 0:g.threeDSecure)}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,C.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.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,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:L.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(G.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){H.changeStep(G.INFO)},this.onBackToShippingClick=function(){H.changeStep(G.SHIPPING)},this.setCustomerConsentGranted=function(e){H.checkout.customer&&(H.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){H.useDifferentAddress=e,H.useDifferentAddress?(localStorage.setItem("sAddr","1"),H.checkout.billingAddress=H.checkout.billingAddress||new D,H.checkout.billingAddress.countrySettings=H.countrySettings):(localStorage.removeItem("sAddr"),H.checkout.billingAddress=H.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){H.shouldSaveAddress=e},this.setAddressTitle=function(e){H.addressTitle=e},this.setPaymentGateway=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return this.paymentGateways.length?"STRIPE"!==(e=this.paymentGateways[i]).code||!(null===(n=e.settings)||void 0===n?void 0:n.find((function(e){return"allow_custom_flow"===e.label&&"1"===e.value})))||this.stripeResponse?[3,2]:[4,C.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})]:[2];case 1:(s=t.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),t.label=2;case 2:return"KLARNA"!==e.code||this.klarnaResponse?[3,4]:[4,C.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 3:(s=t.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),t.label=4;case 4:return"ADYEN"!==e.code||this.adyenResponse?[3,6]:[4,C.createAdyenClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 5:(s=t.sent()).isSuccess&&s.data&&(this.adyenResponse=s.data),t.label=6;case 6:return"PAYPAL"!==e.code||this.payPalClientIdResponse?[3,8]:[4,C.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 7:(s=t.sent()).isSuccess&&s.data&&(this.payPalClientIdResponse=s.data),t.label=8;case 8:return this.checkout.selectedPaymentGateway=e,this.step!==G.SUCCESS&&(e.paymentMethodType===o.CREDIT_CARD&&e.type===a.INTERNAL&&(this.cardData=new k,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){H.cardData&&(H.cardData.installmentCount=e)},this.changeStep=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return V||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(H,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){H.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===l.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,P.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new p(e.data,this.countrySettings),i.accepted&&this.step===G.SUCCESS?this.changeStep(G.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(H,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,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=g,this.returnPolicy=f,this.privacyPolicy=M,this.termsOfService=_,this.imprint=F,this.shippingPolicy=Z,this.t=B,this.customizationProps=Y,this.mpVM=new I,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new S({currentLocale:O.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(M.prototype,"merchantSettings",{get:function(){return new f(O.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.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(M.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=j.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(M.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(M.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"finalPrice",{get:function(){return this.step===G.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===L.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(M.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)!==L.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"store",{get:function(){return j.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(M.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)===o.CREDIT_CARD&&i.type===a.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(M.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(M.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 g(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isEPayKolayEnabled",{get:function(){var e=O.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),M.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},M}();function U(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function K(e){return e&&M.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(G||(G={})),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"}(L||(L={}));export{G as CheckoutStep,L as ErrorType,_ 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{IkasPaymentMethodType as o,IkasPaymentGatewayType as a,IkasOrderShippingMethod as c,IkasCartCreatedBy as d,IkasTransactionStatus as u,IkasCartCampaignOfferStatus as l,IkasCampaignOfferTargetPageType as h}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as p}from"../../models/data/checkout/index.js";import"../../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 m}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as g}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 f}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 v}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as y}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 k}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 S from"./components/credit-card-form/model.js";import b from"../../store/customer/api.js";import P from"../../store/checkout/index.js";import C from"../../store/cart/api.js";import I,{MFS_ELEMENT_ID as A,MFS_SCRIPT_URL as w}from"./modelMasterPass.js";import N from"../../store/product/index.js";import{IkasBaseStore as j}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as O}from"@ikas/storefront-config";import{Analytics as E}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as R,CheckStocksLineInput as x}from"@ikas/storefront-api";import D from"../../models/data/order/address/ikas-localized-order-address.js";import T from"../../store/location/index.js";var G,L,M=/^\d+$/,V="undefined"==typeof localStorage,_=function(){function M(c,d,g,f,M,_,F,Z,B,Y){var H=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=G.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.showTestModal=!1,this.init=function(){return e(H,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,j.getInstance().customerStore.waitUntilInitialized()];case 2:return e.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return e.sent(),[4,this.initStep()];case 4:return e.sent(),[2]}}))}))},this.initStep=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:if(O.getIsEditor())return this.step=G.INFO,this.isCheckoutLoaded=!0,[2];if(e=new URLSearchParams(window.location.search),i=e.get("step"),s=e.get("failed"),n=e.get("error"),i){if(this.step=i,this.step===G.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(G.INFO)];if(this.step!==G.PAYMENT||this.canProceedToPayment){if(this.step===G.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(G.INFO)];if(![G.INFO,G.SUCCESS,G.SHIPPING,G.PAYMENT].includes(this.step))return[2,this.changeStep(G.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings?[2,this.changeStep(G.INFO)]:[2,this.changeStep(G.SHIPPING)];this.deliveryMethod="in-store"}}return s&&(this.error={type:L.PAYMENT_ERROR,data:n||null}),this.step!==G.INFO?[3,6]:this.isDigitalOnly?[3,3]:[4,this.getAvailableShippingZones()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 2:t.sent(),this.checkShippingCountries(),t.label=3;case 3:return[4,this.getStockLocations()];case 4:return t.sent(),[4,this.getAvailableStockLocations()];case 5:t.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),t.label=6;case 6:return this.step!==G.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=G.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==G.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==G.PAYMENT&&this.step!==G.SUCCESS?[3,10]:[4,this.listPaymentGateways()]:(this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 7:return t.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,9];case 8:t.sent(),t.label=9;case 9:if(!this.paymentGateways.length)return this.error={type:L.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];t.label=10;case 10:return this.step===G.SUCCESS?[3,14]:this.checkout.isComplete?[2,this.changeStep(G.SUCCESS)]:[3,11];case 11:return[4,this.initialStockCheck()];case 12:t.sent(),t.label=13;case 13:return[3,16];case 14:return[4,this.getSuccessTransaction()];case 15:t.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===r}))),t.label=16;case 16:return this.isCheckoutLoaded=!0,E.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return[4,b.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(H,void 0,void 0,(function(){var e,i,s,n;return t(this,(function(t){switch(t.label){case 0:return e=new R(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!==G.INFO&&this.step!==G.SHIPPING||this.isDigitalOnly||(e.billingAddress=null),this.isDigitalOnly&&(e.shippingAddress=null),[4,C.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:L.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:L.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return e(H,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(H,void 0,void 0,(function(){var e,i,s,n,r,o,a,c,d,u,l,h;return t(this,(function(t){switch(t.label){case 0:return this.isManualOrder?[2]:(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.checkStocks({lines:e.map((function(e){return new x(e)})),stockLocationIdList:(null===(u=O.getStockLocationIds())||void 0===u?void 0:u.length)?O.getStockLocationIds():null})]);case 1:if(!(i=t.sent()).isSuccess)throw{type:L.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(e){return!e.isAvailable})))?void 0:s.length){for(n=[],r=function(e){var t=o.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&n.push({item:t,stockCount:e.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:L.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return e(H,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,j.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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.getAvailableShippingCountries({salesChannelId:O.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?[4,P.listStockLocation({id:{in:O.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:L.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,t.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return O.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,P.getAvailableStockLocations({lines:e.map((function(e){return new x(e)})),stockLocationIdList:O.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=t.sent()).isSuccess)return this.error={type:L.API_ERROR},[2];this.availableStockLocations=i.data||[],t.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=H.shippingCountryIds)||void 0===e?void 0:e.length)||(H.error={type:L.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){"address"===e&&(H.checkout.stockLocationId=null),H.deliveryMethod=e,H.isErrorsVisible=!1},this.initialStockCheck=function(){return e(H,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:L.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return e(H,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=O.getPaymentGateways().map((function(e){return e.id})),[4,P.listPaymentGateway({id:e?void 0:{in:i},locale:O.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===G.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(O.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===G.PAYMENT&&(c=n.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=A,d.src=w,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:j.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:L.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return e(H,void 0,void 0,(function(){var e,s,n;return t(this,(function(t){switch(t.label){case 0:return[4,P.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;H.store.customerStore.customer?(null===(e=H.customerAddresses)||void 0===e||e.forEach((function(e){e.checkoutSettings=H.checkoutSettings,e.shippingZones=H.shippingZones})),H.checkout.customer=new v(H.store.customerStore.customer)):H.checkout.customer=new v(H.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones,H.checkout.shippingAddress.countrySettings=H.countrySettings,H.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones,H.checkout.billingAddress.countrySettings=H.countrySettings,H.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!H.isDigitalOnly)if(H.isInStoreDelivery)H.setCheckoutShippingAddressSettings();else if(H.checkout.shippingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedShippingAddressIdChange(e.id||"-1"),void H.setCheckoutShippingAddressSettings()}H.checkout.shippingAddress=new D(n(H.checkout.shippingAddress)||{}),H.setCheckoutShippingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else H.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(H.useDifferentAddress=!!localStorage.getItem("sAddr"),H.checkout.billingAddress){if(H.store.customerStore.customer){var e=null==(t=H.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=H.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return H.onSelectedBillingAddressIdChange(e.id||"-1"),void H.setCheckoutBillingAddressSettings()}H.checkout.billingAddress=new D(n(H.checkout.billingAddress)||{}),H.setCheckoutBillingAddressSettings()}else if(H.store.customerStore.customer){var t=H.customerAddresses;H.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())}else H.onSelectedBillingAddressIdChange("-1"),H.useDifferentAddress||!H.checkout.shippingAddress||H.isInStoreDelivery||(H.checkout.billingAddress=new D(n(H.checkout.shippingAddress)),H.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(i){return e(H,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 p(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(H,void 0,void 0,(function(){return t(this,(function(e){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return e(H,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,C.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===G.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:t.sent(),t.label=3;case 3:s&&(r=this.checkout,this.checkout=new p(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(H,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,T.getAvailableShippingZones({salesChannelId:O.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(H.selectedShippingAddressId=e,"-1"===e)H.checkout.shippingAddress=new D,H.checkout.shippingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.shippingAddress=new D(i),H.checkout.shippingAddress.countrySettings=H.countrySettings)}H.checkout.shippingAddress&&(H.checkout.shippingAddress.checkoutSettings=H.checkoutSettings,H.checkout.shippingAddress.shippingZones=H.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(H.selectedBillingAddressId=e,"-1"===e)H.checkout.billingAddress=new D,H.checkout.billingAddress.countrySettings=H.countrySettings;else{var i=null===(t=H.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(H.checkout.billingAddress=new D(i),H.checkout.billingAddress.countrySettings=H.countrySettings)}H.checkout.billingAddress&&(H.checkout.billingAddress.checkoutSettings=H.checkoutSettings,H.checkout.billingAddress.shippingZones=H.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){H.isTermsAndConditionsChecked=e},this.onCardNumberChange=function(e){if(H.cardData&&(!(e.length>H.cardData.cardNumber.length)||K(e))){var t=(H.cardData.cardNumber||"").split(" ").join(""),i=e.split(" ").join("");i.length>16||(t.length<6&&i.length>=6&&!H.installmentInfo?H.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:H.checkout.selectedPaymentGateway.id,price:H.checkout.totalFinalPrice}}):i.length<6&&t.length>i.length&&(H.cardData.installmentCount=1,H.installmentInfo=void 0),H.cardData.cardNumber=U(i,4).join(" "))}},this.onCardHolderNameChange=function(e){H.cardData&&(H.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(H.cardData&&(!(e.length>H.cardData.expirationDate.length)||K(e))){if(0===(null===(t=H.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(H.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(H.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(H.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(H.cardData.expirationDate=U(d,2).join(" / "))}},this.onCvcChange=function(e){H.cardData&&(e.length>H.cardData.cvv.length&&!K(e)||e.length>4||(H.cardData.cvv=e))},this.saveAddress=function(s){return e(H,void 0,void 0,(function(){var e,r,o,a,c,d,u,l,h,p,g,f,v=this;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(e="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(t){return t.id===(null==e?void 0:e.id)})))?[2]:(r=null===(p=this.customerAddresses)||void 0===p?void 0:p.map((function(e){return e.id})),o=new m(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===(g=this.customerAddresses)||void 0===g||g.forEach((function(e){e.checkoutSettings=v.checkoutSettings,e.shippingZones=v.shippingZones})),c=null===(f=this.customerAddresses)||void 0===f?void 0:f.map((function(e){return e.id})),d=null==c?void 0:c.filter((function(e){return!(null==r?void 0:r.includes(e))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),t.label=2;case 2:return[3,4];case 3:return l=t.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){H.router.push("/cart")},this.onBackToShoppingClick=function(){H.router.push("/")},this.onGoToLoginClick=function(){H.router.push("/account/login")},this.onProceedToShippingClick=function(){return e(H,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(G.SHIPPING):this.changeStep(G.PAYMENT),[3,7];case 6:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return e(H,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(G.PAYMENT),[3,5];case 4:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return e(H,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(G.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:L.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!H.canPerformPayment||(H.isErrorsVisible=!0,!1)},this.onCompletePaymentClick=function(){return e(H,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.isKlarna?[4,this.saveCart()]:[3,2]):(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.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 7:return t.sent(),[3,9];case 8:return void 0!==typeof(i=t.sent()).type?this.error=i:this.error={type:L.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return e(H,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:L.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return e(H,void 0,void 0,(function(){var e,i,s,n,r,c,d,l,h,p,m,g,f,v,y;return t(this,(function(t){switch(t.label){case 0:return i=this.mpVM.selectedCard,!this.isFree&&i&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(e=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,P.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===(g=this.cardData)||void 0===g?void 0:g.threeDSecure)}}})]):[3,2];case 1:return s=t.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,P.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:i&&e?{phoneNumber:e,savedCardName:null===(f=this.mpVM.selectedCard)||void 0===f?void 0:f.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:this.isFree||i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===o.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===a.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,c=r&&[u.SUCCESS,u.AUTHORIZED].includes(r),d=r===u.PENDING,c?[4,this.getSuccessTransaction()]:[3,7];case 5:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return t.sent(),[3,8];case 7:if(!d||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:L.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,t.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return localStorage.removeItem("sAddr"),(null===(e=this.checkout.customer)||void 0===e?void 0:e.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.changeStep(G.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){H.changeStep(G.INFO)},this.onBackToShippingClick=function(){H.changeStep(G.SHIPPING)},this.setCustomerConsentGranted=function(e){H.checkout.customer&&(H.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(e){H.useDifferentAddress=e,H.useDifferentAddress?(localStorage.setItem("sAddr","1"),H.checkout.billingAddress=H.checkout.billingAddress||new D,H.checkout.billingAddress.countrySettings=H.countrySettings):(localStorage.removeItem("sAddr"),H.checkout.billingAddress=H.checkout.shippingAddress)},this.setShouldSaveAddress=function(e){H.shouldSaveAddress=e},this.setAddressTitle=function(e){H.addressTitle=e},this.reInitPaymentMethod=function(){return e(H,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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.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(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,P.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(H,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!==G.SUCCESS&&(e.paymentMethodType===o.CREDIT_CARD&&e.type===a.INTERNAL&&(this.cardData=new S,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){H.cardData&&(H.cardData.installmentCount=e)},this.changeStep=function(i){return e(H,void 0,void 0,(function(){return t(this,(function(e){return V||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return e(H,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){H.isContactModalVisible=e},this.getCampaignOfferProducts=function(i){return e(H,void 0,void 0,(function(){var e,s,n,r;return t(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(e=this.checkout.campaignOffers.filter((function(e){var t;return e.status===l.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===i})))})),!e.length)return[3,4];s=function(i){var s,n,r,o,a;return t(this,(function(t){switch(t.label){case 0:return(s=e[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(e){return e.id===s.campaignOfferProductId})))?[4,N.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=t.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(e){var t;e.hasStock&&!(null===(t=n.excludedVariantIdList)||void 0===t?void 0:t.some((function(t){return t===e.id})))&&a.push(e)})):a.push.apply(a,o.variants.filter((function(e){return e.hasStock}))),a.length))return[2,{value:{product:new y(o),variants:a,campaignOffer:s,offer:n}}];t.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<e.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return e(H,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOfferProducts(h.CHECKOUT)];case 1:return e.checkoutCampaignOffer=t.sent(),i=this,[4,this.getCampaignOfferProducts(h.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return e(H,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.isCheckoutLoaded=!1,[4,C.updateCartCampaignOffer({input:i})];case 1:return(e=t.sent())&&e.isSuccess&&e.data&&(this.checkout=new p(e.data,this.countrySettings),i.accepted&&this.step===G.SUCCESS?this.changeStep(G.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return e(H,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,b.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.checkout=c,this.checkoutSettings=d,this.router=g,this.returnPolicy=f,this.privacyPolicy=M,this.termsOfService=_,this.imprint=F,this.shippingPolicy=Z,this.t=B,this.customizationProps=Y,this.mpVM=new I,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new k({currentLocale:O.getCurrentLocale()}),this.init(),s(this)}return Object.defineProperty(M.prototype,"merchantSettings",{get:function(){return new f(O.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.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(M.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=j.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(M.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(M.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"finalPrice",{get:function(){return this.step===G.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===L.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(M.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)!==L.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.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(M.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"store",{get:function(){return j.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(M.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)===o.CREDIT_CARD&&i.type===a.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(M.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===c.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(M.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 g(i({countrySettings:s.countrySettings},e));return t.checkoutSettings=s.checkoutSettings,t.shippingZones=s.shippingZones,t.getValidatedCustomerAddress(),t}))},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isEPayKolayEnabled",{get:function(){var e=O.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),M.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},M}();function U(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function K(e){return e&&M.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(G||(G={})),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"}(L||(L={}));export{G as CheckoutStep,L as ErrorType,_ as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.3",
|
|
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.7.
|
|
21
|
-
"@ikas/storefront-config": "^4.7.
|
|
22
|
-
"@ikas/storefront-model-functions": "^4.7.
|
|
23
|
-
"@ikas/storefront-models": "^4.7.
|
|
24
|
-
"@ikas/storefront-providers": "^4.7.
|
|
20
|
+
"@ikas/storefront-api": "^4.7.3",
|
|
21
|
+
"@ikas/storefront-config": "^4.7.3",
|
|
22
|
+
"@ikas/storefront-model-functions": "^4.7.3",
|
|
23
|
+
"@ikas/storefront-models": "^4.7.3",
|
|
24
|
+
"@ikas/storefront-providers": "^4.7.3",
|
|
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.7.
|
|
59
|
-
"@ikas/storefront-config": "^4.7.
|
|
60
|
-
"@ikas/storefront-model-functions": "^4.7.
|
|
61
|
-
"@ikas/storefront-models": "^4.7.
|
|
62
|
-
"@ikas/storefront-providers": "^4.7.
|
|
58
|
+
"@ikas/storefront-api": "^4.7.3",
|
|
59
|
+
"@ikas/storefront-config": "^4.7.3",
|
|
60
|
+
"@ikas/storefront-model-functions": "^4.7.3",
|
|
61
|
+
"@ikas/storefront-models": "^4.7.3",
|
|
62
|
+
"@ikas/storefront-providers": "^4.7.3",
|
|
63
63
|
"mobx": "^6.1.3",
|
|
64
64
|
"mobx-react-lite": "^3.1.5",
|
|
65
65
|
"next": "12.2.0",
|