@ikas/storefront 6.1.0-beta.301 → 6.1.0-beta.303

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{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as t}from"mobx-react-lite";import{IkasCheckoutRequirement as o}from"@ikas/storefront-models";import{FormItem as i}from"../form-item/index.js";import{FormItemType as a,FormItemInputMode as n}from"../form-item/model.js";import l from"./model.js";import{Checkbox as s}from"../checkbox/index.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";import{AddressFormItem as c,BillingFormItem as u}from"@ikas/localized-address";import v from"../../styles/common.module.scss.js";import m from"../../style.module.scss.js";var E=t((function(t){var o=r.useMemo((function(){return new l(e({},t))}),[]);return r.useEffect((function(){Object.entries(t).forEach((function(e){o[e[0]]=e[1]}))}),Object.values(t)),"in-store"===t.deliveryMethod?r.createElement(p,{props:t,vm:o}):r.createElement(h,{props:t,vm:o})})),p=t((function(t){var i=t.props,a=t.vm;return d().t,r.createElement("div",null,r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},r.createElement(g,e({},i,{vm:a})),r.createElement(f,e({},i,{vm:a})),r.createElement("div",null)," "),!!a.address.checkoutSettings&&a.address.checkoutSettings.phoneRequirement!==o.INVISIBLE&&r.createElement("div",{className:m.RowPB},r.createElement(I,e({},i,{vm:a})),r.createElement("div",null)," "))})),h=t((function(t){var o,i,a,n=t.props,l=t.vm,E=d().t,p=function(t){var o=t.map((function(t){return function(t){switch(t){case c.FIRSTNAME:return r.createElement(g,e({},n,{vm:l}));case c.LASTNAME:return r.createElement(f,e({},n,{vm:l}));case c.IDENTITY_NUMBER:return r.createElement(b,e({},n,{vm:l}));case c.ADDRESS_LINE_1:return r.createElement(y,e({},n,{vm:l}));case c.ADDRESS_LINE_2:return r.createElement(T,e({},n,{vm:l}));case c.POSTAL_CODE:return r.createElement(N,e({},n,{vm:l}));case c.COUNTRY:return r.createElement(k,e({},n,{vm:l}));case c.STATE:return r.createElement(L,e({},n,{vm:l}));case c.CITY:return l.address.isFreeTextCity?r.createElement(R,e({},n,{vm:l})):r.createElement(x,e({},n,{vm:l}));case c.DISTRICT:return l.address.isFreeTextDistrict?r.createElement(S,e({},n,{vm:l})):r.createElement(O,e({},n,{vm:l}));case c.REGION:return r.createElement(A,e({},n,{vm:l}));case c.PHONE:return r.createElement(I,e({},n,{vm:l}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},o),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},o,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},o,r.createElement("div",null)," "))},h=function(t){var o=t.map((function(t){return function(t){switch(t){case u.COMPANY:return r.createElement(V,e({},n,{vm:l}));case u.TAX_NUMBER:return r.createElement(j,e({},n,{vm:l}));case u.TAX_OFFICE:return r.createElement(F,e({},n,{vm:l}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},o),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},o,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},o,r.createElement("div",null)," "))};return r.createElement("div",null,l.allowTitleChange&&r.createElement("div",{className:m.RowPB},r.createElement(C,e({},n,{vm:l}))),l.countryOptions.length<=1?null===(o=l.address.addressFormatIgnoreCountry)||void 0===o?void 0:o.map((function(e){return p(e)})):null===(i=l.address.addressFormat)||void 0===i?void 0:i.map((function(e){return p(e)})),!!l.allowCorporateInfo&&r.createElement("div",{style:{marginTop:"12px"}},r.createElement(s,{value:l.isCorporate,label:E("checkout-page:corporateInvoice"),onChange:l.onCorporateChange})),!!l.isCorporate&&(null===(a=l.address.billingFormat)||void 0===a?void 0:a.map((function(e){return h(e)}))))})),g=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping given-name":"given-name",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.firstName;return r.createElement(i,{name:"firstName",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.firstName)||void 0===n?void 0:n.label)||c("checkout-page:firstName"),autocomplete:u,value:s.firstName||"",onChange:s.onFirstNameChange,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.firstName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:firstNameError")})})),f=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping family-name":"family-name",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.lastName;return r.createElement(i,{name:"lastName",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.lastName)||void 0===n?void 0:n.label)||c("checkout-page:lastName"),autocomplete:u,value:s.lastName||"",onChange:s.onLastNameChange,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.lastName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:lastNameError")})})),b=t((function(e){var t,o,n,l=e.vm,s=d().t;return r.createElement(i,{name:"identityNumber",type:a.TEXT,label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.identityNumber)||void 0===o?void 0:o.label)||s("checkout-page:identityNumber"),value:l.identityNumber||"",onChange:l.onIdentityNumberChange,hasError:l.isErrorsVisible&&(null===(n=l.address.validationResults)||void 0===n?void 0:n.identityNumber.hasError),errorText:s("checkout-page:identityNumberError")})})),C=t((function(e){var t=e.vm,o=d().t,n=t.address;return r.createElement(i,{type:a.TEXT,label:o("checkout-page:addressTitle"),value:n.title||"",onChange:t.onAddressTitleChange,hasError:t.isErrorsVisible&&!n.title,errorText:o("checkout-page:addressTitleError")})})),y=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping address-line1":"address-line1",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine1;return r.createElement(i,{name:"addressLine1",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.addressLine1)||void 0===n?void 0:n.label)||c("checkout-page:addressLine1"),autocomplete:u,value:s.address.addressLine1||"",onChange:s.onAddressLine1Change,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.addressLine1.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:addressError")})})),T=t((function(e){var t,o,n,l=e.vm,s=d().t,c=l.isShippingAddress?"shipping address-line2":"address-line2",u=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine2;return r.createElement(i,{name:"addressLine2",type:a.TEXT,autocomplete:c,label:(null===(n=null===(o=l.address.fieldLabels)||void 0===o?void 0:o.addressLine2)||void 0===n?void 0:n.label)||s("checkout-page:addressLine2"),value:l.address.addressLine2||"",onChange:l.onAddressLine2Change,hasError:l.isErrorsVisible&&u,errorText:u?s("checkout-page:fieldRestrictionError"):void 0})})),N=t((function(e){var t,o,n,l=e.vm,s=d().t,c=l.isShippingAddress?"shipping postal-code":"postal-code";return r.createElement(i,{name:"postalCode",type:a.TEXT,label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.postalCode)||void 0===o?void 0:o.label)||s("checkout-page:postalCode"),autocomplete:c,value:l.address.postalCode||"",onChange:l.onAddressPostalCodeChange,hasError:l.isErrorsVisible&&(null===(n=l.address.validationResults)||void 0===n?void 0:n.postalCode.hasError),errorText:s("checkout-page:postalCodeError")})})),k=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return s.countryOptions.length<=1?null:r.createElement(i,{name:"country",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.country)||void 0===o?void 0:o.label)||c("checkout-page:country"),autocomplete:"country-name",value:(null===(n=s.country)||void 0===n?void 0:n.id)||"",onChange:s.onCountryChange,options:s.countryOptions,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.country.hasError),errorText:c("checkout-page:countryError")})})),L=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"state",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.state)||void 0===o?void 0:o.label)||c("checkout-page:state"),value:(null===(n=s.state)||void 0===n?void 0:n.id)||"",onChange:s.onStateChange,options:s.stateOptions,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.state.hasError),errorText:c("checkout-page:stateError")})})),x=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"city",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===o?void 0:o.label)||c("checkout-page:city"),autocomplete:"off",value:(null===(n=s.city)||void 0===n?void 0:n.id)||"",onChange:s.onCityChange,options:s.cityOptions,disabled:!s.cityOptions.length,isLoading:s.isLoadingCities,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.city.hasError),errorText:c("checkout-page:cityError")})})),R=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"city",type:a.TEXT,autocomplete:"address-level2",label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===o?void 0:o.label)||c("checkout-page:city"),value:(null===(n=s.city)||void 0===n?void 0:n.name)||"",hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.city.hasError),onChange:s.onCityInputChange,errorText:c("checkout-page:cityError")})})),O=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"district",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===o?void 0:o.label)||c("checkout-page:district"),autocomplete:"off",value:(null===(n=s.district)||void 0===n?void 0:n.id)||"",onChange:s.onDistrictChange,options:s.districtOptions,disabled:!s.districtOptions.length,isLoading:s.isLoadingDistricts,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.district.hasError),errorText:c("checkout-page:districtError")})})),S=t((function(e){var t,o,n,l=e.vm,s=d().t;return r.createElement(i,{name:"district",type:a.TEXT,autocomplete:"address-level3",label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===o?void 0:o.label)||s("checkout-page:district"),value:(null===(n=l.district)||void 0===n?void 0:n.name)||"",onChange:l.onDistrictInputChange})})),A=t((function(e){var t,o,n=e.vm,l=d().t;return r.createElement(i,{name:"region",type:a.SELECT,label:l("checkout-page:region"),autocomplete:"off",value:(null===(t=n.region)||void 0===t?void 0:t.id)||"",onChange:n.onRegionChange,options:n.regionOptions,hasError:n.isErrorsVisible&&(null===(o=n.address.validationResults)||void 0===o?void 0:o.region.hasError),errorText:l("checkout-page:regionError")})})),I=t((function(e){var t,o,l,s,c=e.vm,u=d().t,v=c.isShippingAddress?"shipping tel":"tel";return r.createElement(i,{name:"phone",type:a.TEL,inputMode:n.TEL,label:(null===(o=null===(t=c.address.fieldLabels)||void 0===t?void 0:t.phone)||void 0===o?void 0:o.label)||u("checkout-page:phone"),autocomplete:v,value:c.phone||"",onChange:c.onPhoneChange,hasError:c.isErrorsVisible&&(null===(l=c.address.validationResults)||void 0===l?void 0:l.phone.hasError),currentCountryCode:(null===(s=c.address.country)||void 0===s?void 0:s.iso2)||c.myCountryCode,errorText:u("checkout-page:phoneError")})})),V=t((function(e){var t,o,n,l=e.vm,s=d().t,c=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.companyName;return r.createElement(i,{name:"company",type:a.TEXT,label:(null===(n=null===(o=l.address.fieldLabels)||void 0===o?void 0:o.company)||void 0===n?void 0:n.label)||s("checkout-page:companyName"),value:l.address.company||"",onChange:l.onCompanyChange,hasError:l.isErrorsVisible&&c,errorText:c?s("checkout-page:fieldRestrictionError"):void 0})})),F=t((function(e){var t,o,n,l,s,c=e.vm,u=d().t,v=null===(t=c.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.taxOffice;return r.createElement(i,{name:"taxOffice",type:a.TEXT,label:(null===(n=null===(o=c.address.fieldLabels)||void 0===o?void 0:o.taxOffice)||void 0===n?void 0:n.label)||u("checkout-page:taxOffice"),value:(null===(l=c.address)||void 0===l?void 0:l.taxOffice)||"",onChange:c.onTaxOfficeChange,hasError:c.isErrorsVisible&&((null===(s=c.address.validationResults)||void 0===s?void 0:s.taxOffice.hasError)||v),errorText:u(v?"checkout-page:fieldRestrictionError":"checkout-page:taxOfficeError")})})),j=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"taxNumber",type:a.TEXT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.taxNumber)||void 0===o?void 0:o.label)||c("checkout-page:taxNumber"),value:(null===(n=s.address)||void 0===n?void 0:n.taxNumber)||"",onChange:s.onTaxNumberChange,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.taxNumber.hasError),errorText:c("checkout-page:taxNumberError")})}));export{E as AddressForm};
1
+ import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as t}from"mobx-react-lite";import{IkasCheckoutRequirement as i}from"@ikas/storefront-models";import{FormItem as o}from"../form-item/index.js";import{FormItemType as a,FormItemInputMode as n}from"../form-item/model.js";import s from"./model.js";import{Checkbox as l}from"../checkbox/index.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";import{AddressFormItem as c,BillingFormItem as u}from"@ikas/localized-address";import v from"../../styles/common.module.scss.js";import m from"../../style.module.scss.js";var E=t((function(t){var i=r.useMemo((function(){return new s(e({},t))}),[]);return r.useEffect((function(){Object.entries(t).forEach((function(e){i[e[0]]=e[1]}))}),Object.values(t)),"in-store"===t.deliveryMethod?r.createElement(p,{props:t,vm:i}):r.createElement(h,{props:t,vm:i})})),p=t((function(t){var o=t.props,a=t.vm;return d().t,r.createElement("div",null,r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},r.createElement(g,e({},o,{vm:a})),r.createElement(f,e({},o,{vm:a})),r.createElement("div",null)," "),!!a.address.checkoutSettings&&a.address.checkoutSettings.phoneRequirement!==i.INVISIBLE&&r.createElement("div",{className:m.RowPB},r.createElement(I,e({},o,{vm:a})),r.createElement("div",null)," "))})),h=t((function(t){var i,o,a,n=t.props,s=t.vm,E=d().t,p=function(t){var i=t.map((function(t){return function(t){switch(t){case c.FIRSTNAME:return r.createElement(g,e({},n,{vm:s}));case c.LASTNAME:return r.createElement(f,e({},n,{vm:s}));case c.IDENTITY_NUMBER:return r.createElement(b,e({},n,{vm:s}));case c.ADDRESS_LINE_1:return r.createElement(y,e({},n,{vm:s}));case c.ADDRESS_LINE_2:return r.createElement(T,e({},n,{vm:s}));case c.POSTAL_CODE:return r.createElement(N,e({},n,{vm:s}));case c.COUNTRY:return r.createElement(L,e({},n,{vm:s}));case c.STATE:return r.createElement(k,e({},n,{vm:s}));case c.CITY:return s.address.isFreeTextCity?r.createElement(R,e({},n,{vm:s})):r.createElement(x,e({},n,{vm:s}));case c.DISTRICT:return s.address.isFreeTextDistrict?r.createElement(S,e({},n,{vm:s})):r.createElement(O,e({},n,{vm:s}));case c.REGION:return r.createElement(A,e({},n,{vm:s}));case c.PHONE:return r.createElement(I,e({},n,{vm:s}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},i),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},i,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},i,r.createElement("div",null)," "))},h=function(t){var i=t.map((function(t){return function(t){switch(t){case u.COMPANY:return r.createElement(V,e({},n,{vm:s}));case u.TAX_NUMBER:return r.createElement(j,e({},n,{vm:s}));case u.TAX_OFFICE:return r.createElement(F,e({},n,{vm:s}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},i),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},i,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},i,r.createElement("div",null)," "))};return r.createElement("div",null,s.allowTitleChange&&r.createElement("div",{className:m.RowPB},r.createElement(C,e({},n,{vm:s}))),s.countryOptions.length<=1?null===(i=s.address.addressFormatIgnoreCountry)||void 0===i?void 0:i.map((function(e){return p(e)})):null===(o=s.address.addressFormat)||void 0===o?void 0:o.map((function(e){return p(e)})),!!s.allowCorporateInfo&&r.createElement("div",{style:{marginTop:"12px"}},r.createElement(l,{value:s.isCorporate,label:E("checkout-page:corporateInvoice"),onChange:s.onCorporateChange})),!!s.isCorporate&&(null===(a=s.address.billingFormat)||void 0===a?void 0:a.map((function(e){return h(e)}))))})),g=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping given-name":"given-name",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.firstName;return r.createElement(o,{name:"firstName",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.firstName)||void 0===n?void 0:n.label)||c("checkout-page:firstName"),autocomplete:u,value:l.firstName||"",onChange:l.onFirstNameChange,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.firstName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.firstName":"checkout-page:firstNameError")})})),f=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping family-name":"family-name",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.lastName;return r.createElement(o,{name:"lastName",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.lastName)||void 0===n?void 0:n.label)||c("checkout-page:lastName"),autocomplete:u,value:l.lastName||"",onChange:l.onLastNameChange,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.lastName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.lastName":"checkout-page:lastNameError")})})),b=t((function(e){var t,i,n,s=e.vm,l=d().t;return r.createElement(o,{name:"identityNumber",type:a.TEXT,label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.identityNumber)||void 0===i?void 0:i.label)||l("checkout-page:identityNumber"),value:s.identityNumber||"",onChange:s.onIdentityNumberChange,hasError:s.isErrorsVisible&&(null===(n=s.address.validationResults)||void 0===n?void 0:n.identityNumber.hasError),errorText:l("checkout-page:identityNumberError")})})),C=t((function(e){var t=e.vm,i=d().t,n=t.address;return r.createElement(o,{type:a.TEXT,label:i("checkout-page:addressTitle"),value:n.title||"",onChange:t.onAddressTitleChange,hasError:t.isErrorsVisible&&!n.title,errorText:i("checkout-page:addressTitleError")})})),y=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping address-line1":"address-line1",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine1;return r.createElement(o,{name:"addressLine1",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.addressLine1)||void 0===n?void 0:n.label)||c("checkout-page:addressLine1"),autocomplete:u,value:l.address.addressLine1||"",onChange:l.onAddressLine1Change,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.addressLine1.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.addressLine1":"checkout-page:addressError")})})),T=t((function(e){var t,i,n,s=e.vm,l=d().t,c=s.isShippingAddress?"shipping address-line2":"address-line2",u=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine2;return r.createElement(o,{name:"addressLine2",type:a.TEXT,autocomplete:c,label:(null===(n=null===(i=s.address.fieldLabels)||void 0===i?void 0:i.addressLine2)||void 0===n?void 0:n.label)||l("checkout-page:addressLine2"),value:s.address.addressLine2||"",onChange:s.onAddressLine2Change,hasError:s.isErrorsVisible&&u,errorText:u?l("checkout-page:fieldRestrictionError.addressLine2"):void 0})})),N=t((function(e){var t,i,n,s=e.vm,l=d().t,c=s.isShippingAddress?"shipping postal-code":"postal-code";return r.createElement(o,{name:"postalCode",type:a.TEXT,label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.postalCode)||void 0===i?void 0:i.label)||l("checkout-page:postalCode"),autocomplete:c,value:s.address.postalCode||"",onChange:s.onAddressPostalCodeChange,hasError:s.isErrorsVisible&&(null===(n=s.address.validationResults)||void 0===n?void 0:n.postalCode.hasError),errorText:l("checkout-page:postalCodeError")})})),L=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return l.countryOptions.length<=1?null:r.createElement(o,{name:"country",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.country)||void 0===i?void 0:i.label)||c("checkout-page:country"),autocomplete:"country-name",value:(null===(n=l.country)||void 0===n?void 0:n.id)||"",onChange:l.onCountryChange,options:l.countryOptions,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.country.hasError),errorText:c("checkout-page:countryError")})})),k=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"state",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.state)||void 0===i?void 0:i.label)||c("checkout-page:state"),value:(null===(n=l.state)||void 0===n?void 0:n.id)||"",onChange:l.onStateChange,options:l.stateOptions,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.state.hasError),errorText:c("checkout-page:stateError")})})),x=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"city",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===i?void 0:i.label)||c("checkout-page:city"),autocomplete:"off",value:(null===(n=l.city)||void 0===n?void 0:n.id)||"",onChange:l.onCityChange,options:l.cityOptions,disabled:!l.cityOptions.length,isLoading:l.isLoadingCities,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.city.hasError),errorText:c("checkout-page:cityError")})})),R=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"city",type:a.TEXT,autocomplete:"address-level2",label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===i?void 0:i.label)||c("checkout-page:city"),value:(null===(n=l.city)||void 0===n?void 0:n.name)||"",hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.city.hasError),onChange:l.onCityInputChange,errorText:c("checkout-page:cityError")})})),O=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"district",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===i?void 0:i.label)||c("checkout-page:district"),autocomplete:"off",value:(null===(n=l.district)||void 0===n?void 0:n.id)||"",onChange:l.onDistrictChange,options:l.districtOptions,disabled:!l.districtOptions.length,isLoading:l.isLoadingDistricts,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.district.hasError),errorText:c("checkout-page:districtError")})})),S=t((function(e){var t,i,n,s=e.vm,l=d().t;return r.createElement(o,{name:"district",type:a.TEXT,autocomplete:"address-level3",label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===i?void 0:i.label)||l("checkout-page:district"),value:(null===(n=s.district)||void 0===n?void 0:n.name)||"",onChange:s.onDistrictInputChange})})),A=t((function(e){var t,i,n=e.vm,s=d().t;return r.createElement(o,{name:"region",type:a.SELECT,label:s("checkout-page:region"),autocomplete:"off",value:(null===(t=n.region)||void 0===t?void 0:t.id)||"",onChange:n.onRegionChange,options:n.regionOptions,hasError:n.isErrorsVisible&&(null===(i=n.address.validationResults)||void 0===i?void 0:i.region.hasError),errorText:s("checkout-page:regionError")})})),I=t((function(e){var t,i,s,l,c=e.vm,u=d().t,v=c.isShippingAddress?"shipping tel":"tel";return r.createElement(o,{name:"phone",type:a.TEL,inputMode:n.TEL,label:(null===(i=null===(t=c.address.fieldLabels)||void 0===t?void 0:t.phone)||void 0===i?void 0:i.label)||u("checkout-page:phone"),autocomplete:v,value:c.phone||"",onChange:c.onPhoneChange,hasError:c.isErrorsVisible&&(null===(s=c.address.validationResults)||void 0===s?void 0:s.phone.hasError),currentCountryCode:(null===(l=c.address.country)||void 0===l?void 0:l.iso2)||c.myCountryCode,errorText:u("checkout-page:phoneError")})})),V=t((function(e){var t,i,n,s=e.vm,l=d().t,c=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.companyName;return r.createElement(o,{name:"company",type:a.TEXT,label:(null===(n=null===(i=s.address.fieldLabels)||void 0===i?void 0:i.company)||void 0===n?void 0:n.label)||l("checkout-page:companyName"),value:s.address.company||"",onChange:s.onCompanyChange,hasError:s.isErrorsVisible&&c,errorText:c?l("checkout-page:fieldRestrictionError.companyName"):void 0})})),F=t((function(e){var t,i,n,s,l,c=e.vm,u=d().t,v=null===(t=c.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.taxOffice;return r.createElement(o,{name:"taxOffice",type:a.TEXT,label:(null===(n=null===(i=c.address.fieldLabels)||void 0===i?void 0:i.taxOffice)||void 0===n?void 0:n.label)||u("checkout-page:taxOffice"),value:(null===(s=c.address)||void 0===s?void 0:s.taxOffice)||"",onChange:c.onTaxOfficeChange,hasError:c.isErrorsVisible&&((null===(l=c.address.validationResults)||void 0===l?void 0:l.taxOffice.hasError)||v),errorText:u(v?"checkout-page:fieldRestrictionError.taxOffice":"checkout-page:taxOfficeError")})})),j=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"taxNumber",type:a.TEXT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.taxNumber)||void 0===i?void 0:i.label)||c("checkout-page:taxNumber"),value:(null===(n=l.address)||void 0===n?void 0:n.taxNumber)||"",onChange:l.onTaxNumberChange,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.taxNumber.hasError),errorText:c("checkout-page:taxNumberError")})}));export{E as AddressForm};
@@ -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{IkasCartCreatedBy as k,IkasCampaignCreatedFor as N,IkasGiftCardType as S}from"@ikas/storefront-models";import I from"../../../../hooks/useDimension.js";import M from"../svg/coupon-code-tag.js";import x from"../svg/gift-cart-tag.js";import T from"../svg/store-credit-tag.js";import j from"../svg/gift-loyalty.js";import b from"../svg/package-loyalty.js";import w from"../svg/percentage-loyalty.js";import O from"../svg/arrow-loyalty.js";import A from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as D,searchProducts as F,useLoyaltyPoints as R}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 U}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 H from"../svg/arrow-right-loyalty.js";var B;!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"}(B||(B={}));var G=i((function(e){var t,n,i,a,l,y,p,v,f,g,h,P,N=e.vm,S=e.allowExpand,M=e.isSuccessPageSummary,x=N.checkout,T=u().t,j=o.useState(!S),b=j[0],w=j[1],O=o.useState(!1),A=O[0],D=O[1],F=o.useState(null),R=F[0],_=F[1],V=o.useState(0),U=V[0],H=V[1],G=o.useState(null),Y=G[0],$=G[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(!1),oe=ne[0],ie=ne[1],ae=o.useState(!1),le=ae[0],se=ae[1],re=I().isMobile;o.useEffect((function(){S&&(b?Y&&H(Y.getBoundingClientRect().height):H(0))}),[b,Y,S,ee,oe,A,le]);var ce=o.useMemo((function(){switch(R){case B.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case B.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case B.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");default:return""}}),[R]),de=[C.CartSummary,S?C.HideOnDesktop:"",M?C.SuccessPageCartSummary:""].join(" "),ue=S?{height:U+"px"}:void 0,me=[C.ArrowDown,b?C.Rotated:""].join(" "),ye=!!(null===(t=N.loyaltySpendingMethods)||void 0===t?void 0:t.length)&&(null===(n=N.loyaltySpendingMethods)||void 0===n?void 0:n.length)>0&&!re&&!!(null===(i=N.customizationProps)||void 0===i?void 0:i.showLoyaltyPoints)&&!N.isOpenEditOrderWithTransaction&&!(N.checkout.createdBy===k.UPSELL||N.checkout.createdBy===k.ADMIN);return x?o.createElement(o.Fragment,null,!!S&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}w(!b)}},o.createElement("div",{className:C.Left},T("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(N.finalPrice||0,x.currencyCode,x.currencySymbol)," (").concat(x.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:me},o.createElement(E,null))))),o.createElement("div",{className:de},o.createElement("div",{className:[C.DetailsContainer,M?C.SuccessPageDetailContainer:""].join(" "),style:ue},o.createElement("div",{className:C.Details,ref:$},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,x.items.map((function(e,t){return o.createElement(m,{key:t,vm:N,cartItem:e,currencyCode:x.currencyCode,onChange:se,isSuccessPageSummary:M})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},A&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:ce,onClose:function(){D(!1),_(null)}})),o.createElement(X,{label:T("checkout-page:subtotal"),value:x.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(N.isCouponCodeVisible||(null===(a=N.checkout.giftCardLines)||void 0===a?void 0:a.length)||(null===(l=N.checkout.loyaltyLines)||void 0===l?void 0:l.length)||(null===(y=N.checkout.nonCouponAdjustments)||void 0===y?void 0:y.length))}),!!(null===(p=x.shippingLines)||void 0===p?void 0:p.length)&&(N.step===r.SUCCESS?o.createElement(X,{label:T("checkout-page:cartShippingTitle"),value:x.shippingTotal?x.formattedShippingTotal:T("checkout-page:free")}):x.shippingLines.map((function(e,t){return o.createElement(X,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,x.currencyCode,x.currencySymbol):T("checkout-page:free")})}))),o.createElement(W,{vm:N}),o.createElement(z,{vm:N}),(N.step===r.SUCCESS&&(!!N.checkout.note||!!N.checkout.appliedCouponCode)||N.step!==r.SUCCESS)&&N.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),ye&&o.createElement(K,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible,isMobile:re}),o.createElement(Q,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible}),o.createElement(q,{vm:N,isAddingCoupon:oe,setAddingCoupon:ie,setCouponError:D,setCouponErrorCode:_}),o.createElement(J,{vm:N,isAddingNote:ee,setAddingNote:te}),!!N.installmentExtraPrice&&N.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(X,{label:T("checkout-page:cartInterest"),value:d(N.installmentExtraPrice,x.currencyCode,x.currencySymbol)}))),N.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=N.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(X,{label:T("checkout-page:chargedAmount"),value:d((null===(f=N.openEditOrderTransaction)||void 0===f?void 0:f.chargedAmount)||0,x.currencyCode,x.currencySymbol)}),!!(null===(g=N.openEditOrderTransaction)||void 0===g?void 0:g.refundedAmount)&&o.createElement(X,{label:T("checkout-page:refundedAmount"),value:d((null===(h=N.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,x.currencyCode,x.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,M?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},N.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(N.finalPrice||0,x.currencyCode,x.currencySymbol)),!!x.$totalTax&&!!(null===(P=N.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+x.$formattedTotalTax)))),!!N.loyaltyEarningMethod&&!!N.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},T("checkout-page:loyaltyEarningMethodTitle",{value:(N.loyaltyEarningMethod.pointsEarned/(N.loyaltyEarningMethod.amountPerPointsEarned||1)*N.finalPrice).toFixed(2)}))),!M&&!N.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})),X=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))})),W=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!==N.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})),q=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(Y,{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(Y,{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($,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),Y=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)===S.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(T,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(M,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(x,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)))))})),$=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===D.FREE_PRODUCT?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===D.FREE_SHIPPING?{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(w,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(w,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!==D.FREE_PRODUCT&&m.type!==D.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)))))})),K=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===D.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===D.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(w,null)),e.type===D.FREE_SHIPPING&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(b,null)),e.type!==D.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(w,null)),e.type===D.FREE_PRODUCT&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(j,null)),e.type===D.RATIO&&(s="".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,")"),r=o.createElement(w,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!==D.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,T=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(O,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},I("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},T.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(j,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(O,null)))))})),Q=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],T=M[1],O=o.useState(!1),B=O[0],G=O[1],X=o.useState(!1),W=X[0],z=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(){T(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){z(!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===D.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,F({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 U({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 U({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===D.FIXED_AMOUNT&&e.isDynamic&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(w,null)),e.type===D.FREE_SHIPPING&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(b,null)),e.type!==D.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(w,null)),e.type===D.FREE_PRODUCT&&(i=Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(j,null)),e.type===D.RATIO&&(i="".concat(Ie("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,")"),a=o.createElement(w,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==D.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)===D.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,R({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:W?{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(A,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===D.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===D.FIXED_AMOUNT&&n.isDynamic?(ie(n),z(!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(j,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)||T(!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(A,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"))}())))}))))),(W&&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(A,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(H,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(w,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)})})))))))})),J=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{G as CartSummary,q as Coupon,B as CouponErrorCode,K 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 g from"../svg/cross.js";import f 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{IkasCartCreatedBy as k,IkasCampaignCreatedFor as N,IkasGiftCardType as S}from"@ikas/storefront-models";import I from"../../../../hooks/useDimension.js";import M from"../svg/coupon-code-tag.js";import x from"../svg/gift-cart-tag.js";import T from"../svg/store-credit-tag.js";import j from"../svg/gift-loyalty.js";import b from"../svg/package-loyalty.js";import w from"../svg/percentage-loyalty.js";import O from"../svg/arrow-loyalty.js";import A from"../svg/star-loyalty.js";import{LoyaltyProgramMethodSpendingTypeEnum as D,searchProducts as F,useLoyaltyPoints as R}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 U}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 H from"../svg/arrow-right-loyalty.js";var B;!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"}(B||(B={}));var G=i((function(e){var t,n,i,a,l,y,p,v,g,f,h,P,N=e.vm,S=e.allowExpand,M=e.isSuccessPageSummary,x=N.checkout,T=u().t,j=o.useState(!S),b=j[0],w=j[1],O=o.useState(!1),A=O[0],D=O[1],F=o.useState(null),R=F[0],_=F[1],V=o.useState(0),U=V[0],H=V[1],G=o.useState(null),Y=G[0],$=G[1],Z=o.useState(!1),ee=Z[0],te=Z[1],ne=o.useState(!1),oe=ne[0],ie=ne[1],ae=o.useState(!1),le=ae[0],se=ae[1],re=I().isMobile;o.useEffect((function(){S&&(b?Y&&H(Y.getBoundingClientRect().height):H(0))}),[b,Y,S,ee,oe,A,le]);var ce=o.useMemo((function(){switch(R){case B.COUPON_CODE_NOT_EXIST:return T("checkout-page:giftCodeErrorDescription");case B.COUPON_CODE_NOT_EXIST_FOR_GUESS:return T("checkout-page:mustBeSignInToApplyCampaign");case B.COUPON_APPLIED_WITHOUT_DISCOUNT:return T("checkout-page:couponInvalidForCartItems");default:return""}}),[R]),de=[C.CartSummary,S?C.HideOnDesktop:"",M?C.SuccessPageCartSummary:""].join(" "),ue=S?{height:U+"px"}:void 0,me=[C.ArrowDown,b?C.Rotated:""].join(" "),ye=!!(null===(t=N.loyaltySpendingMethods)||void 0===t?void 0:t.length)&&(null===(n=N.loyaltySpendingMethods)||void 0===n?void 0:n.length)>0&&!re&&!!(null===(i=N.customizationProps)||void 0===i?void 0:i.showLoyaltyPoints)&&!N.isOpenEditOrderWithTransaction&&!(N.checkout.createdBy===k.UPSELL||N.checkout.createdBy===k.ADMIN);return x?o.createElement(o.Fragment,null,!!S&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:C.ExpandHeader,onClick:function(){if(!b){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}w(!b)}},o.createElement("div",{className:C.Left},T("checkout-page:summary")),o.createElement("div",{className:C.Price},o.createElement("span",{className:C.PriceText},"".concat(d(N.finalPrice||0,x.currencyCode,x.currencySymbol)," (").concat(x.itemQuantity," ").concat(T("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:me},o.createElement(E,null))))),o.createElement("div",{className:de},o.createElement("div",{className:[C.DetailsContainer,M?C.SuccessPageDetailContainer:""].join(" "),style:ue},o.createElement("div",{className:C.Details,ref:$},o.createElement("div",{className:C.ItemsContainer},o.createElement("div",null,x.items.map((function(e,t){return o.createElement(m,{key:t,vm:N,cartItem:e,currencyCode:x.currencyCode,onChange:se,isSuccessPageSummary:M})})))),o.createElement("div",{className:C.Divider}),o.createElement("div",{className:C.SubTotalInfo},A&&o.createElement("div",{className:C.NotificationContainer},o.createElement(s,{type:"warning",title:T("checkout-page:giftCodeErrorTitle"),content:ce,onClose:function(){D(!1),_(null)}})),o.createElement(X,{label:T("checkout-page:subtotal"),value:x.formattedTotalPrice,tooltipText:T("checkout-page:subtotalTooltip"),hideMarginBottom:!(N.isCouponCodeVisible||(null===(a=N.checkout.giftCardLines)||void 0===a?void 0:a.length)||(null===(l=N.checkout.loyaltyLines)||void 0===l?void 0:l.length)||(null===(y=N.checkout.nonCouponAdjustments)||void 0===y?void 0:y.length))}),!!(null===(p=x.shippingLines)||void 0===p?void 0:p.length)&&(N.step===r.SUCCESS?o.createElement(X,{label:T("checkout-page:cartShippingTitle"),value:x.shippingTotal?x.formattedShippingTotal:T("checkout-page:free")}):x.shippingLines.map((function(e,t){return o.createElement(X,{key:t,label:e.paymentMethod?e.title:T("checkout-page:cartShippingTitle"),value:e.finalPrice?d(e.finalPrice,x.currencyCode,x.currencySymbol):T("checkout-page:free")})}))),o.createElement(W,{vm:N}),o.createElement(z,{vm:N}),(N.step===r.SUCCESS&&(!!N.checkout.note||!!N.checkout.appliedCouponCode)||N.step!==r.SUCCESS)&&N.isCouponCodeVisible&&o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),ye&&o.createElement(K,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible,isMobile:re}),o.createElement(Q,{vm:N,isVisibleLoyaltyPoints:N.isLoyaltyPointsVisible,setIsVisibleLoyaltyPoints:N.setIsLoyaltyPointsVisible}),o.createElement(q,{vm:N,isAddingCoupon:oe,setAddingCoupon:ie,setCouponError:D,setCouponErrorCode:_}),o.createElement(J,{vm:N,isAddingNote:ee,setAddingNote:te}),!!N.installmentExtraPrice&&N.installmentExtraPrice>0&&o.createElement(o.Fragment,null,o.createElement("div",{className:C.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(X,{label:T("checkout-page:cartInterest"),value:d(N.installmentExtraPrice,x.currencyCode,x.currencySymbol)}))),N.isOpenEditOrderWithTransaction&&o.createElement("div",{className:C.SubTotalInfo,style:{}},!!(null===(v=N.openEditOrderTransaction)||void 0===v?void 0:v.chargedAmount)&&o.createElement(X,{label:T("checkout-page:chargedAmount"),value:d((null===(g=N.openEditOrderTransaction)||void 0===g?void 0:g.chargedAmount)||0,x.currencyCode,x.currencySymbol)}),!!(null===(f=N.openEditOrderTransaction)||void 0===f?void 0:f.refundedAmount)&&o.createElement(X,{label:T("checkout-page:refundedAmount"),value:d((null===(h=N.openEditOrderTransaction)||void 0===h?void 0:h.refundedAmount)||0,x.currencyCode,x.currencySymbol)})),o.createElement("div",{className:[C.TotalContainer,M?C.SuccessPageTotalContainer:""].join(" ")},o.createElement("div",{className:C.TitleContainer},o.createElement("div",{className:C.Title},N.isOpenEditOrderWithTransaction?T("checkout-page:totalAmountPayable"):T("checkout-page:total"))),o.createElement("div",null,o.createElement("div",{className:C.TotalPricesContainer},o.createElement("div",{className:C.TotalPrice},d(N.finalPrice||0,x.currencyCode,x.currencySymbol)),!!x.$totalTax&&!!(null===(P=N.customizationProps)||void 0===P?void 0:P.showTax)&&o.createElement("div",{className:[C.TotalTax].join(" ")},T("checkout-page:cartTaxTitle")+" "+x.$formattedTotalTax)))),!!N.loyaltyEarningMethod&&!!N.loyaltyCustomerInfo&&o.createElement("div",{className:C.LoyaltyEarningMethod},o.createElement("div",{className:C.LoyaltyEarningMethodTitle},T("checkout-page:loyaltyEarningMethodTitle",{value:(N.loyaltyEarningMethod.pointsEarned/(N.loyaltyEarningMethod.amountPerPointsEarned||1)*N.finalPrice).toFixed(2)}))),!M&&!N.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})),X=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))})),W=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!==N.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(f,{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})),q=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,g=u().t,f=o.useState(""),L=f[0],k=f[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},g("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)}},g("checkout-page:addCouponCode")),a&&!m&&o.createElement("div",{style:{marginBottom:"10px"}},o.createElement(l,{value:L,placeholder:g("checkout-page:couponCode"),buttonLabel:g("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:g("checkout-page:addCouponCode"),type:p.TEXT,value:L,onChange:k}),o.createElement(P,{style:{width:"33%"},text:g("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(Y,{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(Y,{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($,{vm:i,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),Y=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)===S.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(T,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(M,null)):!y&&o.createElement("span",{style:{height:"16px"}},o.createElement(x,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(g,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)))))})),$=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===D.FREE_PRODUCT?{icon:o.createElement(j,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProductAdded")}:m.type===D.FREE_SHIPPING?{icon:o.createElement(b,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping")}:{icon:o.createElement(w,null),title:c("checkout-page:loyaltyPointsLinesModalContentItemTitleFixedAmount",{value:d((null==s?void 0:s.amount)||0,i.checkout.currencyCode,i.checkout.currencySymbol)})}:{icon:o.createElement(w,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(g,null)))),o.createElement("span",{className:C.LoyaltyPointSpending},"(",c("checkout-page:loyaltyPointSpending",{point:l.amount}),")")),m?m.type!==D.FREE_PRODUCT&&m.type!==D.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)))))})),K=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),g=E[0],f=E[1];o.useEffect((function(){var e=function(){return f(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===D.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===D.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(w,null)),e.type===D.FREE_SHIPPING&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),r=o.createElement(b,null)),e.type!==D.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(w,null)),e.type===D.FREE_PRODUCT&&(s=I("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),r=o.createElement(j,null)),e.type===D.RATIO&&(s="".concat(I("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(l=e.discountSettings)||void 0===l?void 0:l.discountAmount)||0,")"),r=o.createElement(w,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!==D.FREE_PRODUCT})))&&void 0!==l?l:[],x=g>1380||v?h&&h.length>0?2:3:g<1100?h&&h.length>0?0:1:h&&h.length>0?1:2,T=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(O,null))):o.createElement("div",{className:C.LoyaltyPointsContainer},o.createElement("div",{className:C.LoyaltyPointsTitle},I("checkout-page:loyaltyPointsTitle")),o.createElement("div",{className:C.LoyaltyPointsLines},T.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(j,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(O,null)))))})),Q=i((function(i){var a,l,s,r,m,y,p,v,E,f,h,L,k,N=i.vm,S=i.isVisibleLoyaltyPoints,I=i.setIsVisibleLoyaltyPoints,M=o.useState(!1),x=M[0],T=M[1],O=o.useState(!1),B=O[0],G=O[1],X=o.useState(!1),W=X[0],z=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(){T(!1),G(!1)}),180);return function(){return clearTimeout(e)}}}),[B]),o.useEffect((function(){if(Y){var e=setTimeout((function(){z(!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===D.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&&fe((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],ge=ve[1],fe=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,F({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)||[],ge(o.map((function(e){var t,n,o,i,a,l;return{id:e.id,name:e.name,mainImageSrc:new U({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 U({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===D.FIXED_AMOUNT&&e.isDynamic&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleDynamicAmount"),a=o.createElement(w,null)),e.type===D.FREE_SHIPPING&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeShipping"),a=o.createElement(b,null)),e.type!==D.FIXED_AMOUNT||e.isDynamic||(i=Me("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(w,null)),e.type===D.FREE_PRODUCT&&(i=Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct"),a=o.createElement(j,null)),e.type===D.RATIO&&(i="".concat(Me("checkout-page:loyaltyPointsLinesModalContentItemTitleRatio")," (%").concat((null===(n=e.discountSettings)||void 0===n?void 0:n.discountAmount)||0,")"),a=o.createElement(w,null)),{title:i,icon:a}},ke=null===(s=N.loyaltySpendingMethods)||void 0===s?void 0:s.filter((function(e){return e.type!==D.FREE_PRODUCT})),Ne=1===(null==ke?void 0:ke.length),Se=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)===D.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},Ie=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,R({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]}}))}))},Me=u().t;if(!S&&!Q)return null;var xe=[C.LoyaltyPointsLinesModalContainer,ee&&!Q&&C.LoyaltyPointsLinesModalContainerVisible,Q&&C.LoyaltyPointsLinesModalContainerClosing].filter(Boolean).join(" ");return o.createElement("div",{className:xe,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(g,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeader},o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderTitle},Me("checkout-page:loyaltyPointsLinesModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsLinesModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent,style:W?{maxHeight:"316px",height:"316px"}:{maxHeight:ye<748?ye-140+"px":650}},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(r=N.loyaltyCustomerInfo)||void 0===r?void 0:r.totalPoint)||0," ",Me("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||Ne&&0===i?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===D.FIXED_AMOUNT&&n.isDynamic?Me("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(Me("checkout-page:loyaltyPoint"))))),o.createElement("div",null,o.createElement("button",{type:"button",disabled:Se((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,Se(e,n)?[2]:n.type===D.FIXED_AMOUNT&&n.isDynamic?(ie(n),z(!0),[3,3]):[3,1];case 1:return[4,Ie(n.loyaltyProgramId,n.id)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("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(j,null)),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMain},o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainTitle},Me("checkout-page:loyaltyPointsLinesModalContentItemTitleFreeProduct")),o.createElement("span",{className:C.LoyaltyPointsLinesModalContentItemHeaderValueTextMainValue},Ce&&Le?"".concat(Ce," ~ ").concat(Le):""," ",Me("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)||T(!0)}},Me("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(g,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),Me("checkout-page:loyaltyPointsGiftModalTitle")),o.createElement("div",{className:C.LoyaltyPointsLinesModalHeaderDescription},Me("checkout-page:loyaltyPointsGiftModalDescription"))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContent},o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeader},o.createElement("span",null,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(m=N.loyaltyCustomerInfo)||void 0===m?void 0:m.totalPoint)||0," ",Me("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," ",Me("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," ",Me("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=Se(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,Ie(a.loyaltyProgramId,a.id)];case 1:return e.sent(),[2]}}))}))},className:C.LoyaltyPointsLinesModalContentItemButton},Me("checkout-page:loyaltyPointsLineItemButtonAddFree"))}())))}))))),(W&&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(g,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),Me("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},Me("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,Me("checkout-page:loyaltyPointsLinesModalCurrentPoints")," "),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemHeaderValue},o.createElement("div",{style:{width:"18px",height:"18px"}},o.createElement(A,null)),o.createElement("span",null,(null===(E=N.loyaltyCustomerInfo)||void 0===E?void 0:E.totalPoint)||0," ",Me("checkout-page:loyaltyPoint")))),o.createElement("div",{className:C.LoyaltyPointsLinesModalContentItemSlider},o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfo},o.createElement("span",null,le," ",Me("checkout-page:loyaltyPoint")),o.createElement(H,null),o.createElement("div",{className:C.LoyaltyPointsLinesModalSliderInfoValue},o.createElement(w,null),o.createElement("span",null,d(le/((null===(f=null==oe?void 0:oe.discountSettings)||void 0===f?void 0:f.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,Ie(oe.loyaltyProgramId,oe.id,le)];case 1:return e.sent(),[2]}}))}))},style:{width:"100%"},text:Me("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)})})))))))})),J=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{G as CartSummary,q as Coupon,B as CouponErrorCode,K as LoyaltyPointsLine};
@@ -105,7 +105,7 @@ export declare class IkasCustomerStore {
105
105
  createEmailSubscription: (email: string) => Promise<boolean>;
106
106
  saveCustomerFormData: (input: SaveCustomerFormDataInput) => Promise<boolean>;
107
107
  sendReview: (input: IkasCustomerReviewForm) => Promise<import("../../models/data").IkasCustomerReview | null | undefined>;
108
- deactivateCustomer: (password: string) => Promise<APIResponse<undefined> | APIResponse<boolean> | undefined>;
108
+ deactivateCustomer: (password?: string) => Promise<APIResponse<undefined> | APIResponse<boolean> | undefined>;
109
109
  exportCustomerPersonalData: () => Promise<APIResponse<undefined> | APIResponse<string> | undefined>;
110
110
  onCustomerConsentGrant: () => void;
111
111
  waitUntilInitialized: () => Promise<unknown>;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as c}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../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-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../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{IkasRaffleParticipant as u}from"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/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 d from"../raffle/index.js";import{APIResponse as l}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as w}from"@ikas/storefront-providers";import C from"../checkout/index.js";import{formatCurrency as b}from"../../utils/currency.js";var k="undefined"==typeof localStorage,S=function(){function S(i){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(s,i,o,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:s})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),i=p.getSalesChannelId(),o=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer({password:r})]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,w(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,C.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})),t?[4,C.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:s}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,C.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:b(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(S.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||k||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),S.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},S.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},S.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},S.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},S.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},S.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return k||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},S.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},S.prototype.setCustomer=function(t){this.customer=new a(t)},S.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},S.prototype.saveLastViewedProducts=function(){k||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},S.prototype.loadLastViewedProducts=function(){k||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},S.prototype.getLocalLastViewedProducts=function(){if(k)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},S.prototype.removeLastViewedProducts=function(){k||window.localStorage.removeItem("lastViewedProducts")},S.prototype.onProductView=function(r,s){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},S.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(k)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},S.prototype.saveCustomerConsent=function(){k||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},S.prototype.loadCustomerConsent=function(){k||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},S.prototype.removeCustomerConsent=function(){k||window.localStorage.removeItem("customerConsent")},S.prototype.setToken=function(t,e){k||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},S.prototype.loadToken=function(){if(!k){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},S.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},S.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},S.prototype.clearCaptchaToken=function(){this._captchaToken=null},S.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},S}();export{S as IkasCustomerStore};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as c}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../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-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../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{IkasRaffleParticipant as u}from"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/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 d from"../raffle/index.js";import{APIResponse as l}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as w}from"@ikas/storefront-providers";import C from"../checkout/index.js";import{formatCurrency as b}from"../../utils/currency.js";var k="undefined"==typeof localStorage,S=function(){function S(i){var a=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(s,i,o,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:s})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),i=p.getSalesChannelId(),o=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(s){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer(r({},s&&{password:s}))]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,w(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,C.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})),t?[4,C.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:s}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,C.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:b(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(S.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||k||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),S.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},S.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},S.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},S.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},S.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},S.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return k||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},S.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,n.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},S.prototype.setCustomer=function(t){this.customer=new a(t)},S.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},S.prototype.saveLastViewedProducts=function(){k||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},S.prototype.loadLastViewedProducts=function(){k||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},S.prototype.getLocalLastViewedProducts=function(){if(k)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},S.prototype.removeLastViewedProducts=function(){k||window.localStorage.removeItem("lastViewedProducts")},S.prototype.onProductView=function(r,s){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},S.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(k)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},S.prototype.saveCustomerConsent=function(){k||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},S.prototype.loadCustomerConsent=function(){k||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},S.prototype.removeCustomerConsent=function(){k||window.localStorage.removeItem("customerConsent")},S.prototype.setToken=function(t,e){k||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},S.prototype.loadToken=function(){if(!k){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},S.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},S.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},S.prototype.clearCaptchaToken=function(){this._captchaToken=null},S.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},S}();export{S as IkasCustomerStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.301",
3
+ "version": "6.1.0-beta.303",
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.301",
27
- "@ikas/storefront-config": "^6.1.0-beta.301",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.301",
29
- "@ikas/storefront-models": "^6.1.0-beta.301",
30
- "@ikas/storefront-providers": "^6.1.0-beta.301",
26
+ "@ikas/storefront-api": "^6.1.0-beta.303",
27
+ "@ikas/storefront-config": "^6.1.0-beta.303",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.303",
29
+ "@ikas/storefront-models": "^6.1.0-beta.303",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.303",
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.301",
66
- "@ikas/storefront-config": "^6.1.0-beta.301",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.301",
68
- "@ikas/storefront-models": "^6.1.0-beta.301",
69
- "@ikas/storefront-providers": "^6.1.0-beta.301",
65
+ "@ikas/storefront-api": "^6.1.0-beta.303",
66
+ "@ikas/storefront-config": "^6.1.0-beta.303",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.303",
68
+ "@ikas/storefront-models": "^6.1.0-beta.303",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.303",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",