@ikas/storefront 6.1.0-beta.283 → 6.1.0-beta.284
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import a from"lodash/sortBy";import l from"../input-with-button/index.js";import s from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as d}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as y}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import v from"../tooltip/index.js";import E from"../svg/arrow-down.js";import f from"../svg/cross.js";import g from"../svg/gift.js";import h from"../../styles/common.module.scss.js";import C from"./style.module.scss.js";import L from"../svg/ikas.js";import{Button as P}from"../button/index.js";import{IkasCampaignCreatedFor as k,IkasGiftCardType as N}from"@ikas/storefront-models";import S from"../../../../hooks/useDimension.js";import I from"../svg/coupon-code-tag.js";import M from"../svg/gift-cart-tag.js";import x from"../svg/store-credit-tag.js";import T from"../svg/gift-loyalty.js";import j from"../svg/package-loyalty.js";import b from"../svg/percentage-loyalty.js";import w from"../svg/arrow-loyalty.js";import O from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as A,searchProducts as D,useLoyaltyPoints as F}from"@ikas/storefront-api";import _ from"../svg/left-arrow-loyalty.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 V}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 R}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-filter/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 U from"../svg/arrow-right-loyalty.js";var H;!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"}(H||(H={}));var B=i((function(e){var t,n,i,a,l,y,p,v,f,g,h,P,k=e.vm,N=e.allowExpand,I=e.isSuccessPageSummary,M=k.checkout,x=u().t,T=o.useState(!N),j=T[0],b=T[1],w=o.useState(!1),O=w[0],A=w[1],D=o.useState(null),F=D[0],_=D[1],V=o.useState(0),R=V[0],U=V[1],B=o.useState(null),q=B[0],Y=B[1],J=o.useState(!1),Z=J[0],ee=J[1],te=o.useState(!1),ne=te[0],oe=te[1],ie=o.useState(!1),ae=ie[0],le=ie[1],se=S().isMobile;o.useEffect((function(){N&&(j?q&&U(q.getBoundingClientRect().height):U(0))}),[j,q,N,Z,ne,O,ae]);var re=o.useMemo((function(){switch(F){case H.COUPON_CODE_NOT_EXIST:return x("checkout-page:giftCodeErrorDescription");case H.COUPON_CODE_NOT_EXIST_FOR_GUESS:return x("checkout-page:mustBeSignInToApplyCampaign");case H.COUPON_APPLIED_WITHOUT_DISCOUNT:return x("checkout-page:couponInvalidForCartItems");default:return""}}),[F]),ce=[C.CartSummary,N?C.HideOnDesktop:"",I?C.SuccessPageCartSummary:""].join(" "),de=N?{height:R+"px"}:void 0,ue=[C.ArrowDown,j?C.Rotated:""].join(" ");return M?o.createElement(o.Fragment,null,!!N&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!j){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}b(!j)}},o.createElement("div",{className:C.Left},x("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(k.finalPrice||0,M.currencyCode,M.currencySymbol)," (").concat(M.itemQuantity," ").concat(x("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:ue},o.createElement(E,null))))),o.createElement("div",{className:ce},o.createElement("div",{className:[C.DetailsContainer,I?C.SuccessPageDetailContainer:""].join(" "),style:de},o.createElement("div",{className:C.Details,ref:Y},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,M.items.map((function(e,t){return o.createElement(m,{key:t,vm:k,cartItem:e,currencyCode:M.currencyCode,onChange:le,isSuccessPageSummary:I})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},O&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:x("checkout-page:giftCodeErrorTitle"),content:re,onClose:function(){A(!1),_(null)}})),o.createElement(G,{label:x("checkout-page:subtotal"),value:M.formattedTotalPrice,tooltipText:x("checkout-page:subtotalTooltip"),hideMarginBottom:!(k.isCouponCodeVisible||(null===(t=k.checkout.giftCardLines)||void 0===t?void 0:t.length)||(null===(n=k.checkout.loyaltyLines)||void 0===n?void 0:n.length)||(null===(i=k.checkout.nonCouponAdjustments)||void 0===i?void 0:i.length))}),!!(null===(a=M.shippingLines)||void 0===a?void 0:a.length)&&(k.step===r.SUCCESS?o.createElement(G,{label:x("checkout-page:cartShippingTitle"),value:M.shippingTotal?M.formattedShippingTotal:x("checkout-page:free")}):M.shippingLines.map((function(e,t){return o.createElement(G,{key:t,label:e.paymentMethod?e.title:x("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,M.currencyCode,M.currencySymbol):x("checkout-page:free")})}))),o.createElement(X,{vm:k}),o.createElement(z,{vm:k}),(k.step===r.SUCCESS&&(!!k.checkout.note||!!k.checkout.appliedCouponCode)||k.step!==r.SUCCESS)&&k.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),!!(null===(l=k.loyaltySpendingMethods)||void 0===l?void 0:l.length)&&(null===(y=k.loyaltySpendingMethods)||void 0===y?void 0:y.length)>0&&!se&&!!(null===(p=k.customizationProps)||void 0===p?void 0:p.showLoyaltyPoints)&&o.createElement($,{vm:k,isVisibleLoyaltyPoints:k.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:k.setIsLoyaltyPointsVisible,isMobile:se}),o.createElement(K,{vm:k,isVisibleLoyaltyPoints:k.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:k.setIsLoyaltyPointsVisible}),o.createElement(W,{vm:k,isAddingCoupon:ne,setAddingCoupon:oe,setCouponError:A,setCouponErrorCode:_}),o.createElement(Q,{vm:k,isAddingNote:Z,setAddingNote:ee}),!!k.installmentExtraPrice&&k.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(G,{label:x("checkout-page:cartInterest"),value:d(k.installmentExtraPrice,M.currencyCode,M.currencySymbol)}))),k.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=k.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(G,{label:x("checkout-page:chargedAmount"),value:d((null===(f=k.openEditOrderTransaction)||void 0===f?void 0:f.chargedAmount)||0,M.currencyCode,M.currencySymbol)}),!!(null===(g=k.openEditOrderTransaction)||void 0===g?void 0:g.refundedAmount)&&o.createElement(G,{label:x("checkout-page:refundedAmount"),value:d((null===(h=k.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,M.currencyCode,M.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,I?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},k.isOpenEditOrderWithTransaction?x("checkout-page:totalAmountPayable"):x("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(k.finalPrice||0,M.currencyCode,M.currencySymbol)),!!M.$totalTax&&!!(null===(P=k.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},x("checkout-page:cartTaxTitle")+" "+M.$formattedTotalTax)))),!!k.loyaltyEarningMethod&&!!k.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},x("checkout-page:loyaltyEarningMethodTitle",{value:(k.loyaltyEarningMethod.pointsEarned/(k.loyaltyEarningMethod.amountPerPointsEarned||1)*k.finalPrice).toFixed(2)}))),!I&&!k.isPoweredByHidden&&o.createElement("div",{className:C.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))))):null})),G=i((function(e){var t=e.label,n=e.value,i=e.tooltipText,a=e.hideMarginBottom;return o.createElement("div",{className:[C.InfoRow,a?C.hideMb:""].join(" ")},o.createElement("div",{className:C.Label},o.createElement("span",null,t),!!i&&o.createElement(v,{text:i,style:{marginLeft:"8px"}})),o.createElement("div",{className:C.Value},n))})),X=i((function(e){var t=e.vm,n=u().t;return t.checkout?o.createElement(o.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==k.LOYALTY_SPEND})).map((function(e,i){return o.createElement("div",{className:C.InfoRow,key:i},o.createElement("div",{className:C.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,d(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),z=i((function(e){var t,n=e.vm,i=u().t;return n.checkout?o.createElement(o.Fragment,null,null===(t=n.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return o.createElement("div",{className:C.InfoRow,key:t},o.createElement("div",{className:C.Label},o.createElement("div",{className:C.GiftLabel},o.createElement(g,{style:{position:"relative",top:"-1px"}}),o.createElement("span",null,i("checkout-page:giftPackage")))),o.createElement("div",{className:C.Value},o.createElement("span",null,d(e.price,n.checkout.currencyCode,n.checkout.currencySymbol))))}))):null})),W=i((function(n){var i=n.vm,a=n.isAddingCoupon,s=n.setAddingCoupon,c=n.setCouponError,d=n.setCouponErrorCode,m=n.isOpenCouponCode,v=n.isMobile,E=n.showOnlyMobile,f=u().t,g=o.useState(""),L=g[0],k=g[1],N=o.useState(!1),S=N[0],I=N[1],M=o.useRef(null);o.useEffect((function(){a&&M.current&&M.current.focus()}),[a]);var x=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return i.checkout.couponCode=L,I(!0),[4,i.onCouponCodeApply(!0)];case 1:return t.sent(),I(!1),k(""),e=i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length,i.couponError?[3,4]:i.checkout.appliedCouponCode||e?(c(!1),d(null),[4,i.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:i.checkout.couponCode=null,c(!0),d(i.couponError),t.label=5;case 5:return[2]}}))}))},T=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeGiftCardLine(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))};i.step,r.SUCCESS;var b=i.step===r.SHIPPING,w=!!i.checkout.appliedCouponCode||!!(i.checkout.giftCardLines&&i.checkout.giftCardLines.length>0)||!!(i.checkout.loyaltyLines&&i.checkout.loyaltyLines.length>0),O=!!i.checkout.appliedCouponCode&&m,A=!a&&i.isCouponCodeVisible&&!i.isCouponCodeRequirementOpen&&i.step!==r.SUCCESS,D=w&&(!m||v);return o.createElement(o.Fragment,null,!!m&&o.createElement(o.Fragment,null,o.createElement("div",{className:[C.CartSummary,C.OpenCouponCodeSummary].join(" ")},o.createElement("div",{className:h.FormSectionTitle},o.createElement("div",{style:{paddingBottom:O?0:6},className:h.Title},f("checkout-page:couponCode"))))),w&&!b&&!i.isCouponCodeRequirementDefult&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement("div",{className:A?C.InfoRow:""},A&&o.createElement("div",{className:C.ActionTextBtn,onClick:function(){return s(!0)}},f("checkout-page:addCouponCode")),a&&!m&&o.createElement("div",{style:{marginBottom:"10px"}},o.createElement(l,{value:L,placeholder:f("checkout-page:couponCode"),buttonLabel:f("checkout-page:actions.apply"),inputRef:M,onClick:x,isLoading:S,onChange:k})),m&&o.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[C.OpenCouponCodeMain,D?C.OpenCouponCodeMainWithMb:""].join(" ")},o.createElement(y,{name:"couponCode",label:f("checkout-page:addCouponCode"),type:p.TEXT,value:L,onChange:k}),o.createElement(P,{style:{width:"33%"},text:f("checkout-page:actions.apply"),isLoading:S,onClick:x}))),D&&o.createElement(o.Fragment,null,!!i.checkout.appliedCouponCode&&o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(q,{vm:i,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return i.checkout.couponCode=null,I(!0),[4,i.onCouponCodeApply(!1)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},couponCode:i.checkout.appliedCouponCode})),!!i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length&&i.checkout.giftCardLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(q,{vm:i,onClearGiftCode:T,couponCode:e.code,giftCardLine:e}))})),!!i.checkout.loyaltyLines&&!!i.checkout.loyaltyLines.length&&i.checkout.loyaltyLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),q=i((function(e){var t=e.vm,n=e.onClearCouponCode,i=e.couponCode,a=e.giftCardLine,l=e.onClearGiftCode,s=t.checkout.couponAdjustment,c=u().t,m=!a,y=(null==a?void 0:a.type)===N.STORE_CREDIT;return o.createElement(o.Fragment,null,o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},a&&y&&o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},o.createElement("span",{style:{height:"20px"}},o.createElement(x,null)),o.createElement("span",{className:C.StoreCreditTag},c("checkout-page:storeCredit"))),!y&&o.createElement("span",{className:[C.AppliedCoupon,t.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},m?o.createElement("span",{style:{height:"16px"}},o.createElement(I,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(M,null)),o.createElement("span",{className:C.CouponCode},i),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCoupon,onClick:function(){return a?l&&l(a.giftCardId):n&&n()}},o.createElement(f,null)))),o.createElement("div",null,a?o.createElement("div",{className:C.Value},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==a?void 0:a.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===(null==s?void 0:s.type)?"- ":"")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),Y=i((function(e){var t,n,i=e.vm,a=e.onClearLoyaltyPoints,l=e.loyaltyPointsLine,s=null===(t=i.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===l.id})),c=u().t,m=null===(n=i.loyaltySpendingMethodsAll)||void 0===n?void 0:n.find((function(e){return e.id===l.loyaltySpendingMethodId})),y=function(){return m?m.type===A.FREE_PRODUCT?{icon:o.createElement(T,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===A.FREE_SHIPPING?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPoints")}};return o.createElement(o.Fragment,null,o.createElement("div",{className:C.LoyaltyPointsLineContainer},o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},o.createElement("span",{className:[C.AppliedCouponLoyalty,i.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},o.createElement("div",{style:{width:"16px",height:"16px"},className:C.LoyaltyPointsLineIcon},y().icon),o.createElement("span",{className:C.CouponCode},y().title),i.step!==r.SUCCESS&&!i.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCouponLoyalty,onClick:function(){return a&&a(l.loyaltySpendingMethodId)}},o.createElement(f,null)))),o.createElement("span",{className:C.LoyaltyPointSpending},"(",c("checkout-page:loyaltyPointSpending",{point:l.amount}),")")),m?m.type!==A.FREE_PRODUCT&&m.type!==A.FREE_SHIPPING?o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))):null:o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))))})),$=i((function(e){var t,n,i,a,l,s,r,c,m,y=e.vm;e.isVisibleLoyaltyPoints;var p=e.setIsVisibleLoyaltyPoints,v=e.isMobile,E=o.useState("undefined"!=typeof window?window.innerWidth:1500),f=E[0],g=E[1];o.useEffect((function(){var e=function(){return g(window.innerWidth)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var h=null===(t=y.loyaltySpendingMethods)||void 0===t?void 0:t.filter((function(e){return e.type===A.FREE_PRODUCT})),L=null!==(n=null==h?void 0:h.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==n?n:[],P=L.length?Math.min.apply(Math,L):null,k=L.length?Math.max.apply(Math,L):null,N=1===(null===(i=y.loyaltySpendingMethods)||void 0===i?void 0:i.length),S=function(e){var t,n,i,a,l,s="",r=null;return e.type===A.FIXED_AMOUNT&&e.isDynamic&&(s=N?"".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount")," (").concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0,amount:d((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),")"):I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),r=o.createElement(b,null)),e.type===A.FREE_SHIPPING&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(j,null)),e.type!==A.FIXED_AMOUNT||e.isDynamic||(s=N?I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmountOneRow",{value:d((null===(i=e.discountSettings)||void 0===i?void 0:i.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}):I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(a=e.discountSettings)||void 0===a?void 0:a.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),r=o.createElement(b,null)),e.type===A.FREE_PRODUCT&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(T,null)),e.type===A.RATIO&&(s="".concat(e.description," (").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,"%)"),r=o.createElement(b,null)),{title:s,icon:r}},I=u().t,M=null!==(l=null===(a=y.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type!==A.FREE_PRODUCT})))&&void 0!==l?l:[],x=f>1380||v?h&&h.length>0?2:3:f<1100?h&&h.length>0?0:1:h&&h.length>0?1:2,O=M.slice(0,Math.min(x,M.length));return 1===(null===(s=y.loyaltySpendingMethods)||void 0===s?void 0:s.length)?o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsLineOneRow,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineOneRowTitle},S(null===(r=y.loyaltySpendingMethods)||void 0===r?void 0:r[0]).icon&&S(null===(c=y.loyaltySpendingMethods)||void 0===c?void 0:c[0]).icon,o.createElement("span",{className:C.LoyaltyPointsLineOneRowTitleText},S(null===(m=y.loyaltySpendingMethods)||void 0===m?void 0:m[0]).title)),o.createElement(w,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},I("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},O.map((function(e){var t;return o.createElement("div",{key:e.id,className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},S(e).icon&&S(e).icon,o.createElement("span",{className:C.LoyaltyPointsLineTitleText},S(e).title)),o.createElement("span",{className:C.LoyaltyPointsLineValue},(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0," ",I("checkout-page:loyaltyPoint")))})),h&&h.length>0&&o.createElement("div",{className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},o.createElement(T,null),o.createElement("span",{className:C.LoyaltyPointsLineTitleText},I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"))),o.createElement("span",{className:C.LoyaltyPointsLineValue},P&&k?"".concat(P," ~ ").concat(k):""," ",I("checkout-page:loyaltyPoint"))),o.createElement("div",{className:[C.LoyaltyPointsLine,C.LoyaltyPointsLineAllMain].join(" "),onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineAllContainer},o.createElement("span",{className:C.LoyaltyPointsLineAll},I("checkout-page:loyaltyPointsViewAll")),o.createElement(w,null)))))})),K=i((function(i){var a,l,s,r,m,y,p,v,E,g,h,L,k,N=i.vm,S=i.isVisibleLoyaltyPoints,I=i.setIsVisibleLoyaltyPoints,M=o.useState(!1),x=M[0],w=M[1],H=o.useState(!1),B=H[0],G=H[1],X=o.useState(!1),z=X[0],W=X[1],q=o.useState(!1),Y=q[0],$=q[1],K=o.useState(!1),Q=K[0],J=K[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(null),oe=ne[0],ie=ne[1],ae=o.useState(0),le=ae[0],se=ae[1];o.useEffect((function(){if(S&&!Q){var e=requestAnimationFrame((function(){requestAnimationFrame((function(){return te(!0)}))}));return function(){return cancelAnimationFrame(e)}}S||te(!1)}),[S,Q]),o.useEffect((function(){if(Q){var e=setTimeout((function(){I(!1),J(!1)}),250);return function(){return clearTimeout(e)}}}),[Q]);var re=o.useCallback((function(){J(!0)}),[]),ce=o.useCallback((function(){G(!0)}),[]),de=o.useCallback((function(){$(!0)}),[]);o.useEffect((function(){if(B){var e=setTimeout((function(){w(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){W(!1),ie(null),$(!1)}),180);return function(){return clearTimeout(e)}}}),[Y]),o.useEffect((function(){var e,t;if(oe){var n=(null===(e=oe.discountSettings)||void 0===e?void 0:e.point)||1,o=null===(t=oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit;se("number"==typeof o&&o>0?o:n)}}),[oe]);var ue=null===(a=N.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type===A.FREE_PRODUCT})),me=o.useState("undefined"!=typeof window?window.innerHeight:1200),ye=me[0],pe=me[1];o.useEffect((function(){var e=function(){return pe(window.innerHeight)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),o.useEffect((function(){S&&ge((null==ue?void 0:ue.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})))||[])}),[S]);var ve=o.useState([]),Ee=ve[0],fe=ve[1],ge=function(n){return e(void 0,void 0,void 0,(function(){var e,o,i;return t(this,(function(t){switch(t.label){case 0:return(null==n?void 0:n.length)?[4,D({input:{productIdList:n,page:1,perPage:n.length,priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId()}},[])]:[2,[]];case 1:return e=t.sent(),o=(null===(i=e.data)||void 0===i?void 0:i.data)||[],fe(o.map((function(e){var t,n,o,i,a,l;return{id:e.id,name:e.name,mainImageSrc:new R({id:(null===(a=null===(i=null===(o=null===(n=null===(t=e.variants)||void 0===t?void 0:t[0])||void 0===n?void 0:n.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===i?void 0:i.image)||void 0===a?void 0:a.id)||null,isVideo:!1}).thumbnailSrc,variants:(null===(l=e.variants)||void 0===l?void 0:l.map((function(e){var t,n,o,i;return{id:e.id,mainImageSrc:new R({id:(null===(o=null===(n=null===(t=e.images)||void 0===t?void 0:t.find((function(e){return e.isMain})))||void 0===n?void 0:n.image)||void 0===o?void 0:o.id)||null,isVideo:!1}).thumbnailSrc,variantText:(null===(i=e.variantValues)||void 0===i?void 0:i.map((function(e){return e.name})).join(" / "))||null}})))||[]}}))),[2]}}))}))},he=null!==(l=null==ue?void 0:ue.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==l?l:[],Ce=he.length?Math.min.apply(Math,he):null,Le=he.length?Math.max.apply(Math,he):null,Pe=function(e){var t,n,i="",a=null;return e.type===A.FIXED_AMOUNT&&e.isDynamic&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(b,null)),e.type===A.FREE_SHIPPING&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(j,null)),e.type!==A.FIXED_AMOUNT||e.isDynamic||(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}),a=o.createElement(b,null)),e.type===A.FREE_PRODUCT&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(T,null)),e.type===A.RATIO&&(i="".concat(e.description," (").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,"%)"),a=o.createElement(b,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==A.FREE_PRODUCT})),Ne=function(e,t){var n,o,i,a,l=null!==(o=null===(n=N.loyaltyCustomerInfo)||void 0===n?void 0:n.totalPoint)&&void 0!==o?o:0;return(null==t?void 0:t.type)===A.FIXED_AMOUNT&&(null==t?void 0:t.isDynamic)?!!((null===(i=t.pointUsageLimit)||void 0===i?void 0:i.minPointLimit)&&(null===(a=t.pointUsageLimit)||void 0===a?void 0:a.minPointLimit)>l):!l||l<e},Se=function(o,i,a){return e(void 0,void 0,void 0,(function(){var e,l;return t(this,(function(t){switch(t.label){case 0:return[4,F({input:n({cartId:N.checkout.id,loyaltyProgramId:o,loyaltySpendingMethodId:i},a?{amount:a}:{})})];case 1:return(e=t.sent()).isSuccess?(re(),l=e.data,N.checkout=new V(n(n({},l),{shippingAddress:N.checkout.shippingAddress,billingAddress:N.checkout.billingAddress,customer:N.checkout.customer,selectedPaymentGateway:N.checkout.selectedPaymentGateway}),N.countrySettings),[4,N.getLoyaltyCustomerInfo()]):[3,4];case 2:return t.sent(),[4,N.listSpendingMethodsByCartId()];case 3:t.sent(),t.label=4;case 4:return[2,e]}}))}))},Ie=u().t;if(!S&&!Q)return null;var Me=[C.LoyaltyPointsLinesModalContainer,ee&&!Q&&C.LoyaltyPointsLinesModalContainerVisible,Q&&C.LoyaltyPointsLinesModalContainerClosing].filter(Boolean).join(" ");return o.createElement("div",{className:Me,onClick:re,role:"presentation"},o.createElement("div",{className:C.LoyaltyPointsLinesModal,onClick:function(e){return e.stopPropagation()},role:"dialog","aria-modal":"true"},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderTitle},Ie("checkout-page:loyaltyPointsLinesModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsLinesModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:z?{maxHeight:"316px"}:{maxHeight:ye<748?ye-140+"px":650}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(r=N.loyaltyCustomerInfo)||void 0===r?void 0:r.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),null==ke?void 0:ke.map((function(n,i){var a,l,s,r;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i!==((null==ke?void 0:ke.length)||0)-1||ue?"":C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},Pe(n).icon&&Pe(n).icon),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Pe(n).title),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},n.type===A.FIXED_AMOUNT&&n.isDynamic?Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(a=n.discountSettings)||void 0===a?void 0:a.point)||0,amount:d((null===(l=n.discountSettings)||void 0===l?void 0:l.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}):"".concat((null===(s=n.discountSettings)||void 0===s?void 0:s.point)||0," ").concat(Ie("checkout-page:loyaltyPoint"))))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:Ne((null===(r=n.discountSettings)||void 0===r?void 0:r.point)||0,n),onClick:function(){return e(void 0,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:return e=(null===(o=n.discountSettings)||void 0===o?void 0:o.point)||0,Ne(e,n)?[2]:n.type===A.FIXED_AMOUNT&&n.isDynamic?(ie(n),W(!0),[3,3]):[3,1];case 1:return[4,Se(n.loyaltyProgramId,n.id)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Ie("checkout-page:loyaltyPointsLineItemButtonApply")))))})),ue&&ue.length>0&&o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},o.createElement(T,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},Ce&&Le?"".concat(Ce," ~ ").concat(Le):""," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;return!n||n<(null!=Ce?Ce:0)}(),className:C.LoyaltyPointsLinesModalContentItemButton,onClick:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;!n||n<(null!=Ce?Ce:0)||w(!0)}},Ie("checkout-page:loyaltyPointsLineItemButtonSelectGift")))))),(x||B)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,B&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:ce,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(_,null),Ie("checkout-page:loyaltyPointsGiftModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsGiftModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(m=N.loyaltyCustomerInfo)||void 0===m?void 0:m.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),null==Ee?void 0:Ee.map((function(n,i){var a,l,s,r,c,d;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItemFreeProduct,C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==Ee?void 0:Ee.length)||0)-1?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconImage},n.mainImageSrc&&o.createElement("img",{src:n.mainImageSrc,alt:n.name})),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},n.name),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},(null===(l=null===(a=n.variants)||void 0===a?void 0:a.find((function(e){var t,o;return e.id===(null===(o=null===(t=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===t?void 0:t.discountSettings)||void 0===o?void 0:o.freeProductVariantId)})))||void 0===l?void 0:l.variantText)||""),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPoint},(null===(r=null===(s=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===s?void 0:s.discountSettings)||void 0===r?void 0:r.point)||0," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemButtonContainerMobile},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPointMobile},(null===(d=null===(c=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===c?void 0:c.discountSettings)||void 0===d?void 0:d.point)||0," ",Ie("checkout-page:loyaltyPoint")),function(){var i,a=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})),l=(null===(i=null==a?void 0:a.discountSettings)||void 0===i?void 0:i.point)||0,s=Ne(l,a);return o.createElement("button",{type:"button",disabled:s,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return s||!a?[2]:[4,Se(a.loyaltyProgramId,a.id)];case 1:return e.sent(),[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Ie("checkout-page:loyaltyPointsLineItemButtonAddFree"))}())))}))))),(z&&oe||Y)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,Y&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:de,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(_,null),Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(y=null==oe?void 0:oe.discountSettings)||void 0===y?void 0:y.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)})),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(p=null==oe?void 0:oe.discountSettings)||void 0===p?void 0:p.point)||0,amount:d((null===(v=null==oe?void 0:oe.discountSettings)||void 0===v?void 0:v.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:{maxHeight:"316px",overflow:"hidden"}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(E=N.loyaltyCustomerInfo)||void 0===E?void 0:E.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfo},o.createElement("span",null,le," ",Ie("checkout-page:loyaltyPoint")),o.createElement(U,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(b,null),o.createElement("span",null,d(le/((null===(g=null==oe?void 0:oe.discountSettings)||void 0===g?void 0:g.point)||1)*((null===(h=null==oe?void 0:oe.discountSettings)||void 0===h?void 0:h.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)))),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},function(){var e,t,n,i,a,l,s,r=(null===(e=null==oe?void 0:oe.discountSettings)||void 0===e?void 0:e.point)||1,c=null!==(n=null===(t=null==oe?void 0:oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit)&&void 0!==n?n:r,d=null!==(s=null!==(a=null===(i=null==oe?void 0:oe.pointUsageLimit)||void 0===i?void 0:i.maxPointLimit)&&void 0!==a?a:null===(l=N.loyaltyCustomerInfo)||void 0===l?void 0:l.totalPoint)&&void 0!==s?s:r,u=Math.max(d-c,0),m=u>0?(le-c)/u*100:0,y=Math.min(100,Math.max(0,m));return o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValue}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueText,style:{width:"".concat(y,"%")}}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueTextValue,style:{left:"".concat(y,"%")}}),o.createElement("input",{type:"range",min:c,max:d,step:r,className:C.LoyaltyPointsLinesModalSliderInput,value:le,onChange:function(e){return se(Number(e.target.value))}}))}())),o.createElement("div",{style:{display:"flex",width:"100%",marginTop:"24px",marginBottom:"24px"}},o.createElement(P,{onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Se(oe.loyaltyProgramId,oe.id,le)];case 1:return e.sent(),[2]}}))}))},style:{width:"100%"},text:Ie("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:d(le/((null===(L=null==oe?void 0:oe.discountSettings)||void 0===L?void 0:L.point)||1)*((null===(k=null==oe?void 0:oe.discountSettings)||void 0===k?void 0:k.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)})})))))))})),Q=i((function(e){var t=e.vm,n=e.isAddingNote,i=e.setAddingNote,a=u().t,l=o.useState(t.checkout.note?a("checkout-page:editOrderNote"):a("checkout-page:addOrderNote"))[0],s=o.useCallback((function(){i(!0)}),[]),c=o.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var d=t.step===r.SUCCESS;return d&&!t.checkout.note?null:o.createElement("div",{className:C.InfoRow},!n&&!d&&o.createElement("div",{className:C.ActionTextBtn,onClick:s},l),(n||d)&&o.createElement("div",{className:[C.CheckoutNoteContainer,d?C.Success:""].join(" ")},o.createElement("div",{className:C.Title},a("checkout-page:orderNote")),d?o.createElement("div",{className:C.CheckoutNoteDisplay},t.checkout.note):o.createElement(y,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:c,maxLength:320})))}));export{B as CartSummary,W as Coupon,H as CouponErrorCode,$ as LoyaltyPointsLine};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import a from"lodash/sortBy";import l from"../input-with-button/index.js";import s from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{formatCurrency as d}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as y}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import v from"../tooltip/index.js";import E from"../svg/arrow-down.js";import f from"../svg/cross.js";import g from"../svg/gift.js";import h from"../../styles/common.module.scss.js";import C from"./style.module.scss.js";import L from"../svg/ikas.js";import{Button as P}from"../button/index.js";import{IkasCampaignCreatedFor as k,IkasGiftCardType as N}from"@ikas/storefront-models";import S from"../../../../hooks/useDimension.js";import I from"../svg/coupon-code-tag.js";import M from"../svg/gift-cart-tag.js";import x from"../svg/store-credit-tag.js";import T from"../svg/gift-loyalty.js";import j from"../svg/package-loyalty.js";import b from"../svg/percentage-loyalty.js";import w from"../svg/arrow-loyalty.js";import O from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as A,searchProducts as D,useLoyaltyPoints as F}from"@ikas/storefront-api";import R from"../svg/left-arrow-loyalty.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 _}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 V}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-filter/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 U from"../svg/arrow-right-loyalty.js";var H;!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"}(H||(H={}));var B=i((function(e){var t,n,i,a,l,y,p,v,f,g,h,P,k=e.vm,N=e.allowExpand,I=e.isSuccessPageSummary,M=k.checkout,x=u().t,T=o.useState(!N),j=T[0],b=T[1],w=o.useState(!1),O=w[0],A=w[1],D=o.useState(null),F=D[0],R=D[1],_=o.useState(0),V=_[0],U=_[1],B=o.useState(null),q=B[0],Y=B[1],J=o.useState(!1),Z=J[0],ee=J[1],te=o.useState(!1),ne=te[0],oe=te[1],ie=o.useState(!1),ae=ie[0],le=ie[1],se=S().isMobile;o.useEffect((function(){N&&(j?q&&U(q.getBoundingClientRect().height):U(0))}),[j,q,N,Z,ne,O,ae]);var re=o.useMemo((function(){switch(F){case H.COUPON_CODE_NOT_EXIST:return x("checkout-page:giftCodeErrorDescription");case H.COUPON_CODE_NOT_EXIST_FOR_GUESS:return x("checkout-page:mustBeSignInToApplyCampaign");case H.COUPON_APPLIED_WITHOUT_DISCOUNT:return x("checkout-page:couponInvalidForCartItems");default:return""}}),[F]),ce=[C.CartSummary,N?C.HideOnDesktop:"",I?C.SuccessPageCartSummary:""].join(" "),de=N?{height:V+"px"}:void 0,ue=[C.ArrowDown,j?C.Rotated:""].join(" ");return M?o.createElement(o.Fragment,null,!!N&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!j){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}b(!j)}},o.createElement("div",{className:C.Left},x("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(k.finalPrice||0,M.currencyCode,M.currencySymbol)," (").concat(M.itemQuantity," ").concat(x("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:ue},o.createElement(E,null))))),o.createElement("div",{className:ce},o.createElement("div",{className:[C.DetailsContainer,I?C.SuccessPageDetailContainer:""].join(" "),style:de},o.createElement("div",{className:C.Details,ref:Y},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,M.items.map((function(e,t){return o.createElement(m,{key:t,vm:k,cartItem:e,currencyCode:M.currencyCode,onChange:le,isSuccessPageSummary:I})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},O&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:x("checkout-page:giftCodeErrorTitle"),content:re,onClose:function(){A(!1),R(null)}})),o.createElement(G,{label:x("checkout-page:subtotal"),value:M.formattedTotalPrice,tooltipText:x("checkout-page:subtotalTooltip"),hideMarginBottom:!(k.isCouponCodeVisible||(null===(t=k.checkout.giftCardLines)||void 0===t?void 0:t.length)||(null===(n=k.checkout.loyaltyLines)||void 0===n?void 0:n.length)||(null===(i=k.checkout.nonCouponAdjustments)||void 0===i?void 0:i.length))}),!!(null===(a=M.shippingLines)||void 0===a?void 0:a.length)&&(k.step===r.SUCCESS?o.createElement(G,{label:x("checkout-page:cartShippingTitle"),value:M.shippingTotal?M.formattedShippingTotal:x("checkout-page:free")}):M.shippingLines.map((function(e,t){return o.createElement(G,{key:t,label:e.paymentMethod?e.title:x("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,M.currencyCode,M.currencySymbol):x("checkout-page:free")})}))),o.createElement(X,{vm:k}),o.createElement(z,{vm:k}),(k.step===r.SUCCESS&&(!!k.checkout.note||!!k.checkout.appliedCouponCode)||k.step!==r.SUCCESS)&&k.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),!!(null===(l=k.loyaltySpendingMethods)||void 0===l?void 0:l.length)&&(null===(y=k.loyaltySpendingMethods)||void 0===y?void 0:y.length)>0&&!se&&!!(null===(p=k.customizationProps)||void 0===p?void 0:p.showLoyaltyPoints)&&o.createElement($,{vm:k,isVisibleLoyaltyPoints:k.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:k.setIsLoyaltyPointsVisible,isMobile:se}),o.createElement(K,{vm:k,isVisibleLoyaltyPoints:k.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:k.setIsLoyaltyPointsVisible}),o.createElement(W,{vm:k,isAddingCoupon:ne,setAddingCoupon:oe,setCouponError:A,setCouponErrorCode:R}),o.createElement(Q,{vm:k,isAddingNote:Z,setAddingNote:ee}),!!k.installmentExtraPrice&&k.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(G,{label:x("checkout-page:cartInterest"),value:d(k.installmentExtraPrice,M.currencyCode,M.currencySymbol)}))),k.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=k.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(G,{label:x("checkout-page:chargedAmount"),value:d((null===(f=k.openEditOrderTransaction)||void 0===f?void 0:f.chargedAmount)||0,M.currencyCode,M.currencySymbol)}),!!(null===(g=k.openEditOrderTransaction)||void 0===g?void 0:g.refundedAmount)&&o.createElement(G,{label:x("checkout-page:refundedAmount"),value:d((null===(h=k.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,M.currencyCode,M.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,I?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},k.isOpenEditOrderWithTransaction?x("checkout-page:totalAmountPayable"):x("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(k.finalPrice||0,M.currencyCode,M.currencySymbol)),!!M.$totalTax&&!!(null===(P=k.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},x("checkout-page:cartTaxTitle")+" "+M.$formattedTotalTax)))),!!k.loyaltyEarningMethod&&!!k.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},x("checkout-page:loyaltyEarningMethodTitle",{value:(k.loyaltyEarningMethod.pointsEarned/(k.loyaltyEarningMethod.amountPerPointsEarned||1)*k.finalPrice).toFixed(2)}))),!I&&!k.isPoweredByHidden&&o.createElement("div",{className:C.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(L,null))))))):null})),G=i((function(e){var t=e.label,n=e.value,i=e.tooltipText,a=e.hideMarginBottom;return o.createElement("div",{className:[C.InfoRow,a?C.hideMb:""].join(" ")},o.createElement("div",{className:C.Label},o.createElement("span",null,t),!!i&&o.createElement(v,{text:i,style:{marginLeft:"8px"}})),o.createElement("div",{className:C.Value},n))})),X=i((function(e){var t=e.vm,n=u().t;return t.checkout?o.createElement(o.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==k.LOYALTY_SPEND})).map((function(e,i){return o.createElement("div",{className:C.InfoRow,key:i},o.createElement("div",{className:C.Label},"INTEREST"===e.name?n("checkout-page:cartInterest"):e.name),o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,d(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),z=i((function(e){var t,n=e.vm,i=u().t;return n.checkout?o.createElement(o.Fragment,null,null===(t=n.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return o.createElement("div",{className:C.InfoRow,key:t},o.createElement("div",{className:C.Label},o.createElement("div",{className:C.GiftLabel},o.createElement(g,{style:{position:"relative",top:"-1px"}}),o.createElement("span",null,i("checkout-page:giftPackage")))),o.createElement("div",{className:C.Value},o.createElement("span",null,d(e.price,n.checkout.currencyCode,n.checkout.currencySymbol))))}))):null})),W=i((function(n){var i=n.vm,a=n.isAddingCoupon,s=n.setAddingCoupon,c=n.setCouponError,d=n.setCouponErrorCode,m=n.isOpenCouponCode,v=n.isMobile,E=n.showOnlyMobile,f=u().t,g=o.useState(""),L=g[0],k=g[1],N=o.useState(!1),S=N[0],I=N[1],M=o.useRef(null);o.useEffect((function(){a&&M.current&&M.current.focus()}),[a]);var x=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return i.checkout.couponCode=L,I(!0),[4,i.onCouponCodeApply(!0)];case 1:return t.sent(),I(!1),k(""),e=i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length,i.couponError?[3,4]:i.checkout.appliedCouponCode||e?(c(!1),d(null),[4,i.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:i.checkout.couponCode=null,c(!0),d(i.couponError),t.label=5;case 5:return[2]}}))}))},T=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeGiftCardLine(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return I(!0),[4,i.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))};i.step,r.SUCCESS;var b=i.step===r.SHIPPING,w=!!i.checkout.appliedCouponCode||!!(i.checkout.giftCardLines&&i.checkout.giftCardLines.length>0)||!!(i.checkout.loyaltyLines&&i.checkout.loyaltyLines.length>0),O=!!i.checkout.appliedCouponCode&&m,A=!a&&i.isCouponCodeVisible&&!i.isCouponCodeRequirementOpen&&i.step!==r.SUCCESS,D=w&&(!m||v);return o.createElement(o.Fragment,null,!!m&&o.createElement(o.Fragment,null,o.createElement("div",{className:[C.CartSummary,C.OpenCouponCodeSummary].join(" ")},o.createElement("div",{className:h.FormSectionTitle},o.createElement("div",{style:{paddingBottom:O?0:6},className:h.Title},f("checkout-page:couponCode"))))),w&&!b&&!i.isCouponCodeRequirementDefult&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement("div",{className:A?C.InfoRow:""},A&&o.createElement("div",{className:C.ActionTextBtn,onClick:function(){return s(!0)}},f("checkout-page:addCouponCode")),a&&!m&&o.createElement("div",{style:{marginBottom:"10px"}},o.createElement(l,{value:L,placeholder:f("checkout-page:couponCode"),buttonLabel:f("checkout-page:actions.apply"),inputRef:M,onClick:x,isLoading:S,onChange:k})),m&&o.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&x()},className:[C.OpenCouponCodeMain,D?C.OpenCouponCodeMainWithMb:""].join(" ")},o.createElement(y,{name:"couponCode",label:f("checkout-page:addCouponCode"),type:p.TEXT,value:L,onChange:k}),o.createElement(P,{style:{width:"33%"},text:f("checkout-page:actions.apply"),isLoading:S,onClick:x}))),D&&o.createElement(o.Fragment,null,!!i.checkout.appliedCouponCode&&o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(q,{vm:i,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return i.checkout.couponCode=null,I(!0),[4,i.onCouponCodeApply(!1)];case 1:return e.sent(),[4,i.reInitPaymentMethod()];case 2:return e.sent(),I(!1),[2]}}))}))},couponCode:i.checkout.appliedCouponCode})),!!i.checkout.giftCardLines&&!!i.checkout.giftCardLines.length&&i.checkout.giftCardLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(q,{vm:i,onClearGiftCode:T,couponCode:e.code,giftCardLine:e}))})),!!i.checkout.loyaltyLines&&!!i.checkout.loyaltyLines.length&&i.checkout.loyaltyLines.map((function(e){return o.createElement("div",{className:[C.InfoRow,E?C.InfoRowGiftCardMobile:""].join(" ")},o.createElement(Y,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),q=i((function(e){var t=e.vm,n=e.onClearCouponCode,i=e.couponCode,a=e.giftCardLine,l=e.onClearGiftCode,s=t.checkout.couponAdjustment,c=u().t,m=!a,y=(null==a?void 0:a.type)===N.STORE_CREDIT;return o.createElement(o.Fragment,null,o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},a&&y&&o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},o.createElement("span",{style:{height:"20px"}},o.createElement(x,null)),o.createElement("span",{className:C.StoreCreditTag},c("checkout-page:storeCredit"))),!y&&o.createElement("span",{className:[C.AppliedCoupon,t.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},m?o.createElement("span",{style:{height:"16px"}},o.createElement(I,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(M,null)),o.createElement("span",{className:C.CouponCode},i),t.step!==r.SUCCESS&&!t.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCoupon,onClick:function(){return a?l&&l(a.giftCardId):n&&n()}},o.createElement(f,null)))),o.createElement("div",null,a?o.createElement("div",{className:C.Value},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==a?void 0:a.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):o.createElement("div",{className:C.Value},o.createElement("span",null,"DECREMENT"===(null==s?void 0:s.type)?"- ":"")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),Y=i((function(e){var t,n,i=e.vm,a=e.onClearLoyaltyPoints,l=e.loyaltyPointsLine,s=null===(t=i.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===l.id})),c=u().t,m=null===(n=i.loyaltySpendingMethodsAll)||void 0===n?void 0:n.find((function(e){return e.id===l.loyaltySpendingMethodId})),y=function(){return m?m.type===A.FREE_PRODUCT?{icon:o.createElement(T,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===A.FREE_SHIPPING?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPoints")}};return o.createElement(o.Fragment,null,o.createElement("div",{className:C.LoyaltyPointsLineContainer},o.createElement("div",{className:[C.ActionTextBtn,C.NoUnderline].join(" ")},o.createElement("span",{className:[C.AppliedCouponLoyalty,i.isCouponCodeRequirementDefult?"":C.NotClosed].join(" ")},o.createElement("div",{style:{width:"16px",height:"16px"},className:C.LoyaltyPointsLineIcon},y().icon),o.createElement("span",{className:C.CouponCode},y().title),i.step!==r.SUCCESS&&!i.isOpenEditOrderWithTransaction&&o.createElement("span",{className:C.ClearCouponLoyalty,onClick:function(){return a&&a(l.loyaltySpendingMethodId)}},o.createElement(f,null)))),o.createElement("span",{className:C.LoyaltyPointSpending},"(",c("checkout-page:loyaltyPointSpending",{point:l.amount}),")")),m?m.type!==A.FREE_PRODUCT&&m.type!==A.FREE_SHIPPING?o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))):null:o.createElement("div",null,o.createElement("div",{className:C.ValueLoyalty},o.createElement("span",null,"-")," ",o.createElement("span",null,d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)))))})),$=i((function(e){var t,n,i,a,l,s,r,c,m,y=e.vm;e.isVisibleLoyaltyPoints;var p=e.setIsVisibleLoyaltyPoints,v=e.isMobile,E=o.useState("undefined"!=typeof window?window.innerWidth:1500),f=E[0],g=E[1];o.useEffect((function(){var e=function(){return g(window.innerWidth)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var h=null===(t=y.loyaltySpendingMethods)||void 0===t?void 0:t.filter((function(e){return e.type===A.FREE_PRODUCT})),L=null!==(n=null==h?void 0:h.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==n?n:[],P=L.length?Math.min.apply(Math,L):null,k=L.length?Math.max.apply(Math,L):null,N=1===(null===(i=y.loyaltySpendingMethods)||void 0===i?void 0:i.length),S=function(e){var t,n,i,a,l,s="",r=null;return e.type===A.FIXED_AMOUNT&&e.isDynamic&&(s=N?"".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount")," (").concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0,amount:d((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),")"):I("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),r=o.createElement(b,null)),e.type===A.FREE_SHIPPING&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(j,null)),e.type!==A.FIXED_AMOUNT||e.isDynamic||(s=N?I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmountOneRow",{value:d((null===(i=e.discountSettings)||void 0===i?void 0:i.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}):I("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(a=e.discountSettings)||void 0===a?void 0:a.discountAmount)||0,y.checkout.currencyCode,y.checkout.currencySymbol)}),r=o.createElement(b,null)),e.type===A.FREE_PRODUCT&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(T,null)),e.type===A.RATIO&&(s="".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,")"),r=o.createElement(b,null)),{title:s,icon:r}},I=u().t,M=null!==(l=null===(a=y.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type!==A.FREE_PRODUCT})))&&void 0!==l?l:[],x=f>1380||v?h&&h.length>0?2:3:f<1100?h&&h.length>0?0:1:h&&h.length>0?1:2,O=M.slice(0,Math.min(x,M.length));return 1===(null===(s=y.loyaltySpendingMethods)||void 0===s?void 0:s.length)?o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsLineOneRow,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineOneRowTitle},S(null===(r=y.loyaltySpendingMethods)||void 0===r?void 0:r[0]).icon&&S(null===(c=y.loyaltySpendingMethods)||void 0===c?void 0:c[0]).icon,o.createElement("span",{className:C.LoyaltyPointsLineOneRowTitleText},S(null===(m=y.loyaltySpendingMethods)||void 0===m?void 0:m[0]).title)),o.createElement(w,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},I("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},O.map((function(e){var t;return o.createElement("div",{key:e.id,className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},S(e).icon&&S(e).icon,o.createElement("span",{className:C.LoyaltyPointsLineTitleText},S(e).title)),o.createElement("span",{className:C.LoyaltyPointsLineValue},(null===(t=e.discountSettings)||void 0===t?void 0:t.point)||0," ",I("checkout-page:loyaltyPoint")))})),h&&h.length>0&&o.createElement("div",{className:C.LoyaltyPointsLine,onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineTitle},o.createElement(T,null),o.createElement("span",{className:C.LoyaltyPointsLineTitleText},I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"))),o.createElement("span",{className:C.LoyaltyPointsLineValue},P&&k?"".concat(P," ~ ").concat(k):""," ",I("checkout-page:loyaltyPoint"))),o.createElement("div",{className:[C.LoyaltyPointsLine,C.LoyaltyPointsLineAllMain].join(" "),onClick:function(){return p(!0)}},o.createElement("div",{className:C.LoyaltyPointsLineAllContainer},o.createElement("span",{className:C.LoyaltyPointsLineAll},I("checkout-page:loyaltyPointsViewAll")),o.createElement(w,null)))))})),K=i((function(i){var a,l,s,r,m,y,p,v,E,g,h,L,k,N=i.vm,S=i.isVisibleLoyaltyPoints,I=i.setIsVisibleLoyaltyPoints,M=o.useState(!1),x=M[0],w=M[1],H=o.useState(!1),B=H[0],G=H[1],X=o.useState(!1),z=X[0],W=X[1],q=o.useState(!1),Y=q[0],$=q[1],K=o.useState(!1),Q=K[0],J=K[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(null),oe=ne[0],ie=ne[1],ae=o.useState(0),le=ae[0],se=ae[1];o.useEffect((function(){if(S&&!Q){var e=requestAnimationFrame((function(){requestAnimationFrame((function(){return te(!0)}))}));return function(){return cancelAnimationFrame(e)}}S||te(!1)}),[S,Q]),o.useEffect((function(){if(Q){var e=setTimeout((function(){I(!1),J(!1)}),250);return function(){return clearTimeout(e)}}}),[Q]);var re=o.useCallback((function(){J(!0)}),[]),ce=o.useCallback((function(){G(!0)}),[]),de=o.useCallback((function(){$(!0)}),[]);o.useEffect((function(){if(B){var e=setTimeout((function(){w(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){W(!1),ie(null),$(!1)}),180);return function(){return clearTimeout(e)}}}),[Y]),o.useEffect((function(){var e,t;if(oe){var n=(null===(e=oe.discountSettings)||void 0===e?void 0:e.point)||1,o=null===(t=oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit;se("number"==typeof o&&o>0?o:n)}}),[oe]);var ue=null===(a=N.loyaltySpendingMethods)||void 0===a?void 0:a.filter((function(e){return e.type===A.FREE_PRODUCT})),me=o.useState("undefined"!=typeof window?window.innerHeight:1200),ye=me[0],pe=me[1];o.useEffect((function(){var e=function(){return pe(window.innerHeight)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),o.useEffect((function(){S&&ge((null==ue?void 0:ue.map((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)||""})))||[])}),[S]);var ve=o.useState([]),Ee=ve[0],fe=ve[1],ge=function(n){return e(void 0,void 0,void 0,(function(){var e,o,i;return t(this,(function(t){switch(t.label){case 0:return(null==n?void 0:n.length)?[4,D({input:{productIdList:n,page:1,perPage:n.length,priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId()}},[])]:[2,[]];case 1:return e=t.sent(),o=(null===(i=e.data)||void 0===i?void 0:i.data)||[],fe(o.map((function(e){var t,n,o,i,a,l;return{id:e.id,name:e.name,mainImageSrc:new V({id:(null===(a=null===(i=null===(o=null===(n=null===(t=e.variants)||void 0===t?void 0:t[0])||void 0===n?void 0:n.images)||void 0===o?void 0:o.find((function(e){return e.isMain})))||void 0===i?void 0:i.image)||void 0===a?void 0:a.id)||null,isVideo:!1}).thumbnailSrc,variants:(null===(l=e.variants)||void 0===l?void 0:l.map((function(e){var t,n,o,i;return{id:e.id,mainImageSrc:new V({id:(null===(o=null===(n=null===(t=e.images)||void 0===t?void 0:t.find((function(e){return e.isMain})))||void 0===n?void 0:n.image)||void 0===o?void 0:o.id)||null,isVideo:!1}).thumbnailSrc,variantText:(null===(i=e.variantValues)||void 0===i?void 0:i.map((function(e){return e.name})).join(" / "))||null}})))||[]}}))),[2]}}))}))},he=null!==(l=null==ue?void 0:ue.map((function(e){var t;return null===(t=e.discountSettings)||void 0===t?void 0:t.point})).filter((function(e){return"number"==typeof e})))&&void 0!==l?l:[],Ce=he.length?Math.min.apply(Math,he):null,Le=he.length?Math.max.apply(Math,he):null,Pe=function(e){var t,n,i="",a=null;return e.type===A.FIXED_AMOUNT&&e.isDynamic&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(b,null)),e.type===A.FREE_SHIPPING&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(j,null)),e.type!==A.FIXED_AMOUNT||e.isDynamic||(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(t=e.discountSettings)||void 0===t?void 0:t.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}),a=o.createElement(b,null)),e.type===A.FREE_PRODUCT&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(T,null)),e.type===A.RATIO&&(i="".concat(Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,")"),a=o.createElement(b,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==A.FREE_PRODUCT})),Ne=function(e,t){var n,o,i,a,l=null!==(o=null===(n=N.loyaltyCustomerInfo)||void 0===n?void 0:n.totalPoint)&&void 0!==o?o:0;return(null==t?void 0:t.type)===A.FIXED_AMOUNT&&(null==t?void 0:t.isDynamic)?!!((null===(i=t.pointUsageLimit)||void 0===i?void 0:i.minPointLimit)&&(null===(a=t.pointUsageLimit)||void 0===a?void 0:a.minPointLimit)>l):!l||l<e},Se=function(o,i,a){return e(void 0,void 0,void 0,(function(){var e,l;return t(this,(function(t){switch(t.label){case 0:return[4,F({input:n({cartId:N.checkout.id,loyaltyProgramId:o,loyaltySpendingMethodId:i},a?{amount:a}:{})})];case 1:return(e=t.sent()).isSuccess?(re(),l=e.data,N.checkout=new _(n(n({},l),{shippingAddress:N.checkout.shippingAddress,billingAddress:N.checkout.billingAddress,customer:N.checkout.customer,selectedPaymentGateway:N.checkout.selectedPaymentGateway}),N.countrySettings),[4,N.getLoyaltyCustomerInfo()]):[3,4];case 2:return t.sent(),[4,N.listSpendingMethodsByCartId()];case 3:t.sent(),t.label=4;case 4:return[2,e]}}))}))},Ie=u().t;if(!S&&!Q)return null;var Me=[C.LoyaltyPointsLinesModalContainer,ee&&!Q&&C.LoyaltyPointsLinesModalContainerVisible,Q&&C.LoyaltyPointsLinesModalContainerClosing].filter(Boolean).join(" ");return o.createElement("div",{className:Me,onClick:re,role:"presentation"},o.createElement("div",{className:C.LoyaltyPointsLinesModal,onClick:function(e){return e.stopPropagation()},role:"dialog","aria-modal":"true"},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderTitle},Ie("checkout-page:loyaltyPointsLinesModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsLinesModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:z?{maxHeight:"316px"}:{maxHeight:ye<748?ye-140+"px":650}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(r=N.loyaltyCustomerInfo)||void 0===r?void 0:r.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),null==ke?void 0:ke.map((function(n,i){var a,l,s,r;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i!==((null==ke?void 0:ke.length)||0)-1||ue?"":C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},Pe(n).icon&&Pe(n).icon),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Pe(n).title),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},n.type===A.FIXED_AMOUNT&&n.isDynamic?Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(a=n.discountSettings)||void 0===a?void 0:a.point)||0,amount:d((null===(l=n.discountSettings)||void 0===l?void 0:l.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}):"".concat((null===(s=n.discountSettings)||void 0===s?void 0:s.point)||0," ").concat(Ie("checkout-page:loyaltyPoint"))))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:Ne((null===(r=n.discountSettings)||void 0===r?void 0:r.point)||0,n),onClick:function(){return e(void 0,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:return e=(null===(o=n.discountSettings)||void 0===o?void 0:o.point)||0,Ne(e,n)?[2]:n.type===A.FIXED_AMOUNT&&n.isDynamic?(ie(n),W(!0),[3,3]):[3,1];case 1:return[4,Se(n.loyaltyProgramId,n.id)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Ie("checkout-page:loyaltyPointsLineItemButtonApply")))))})),ue&&ue.length>0&&o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItem,C.LoyaltyPointsLinesModalContentItemsLast].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIcon},o.createElement(T,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},Ce&&Le?"".concat(Ce," ~ ").concat(Le):""," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;return!n||n<(null!=Ce?Ce:0)}(),className:C.LoyaltyPointsLinesModalContentItemButton,onClick:function(){var e,t,n=null!==(t=null===(e=N.loyaltyCustomerInfo)||void 0===e?void 0:e.totalPoint)&&void 0!==t?t:0;!n||n<(null!=Ce?Ce:0)||w(!0)}},Ie("checkout-page:loyaltyPointsLineItemButtonSelectGift")))))),(x||B)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,B&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:ce,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(R,null),Ie("checkout-page:loyaltyPointsGiftModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsGiftModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(m=N.loyaltyCustomerInfo)||void 0===m?void 0:m.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),null==Ee?void 0:Ee.map((function(n,i){var a,l,s,r,c,d;return o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItems},o.createElement("div",{className:[C.LoyaltyPointsLinesModalContentItemFreeProduct,C.LoyaltyPointsLinesModalContentItem,0===i?C.LoyaltyPointsLinesModalContentItemsFirst:"",i===((null==Ee?void 0:Ee.length)||0)-1?C.LoyaltyPointsLinesModalContentItemsLast:""].join(" ")},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconContainer},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueIconImage},n.mainImageSrc&&o.createElement("img",{src:n.mainImageSrc,alt:n.name})),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},n.name),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},(null===(l=null===(a=n.variants)||void 0===a?void 0:a.find((function(e){var t,o;return e.id===(null===(o=null===(t=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===t?void 0:t.discountSettings)||void 0===o?void 0:o.freeProductVariantId)})))||void 0===l?void 0:l.variantText)||""),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPoint},(null===(r=null===(s=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===s?void 0:s.discountSettings)||void 0===r?void 0:r.point)||0," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemButtonContainerMobile},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemPointMobile},(null===(d=null===(c=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})))||void 0===c?void 0:c.discountSettings)||void 0===d?void 0:d.point)||0," ",Ie("checkout-page:loyaltyPoint")),function(){var i,a=null==ue?void 0:ue.find((function(e){var t;return(null===(t=e.discountSettings)||void 0===t?void 0:t.freeProductId)===n.id})),l=(null===(i=null==a?void 0:a.discountSettings)||void 0===i?void 0:i.point)||0,s=Ne(l,a);return o.createElement("button",{type:"button",disabled:s,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return s||!a?[2]:[4,Se(a.loyaltyProgramId,a.id)];case 1:return e.sent(),[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Ie("checkout-page:loyaltyPointsLineItemButtonAddFree"))}())))}))))),(z&&oe||Y)&&o.createElement("div",{className:C.LoyaltyPointsGiftModalOverlay},o.createElement("div",{className:[C.LoyaltyPointsGiftModal,Y&&C.LoyaltyPointsGiftModalClosing].filter(Boolean).join(" ")},o.createElement("span",{onClick:re,className:C.LoyaltyPointsLinesModalCloseButton},o.createElement(f,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{style:{display:"flex",alignItems:"center",gap:"12px",cursor:"pointer"},onClick:de,className:C.LoyaltyPointsLinesModalHeaderTitle},o.createElement(R,null),Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null===(y=null==oe?void 0:oe.discountSettings)||void 0===y?void 0:y.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)})),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmountDescription",{point:(null===(p=null==oe?void 0:oe.discountSettings)||void 0===p?void 0:p.point)||0,amount:d((null===(v=null==oe?void 0:oe.discountSettings)||void 0===v?void 0:v.discountAmount)||0,N.checkout.currencyCode,N.checkout.currencySymbol)}))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:{maxHeight:"316px",overflow:"hidden"}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Ie("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(O,null)),o.createElement("span",null,(null===(E=N.loyaltyCustomerInfo)||void 0===E?void 0:E.totalPoint)||0," ",Ie("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfo},o.createElement("span",null,le," ",Ie("checkout-page:loyaltyPoint")),o.createElement(U,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(b,null),o.createElement("span",null,d(le/((null===(g=null==oe?void 0:oe.discountSettings)||void 0===g?void 0:g.point)||1)*((null===(h=null==oe?void 0:oe.discountSettings)||void 0===h?void 0:h.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)))),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},function(){var e,t,n,i,a,l,s,r=(null===(e=null==oe?void 0:oe.discountSettings)||void 0===e?void 0:e.point)||1,c=null!==(n=null===(t=null==oe?void 0:oe.pointUsageLimit)||void 0===t?void 0:t.minPointLimit)&&void 0!==n?n:r,d=null!==(s=null!==(a=null===(i=null==oe?void 0:oe.pointUsageLimit)||void 0===i?void 0:i.maxPointLimit)&&void 0!==a?a:null===(l=N.loyaltyCustomerInfo)||void 0===l?void 0:l.totalPoint)&&void 0!==s?s:r,u=Math.max(d-c,0),m=u>0?(le-c)/u*100:0,y=Math.min(100,Math.max(0,m));return o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValue}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueText,style:{width:"".concat(y,"%")}}),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoSliderValueTextValue,style:{left:"".concat(y,"%")}}),o.createElement("input",{type:"range",min:c,max:d,step:r,className:C.LoyaltyPointsLinesModalSliderInput,value:le,onChange:function(e){return se(Number(e.target.value))}}))}())),o.createElement("div",{style:{display:"flex",width:"100%",marginTop:"24px",marginBottom:"24px"}},o.createElement(P,{onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Se(oe.loyaltyProgramId,oe.id,le)];case 1:return e.sent(),[2]}}))}))},style:{width:"100%"},text:Ie("checkout-page:loyaltyPointsLineItemButtonApplyAmount",{amount:d(le/((null===(L=null==oe?void 0:oe.discountSettings)||void 0===L?void 0:L.point)||1)*((null===(k=null==oe?void 0:oe.discountSettings)||void 0===k?void 0:k.discountAmount)||0),N.checkout.currencyCode,N.checkout.currencySymbol)})})))))))})),Q=i((function(e){var t=e.vm,n=e.isAddingNote,i=e.setAddingNote,a=u().t,l=o.useState(t.checkout.note?a("checkout-page:editOrderNote"):a("checkout-page:addOrderNote"))[0],s=o.useCallback((function(){i(!0)}),[]),c=o.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var d=t.step===r.SUCCESS;return d&&!t.checkout.note?null:o.createElement("div",{className:C.InfoRow},!n&&!d&&o.createElement("div",{className:C.ActionTextBtn,onClick:s},l),(n||d)&&o.createElement("div",{className:[C.CheckoutNoteContainer,d?C.Success:""].join(" ")},o.createElement("div",{className:C.Title},a("checkout-page:orderNote")),d?o.createElement("div",{className:C.CheckoutNoteDisplay},t.checkout.note):o.createElement(y,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:c,maxLength:320})))}));export{B as CartSummary,W as Coupon,H as CouponErrorCode,$ as LoyaltyPointsLine};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.284",
|
|
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.
|
|
27
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
29
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
30
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
26
|
+
"@ikas/storefront-api": "^6.1.0-beta.284",
|
|
27
|
+
"@ikas/storefront-config": "^6.1.0-beta.284",
|
|
28
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.284",
|
|
29
|
+
"@ikas/storefront-models": "^6.1.0-beta.284",
|
|
30
|
+
"@ikas/storefront-providers": "^6.1.0-beta.284",
|
|
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.
|
|
66
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
68
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
69
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
65
|
+
"@ikas/storefront-api": "^6.1.0-beta.284",
|
|
66
|
+
"@ikas/storefront-config": "^6.1.0-beta.284",
|
|
67
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.284",
|
|
68
|
+
"@ikas/storefront-models": "^6.1.0-beta.284",
|
|
69
|
+
"@ikas/storefront-providers": "^6.1.0-beta.284",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|