@ikas/storefront 6.1.0-beta.398 → 6.1.0-beta.399

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 n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import l from"../input-with-button/index.js";import c from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import C from"../svg/arrow-down.js";import h from"../svg/cross.js";import v from"../svg/gift.js";import y from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import f from"../svg/ikas.js";import{Button as k}from"../button/index.js";import{IkasCampaignCreatedFor as N,IkasCartCreatedBy as S,IkasGiftCardType as T}from"@ikas/storefront-models";import P from"../../../../hooks/useDimension.js";import O from"../svg/coupon-code-tag.js";import b from"../svg/gift-cart-tag.js";import I from"../svg/store-credit-tag.js";import L from"../svg/gift-loyalty.js";import _ from"../svg/package-loyalty.js";import x from"../svg/percentage-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as A}from"@ikas/storefront-api";import{isLoyaltyBlockVisible as j,LoyaltyPointsBlock as D,LoyaltyEarningRow as R}from"./loyalty/index.js";var U;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT",e.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED="COUPON_PERIOD_USAGE_LIMIT_EXCEEDED"}(U||(U={}));var M=o((function(e){var t,o,a,l,d,p,E,h,v,y=e.vm,k=e.allowExpand,N=e.isSuccessPageSummary,S=y.checkout,T=u().t,O=n.useState(!k||y.isMiniCartOpenOnLoad),b=O[0],I=O[1],L=n.useState(!1),_=L[0],x=L[1],A=n.useState(null),M=A[0],V=A[1],X=n.useState(0),W=X[0],q=X[1],Y=n.useState(null),z=Y[0],$=Y[1],K=n.useState(!1),Q=K[0],J=K[1],Z=n.useState(!1),ee=Z[0],te=Z[1],ne=n.useState(!1),oe=ne[0],ae=ne[1],le=P().isMobile;n.useEffect((function(){k&&(b?z&&q(z.getBoundingClientRect().height):q(0))}),[b,z,k,Q,ee,_,oe]);var ce=n.useMemo((function(){switch(M){case U.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case U.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case U.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");case U.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return T("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[M]),re=[g.CartSummary,k?g.HideOnDesktop:"",N?g.SuccessPageCartSummary:""].join(" "),ie=k?{height:W+"px"}:void 0,se=[g.ArrowDown,b?g.Rotated:""].join(" "),ue=!le&&j(y);return S?n.createElement(n.Fragment,null,!!k&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}I(!b)}},n.createElement("div",{className:g.Left},T("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(s(y.finalPrice||0,S.currencyCode,S.currencySymbol)," (").concat(S.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:se},n.createElement(C,null))))),n.createElement("div",{className:re},n.createElement("div",{className:[g.DetailsContainer,N?g.SuccessPageDetailContainer:""].join(" "),style:ie},n.createElement("div",{className:g.Details,ref:$},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,S.items.map((function(e,t){return n.createElement(m,{key:t,vm:y,cartItem:e,currencyCode:S.currencyCode,onChange:ae,isSuccessPageSummary:N})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},_&&n.createElement("div",{className:g.NotificationContainer},n.createElement(c,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:ce,onClose:function(){x(!1),V(null)}})),n.createElement(w,{label:T("checkout-page:subtotal"),value:S.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(y.isCouponCodeVisible||(null===(t=y.checkout.giftCardLines)||void 0===t?void 0:t.length)||(null===(o=y.checkout.loyaltyLines)||void 0===o?void 0:o.length)||(null===(a=y.checkout.nonCouponAdjustments)||void 0===a?void 0:a.length))}),!!(null===(l=S.shippingLines)||void 0===l?void 0:l.length)&&(y.step===r.SUCCESS?n.createElement(w,{label:T("checkout-page:cartShippingTitle"),value:S.shippingTotal?S.formattedShippingTotal:T("checkout-page:free")}):S.shippingLines.map((function(e,t){return n.createElement(w,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?s(e.finalPrice,S.currencyCode,S.currencySymbol):T("checkout-page:free")})}))),n.createElement(F,{vm:y}),n.createElement(B,{vm:y}),(y.step===r.SUCCESS&&(!!y.checkout.note||!!y.checkout.appliedCouponCode)||y.step!==r.SUCCESS)&&y.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),ue&&n.createElement(D,{vm:y}),n.createElement(G,{vm:y,isAddingCoupon:ee,setAddingCoupon:te,setCouponError:x,setCouponErrorCode:V}),n.createElement(H,{vm:y,isAddingNote:Q,setAddingNote:J}),!!y.installmentExtraPrice&&y.installmentExtraPrice>0&&n.createElement(n.Fragment,null,n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(w,{label:T("checkout-page:cartInterest"),value:s(y.installmentExtraPrice,S.currencyCode,S.currencySymbol)}))),y.isOpenEditOrderWithTransaction&&n.createElement("div",{className:g.SubTotalInfo,style:{}},!!(null===(d=y.openEditOrderTransaction)||void 0===d?void 0:d.chargedAmount)&&n.createElement(w,{label:T("checkout-page:chargedAmount"),value:s((null===(p=y.openEditOrderTransaction)||void 0===p?void 0:p.chargedAmount)||0,S.currencyCode,S.currencySymbol)}),!!(null===(E=y.openEditOrderTransaction)||void 0===E?void 0:E.refundedAmount)&&n.createElement(w,{label:T("checkout-page:refundedAmount"),value:s((null===(h=y.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,S.currencyCode,S.currencySymbol)})),n.createElement("div",{className:[g.TotalContainer,N?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},y.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},s(y.finalPrice||0,S.currencyCode,S.currencySymbol)),!!S.$totalTax&&!!(null===(v=y.customizationProps)||void 0===v?void 0:v.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+S.$formattedTotalTax)))),!N&&y.step===r.PAYMENT&&y.isMilesSmilesActive()&&y.milesSmilesAppliedValue>0&&n.createElement("div",{className:g.MilesSmilesPayable},n.createElement(w,{label:T("checkout-page:milesSmilesPaymentLabel"),value:"-"+s(y.milesSmilesAppliedValue,S.currencyCode,S.currencySymbol)}),n.createElement("div",{className:g.TotalContainer},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},T("checkout-page:milesSmilesAmountToPay"))),n.createElement("div",{className:g.TotalPrice},s(y.milesSmilesAmountToPay,S.currencyCode,S.currencySymbol)))),n.createElement(R,{vm:y}),!N&&!y.isPoweredByHidden&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(f,null))))))):null})),w=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,l=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,l?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(E,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),F=o((function(e){var t=e.vm,o=u().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,s(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),B=o((function(e){var t,o=e.vm,a=u().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(v,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,s(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),G=o((function(o){var a=o.vm,c=o.isAddingCoupon,i=o.setAddingCoupon,s=o.setCouponError,m=o.setCouponErrorCode,E=o.isOpenCouponCode,C=o.isMobile,h=o.showOnlyMobile,v=u().t,f=n.useState(""),N=f[0],T=f[1],P=n.useState(!1),O=P[0],b=P[1],I=n.useRef(null);n.useEffect((function(){c&&I.current&&I.current.focus()}),[c]);var L=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=N,b(!0),[4,a.onCouponCodeApply(!0)];case 1:return t.sent(),b(!1),T(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(s(!1),m(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,s(!0),m(a.couponError),t.label=5;case 5:return[2]}}))}))},_=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return b(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},x=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return b(!0),[4,a.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},A=a.step===r.SUCCESS,j=a.step===r.SHIPPING,D=A&&!!(a.checkout.loyaltyLines&&a.checkout.loyaltyLines.length>0),R=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0)||D,U=!!a.checkout.appliedCouponCode&&E,M=!c&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==r.SUCCESS,w=R&&(!E||C),F=!!E&&!(a.checkout.createdBy===S.UPSELL||a.checkout.createdBy===S.ADMIN)&&!a.isOpenEditOrderWithTransaction;return n.createElement(n.Fragment,null,F&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:y.FormSectionTitle},n.createElement("div",{style:{paddingBottom:U?0:6},className:y.Title},v("checkout-page:couponCode"))))),R&&!j&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:M?g.InfoRow:""},M&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},v("checkout-page:addCouponCode")),c&&!E&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(l,{value:N,placeholder:v("checkout-page:couponCode"),buttonLabel:v("checkout-page:actions.apply"),inputRef:I,onClick:L,isLoading:O,onChange:T})),F&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&L()},className:[g.OpenCouponCodeMain,w?g.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{name:"couponCode",label:v("checkout-page:addCouponCode"),type:p.TEXT,value:N,onChange:T}),n.createElement(k,{style:{width:"33%"},text:v("checkout-page:actions.apply"),isLoading:O,onClick:L}))),w&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(V,{vm:a,onClearCouponCode: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,b(!0),[4,a.onCouponCodeApply(!1)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(V,{vm:a,onClearGiftCode:_,couponCode:e.code,giftCardLine:e}))})),D&&a.checkout.loyaltyLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(X,{vm:a,onClearLoyaltyPoints:x,loyaltyPointsLine:e}))}))))})),V=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,l=e.giftCardLine,c=e.onClearGiftCode,i=t.checkout.couponAdjustment,m=u().t,d=!l,p=(null==l?void 0:l.type)===T.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},l&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(I,null)),n.createElement("span",{className:g.StoreCreditTag},m("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[g.AppliedCoupon,t.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(O,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:g.CouponCode},a),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return l?c&&c(l.giftCardId):o&&o()}},n.createElement(h,null)))),n.createElement("div",null,l?n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==l?void 0:l.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),X=o((function(e){var t,o,a=e.vm,l=e.onClearLoyaltyPoints,c=e.loyaltyPointsLine,i=null===(t=a.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===c.id})),m=u().t,d=null===(o=a.loyaltySpendingMethodsAll)||void 0===o?void 0:o.find((function(e){return e.id===c.loyaltySpendingMethodId})),p=function(){return d?d.type===A.FREE_PRODUCT?{icon:n.createElement(L,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:d.type===A.FREE_SHIPPING?{icon:n.createElement(_,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:n.createElement(x,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)})}:{icon:n.createElement(x,null),title:m("checkout-page:loyaltyPoints")}};return n.createElement(n.Fragment,null,n.createElement("div",{className:g.LoyaltyPointsLineContainer},n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},n.createElement("span",{className:[g.AppliedCouponLoyalty,a.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("div",{style:{width:"16px",height:"16px"},className:g.LoyaltyPointsLineIcon},p().icon),n.createElement("span",{className:g.CouponCode},p().title),a.step!==r.SUCCESS&&!a.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCouponLoyalty,onClick:function(){return l&&l(c.loyaltySpendingMethodId)}},n.createElement(h,null)))),n.createElement("span",{className:g.LoyaltyPointSpending},"(",m("checkout-page:loyaltyPointSpending",{point:c.amount}),")")),d?d.type!==A.FREE_PRODUCT&&d.type!==A.FREE_SHIPPING?n.createElement("div",null,n.createElement("div",{className:g.ValueLoyalty},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))):null:n.createElement("div",null,n.createElement("div",{className:g.ValueLoyalty},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))))})),H=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,l=u().t,c=n.useState(t.checkout.note?l("checkout-page:editOrderNote"):l("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),s=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},c),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},l("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s,maxLength:320})))}));export{M as CartSummary,G as Coupon,U as CouponErrorCode};
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 l from"../input-with-button/index.js";import c from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import C from"../svg/arrow-down.js";import v from"../svg/cross.js";import h from"../svg/gift.js";import y from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import f from"../svg/ikas.js";import{Button as k}from"../button/index.js";import{IkasCampaignCreatedFor as N,IkasCartCreatedBy as S,IkasGiftCardType as T}from"@ikas/storefront-models";import P from"../../../../hooks/useDimension.js";import O from"../svg/coupon-code-tag.js";import b from"../svg/gift-cart-tag.js";import I from"../svg/store-credit-tag.js";import L from"../svg/gift-loyalty.js";import _ from"../svg/package-loyalty.js";import x from"../svg/percentage-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as A}from"@ikas/storefront-api";import{isLoyaltyBlockVisible as j,LoyaltyDroppedWarning as D,LoyaltyPointsBlock as R,LoyaltyEarningRow as U}from"./loyalty/index.js";var M;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT",e.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED="COUPON_PERIOD_USAGE_LIMIT_EXCEEDED"}(M||(M={}));var w=o((function(e){var t,o,a,l,d,p,E,v,h,y=e.vm,k=e.allowExpand,N=e.isSuccessPageSummary,S=y.checkout,T=u().t,O=n.useState(!k||y.isMiniCartOpenOnLoad),b=O[0],I=O[1],L=n.useState(!1),_=L[0],x=L[1],A=n.useState(null),w=A[0],X=A[1],H=n.useState(0),q=H[0],Y=H[1],z=n.useState(null),$=z[0],K=z[1],Q=n.useState(!1),J=Q[0],Z=Q[1],ee=n.useState(!1),te=ee[0],ne=ee[1],oe=n.useState(!1),ae=oe[0],le=oe[1],ce=P().isMobile;n.useEffect((function(){k&&(b?$&&Y($.getBoundingClientRect().height):Y(0))}),[b,$,k,J,te,_,ae]);var re=n.useMemo((function(){switch(w){case M.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case M.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case M.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");case M.COUPON_PERIOD_USAGE_LIMIT_EXCEEDED:return T("checkout-page:couponPeriodUsageLimitExceeded");default:return""}}),[w]),ie=[g.CartSummary,k?g.HideOnDesktop:"",N?g.SuccessPageCartSummary:""].join(" "),se=k?{height:q+"px"}:void 0,ue=[g.ArrowDown,b?g.Rotated:""].join(" "),me=!ce&&j(y);return S?n.createElement(n.Fragment,null,!!k&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}I(!b)}},n.createElement("div",{className:g.Left},T("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(s(y.finalPrice||0,S.currencyCode,S.currencySymbol)," (").concat(S.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:ue},n.createElement(C,null))))),n.createElement("div",{className:ie},n.createElement("div",{className:[g.DetailsContainer,N?g.SuccessPageDetailContainer:""].join(" "),style:se},n.createElement("div",{className:g.Details,ref:K},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,S.items.map((function(e,t){return n.createElement(m,{key:t,vm:y,cartItem:e,currencyCode:S.currencyCode,onChange:le,isSuccessPageSummary:N})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},_&&n.createElement("div",{className:g.NotificationContainer},n.createElement(c,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:re,onClose:function(){x(!1),X(null)}})),n.createElement(F,{label:T("checkout-page:subtotal"),value:S.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(y.isCouponCodeVisible||(null===(t=y.checkout.giftCardLines)||void 0===t?void 0:t.length)||(null===(o=y.checkout.loyaltyLines)||void 0===o?void 0:o.length)||(null===(a=y.checkout.nonCouponAdjustments)||void 0===a?void 0:a.length))}),!!(null===(l=S.shippingLines)||void 0===l?void 0:l.length)&&(y.step===r.SUCCESS?n.createElement(F,{label:T("checkout-page:cartShippingTitle"),value:S.shippingTotal?S.formattedShippingTotal:T("checkout-page:free")}):S.shippingLines.map((function(e,t){return n.createElement(F,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?s(e.finalPrice,S.currencyCode,S.currencySymbol):T("checkout-page:free")})}))),n.createElement(B,{vm:y}),n.createElement(D,{vm:y}),n.createElement(G,{vm:y}),(y.step===r.SUCCESS&&(!!y.checkout.note||!!y.checkout.appliedCouponCode)||y.step!==r.SUCCESS)&&y.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),me&&n.createElement(R,{vm:y}),n.createElement(V,{vm:y,isAddingCoupon:te,setAddingCoupon:ne,setCouponError:x,setCouponErrorCode:X}),n.createElement(W,{vm:y,isAddingNote:J,setAddingNote:Z}),!!y.installmentExtraPrice&&y.installmentExtraPrice>0&&n.createElement(n.Fragment,null,n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(F,{label:T("checkout-page:cartInterest"),value:s(y.installmentExtraPrice,S.currencyCode,S.currencySymbol)}))),y.isOpenEditOrderWithTransaction&&n.createElement("div",{className:g.SubTotalInfo,style:{}},!!(null===(d=y.openEditOrderTransaction)||void 0===d?void 0:d.chargedAmount)&&n.createElement(F,{label:T("checkout-page:chargedAmount"),value:s((null===(p=y.openEditOrderTransaction)||void 0===p?void 0:p.chargedAmount)||0,S.currencyCode,S.currencySymbol)}),!!(null===(E=y.openEditOrderTransaction)||void 0===E?void 0:E.refundedAmount)&&n.createElement(F,{label:T("checkout-page:refundedAmount"),value:s((null===(v=y.openEditOrderTransaction)||void 0===v?void 0:v.refundedAmount)||0,S.currencyCode,S.currencySymbol)})),n.createElement("div",{className:[g.TotalContainer,N?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},y.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},s(y.finalPrice||0,S.currencyCode,S.currencySymbol)),!!S.$totalTax&&!!(null===(h=y.customizationProps)||void 0===h?void 0:h.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+S.$formattedTotalTax)))),!N&&y.step===r.PAYMENT&&y.isMilesSmilesActive()&&y.milesSmilesAppliedValue>0&&n.createElement("div",{className:g.MilesSmilesPayable},n.createElement(F,{label:T("checkout-page:milesSmilesPaymentLabel"),value:"-"+s(y.milesSmilesAppliedValue,S.currencyCode,S.currencySymbol)}),n.createElement("div",{className:g.TotalContainer},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},T("checkout-page:milesSmilesAmountToPay"))),n.createElement("div",{className:g.TotalPrice},s(y.milesSmilesAmountToPay,S.currencyCode,S.currencySymbol)))),n.createElement(U,{vm:y}),!N&&!y.isPoweredByHidden&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(f,null))))))):null})),F=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,l=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,l?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(E,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),B=o((function(e){var t=e.vm,o=u().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,s(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),G=o((function(e){var t,o=e.vm,a=u().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(h,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,s(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),V=o((function(o){var a=o.vm,c=o.isAddingCoupon,i=o.setAddingCoupon,s=o.setCouponError,m=o.setCouponErrorCode,E=o.isOpenCouponCode,C=o.isMobile,v=o.showOnlyMobile,h=u().t,f=n.useState(""),N=f[0],T=f[1],P=n.useState(!1),O=P[0],b=P[1],I=n.useRef(null);n.useEffect((function(){c&&I.current&&I.current.focus()}),[c]);var L=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=N,b(!0),[4,a.onCouponCodeApply(!0)];case 1:return t.sent(),b(!1),T(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(s(!1),m(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,s(!0),m(a.couponError),t.label=5;case 5:return[2]}}))}))},_=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return b(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},x=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return b(!0),[4,a.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},A=a.step===r.SUCCESS,j=a.step===r.SHIPPING,D=A&&!!(a.checkout.loyaltyLines&&a.checkout.loyaltyLines.length>0),R=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0)||D,U=!!a.checkout.appliedCouponCode&&E,M=!c&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==r.SUCCESS,w=R&&(!E||C),F=!!E&&!(a.checkout.createdBy===S.UPSELL||a.checkout.createdBy===S.ADMIN)&&!a.isOpenEditOrderWithTransaction;return n.createElement(n.Fragment,null,F&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:y.FormSectionTitle},n.createElement("div",{style:{paddingBottom:U?0:6},className:y.Title},h("checkout-page:couponCode"))))),R&&!j&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:M?g.InfoRow:""},M&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},h("checkout-page:addCouponCode")),c&&!E&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(l,{value:N,placeholder:h("checkout-page:couponCode"),buttonLabel:h("checkout-page:actions.apply"),inputRef:I,onClick:L,isLoading:O,onChange:T})),F&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&L()},className:[g.OpenCouponCodeMain,w?g.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{name:"couponCode",label:h("checkout-page:addCouponCode"),type:p.TEXT,value:N,onChange:T}),n.createElement(k,{style:{width:"33%"},text:h("checkout-page:actions.apply"),isLoading:O,onClick:L}))),w&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[g.InfoRow,v?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(X,{vm:a,onClearCouponCode: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,b(!0),[4,a.onCouponCodeApply(!1)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),b(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,v?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(X,{vm:a,onClearGiftCode:_,couponCode:e.code,giftCardLine:e}))})),D&&a.checkout.loyaltyLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,v?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(H,{vm:a,onClearLoyaltyPoints:x,loyaltyPointsLine:e}))}))))})),X=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,l=e.giftCardLine,c=e.onClearGiftCode,i=t.checkout.couponAdjustment,m=u().t,d=!l,p=(null==l?void 0:l.type)===T.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},l&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(I,null)),n.createElement("span",{className:g.StoreCreditTag},m("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[g.AppliedCoupon,t.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(O,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:g.CouponCode},a),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return l?c&&c(l.giftCardId):o&&o()}},n.createElement(v,null)))),n.createElement("div",null,l?n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==l?void 0:l.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),H=o((function(e){var t,o,a=e.vm,l=e.onClearLoyaltyPoints,c=e.loyaltyPointsLine,i=null===(t=a.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===c.id})),m=u().t,d=null===(o=a.loyaltySpendingMethodsAll)||void 0===o?void 0:o.find((function(e){return e.id===c.loyaltySpendingMethodId})),p=function(){return d?d.type===A.FREE_PRODUCT?{icon:n.createElement(L,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:d.type===A.FREE_SHIPPING?{icon:n.createElement(_,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:n.createElement(x,null),title:m("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)})}:{icon:n.createElement(x,null),title:m("checkout-page:loyaltyPoints")}};return n.createElement(n.Fragment,null,n.createElement("div",{className:g.LoyaltyPointsLineContainer},n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},n.createElement("span",{className:[g.AppliedCouponLoyalty,a.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("div",{style:{width:"16px",height:"16px"},className:g.LoyaltyPointsLineIcon},p().icon),n.createElement("span",{className:g.CouponCode},p().title),a.step!==r.SUCCESS&&!a.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCouponLoyalty,onClick:function(){return l&&l(c.loyaltySpendingMethodId)}},n.createElement(v,null)))),n.createElement("span",{className:g.LoyaltyPointSpending},"(",m("checkout-page:loyaltyPointSpending",{point:c.amount}),")")),d?d.type!==A.FREE_PRODUCT&&d.type!==A.FREE_SHIPPING?n.createElement("div",null,n.createElement("div",{className:g.ValueLoyalty},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))):null:n.createElement("div",null,n.createElement("div",{className:g.ValueLoyalty},n.createElement("span",null,"-")," ",n.createElement("span",null,s((null==i?void 0:i.amount)||0,a.checkout.currencyCode,a.checkout.currencySymbol)))))})),W=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,l=u().t,c=n.useState(t.checkout.note?l("checkout-page:editOrderNote"):l("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),s=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},c),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},l("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s,maxLength:320})))}));export{w as CartSummary,V as Coupon,M as CouponErrorCode};
@@ -3,6 +3,14 @@ import CheckoutViewModel from "../../../model";
3
3
  /** Points are always whole numbers written in tr-TR format ("1.250"). */
4
4
  export declare const formatPoint: (value: number) => string;
5
5
  export declare const isLoyaltyBlockVisible: (vm: CheckoutViewModel) => boolean;
6
+ /**
7
+ * Warns when points applied to the cart (from the widget or this page) were
8
+ * dropped by the backend, e.g. a campaign in the cart won over the points.
9
+ * It does not depend on the points block being enabled.
10
+ */
11
+ export declare const LoyaltyDroppedWarning: React.FC<{
12
+ vm: CheckoutViewModel;
13
+ }>;
6
14
  export declare const LoyaltyEarningRow: React.FC<{
7
15
  vm: CheckoutViewModel;
8
16
  }>;
@@ -1 +1 @@
1
- import{__spreadArray as e,__awaiter as t,__generator as n,__assign as o}from'./../../../../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as a}from"mobx-react-lite";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{LoyaltyProgramMethodSpendingTypeEnum as r,searchProducts as s,useLoyaltyPoints as d}from"@ikas/storefront-api";import{IkasCartCreatedBy as c}from"@ikas/storefront-models";import{CheckoutStep as u}from"../../../model.js";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import{IkasCheckout as m}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"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/customer-form-data-input/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import{IkasImage as p}from"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/region/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/order-transaction-with-prices/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../../../models/data/storefront-popup/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/ikas-address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatCurrency as y}from"../../../../../utils/currency.js";import{useTranslation as v}from"../../../../../utils/i18n.js";import{Button as f}from"../../button/index.js";import g from"../../input-with-button/index.js";import h from"../../svg/cross.js";import{SVGLoyaltyGift as x,SVGLoyaltyBox as k,SVGLoyaltyTag as E}from"./icons.js";import j from"../../svg/star-loyalty.js";import I from"./style.module.scss.js";var S=new Intl.NumberFormat("tr-TR",{maximumFractionDigits:0}),P=function(e){return S.format(Math.floor(e||0))},C=function(e){var t=Math.abs(Math.floor(e)),n=P(t),o="'in";if(0===t)o="'ın";else if(t%1e6==0)o="'un";else if(t%1e3==0)o="'in";else if(t%100==0)o="'ün";else if(t%10==0){o={1:"'un",2:"'nin",3:"'un",4:"'ın",5:"'nin",6:"'ın",7:"'in",8:"'in",9:"'ın"}[t/10%10]}else{o={1:"'in",2:"'nin",3:"'ün",4:"'ün",5:"'in",6:"'nın",7:"'nin",8:"'in",9:"'un"}[t%10]}return n+o},N=function(e){switch(e.type){case r.FREE_PRODUCT:return"GIFT";case r.FREE_SHIPPING:return"SHIPPING";case r.RATIO:return"RATIO";default:return e.isDynamic?"DYNAMIC":"FIXED"}},M=function(e,t){var n,o,i,a,l,r=(null===(n=e.discountSettings)||void 0===n?void 0:n.point)||1,s=null!==(i=null===(o=e.pointUsageLimit)||void 0===o?void 0:o.minPointLimit)&&void 0!==i?i:r,d=Math.min(null!==(l=null===(a=e.pointUsageLimit)||void 0===a?void 0:a.maxPointLimit)&&void 0!==l?l:t,t);return{step:r,min:s,max:Math.max(Math.floor(d/r)*r,0)}},b=function(e){var t=e.kind;return"GIFT"===t?i.createElement(x,null):"SHIPPING"===t?i.createElement(k,null):i.createElement(E,null)},T=function(e){var t,n,o;return!(e.step===u.SUCCESS||!(null===(t=e.customizationProps)||void 0===t?void 0:t.showLoyaltyPoints)||!e.loyaltyCustomerInfo||!(null===(n=e.loyaltySpendingMethods)||void 0===n?void 0:n.length)&&!(null===(o=e.checkout.loyaltyLines)||void 0===o?void 0:o.length)||e.isOpenEditOrderWithTransaction||e.checkout.createdBy===c.UPSELL||e.checkout.createdBy===c.ADMIN)},A=a((function(e){var t,n,o=e.vm,a=v().t,r=o.loyaltyEarningMethod,s=o.loyaltyCustomerInfo;if(!r||!s)return null;var d,c,u,m=r.amountPerPointsEarned||1,p=Math.floor(r.pointsEarned/m*(o.finalPrice||0)),f=s.customerTier,g=l.getCurrentLocale(),h=(f?(null===(n=null===(t=f.translations)||void 0===t?void 0:t.find((function(e){return e.locale===g})))||void 0===n?void 0:n.name)||f.name:null)||a("checkout-page:loyaltyEarnRule",{amount:y(m,o.checkout.currencyCode,o.checkout.currencySymbol),point:P(r.pointsEarned)});return i.createElement("div",{className:I.EarningRow},i.createElement("div",{className:I.EarningRowLeft},i.createElement("span",{className:I.StarIcon},i.createElement(j,null)),i.createElement("span",null,(d=a("checkout-page:loyaltyEarnTitle"),c="".concat(P(p)," ").concat(a("checkout-page:loyaltyPoint")),(u=d.split("{{value}}")).length<2?d:i.createElement(i.Fragment,null,u[0],i.createElement("strong",null,c),u.slice(1).join(c))))),i.createElement("span",{className:I.SecondaryText},h))})),L=a((function(a){var c,g,x,k,E=a.vm,S=v().t,C=i.useState(null),T=C[0],A=C[1],L=i.useState(null),F=L[0],R=L[1],w=i.useState(null),G=w[0],O=w[1],B=i.useState([]),U=B[0],H=B[1],V=i.useState(null),Y=V[0],z=V[1],X=E.isLoyaltyPointsVisible,_=Math.floor(null!==(g=null===(c=E.loyaltyCustomerInfo)||void 0===c?void 0:c.totalPoint)&&void 0!==g?g:0),W=E.checkout.loyaltyLines||[],$=W.map((function(e){return e.loyaltySpendingMethodId})),q=E.step!==u.SUCCESS&&!E.isOpenEditOrderWithTransaction,J=function(e){return y(e,E.checkout.currencyCode,E.checkout.currencySymbol)},K=function(e){return"".concat(P(e)," ").concat(S("checkout-page:loyaltyPoint"))},Q=i.useMemo((function(){var t=(E.loyaltySpendingMethods||[]).filter((function(e){return!$.includes(e.id)})),n=[],o=[];if(t.forEach((function(e){var t,i=N(e);if("GIFT"!==i){var a="DYNAMIC"===i?M(e,_).min:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0;n.push({key:e.id,kind:i,methods:[e],minCost:a,maxCost:a,isDisabled:_<a,missingPoint:Math.max(a-_,0)})}else o.push(e)})),o.length){var i=o.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0})),a=Math.min.apply(Math,i);n.push({key:"GIFT",kind:"GIFT",methods:o,minCost:a,maxCost:Math.max.apply(Math,i),isDisabled:_<a,missingPoint:Math.max(a-_,0)})}return e(e([],n.filter((function(e){return!e.isDisabled})),!0),n.filter((function(e){return e.isDisabled})),!0)}),[E.loyaltySpendingMethods,$.join(","),_]),Z=Q.filter((function(e){return!e.isDisabled})),ee=1===Q.length&&1===Z.length?Q[0]:null,te=q&&Q.length>0&&(Z.length>0||0===W.length);i.useEffect((function(){!te&&X&&E.setIsLoyaltyPointsVisible(!1)}),[te,X]),i.useEffect((function(){T&&!Q.some((function(e){return e.key===T}))&&A(null)}),[Q,T]),i.useEffect((function(){z(null)}),[T,X]);var ne=i.useMemo((function(){return(E.loyaltySpendingMethodsAll||E.loyaltySpendingMethods||[]).filter((function(e){return e.type===r.FREE_PRODUCT}))}),[E.loyaltySpendingMethodsAll,E.loyaltySpendingMethods]),oe=ne.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})).filter(Boolean).join(",");i.useEffect((function(){if(oe){var e=!1;return t(void 0,void 0,void 0,(function(){var t,o,i,a,r;return n(this,(function(n){switch(n.label){case 0:return t=oe.split(","),[4,s({input:{productIdList:t,page:1,perPage:t.length,priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}},[])];case 1:return o=n.sent(),e||(i=(null===(r=o.data)||void 0===r?void 0:r.data)||[],a=[],ne.forEach((function(e){var t,n,o,l,r,s,d,c,u,m,y,v=i.find((function(t){var n;return t.id===(null===(n=e.discountSettings)||void 0===n?void 0:n.freeProductId)}));if(v){var f=(null===(t=v.variants)||void 0===t?void 0:t.find((function(t){var n;return t.id===(null===(n=e.discountSettings)||void 0===n?void 0:n.freeProductVariantId)})))||(null===(n=v.variants)||void 0===n?void 0:n[0]),g=(null===(r=null===(l=null===(o=null==f?void 0:f.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===l?void 0:l.image)||void 0===r?void 0:r.id)||(null===(c=null===(d=null===(s=null==f?void 0:f.images)||void 0===s?void 0:s[0])||void 0===d?void 0:d.image)||void 0===c?void 0:c.id)||null,h=null===(u=null==f?void 0:f.prices)||void 0===u?void 0:u[0];a.push({id:e.id,name:v.name,imageSrc:g?new p({id:g,isVideo:!1}).thumbnailSrc:null,price:h&&null!==(y=null!==(m=h.discountPrice)&&void 0!==m?m:h.sellPrice)&&void 0!==y?y:null,method:e})}})),H(a)),[2]}}))})),function(){e=!0}}}),[oe]);var ie=function(e,i,a){return t(void 0,void 0,void 0,(function(){var t,l,r;return n(this,(function(n){switch(n.label){case 0:if(F)return[2,!1];R(i),z(null),n.label=1;case 1:return n.trys.push([1,,7,8]),[4,d({input:o({cartId:E.checkout.id,loyaltyProgramId:e.loyaltyProgramId,loyaltySpendingMethodId:e.id},a?{amount:a}:{})})];case 2:return(t=n.sent()).isSuccess&&t.data?(l=!!(null===(r=t.data.loyaltyLines)||void 0===r?void 0:r.some((function(t){return t.loyaltySpendingMethodId===e.id}))),E.checkout=new m(o(o({},t.data),{shippingAddress:E.checkout.shippingAddress,billingAddress:E.checkout.billingAddress,customer:E.checkout.customer,selectedPaymentGateway:E.checkout.selectedPaymentGateway}),E.countrySettings),[4,E.getLoyaltyCustomerInfo()]):[3,6];case 3:return n.sent(),[4,E.listSpendingMethodsByCartId()];case 4:return n.sent(),[4,E.reInitPaymentMethod()];case 5:return n.sent(),l?(A(null),E.setIsLoyaltyPointsVisible(!1),[2,!0]):(z(e.id),[2,!1]);case 6:return[2,!1];case 7:return R(null),[7];case 8:return[2]}}))}))},ae=function(e){var t;return(E.checkout.totalPrice||0)*((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0)/100},le=function(e){var t=Y&&e.methods.some((function(e){return e.id===Y}))?S("checkout-page:loyaltyErrorNotApplied"):null;return"DYNAMIC"===e.kind?re(e,t):i.createElement(i.Fragment,null,re(e,null),!!t&&i.createElement("span",{className:I.ErrorText},t))},re=function(t,n){var o,a=t.methods[0];if("DYNAMIC"===t.kind)return i.createElement(D,{vm:E,method:a,balance:_,isLoading:F===t.key,applyError:n,onEdit:function(){return z(null)},onApply:function(e){return ie(a,t.key,e)}});if("GIFT"===t.kind){var l=U.filter((function(e){return t.methods.some((function(t){return t.id===e.method.id}))})),r=e(e([],l.filter((function(e){var t;return((null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0)<=_})),!0),l.filter((function(e){var t;return((null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0)>_})),!0);return i.createElement("div",{className:I.GiftList},r.map((function(e){var t,n=(null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0,o=n>_;return i.createElement("div",{key:e.id,className:[I.GiftRow,o?I.GiftRowDisabled:""].join(" ")},i.createElement("div",{className:I.GiftImage},!!e.imageSrc&&i.createElement("img",{src:e.imageSrc,alt:e.name})),i.createElement("div",{className:I.GiftInfo},i.createElement("span",{className:I.GiftName},e.name),i.createElement("span",{className:I.SecondaryText},K(n),null!==e.price&&i.createElement(i.Fragment,null," · ",i.createElement("s",null,J(e.price))),o&&" · ".concat(S("checkout-page:loyaltyMissingPoints",{point:P(n-_)})))),i.createElement(f,{size:"medium",classes:I.SmallButton,isDisabled:o,isLoading:F===e.id,text:S("checkout-page:loyaltyPointsLineItemButtonAddFree"),onClick:function(){return ie(e.method,e.id)}}))})))}var s="SHIPPING"===t.kind?S("checkout-page:loyaltyApplyFreeShipping"):S("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:J("RATIO"===t.kind?ae(a):(null===(o=a.discountSettings)||void 0===o?void 0:o.discountAmount)||0)});return i.createElement(f,{size:"medium",style:{width:"100%"},isLoading:F===t.key,text:s,onClick:function(){return ie(a,t.key)}})},se="DYNAMIC"===(null==ee?void 0:ee.kind)?ee.methods[0]:null;return i.createElement("div",{className:I.LoyaltyBlock},i.createElement("div",{className:I.BalanceRow},i.createElement("div",{className:I.BalanceText},i.createElement("span",{className:I.StarIcon},i.createElement(j,null)),i.createElement("span",null,i.createElement("span",{className:I.SecondaryText},W.length?S("checkout-page:loyaltyRemainingBalance"):S("checkout-page:loyaltyBalance"))," ",i.createElement("strong",null,K(_)),!!se&&i.createElement("span",{className:I.SecondaryText}," · ",S("checkout-page:loyaltyRateRule",{point:P((null===(x=se.discountSettings)||void 0===x?void 0:x.point)||0),amount:J((null===(k=se.discountSettings)||void 0===k?void 0:k.discountAmount)||0)})))),te&&i.createElement(f,{isLine:!0,size:"medium",classes:I.UseButton,text:S(X?"checkout-page:actions.cancel":"checkout-page:loyaltyUse"),onClick:function(){X&&A(null),E.setIsLoyaltyPointsVisible(!X)}})),X&&te&&!!ee&&i.createElement("div",{className:I.SingleContent},le(ee)),X&&te&&!ee&&i.createElement("div",{className:I.OptionList},Q.map((function(e){var t=T===e.key;return i.createElement("div",{key:e.key,className:[I.OptionCard,t?I.OptionCardSelected:"",e.isDisabled?I.OptionCardDisabled:""].join(" ")},i.createElement("div",{className:I.OptionHeader,onClick:function(){return e.isDisabled||t?void 0:A(e.key)}},i.createElement("span",{className:I.Radio}),i.createElement("span",{className:I.IconBox},i.createElement(b,{kind:e.kind})),i.createElement("div",{className:I.TextColumn},i.createElement("span",{className:I.PrimaryText},function(e){var t,n=(null===(t=e.methods[0].discountSettings)||void 0===t?void 0:t.discountAmount)||0;switch(e.kind){case"DYNAMIC":return S("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount");case"FIXED":return S("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:J(n)});case"SHIPPING":return S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping");case"RATIO":return"".concat(S("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat(n,")");case"GIFT":return S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")}}(e)),i.createElement("span",{className:I.SecondaryText},e.isDisabled?S("checkout-page:loyaltyMissingPoints",{point:P(e.missingPoint)}):function(e){var t,n,o=e.methods[0],i=(null===(t=o.discountSettings)||void 0===t?void 0:t.discountAmount)||0;switch(e.kind){case"DYNAMIC":return S("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:P((null===(n=o.discountSettings)||void 0===n?void 0:n.point)||0),amount:J(i)});case"FIXED":return S("checkout-page:loyaltyCardFixedDescription",{amount:J(i)});case"SHIPPING":return S("checkout-page:loyaltyCardFreeShippingDescription");case"RATIO":return S("checkout-page:loyaltyCardRatioDescription",{ratio:String(i),amount:J(ae(o))});case"GIFT":return S("checkout-page:loyaltyCardFreeProductDescription",{count:String(e.methods.length)})}}(e))),i.createElement("span",{className:[I.Cost,I.SecondaryText].join(" ")},function(e){return"DYNAMIC"===e.kind?S("checkout-page:loyaltyCardDynamicCost",{point:P(e.minCost)}):"GIFT"===e.kind&&e.minCost!==e.maxCost?"".concat(P(e.minCost)," ~ ").concat(K(e.maxCost)):K(e.minCost)}(e))),t&&i.createElement("div",{className:I.OptionContent},le(e)))}))),!!W.length&&i.createElement("div",{className:I.AppliedList},W.map((function(e){var o,a,l,r,s,d,c=null===(o=E.loyaltySpendingMethodsAll)||void 0===o?void 0:o.find((function(t){return t.id===e.loyaltySpendingMethodId})),u=null===(a=E.checkout.nonCouponAdjustments)||void 0===a?void 0:a.find((function(t){return t.campaignId===e.id})),m=c?N(c):"FIXED",p=(null==u?void 0:u.amount)||0,y="",v=null;if("GIFT"===m){var f=null===(l=null==c?void 0:c.discountSettings)||void 0===l?void 0:l.freeProductId,g=(null===(r=E.checkout.items.find((function(e){return e.variant.productId===f})))||void 0===r?void 0:r.variant.name)||(null===(s=U.find((function(e){return e.method.id===(null==c?void 0:c.id)})))||void 0===s?void 0:s.name);y=g?S("checkout-page:loyaltyAppliedGiftTitle",{name:g}):S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),v=p?i.createElement("span",{className:I.DiscountValue},"- ",J(p)):i.createElement("span",null,S("checkout-page:free"))}else"SHIPPING"===m?(y=S("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),v=i.createElement("span",null,S("checkout-page:loyaltyAppliedShippingFree"))):(y="RATIO"===m?S("checkout-page:loyaltyAppliedRatioTitle",{ratio:String((null===(d=null==c?void 0:c.discountSettings)||void 0===d?void 0:d.discountAmount)||0)}):S("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:J(p)}),v=i.createElement("span",{className:I.DiscountValue},"- ",J(p)));return i.createElement("div",{key:e.id,className:I.AppliedRow},i.createElement("span",{className:I.IconBox},i.createElement(b,{kind:m})),i.createElement("div",{className:I.TextColumn},i.createElement("span",{className:I.PrimaryText},y),i.createElement("span",{className:I.SecondaryText},S("checkout-page:loyaltyAppliedPointsUsed",{point:P(e.amount)}))),i.createElement("div",{className:I.AppliedValue},v,q&&i.createElement("span",{className:[I.RemoveIcon,G===e.loyaltySpendingMethodId?I.RemoveIconLoading:""].join(" "),onClick:function(){return o=e.loyaltySpendingMethodId,t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:if(G)return[2];O(o),e.label=1;case 1:return e.trys.push([1,,4,5]),[4,E.removeLoyaltyPointsFromCart(o)];case 2:return e.sent(),[4,E.reInitPaymentMethod()];case 3:return e.sent(),[3,5];case 4:return O(null),[7];case 5:return[2]}}))}));var o}},i.createElement(h,null))))}))))})),D=a((function(e){var o,a=e.vm,l=e.method,r=e.balance,s=e.isLoading,d=e.applyError,c=e.onEdit,u=e.onApply,m=v().t,p=i.useState(""),f=p[0],h=p[1],x=i.useState(null),k=x[0],E=x[1],j=i.useRef(null);i.useEffect((function(){var e;null===(e=j.current)||void 0===e||e.focus()}),[]);var S,N=M(l,r),b=N.step,T=N.min,A=N.max,L=(null===(o=l.discountSettings)||void 0===o?void 0:o.discountAmount)||0,D=function(e){return y(e,a.checkout.currencyCode,a.checkout.currencySymbol)},F=(S=f.replace(/[.\s]/g,""))&&/^\d+$/.test(S)?parseInt(S,10):null,R=null!==F&&F>0?m("checkout-page:loyaltyDynamicPreview",{point:P(F),amount:D(F/b*L)}):"".concat(m("checkout-page:loyaltyDynamicRule",{min:P(T),max:P(A)})," · ").concat(m("checkout-page:loyaltyRateRule",{point:P(b),amount:D(L)}));return i.createElement("div",{className:I.DynamicInput},i.createElement(g,{value:f,inputRef:j,placeholder:m("checkout-page:loyaltyDynamicPlaceholder"),buttonLabel:m("checkout-page:actions.apply"),isLoading:s,onChange:function(e){h(e),k&&E(null),null==c||c()},onClick:function(){return t(void 0,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return s?[2]:(e=function(e){if(null===e)return m("checkout-page:loyaltyErrorEmpty");if(e<T)return m("checkout-page:loyaltyErrorMin",{min:P(T)});if(e>A)return m("checkout-page:loyaltyErrorMax",{max:P(A)});if(e%b!=0){var t=Math.min(Math.max(Math.floor(e/b)*b,T),A);return m("checkout-page:loyaltyErrorStep",{point:P(b),pointWithSuffix:C(b),example:P(t)})}return null}(F),E(e),e||null===F?[2]:[4,u(F)]);case 1:return t.sent(),[2]}}))}))}}),i.createElement("div",{className:I.HintRow},i.createElement("span",{className:k||d?I.ErrorText:I.SecondaryText},k||d||R),A>=T&&i.createElement("span",{className:I.TextLink,onClick:function(){h(P(A)),E(null)}},m("checkout-page:loyaltyUseAll"))))}));export{A as LoyaltyEarningRow,L as LoyaltyPointsBlock,P as formatPoint,T as isLoyaltyBlockVisible};
1
+ import{__spreadArray as e,__awaiter as t,__generator as n,__assign as o}from'./../../../../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as a}from"mobx-react-lite";import{IkasStorefrontConfig as r}from"@ikas/storefront-config";import{LoyaltyProgramMethodSpendingTypeEnum as l,searchProducts as s,useLoyaltyPoints as d}from"@ikas/storefront-api";import{IkasCartCreatedBy as c,IkasLoyaltyLineErrorCode as u}from"@ikas/storefront-models";import{CheckoutStep as m}from"../../../model.js";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import{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"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/address/ikas-localized-customer-address.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/customer-form-data-input/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import{IkasImage as y}from"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/region/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/order-transaction-with-prices/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/campaign-offer/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/stock-location/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/shipping-zone/state/city/district/region/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../../../models/data/storefront-popup/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/component/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/ikas-address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatCurrency as v}from"../../../../../utils/currency.js";import{useTranslation as f}from"../../../../../utils/i18n.js";import{Button as g}from"../../button/index.js";import h from"../../notification-box/index.js";import k from"../../input-with-button/index.js";import x from"../../svg/cross.js";import{SVGLoyaltyGift as E,SVGLoyaltyBox as j,SVGLoyaltyTag as I}from"./icons.js";import S from"../../svg/star-loyalty.js";import C from"./style.module.scss.js";var P=new Intl.NumberFormat("tr-TR",{maximumFractionDigits:0}),N=function(e){return P.format(Math.floor(e||0))},M=function(e){var t=Math.abs(Math.floor(e)),n=N(t),o="'in";if(0===t)o="'ın";else if(t%1e6==0)o="'un";else if(t%1e3==0)o="'in";else if(t%100==0)o="'ün";else if(t%10==0){o={1:"'un",2:"'nin",3:"'un",4:"'ın",5:"'nin",6:"'ın",7:"'in",8:"'in",9:"'ın"}[t/10%10]}else{o={1:"'in",2:"'nin",3:"'ün",4:"'ün",5:"'in",6:"'nın",7:"'nin",8:"'in",9:"'un"}[t%10]}return n+o},T=function(e){switch(e.type){case l.FREE_PRODUCT:return"GIFT";case l.FREE_SHIPPING:return"SHIPPING";case l.RATIO:return"RATIO";default:return e.isDynamic?"DYNAMIC":"FIXED"}},L=function(e,t){var n,o,i,a,r,l=(null===(n=e.discountSettings)||void 0===n?void 0:n.point)||1,s=null!==(i=null===(o=e.pointUsageLimit)||void 0===o?void 0:o.minPointLimit)&&void 0!==i?i:l,d=Math.min(null!==(r=null===(a=e.pointUsageLimit)||void 0===a?void 0:a.maxPointLimit)&&void 0!==r?r:t,t);return{step:l,min:s,max:Math.max(Math.floor(d/l)*l,0)}},b=function(e){var t=e.kind;return"GIFT"===t?i.createElement(E,null):"SHIPPING"===t?i.createElement(j,null):i.createElement(I,null)},A=function(e){switch(e.code){case u.LOYALTY_NOT_COMBINABLE_WITH_CAMPAIGN:return"checkout-page:loyaltyDroppedNotCombinableWithCampaign";case u.NOT_ENOUGH_LOYALTY_POINTS:return"checkout-page:loyaltyDroppedNotEnoughPoints";default:return"checkout-page:loyaltyDroppedNotApplicable"}},D=function(e){var t,n,o;return!(e.step===m.SUCCESS||!(null===(t=e.customizationProps)||void 0===t?void 0:t.showLoyaltyPoints)||!e.loyaltyCustomerInfo||!(null===(n=e.loyaltySpendingMethods)||void 0===n?void 0:n.length)&&!(null===(o=e.checkout.loyaltyLines)||void 0===o?void 0:o.length)||e.isOpenEditOrderWithTransaction||e.checkout.createdBy===c.UPSELL||e.checkout.createdBy===c.ADMIN)},w=a((function(e){var t=e.vm,n=f().t,o=i.useState(null),a=o[0],r=o[1];if(t.step===m.SUCCESS||t.isOpenEditOrderWithTransaction)return null;var l=function(e){var t;return(null===(t=e.checkout.loyaltyLines)||void 0===t?void 0:t.length)?[]:e.checkout.droppedLoyaltyLines||[]}(t),s=l.map((function(e){return"".concat(e.loyaltySpendingMethodId,":").concat(e.code)})).join(",");if(!s||a===s)return null;var d=Array.from(new Set(l.map(A)));return i.createElement("div",{className:C.DroppedWarning},i.createElement(h,{type:"warning",title:n("checkout-page:loyaltyDroppedTitle"),content:d.map((function(e){return n(e)})).join(" "),onClose:function(){return r(s)},ignoreScroll:!0}))})),F=a((function(e){var t,n,o=e.vm,a=f().t,l=o.loyaltyEarningMethod,s=o.loyaltyCustomerInfo;if(!l||!s)return null;var d,c,u,m=l.amountPerPointsEarned||1,p=Math.floor(l.pointsEarned/m*(o.finalPrice||0)),y=s.customerTier,g=r.getCurrentLocale(),h=(y?(null===(n=null===(t=y.translations)||void 0===t?void 0:t.find((function(e){return e.locale===g})))||void 0===n?void 0:n.name)||y.name:null)||a("checkout-page:loyaltyEarnRule",{amount:v(m,o.checkout.currencyCode,o.checkout.currencySymbol),point:N(l.pointsEarned)});return i.createElement("div",{className:C.EarningRow},i.createElement("div",{className:C.EarningRowLeft},i.createElement("span",{className:C.StarIcon},i.createElement(S,null)),i.createElement("span",null,(d=a("checkout-page:loyaltyEarnTitle"),c="".concat(N(p)," ").concat(a("checkout-page:loyaltyPoint")),(u=d.split("{{value}}")).length<2?d:i.createElement(i.Fragment,null,u[0],i.createElement("strong",null,c),u.slice(1).join(c))))),i.createElement("span",{className:C.SecondaryText},h))})),R=a((function(a){var c,u,h,k,E=a.vm,j=f().t,I=i.useState(null),P=I[0],M=I[1],A=i.useState(null),D=A[0],w=A[1],F=i.useState(null),R=F[0],O=F[1],B=i.useState([]),U=B[0],Y=B[1],H=i.useState(null),_=H[0],V=H[1],z=E.isLoyaltyPointsVisible,W=Math.floor(null!==(u=null===(c=E.loyaltyCustomerInfo)||void 0===c?void 0:c.totalPoint)&&void 0!==u?u:0),X=E.checkout.loyaltyLines||[],Q=X.map((function(e){return e.loyaltySpendingMethodId})),$=E.step!==m.SUCCESS&&!E.isOpenEditOrderWithTransaction,q=function(e){return v(e,E.checkout.currencyCode,E.checkout.currencySymbol)},J=function(e){return"".concat(N(e)," ").concat(j("checkout-page:loyaltyPoint"))},K=i.useMemo((function(){var t=(E.loyaltySpendingMethods||[]).filter((function(e){return!Q.includes(e.id)})),n=[],o=[];if(t.forEach((function(e){var t,i=T(e);if("GIFT"!==i){var a="DYNAMIC"===i?L(e,W).min:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0;n.push({key:e.id,kind:i,methods:[e],minCost:a,maxCost:a,isDisabled:W<a,missingPoint:Math.max(a-W,0)})}else o.push(e)})),o.length){var i=o.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0})),a=Math.min.apply(Math,i);n.push({key:"GIFT",kind:"GIFT",methods:o,minCost:a,maxCost:Math.max.apply(Math,i),isDisabled:W<a,missingPoint:Math.max(a-W,0)})}return e(e([],n.filter((function(e){return!e.isDisabled})),!0),n.filter((function(e){return e.isDisabled})),!0)}),[E.loyaltySpendingMethods,Q.join(","),W]),Z=K.filter((function(e){return!e.isDisabled})),ee=1===K.length&&1===Z.length?K[0]:null,te=$&&K.length>0&&(Z.length>0||0===X.length);i.useEffect((function(){!te&&z&&E.setIsLoyaltyPointsVisible(!1)}),[te,z]),i.useEffect((function(){P&&!K.some((function(e){return e.key===P}))&&M(null)}),[K,P]),i.useEffect((function(){V(null)}),[P,z]);var ne=i.useMemo((function(){return(E.loyaltySpendingMethodsAll||E.loyaltySpendingMethods||[]).filter((function(e){return e.type===l.FREE_PRODUCT}))}),[E.loyaltySpendingMethodsAll,E.loyaltySpendingMethods]),oe=ne.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})).filter(Boolean).join(",");i.useEffect((function(){if(oe){var e=!1;return t(void 0,void 0,void 0,(function(){var t,o,i,a,l;return n(this,(function(n){switch(n.label){case 0:return t=oe.split(","),[4,s({input:{productIdList:t,page:1,perPage:t.length,priceListId:r.getPriceListId(),salesChannelId:r.getSalesChannelId()}},[])];case 1:return o=n.sent(),e||(i=(null===(l=o.data)||void 0===l?void 0:l.data)||[],a=[],ne.forEach((function(e){var t,n,o,r,l,s,d,c,u,m,p,v=i.find((function(t){var n;return t.id===(null===(n=e.discountSettings)||void 0===n?void 0:n.freeProductId)}));if(v){var f=(null===(t=v.variants)||void 0===t?void 0:t.find((function(t){var n;return t.id===(null===(n=e.discountSettings)||void 0===n?void 0:n.freeProductVariantId)})))||(null===(n=v.variants)||void 0===n?void 0:n[0]),g=(null===(l=null===(r=null===(o=null==f?void 0:f.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===r?void 0:r.image)||void 0===l?void 0:l.id)||(null===(c=null===(d=null===(s=null==f?void 0:f.images)||void 0===s?void 0:s[0])||void 0===d?void 0:d.image)||void 0===c?void 0:c.id)||null,h=null===(u=null==f?void 0:f.prices)||void 0===u?void 0:u[0];a.push({id:e.id,name:v.name,imageSrc:g?new y({id:g,isVideo:!1}).thumbnailSrc:null,price:h&&null!==(p=null!==(m=h.discountPrice)&&void 0!==m?m:h.sellPrice)&&void 0!==p?p:null,method:e})}})),Y(a)),[2]}}))})),function(){e=!0}}}),[oe]);var ie=function(e,i,a){return t(void 0,void 0,void 0,(function(){var t,r,l,s,c;return n(this,(function(n){switch(n.label){case 0:if(D)return[2,!1];w(i),V(null),n.label=1;case 1:return n.trys.push([1,,12,13]),[4,d({input:o({cartId:E.checkout.id,loyaltyProgramId:e.loyaltyProgramId,loyaltySpendingMethodId:e.id},a?{amount:a}:{})})];case 2:return(t=n.sent()).isSuccess||!(null===(l=t.graphQLErrors)||void 0===l?void 0:l.length)?[3,7]:[4,E.refreshCheckoutCart()];case 3:return n.sent(),[4,E.getLoyaltyCustomerInfo()];case 4:return n.sent(),[4,E.listSpendingMethodsByCartId()];case 5:return n.sent(),[4,E.reInitPaymentMethod()];case 6:return n.sent(),!!(null===(s=E.checkout.droppedLoyaltyLines)||void 0===s?void 0:s.some((function(t){return t.loyaltySpendingMethodId===e.id})))||V(e.id),[2,!1];case 7:return t.isSuccess&&t.data?(r=!!(null===(c=t.data.loyaltyLines)||void 0===c?void 0:c.some((function(t){return t.loyaltySpendingMethodId===e.id}))),E.checkout=new p(o(o({},t.data),{shippingAddress:E.checkout.shippingAddress,billingAddress:E.checkout.billingAddress,customer:E.checkout.customer,selectedPaymentGateway:E.checkout.selectedPaymentGateway}),E.countrySettings),[4,E.getLoyaltyCustomerInfo()]):[3,11];case 8:return n.sent(),[4,E.listSpendingMethodsByCartId()];case 9:return n.sent(),[4,E.reInitPaymentMethod()];case 10:return n.sent(),r?(M(null),E.setIsLoyaltyPointsVisible(!1),[2,!0]):(V(e.id),[2,!1]);case 11:return[2,!1];case 12:return w(null),[7];case 13:return[2]}}))}))},ae=function(e){var t;return(E.checkout.totalPrice||0)*((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0)/100},re=function(e){var t=_&&e.methods.some((function(e){return e.id===_}))?j("checkout-page:loyaltyErrorNotApplied"):null;return"DYNAMIC"===e.kind?le(e,t):i.createElement(i.Fragment,null,le(e,null),!!t&&i.createElement("span",{className:C.ErrorText},t))},le=function(t,n){var o,a=t.methods[0];if("DYNAMIC"===t.kind)return i.createElement(G,{vm:E,method:a,balance:W,isLoading:D===t.key,applyError:n,onEdit:function(){return V(null)},onApply:function(e){return ie(a,t.key,e)}});if("GIFT"===t.kind){var r=U.filter((function(e){return t.methods.some((function(t){return t.id===e.method.id}))})),l=e(e([],r.filter((function(e){var t;return((null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0)<=W})),!0),r.filter((function(e){var t;return((null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0)>W})),!0);return i.createElement("div",{className:C.GiftList},l.map((function(e){var t,n=(null===(t=e.method.discountSettings)||void 0===t?void 0:t.point)||0,o=n>W;return i.createElement("div",{key:e.id,className:[C.GiftRow,o?C.GiftRowDisabled:""].join(" ")},i.createElement("div",{className:C.GiftImage},!!e.imageSrc&&i.createElement("img",{src:e.imageSrc,alt:e.name})),i.createElement("div",{className:C.GiftInfo},i.createElement("span",{className:C.GiftName},e.name),i.createElement("span",{className:C.SecondaryText},J(n),null!==e.price&&i.createElement(i.Fragment,null," · ",i.createElement("s",null,q(e.price))),o&&" · ".concat(j("checkout-page:loyaltyMissingPoints",{point:N(n-W)})))),i.createElement(g,{size:"medium",classes:C.SmallButton,isDisabled:o,isLoading:D===e.id,text:j("checkout-page:loyaltyPointsLineItemButtonAddFree"),onClick:function(){return ie(e.method,e.id)}}))})))}var s="SHIPPING"===t.kind?j("checkout-page:loyaltyApplyFreeShipping"):j("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:q("RATIO"===t.kind?ae(a):(null===(o=a.discountSettings)||void 0===o?void 0:o.discountAmount)||0)});return i.createElement(g,{size:"medium",style:{width:"100%"},isLoading:D===t.key,text:s,onClick:function(){return ie(a,t.key)}})},se="DYNAMIC"===(null==ee?void 0:ee.kind)?ee.methods[0]:null;return i.createElement("div",{className:C.LoyaltyBlock},i.createElement("div",{className:C.BalanceRow},i.createElement("div",{className:C.BalanceText},i.createElement("span",{className:C.StarIcon},i.createElement(S,null)),i.createElement("span",null,i.createElement("span",{className:C.SecondaryText},X.length?j("checkout-page:loyaltyRemainingBalance"):j("checkout-page:loyaltyBalance"))," ",i.createElement("strong",null,J(W)),!!se&&i.createElement("span",{className:C.SecondaryText}," · ",j("checkout-page:loyaltyRateRule",{point:N((null===(h=se.discountSettings)||void 0===h?void 0:h.point)||0),amount:q((null===(k=se.discountSettings)||void 0===k?void 0:k.discountAmount)||0)})))),te&&i.createElement(g,{isLine:!0,size:"medium",classes:C.UseButton,text:j(z?"checkout-page:actions.cancel":"checkout-page:loyaltyUse"),onClick:function(){z&&M(null),E.setIsLoyaltyPointsVisible(!z)}})),z&&te&&!!ee&&i.createElement("div",{className:C.SingleContent},re(ee)),z&&te&&!ee&&i.createElement("div",{className:C.OptionList},K.map((function(e){var t=P===e.key;return i.createElement("div",{key:e.key,className:[C.OptionCard,t?C.OptionCardSelected:"",e.isDisabled?C.OptionCardDisabled:""].join(" ")},i.createElement("div",{className:C.OptionHeader,onClick:function(){return e.isDisabled||t?void 0:M(e.key)}},i.createElement("span",{className:C.Radio}),i.createElement("span",{className:C.IconBox},i.createElement(b,{kind:e.kind})),i.createElement("div",{className:C.TextColumn},i.createElement("span",{className:C.PrimaryText},function(e){var t,n=(null===(t=e.methods[0].discountSettings)||void 0===t?void 0:t.discountAmount)||0;switch(e.kind){case"DYNAMIC":return j("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount");case"FIXED":return j("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:q(n)});case"SHIPPING":return j("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping");case"RATIO":return"".concat(j("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat(n,")");case"GIFT":return j("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")}}(e)),i.createElement("span",{className:C.SecondaryText},e.isDisabled?j("checkout-page:loyaltyMissingPoints",{point:N(e.missingPoint)}):function(e){var t,n,o=e.methods[0],i=(null===(t=o.discountSettings)||void 0===t?void 0:t.discountAmount)||0;switch(e.kind){case"DYNAMIC":return j("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:N((null===(n=o.discountSettings)||void 0===n?void 0:n.point)||0),amount:q(i)});case"FIXED":return j("checkout-page:loyaltyCardFixedDescription",{amount:q(i)});case"SHIPPING":return j("checkout-page:loyaltyCardFreeShippingDescription");case"RATIO":return j("checkout-page:loyaltyCardRatioDescription",{ratio:String(i),amount:q(ae(o))});case"GIFT":return j("checkout-page:loyaltyCardFreeProductDescription",{count:String(e.methods.length)})}}(e))),i.createElement("span",{className:[C.Cost,C.SecondaryText].join(" ")},function(e){return"DYNAMIC"===e.kind?j("checkout-page:loyaltyCardDynamicCost",{point:N(e.minCost)}):"GIFT"===e.kind&&e.minCost!==e.maxCost?"".concat(N(e.minCost)," ~ ").concat(J(e.maxCost)):J(e.minCost)}(e))),t&&i.createElement("div",{className:C.OptionContent},re(e)))}))),!!X.length&&i.createElement("div",{className:C.AppliedList},X.map((function(e){var o,a,r,l,s,d,c=null===(o=E.loyaltySpendingMethodsAll)||void 0===o?void 0:o.find((function(t){return t.id===e.loyaltySpendingMethodId})),u=null===(a=E.checkout.nonCouponAdjustments)||void 0===a?void 0:a.find((function(t){return t.campaignId===e.id})),m=c?T(c):"FIXED",p=(null==u?void 0:u.amount)||0,y="",v=null;if("GIFT"===m){var f=null===(r=null==c?void 0:c.discountSettings)||void 0===r?void 0:r.freeProductId,g=(null===(l=E.checkout.items.find((function(e){return e.variant.productId===f})))||void 0===l?void 0:l.variant.name)||(null===(s=U.find((function(e){return e.method.id===(null==c?void 0:c.id)})))||void 0===s?void 0:s.name);y=g?j("checkout-page:loyaltyAppliedGiftTitle",{name:g}):j("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),v=p?i.createElement("span",{className:C.DiscountValue},"- ",q(p)):i.createElement("span",null,j("checkout-page:free"))}else"SHIPPING"===m?(y=j("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),v=i.createElement("span",null,j("checkout-page:loyaltyAppliedShippingFree"))):(y="RATIO"===m?j("checkout-page:loyaltyAppliedRatioTitle",{ratio:String((null===(d=null==c?void 0:c.discountSettings)||void 0===d?void 0:d.discountAmount)||0)}):j("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:q(p)}),v=i.createElement("span",{className:C.DiscountValue},"- ",q(p)));return i.createElement("div",{key:e.id,className:C.AppliedRow},i.createElement("span",{className:C.IconBox},i.createElement(b,{kind:m})),i.createElement("div",{className:C.TextColumn},i.createElement("span",{className:C.PrimaryText},y),i.createElement("span",{className:C.SecondaryText},j("checkout-page:loyaltyAppliedPointsUsed",{point:N(e.amount)}))),i.createElement("div",{className:C.AppliedValue},v,$&&i.createElement("span",{className:[C.RemoveIcon,R===e.loyaltySpendingMethodId?C.RemoveIconLoading:""].join(" "),onClick:function(){return o=e.loyaltySpendingMethodId,t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:if(R)return[2];O(o),e.label=1;case 1:return e.trys.push([1,,4,5]),[4,E.removeLoyaltyPointsFromCart(o)];case 2:return e.sent(),[4,E.reInitPaymentMethod()];case 3:return e.sent(),[3,5];case 4:return O(null),[7];case 5:return[2]}}))}));var o}},i.createElement(x,null))))}))))})),G=a((function(e){var o,a=e.vm,r=e.method,l=e.balance,s=e.isLoading,d=e.applyError,c=e.onEdit,u=e.onApply,m=f().t,p=i.useState(""),y=p[0],g=p[1],h=i.useState(null),x=h[0],E=h[1],j=i.useRef(null);i.useEffect((function(){var e;null===(e=j.current)||void 0===e||e.focus()}),[]);var I,S=L(r,l),P=S.step,T=S.min,b=S.max,A=(null===(o=r.discountSettings)||void 0===o?void 0:o.discountAmount)||0,D=function(e){return v(e,a.checkout.currencyCode,a.checkout.currencySymbol)},w=(I=y.replace(/[.\s]/g,""))&&/^\d+$/.test(I)?parseInt(I,10):null,F=null!==w&&w>0?m("checkout-page:loyaltyDynamicPreview",{point:N(w),amount:D(w/P*A)}):"".concat(m("checkout-page:loyaltyDynamicRule",{min:N(T),max:N(b)})," · ").concat(m("checkout-page:loyaltyRateRule",{point:N(P),amount:D(A)}));return i.createElement("div",{className:C.DynamicInput},i.createElement(k,{value:y,inputRef:j,placeholder:m("checkout-page:loyaltyDynamicPlaceholder"),buttonLabel:m("checkout-page:actions.apply"),isLoading:s,onChange:function(e){g(e),x&&E(null),null==c||c()},onClick:function(){return t(void 0,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return s?[2]:(e=function(e){if(null===e)return m("checkout-page:loyaltyErrorEmpty");if(e<T)return m("checkout-page:loyaltyErrorMin",{min:N(T)});if(e>b)return m("checkout-page:loyaltyErrorMax",{max:N(b)});if(e%P!=0){var t=Math.min(Math.max(Math.floor(e/P)*P,T),b);return m("checkout-page:loyaltyErrorStep",{point:N(P),pointWithSuffix:M(P),example:N(t)})}return null}(w),E(e),e||null===w?[2]:[4,u(w)]);case 1:return t.sent(),[2]}}))}))}}),i.createElement("div",{className:C.HintRow},i.createElement("span",{className:x||d?C.ErrorText:C.SecondaryText},x||d||F),b>=T&&i.createElement("span",{className:C.TextLink,onClick:function(){g(N(b)),E(null)}},m("checkout-page:loyaltyUseAll"))))}));export{w as LoyaltyDroppedWarning,F as LoyaltyEarningRow,R as LoyaltyPointsBlock,N as formatPoint,D as isLoyaltyBlockVisible};
@@ -1 +1 @@
1
- import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var n={PrimaryText:"style-module_PrimaryText__HGpu6",SecondaryText:"style-module_SecondaryText__z9dmR",ErrorText:"style-module_ErrorText__r4c62",TextLink:"style-module_TextLink__xwg5z",StarIcon:"style-module_StarIcon__12tKJ",IconBox:"style-module_IconBox__lFMov",TextColumn:"style-module_TextColumn__vtGBb",EarningRow:"style-module_EarningRow__0QTAQ",EarningRowLeft:"style-module_EarningRowLeft__3OlOo",LoyaltyBlock:"style-module_LoyaltyBlock__MWvGo",BalanceRow:"style-module_BalanceRow__yVaQc",BalanceText:"style-module_BalanceText__SD-u6",UseButton:"style-module_UseButton__hL-Rh",SmallButton:"style-module_SmallButton__Styu6",SingleContent:"style-module_SingleContent__zlrTo",OptionList:"style-module_OptionList__repyQ",Radio:"style-module_Radio__XVGRg",OptionCard:"style-module_OptionCard__BGQPj",OptionHeader:"style-module_OptionHeader__JtkLp",Cost:"style-module_Cost__NLCD-",OptionContent:"style-module_OptionContent__KUmfq",OptionCardSelected:"style-module_OptionCardSelected__-TSjd",OptionCardDisabled:"style-module_OptionCardDisabled__vHjmn",DynamicInput:"style-module_DynamicInput__jh-g0",HintRow:"style-module_HintRow__6UPJ-",GiftList:"style-module_GiftList__xs6uv",GiftRow:"style-module_GiftRow__addVG",GiftRowDisabled:"style-module_GiftRowDisabled__7Ossr",GiftImage:"style-module_GiftImage__L8Qdn",GiftInfo:"style-module_GiftInfo__VAtS7",GiftName:"style-module_GiftName__hjiMJ",AppliedList:"style-module_AppliedList__yHMSJ",AppliedRow:"style-module_AppliedRow__6ePX6",AppliedValue:"style-module_AppliedValue__zM0fW",DiscountValue:"style-module_DiscountValue__PBnlU",RemoveIcon:"style-module_RemoveIcon__HQ26R",RemoveIconLoading:"style-module_RemoveIconLoading__iGIrr"};e(".style-module_PrimaryText__HGpu6 {\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_SecondaryText__z9dmR {\n font-size: 13px;\n line-height: 18px;\n color: var(--checkout-secondary-text-color);\n}\n\n.style-module_ErrorText__r4c62 {\n font-size: 16px;\n line-height: 20px;\n color: var(--checkout-error-color);\n}\n\n.style-module_TextLink__xwg5z {\n flex: 0 0 auto;\n font-size: 16px;\n line-height: 20px;\n color: var(--checkout-secondary-text-color);\n cursor: pointer;\n user-select: none;\n}\n.style-module_TextLink__xwg5z:hover {\n text-decoration: underline;\n}\n\n.style-module_StarIcon__12tKJ {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n color: var(--checkout-loyalty-icon-color);\n}\n\n.style-module_IconBox__lFMov {\n flex: 0 0 auto;\n width: 28px;\n height: 28px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 6px;\n background-color: var(--checkout-primary-bg-color);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_TextColumn__vtGBb {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.style-module_EarningRow__0QTAQ {\n margin-top: 16px;\n padding: 10px 16px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.style-module_EarningRow__0QTAQ .style-module_EarningRowLeft__3OlOo {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_EarningRow__0QTAQ .style-module_EarningRowLeft__3OlOo strong {\n font-weight: 600;\n}\n.style-module_EarningRow__0QTAQ .style-module_SecondaryText__z9dmR {\n flex: 0 0 auto;\n text-align: right;\n}\n\n.style-module_LoyaltyBlock__MWvGo {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin-bottom: 18px;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_LoyaltyBlock__MWvGo {\n margin-bottom: 0;\n margin-top: 16px;\n }\n}\n\n.style-module_BalanceRow__yVaQc {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 strong {\n font-weight: 600;\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 .style-module_SecondaryText__z9dmR {\n font-size: 16px;\n line-height: 24px;\n}\n\n.style-module_UseButton__hL-Rh {\n flex: 0 0 auto;\n height: 36px !important;\n padding: 0 16px !important;\n font-size: 14px;\n}\n\n.style-module_SmallButton__Styu6 {\n flex: 0 0 auto;\n height: 40px !important;\n padding: 0 16px !important;\n font-size: 14px;\n}\n\n.style-module_SingleContent__zlrTo {\n display: flex;\n flex-direction: column;\n}\n\n.style-module_OptionList__repyQ {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.style-module_Radio__XVGRg {\n flex: 0 0 auto;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n border: 1px solid var(--checkout-border-color);\n background-color: var(--checkout-primary-bg-color);\n box-sizing: border-box;\n transition: border-color 0.2s;\n}\n\n.style-module_OptionCard__BGQPj {\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n transition: border-color 0.2s;\n}\n.style-module_OptionCard__BGQPj .style-module_OptionHeader__JtkLp {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 14px;\n cursor: pointer;\n user-select: none;\n}\n.style-module_OptionCard__BGQPj .style-module_Cost__NLCD- {\n flex: 0 0 auto;\n text-align: right;\n}\n.style-module_OptionCard__BGQPj .style-module_OptionContent__KUmfq {\n padding: 0 14px 16px;\n}\n.style-module_OptionCard__BGQPj:hover:not(.style-module_OptionCardSelected__-TSjd):not(.style-module_OptionCardDisabled__vHjmn) {\n border-color: var(--checkout-secondary-text-color);\n}\n.style-module_OptionCard__BGQPj:hover:not(.style-module_OptionCardSelected__-TSjd):not(.style-module_OptionCardDisabled__vHjmn) .style-module_Radio__XVGRg {\n border-color: var(--checkout-secondary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd {\n border-color: var(--checkout-primary-text-color);\n box-shadow: 0 0 0 1px var(--checkout-primary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd .style-module_OptionHeader__JtkLp {\n cursor: default;\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd .style-module_Radio__XVGRg {\n border: 5px solid var(--checkout-primary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardDisabled__vHjmn {\n background-color: transparent;\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardDisabled__vHjmn .style-module_OptionHeader__JtkLp {\n cursor: default;\n opacity: 0.5;\n}\n\n.style-module_DynamicInput__jh-g0 {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.style-module_HintRow__6UPJ- {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 12px;\n}\n.style-module_HintRow__6UPJ- .style-module_SecondaryText__z9dmR {\n font-size: 16px;\n line-height: 20px;\n}\n\n.style-module_GiftList__xs6uv {\n display: flex;\n flex-direction: column;\n padding: 8px 0 4px;\n}\n\n.style-module_GiftRow__addVG {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 0;\n}\n.style-module_GiftRow__addVG + .style-module_GiftRow__addVG {\n border-top: 1px solid var(--checkout-border-color);\n}\n.style-module_GiftRow__addVG:first-child {\n padding-top: 0;\n}\n.style-module_GiftRow__addVG:last-child {\n padding-bottom: 0;\n}\n.style-module_GiftRow__addVG.style-module_GiftRowDisabled__7Ossr .style-module_GiftImage__L8Qdn,\n.style-module_GiftRow__addVG.style-module_GiftRowDisabled__7Ossr .style-module_GiftInfo__VAtS7 {\n opacity: 0.5;\n}\n\n.style-module_GiftImage__L8Qdn {\n flex: 0 0 auto;\n width: 44px;\n height: 44px;\n border-radius: 8px;\n overflow: hidden;\n background-color: var(--checkout-secondary-bg-color);\n}\n.style-module_GiftImage__L8Qdn img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.style-module_GiftInfo__VAtS7 {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n.style-module_GiftInfo__VAtS7 .style-module_GiftName__hjiMJ {\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_AppliedList__yHMSJ {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.style-module_AppliedRow__6ePX6 {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n}\n.style-module_AppliedRow__6ePX6 .style-module_AppliedValue__zM0fW {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_AppliedRow__6ePX6 .style-module_DiscountValue__PBnlU {\n color: var(--checkout-error-color);\n}\n\n.style-module_RemoveIcon__HQ26R {\n cursor: pointer;\n display: flex;\n align-items: center;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_RemoveIcon__HQ26R svg {\n width: 20px;\n height: 20px;\n transform: scale(0.8);\n}\n.style-module_RemoveIcon__HQ26R.style-module_RemoveIconLoading__iGIrr {\n pointer-events: none;\n opacity: 0.5;\n}");export{n as default};
1
+ import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var n={PrimaryText:"style-module_PrimaryText__HGpu6",SecondaryText:"style-module_SecondaryText__z9dmR",ErrorText:"style-module_ErrorText__r4c62",TextLink:"style-module_TextLink__xwg5z",StarIcon:"style-module_StarIcon__12tKJ",IconBox:"style-module_IconBox__lFMov",TextColumn:"style-module_TextColumn__vtGBb",EarningRow:"style-module_EarningRow__0QTAQ",EarningRowLeft:"style-module_EarningRowLeft__3OlOo",DroppedWarning:"style-module_DroppedWarning__WlZAR",LoyaltyBlock:"style-module_LoyaltyBlock__MWvGo",BalanceRow:"style-module_BalanceRow__yVaQc",BalanceText:"style-module_BalanceText__SD-u6",UseButton:"style-module_UseButton__hL-Rh",SmallButton:"style-module_SmallButton__Styu6",SingleContent:"style-module_SingleContent__zlrTo",OptionList:"style-module_OptionList__repyQ",Radio:"style-module_Radio__XVGRg",OptionCard:"style-module_OptionCard__BGQPj",OptionHeader:"style-module_OptionHeader__JtkLp",Cost:"style-module_Cost__NLCD-",OptionContent:"style-module_OptionContent__KUmfq",OptionCardSelected:"style-module_OptionCardSelected__-TSjd",OptionCardDisabled:"style-module_OptionCardDisabled__vHjmn",DynamicInput:"style-module_DynamicInput__jh-g0",HintRow:"style-module_HintRow__6UPJ-",GiftList:"style-module_GiftList__xs6uv",GiftRow:"style-module_GiftRow__addVG",GiftRowDisabled:"style-module_GiftRowDisabled__7Ossr",GiftImage:"style-module_GiftImage__L8Qdn",GiftInfo:"style-module_GiftInfo__VAtS7",GiftName:"style-module_GiftName__hjiMJ",AppliedList:"style-module_AppliedList__yHMSJ",AppliedRow:"style-module_AppliedRow__6ePX6",AppliedValue:"style-module_AppliedValue__zM0fW",DiscountValue:"style-module_DiscountValue__PBnlU",RemoveIcon:"style-module_RemoveIcon__HQ26R",RemoveIconLoading:"style-module_RemoveIconLoading__iGIrr"};e(".style-module_PrimaryText__HGpu6 {\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_SecondaryText__z9dmR {\n font-size: 13px;\n line-height: 18px;\n color: var(--checkout-secondary-text-color);\n}\n\n.style-module_ErrorText__r4c62 {\n font-size: 16px;\n line-height: 20px;\n color: var(--checkout-error-color);\n}\n\n.style-module_TextLink__xwg5z {\n flex: 0 0 auto;\n font-size: 16px;\n line-height: 20px;\n color: var(--checkout-secondary-text-color);\n cursor: pointer;\n user-select: none;\n}\n.style-module_TextLink__xwg5z:hover {\n text-decoration: underline;\n}\n\n.style-module_StarIcon__12tKJ {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n color: var(--checkout-loyalty-icon-color);\n}\n\n.style-module_IconBox__lFMov {\n flex: 0 0 auto;\n width: 28px;\n height: 28px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 6px;\n background-color: var(--checkout-primary-bg-color);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_TextColumn__vtGBb {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.style-module_EarningRow__0QTAQ {\n margin-top: 16px;\n padding: 10px 16px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.style-module_EarningRow__0QTAQ .style-module_EarningRowLeft__3OlOo {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_EarningRow__0QTAQ .style-module_EarningRowLeft__3OlOo strong {\n font-weight: 600;\n}\n.style-module_EarningRow__0QTAQ .style-module_SecondaryText__z9dmR {\n flex: 0 0 auto;\n text-align: right;\n}\n\n.style-module_DroppedWarning__WlZAR {\n margin-bottom: 14px;\n}\n\n.style-module_LoyaltyBlock__MWvGo {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin-bottom: 18px;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_LoyaltyBlock__MWvGo {\n margin-bottom: 0;\n margin-top: 16px;\n }\n}\n\n.style-module_BalanceRow__yVaQc {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 strong {\n font-weight: 600;\n}\n.style-module_BalanceRow__yVaQc .style-module_BalanceText__SD-u6 .style-module_SecondaryText__z9dmR {\n font-size: 16px;\n line-height: 24px;\n}\n\n.style-module_UseButton__hL-Rh {\n flex: 0 0 auto;\n height: 36px !important;\n padding: 0 16px !important;\n font-size: 14px;\n}\n\n.style-module_SmallButton__Styu6 {\n flex: 0 0 auto;\n height: 40px !important;\n padding: 0 16px !important;\n font-size: 14px;\n}\n\n.style-module_SingleContent__zlrTo {\n display: flex;\n flex-direction: column;\n}\n\n.style-module_OptionList__repyQ {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.style-module_Radio__XVGRg {\n flex: 0 0 auto;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n border: 1px solid var(--checkout-border-color);\n background-color: var(--checkout-primary-bg-color);\n box-sizing: border-box;\n transition: border-color 0.2s;\n}\n\n.style-module_OptionCard__BGQPj {\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n transition: border-color 0.2s;\n}\n.style-module_OptionCard__BGQPj .style-module_OptionHeader__JtkLp {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 14px;\n cursor: pointer;\n user-select: none;\n}\n.style-module_OptionCard__BGQPj .style-module_Cost__NLCD- {\n flex: 0 0 auto;\n text-align: right;\n}\n.style-module_OptionCard__BGQPj .style-module_OptionContent__KUmfq {\n padding: 0 14px 16px;\n}\n.style-module_OptionCard__BGQPj:hover:not(.style-module_OptionCardSelected__-TSjd):not(.style-module_OptionCardDisabled__vHjmn) {\n border-color: var(--checkout-secondary-text-color);\n}\n.style-module_OptionCard__BGQPj:hover:not(.style-module_OptionCardSelected__-TSjd):not(.style-module_OptionCardDisabled__vHjmn) .style-module_Radio__XVGRg {\n border-color: var(--checkout-secondary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd {\n border-color: var(--checkout-primary-text-color);\n box-shadow: 0 0 0 1px var(--checkout-primary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd .style-module_OptionHeader__JtkLp {\n cursor: default;\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardSelected__-TSjd .style-module_Radio__XVGRg {\n border: 5px solid var(--checkout-primary-text-color);\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardDisabled__vHjmn {\n background-color: transparent;\n}\n.style-module_OptionCard__BGQPj.style-module_OptionCardDisabled__vHjmn .style-module_OptionHeader__JtkLp {\n cursor: default;\n opacity: 0.5;\n}\n\n.style-module_DynamicInput__jh-g0 {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.style-module_HintRow__6UPJ- {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 12px;\n}\n.style-module_HintRow__6UPJ- .style-module_SecondaryText__z9dmR {\n font-size: 16px;\n line-height: 20px;\n}\n\n.style-module_GiftList__xs6uv {\n display: flex;\n flex-direction: column;\n padding: 8px 0 4px;\n}\n\n.style-module_GiftRow__addVG {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 0;\n}\n.style-module_GiftRow__addVG + .style-module_GiftRow__addVG {\n border-top: 1px solid var(--checkout-border-color);\n}\n.style-module_GiftRow__addVG:first-child {\n padding-top: 0;\n}\n.style-module_GiftRow__addVG:last-child {\n padding-bottom: 0;\n}\n.style-module_GiftRow__addVG.style-module_GiftRowDisabled__7Ossr .style-module_GiftImage__L8Qdn,\n.style-module_GiftRow__addVG.style-module_GiftRowDisabled__7Ossr .style-module_GiftInfo__VAtS7 {\n opacity: 0.5;\n}\n\n.style-module_GiftImage__L8Qdn {\n flex: 0 0 auto;\n width: 44px;\n height: 44px;\n border-radius: 8px;\n overflow: hidden;\n background-color: var(--checkout-secondary-bg-color);\n}\n.style-module_GiftImage__L8Qdn img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.style-module_GiftInfo__VAtS7 {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n min-width: 0;\n}\n.style-module_GiftInfo__VAtS7 .style-module_GiftName__hjiMJ {\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_AppliedList__yHMSJ {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.style-module_AppliedRow__6ePX6 {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n border: 1px solid var(--checkout-border-color);\n border-radius: 8px;\n background-color: var(--checkout-primary-bg-color);\n}\n.style-module_AppliedRow__6ePX6 .style-module_AppliedValue__zM0fW {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n}\n.style-module_AppliedRow__6ePX6 .style-module_DiscountValue__PBnlU {\n color: var(--checkout-error-color);\n}\n\n.style-module_RemoveIcon__HQ26R {\n cursor: pointer;\n display: flex;\n align-items: center;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_RemoveIcon__HQ26R svg {\n width: 20px;\n height: 20px;\n transform: scale(0.8);\n}\n.style-module_RemoveIcon__HQ26R.style-module_RemoveIconLoading__iGIrr {\n pointer-events: none;\n opacity: 0.5;\n}");export{n as default};
@@ -329,6 +329,7 @@ export default class CheckoutViewModel {
329
329
  onStockLocationChange: (location: IkasStockLocation) => Promise<void>;
330
330
  onCouponCodeApply: (isAddingCoupon?: boolean) => Promise<void>;
331
331
  removeGiftCardLine: (giftCardId: string | null) => Promise<void>;
332
+ refreshCheckoutCart: () => Promise<boolean>;
332
333
  removeLoyaltyPointsFromCart: (loyaltySpendingMethodId: string) => Promise<void>;
333
334
  getAvailableShippingZones: () => Promise<void>;
334
335
  onSelectedShippingAddressIdChange: (value: string) => void;
@@ -1 +1 @@
1
- import{__assign as e,__awaiter as t,__generator as i,__spreadArray as s}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as n}from"mobx";import r from"lodash/cloneDeep";import o 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 a,IkasPaymentGatewayType as c,IkasCartCreatedBy as d,IkasCouponCodeRequirement as l,IkasCorporateInvoiceRequirement as u,IkasOrderShippingMethod as h,IkasOrderStatus as p,IkasCustomerEmailSubscriptionStatus as m,IkasOrderPaymentStatus as f,IkasTransactionStatus as g,IkasCartCampaignOfferStatus as y,IkasCampaignOfferTargetPageType as v,IkasOrderLineItemStatus as S,IkasAmountType as b,IkasCampaignOfferProductApplicablePriceEnum as C}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{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as I}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as A}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/customer-form-data-input/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 E}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 w}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/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as O}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as R}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as M}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/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/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 T,COUNTRY_FORMS_LOCALES as N,LocalizedAddressConfig as L}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 _ from"./components/credit-card-form/model.js";import j from"./components/secure-card-form/model.js";import G from"./components/secure-card-form/masterpass-bridge-model.js";import D from"../../store/customer/api.js";import x from"../../store/checkout/index.js";import F from"../../store/cart/api.js";import V,{MFS_ELEMENT_ID as U,MFS_SCRIPT_URL as B}from"./modelMasterPass.js";import{APIResponse as Y}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import H from'./../../ext/@ikas/fe-api-client/build/config/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import K from"../../store/product/index.js";import{MILES_SMILES_CURRENCY_CODE as Z,TransactionCardAssociationEnum as W,MILES_SMILES_CARD_GATEWAY_CODE as z,SaveCartInput as q,CheckStocksLineInput as Q,getLoyaltyCustomerInfo as X,listSpendingMethodsByCartId as $,LoyaltyProgramPointEarningTypeEnum as J,listEarningMethods as ee,getMilesSmilesDetails as te,CampaignOfferTargetPageTypeEnum as ie}from"@ikas/storefront-api";import{IkasBaseStore as se}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as ne}from"@ikas/storefront-config";import{Analytics as re}from"../../analytics/analytics.js";import{isPaymentScriptPolicyEnabled as oe}from"../../analytics/head/index.js";import ae from"../../models/data/order/address/ikas-localized-order-address.js";import ce from"../../store/location/index.js";import{getCookieValue as de,getOpenAiAttributionMetadata as le,isEqual as ue}from"../../utils/helper.js";import{readMilesSmilesBindResult as he}from"../../utils/miles-smiles.js";import pe from"../../analytics/ikasV3.js";import{suggestEmailCorrection as me}from"@ikas/storefront-model-functions";var fe,ge,ye,ve=/^\d+$/,Se=/^3[47]/,be="undefined"==typeof localStorage,Ce=((fe={})[Z]=.35,fe),Pe=["UNAUTHORIZED","AUTHORIZATION_REQUIRED","MILES_SMILES_LOGIN_REQUIRED","MILES_SMILES_MEMBER_MISMATCH","EXTERNAL_ACCOUNT_MEMBER_MISMATCH"],ke=["MILES_SMILES_NOT_ENABLED","MILES_SMILES_GATEWAY_NOT_SUPPORTED","MILES_SMILES_CURRENCY_NOT_SUPPORTED","MILES_SMILES_RATE_NOT_CONFIGURED","MILES_SMILES_OAUTH_NOT_CONFIGURED","PAYMENT_GATEWAY_NOT_FOUND"],Ie=function(e){return!!e&&(e.startsWith("MILES_")||e.startsWith("EXTERNAL_ACCOUNT_")||"INVALID_MILES"===e)},Ae=function(){function fe(d,u,p,A,E,Z,W,z,me,fe){var ve=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isCheckoutLoadFailed=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=ge.INFO,this.customizationProps=null,this.cardData=null,this.storeCard=!1,this.savedCards=[],this.savedCardsGatewayId=null,this.selectedSavedCardId=null,this.savedCardCvv="",this.secureCard=new j({onBinChange:function(e){return ve.onCardBinChange(e)},onMasterPassConsentChange:function(e){return ve.mpVM.onSaveCardToMasterPassCheckedChange(e)}}),this.masterPassBridge=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.isMilesSmilesTermsAccepted=!1,this.milesToRedeem=0,this.isMilesSmilesLoginRequired=!1,this.isMilesSmilesUnavailable=!1,this.isMilesSmilesBindLoading=!1,this.milesSmilesDetails=null,this.milesSmilesError=null,this.milesSmilesBindLanding=null,this.isMiniCartOpenOnLoad=!1,this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.hepsipayFrameInitResponse=null,this.iyzicoResponse=null,this.isIyzicoLoading=!1,this.showIyzicoContainer=!1,this.tkPayResponse=null,this.isTkPayLoading=!1,this.showTkPayContainer=!1,this.tkPayFormMiles=null,this.isTkPayPaymentCompleted=!1,this.stripeExpressCheckoutSessionResponse=null,this.isStripeExpressCheckoutSessionVisible=!1,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.storeCreditBalance=null,this.loyaltyCustomerInfo=null,this.loyaltySpendingMethods=null,this.loyaltySpendingMethodsAll=null,this.loyaltyEarningMethod=null,this.isLoyaltyPointsVisible=!1,this.showTestModal=!1,this.openEditOrderTransaction=null,this.previousRawValue="",this.previousBin=null,this.init=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(this.redirectTopIfInsideIframe())return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.waitForCountrySettingsOrFail()];case 2:return t.sent(),[3,4];case 3:return t.sent(),this.isCheckoutLoadFailed=!0,[2];case 4:return[4,se.getInstance().customerStore.waitUntilInitialized()];case 5:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,7];case 6:t.sent(),t.label=7;case 7:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 8:return t.sent(),[2]}}))}))},this.redirectTopIfInsideIframe=function(){if(be||ne.getIsEditor())return!1;try{return!(window.self===window.top||!window.top)&&(window.top.location.origin===window.location.origin&&(window.top.location.replace(window.location.href),!0))}catch(e){return!1}},this.waitForCountrySettingsOrFail=function(){return new Promise((function(e,s){var n=!1,r=function(){n=!0,clearInterval(o),clearTimeout(a)},o=setInterval((function(){ve.countrySettings.initialized&&(r(),e())}),100),a=setTimeout((function(){n||(r(),s(new Error("timeout")))}),1e4);t(ve,void 0,void 0,(function(){var e,t,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=ne.getCurrentLocale(),N.includes(e)||(e="en"),t="".concat(L.getCDNUrl(),"sf/static/location/settings.json"),o="https://eu.myikas.com/sf/static/location/".concat(e,".json"),[4,Promise.all([fetch(t),fetch(o)])];case 1:return a=i.sent(),n?[2]:(a.some((function(e){return!e.ok}))&&(r(),s(new Error("fetch failed"))),[3,3]);case 2:return c=i.sent(),n?[2]:(r(),s(c),[3,3]);case 3:return[2]}}))}))}))},this.initStep=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,a,c,d;return i(this,(function(i){switch(i.label){case 0:if(ne.getIsEditor())return this.step=ge.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),s=t.get("step"),n=t.get("failed"),r=t.get("error"),this.isMiniCartOpenOnLoad="open"===t.get("miniCart"),this.milesSmilesBindLanding=he(),s){if(this.step=s,this.step===ge.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(ge.INFO)];if(this.step!==ge.PAYMENT||this.canProceedToPayment){if(this.step===ge.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(ge.INFO)];if(![ge.INFO,ge.SUCCESS,ge.SHIPPING,ge.PAYMENT].includes(this.step))return[2,this.changeStep(ge.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(ge.INFO)]:[2,this.changeStep(ge.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new k(e(e({},this.checkoutSettings),{couponCodeRequirement:l.DEFAULT}))),this.step!==ge.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return i.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:i.sent(),this.checkShippingCountries(),i.label=4;case 4:return[4,this.getStockLocations()];case 5:return i.sent(),[4,this.getAvailableStockLocations()];case 6:i.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),i.label=7;case 7:if(this.step===ge.SHIPPING&&1===(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)&&!this.checkoutSettings.isGiftPackageEnabled){if(oe())return this.changeStep(ge.PAYMENT),[2];this.step=ge.PAYMENT,o=this.getRoutingPath(),this.router.replace("".concat(o,"/checkout?id=").concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})}return this.step!==ge.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==ge.SUCCESS||this.checkout.orderPaymentStatus!==f.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ye.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==ge.PAYMENT&&this.step!==ge.SUCCESS?[3,15]:[4,this.listPaymentGateways()];case 10:return i.sent(),this.checkout.hasCustomer?[4,this.getStoreCreditBalance()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,14];case 13:i.sent(),i.label=14;case 14:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:ye.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===ge.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(ge.SUCCESS)]:[3,16];case 16:return[4,this.initialStockCheck()];case 17:i.sent(),i.label=18;case 18:return this.checkout.hasCustomer?[4,this.getLoyaltyCustomerInfo()]:[3,22];case 19:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 20:return i.sent(),[4,this.listEarningMethods()];case 21:i.sent(),i.label=22;case 22:return[3,25];case 23:return[4,this.getSuccessTransaction()];case 24:i.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),i.label=25;case 25:return n&&(this.error={type:ye.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,re.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,D.listOrderTransactionsWithPrices({input:{orderId:this.checkout.id}})];case 1:return(e=t.sent()).isSuccess&&e.data&&e.data.chargedAmount&&(this.openEditOrderTransaction=e.data),[2]}}))}))},this.getSuccessTransaction=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,D.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=i.sent(),this.successTransactions=e.isSuccess&&(null===(t=e.data)||void 0===t?void 0:t.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.isCardStorageGateway=function(e){var t,i;return!!e&&"PAYTR"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"card_storage_enabled"===e.label})))||void 0===i?void 0:i.value)&&!!ve.store.customerStore.customer},this.saveCart=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,a,c,d,l,u,h,p,f,g,y,v,S;return i(this,(function(i){switch(i.label){case 0:return t=new q(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=i.sent(),i.label=2;case 2:return this.step!==ge.INFO&&this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===ge.PAYMENT||(t.billingAddress=null),t.billingAddress&&(this.isShowBillingAddressOnShippingStep&&this.useDifferentAddress||this.useDifferentAddress&&!this.isShowBillingAddressOnShippingStep&&this.checkoutSettings.showCompanyInfoInShippingAddress)&&(t.billingAddress.company=(null===(r=t.shippingAddress)||void 0===r?void 0:r.company)||null,t.billingAddress.taxNumber=(null===(o=t.shippingAddress)||void 0===o?void 0:o.taxNumber)||null,t.billingAddress.taxOffice=(null===(a=t.shippingAddress)||void 0===a?void 0:a.taxOffice)||null)),this.isDigitalOnly&&(t.shippingAddress=null),t.customer&&(this.store.customerStore.customer?t.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED:this.checkout.customer&&(t.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),null===(null===(d=null===(c=t.shippingAddress)||void 0===c?void 0:c.city)||void 0===d?void 0:d.code)&&""===(null===(u=null===(l=t.shippingAddress)||void 0===l?void 0:l.city)||void 0===u?void 0:u.name)&&(t.shippingAddress.city.name="-"),null===(null===(p=null===(h=t.billingAddress)||void 0===h?void 0:h.city)||void 0===p?void 0:p.code)&&""===(null===(g=null===(f=t.billingAddress)||void 0===f?void 0:f.city)||void 0===g?void 0:g.name)&&(t.billingAddress.city.name="-"),t.metadata=e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),[4,F.saveCart({input:t})];case 3:if((null==(s=i.sent())?void 0:s.graphQLErrors)&&s.graphQLErrors.length)throw n=s.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(y=n.extensions)||void 0===y?void 0:y.code)?{type:ye.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(v=n.extensions)||void 0===v?void 0:v.code)?{type:ye.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(S=n.extensions)||void 0===S?void 0:S.code)?{type:ye.ARGUMENT_VALIDATION_ERROR,data:n.extensions.validationErrors}:{type:ye.API_ERROR,data:s.firstErrorMessage};return[2,s.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(ve,void 0,void 0,(function(){var t,s,n=this;return i(this,(function(i){return t=e,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,l,u,p,m,f;return i(this,(function(i){switch(i.label){case 0:return this.isManualOrder||this.isOpenEditOrderWithTransaction?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===h.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(p=ne.getStockLocationIds())||void 0===p?void 0:p.length)?ne.getStockLocationIds():null,[4,x.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(t=i.sent()).isSuccess)throw s="UPSELL"===this.checkout.createdBy,n=s?this.t("checkout-page:upsellTimeErrorMessage"):t.firstErrorMessage,{type:ye.API_ERROR,data:n};if(null==(r=null===(f=null===(m=t.data)||void 0===m?void 0:m.lines)||void 0===f?void 0:f.filter((function(e){return!e.isAvailable})))?void 0:r.length){for(o=[],a=function(e){var t=c.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&o.push({item:t,stockCount:e.stockCount})},c=this,d=0,l=r;d<l.length;d++)u=l[d],a(u);throw{type:ye.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){ve.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:t=0,s=e,i.label=1;case 1:return t<s.length?(n=s[t],[4,se.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getAvailableShippingCountries({salesChannelId:ne.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?[4,x.listStockLocation({id:{in:ne.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=i.sent()).isSuccess||!(null===(t=e.data)||void 0===t?void 0:t.length))return this.error={type:ye.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,x.getAvailableStockLocations({lines:e.map((function(e){return new Q(e)})),stockLocationIdList:ne.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ye.API_ERROR},[2];s=ne.getCurrentRouting(),this.availableStockLocations=(t.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),i.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ve.shippingCountryIds)||void 0===e?void 0:e.length)||(ve.error={type:ye.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;ve.deliveryMethod!==e&&("address"===e&&(ve.checkout.stockLocationId=null,(null===(t=ve.customerAddresses)||void 0===t?void 0:t.length)?ve.onSelectedShippingAddressIdChange(ve.customerAddresses[0].id||"-1"):(ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)),ve.deliveryMethod=e,ve.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(ve,void 0,void 0,(function(){var e;return i(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:ye.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,X({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,$({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltySpendingMethods=e.data.filter((function(e){return e.isAvailable})),this.loyaltySpendingMethodsAll=e.data),[2]}}))}))},this.listEarningMethods=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,ee()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===J.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return this.resetMilesSmilesIfNothingToPay(),e="local"===process.env.NEXT_PUBLIC_ENV,t=ne.getPaymentGateways().map((function(e){return e.id})),[4,x.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:ne.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=i.sent()).isSuccess?(null===(p=s.data)||void 0===p?void 0:p.length)||this.isFree?(this.error=void 0,n=null===(m=s.data)||void 0===m?void 0:m.some((function(e){return"IKAS_WALLET"===e.code})),this.isMinTransactionError=n&&this.finalPrice<200&&!this.isDigitalOnly,this.isMinTransactionError?[2]:(r=s.data||[],this.step===ge.PAYMENT&&(r=r.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(y.checkout.currencyCode)})),(a=null===(f=this.checkout.shippingAddress)||void 0===f?void 0:f.country)&&a.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")}))),c=null===(g=this.checkout.billingAddress)||void 0===g?void 0:g.country,!a&&c&&c.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(c.iso2||"")})))),d=[],o(ne.getPaymentGateways(),"order").forEach((function(e){var t=null==r?void 0:r.find((function(t){return t.id===e.id}));t&&d.push(t)})),this.paymentGateways=e?r:d,l=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.step===ge.SUCCESS?[3,4]:this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=y.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==l?l:0),[3,4]))):(this.error={type:ye.NO_SHIPPING_ERROR},[2]):(this.error={type:ye.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==ge.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===ge.PAYMENT&&((u=r.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=u),u&&!this.masterPassBridge&&((h=document.createElement("script")).id=U,h.src=B,h.onload=function(){y.mpVM.checkMasterPass({checkout:y.checkout,store:se.getInstance()})},document.head.appendChild(h))),this.isMilesSmilesActive()?[4,this.loadMilesSmilesDetails()]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},this.resetMilesSmilesIfNothingToPay=function(){ve.isMilesSmilesNothingToPay&&(ve.useMilesSmiles=!1,ve.milesToRedeem=0,ve.isMilesSmilesTermsAccepted=!1)},this.loadMilesSmilesDetails=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return this.isMilesSmilesActive()?(e=this.milesSmilesBindLanding,this.milesSmilesBindLanding=null,"fail"===(null==e?void 0:e.status)&&(this.milesSmilesError=e.errorCode||"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"),this.store.customerStore.customer?[4,te()]:(this.isMilesSmilesLoginRequired=!0,this.milesSmilesDetails=null,[2])):[2];case 1:return(t=i.sent()).isSuccess&&t.data?(this.milesSmilesDetails=t.data,this.isMilesSmilesLoginRequired=!1,"success"!==(null==e?void 0:e.status)||this.useMilesSmiles||this.isMilesSmilesNothingToPay?[3,3]:[4,this.setUseMilesSmiles(!0)]):[3,4];case 2:i.sent(),i.label=3;case 3:return[2];case 4:return s=t.errorCodes,Pe.some((function(e){return s.includes(e)}))?(this.isMilesSmilesLoginRequired=!0,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesDetails=null,[2]):ke.some((function(e){return s.includes(e)}))?(this.isMilesSmilesUnavailable=!0,this.milesSmilesDetails=null,this.useMilesSmiles=!1,this.milesToRedeem=0,[2]):(this.milesSmilesDetails=null,this.milesSmilesError=s[0]||"MILES_MEMBER_DETAILS_FAILED",[2])}}))}))},this.getMilesSmilesBindRedirect=function(){var e=ve.getRoutingPath();return"".concat(e,"/checkout?id=").concat(ve.checkout.id,"&step=").concat(ge.PAYMENT)},this.getMilesSmilesLoginRedirectUrl=function(){var e=ve.getRoutingPath();return"".concat(e,"/account/login?redirect=").concat(encodeURIComponent(ve.getMilesSmilesBindRedirect()))},this.startMilesSmilesBind=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.milesSmilesError=null,this.store.customerStore.customer?(this.isMilesSmilesBindLoading=!0,[4,this.store.customerStore.startMilesSmilesBind(this.getMilesSmilesBindRedirect())]):(window.location.href=this.getMilesSmilesLoginRedirectUrl(),[2]);case 1:return(e=t.sent()).isSuccess||(this.isMilesSmilesBindLoading=!1,this.milesSmilesError=e.errorCode||"UNEXPECTED_ERROR"),[2]}}))}))},this.setUseMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.useMilesSmiles=e,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesError=null,e?(t=this.milesSmilesPaymentGateway,-1===(s=t?this.paymentGateways.findIndex((function(e){return e.id===t.id})):-1)||this.selectedPaymentGatewayIndex===s?[3,2]:[4,this.setPaymentGateway(s)]):[3,2];case 1:i.sent(),this.mpVM.selectedCard=void 0,i.label=2;case 2:return this.milesToRedeem=0,[4,this.onMilesSmilesSelectionChange()];case 3:return i.sent(),[2]}}))}))},this.setMilesSmilesTermsAccepted=function(e){ve.isMilesSmilesTermsAccepted=e},this.setMilesToRedeem=function(e){ve.milesToRedeem=Math.max(0,Math.floor(e||0))},this.clampMilesToRedeem=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this.milesSmilesMaxRedeemable,this.milesToRedeem>e&&(this.milesToRedeem=e),[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.selectMilesSmilesChip=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e>this.milesSmilesMaxRedeemable?[2]:(this.milesToRedeem=e,[4,this.onMilesSmilesSelectionChange()]);case 1:return t.sent(),[2]}}))}))},this.setUseAllMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.milesToRedeem=e?this.milesSmilesMaxRedeemable:0,[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.onMilesSmilesSelectionChange=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return this.isTkPay&&this.checkout.selectedPaymentGateway?this.isTkPayPaymentCompleted?[2]:(e=(null===(t=this.milesSmilesInput)||void 0===t?void 0:t.miles)||0,this.tkPayResponse&&this.tkPayFormMiles===e?[2]:(this.tkPayResponse=null,[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)])):[2];case 1:return i.sent(),[2]}}))}))},this.handleMilesSmilesSaleError=function(e){var t,i;return ve.handleMilesSmilesErrorCodes(s(s([],e.errorCodes||[],!0),[null===(i=null===(t=e.data)||void 0===t?void 0:t.error)||void 0===i?void 0:i.code],!1))},this.handleMilesSmilesErrorCodes=function(e){var t=e.filter(Ie);if(!t.length)return null;var i=t[0];return Pe.includes(i)?(ve.isMilesSmilesLoginRequired=!0,ve.isMilesSmilesTermsAccepted=!1,ve.milesSmilesDetails=null,ve.useMilesSmiles=!1,ve.milesToRedeem=0):ke.includes(i)&&(ve.isMilesSmilesUnavailable=!0,ve.useMilesSmiles=!1,ve.milesToRedeem=0),ve.milesSmilesError=i,ve.getMilesSmilesErrorMessage(i)},this.getMilesSmilesErrorMessage=function(e){var t="checkout-page:milesSmilesErrors.".concat(e),i=e?ve.t(t):"";return i&&i!==t?i:ve.t("checkout-page:milesSmilesErrors.default")},this.retrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,x.retrieveInstallmentInfo(e)];case 1:return t=i.sent(),s=t.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 t;ve.store.customerStore.customer?(null===(t=ve.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=ve.checkoutSettings,e.shippingZones=ve.shippingZones})),ve.checkout.customer=new w(e(e({},ve.store.customerStore.customer),{notificationsAccepted:ve.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED}))):ve.checkout.customer=new w(ve.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones,ve.checkout.billingAddress.countrySettings=ve.countrySettings,ve.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ve.isDigitalOnly)if(ve.isInStoreDelivery)ve.setCheckoutShippingAddressSettings();else if(ve.checkout.shippingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedShippingAddressIdChange(e.id||"-1"),void ve.setCheckoutShippingAddressSettings()}ve.checkout.shippingAddress=new ae(r(ve.checkout.shippingAddress)||{}),ve.setCheckoutShippingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ve.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ve.useDifferentAddress=!!localStorage.getItem("sAddr"),ve.checkout.billingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedBillingAddressIdChange(e.id||"-1"),void ve.setCheckoutBillingAddressSettings()}ve.checkout.billingAddress=new ae(r(ve.checkout.billingAddress)||{}),ve.setCheckoutBillingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())}else ve.onSelectedBillingAddressIdChange("-1"),ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=e.shippingSettingsId,this.checkout.shippingZoneRateId=e.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=i.sent())&&(this.checkout=new P(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(ve,void 0,void 0,(function(){var t,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(o=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT||this.checkout.totalFinalPrice===o.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,s?re.addCouponCode(n):re.removeCouponCode(n),i.label=7;case 7:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,i.label=7;case 7:return[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeLoyaltyPointsFromCart=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,F.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,9];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,9];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:return i.sent(),this.isCampaignOfferLoaded=!0,re.removeLoyaltyPoints(n),[4,this.getLoyaltyCustomerInfo()];case 7:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return i.sent(),[3,11];case 11:return[2]}}))}))},this.getAvailableShippingZones=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ce.getAvailableShippingZones({salesChannelId:ne.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(ve.selectedShippingAddressId=e,"-1"===e)ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.shippingAddress=new ae(i),ve.checkout.shippingAddress.countrySettings=ve.countrySettings)}ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ve.selectedBillingAddressId=e,"-1"===e)ve.checkout.billingAddress=new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.billingAddress=new ae(i),ve.checkout.billingAddress.countrySettings=ve.countrySettings)}ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ve.isTermsAndConditionsChecked=e,ve.isIyzico&&(ve.showIyzicoContainer=e),ve.isTkPay&&(ve.showTkPayContainer=e,ve.saveCart())},this.onCardNumberChange=function(e){if(ve.cardData){var t=(e||"").replace(/\D/g,""),i=ve.previousRawValue,s=t.slice(0,8),n=ve.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(ve.getRetrieveInstallmentInfo(t),ve.previousBin=s),t.length<8&&i.length>=8&&(ve.cardData.installmentCount=1,ve.installmentInfo=void 0,ve.previousBin=null),ve.isAmexCard(t)?ve.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(t).join(" "):ve.cardData.cardNumber=Ee(t,4).join(" "),ve.previousRawValue=t}}},this.onCardBinChange=function(e){if(ve.cardData&&ve.checkout.selectedPaymentGateway&&!ve.selectedSavedCard)return e?void ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,binNumber:e,paymentGatewayId:ve.checkout.selectedPaymentGateway.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}}):(ve.cardData.installmentCount=1,void(ve.installmentInfo=void 0))},this.getRetrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:e.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return i.sent(),(null===(t=this.cardData)||void 0===t?void 0:t.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){ve.cardData&&(ve.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ve.cardData&&(!(e.length>ve.cardData.expirationDate.length)||we(e))){if(0===(null===(t=ve.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(ve.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(ve.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(ve.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ve.cardData.expirationDate=Ee(d,2).join(" / "))}},this.onCvcChange=function(e){if(ve.cardData&&(!(e.length>ve.cardData.cvv.length)||we(e))){if(ve.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;ve.cardData.cvv=e}},this.saveAddress=function(s){return t(ve,void 0,void 0,(function(){var t,n,o,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,n=null===(p=this.customerAddresses)||void 0===p?void 0:p.find((function(e){return e.id===(null==t?void 0:t.id)})),n?[2]:(o=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(e){return e.id})),a=new I(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(c=r(this.store.customerStore.customer)).addresses||(c.addresses=[]),c.addresses.push(a),[4,this.store.customerStore.saveCustomer(c)])):[3,2];case 1:i.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(e){e.checkoutSettings=y.checkoutSettings,e.shippingZones=y.shippingZones})),d=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(e){return e.id})),l=null==d?void 0:d.filter((function(e){return!(null==o?void 0:o.includes(e))})),u=(null==l?void 0:l.length)?l[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),i.label=2;case 2:return[3,4];case 3:return h=i.sent(),console.error(h),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=ne.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=ve.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(ve.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isShowBillingAddressOnShippingStep&&!this.useDifferentAddress&&("address"===this.deliveryMethod&&this.checkout.shippingAddress?this.checkout.billingAddress=new ae(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new ae(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2: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=3;case 3:return t.trys.push([3,10,,11]),this.isStepLoading=!0,"address"!==this.deliveryMethod||this.isShowBillingAddressOnShippingStep?[3,5]:[4,this.saveAddress("shipping")];case 4:t.sent(),t.label=5;case 5:return this.isShowBillingAddressOnShippingStep?[4,this.saveAddress("billing")]:[3,7];case 6:t.sent(),t.label=7;case 7:return[4,this.checkStocks()];case 8:return t.sent(),[4,this.saveCart()];case 9:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(ge.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(ge.SHIPPING):this.changeStep(ge.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,6,,7]),this.isStepLoading=!0,[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.changeStep(ge.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(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(ge.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ve.canPerformPayment||(ve.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){ve.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return!this.canPerformPayment||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]);case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return this.isFree||!this.isIyzico?[3,4]:[4,this.saveCart()];case 3:return i.sent(),[2];case 4:if(this.isFree||!this.isHepsiPay)return[3,11];i.label=5;case 5:return i.trys.push([5,9,,10]),window.HepsipaySdk&&(null===(o=this.hepsipayFrameInitResponse)||void 0===o?void 0:o.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,7];case 6:return i.sent(),window.HepsipaySdk.initPayment(),[3,8];case 7:console.error("HepsipaySdk is not available"),i.label=8;case 8:return[3,10];case 9:return i.sent(),this.isStepLoading=!1,[2];case 10:return[2];case 11:return i.trys.push([11,17,,18]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 12:return i.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,14];case 13:i.sent(),i.label=14;case 14:return[4,this.saveCart()];case 15:return e=i.sent(),this.checkout.shippingMethod===h.SHIPMENT&&(t=null!==(a=null==e?void 0:e.availableShippingMethods)&&void 0!==a?a:[],s=null!==(c=this.checkout.availableShippingMethods)&&void 0!==c?c:[],!ue(t,s))?(this.changeStep(ge.SHIPPING),[2]):!this.isFree&&this.isCustomFlowStripe?((n=document.querySelector("#stripe-form-btn"))&&n.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 16:return i.sent(),[3,18];case 17:return void 0!==typeof(r=i.sent()).type?this.error=r:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:if(this.isFree||!this.isHepsiPay)return[3,9];i.label=3;case 3:return i.trys.push([3,7,,8]),window.HepsipaySdk&&(null===(s=this.hepsipayFrameInitResponse)||void 0===s?void 0:s.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,5];case 4:return i.sent(),window.HepsipaySdk.initPayment(),[3,6];case 5:console.error("HepsipaySdk is not available"),i.label=6;case 6:return[3,8];case 7:return i.sent(),this.isStepLoading=!1,[2];case 8:return[2];case 9:return i.trys.push([9,13,,14]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 10:return i.sent(),[4,this.saveCart()];case 11:return i.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 12:return i.sent(),[3,14];case 13:return(t=i.sent()).type?this.error=t:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,d,l,u,h,p,m,f,y,v,S,b,C,P,k,I,A,E,w,O,R,M,T,N,L,_,j,G,D,F;return i(this,(function(i){switch(i.label){case 0:return s=this.mpVM.selectedCard,r=this.milesSmilesInput,!this.isFree&&s&&(null===(P=this.mpVM.selectedCard)||void 0===P?void 0:P.Name)?((o=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=o),void 0===(null===(k=this.cardData)||void 0===k?void 0:k.installmentCount)?[2]:[4,x.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(I=this.mpVM.selectedCard)||void 0===I?void 0:I.Name},paymentGatewayId:null===(A=this.mpVM.selectedCard)||void 0===A?void 0:A.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===(E=this.cardData)||void 0===E?void 0:E.threeDSecure)},metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),milesSmiles:(null===(w=this.mpVM.selectedCard)||void 0===w?void 0:w.paymentGatewayId)===(null===(O=this.milesSmilesPaymentGateway)||void 0===O?void 0:O.id)?r:void 0}})]):[3,2];case 1:return n=i.sent(),[3,10];case 2:return this.checkout.selectedPaymentGateway||this.isFree?(d=this.isFree||s?void 0:this.selectedSavedCard,l=!this.isFree&&!s&&!d&&this.storeCard&&this.isCardStorageEnabled,u=!(this.isFree||s||d||(null===(R=this.checkout.selectedPaymentGateway)||void 0===R?void 0:R.paymentMethodType)!==a.CREDIT_CARD||(null===(M=this.checkout.selectedPaymentGateway)||void 0===M?void 0:M.type)!==c.INTERNAL||!this.cardData),h=e({cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:s&&t?{phoneNumber:t,savedCardName:null===(T=this.mpVM.selectedCard)||void 0===T?void 0:T.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":this.isMilesSmilesFullPayment?null===(N=this.milesSmilesPaymentGateway)||void 0===N?void 0:N.id:null===(L=this.checkout.selectedPaymentGateway)||void 0===L?void 0:L.id,metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),milesSmiles:r},l?{storeCard:!0}:{}),d?[4,this.createSaleTransactionWithSavedCard(h,d)]:[3,4]):[2];case 3:return p=i.sent(),[3,9];case 4:return u&&this.isSecureCardEnabled?[4,this.createSaleTransactionWithSecureCard(h)]:[3,6];case 5:return m=i.sent(),[3,8];case 6:return[4,x.createSaleTransactionWithCart({input:e(e({},h),{paymentMethodDetail:u?this.cardData.toInput():void 0})})];case 7:m=i.sent(),i.label=8;case 8:p=m,i.label=9;case 9:n=p,i.label=10;case 10:return f=null===(_=null==n?void 0:n.data)||void 0===_?void 0:_.transactionStatus,y=f&&[g.SUCCESS,g.AUTHORIZED].includes(f),v=f===g.PENDING,y?[4,this.getSuccessTransaction()]:[3,13];case 11:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(j=null==n?void 0:n.data)||void 0===j?void 0:j.orderId)||void 0)];case 12:return i.sent(),[3,14];case 13:if(!v||!(null===(G=null==n?void 0:n.data)||void 0===G?void 0:G.returnSlug))throw b=n.firstErrorMessage,"IKAS_WALLET_501"===(null===(F=null===(D=n.data)||void 0===D?void 0:D.error)||void 0===F?void 0:F.code)&&(b=this.t("checkout-page:errorContactStore")),(C=this.handleMilesSmilesSaleError(n))&&(b=C),{data:b,type:ye.UNKNOWN};S="local"===process.env.NEXT_PUBLIC_ENV?process.env.NEXT_PUBLIC_BASE_URL:window.location.origin+"/api/sf",window.location.href=S+n.data.returnSlug,i.label=14;case 14:return[2]}}))}))},this.createSaleTransactionWithSavedCard=function(s,n){return t(ve,void 0,void 0,(function(){var t,r,o,a;return i(this,(function(i){switch(i.label){case 0:return t=(null===(o=null===(r=this.installmentInfo)||void 0===r?void 0:r.installmentPrices)||void 0===o?void 0:o.length)&&(null===(a=this.cardData)||void 0===a?void 0:a.installmentCount)||1,n.requireCvv&&this.isSecureCardEnabled?[4,this.submitSecureCardSale(e(e({},s),{savedCardDetail:{savedCardId:n.id,installmentCount:t}}))]:[3,2];case 1:case 3:return[2,i.sent()];case 2:return[4,x.createSaleTransactionWithCart({input:e(e({},s),{savedCardDetail:e(e({savedCardId:n.id},n.requireCvv?{cvv:this.savedCardCvv}:{}),{installmentCount:t})})})]}}))}))},this.createSaleTransactionWithSecureCard=function(s){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.submitSecureCardSale(e(e({},s),{paymentMethodDetail:{installmentCount:this.cardData.installmentCount,threeDSecure:!!this.cardData.threeDSecure}}))];case 1:return[2,t.sent()]}}))}))},this.submitSecureCardSale=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.secureCard.submitSale(e)];case 1:if(!(t=i.sent()).ok)throw"INVALID_CARD"===t.errorCode&&(this.isErrorsVisible=!0),{type:ye.UNKNOWN};return s=t.errors,n=new Y(t.data||void 0,s),null===(o=null===(r=H.ON_ERROR)||void 0===r?void 0:r.errorCodes)||void 0===o||o.forEach((function(e){var t=e.errorCode,i=e.callback;n.errorCodes.includes(t)&&i({graphQLErrors:s,operationName:"createSaleTransactionWithCart"})})),[2,n]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:i.sent(),i.label=2;case 2:return pe.refreshJourneyId(),this.changeStep(ge.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){ve.changeStep(ge.INFO)},this.onBackToShippingClick=function(){ve.changeStep(ge.SHIPPING)},this.setCustomerConsentGranted=function(e){ve.checkout.customer&&(ve.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;ve.useDifferentAddress=t,ve.useDifferentAddress?(localStorage.setItem("sAddr","1"),ve.checkout.billingAddress=ve.checkout.billingAddress||new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings):(localStorage.removeItem("sAddr"),ve.checkout.billingAddress=new ae(e({},ve.checkout.shippingAddress)),ve.store.customerStore.customer&&(null===(s=ve.customerAddresses)||void 0===s?void 0:s.length)&&i&&ve.isShowBillingAddressOnShippingStep&&ve.onSelectedBillingAddressIdChange(ve.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){ve.shouldSaveAddress=e},this.setAddressTitle=function(e){ve.addressTitle=e},this.reInitPaymentMethod=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,12];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(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 this.isHepsiPay?[4,this.hepsipayFrameInit(this.checkout.selectedPaymentGateway)]:[3,8];case 7:e.sent(),e.label=8;case 8:return this.isIyzico?[4,this.createIyzicoCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,10];case 9:e.sent(),e.label=10;case 10:return this.isTkPay?[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,12];case 11:e.sent(),e.label=12;case 12:return[2]}}))}))},this.createStripePaymentIntent=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.stripeResponse=t.data,this.stripeError=null):this.stripeError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.klarnaResponse=t.data,this.klarnaError=null):this.klarnaError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.adyenResponse=t.data),[2]}}))}))},this.getPayPalClientId=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.payPalClientIdResponse=t.data),[2]}}))}))},this.hepsipayFrameInit=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.hepsipayFrameInit({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.hepsipayFrameInitResponse=t.data),[2]}}))}))},this.createIyzicoCheckoutForm=function(s){return t(ve,void 0,void 0,(function(){var t,n;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this.isIyzicoLoading=!0,[4,x.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:s.id||"",metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le())}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.iyzicoResponse=t.data,[2]):(n=function(e){var i,s;return(null===(i=t.errorCodes)||void 0===i?void 0:i.includes(e))||(null===(s=t.graphQLErrors)||void 0===s?void 0:s.some((function(t){var i;return(null===(i=t.extensions)||void 0===i?void 0:i.code)===e})))},n("ORDER_LINE_STOCK_NOT_AVAILABLE")?this.error={type:ye.API_ERROR,data:this.t("checkout-page:iyzicoStockReservationError")}:n("IYZICO_CHECKOUT_FORM_INIT_FAILED")&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:iyzicoInitError")}),[3,4]);case 2:return i.sent(),[3,4];case 3:return this.isIyzicoLoading=!1,[7];case 4:return[2]}}))}))},this.createTkPayCheckoutForm=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:if(this.isTkPayPaymentCompleted||this.step===ge.SUCCESS)return[2];if(this.isFree)return this.tkPayResponse=null,[2];t=!1,i.label=1;case 1:return i.trys.push([1,3,4,5]),this.isTkPayLoading=!0,s=this.milesSmilesInput,[4,x.createTkPayCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||"",milesSmiles:s}})];case 2:return n=i.sent(),this.isTkPayPaymentCompleted?[2]:(n.isSuccess&&n.data?(this.tkPayResponse=n.data,this.tkPayFormMiles=(null==s?void 0:s.miles)||0):s&&(t=!!this.handleMilesSmilesErrorCodes(n.errorCodes||[])),[3,5]);case 3:return i.sent(),[3,5];case 4:return this.isTkPayLoading=!1,[7];case 5:return!t||this.milesSmilesInput?[3,7]:[4,this.createTkPayCheckoutForm(e)];case 6:i.sent(),i.label=7;case 7:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.stripeExpressCheckoutSessionResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return[7];case 4:return[2]}}))}))},this.updateStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:if(!this.stripeExpressCheckoutSessionResponse)return[2,null];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,x.updateStripeExpressCheckoutSession({input:{cartId:this.checkout.id,sessionId:"",transactionId:"",address:e.address||null,shippingSettingsId:e.shippingSettingsId||null,shippingZoneRateId:e.shippingZoneRateId||null}})];case 2:return(t=i.sent()).isSuccess&&t.data?[2,t.data]:[2,null];case 3:return i.sent(),[2,null];case 4:return[2]}}))}))},this.setShowIyzicoContainer=function(e){ve.showIyzicoContainer=e},this.onTkPayPaymentSuccess=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.isTkPayPaymentCompleted?[2]:(this.isTkPayPaymentCompleted=!0,this.isStepLoading=!0,[4,e()]);case 1:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 2:return t.sent(),[2]}}))}))},this.setShowTkPayContainer=function(e){ve.showTkPayContainer=e},this.setPaymentGateway=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==ge.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==t.code?[3,2]:[4,this.updatePaymentGateway(t)]):[2];case 1:s=i.sent(),i.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(t)];case 4:return s=i.sent(),[3,7];case 5:return"CUSTOM"!==t.code?[3,7]:[4,this.updatePaymentGateway(t)];case 6:s=i.sent(),i.label=7;case 7:return s?"STRIPE"!==t.code&&"STRIPE_EU"!==t.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(t)]:[2];case 8:i.sent(),i.label=9;case 9:return"KLARNA"!==t.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(t)];case 10:i.sent(),i.label=11;case 11:return"ADYEN_PLATFORM"!==t.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(t)];case 12:i.sent(),i.label=13;case 13:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(t)];case 14:i.sent(),i.label=15;case 15:return"HEPSIPAY"!==t.code||this.hepsipayFrameInitResponse?[3,17]:[4,this.hepsipayFrameInit(t)];case 16:i.sent(),i.label=17;case 17:return"IYZICO"!==t.code||this.iyzicoResponse?[3,19]:[4,this.createIyzicoCheckoutForm(t)];case 18:i.sent(),i.label=19;case 19:return"TK_PAY"!==t.code||this.tkPayResponse||"true"!==(null===(r=null===(n=t.settings)||void 0===n?void 0:n.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===r?void 0:r.value)?[3,21]:[4,this.createTkPayCheckoutForm(t)];case 20:i.sent(),i.label=21;case 21:return this.isCardStorageGateway(t)?[4,this.listSavedCards(t)]:[3,23];case 22:i.sent(),i.label=23;case 23:return this.checkout.selectedPaymentGateway=t,this.step!==ge.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new _,this.secureCard.reset(),this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0,this.selectedSavedCardId=null,this.selectSavedCard((null===(o=this.visibleSavedCards[0])||void 0===o?void 0:o.id)||null)),[2]}}))}))},this.listSavedCards=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.savedCardsGatewayId===e.id?[2]:[4,x.listPaymentSavedCard({paymentGatewayId:e.id})];case 1:return t=i.sent(),this.savedCards=t.isSuccess&&t.data||[],this.savedCardsGatewayId=e.id||null,[2]}}))}))},this.selectSavedCard=function(e){var t=ve.selectedSavedCardId!==e;if(ve.selectedSavedCardId=e,t){ve.savedCardCvv="",ve.isSecureCardEnabled&&ve.secureCard.reset(),ve.installmentInfo=void 0,ve.cardData=new _,ve.previousRawValue="",ve.previousBin=null;var i=ve.selectedSavedCard,s=ve.checkout.selectedPaymentGateway;i&&(null==s?void 0:s.id)&&ve.checkout.totalFinalPrice&&ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,savedCardId:i.id,paymentGatewayId:s.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}})}},this.onSavedCardCvvChange=function(e){var t=(e||"").replace(/\D/g,"");t.length>4||(ve.savedCardCvv=t)},this.setStoreCard=function(e){ve.storeCard=e},this.updatePaymentGateway=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,F.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:ie.CHECKOUT})];case 1:return(t=i.sent()).isSuccess?((n=t.data)&&(r=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){ve.cardData&&(ve.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return be||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(ve,void 0,void 0,(function(){return i(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){ve.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(ve,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===y.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return t(a,void 0,void 0,(function(){var t,n,r,o,a,c,d,l,u;return i(this,(function(i){switch(i.label){case 0:return t=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})),t?(n=[t.productId],[4,K.searchProducts({input:{productIdList:n,priceListId:ne.getPriceListId(),salesChannelId:ne.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.sent()).isSuccess&&(null===(u=null===(l=r.data)||void 0===l?void 0:l.data)||void 0===u?void 0:u.length)?(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(t.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(i){if(!t.discountAmount)return i;var s=!1;return t.discountType===b.AMOUNT&&(s=!0),new R(e(e({},i),{prices:i.prices.map((function(i){var n=i.finalPrice,r=i.finalPrice-(s?t.discountAmount:i.finalPrice*t.discountAmount/100);return t.applicablePrice===C.SELL_PRICE&&(n=i.sellPrice,r=i.sellPrice-(s?t.discountAmount:i.sellPrice*t.discountAmount/100)),new O(e(e({},i),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new M(e(e({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:t,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===ge.SUCCESS?v.POST_CHECKOUT:v.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return e.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,F.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===ge.SUCCESS?ge.PAYMENT:this.step,null===(s=t.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=t.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:i.sent(),this.isCampaignOfferLoaded=!0,i.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,D.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:e})]:[3,2]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==S.REFUNDED})).map((function(e){return e.variant.fileId})),e.length?[4,x.listProductFile({id:{in:e}})]:[3,2];case 1:(t=i.sent()).isSuccess&&(this.productFiles=t.data||[]),i.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=this.checkout.orderLineItems.find((function(t){return t.variant.id===e.variantId})),t?[4,x.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:t.id})]:[3,2];case 1:s=i.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(e.name),r.click(),r.remove()),i.label=2;case 2:return[3,4];case 3:return o=i.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=d,this.checkoutSettings=u,this.router=p,this.returnPolicy=A,this.privacyPolicy=E,this.termsOfService=Z,this.imprint=W,this.shippingPolicy=z,this.t=me,this.customizationProps=fe,this.mpVM=new V,j.isEnabled&&(this.masterPassBridge=new G(this.secureCard),this.mpVM.setBridge(this.masterPassBridge),this.secureCard.onReady((function(){"card"===ve.secureCard.mode&&ve.checkout.masterPassPaymentGateway&&ve.mpVM.checkMasterPass({checkout:ve.checkout,store:ve.store})}))),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new T({currentLocale:ne.getCurrentLocale()}),this.init(),n(this)}return fe.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===W.AMERICAN_EXPRESS||Se.test(i)},Object.defineProperty(fe.prototype,"merchantSettings",{get:function(){return new E(ne.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.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(fe.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=se.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(fe.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(fe.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"installmentExtraPrice",{get:function(){var e;if(this.installmentPrice&&this.checkout.totalFinalPrice){var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice-t}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"finalPrice",{get:function(){var e;if(this.step===ge.SUCCESS)return this.checkout.totalFinalPrice-this.giftCardTotalPrice;var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice?this.installmentPrice:t},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ye.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasMasterPassGateway",{get:function(){return this.paymentGateways.some((function(e){return!!e.masterPassClientId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"secureCardGatewayId",{get:function(){var e,t=function(e){return e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&"STRIPE"!==e.code&&"STRIPE_EU"!==e.code},i=this.checkout.selectedPaymentGateway;if(i&&t(i))return i.id;var s=this.paymentGateways.filter(t);return null===(e=s.find((function(e){return!!e.masterPassClientId}))||s[0])||void 0===e?void 0:e.id},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"masterPassSavePhoneNumber",{get:function(){return this.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?this.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({withPlus:!0,store:this.store,checkout:this.checkout}):this.mpVM.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToShipping",{get:function(){var e,t,i,s=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),n=!!(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress);return(this.isDigitalOnly?s:this.isShowBillingAddressOnShippingStep?"address"===this.deliveryMethod&&this.useDifferentAddress?n&&s:s:n)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&!this.hasCorrectableEmailTypo&&(null===(i=this.error)||void 0===i?void 0:i.type)!==ye.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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.hasCorrectableEmailTypo||!this.checkout.stockLocationId)&&(!this.isShowBillingAddressOnShippingStep||this.canProceedToShipping)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||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(fe.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrderWithoutShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&!(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGatewayIndex",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));return e},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isTkPay",{get:function(){var e,t,i=this.checkout.selectedPaymentGateway;return i&&"TK_PAY"===i.code&&"true"===(null===(t=null===(e=i.settings)||void 0===e?void 0:e.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===t?void 0:t.value)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCardStorageEnabled",{get:function(){return this.isCardStorageGateway(this.checkout.selectedPaymentGateway)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"visibleSavedCards",{get:function(){var e;return this.isCardStorageEnabled&&this.savedCardsGatewayId===(null===(e=this.checkout.selectedPaymentGateway)||void 0===e?void 0:e.id)?this.savedCards:[]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"selectedSavedCard",{get:function(){var e=this;return this.visibleSavedCards.find((function(t){return t.id===e.selectedSavedCardId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isSavedCardCvvValid",{get:function(){return/^\d{3,4}$/.test(this.savedCardCvv)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isSavedCardCvvReady",{get:function(){var e=this.selectedSavedCard;return!(null==e?void 0:e.requireCvv)||(this.isSecureCardEnabled?this.secureCard.isValid:this.isSavedCardCvvValid)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return e.code===z&&!!e.milesSmilesEnabled}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRate",{get:function(){var e,t,i=null===(t=null===(e=this.milesSmilesPaymentGateway)||void 0===e?void 0:e.settings)||void 0===t?void 0:t.find((function(e){return"miles_smiles_try_per_1000"===e.label})),s=(null==i?void 0:i.value)?parseFloat(i.value):NaN;return isFinite(s)&&s>0?s/1e3:Ce[this.checkout.currencyCode]||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAvailableMiles",{get:function(){var e;return(null===(e=this.milesSmilesDetails)||void 0===e?void 0:e.availableMiles)||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesMaxRedeemable",{get:function(){var e=this.milesSmilesAvailableMiles,t=this.milesSmilesRate,i=this.finalPrice||0;return!t||i<=0?e:Math.min(e,Math.ceil(i/t))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRedeemValue",{get:function(){if(!this.useMilesSmiles)return 0;var e=this.milesSmilesRate;return e?(this.milesToRedeem||0)*e:0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAppliedValue",{get:function(){return this.milesToRedeem>this.milesSmilesAvailableMiles?0:Math.min(this.milesSmilesRedeemValue,this.finalPrice||0)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAmountToPay",{get:function(){return Math.max(0,(this.finalPrice||0)-this.milesSmilesAppliedValue)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesAllMilesUsed",{get:function(){return this.milesToRedeem>0&&this.milesToRedeem===this.milesSmilesMaxRedeemable},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesNothingToPay",{get:function(){return this.checkout.totalFinalPrice<=0||this.finalPrice<=0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesInput",{get:function(){if(!this.isMilesSmilesNothingToPay&&this.useMilesSmiles&&this.isMilesSmilesActive()){var e=Math.floor(this.milesToRedeem||0);if(!(e<1))return{miles:e}}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"store",{get:function(){return se.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===d.UPSELL||this.checkout.createdBy===d.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==u.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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.selectedSavedCard?this.isSavedCardCvvReady:!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!(this.isKlarna||this.isPayPal||this.isHepsiPay)||(this.isSecureCardEnabled?this.secureCard.isValid:null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=ne.getCurrentRouting())||void 0===t?void 0:t.countryCodes;return null===(s=null===(i=this.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(t){var i=new A(e({countrySettings:n.countrySettings},t));return i.checkoutSettings=n.checkoutSettings,i.shippingZones=n.shippingZones,i.getValidatedCustomerAddress(),i}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===d.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrderWithTransaction",{get:function(){var e,t;return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber&&!!(null===(e=this.openEditOrderTransaction)||void 0===e?void 0:e.chargedAmount)&&(null===(t=this.openEditOrderTransaction)||void 0===t?void 0:t.chargedAmount)>0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isEPayKolayEnabled",{get:function(){var e=ne.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPoweredByHidden",{get:function(){var e=ne.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasCorrectableEmailTypo",{get:function(){var e;return!this.checkout.hasCustomer&&!!me((null===(e=this.checkout.customer)||void 0===e?void 0:e.email)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&(!this.checkout.hasValidCustomerEmail||this.hasCorrectableEmailTypo)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesTermsMissing",{get:function(){return this.useMilesSmiles&&this.isMilesSmilesActive()&&!this.isMilesSmilesNothingToPay&&this.milesToRedeem>0&&!this.isMilesSmilesTermsAccepted},enumerable:!1,configurable:!0}),fe.prototype.isMilesSmilesActive=function(){return!this.isMilesSmilesUnavailable&&!!this.milesSmilesPaymentGateway&&this.checkout.currencyCode===Z},Object.defineProperty(fe.prototype,"isSecureCardEnabled",{get:function(){return j.isEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"cardBin",{get:function(){var e,t;if(this.isSecureCardEnabled)return this.secureCard.bin||void 0;var i=null===(t=null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)||void 0===t?void 0:t.split(" ").join("");return i&&i.length>=8?i.slice(0,8):void 0},enumerable:!1,configurable:!0}),fe.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},fe}();function Ee(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function we(e){return e&&ve.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(ge||(ge={})),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",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(ye||(ye={}));export{ge as CheckoutStep,ye as ErrorType,Pe as MILES_SMILES_LOGIN_REQUIRED_CODES,Ce as MILES_SMILES_RATE_PER_POINT,ke as MILES_SMILES_UNAVAILABLE_CODES,Ae as default};
1
+ import{__assign as e,__awaiter as t,__generator as i,__spreadArray as s}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as n}from"mobx";import r from"lodash/cloneDeep";import o 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 a,IkasPaymentGatewayType as c,IkasCartCreatedBy as d,IkasCouponCodeRequirement as l,IkasCorporateInvoiceRequirement as u,IkasOrderShippingMethod as h,IkasOrderStatus as p,IkasCustomerEmailSubscriptionStatus as m,IkasOrderPaymentStatus as f,IkasTransactionStatus as g,IkasCartCampaignOfferStatus as y,IkasCampaignOfferTargetPageType as v,IkasOrderLineItemStatus as S,IkasAmountType as b,IkasCampaignOfferProductApplicablePriceEnum as C}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{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/region/index.js";import{IkasCustomerAddress as I}from"../../models/data/customer/address/index.js";import{IkasLocalizedCustomerAddress as A}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/customer-form-data-input/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 E}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 w}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/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import{IkasProductPrice as O}from"../../models/data/product/variant/price/index.js";import{IkasProductVariant as R}from"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as M}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/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/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 T,COUNTRY_FORMS_LOCALES as N,LocalizedAddressConfig as L}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 _ from"./components/credit-card-form/model.js";import G from"./components/secure-card-form/model.js";import j from"./components/secure-card-form/masterpass-bridge-model.js";import D from"../../store/customer/api.js";import x from"../../store/checkout/index.js";import F from"../../store/cart/api.js";import V,{MFS_ELEMENT_ID as U,MFS_SCRIPT_URL as B}from"./modelMasterPass.js";import{APIResponse as Y}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import H from'./../../ext/@ikas/fe-api-client/build/config/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import K from"../../store/product/index.js";import{MILES_SMILES_CURRENCY_CODE as Z,TransactionCardAssociationEnum as W,MILES_SMILES_CARD_GATEWAY_CODE as z,SaveCartInput as q,CheckStocksLineInput as Q,getLoyaltyCustomerInfo as X,listSpendingMethodsByCartId as $,LoyaltyProgramPointEarningTypeEnum as J,listEarningMethods as ee,getMilesSmilesDetails as te,CampaignOfferTargetPageTypeEnum as ie}from"@ikas/storefront-api";import{IkasBaseStore as se}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as ne}from"@ikas/storefront-config";import{Analytics as re}from"../../analytics/analytics.js";import{isPaymentScriptPolicyEnabled as oe}from"../../analytics/head/index.js";import ae from"../../models/data/order/address/ikas-localized-order-address.js";import ce from"../../store/location/index.js";import{getCookieValue as de,getOpenAiAttributionMetadata as le,isEqual as ue}from"../../utils/helper.js";import{readMilesSmilesBindResult as he}from"../../utils/miles-smiles.js";import pe from"../../analytics/ikasV3.js";import{suggestEmailCorrection as me}from"@ikas/storefront-model-functions";var fe,ge,ye,ve=/^\d+$/,Se=/^3[47]/,be="undefined"==typeof localStorage,Ce=((fe={})[Z]=.35,fe),Pe=["UNAUTHORIZED","AUTHORIZATION_REQUIRED","MILES_SMILES_LOGIN_REQUIRED","MILES_SMILES_MEMBER_MISMATCH","EXTERNAL_ACCOUNT_MEMBER_MISMATCH"],ke=["MILES_SMILES_NOT_ENABLED","MILES_SMILES_GATEWAY_NOT_SUPPORTED","MILES_SMILES_CURRENCY_NOT_SUPPORTED","MILES_SMILES_RATE_NOT_CONFIGURED","MILES_SMILES_OAUTH_NOT_CONFIGURED","PAYMENT_GATEWAY_NOT_FOUND"],Ie=function(e){return!!e&&(e.startsWith("MILES_")||e.startsWith("EXTERNAL_ACCOUNT_")||"INVALID_MILES"===e)},Ae=function(){function fe(d,u,p,A,E,Z,W,z,me,fe){var ve=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isCheckoutLoadFailed=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.isPaymentMethodVisible=!0,this.step=ge.INFO,this.customizationProps=null,this.cardData=null,this.storeCard=!1,this.savedCards=[],this.savedCardsGatewayId=null,this.selectedSavedCardId=null,this.savedCardCvv="",this.secureCard=new G({onBinChange:function(e){return ve.onCardBinChange(e)},onMasterPassConsentChange:function(e){return ve.mpVM.onSaveCardToMasterPassCheckedChange(e)}}),this.masterPassBridge=null,this.paymentGateways=[],this.useMilesSmiles=!1,this.isMilesSmilesTermsAccepted=!1,this.milesToRedeem=0,this.isMilesSmilesLoginRequired=!1,this.isMilesSmilesUnavailable=!1,this.isMilesSmilesBindLoading=!1,this.milesSmilesDetails=null,this.milesSmilesError=null,this.milesSmilesBindLanding=null,this.isMiniCartOpenOnLoad=!1,this.productFiles=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.stripeError=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.klarnaError=null,this.adyenResponse=null,this.payPalClientIdResponse=null,this.paypalOrderResponse=null,this.hepsipayFrameInitResponse=null,this.iyzicoResponse=null,this.isIyzicoLoading=!1,this.showIyzicoContainer=!1,this.tkPayResponse=null,this.isTkPayLoading=!1,this.showTkPayContainer=!1,this.tkPayFormMiles=null,this.isTkPayPaymentCompleted=!1,this.stripeExpressCheckoutSessionResponse=null,this.isStripeExpressCheckoutSessionVisible=!1,this.isCampaignOfferLoaded=!0,this.shippingZones=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.couponError=null,this.storeCreditBalance=null,this.loyaltyCustomerInfo=null,this.loyaltySpendingMethods=null,this.loyaltySpendingMethodsAll=null,this.loyaltyEarningMethod=null,this.isLoyaltyPointsVisible=!1,this.showTestModal=!1,this.openEditOrderTransaction=null,this.previousRawValue="",this.previousBin=null,this.init=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:if(this.redirectTopIfInsideIframe())return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.waitForCountrySettingsOrFail()];case 2:return t.sent(),[3,4];case 3:return t.sent(),this.isCheckoutLoadFailed=!0,[2];case 4:return[4,se.getInstance().customerStore.waitUntilInitialized()];case 5:return t.sent(),(e=this.isOpenEditOrder||this.checkout.edited)?[4,this.getOpenEditOrderTransaction()]:[3,7];case 6:t.sent(),t.label=7;case 7:return e&&(this.openEditOrderTransaction||this.checkout.edited)||this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.initStep()];case 8:return t.sent(),[2]}}))}))},this.redirectTopIfInsideIframe=function(){if(be||ne.getIsEditor())return!1;try{return!(window.self===window.top||!window.top)&&(window.top.location.origin===window.location.origin&&(window.top.location.replace(window.location.href),!0))}catch(e){return!1}},this.waitForCountrySettingsOrFail=function(){return new Promise((function(e,s){var n=!1,r=function(){n=!0,clearInterval(o),clearTimeout(a)},o=setInterval((function(){ve.countrySettings.initialized&&(r(),e())}),100),a=setTimeout((function(){n||(r(),s(new Error("timeout")))}),1e4);t(ve,void 0,void 0,(function(){var e,t,o,a,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=ne.getCurrentLocale(),N.includes(e)||(e="en"),t="".concat(L.getCDNUrl(),"sf/static/location/settings.json"),o="https://eu.myikas.com/sf/static/location/".concat(e,".json"),[4,Promise.all([fetch(t),fetch(o)])];case 1:return a=i.sent(),n?[2]:(a.some((function(e){return!e.ok}))&&(r(),s(new Error("fetch failed"))),[3,3]);case 2:return c=i.sent(),n?[2]:(r(),s(c),[3,3]);case 3:return[2]}}))}))}))},this.initStep=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,a,c,d;return i(this,(function(i){switch(i.label){case 0:if(ne.getIsEditor())return this.step=ge.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),s=t.get("step"),n=t.get("failed"),r=t.get("error"),this.isMiniCartOpenOnLoad="open"===t.get("miniCart"),this.milesSmilesBindLanding=he(),s){if(this.step=s,this.step===ge.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(ge.INFO)];if(this.step!==ge.PAYMENT||this.canProceedToPayment){if(this.step===ge.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(ge.INFO)];if(![ge.INFO,ge.SUCCESS,ge.SHIPPING,ge.PAYMENT].includes(this.step))return[2,this.changeStep(ge.INFO)]}else{if(!this.isInStoreDelivery)return this.isValidShippingSettings||this.isManualOrderWithoutShippingLines?[2,this.changeStep(ge.INFO)]:[2,this.changeStep(ge.SHIPPING)];this.deliveryMethod="in-store"}}return[4,this.createCampaignOffer()];case 1:return i.sent(),this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isCouponCodeRequirementInvisible||(this.checkoutSettings=new k(e(e({},this.checkoutSettings),{couponCodeRequirement:l.DEFAULT}))),this.step!==ge.INFO?[3,7]:this.isDigitalOnly?[3,4]:[4,this.getAvailableShippingZones()];case 2:return i.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getShippingCountries()];case 3:i.sent(),this.checkShippingCountries(),i.label=4;case 4:return[4,this.getStockLocations()];case 5:return i.sent(),[4,this.getAvailableStockLocations()];case 6:i.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),i.label=7;case 7:if(this.step===ge.SHIPPING&&1===(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)&&!this.checkoutSettings.isGiftPackageEnabled){if(oe())return this.changeStep(ge.PAYMENT),[2];this.step=ge.PAYMENT,o=this.getRoutingPath(),this.router.replace("".concat(o,"/checkout?id=").concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})}return this.step!==ge.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==ge.SUCCESS||this.checkout.orderPaymentStatus!==f.PAID?[3,9]:[4,this.listProductFile()]:(this.error={type:ye.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 8:i.sent(),i.label=9;case 9:return this.step!==ge.PAYMENT&&this.step!==ge.SUCCESS?[3,15]:[4,this.listPaymentGateways()];case 10:return i.sent(),this.checkout.hasCustomer?[4,this.getStoreCreditBalance()]:[3,12];case 11:i.sent(),i.label=12;case 12:return this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,14];case 13:i.sent(),i.label=14;case 14:if(!this.paymentGateways.length&&!this.isFree)return this.error={type:ye.NO_SHIPPING_ERROR},this.isMinTransactionError&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:minTransactionErrorMessage",{value:200})}),this.isCheckoutLoaded=!0,[2];i.label=15;case 15:return this.step===ge.SUCCESS?[3,23]:this.isOpenEditOrder?[3,18]:this.checkout.isComplete?[2,this.changeStep(ge.SUCCESS)]:[3,16];case 16:return[4,this.initialStockCheck()];case 17:i.sent(),i.label=18;case 18:return this.checkout.hasCustomer?[4,this.getLoyaltyCustomerInfo()]:[3,22];case 19:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 20:return i.sent(),[4,this.listEarningMethods()];case 21:i.sent(),i.label=22;case 22:return[3,25];case 23:return[4,this.getSuccessTransaction()];case 24:i.sent(),this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(e){return e.id===a}))),i.label=25;case 25:return n&&(this.error={type:ye.PAYMENT_ERROR,data:r||null}),this.isCheckoutLoaded=!0,re.checkoutStep(this.checkout,this.step,this.checkoutSettings),[2]}}))}))},this.getOpenEditOrderTransaction=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,D.listOrderTransactionsWithPrices({input:{orderId:this.checkout.id}})];case 1:return(e=t.sent()).isSuccess&&e.data&&e.data.chargedAmount&&(this.openEditOrderTransaction=e.data),[2]}}))}))},this.getSuccessTransaction=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return[4,D.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return e=i.sent(),this.successTransactions=e.isSuccess&&(null===(t=e.data)||void 0===t?void 0:t.length)?e.data:[],this.successTransaction=e.isSuccess&&(null===(s=e.data)||void 0===s?void 0:s.length)?e.data[e.data.length-1]:void 0,[2]}}))}))},this.isCardStorageGateway=function(e){var t,i;return!!e&&"PAYTR"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"card_storage_enabled"===e.label})))||void 0===i?void 0:i.value)&&!!ve.store.customerStore.customer},this.saveCart=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,a,c,d,l,u,h,p,f,g,y,v,S;return i(this,(function(i){switch(i.label){case 0:return t=new q(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=i.sent(),i.label=2;case 2:return this.step!==ge.INFO&&this.step!==ge.SHIPPING&&this.step!==ge.PAYMENT||this.isDigitalOnly||(this.isShowBillingAddressOnShippingStep||this.step===ge.PAYMENT||(t.billingAddress=null),t.billingAddress&&(this.isShowBillingAddressOnShippingStep&&this.useDifferentAddress||this.useDifferentAddress&&!this.isShowBillingAddressOnShippingStep&&this.checkoutSettings.showCompanyInfoInShippingAddress)&&(t.billingAddress.company=(null===(r=t.shippingAddress)||void 0===r?void 0:r.company)||null,t.billingAddress.taxNumber=(null===(o=t.shippingAddress)||void 0===o?void 0:o.taxNumber)||null,t.billingAddress.taxOffice=(null===(a=t.shippingAddress)||void 0===a?void 0:a.taxOffice)||null)),this.isDigitalOnly&&(t.shippingAddress=null),t.customer&&(this.store.customerStore.customer?t.customer.notificationsAccepted=this.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED:this.checkout.customer&&(t.customer.notificationsAccepted=this.checkout.customer.notificationsAccepted||!1)),null===(null===(d=null===(c=t.shippingAddress)||void 0===c?void 0:c.city)||void 0===d?void 0:d.code)&&""===(null===(u=null===(l=t.shippingAddress)||void 0===l?void 0:l.city)||void 0===u?void 0:u.name)&&(t.shippingAddress.city.name="-"),null===(null===(p=null===(h=t.billingAddress)||void 0===h?void 0:h.city)||void 0===p?void 0:p.code)&&""===(null===(g=null===(f=t.billingAddress)||void 0===f?void 0:f.city)||void 0===g?void 0:g.name)&&(t.billingAddress.city.name="-"),t.metadata=e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),[4,F.saveCart({input:t})];case 3:if((null==(s=i.sent())?void 0:s.graphQLErrors)&&s.graphQLErrors.length)throw n=s.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(y=n.extensions)||void 0===y?void 0:y.code)?{type:ye.CUSTOMER_LOGIN_REQUIRED_ERROR}:"CUSTOMER_ACCOUNT_DISABLED"===(null===(v=n.extensions)||void 0===v?void 0:v.code)?{type:ye.CUSTOMER_ACCOUNT_DISABLED_ERROR}:"ARGUMENT_VALIDATION_ERROR"===(null===(S=n.extensions)||void 0===S?void 0:S.code)?{type:ye.ARGUMENT_VALIDATION_ERROR,data:n.extensions.validationErrors}:{type:ye.API_ERROR,data:s.firstErrorMessage};return[2,s.data]}}))}))},this.inStockDeliveryInputData=function(e){return t(ve,void 0,void 0,(function(){var t,s,n=this;return i(this,(function(i){return t=e,(s=this.stockLocations.find((function(e){return e.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c,d,l,u,p,m,f;return i(this,(function(i){switch(i.label){case 0:return this.isManualOrder||this.isOpenEditOrderWithTransaction?[2]:(e=this.checkout.stockLocationId&&this.checkout.shippingMethod===h.CLICK_AND_COLLECT?[this.checkout.stockLocationId]:(null===(p=ne.getStockLocationIds())||void 0===p?void 0:p.length)?ne.getStockLocationIds():null,[4,x.checkCartStocks({cartId:this.checkout.id,stockLocationIdList:e})]);case 1:if(!(t=i.sent()).isSuccess)throw s="UPSELL"===this.checkout.createdBy,n=s?this.t("checkout-page:upsellTimeErrorMessage"):t.firstErrorMessage,{type:ye.API_ERROR,data:n};if(null==(r=null===(f=null===(m=t.data)||void 0===m?void 0:m.lines)||void 0===f?void 0:f.filter((function(e){return!e.isAvailable})))?void 0:r.length){for(o=[],a=function(e){var t=c.checkout.items.find((function(t){return t.variant.id===e.variantId}));t&&o.push({item:t,stockCount:e.stockCount})},c=this,d=0,l=r;d<l.length;d++)u=l[d],a(u);throw{type:ye.STOCK_ERROR,data:o}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isKlarnaPaymentCompleted=e,[2]}))}))},this.setIsLoyaltyPointsVisible=function(e){ve.isLoyaltyPointsVisible=e},this.removeUnavailableItems=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:t=0,s=e,i.label=1;case 1:return t<s.length?(n=s[t],[4,se.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount<0?0:n.stockCount)]):[3,4];case 2:i.sent(),i.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getAvailableShippingCountries({salesChannelId:ne.getSalesChannelId()})];case 1:return e=t.sent(),this.shippingCountryIds=e.data,[2]}}))}))},this.getStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?[4,x.listStockLocation({id:{in:ne.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(e=i.sent()).isSuccess||!(null===(t=e.data)||void 0===t?void 0:t.length))return this.error={type:ye.API_ERROR,data:e.firstErrorMessage},[2];this.stockLocations=e.data,i.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n=this;return i(this,(function(i){switch(i.label){case 0:return ne.getPickupStockLocationIds()?(e=this.checkout.items.map((function(e){return{quantity:e.quantity,variantId:e.variant.id,productId:e.variant.productId}})),[4,x.getAvailableStockLocations({lines:e.map((function(e){return new Q(e)})),stockLocationIdList:ne.getPickupStockLocationIds(),cartId:this.checkout.id})]):[3,2];case 1:if(!(t=i.sent()).isSuccess)return this.error={type:ye.API_ERROR},[2];s=ne.getCurrentRouting(),this.availableStockLocations=(t.data||[]).filter((function(e){var t,i,r,o;return(null===(i=null===(t=e.address)||void 0===t?void 0:t.country)||void 0===i?void 0:i.id)&&e.address.country.iso2&&(null===(r=n.shippingCountryIds)||void 0===r?void 0:r.includes(e.address.country.id))&&(!(null===(o=null==s?void 0:s.countryCodes)||void 0===o?void 0:o.length)||s.countryCodes.includes(e.address.country.iso2))})),i.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var e;(null===(e=ve.shippingCountryIds)||void 0===e?void 0:e.length)||(ve.error={type:ye.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(e){var t;ve.deliveryMethod!==e&&("address"===e&&(ve.checkout.stockLocationId=null,(null===(t=ve.customerAddresses)||void 0===t?void 0:t.length)?ve.onSelectedShippingAddressIdChange(ve.customerAddresses[0].id||"-1"):(ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)),ve.deliveryMethod=e,ve.isErrorsVisible=!1)},this.initialStockCheck=function(){return t(ve,void 0,void 0,(function(){var e;return i(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:ye.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.getStoreCreditBalance=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,x.getStoreCreditBalance()];case 1:return e=t.sent(),this.storeCreditBalance=e.data,[2]}}))}))},this.getLoyaltyCustomerInfo=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,X({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyCustomerInfo=e.data),[2]}}))}))},this.listSpendingMethodsByCartId=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,$({cartId:this.checkout.id})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltySpendingMethods=e.data.filter((function(e){return e.isAvailable})),this.loyaltySpendingMethodsAll=e.data),[2]}}))}))},this.listEarningMethods=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,ee()];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.loyaltyEarningMethod=e.data.find((function(e){return"ORDER_CREATE"===e.methodType&&e.pointEarningType===J.DYNAMIC_ORDER_AMOUNT}))),[2]}}))}))},this.listPaymentGateways=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return this.resetMilesSmilesIfNothingToPay(),e="local"===process.env.NEXT_PUBLIC_ENV,t=ne.getPaymentGateways().map((function(e){return e.id})),[4,x.listPaymentGateway({cartId:this.checkout.id,id:e?void 0:{in:t},locale:ne.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=i.sent()).isSuccess?(null===(p=s.data)||void 0===p?void 0:p.length)||this.isFree?(this.error=void 0,n=null===(m=s.data)||void 0===m?void 0:m.some((function(e){return"IKAS_WALLET"===e.code})),this.isMinTransactionError=n&&this.finalPrice<200&&!this.isDigitalOnly,this.isMinTransactionError?[2]:(r=s.data||[],this.step===ge.PAYMENT&&(r=r.filter((function(e){var t;return!(null===(t=e.supportedCurrencies)||void 0===t?void 0:t.length)||e.supportedCurrencies.includes(y.checkout.currencyCode)})),(a=null===(f=this.checkout.shippingAddress)||void 0===f?void 0:f.country)&&a.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(a.iso2||"")}))),c=null===(g=this.checkout.billingAddress)||void 0===g?void 0:g.country,!a&&c&&c.iso2&&(r=r.filter((function(e){var t;return!(null===(t=e.availableCountries)||void 0===t?void 0:t.length)||e.availableCountries.includes(c.iso2||"")})))),d=[],o(ne.getPaymentGateways(),"order").forEach((function(e){var t=null==r?void 0:r.find((function(t){return t.id===e.id}));t&&d.push(t)})),this.paymentGateways=e?r:d,l=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code})),this.step===ge.SUCCESS?[3,4]:this.checkout.selectedPaymentGateway&&this.paymentGateways.some((function(e){var t;return e.id===(null===(t=y.checkout.selectedPaymentGateway)||void 0===t?void 0:t.id)}))?[3,2]:(this.setPaymentGateway(-1!==l?l:0),[3,4]))):(this.error={type:ye.NO_SHIPPING_ERROR},[2]):(this.error={type:ye.API_ERROR,data:s.firstErrorMessage},[2]);case 2:return this.step!==ge.PAYMENT?[3,4]:[4,this.updatePaymentGateway(this.checkout.selectedPaymentGateway)];case 3:i.sent(),i.label=4;case 4:return this.step===ge.PAYMENT&&((u=r.find((function(e){return!!e.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=u),u&&!this.masterPassBridge&&((h=document.createElement("script")).id=U,h.src=B,h.onload=function(){y.mpVM.checkMasterPass({checkout:y.checkout,store:se.getInstance()})},document.head.appendChild(h))),this.isMilesSmilesActive()?[4,this.loadMilesSmilesDetails()]:[3,6];case 5:i.sent(),i.label=6;case 6:return[2]}}))}))},this.resetMilesSmilesIfNothingToPay=function(){ve.isMilesSmilesNothingToPay&&(ve.useMilesSmiles=!1,ve.milesToRedeem=0,ve.isMilesSmilesTermsAccepted=!1)},this.loadMilesSmilesDetails=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return this.isMilesSmilesActive()?(e=this.milesSmilesBindLanding,this.milesSmilesBindLanding=null,"fail"===(null==e?void 0:e.status)&&(this.milesSmilesError=e.errorCode||"MILES_SMILES_LOGIN_CANCELLED_OR_FAILED"),this.store.customerStore.customer?[4,te()]:(this.isMilesSmilesLoginRequired=!0,this.milesSmilesDetails=null,[2])):[2];case 1:return(t=i.sent()).isSuccess&&t.data?(this.milesSmilesDetails=t.data,this.isMilesSmilesLoginRequired=!1,"success"!==(null==e?void 0:e.status)||this.useMilesSmiles||this.isMilesSmilesNothingToPay?[3,3]:[4,this.setUseMilesSmiles(!0)]):[3,4];case 2:i.sent(),i.label=3;case 3:return[2];case 4:return s=t.errorCodes,Pe.some((function(e){return s.includes(e)}))?(this.isMilesSmilesLoginRequired=!0,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesDetails=null,[2]):ke.some((function(e){return s.includes(e)}))?(this.isMilesSmilesUnavailable=!0,this.milesSmilesDetails=null,this.useMilesSmiles=!1,this.milesToRedeem=0,[2]):(this.milesSmilesDetails=null,this.milesSmilesError=s[0]||"MILES_MEMBER_DETAILS_FAILED",[2])}}))}))},this.getMilesSmilesBindRedirect=function(){var e=ve.getRoutingPath();return"".concat(e,"/checkout?id=").concat(ve.checkout.id,"&step=").concat(ge.PAYMENT)},this.getMilesSmilesLoginRedirectUrl=function(){var e=ve.getRoutingPath();return"".concat(e,"/account/login?redirect=").concat(encodeURIComponent(ve.getMilesSmilesBindRedirect()))},this.startMilesSmilesBind=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.milesSmilesError=null,this.store.customerStore.customer?(this.isMilesSmilesBindLoading=!0,[4,this.store.customerStore.startMilesSmilesBind(this.getMilesSmilesBindRedirect())]):(window.location.href=this.getMilesSmilesLoginRedirectUrl(),[2]);case 1:return(e=t.sent()).isSuccess||(this.isMilesSmilesBindLoading=!1,this.milesSmilesError=e.errorCode||"UNEXPECTED_ERROR"),[2]}}))}))},this.setUseMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return this.useMilesSmiles=e,this.isMilesSmilesTermsAccepted=!1,this.milesSmilesError=null,e?(t=this.milesSmilesPaymentGateway,-1===(s=t?this.paymentGateways.findIndex((function(e){return e.id===t.id})):-1)||this.selectedPaymentGatewayIndex===s?[3,2]:[4,this.setPaymentGateway(s)]):[3,2];case 1:i.sent(),this.mpVM.selectedCard=void 0,i.label=2;case 2:return this.milesToRedeem=0,[4,this.onMilesSmilesSelectionChange()];case 3:return i.sent(),[2]}}))}))},this.setMilesSmilesTermsAccepted=function(e){ve.isMilesSmilesTermsAccepted=e},this.setMilesToRedeem=function(e){ve.milesToRedeem=Math.max(0,Math.floor(e||0))},this.clampMilesToRedeem=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this.milesSmilesMaxRedeemable,this.milesToRedeem>e&&(this.milesToRedeem=e),[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.selectMilesSmilesChip=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return e>this.milesSmilesMaxRedeemable?[2]:(this.milesToRedeem=e,[4,this.onMilesSmilesSelectionChange()]);case 1:return t.sent(),[2]}}))}))},this.setUseAllMilesSmiles=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.milesToRedeem=e?this.milesSmilesMaxRedeemable:0,[4,this.onMilesSmilesSelectionChange()];case 1:return t.sent(),[2]}}))}))},this.onMilesSmilesSelectionChange=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return this.isTkPay&&this.checkout.selectedPaymentGateway?this.isTkPayPaymentCompleted?[2]:(e=(null===(t=this.milesSmilesInput)||void 0===t?void 0:t.miles)||0,this.tkPayResponse&&this.tkPayFormMiles===e?[2]:(this.tkPayResponse=null,[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)])):[2];case 1:return i.sent(),[2]}}))}))},this.handleMilesSmilesSaleError=function(e){var t,i;return ve.handleMilesSmilesErrorCodes(s(s([],e.errorCodes||[],!0),[null===(i=null===(t=e.data)||void 0===t?void 0:t.error)||void 0===i?void 0:i.code],!1))},this.handleMilesSmilesErrorCodes=function(e){var t=e.filter(Ie);if(!t.length)return null;var i=t[0];return Pe.includes(i)?(ve.isMilesSmilesLoginRequired=!0,ve.isMilesSmilesTermsAccepted=!1,ve.milesSmilesDetails=null,ve.useMilesSmiles=!1,ve.milesToRedeem=0):ke.includes(i)&&(ve.isMilesSmilesUnavailable=!0,ve.useMilesSmiles=!1,ve.milesToRedeem=0),ve.milesSmilesError=i,ve.getMilesSmilesErrorMessage(i)},this.getMilesSmilesErrorMessage=function(e){var t="checkout-page:milesSmilesErrors.".concat(e),i=e?ve.t(t):"";return i&&i!==t?i:ve.t("checkout-page:milesSmilesErrors.default")},this.retrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return[4,x.retrieveInstallmentInfo(e)];case 1:return t=i.sent(),s=t.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 t;ve.store.customerStore.customer?(null===(t=ve.customerAddresses)||void 0===t||t.forEach((function(e){e.checkoutSettings=ve.checkoutSettings,e.shippingZones=ve.shippingZones})),ve.checkout.customer=new w(e(e({},ve.store.customerStore.customer),{notificationsAccepted:ve.store.customerStore.customer.subscriptionStatus===m.SUBSCRIBED}))):ve.checkout.customer=new w(ve.checkout.customer||{})},this.setCheckoutShippingAddressSettings=function(){ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones,ve.checkout.shippingAddress.countrySettings=ve.countrySettings,ve.checkout.shippingAddress.getValidatedCustomerAddress())},this.setCheckoutBillingAddressSettings=function(){ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones,ve.checkout.billingAddress.countrySettings=ve.countrySettings,ve.checkout.billingAddress.getValidatedCustomerAddress())},this.createShippingAddress=function(){if(!ve.isDigitalOnly)if(ve.isInStoreDelivery)ve.setCheckoutShippingAddressSettings();else if(ve.checkout.shippingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.shippingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedShippingAddressIdChange(e.id||"-1"),void ve.setCheckoutShippingAddressSettings()}ve.checkout.shippingAddress=new ae(r(ve.checkout.shippingAddress)||{}),ve.setCheckoutShippingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else ve.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(ve.useDifferentAddress=!!localStorage.getItem("sAddr"),ve.checkout.billingAddress){if(ve.store.customerStore.customer){var e=null==(t=ve.customerAddresses)?void 0:t.find((function(e){var t;return e.id===(null===(t=ve.checkout.billingAddress)||void 0===t?void 0:t.id)}));if(e)return ve.onSelectedBillingAddressIdChange(e.id||"-1"),void ve.setCheckoutBillingAddressSettings()}ve.checkout.billingAddress=new ae(r(ve.checkout.billingAddress)||{}),ve.setCheckoutBillingAddressSettings()}else if(ve.store.customerStore.customer){var t=ve.customerAddresses;ve.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1"),(null==t?void 0:t.length)||ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())}else ve.onSelectedBillingAddressIdChange("-1"),ve.useDifferentAddress||!ve.checkout.shippingAddress||ve.isInStoreDelivery||(ve.checkout.billingAddress=new ae(r(ve.checkout.shippingAddress)),ve.setCheckoutBillingAddressSettings())},this.onShippingMethodChange=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=e.shippingSettingsId,this.checkout.shippingZoneRateId=e.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=i.sent())&&(this.checkout=new P(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings,this.checkout.shippingAddress.shippingZones=this.shippingZones),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.checkout.stockLocationId=e.id,[2]}))}))},this.onCouponCodeApply=function(s){return t(ve,void 0,void 0,(function(){var t,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(o=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT||this.checkout.totalFinalPrice===o.totalFinalPrice&&!this.checkout.giftCardLines?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,s?re.addCouponCode(n):re.removeCouponCode(n),i.label=7;case 7:return t.isSuccess||(this.couponError=t.errorCodes[0]),[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.removeGiftCardLine=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,F.removeGiftCardFromCart({cartId:this.checkout.id,giftCardId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,7];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,7];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:i.sent(),this.isCampaignOfferLoaded=!0,i.label=7;case 7:return[3,9];case 8:return i.sent(),[3,9];case 9:return[2]}}))}))},this.refreshCheckoutCart=function(){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return[4,F.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:null===(s=this.checkout.selectedPaymentGateway)||void 0===s?void 0:s.id,targetPageType:ie.CHECKOUT})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.checkout=new P(e(e({},t.data),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),[2,!0]):[2,!1]}}))}))},this.removeLoyaltyPointsFromCart=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,10,,11]),[4,F.removeLoyaltyPointsFromCart({cartId:this.checkout.id,loyaltySpendingMethodId:s})];case 1:return(t=i.sent()).isSuccess&&t.data?(n=t.data,r=this.cardBin,this.couponError=null,this.step===ge.PAYMENT&&r&&this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:r,paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:this.mpVM.selectedCard.Value1.slice(0,8),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:n.totalFinalPrice,currencyCode:this.checkout.currencyCode}})]:[3,3]):[3,9];case 2:i.sent(),i.label=3;case 3:return n?(this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:this.checkout.shippingAddress,billingAddress:this.checkout.billingAddress,customer:this.checkout.customer,selectedPaymentGateway:this.checkout.selectedPaymentGateway}),this.countrySettings),this.step!==ge.PAYMENT?[3,5]:[4,this.listPaymentGateways()]):[3,9];case 4:i.sent(),i.label=5;case 5:return this.checkout.campaignOffers=n.campaignOffers,this.isCampaignOfferLoaded=!1,[4,this.createCampaignOffer()];case 6:return i.sent(),this.isCampaignOfferLoaded=!0,re.removeLoyaltyPoints(n),[4,this.getLoyaltyCustomerInfo()];case 7:return i.sent(),[4,this.listSpendingMethodsByCartId()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return i.sent(),[3,11];case 11:return[2]}}))}))},this.getAvailableShippingZones=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ce.getAvailableShippingZones({salesChannelId:ne.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(ve.selectedShippingAddressId=e,"-1"===e)ve.checkout.shippingAddress=new ae,ve.checkout.shippingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.shippingAddress=new ae(i),ve.checkout.shippingAddress.countrySettings=ve.countrySettings)}ve.checkout.shippingAddress&&(ve.checkout.shippingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.shippingAddress.shippingZones=ve.shippingZones)},this.onSelectedBillingAddressIdChange=function(e){var t;if(ve.selectedBillingAddressId=e,"-1"===e)ve.checkout.billingAddress=new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings;else{var i=null===(t=ve.customerAddresses)||void 0===t?void 0:t.find((function(t){return t.id===e}));i&&(ve.checkout.billingAddress=new ae(i),ve.checkout.billingAddress.countrySettings=ve.countrySettings)}ve.checkout.billingAddress&&(ve.checkout.billingAddress.checkoutSettings=ve.checkoutSettings,ve.checkout.billingAddress.shippingZones=ve.shippingZones)},this.onTermsAndConditionsCheckedChange=function(e){ve.isTermsAndConditionsChecked=e,ve.isIyzico&&(ve.showIyzicoContainer=e),ve.isTkPay&&(ve.showTkPayContainer=e,ve.saveCart())},this.onCardNumberChange=function(e){if(ve.cardData){var t=(e||"").replace(/\D/g,""),i=ve.previousRawValue,s=t.slice(0,8),n=ve.previousBin;if(!(t.length>16)){var r=i.length<8&&t.length>=8,o=8===s.length&&s!==n;(r||o)&&8===s.length&&(ve.getRetrieveInstallmentInfo(t),ve.previousBin=s),t.length<8&&i.length>=8&&(ve.cardData.installmentCount=1,ve.installmentInfo=void 0,ve.previousBin=null),ve.isAmexCard(t)?ve.cardData.cardNumber=function(e){var t=[],i=e.slice(0,4),s=e.slice(4,10),n=e.slice(10,15);i&&t.push(i);s&&t.push(s);n&&t.push(n);return t}(t).join(" "):ve.cardData.cardNumber=Ee(t,4).join(" "),ve.previousRawValue=t}}},this.onCardBinChange=function(e){if(ve.cardData&&ve.checkout.selectedPaymentGateway&&!ve.selectedSavedCard)return e?void ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,binNumber:e,paymentGatewayId:ve.checkout.selectedPaymentGateway.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}}):(ve.cardData.installmentCount=1,void(ve.installmentInfo=void 0))},this.getRetrieveInstallmentInfo=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,this.retrieveInstallmentInfo({input:{orderId:this.checkout.id,binNumber:e.slice(0,8),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:this.checkout.totalFinalPrice,currencyCode:this.checkout.currencyCode}})];case 1:return i.sent(),(null===(t=this.cardData)||void 0===t?void 0:t.cardNumber)&&this.onCardNumberChange(this.cardData.cardNumber),[2]}}))}))},this.onCardHolderNameChange=function(e){ve.cardData&&(ve.cardData.cardHolderName=e)},this.onExpirationDateChange=function(e){var t;if(ve.cardData&&(!(e.length>ve.cardData.expirationDate.length)||we(e))){if(0===(null===(t=ve.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(ve.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(ve.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(ve.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=e.split(" / ").join("");d.length>4||(ve.cardData.expirationDate=Ee(d,2).join(" / "))}},this.onCvcChange=function(e){if(ve.cardData&&(!(e.length>ve.cardData.cvv.length)||we(e))){if(ve.isAmexCard()){if(e.length>4)return}else if(e.length>3)return;ve.cardData.cvv=e}},this.saveAddress=function(s){return t(ve,void 0,void 0,(function(){var t,n,o,a,c,d,l,u,h,p,m,f,g,y=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,n=null===(p=this.customerAddresses)||void 0===p?void 0:p.find((function(e){return e.id===(null==t?void 0:t.id)})),n?[2]:(o=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(e){return e.id})),a=new I(e(e({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(c=r(this.store.customerStore.customer)).addresses||(c.addresses=[]),c.addresses.push(a),[4,this.store.customerStore.saveCustomer(c)])):[3,2];case 1:i.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(e){e.checkoutSettings=y.checkoutSettings,e.shippingZones=y.shippingZones})),d=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(e){return e.id})),l=null==d?void 0:d.filter((function(e){return!(null==o?void 0:o.includes(e))})),u=(null==l?void 0:l.length)?l[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),i.label=2;case 2:return[3,4];case 3:return h=i.sent(),console.error(h),[3,4];case 4:return[2]}}))}))},this.getRoutingPath=function(){var e=ne.getCurrentRouting();return(null==e?void 0:e.path)?"/".concat(e.path):""},this.getGoToCartHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/cart")},this.getBackToShoppingHref=function(){var e=ve.getRoutingPath();return"".concat(e,"/")},this.getGoToLoginHref=function(){var e=ve.getRoutingPath();return"".concat(e)+"/account/login?redirect="+encodeURIComponent(ve.checkoutUrl)},this.onHandleBillingAddressOnShippingStep=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return this.isShowBillingAddressOnShippingStep&&!this.useDifferentAddress&&("address"===this.deliveryMethod&&this.checkout.shippingAddress?this.checkout.billingAddress=new ae(e({},this.checkout.shippingAddress)):this.checkout.billingAddress=new ae(e({},this.checkout.billingAddress))),[2]}))}))},this.onProceedToShippingClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2: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=3;case 3:return t.trys.push([3,10,,11]),this.isStepLoading=!0,"address"!==this.deliveryMethod||this.isShowBillingAddressOnShippingStep?[3,5]:[4,this.saveAddress("shipping")];case 4:t.sent(),t.label=5;case 5:return this.isShowBillingAddressOnShippingStep?[4,this.saveAddress("billing")]:[3,7];case 6:t.sent(),t.label=7;case 7:return[4,this.checkStocks()];case 8:return t.sent(),[4,this.saveCart()];case 9:return t.sent(),this.isManualOrderWithShippingLines?[2,this.changeStep(ge.PAYMENT)]:("address"===this.deliveryMethod?this.changeStep(ge.SHIPPING):this.changeStep(ge.PAYMENT),[3,11]);case 10:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,11];case 11:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.isShowBillingAddressOnShippingStep?[4,this.onHandleBillingAddressOnShippingStep()]:[3,2];case 1:t.sent(),t.label=2;case 2:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,t.label=3;case 3:return t.trys.push([3,6,,7]),this.isStepLoading=!0,[4,this.checkStocks()];case 4:return t.sent(),[4,this.saveCart()];case 5:return t.sent(),this.changeStep(ge.PAYMENT),[3,7];case 6:return(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e;return i(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(ge.PAYMENT),[3,5];case 4:return void 0!==typeof(e=t.sent()).type?this.error=e:(console.log(e),this.error={type:ye.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.checkPaypalButtonAvailable=function(){return!!ve.canPerformPayment||(ve.isErrorsVisible=!0,!1)},this.handlePaymentError=function(e,t){ve.error={type:e,data:t}},this.onCompletePaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s,n,r,o,a,c;return i(this,(function(i){switch(i.label){case 0:return!this.canPerformPayment||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isFree||!this.isKlarna?[3,2]:[4,this.saveCart()]);case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return this.isFree||!this.isIyzico?[3,4]:[4,this.saveCart()];case 3:return i.sent(),[2];case 4:if(this.isFree||!this.isHepsiPay)return[3,11];i.label=5;case 5:return i.trys.push([5,9,,10]),window.HepsipaySdk&&(null===(o=this.hepsipayFrameInitResponse)||void 0===o?void 0:o.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,7];case 6:return i.sent(),window.HepsipaySdk.initPayment(),[3,8];case 7:console.error("HepsipaySdk is not available"),i.label=8;case 8:return[3,10];case 9:return i.sent(),this.isStepLoading=!1,[2];case 10:return[2];case 11:return i.trys.push([11,17,,18]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 12:return i.sent(),"address"===this.deliveryMethod&&this.useDifferentAddress?[4,this.saveAddress("billing")]:[3,14];case 13:i.sent(),i.label=14;case 14:return[4,this.saveCart()];case 15:return e=i.sent(),this.checkout.shippingMethod===h.SHIPMENT&&(t=null!==(a=null==e?void 0:e.availableShippingMethods)&&void 0!==a?a:[],s=null!==(c=this.checkout.availableShippingMethods)&&void 0!==c?c:[],!ue(t,s))?(this.changeStep(ge.SHIPPING),[2]):!this.isFree&&this.isCustomFlowStripe?((n=document.querySelector("#stripe-form-btn"))&&n.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 16:return i.sent(),[3,18];case 17:return void 0!==typeof(r=i.sent()).type?this.error=r:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,18];case 18:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(ve,void 0,void 0,(function(){var e,t,s;return i(this,(function(i){switch(i.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked||this.isMilesSmilesTermsMissing?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return i.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:if(this.isFree||!this.isHepsiPay)return[3,9];i.label=3;case 3:return i.trys.push([3,7,,8]),window.HepsipaySdk&&(null===(s=this.hepsipayFrameInitResponse)||void 0===s?void 0:s.frameUrl)?(this.isStepLoading=!0,[4,this.saveCart()]):[3,5];case 4:return i.sent(),window.HepsipaySdk.initPayment(),[3,6];case 5:console.error("HepsipaySdk is not available"),i.label=6;case 6:return[3,8];case 7:return i.sent(),this.isStepLoading=!1,[2];case 8:return[2];case 9:return i.trys.push([9,13,,14]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 10:return i.sent(),[4,this.saveCart()];case 11:return i.sent(),!this.isFree&&this.isCustomFlowStripe?((e=document.querySelector("#stripe-form-btn"))&&e.click(),[2]):!this.isFree&&this.isAdyen?(this.adyenDropinElement.submit(),this.adyenDropinElement.isValid||(this.isStepLoading=!1),[2]):!this.isFree&&this.isPayPal?[2]:[4,this.createSaleTransaction()];case 12:return i.sent(),[3,14];case 13:return(t=i.sent()).type?this.error=t:this.error={type:ye.UNKNOWN},this.isStepLoading=!1,[3,14];case 14:return[2]}}))}))},this.createSaleTransaction=function(){return t(ve,void 0,void 0,(function(){var t,s,n,r,o,d,l,u,h,p,m,f,y,v,S,b,C,P,k,I,A,E,w,O,R,M,T,N,L,_,G,j,D,F;return i(this,(function(i){switch(i.label){case 0:return s=this.mpVM.selectedCard,r=this.milesSmilesInput,!this.isFree&&s&&(null===(P=this.mpVM.selectedCard)||void 0===P?void 0:P.Name)?((o=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=o),void 0===(null===(k=this.cardData)||void 0===k?void 0:k.installmentCount)?[2]:[4,x.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(I=this.mpVM.selectedCard)||void 0===I?void 0:I.Name},paymentGatewayId:null===(A=this.mpVM.selectedCard)||void 0===A?void 0:A.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===(E=this.cardData)||void 0===E?void 0:E.threeDSecure)},metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),milesSmiles:(null===(w=this.mpVM.selectedCard)||void 0===w?void 0:w.paymentGatewayId)===(null===(O=this.milesSmilesPaymentGateway)||void 0===O?void 0:O.id)?r:void 0}})]):[3,2];case 1:return n=i.sent(),[3,10];case 2:return this.checkout.selectedPaymentGateway||this.isFree?(d=this.isFree||s?void 0:this.selectedSavedCard,l=!this.isFree&&!s&&!d&&this.storeCard&&this.isCardStorageEnabled,u=!(this.isFree||s||d||(null===(R=this.checkout.selectedPaymentGateway)||void 0===R?void 0:R.paymentMethodType)!==a.CREDIT_CARD||(null===(M=this.checkout.selectedPaymentGateway)||void 0===M?void 0:M.type)!==c.INTERNAL||!this.cardData),h=e({cartId:this.checkout.id,masterPassDetail:this.isFree?void 0:s&&t?{phoneNumber:t,savedCardName:null===(T=this.mpVM.selectedCard)||void 0===T?void 0:T.Name}:void 0,paymentGatewayId:this.isFree&&!this.isMilesSmilesFullPayment?"9d41af41-4793-4879-a19c-e9a66c929726":this.isMilesSmilesFullPayment?null===(N=this.milesSmilesPaymentGateway)||void 0===N?void 0:N.id:null===(L=this.checkout.selectedPaymentGateway)||void 0===L?void 0:L.id,metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le()),milesSmiles:r},l?{storeCard:!0}:{}),d?[4,this.createSaleTransactionWithSavedCard(h,d)]:[3,4]):[2];case 3:return p=i.sent(),[3,9];case 4:return u&&this.isSecureCardEnabled?[4,this.createSaleTransactionWithSecureCard(h)]:[3,6];case 5:return m=i.sent(),[3,8];case 6:return[4,x.createSaleTransactionWithCart({input:e(e({},h),{paymentMethodDetail:u?this.cardData.toInput():void 0})})];case 7:m=i.sent(),i.label=8;case 8:p=m,i.label=9;case 9:n=p,i.label=10;case 10:return f=null===(_=null==n?void 0:n.data)||void 0===_?void 0:_.transactionStatus,y=f&&[g.SUCCESS,g.AUTHORIZED].includes(f),v=f===g.PENDING,y?[4,this.getSuccessTransaction()]:[3,13];case 11:return i.sent(),[4,this.onCheckoutTransactionSuccess((null===(G=null==n?void 0:n.data)||void 0===G?void 0:G.orderId)||void 0)];case 12:return i.sent(),[3,14];case 13:if(!v||!(null===(j=null==n?void 0:n.data)||void 0===j?void 0:j.returnSlug))throw b=n.firstErrorMessage,"IKAS_WALLET_501"===(null===(F=null===(D=n.data)||void 0===D?void 0:D.error)||void 0===F?void 0:F.code)&&(b=this.t("checkout-page:errorContactStore")),(C=this.handleMilesSmilesSaleError(n))&&(b=C),{data:b,type:ye.UNKNOWN};S="local"===process.env.NEXT_PUBLIC_ENV?process.env.NEXT_PUBLIC_BASE_URL:window.location.origin+"/api/sf",window.location.href=S+n.data.returnSlug,i.label=14;case 14:return[2]}}))}))},this.createSaleTransactionWithSavedCard=function(s,n){return t(ve,void 0,void 0,(function(){var t,r,o,a;return i(this,(function(i){switch(i.label){case 0:return t=(null===(o=null===(r=this.installmentInfo)||void 0===r?void 0:r.installmentPrices)||void 0===o?void 0:o.length)&&(null===(a=this.cardData)||void 0===a?void 0:a.installmentCount)||1,n.requireCvv&&this.isSecureCardEnabled?[4,this.submitSecureCardSale(e(e({},s),{savedCardDetail:{savedCardId:n.id,installmentCount:t}}))]:[3,2];case 1:case 3:return[2,i.sent()];case 2:return[4,x.createSaleTransactionWithCart({input:e(e({},s),{savedCardDetail:e(e({savedCardId:n.id},n.requireCvv?{cvv:this.savedCardCvv}:{}),{installmentCount:t})})})]}}))}))},this.createSaleTransactionWithSecureCard=function(s){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.submitSecureCardSale(e(e({},s),{paymentMethodDetail:{installmentCount:this.cardData.installmentCount,threeDSecure:!!this.cardData.threeDSecure}}))];case 1:return[2,t.sent()]}}))}))},this.submitSecureCardSale=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.secureCard.submitSale(e)];case 1:if(!(t=i.sent()).ok)throw"INVALID_CARD"===t.errorCode&&(this.isErrorsVisible=!0),{type:ye.UNKNOWN};return s=t.errors,n=new Y(t.data||void 0,s),null===(o=null===(r=H.ON_ERROR)||void 0===r?void 0:r.errorCodes)||void 0===o||o.forEach((function(e){var t=e.errorCode,i=e.callback;n.errorCodes.includes(t)&&i({graphQLErrors:s,operationName:"createSaleTransactionWithCart"})})),[2,n]}}))}))},this.onCheckoutTransactionSuccess=function(e){return t(ve,void 0,void 0,(function(){var t,s;return i(this,(function(i){switch(i.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(s=this.checkout.customer)||void 0===s?void 0:s.email)||"")]:[3,2];case 1:i.sent(),i.label=2;case 2:return pe.refreshJourneyId(),this.changeStep(ge.SUCCESS,e),[2]}}))}))},this.onBackToInfoClick=function(){ve.changeStep(ge.INFO)},this.onBackToShippingClick=function(){ve.changeStep(ge.SHIPPING)},this.setCustomerConsentGranted=function(e){ve.checkout.customer&&(ve.checkout.customer.notificationsAccepted=e)},this.setUseDifferentAddress=function(t,i){var s;ve.useDifferentAddress=t,ve.useDifferentAddress?(localStorage.setItem("sAddr","1"),ve.checkout.billingAddress=ve.checkout.billingAddress||new ae,ve.checkout.billingAddress.countrySettings=ve.countrySettings):(localStorage.removeItem("sAddr"),ve.checkout.billingAddress=new ae(e({},ve.checkout.shippingAddress)),ve.store.customerStore.customer&&(null===(s=ve.customerAddresses)||void 0===s?void 0:s.length)&&i&&ve.isShowBillingAddressOnShippingStep&&ve.onSelectedBillingAddressIdChange(ve.checkout.billingAddress.id||"-1"))},this.setShouldSaveAddress=function(e){ve.shouldSaveAddress=e},this.setAddressTitle=function(e){ve.addressTitle=e},this.reInitPaymentMethod=function(){return t(ve,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?this.isCustomFlowStripe?[4,this.createStripePaymentIntent(this.checkout.selectedPaymentGateway)]:[3,2]:[3,12];case 1:e.sent(),e.label=2;case 2:return this.isKlarna&&window.location.reload(),this.isAdyen?[4,this.createAdyenBalancePlatformPaymentSession(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 this.isHepsiPay?[4,this.hepsipayFrameInit(this.checkout.selectedPaymentGateway)]:[3,8];case 7:e.sent(),e.label=8;case 8:return this.isIyzico?[4,this.createIyzicoCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,10];case 9:e.sent(),e.label=10;case 10:return this.isTkPay?[4,this.createTkPayCheckoutForm(this.checkout.selectedPaymentGateway)]:[3,12];case 11:e.sent(),e.label=12;case 12:return[2]}}))}))},this.createStripePaymentIntent=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.stripeResponse=t.data,this.stripeError=null):this.stripeError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createKlarnaClientToken=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.klarnaResponse=t.data,this.klarnaError=null):this.klarnaError={type:ye.API_ERROR,data:t.firstErrorMessage},[2]}}))}))},this.createAdyenBalancePlatformPaymentSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.createAdyenBalancePlatformPaymentSession({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.adyenResponse=t.data),[2]}}))}))},this.getPayPalClientId=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.getPayPalClientId({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.payPalClientIdResponse=t.data),[2]}}))}))},this.hepsipayFrameInit=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,x.hepsipayFrameInit({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.hepsipayFrameInitResponse=t.data),[2]}}))}))},this.createIyzicoCheckoutForm=function(s){return t(ve,void 0,void 0,(function(){var t,n;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this.isIyzicoLoading=!0,[4,x.createIyzicoCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:s.id||"",metadata:e({_fbp:de("_fbp"),_fbc:de("_fbc"),_ga:de("_ga")},le())}})];case 1:return(t=i.sent()).isSuccess&&t.data?(this.iyzicoResponse=t.data,[2]):(n=function(e){var i,s;return(null===(i=t.errorCodes)||void 0===i?void 0:i.includes(e))||(null===(s=t.graphQLErrors)||void 0===s?void 0:s.some((function(t){var i;return(null===(i=t.extensions)||void 0===i?void 0:i.code)===e})))},n("ORDER_LINE_STOCK_NOT_AVAILABLE")?this.error={type:ye.API_ERROR,data:this.t("checkout-page:iyzicoStockReservationError")}:n("IYZICO_CHECKOUT_FORM_INIT_FAILED")&&(this.error={type:ye.API_ERROR,data:this.t("checkout-page:iyzicoInitError")}),[3,4]);case 2:return i.sent(),[3,4];case 3:return this.isIyzicoLoading=!1,[7];case 4:return[2]}}))}))},this.createTkPayCheckoutForm=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:if(this.isTkPayPaymentCompleted||this.step===ge.SUCCESS)return[2];if(this.isFree)return this.tkPayResponse=null,[2];t=!1,i.label=1;case 1:return i.trys.push([1,3,4,5]),this.isTkPayLoading=!0,s=this.milesSmilesInput,[4,x.createTkPayCheckoutForm({input:{cartId:this.checkout.id,paymentGatewayId:e.id||"",milesSmiles:s}})];case 2:return n=i.sent(),this.isTkPayPaymentCompleted?[2]:(n.isSuccess&&n.data?(this.tkPayResponse=n.data,this.tkPayFormMiles=(null==s?void 0:s.miles)||0):s&&(t=!!this.handleMilesSmilesErrorCodes(n.errorCodes||[])),[3,5]);case 3:return i.sent(),[3,5];case 4:return this.isTkPayLoading=!1,[7];case 5:return!t||this.milesSmilesInput?[3,7]:[4,this.createTkPayCheckoutForm(e)];case 6:i.sent(),i.label=7;case 7:return[2]}}))}))},this.createStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,x.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:e.id||""}})];case 1:return(t=i.sent()).isSuccess&&t.data&&(this.stripeExpressCheckoutSessionResponse=t.data),[3,4];case 2:return i.sent(),[3,4];case 3:return[7];case 4:return[2]}}))}))},this.updateStripeExpressCheckoutSession=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:if(!this.stripeExpressCheckoutSessionResponse)return[2,null];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,x.updateStripeExpressCheckoutSession({input:{cartId:this.checkout.id,sessionId:"",transactionId:"",address:e.address||null,shippingSettingsId:e.shippingSettingsId||null,shippingZoneRateId:e.shippingZoneRateId||null}})];case 2:return(t=i.sent()).isSuccess&&t.data?[2,t.data]:[2,null];case 3:return i.sent(),[2,null];case 4:return[2]}}))}))},this.setShowIyzicoContainer=function(e){ve.showIyzicoContainer=e},this.onTkPayPaymentSuccess=function(e){return t(ve,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.isTkPayPaymentCompleted?[2]:(this.isTkPayPaymentCompleted=!0,this.isStepLoading=!0,[4,e()]);case 1:return t.sent(),[4,this.onCheckoutTransactionSuccess()];case 2:return t.sent(),[2]}}))}))},this.setShowTkPayContainer=function(e){ve.showTkPayContainer=e},this.setPaymentGateway=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return this.paymentGateways.length?(t=this.paymentGateways[e],s=!0,this.step!==ge.PAYMENT?[3,7]:this.checkout.selectedPaymentGateway?[3,3]:"CUSTOM"!==t.code?[3,2]:[4,this.updatePaymentGateway(t)]):[2];case 1:s=i.sent(),i.label=2;case 2:return[3,7];case 3:return"CUSTOM"!==this.checkout.selectedPaymentGateway.code?[3,5]:[4,this.updatePaymentGateway(t)];case 4:return s=i.sent(),[3,7];case 5:return"CUSTOM"!==t.code?[3,7]:[4,this.updatePaymentGateway(t)];case 6:s=i.sent(),i.label=7;case 7:return s?"STRIPE"!==t.code&&"STRIPE_EU"!==t.code||this.stripeResponse?[3,9]:[4,this.createStripePaymentIntent(t)]:[2];case 8:i.sent(),i.label=9;case 9:return"KLARNA"!==t.code||this.klarnaResponse?[3,11]:[4,this.createKlarnaClientToken(t)];case 10:i.sent(),i.label=11;case 11:return"ADYEN_PLATFORM"!==t.code||this.adyenResponse?[3,13]:[4,this.createAdyenBalancePlatformPaymentSession(t)];case 12:i.sent(),i.label=13;case 13:return"PAYPAL"!==t.code||this.payPalClientIdResponse?[3,15]:[4,this.getPayPalClientId(t)];case 14:i.sent(),i.label=15;case 15:return"HEPSIPAY"!==t.code||this.hepsipayFrameInitResponse?[3,17]:[4,this.hepsipayFrameInit(t)];case 16:i.sent(),i.label=17;case 17:return"IYZICO"!==t.code||this.iyzicoResponse?[3,19]:[4,this.createIyzicoCheckoutForm(t)];case 18:i.sent(),i.label=19;case 19:return"TK_PAY"!==t.code||this.tkPayResponse||"true"!==(null===(r=null===(n=t.settings)||void 0===n?void 0:n.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===r?void 0:r.value)?[3,21]:[4,this.createTkPayCheckoutForm(t)];case 20:i.sent(),i.label=21;case 21:return this.isCardStorageGateway(t)?[4,this.listSavedCards(t)]:[3,23];case 22:i.sent(),i.label=23;case 23:return this.checkout.selectedPaymentGateway=t,this.step!==ge.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new _,this.secureCard.reset(),this.previousRawValue="",this.previousBin=null,t.masterPassClientId&&this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store})),this.installmentInfo=void 0,this.selectedSavedCardId=null,this.selectSavedCard((null===(o=this.visibleSavedCards[0])||void 0===o?void 0:o.id)||null)),[2]}}))}))},this.listSavedCards=function(e){return t(ve,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return this.savedCardsGatewayId===e.id?[2]:[4,x.listPaymentSavedCard({paymentGatewayId:e.id})];case 1:return t=i.sent(),this.savedCards=t.isSuccess&&t.data||[],this.savedCardsGatewayId=e.id||null,[2]}}))}))},this.selectSavedCard=function(e){var t=ve.selectedSavedCardId!==e;if(ve.selectedSavedCardId=e,t){ve.savedCardCvv="",ve.isSecureCardEnabled&&ve.secureCard.reset(),ve.installmentInfo=void 0,ve.cardData=new _,ve.previousRawValue="",ve.previousBin=null;var i=ve.selectedSavedCard,s=ve.checkout.selectedPaymentGateway;i&&(null==s?void 0:s.id)&&ve.checkout.totalFinalPrice&&ve.retrieveInstallmentInfo({input:{orderId:ve.checkout.id,savedCardId:i.id,paymentGatewayId:s.id,price:ve.checkout.totalFinalPrice,currencyCode:ve.checkout.currencyCode}})}},this.onSavedCardCvvChange=function(e){var t=(e||"").replace(/\D/g,"");t.length>4||(ve.savedCardCvv=t)},this.setStoreCard=function(e){ve.storeCard=e},this.updatePaymentGateway=function(s){return t(ve,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.isPaymentMethodVisible=!1,[4,F.getCartById({id:this.checkout.id,getCompletedCart:!1,paymentGatewayId:s.id,targetPageType:ie.CHECKOUT})];case 1:return(t=i.sent()).isSuccess?((n=t.data)&&(r=this.checkout,this.checkout=new P(e(e({},n),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),this.isPaymentMethodVisible=!0,[2,!0]):(this.isPaymentMethodVisible=!0,[2,!1])}}))}))},this.setInstallmentCount=function(e){ve.cardData&&(ve.cardData.installmentCount=e)},this.changeStep=function(e,s){return t(ve,void 0,void 0,(function(){return i(this,(function(t){return be||window.location.replace("".concat(window.location.pathname,"?id=").concat(s||this.checkout.id,"&step=").concat(e)),[2]}))}))},this.logout=function(){return t(ve,void 0,void 0,(function(){return i(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){ve.isContactModalVisible=e},this.getCampaignOffer=function(s,n){return t(ve,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(c){switch(c.label){case 0:return(null==n?void 0:n.length)?(r=n.filter((function(e){var t;return e.status===y.WAITING_FOR_ACTION&&(null===(t=e.campaignOffer)||void 0===t?void 0:t.targetPageTypes.some((function(e){return e===s})))})),o=r.map((function(s){return t(a,void 0,void 0,(function(){var t,n,r,o,a,c,d,l,u;return i(this,(function(i){switch(i.label){case 0:return t=null===(d=s.campaignOffer)||void 0===d?void 0:d.offers.find((function(e){return e.id===s.campaignOfferProductId})),t?(n=[t.productId],[4,K.searchProducts({input:{productIdList:n,priceListId:ne.getPriceListId(),salesChannelId:ne.getSalesChannelId()}})]):[2,Promise.reject()];case 1:return(r=i.sent()).isSuccess&&(null===(u=null===(l=r.data)||void 0===l?void 0:l.data)||void 0===u?void 0:u.length)?(o=r.data.data[0],(a=o.variants.filter((function(e){return e.hasStock&&!(t.excludedVariantIdList||[]).some((function(t){return t===e.id}))})).map((function(i){if(!t.discountAmount)return i;var s=!1;return t.discountType===b.AMOUNT&&(s=!0),new R(e(e({},i),{prices:i.prices.map((function(i){var n=i.finalPrice,r=i.finalPrice-(s?t.discountAmount:i.finalPrice*t.discountAmount/100);return t.applicablePrice===C.SELL_PRICE&&(n=i.sellPrice,r=i.sellPrice-(s?t.discountAmount:i.sellPrice*t.discountAmount/100)),new O(e(e({},i),{sellPrice:n,discountPrice:r}))}))}))}))).length?(c=a.find((function(e){return e.isActive})),[2,{product:new M(e(e({},o),{selectedVariantValues:(c||a[0]).variantValues,variants:a})),offer:t,campaignOffer:s}]):[2,Promise.reject()]):[2,Promise.reject()]}}))}))})),[4,Promise.allSettled(o)]):[2,[]];case 1:return[2,c.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))]}}))}))},this.createCampaignOffer=function(){return t(ve,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return e=this,[4,this.getCampaignOffer(this.step===ge.SUCCESS?v.POST_CHECKOUT:v.CHECKOUT,this.checkout.campaignOffers)];case 1:return e.campaignOffers=t.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n;return i(this,(function(i){switch(i.label){case 0:return e.accepted?this.isCheckoutLoaded=!1:this.isCampaignOfferLoaded=!1,[4,F.updateCartCampaignOffer({input:e})];case 1:return(t=i.sent()).isSuccess?e.accepted?(this.changeStep(this.step===ge.SUCCESS?ge.PAYMENT:this.step,null===(s=t.data)||void 0===s?void 0:s.id),[3,4]):[3,2]:[3,4];case 2:return this.checkout.campaignOffers=(null===(n=t.data)||void 0===n?void 0:n.campaignOffers)||[],[4,this.createCampaignOffer()];case 3:i.sent(),this.isCampaignOfferLoaded=!0,i.label=4;case 4:return[2]}}))}))},this.registerCustomer=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r;return i(this,(function(i){switch(i.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,D.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:e})]:[3,2]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}}))}))},this.listProductFile=function(){return t(ve,void 0,void 0,(function(){var e,t;return i(this,(function(i){switch(i.label){case 0:return e=this.checkout.orderLineItems.filter((function(e){return!!e.variant.fileId&&e.status!==S.REFUNDED})).map((function(e){return e.variant.fileId})),e.length?[4,x.listProductFile({id:{in:e}})]:[3,2];case 1:(t=i.sent()).isSuccess&&(this.productFiles=t.data||[]),i.label=2;case 2:return[2]}}))}))},this.getDigitalProductFileDownloadUrl=function(e){return t(ve,void 0,void 0,(function(){var t,s,n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=this.checkout.orderLineItems.find((function(t){return t.variant.id===e.variantId})),t?[4,x.getDigitalProductFileDownloadUrl({orderId:this.checkout.id,orderLineItemId:t.id})]:[3,2];case 1:s=i.sent(),(n=s.data)&&((r=document.createElement("a")).href=n,r.download=function(e){try{return decodeURIComponent(e.split("/")[e.split("/").length-1])}catch(e){return""}}(e.name),r.click(),r.remove()),i.label=2;case 2:return[3,4];case 3:return o=i.sent(),console.error(o),[3,4];case 4:return[2]}}))}))},this.checkout=d,this.checkoutSettings=u,this.router=p,this.returnPolicy=A,this.privacyPolicy=E,this.termsOfService=Z,this.imprint=W,this.shippingPolicy=z,this.t=me,this.customizationProps=fe,this.mpVM=new V,G.isEnabled&&(this.masterPassBridge=new j(this.secureCard),this.mpVM.setBridge(this.masterPassBridge),this.secureCard.onReady((function(){"card"===ve.secureCard.mode&&ve.checkout.masterPassPaymentGateway&&ve.mpVM.checkMasterPass({checkout:ve.checkout,store:ve.store})}))),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new T({currentLocale:ne.getCurrentLocale()}),this.init(),n(this)}return fe.prototype.isAmexCard=function(e){var t,i=e||this.previousRawValue;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.cardAssociation)===W.AMERICAN_EXPRESS||Se.test(i)},Object.defineProperty(fe.prototype,"merchantSettings",{get:function(){return new E(ne.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.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(fe.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddressOptions",{get:function(){var e,t,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(t=null===(e=se.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(fe.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(fe.prototype,"giftCardTotalPrice",{get:function(){var e;return(null===(e=this.checkout.giftCardLines)||void 0===e?void 0:e.reduce((function(e,t){return e+t.amount}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"installmentExtraPrice",{get:function(){var e;if(this.installmentPrice&&this.checkout.totalFinalPrice){var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice-t}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"finalPrice",{get:function(){var e;if(this.step===ge.SUCCESS)return this.checkout.totalFinalPrice-this.giftCardTotalPrice;var t=this.checkout.totalFinalPrice;if(this.isOpenEditOrderWithTransaction&&this.openEditOrderTransaction){t=null!==(e=this.checkout.netTotalFinalPrice)&&void 0!==e?e:t;var i=this.openEditOrderTransaction;t=t-((i.chargedAmount||0)+(i.pendingAmount||0))+(i.refundedAmount||0)}else t-=this.giftCardTotalPrice;return this.installmentPrice?this.installmentPrice:t},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasStockError",{get:function(){var e;return(null===(e=this.error)||void 0===e?void 0:e.type)===ye.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasMasterPassGateway",{get:function(){return this.paymentGateways.some((function(e){return!!e.masterPassClientId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"secureCardGatewayId",{get:function(){var e,t=function(e){return e.paymentMethodType===a.CREDIT_CARD&&e.type===c.INTERNAL&&"STRIPE"!==e.code&&"STRIPE_EU"!==e.code},i=this.checkout.selectedPaymentGateway;if(i&&t(i))return i.id;var s=this.paymentGateways.filter(t);return null===(e=s.find((function(e){return!!e.masterPassClientId}))||s[0])||void 0===e?void 0:e.id},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"masterPassSavePhoneNumber",{get:function(){return this.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?this.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({withPlus:!0,store:this.store,checkout:this.checkout}):this.mpVM.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToShipping",{get:function(){var e,t,i,s=!!(null===(e=this.checkout.billingAddress)||void 0===e?void 0:e.isValidAddress),n=!!(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValidAddress);return(this.isDigitalOnly?s:this.isShowBillingAddressOnShippingStep?"address"===this.deliveryMethod&&this.useDifferentAddress?n&&s:s:n)&&(this.checkout.hasCustomer||this.checkout.hasValidCustomerEmail)&&!this.hasCorrectableEmailTypo&&(null===(i=this.error)||void 0===i?void 0:i.type)!==ye.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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.hasCorrectableEmailTypo||!this.checkout.stockLocationId)&&(!this.isShowBillingAddressOnShippingStep||this.canProceedToShipping)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping&&this.isValidShippingSettings},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isValidShippingSettings",{get:function(){var e,t=this;return!!(this.isInStoreDelivery||this.isDigitalOnly||this.isManualOrderWithShippingLines)||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(fe.prototype,"isManualOrderWithShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrderWithoutShippingLines",{get:function(){var e,t;return this.checkout.createdBy===d.ADMIN&&!(null===(e=this.checkout.shippingLines)||void 0===e?void 0:e.length)&&!(null===(t=this.checkout.availableShippingMethods)||void 0===t?void 0:t.length)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"KLARNA"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"adyenPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"ADYEN_PLATFORM"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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(fe.prototype,"payPalPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"PAYPAL"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hepsiPayPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"HEPSIPAY"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"iyzicoPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(e){return"IYZICO"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGateway",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));if(-1!==e)return this.paymentGateways[e]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"tkPayPaymentGatewayIndex",{get:function(){var e=this.paymentGateways.findIndex((function(e){var t,i;return"TK_PAY"===e.code&&"true"===(null===(i=null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===i?void 0:i.value)}));return e},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCustomFlowStripe",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&("STRIPE"===e.code||"STRIPE_EU"===e.code)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isKlarna",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"KLARNA"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isAdyen",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"ADYEN_PLATFORM"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPayPal",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"PAYPAL"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isHepsiPay",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"HEPSIPAY"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isIyzico",{get:function(){var e=this.checkout.selectedPaymentGateway;return e&&"IYZICO"===e.code},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isTkPay",{get:function(){var e,t,i=this.checkout.selectedPaymentGateway;return i&&"TK_PAY"===i.code&&"true"===(null===(t=null===(e=i.settings)||void 0===e?void 0:e.find((function(e){return"tkpay_use_checkout_form"===e.label})))||void 0===t?void 0:t.value)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCardStorageEnabled",{get:function(){return this.isCardStorageGateway(this.checkout.selectedPaymentGateway)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"visibleSavedCards",{get:function(){var e;return this.isCardStorageEnabled&&this.savedCardsGatewayId===(null===(e=this.checkout.selectedPaymentGateway)||void 0===e?void 0:e.id)?this.savedCards:[]},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"selectedSavedCard",{get:function(){var e=this;return this.visibleSavedCards.find((function(t){return t.id===e.selectedSavedCardId}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isSavedCardCvvValid",{get:function(){return/^\d{3,4}$/.test(this.savedCardCvv)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isSavedCardCvvReady",{get:function(){var e=this.selectedSavedCard;return!(null==e?void 0:e.requireCvv)||(this.isSecureCardEnabled?this.secureCard.isValid:this.isSavedCardCvvValid)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isFree",{get:function(){return 0===this.checkout.totalFinalPrice||0===this.finalPrice||this.isMilesSmilesFullPayment},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return e.code===z&&!!e.milesSmilesEnabled}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRate",{get:function(){var e,t,i=null===(t=null===(e=this.milesSmilesPaymentGateway)||void 0===e?void 0:e.settings)||void 0===t?void 0:t.find((function(e){return"miles_smiles_try_per_1000"===e.label})),s=(null==i?void 0:i.value)?parseFloat(i.value):NaN;return isFinite(s)&&s>0?s/1e3:Ce[this.checkout.currencyCode]||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAvailableMiles",{get:function(){var e;return(null===(e=this.milesSmilesDetails)||void 0===e?void 0:e.availableMiles)||0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesMaxRedeemable",{get:function(){var e=this.milesSmilesAvailableMiles,t=this.milesSmilesRate,i=this.finalPrice||0;return!t||i<=0?e:Math.min(e,Math.ceil(i/t))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesRedeemValue",{get:function(){if(!this.useMilesSmiles)return 0;var e=this.milesSmilesRate;return e?(this.milesToRedeem||0)*e:0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesFullPayment",{get:function(){return!!this.useMilesSmiles&&(!(this.finalPrice<=0)&&this.milesSmilesRedeemValue>=this.finalPrice)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAppliedValue",{get:function(){return this.milesToRedeem>this.milesSmilesAvailableMiles?0:Math.min(this.milesSmilesRedeemValue,this.finalPrice||0)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesAmountToPay",{get:function(){return Math.max(0,(this.finalPrice||0)-this.milesSmilesAppliedValue)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesAllMilesUsed",{get:function(){return this.milesToRedeem>0&&this.milesToRedeem===this.milesSmilesMaxRedeemable},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesNothingToPay",{get:function(){return this.checkout.totalFinalPrice<=0||this.finalPrice<=0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"milesSmilesInput",{get:function(){if(!this.isMilesSmilesNothingToPay&&this.useMilesSmiles&&this.isMilesSmilesActive()){var e=Math.floor(this.milesToRedeem||0);if(!(e<1))return{miles:e}}},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"store",{get:function(){return se.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementDefult",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.DEFAULT||null===this.checkoutSettings.couponCodeRequirement},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementOpen",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeRequirementInvisible",{get:function(){return this.checkoutSettings.couponCodeRequirement===l.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCouponCodeVisible",{get:function(){return this.isCouponCodeRequirementDefult&&!this.isCouponCodeRequirementInvisible&&!(this.checkout.createdBy===d.UPSELL||this.checkout.createdBy===d.ADMIN)&&!this.isOpenEditOrderWithTransaction},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isCorporateInvoiceVisible",{get:function(){return this.checkoutSettings.corporateInvoiceRequirement!==u.INVISIBLE},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isShowBillingAddressOnShippingStep",{get:function(){return this.checkoutSettings.showBillingAddressOnShippingStep},enumerable:!1,configurable:!0}),Object.defineProperty(fe.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.selectedSavedCard?this.isSavedCardCvvReady:!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!(this.isKlarna||this.isPayPal||this.isHepsiPay)||(this.isSecureCardEnabled?this.secureCard.isValid:null===(t=this.cardData)||void 0===t?void 0:t.isValid)):!!i));return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===h.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"customerAddresses",{get:function(){var t,i,s,n=this,r=null===(t=ne.getCurrentRouting())||void 0===t?void 0:t.countryCodes;return null===(s=null===(i=this.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===s?void 0:s.filter((function(e){var t;return!(null==r?void 0:r.length)||(null===(t=e.country)||void 0===t?void 0:t.iso2)&&r.includes(e.country.iso2)})).map((function(t){var i=new A(e({countrySettings:n.countrySettings},t));return i.checkoutSettings=n.checkoutSettings,i.shippingZones=n.shippingZones,i.getValidatedCustomerAddress(),i}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isManualOrder",{get:function(){return this.checkout.createdBy===d.ADMIN},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isUpsellOrder",{get:function(){return this.checkout.createdBy===d.UPSELL},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrder",{get:function(){return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"stripeExpressPaymentGateway",{get:function(){return this.paymentGateways.find((function(e){return"STRIPE_EU"===e.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isOpenEditOrderWithTransaction",{get:function(){var e,t;return this.checkout.status===p.OPEN&&!!this.checkout.orderNumber&&!!(null===(e=this.openEditOrderTransaction)||void 0===e?void 0:e.chargedAmount)&&(null===(t=this.openEditOrderTransaction)||void 0===t?void 0:t.chargedAmount)>0},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isEPayKolayEnabled",{get:function(){var e=ne.getCustom();return!!e&&!!e.isEPayKolayEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isPoweredByHidden",{get:function(){var e=ne.getCustom();return!!e&&!!e.hidePoweredBy},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasCorrectableEmailTypo",{get:function(){var e;return!this.checkout.hasCustomer&&!!me((null===(e=this.checkout.customer)||void 0===e?void 0:e.email)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"hasEmailError",{get:function(){return this.isErrorsVisible&&(!this.checkout.hasValidCustomerEmail||this.hasCorrectableEmailTypo)},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"isMilesSmilesTermsMissing",{get:function(){return this.useMilesSmiles&&this.isMilesSmilesActive()&&!this.isMilesSmilesNothingToPay&&this.milesToRedeem>0&&!this.isMilesSmilesTermsAccepted},enumerable:!1,configurable:!0}),fe.prototype.isMilesSmilesActive=function(){return!this.isMilesSmilesUnavailable&&!!this.milesSmilesPaymentGateway&&this.checkout.currencyCode===Z},Object.defineProperty(fe.prototype,"isSecureCardEnabled",{get:function(){return G.isEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(fe.prototype,"cardBin",{get:function(){var e,t;if(this.isSecureCardEnabled)return this.secureCard.bin||void 0;var i=null===(t=null===(e=this.cardData)||void 0===e?void 0:e.cardNumber)||void 0===t?void 0:t.split(" ").join("");return i&&i.length>=8?i.slice(0,8):void 0},enumerable:!1,configurable:!0}),fe.prototype.setAdyenDropinElement=function(e){this.adyenDropinElement=e},fe}();function Ee(e,t){return e.match(new RegExp(".{1,"+t+"}","g"))||[]}function we(e){return e&&ve.test(e.charAt(e.length-1))}!function(e){e.INFO="info",e.SHIPPING="shipping",e.PAYMENT="payment",e.SUCCESS="success"}(ge||(ge={})),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",e[e.CUSTOMER_ACCOUNT_DISABLED_ERROR=6]="CUSTOMER_ACCOUNT_DISABLED_ERROR",e[e.ARGUMENT_VALIDATION_ERROR=7]="ARGUMENT_VALIDATION_ERROR"}(ye||(ye={}));export{ge as CheckoutStep,ye as ErrorType,Pe as MILES_SMILES_LOGIN_REQUIRED_CODES,Ce as MILES_SMILES_RATE_PER_POINT,ke as MILES_SMILES_UNAVAILABLE_CODES,Ae as default};
@@ -1,12 +1,13 @@
1
1
  import { IkasCartCampaignOffer } from "./campaign-offer";
2
2
  import { IkasAvailableShippingMethod } from "./available-shipping-method";
3
3
  import { IkasOrder } from "../order";
4
- import { IkasCart as ICart, IkasCartCreatedBy } from "@ikas/storefront-models";
4
+ import { IkasCart as ICart, IkasCartCreatedBy, IkasCartDroppedLoyaltyLine } from "@ikas/storefront-models";
5
5
  export declare class IkasCart extends IkasOrder implements ICart {
6
6
  availableShippingMethods: IkasAvailableShippingMethod[] | null;
7
7
  campaignOffers: IkasCartCampaignOffer[] | null;
8
8
  couponCode: string | null;
9
9
  createdBy: IkasCartCreatedBy | null;
10
+ droppedLoyaltyLines: IkasCartDroppedLoyaltyLine[] | null;
10
11
  shippingSettingsId: string | null;
11
12
  shippingZoneRateId: string | null;
12
13
  stockLocationId: string | null;
@@ -1 +1 @@
1
- import{__extends as n}from'./../../../ext/tslib/tslib.es6.js';import{IkasCartCampaignOffer as i}from"./campaign-offer/index.js";import{IkasAvailableShippingMethod as o}from"./available-shipping-method/index.js";import{IkasOrder as e}from"../order/index.js";import{makeObservable as t,observable as l}from"mobx";var p=function(e){function p(n,p){var a,s,d=this;return(d=e.call(this,n,p)||this).availableShippingMethods=null,d.campaignOffers=null,d.couponCode=null,d.shippingSettingsId=null,d.shippingZoneRateId=null,d.stockLocationId=null,d.availableShippingMethods=(null===(a=n.availableShippingMethods)||void 0===a?void 0:a.map((function(n){return new o(n)})))||null,d.campaignOffers=(null===(s=n.campaignOffers)||void 0===s?void 0:s.map((function(n){return new i(n)})))||null,d.couponCode=n.couponCode||null,d.createdBy=n.createdBy||null,d.shippingSettingsId=n.shippingSettingsId||null,d.shippingZoneRateId=n.shippingZoneRateId||null,d.stockLocationId=n.stockLocationId||null,t(d,{availableShippingMethods:l,campaignOffers:l,couponCode:l,createdBy:l,shippingSettingsId:l,shippingZoneRateId:l,stockLocationId:l}),d}return n(p,e),p}(e);export{p as IkasCart};
1
+ import{__extends as n,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{IkasCartCampaignOffer as o}from"./campaign-offer/index.js";import{IkasAvailableShippingMethod as e}from"./available-shipping-method/index.js";import{IkasOrder as l}from"../order/index.js";import{makeObservable as t,observable as p}from"mobx";var a=function(l){function a(n,a){var d,s,r,u=this;return(u=l.call(this,n,a)||this).availableShippingMethods=null,u.campaignOffers=null,u.couponCode=null,u.droppedLoyaltyLines=null,u.shippingSettingsId=null,u.shippingZoneRateId=null,u.stockLocationId=null,u.availableShippingMethods=(null===(d=n.availableShippingMethods)||void 0===d?void 0:d.map((function(n){return new e(n)})))||null,u.campaignOffers=(null===(s=n.campaignOffers)||void 0===s?void 0:s.map((function(n){return new o(n)})))||null,u.couponCode=n.couponCode||null,u.createdBy=n.createdBy||null,u.droppedLoyaltyLines=(null===(r=n.droppedLoyaltyLines)||void 0===r?void 0:r.map((function(n){return i({},n)})))||null,u.shippingSettingsId=n.shippingSettingsId||null,u.shippingZoneRateId=n.shippingZoneRateId||null,u.stockLocationId=n.stockLocationId||null,t(u,{availableShippingMethods:p,campaignOffers:p,couponCode:p,createdBy:p,droppedLoyaltyLines:p,shippingSettingsId:p,shippingZoneRateId:p,stockLocationId:p}),u}return n(a,l),a}(l);export{a as IkasCart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.398",
3
+ "version": "6.1.0-beta.399",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^6.1.0-beta.398",
27
- "@ikas/storefront-config": "^6.1.0-beta.398",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.398",
29
- "@ikas/storefront-models": "^6.1.0-beta.398",
30
- "@ikas/storefront-providers": "^6.1.0-beta.398",
26
+ "@ikas/storefront-api": "^6.1.0-beta.399",
27
+ "@ikas/storefront-config": "^6.1.0-beta.399",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.399",
29
+ "@ikas/storefront-models": "^6.1.0-beta.399",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.399",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^6.1.0-beta.398",
66
- "@ikas/storefront-config": "^6.1.0-beta.398",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.398",
68
- "@ikas/storefront-models": "^6.1.0-beta.398",
69
- "@ikas/storefront-providers": "^6.1.0-beta.398",
65
+ "@ikas/storefront-api": "^6.1.0-beta.399",
66
+ "@ikas/storefront-config": "^6.1.0-beta.399",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.399",
68
+ "@ikas/storefront-models": "^6.1.0-beta.399",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.399",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",