@ikas/storefront 3.0.0-alpha.35 → 3.0.0-alpha.37

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*as e from"react";import{observer as s}from"mobx-react-lite";import t from"../../style.module.scss.js";import r from"../select-box/index.js";import{AddressForm as d}from"../address-form/index.js";import{Checkbox as o}from"../checkbox/index.js";import{FormItem as a}from"../form-item/index.js";import{FormItemType as i}from"../form-item/model.js";import n from"./style.module.scss.js";import l from"../../styles/common.module.scss.js";import{Button as c}from"../button/index.js";import{IkasStorefrontConfig as m}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as u}from"../../../../utils/i18n.js";import v from"../delivery-methods/index.js";import{CheckoutStep as p}from"../../model.js";var h=s((function(s){var d,o=s.vm,a=u().t,i=e.useMemo((function(){return e.createElement("div",null,e.createElement(g,{vm:o}),e.createElement(C,{vm:o}))}),[o]),h=e.useMemo((function(){return e.createElement("div",null,e.createElement(E,{vm:o}))}),[o]),k=e.useState("-1"),f=k[0],A=k[1];e.useEffect((function(){o.vm.checkout.stockLocationId&&A(o.vm.checkout.stockLocationId)}),[]);var y=function(e){if(!e.address)return"";var s=[];return e.address.address&&s.push(e.address.address),e.address.postalCode&&s.push(e.address.postalCode),e.address.district&&e.address.district.name&&s.push(e.address.district.name),e.address.city&&e.address.city.name&&s.push(e.address.city.name),e.address.state&&e.address.state.name&&"Default"!==e.address.state.name&&s.push(e.address.state.name),e.address.country&&e.address.country.name&&s.push(e.address.country.name),s.join(", ")};return e.createElement(e.Fragment,null,!!m.pickUpStockLocationIds&&o.vm.availableStockLocations.length>0&&o.vm.step!==p.PAYMENT&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},a("checkout-page:deliveryMethod"))),e.createElement(v,{deliveryMethod:o.vm.deliveryMethod,onClick:function(e){"address"===e&&A("-1"),o.vm.onDeliveryMethodChange(e)}})),e.createElement("div",{className:l.FormSectionTitle},"address"===o.vm.deliveryMethod?e.createElement("div",{className:l.Title},o.editingCustomerAddress?a("checkout-page:editAddress"):"billing"===o.addressType?a("checkout-page:billingAddress"):a("checkout-page:shippingAddress")):e.createElement("div",{className:l.Title},a("checkout-page:pickUpLocation"),e.createElement("span",{className:n.ErrorMessage},o.vm.isErrorsVisible&&!o.vm.checkout.stockLocationId&&a("checkout-page:errorPickupLocationRequired"))),!!o.editingCustomerAddress&&e.createElement("div",{className:n.CancelEdit,onClick:o.onCancelEditAddressClick},a("checkout-page:actions.cancel"))),!!o.vm.store.customerStore.customer&&!o.editingCustomerAddress&&"address"===o.vm.deliveryMethod&&e.createElement("div",{className:t.RowPB},null===(d=o.vm.store.customerStore.customer.addresses)||void 0===d?void 0:d.map((function(s){return e.createElement(r,{key:s.id,label:s.title||"",isSelected:s.id===o.selectedAddressId,rightContent:e.createElement("div",{onClick:function(){return o.onEditAddressClick(s)}},a("checkout-page:actions.edit")),bottomContent:e.createElement("div",{className:n.AddressText},s.addressText),bottomContentVisible:!0,hasError:!s.isValid,errorText:a("checkout-page:missingAddressFields"),onClick:function(){return s.id!==o.selectedAddressId&&o.onAddressSelect(s)}})})),e.createElement(r,{label:a("checkout-page:newAddress"),isSelected:"-1"===o.selectedAddressId,bottomContent:i,onClick:function(){return"-1"!==o.selectedAddressId&&o.onAddressSelect()}})),!o.vm.store.customerStore.customer&&"address"===o.vm.deliveryMethod&&i,"in-store"===o.vm.deliveryMethod&&e.createElement("div",{className:t.RowPB},o.vm.stockLocations.map((function(s){return function(e){return e.address&&e.address.address&&e.address.city&&e.address.country&&o.vm.availableStockLocations.find((function(s){return s.id===e.id}))}(s)&&e.createElement(r,{key:s.id,label:s.name||"",isSelected:f===s.id,bottomContent:e.createElement("div",null,e.createElement("div",{className:n.AddressText},y(s)),s.deliveryTime&&e.createElement("div",{className:n.DeliveryTime},a("checkout-page:stockLocation.deliveryTime.".concat(s.deliveryTime)))),bottomContentVisible:!0,onClick:function(){o.vm.onStockLocationChange(s),A(s.id)}})}))),"in-store"===o.vm.deliveryMethod&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},a("checkout-page:recipientsInfo"))),h),!!o.editingCustomerAddress&&e.createElement(g,{vm:o}),!!o.editingCustomerAddress&&e.createElement("div",{className:n.EditAddressActions},e.createElement(c,{style:{width:"100%"},text:a("checkout-page:deleteAddress"),isLine:!0,isLoading:o.isDeleteAddressLoading,isDisabled:o.isEditAddressLoading,onClick:o.onDeleteAddressClick}),e.createElement(c,{style:{width:"100%",marginTop:o.vm.store.customerStore.customer?"0px":"32px"},text:a("checkout-page:actions.save"),isLoading:o.isEditAddressLoading,isDisabled:o.isDeleteAddressLoading,onClick:o.onSaveAddressClick})))})),g=s((function(s){var t=s.vm;return e.createElement(d,{address:t.editingCustomerAddress||t.address,isErrorsVisible:t.isEditAddressErrorsVisible||t.vm.isErrorsVisible,allowedCountryIds:t.vm.shippingCountryIds||void 0,allowCorporateInfo:"billing"===t.addressType,firstNameChangeCallback:t.firstNameChangeCallback,lastNameChangeCallback:t.lastNameChangeCallback,allowTitleChange:!!t.editingCustomerAddress,deliveryMethod:"address"})})),E=s((function(s){var t=s.vm;return e.createElement(d,{address:t.editingCustomerAddress||t.address,isErrorsVisible:t.isEditAddressErrorsVisible||t.vm.isErrorsVisible,firstNameChangeCallback:t.firstNameChangeCallback,lastNameChangeCallback:t.lastNameChangeCallback,deliveryMethod:"in-store"})})),C=s((function(s){var t=s.vm,r=u().t;return t.vm.store.customerStore.customer&&"-1"===t.selectedAddressId?e.createElement("div",{style:{marginTop:"12px"}},e.createElement(o,{value:t.vm.shouldSaveAddress,label:r("checkout-page:saveAddressCta"),onChange:t.vm.setShouldSaveAddress}),t.vm.shouldSaveAddress&&e.createElement("div",{style:{marginTop:"8px"}},e.createElement(a,{type:i.TEXT,label:r("checkout-page:addressTitle"),value:t.vm.addressTitle,onChange:t.vm.setAddressTitle}))):null}));export{g as CustomerAddressForm,E as RecipientForm,C as SaveAddressCheckboxAndTitle,h as default};
1
+ import*as e from"react";import{observer as s}from"mobx-react-lite";import t from"../../style.module.scss.js";import r from"../select-box/index.js";import{AddressForm as d}from"../address-form/index.js";import{Checkbox as a}from"../checkbox/index.js";import{FormItem as i}from"../form-item/index.js";import{FormItemType as o}from"../form-item/model.js";import n from"./style.module.scss.js";import l from"../../styles/common.module.scss.js";import{Button as c}from"../button/index.js";import{IkasStorefrontConfig as m}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as u}from"../../../../utils/i18n.js";import v from"../delivery-methods/index.js";import{CheckoutStep as p}from"../../model.js";var h=s((function(s){var d,a=s.vm,i=u().t,o=e.useMemo((function(){return e.createElement("div",null,e.createElement(g,{vm:a}),e.createElement(k,{vm:a}))}),[a]),h=e.useMemo((function(){return e.createElement("div",null,e.createElement(E,{vm:a}))}),[a]),C=e.useState("-1"),f=C[0],A=C[1];e.useEffect((function(){a.vm.checkout.stockLocationId&&A(a.vm.checkout.stockLocationId)}),[]);var b=function(e){if(!e.address)return"";var s=[];return e.address.address&&s.push(e.address.address),e.address.postalCode&&s.push(e.address.postalCode),e.address.district&&e.address.district.name&&s.push(e.address.district.name),e.address.city&&e.address.city.name&&s.push(e.address.city.name),e.address.state&&e.address.state.name&&"Default"!==e.address.state.name&&s.push(e.address.state.name),e.address.country&&e.address.country.name&&s.push(e.address.country.name),s.join(", ")};return e.createElement(e.Fragment,null,!!m.pickUpStockLocationIds&&a.vm.availableStockLocations.length>0&&a.vm.step!==p.PAYMENT&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},i("checkout-page:deliveryMethod"))),e.createElement(v,{deliveryMethod:a.vm.deliveryMethod,onClick:function(e){"address"===e&&A("-1"),a.vm.onDeliveryMethodChange(e)}})),e.createElement("div",{className:l.FormSectionTitle},"address"===a.vm.deliveryMethod?e.createElement("div",{className:l.Title},a.editingCustomerAddress?i("checkout-page:editAddress"):"billing"===a.addressType?i("checkout-page:billingAddress"):i("checkout-page:shippingAddress")):a.vm.step===p.PAYMENT?e.createElement("div",{className:l.Title},i("checkout-page:billingAddress")):e.createElement("div",{className:l.Title},i("checkout-page:pickUpLocation"),e.createElement("span",{className:n.ErrorMessage},a.vm.isErrorsVisible&&!a.vm.checkout.stockLocationId&&i("checkout-page:errorPickupLocationRequired"))),!!a.editingCustomerAddress&&e.createElement("div",{className:n.CancelEdit,onClick:a.onCancelEditAddressClick},i("checkout-page:actions.cancel"))),!!a.vm.store.customerStore.customer&&!a.editingCustomerAddress&&"address"===a.vm.deliveryMethod&&e.createElement("div",{className:t.RowPB},null===(d=a.vm.store.customerStore.customer.addresses)||void 0===d?void 0:d.map((function(s){return e.createElement(r,{key:s.id,label:s.title||"",isSelected:s.id===a.selectedAddressId,rightContent:e.createElement("div",{onClick:function(){return a.onEditAddressClick(s)}},i("checkout-page:actions.edit")),bottomContent:e.createElement("div",{className:n.AddressText},s.addressText),bottomContentVisible:!0,hasError:!s.isValid,errorText:i("checkout-page:missingAddressFields"),onClick:function(){return s.id!==a.selectedAddressId&&a.onAddressSelect(s)}})})),e.createElement(r,{label:i("checkout-page:newAddress"),isSelected:"-1"===a.selectedAddressId,bottomContent:o,onClick:function(){return"-1"!==a.selectedAddressId&&a.onAddressSelect()}})),a.vm.store.customerStore.customer||a.vm.step!==p.INFO||"address"!==a.vm.deliveryMethod?a.vm.step===p.PAYMENT&&o:o,"in-store"===a.vm.deliveryMethod&&e.createElement("div",{className:t.RowPB},a.vm.stockLocations.map((function(s){return function(e){return e.address&&e.address.address&&e.address.city&&e.address.country&&a.vm.availableStockLocations.find((function(s){return s.id===e.id}))}(s)&&e.createElement(r,{key:s.id,label:s.name||"",isSelected:f===s.id,bottomContent:e.createElement("div",null,e.createElement("div",{className:n.AddressText},b(s)),s.deliveryTime&&e.createElement("div",{className:n.DeliveryTime},i("checkout-page:stockLocation.deliveryTime.".concat(s.deliveryTime)))),bottomContentVisible:!0,onClick:function(){a.vm.onStockLocationChange(s),A(s.id)}})}))),"in-store"===a.vm.deliveryMethod&&a.vm.step!==p.PAYMENT&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},i("checkout-page:recipientsInfo"))),h),!!a.editingCustomerAddress&&e.createElement(g,{vm:a}),!!a.editingCustomerAddress&&e.createElement("div",{className:n.EditAddressActions},e.createElement(c,{style:{width:"100%"},text:i("checkout-page:deleteAddress"),isLine:!0,isLoading:a.isDeleteAddressLoading,isDisabled:a.isEditAddressLoading,onClick:a.onDeleteAddressClick}),e.createElement(c,{style:{width:"100%",marginTop:a.vm.store.customerStore.customer?"0px":"32px"},text:i("checkout-page:actions.save"),isLoading:a.isEditAddressLoading,isDisabled:a.isDeleteAddressLoading,onClick:a.onSaveAddressClick})))})),g=s((function(s){var t=s.vm;return e.createElement(d,{address:t.editingCustomerAddress||t.address,isErrorsVisible:t.isEditAddressErrorsVisible||t.vm.isErrorsVisible,allowedCountryIds:t.vm.shippingCountryIds||void 0,allowCorporateInfo:"billing"===t.addressType,firstNameChangeCallback:t.firstNameChangeCallback,lastNameChangeCallback:t.lastNameChangeCallback,allowTitleChange:!!t.editingCustomerAddress,deliveryMethod:"address"})})),E=s((function(s){var t=s.vm;return e.createElement(d,{address:t.editingCustomerAddress||t.address,isErrorsVisible:t.isEditAddressErrorsVisible||t.vm.isErrorsVisible,firstNameChangeCallback:t.firstNameChangeCallback,lastNameChangeCallback:t.lastNameChangeCallback,deliveryMethod:"in-store"})})),k=s((function(s){var t=s.vm,r=u().t;return t.vm.store.customerStore.customer&&"-1"===t.selectedAddressId?e.createElement("div",{style:{marginTop:"12px"}},e.createElement(a,{value:t.vm.shouldSaveAddress,label:r("checkout-page:saveAddressCta"),onChange:t.vm.setShouldSaveAddress}),t.vm.shouldSaveAddress&&e.createElement("div",{style:{marginTop:"8px"}},e.createElement(i,{type:o.TEXT,label:r("checkout-page:addressTitle"),value:t.vm.addressTitle,onChange:t.vm.setAddressTitle}))):null}));export{g as CustomerAddressForm,E as RecipientForm,k as SaveAddressCheckboxAndTitle,h as default};
@@ -1 +1 @@
1
- import*as e from"react";import{runInAction as t}from"mobx";import{observer as n}from"mobx-react-lite";import o,{FormItemType as r}from"./model.js";import a from"./caret-down.js";import l from"./style.module.scss.js";import u from'../../../../ext/@ikas/react-phone-number-input/min/index.js';import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as i}from"../../../../utils/i18n.js";import c from'../../../../ext/react-tooltip/dist/index.es.js';var s=n((function(n){var a=i().t,s=e.useState((function(){return new o(n)})),d=s[0],E=s[1];return e.useEffect((function(){c.rebuild()}),[]),e.useEffect((function(){t((function(){d.type=n.type}))}),[n.type]),e.useEffect((function(){t((function(){d.inputType=n.inputType}))}),[n.inputType]),e.useEffect((function(){t((function(){d.value=n.value}))}),[n.value]),e.useEffect((function(){t((function(){d.options=n.options}))}),[n.options]),e.useEffect((function(){t((function(){d.label=n.label}))}),[n.label]),e.useEffect((function(){t((function(){d.hasError=n.hasError}))}),[n.hasError]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){d.textAreaPlaceholder=n.textAreaPlaceholder}))}),[n.textAreaPlaceholder]),e.useEffect((function(){t((function(){d.rightContent=n.rightContent}))}),[n.rightContent]),e.useEffect((function(){t((function(){d.disableResize=n.disableResize}))}),[n.disableResize]),e.useEffect((function(){t((function(){E(new o(n))}))}),[n.onChange]),e.useEffect((function(){!d.country&&n.currentCountryCode&&d.onCountryChange(n.currentCountryCode)}),[n.currentCountryCode]),e.createElement("div",{className:d.formItemStyle,style:n.style},e.createElement("div",{className:l.FormItemWrapper},e.createElement("div",{className:l.FormItemInputWrapper},e.createElement("label",{className:d.labelStyle},d.label),d.type===r.TEXT&&e.createElement(m,{vm:d,autocomplete:n.autocomplete,name:n.name}),d.type===r.TEL&&e.createElement(u,{key:n.currentCountryCode||"1",defaultCountry:n.currentCountryCode,placeholder:a("checkout-page:enterPhoneNumber"),value:d.value?d.value:"",onChange:d.onPhoneChange,international:!0,addInternationalOption:!1}),d.type===r.TEXT_AREA&&e.createElement(f,{vm:d}),d.type===r.SELECT&&e.createElement(p,{vm:d,autocomplete:n.autocomplete})),!!d.hasError&&e.createElement("div",{className:l.ErrorMsg},d.errorText||""),!!n.tooltipText&&e.createElement("div",{className:l.FormItemTooltipContainer,"data-tip":n.tooltipText,"data-event":"touchstart focus mouseover","data-event-off":"mouseout"},"?"),!!d.rightContent&&e.createElement("div",{className:l.RightContent},d.rightContent)))})),m=n((function(t){var n=t.vm,o=t.name,r=t.autocomplete,a=t.type;return e.createElement("input",{type:a||"text",name:o,autoComplete:r,inputMode:n.inputType||"text",className:n.inputStyle,value:n.value,onChange:n.onValueChange})})),f=n((function(t){var n=t.vm;return e.createElement("textarea",{style:{resize:n.disableResize?"none":"initial"},value:n.value,onChange:n.onTextAreaValueChange,placeholder:n.textAreaPlaceholder||""})})),p=n((function(t){var n,o=t.vm,r=t.autocomplete;return e.createElement(e.Fragment,null,e.createElement("select",{className:o.inputStyle,autoComplete:r,onChange:o.onSelectChange},!o.value&&e.createElement("option",{selected:!0,disabled:!0,key:-1}),null===(n=o.options)||void 0===n?void 0:n.map((function(t,n){return e.createElement("option",{key:n+t.value,value:t.label,selected:o.value===t.value},t.label)}))),e.createElement("div",{className:l.ArrowContainer},e.createElement(a,null)))}));export{s as FormItem};
1
+ import*as e from"react";import{runInAction as t}from"mobx";import{observer as n}from"mobx-react-lite";import o,{FormItemType as r}from"./model.js";import a from"./caret-down.js";import l from"./style.module.scss.js";import u from'../../../../ext/@ikas/react-phone-number-input/min/index.js';import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as i}from"../../../../utils/i18n.js";import s from'../../../../ext/react-tooltip/dist/index.es.js';var c=n((function(n){var a=i().t,c=e.useState((function(){return new o(n)})),p=c[0],E=c[1];return e.useEffect((function(){s.rebuild()}),[]),e.useEffect((function(){t((function(){p.type=n.type}))}),[n.type]),e.useEffect((function(){t((function(){p.inputType=n.inputType}))}),[n.inputType]),e.useEffect((function(){t((function(){p.value=n.value}))}),[n.value]),e.useEffect((function(){t((function(){p.options=n.options}))}),[n.options]),e.useEffect((function(){t((function(){p.label=n.label}))}),[n.label]),e.useEffect((function(){t((function(){p.hasError=n.hasError}))}),[n.hasError]),e.useEffect((function(){t((function(){p.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){p.errorText=n.errorText}))}),[n.errorText]),e.useEffect((function(){t((function(){p.textAreaPlaceholder=n.textAreaPlaceholder}))}),[n.textAreaPlaceholder]),e.useEffect((function(){t((function(){p.rightContent=n.rightContent}))}),[n.rightContent]),e.useEffect((function(){t((function(){p.disableResize=n.disableResize}))}),[n.disableResize]),e.useEffect((function(){t((function(){E(new o(n))}))}),[n.onChange]),e.useEffect((function(){!p.country&&n.currentCountryCode&&p.onCountryChange(n.currentCountryCode)}),[n.currentCountryCode]),e.createElement("div",{className:p.formItemStyle,style:n.style},e.createElement("div",{className:l.FormItemWrapper},e.createElement("div",{className:l.FormItemInputWrapper},e.createElement("label",{className:p.labelStyle},p.label),p.type===r.TEXT&&e.createElement(m,{vm:p,disabled:p.disabled,autocomplete:n.autocomplete,name:n.name}),p.type===r.TEL&&e.createElement(u,{key:n.currentCountryCode||"1",disabled:p.disabled,defaultCountry:n.currentCountryCode,placeholder:a("checkout-page:enterPhoneNumber"),value:p.value?p.value:"",onChange:p.onPhoneChange,international:!0,addInternationalOption:!1}),p.type===r.TEXT_AREA&&e.createElement(d,{vm:p}),p.type===r.SELECT&&e.createElement(f,{vm:p,autocomplete:n.autocomplete})),!!p.hasError&&e.createElement("div",{className:l.ErrorMsg},p.errorText||""),!!n.tooltipText&&e.createElement("div",{className:l.FormItemTooltipContainer,"data-tip":n.tooltipText,"data-event":"touchstart focus mouseover","data-event-off":"mouseout"},"?"),!!p.rightContent&&e.createElement("div",{className:l.RightContent},p.rightContent)))})),m=n((function(t){var n=t.vm,o=t.name,r=t.autocomplete,a=t.type,l=t.disabled;return e.createElement("input",{type:a||"text",name:o,disabled:l,autoComplete:r,inputMode:n.inputType||"text",className:n.inputStyle,value:n.value,onChange:n.onValueChange})})),d=n((function(t){var n=t.vm;return e.createElement("textarea",{style:{resize:n.disableResize?"none":"initial"},value:n.value,disabled:n.disabled,onChange:n.onTextAreaValueChange,placeholder:n.textAreaPlaceholder||""})})),f=n((function(t){var n,o=t.vm,r=t.autocomplete;return e.createElement(e.Fragment,null,e.createElement("select",{className:o.inputStyle,disabled:o.disabled,autoComplete:r,onChange:o.onSelectChange},!o.value&&e.createElement("option",{selected:!0,disabled:!0,key:-1}),null===(n=o.options)||void 0===n?void 0:n.map((function(t,n){return e.createElement("option",{key:n+t.value,value:t.label,selected:o.value===t.value},t.label)}))),e.createElement("div",{className:l.ArrowContainer},e.createElement(a,null)))}));export{c as FormItem};
@@ -12,6 +12,7 @@ export default class FormItemViewModel implements Props {
12
12
  textAreaPlaceholder?: string | null;
13
13
  rightContent?: React.ReactElement | null;
14
14
  disableResize?: boolean;
15
+ disabled: boolean;
15
16
  onChange: (value: string) => void;
16
17
  constructor(props: Props);
17
18
  get formItemStyle(): string;
@@ -40,6 +41,7 @@ export interface Props {
40
41
  textAreaPlaceholder?: string | null;
41
42
  rightContent?: React.ReactElement | null;
42
43
  disableResize?: boolean;
44
+ disabled?: boolean;
43
45
  onChange: (value: string) => void;
44
46
  }
45
47
  export declare enum FormItemType {
@@ -1 +1 @@
1
- import{makeAutoObservable as t}from"mobx";import e from"./style.module.scss.js";var n,o,i=function(){function o(e){var n=this;this.country=null,this.textAreaPlaceholder=null,this.onValueChange=function(t){n.onChange(t.target.value)},this.onTextAreaValueChange=function(t){n.onChange(t.target.value)},this.onSelectChange=function(t){var e,o=null===(e=n.options)||void 0===e?void 0:e.find((function(e){return e.label===t.target.value}));o&&n.onChange(o.value)},this.onPhoneChange=function(t){n.onChange(t)},this.onCountryChange=function(t){n.country=t},this.type=e.type,this.inputType=e.inputType,this.options=e.options,this.label=e.label,this.value=e.value,this.hasError=e.hasError,this.errorText=e.errorText,this.tooltipText=e.tooltipText,this.country=e.country||null,this.textAreaPlaceholder=e.textAreaPlaceholder||null,this.rightContent=e.rightContent||null,this.disableResize=e.disableResize||!1,this.onChange=e.onChange,t(this)}return Object.defineProperty(o.prototype,"formItemStyle",{get:function(){var t=[e.FormItem];return this.type===n.TEL&&this.hasError&&t.push(e.PhoneError),t.join(" ")},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"labelStyle",{get:function(){return this.value||this.type===n.TEL?[e.FieldLabel,e.FieldLabelTop].join(" "):[e.FieldLabel].join(" ")},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"inputStyle",{get:function(){var t=[];return this.value&&t.push(e.Bottom),this.hasError&&t.push(e.Error),this.tooltipText&&t.push(e.WithTooltip),this.type===n.TEL&&t.push(e.Tel),t.join(" ")},enumerable:!1,configurable:!0}),o}();!function(t){t[t.TEXT=0]="TEXT",t[t.TEXT_AREA=1]="TEXT_AREA",t[t.SELECT=2]="SELECT",t[t.TEL=3]="TEL"}(n||(n={})),function(t){t.NUMERIC="numeric",t.TEL="tel",t.EMAIL="email"}(o||(o={}));export{o as FormItemInputType,n as FormItemType,i as default};
1
+ import{makeAutoObservable as e}from"mobx";import t from"./style.module.scss.js";var i,n,o=function(){function n(t){var i=this;this.country=null,this.textAreaPlaceholder=null,this.onValueChange=function(e){i.disabled||i.onChange(e.target.value)},this.onTextAreaValueChange=function(e){i.disabled||i.onChange(e.target.value)},this.onSelectChange=function(e){var t;if(!i.disabled){var n=null===(t=i.options)||void 0===t?void 0:t.find((function(t){return t.label===e.target.value}));n&&i.onChange(n.value)}},this.onPhoneChange=function(e){i.disabled||i.onChange(e)},this.onCountryChange=function(e){i.disabled||(i.country=e)},this.type=t.type,this.inputType=t.inputType,this.options=t.options,this.label=t.label,this.value=t.value,this.hasError=t.hasError,this.errorText=t.errorText,this.tooltipText=t.tooltipText,this.country=t.country||null,this.textAreaPlaceholder=t.textAreaPlaceholder||null,this.rightContent=t.rightContent||null,this.disableResize=t.disableResize||!1,this.disabled=t.disabled||!1,this.onChange=t.onChange,e(this)}return Object.defineProperty(n.prototype,"formItemStyle",{get:function(){var e=[t.FormItem];return this.type===i.TEL&&this.hasError&&e.push(t.PhoneError),e.join(" ")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"labelStyle",{get:function(){return this.value||this.type===i.TEL?[t.FieldLabel,t.FieldLabelTop].join(" "):[t.FieldLabel].join(" ")},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"inputStyle",{get:function(){var e=[];return this.value&&e.push(t.Bottom),this.hasError&&e.push(t.Error),this.tooltipText&&e.push(t.WithTooltip),this.type===i.TEL&&e.push(t.Tel),this.disabled&&e.push(t.Disabled),e.join(" ")},enumerable:!1,configurable:!0}),n}();!function(e){e[e.TEXT=0]="TEXT",e[e.TEXT_AREA=1]="TEXT_AREA",e[e.SELECT=2]="SELECT",e[e.TEL=3]="TEL"}(i||(i={})),function(e){e.NUMERIC="numeric",e.TEL="tel",e.EMAIL="email"}(n||(n={}));export{n as FormItemInputType,i as FormItemType,o as default};
@@ -1 +1 @@
1
- import e from"react";import{observer as a}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{createTranslationInputData as t,useTranslation as r}from"../../../../utils/i18n.js";import{Checkbox as s}from"../checkbox/index.js";import{FormItem as n}from"../form-item/index.js";import{FormItemType as m}from"../form-item/model.js";import{Button as i}from"../button/index.js";import c from"./svg/master-pass-by-master-card.js";import d from"../../style.module.scss.js";import l from"./style.module.scss.js";var u=a((function(a){var u=a.vm,p=r().t,C=o.translations["checkout-page"],v=e.useMemo((function(){var e,a;return t(null===(a=null===(e=null==C?void 0:C.masterPass)||void 0===e?void 0:e.creditCardForm)||void 0===a?void 0:a.checkboxLabel)}),[C]),f=e.useMemo((function(){return e.createElement("div",{className:l.CheckboxLabel},v.map((function(a,o){return a.isVariable?e.createElement("span",{key:o,className:l.Logo},e.createElement(c,null)):e.createElement(e.Fragment,{key:o},a.value)})))}),[v]);return e.createElement("div",null,e.createElement(s,{label:f,value:u.mpVM.saveCardToMasterPass.isCheckboxChecked,onChange:u.mpVM.onSaveCardToMasterPassCheckedChange}),u.mpVM.saveCardToMasterPass.isCheckboxChecked&&e.createElement("div",{className:l.FormWrapper},e.createElement("div",{className:d.RowPB},e.createElement(n,{name:"masterPassCardName",type:m.TEXT,label:p("checkout-page:masterPass.creditCardForm.cardName"),value:u.mpVM.saveCardToMasterPass.cardName,onChange:u.mpVM.onSaveCardToMasterPassCardNameChange})),e.createElement("div",{className:d.RowPB},e.createElement(n,{name:"masterPassPhoneNumber",type:m.TEL,label:p("checkout-page:masterPass.creditCardForm.phoneNumber"),value:u.mpVM.saveCardToMasterPass.phoneNumber,onChange:u.mpVM.onSaveCardToMasterPassPhoneNumberChange})),e.createElement(i,{style:{width:"100%"},text:p("checkout-page:masterPass.creditCardForm.button"),isDisabled:u.mpVM.isSendConfirmationButtonDisabled,isLoading:u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending,onClick:function(){var e;if(!u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending&&(console.log("onSendConfirmationButtonClick 1"),u.checkout.selectedPaymentGateway&&(console.log("onSendConfirmationButtonClick 2"),u.cardData&&u.cardData.cardNumber&&u.cardData.expirationDate&&u.cardData.cvv&&(console.log("onSendConfirmationButtonClick 3"),u.mpVM.saveCardToMasterPass.cardName&&(console.log("onSendConfirmationButtonClick 4"),u.mpVM.saveCardToMasterPass.phoneNumber))))){var a,o,t,r,s={creditCard:{rtaPan:u.cardData.cardNumber.replace(/ /g,""),expiryDate:(a=u.cardData.expirationDate,o=a.replace(" / ",""),t=o.substring(0,2),r=o.substring(2,4),"".concat(r).concat(t)),cvc:u.cardData.cvv,accountAliasName:u.mpVM.saveCardToMasterPass.cardName,phoneNumber:null===(e=u.mpVM.saveCardToMasterPass.phoneNumber)||void 0===e?void 0:e.replace("+","")},store:u.store,checkout:u.checkout,paymentGateway:u.checkout.selectedPaymentGateway,callback:function(){u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!1}};console.log("onSendConfirmationButtonClick 5",s),u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!0,u.mpVM.onSaveCardToMasterPassSendConfirmationButtonClick(s)}}})))}));export{u as default};
1
+ import e from"react";import{observer as a}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{createTranslationInputData as t,useTranslation as s}from"../../../../utils/i18n.js";import{Checkbox as r}from"../checkbox/index.js";import{FormItem as n}from"../form-item/index.js";import{FormItemType as m}from"../form-item/model.js";import{Button as i}from"../button/index.js";import d from"./svg/master-pass-by-master-card.js";import c from"../../style.module.scss.js";import l from"./style.module.scss.js";var u=a((function(a){var u=a.vm,p=s().t,C=o.translations["checkout-page"],v=e.useMemo((function(){var e,a;return t(null===(a=null===(e=null==C?void 0:C.masterPass)||void 0===e?void 0:e.creditCardForm)||void 0===a?void 0:a.checkboxLabel)}),[C]),M=e.useMemo((function(){return e.createElement("div",{className:l.CheckboxLabel},v.map((function(a,o){return a.isVariable?e.createElement("span",{key:o,className:l.Logo},e.createElement(d,null)):e.createElement(e.Fragment,{key:o},a.value)})))}),[v]),P=u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?u.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({store:u.store,checkout:u.checkout}):u.mpVM.saveCardToMasterPass.phoneNumber;return e.createElement("div",null,e.createElement(r,{label:M,value:u.mpVM.saveCardToMasterPass.isCheckboxChecked,onChange:u.mpVM.onSaveCardToMasterPassCheckedChange}),u.mpVM.saveCardToMasterPass.isCheckboxChecked&&e.createElement("div",{className:l.FormWrapper},e.createElement("div",{className:c.RowPB},e.createElement(n,{name:"masterPassCardName",type:m.TEXT,label:p("checkout-page:masterPass.creditCardForm.cardName"),value:u.mpVM.saveCardToMasterPass.cardName,onChange:u.mpVM.onSaveCardToMasterPassCardNameChange})),u.mpVM.isSaveCardToMasterPassPhoneNumberInputVisible&&e.createElement("div",{className:c.RowPB},e.createElement(n,{name:"masterPassPhoneNumber",type:m.TEL,disabled:u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled,label:p("checkout-page:masterPass.creditCardForm.phoneNumber"),value:P,onChange:u.mpVM.onSaveCardToMasterPassPhoneNumberChange})),e.createElement(i,{style:{width:"100%"},text:p("checkout-page:masterPass.creditCardForm.button"),isDisabled:u.mpVM.isSendConfirmationButtonDisabled,isLoading:u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending,onClick:function(){var e;if(!u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending&&(console.log("onSendConfirmationButtonClick 1"),u.checkout.selectedPaymentGateway&&(console.log("onSendConfirmationButtonClick 2"),u.cardData&&u.cardData.cardNumber&&u.cardData.expirationDate&&u.cardData.cvv&&(console.log("onSendConfirmationButtonClick 3"),u.mpVM.saveCardToMasterPass.cardName&&(console.log("onSendConfirmationButtonClick 4"),u.mpVM.saveCardToMasterPass.phoneNumber))))){var a,o,t,s,r={creditCard:{rtaPan:u.cardData.cardNumber.replace(/ /g,""),expiryDate:(a=u.cardData.expirationDate,o=a.replace(" / ",""),t=o.substring(0,2),s=o.substring(2,4),"".concat(s).concat(t)),cvc:u.cardData.cvv,accountAliasName:u.mpVM.saveCardToMasterPass.cardName,phoneNumber:null===(e=u.mpVM.saveCardToMasterPass.phoneNumber)||void 0===e?void 0:e.replace("+","")},store:u.store,checkout:u.checkout,paymentGateway:u.checkout.selectedPaymentGateway,callback:function(){u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!1}};console.log("onSendConfirmationButtonClick 5",r),u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!0,u.mpVM.onSaveCardToMasterPassSendConfirmationButtonClick(r)}}})))}));export{u as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as d}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import c from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as u}from"../../models/data/checkout-settings/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import p from"../../models/data/checkout/index.js";import m from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import f from"../../store/checkout/index.js";import{CheckStocksLineInput as g}from"../../__api/models/CheckStocksLineInput.js";import y from"../../store/cart/api.js";import{SaveCartInput as S}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as k,PaymentGatewayTypeEnum as b,TransactionStatusEnum as I}from"../../__api/types/index.js";import C from"./modelMasterPass.js";import P from'../../ext/uuid/dist/esm-node/v4.js';var A,j,w=/^\d+$/,N="undefined"==typeof localStorage,R=function(){function w(w,R,T,O,D,M,G,_,L){var U=this;this.checkout=new p,this.checkoutSettings=new u,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=A.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=A.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===A.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(A.INFO)];if(this.step!==A.PAYMENT||this.canProceedToPayment){if(![A.INFO,A.SUCCESS,A.SHIPPING,A.PAYMENT].includes(this.step))return[2,this.changeStep(A.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(A.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:j.PAYMENT_ERROR,data:n||null}),this.step!==A.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==A.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=A.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==A.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==A.PAYMENT&&this.step!==A.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===A.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(A.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,h.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,m.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(U,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new S(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return[4,y.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:j.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:j.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(U,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),t.billingAddress=null,[2,t]}))}))},this.checkStocks=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.checkStocks({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:j.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,d=s;a<d.length;a++)c=d[a],r(c);throw{type:j.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,f.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:j.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.getAvailableStockLocations({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:j.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=U.shippingCountryIds)||void 0===t?void 0:t.length)||(U.error={type:j.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(U.checkout.stockLocationId=null),U.deliveryMethod=t,U.isErrorsVisible=!1},this.initialStockCheck=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,o,a,d,c,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,f.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(c=s.data)||void 0===c?void 0:c.length)?(n=s.data,this.step===A.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===A.PAYMENT&&(console.log("2",{paymentGateways:n}),(d=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=d,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:j.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,f.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;U.store.customerStore.customer?(null===(t=U.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=U.checkoutSettings})),U.checkout.customer=new d(U.store.customerStore.customer)):U.checkout.customer||(U.checkout.customer=new d({}))},this.createShippingAddress=function(){var t;if(U.checkout.shippingAddress)U.selectedShippingAddressId=U.checkout.shippingAddress.id||"-1",U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings;else{var e=null===(t=U.store.customerStore.customer)||void 0===t?void 0:t.addresses;U.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(U.useDifferentAddress=!!localStorage.getItem("sAddr"),U.useDifferentAddress?(U.checkout.billingAddress&&(U.selectedBillingAddressId=U.checkout.billingAddress.id||"-1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):U.checkout.billingAddress=new a(n(U.checkout.shippingAddress)||{}),U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onShippingMethodChange=function(i){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(U,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,y.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===A.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(U.selectedShippingAddressId=t,"-1"===t)U.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.shippingAddress=new a(s))}U.checkout.shippingAddress&&(U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(U.selectedBillingAddressId=t,"-1"===t)U.checkout.billingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.billingAddress=new a(s))}U.checkout.billingAddress&&(U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){U.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(U.cardData&&(!(t.length>U.cardData.cardNumber.length)||E(t))){var e=(U.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!U.installmentInfo?U.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:U.checkout.selectedPaymentGateway.id,price:U.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(U.cardData.installmentCount=1,U.installmentInfo=void 0),U.cardData.cardNumber=x(i,4).join(" "))}},this.onCardHolderNameChange=function(t){U.cardData&&(U.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(U.cardData&&(!(t.length>U.cardData.expirationDate.length)||E(t))){if(0===(null===(e=U.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(U.cardData.expirationDate=x(a,2).join(" / "))}},this.onCvcChange=function(t){U.cardData&&(t.length>U.cardData.cvv.length&&!E(t)||t.length>4||(U.cardData.cvv=t))},this.saveAddress=function(s){return t(U,void 0,void 0,(function(){var t,r,a,d,c;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:P()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return d=e.sent(),console.error(d),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){U.router.push("/cart")},this.onBackToShoppingClick=function(){U.router.push("/")},this.onProceedToShippingClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(A.SHIPPING):this.changeStep(A.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(A.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:j.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,l,u,h,p,m,v;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(d=this.mpVM.selectedCard)||void 0===d?void 0:d.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(c=this.cardData)||void 0===c?void 0:c.installmentCount)?[2]:[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name},paymentGatewayId:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===k.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===b.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[I.SUCCESS,I.AUTHORIZED].includes(r),a=r===I.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.returnSlug))throw{type:j.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(A.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){U.changeStep(A.INFO)},this.onBackToShippingClick=function(){U.changeStep(A.SHIPPING)},this.setCustomerConsentGranted=function(t){U.checkout.customer&&(U.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){U.useDifferentAddress=t,U.useDifferentAddress?(localStorage.setItem("sAddr","1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),U.checkout.billingAddress=U.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){U.shouldSaveAddress=t},this.setAddressTitle=function(t){U.addressTitle=t},this.setPaymentGateway=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,f.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==A.SUCCESS&&(t.paymentMethodType===k.CREDIT_CARD&&t.type===b.INTERNAL&&(this.cardData=new c),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){U.cardData&&(U.cardData.installmentCount=t)},this.changeStep=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return N||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){U.isContactModalVisible=t},this.checkout=w,this.checkoutSettings=R,this.router=O,this.returnPolicy=D,this.privacyPolicy=M,this.termsOfService=G,this.t=_,this.customizationProps=L,this.mpVM=new C,T&&(this.merchantSettings=T),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(w.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"finalPrice",{get:function(){return this.step===A.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===j.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==j.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s="in-store"===this.deliveryMethod,n=!!s||!!this.canProceedToShipping,r=!!s||!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),o=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===k.CREDIT_CARD&&i.type===b.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return n&&r&&o},enumerable:!1,configurable:!0}),w}();function x(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function E(t){return t&&w.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(A||(A={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(j||(j={}));export{A as CheckoutStep,j as ErrorType,R as default};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as d}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import c from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as u}from"../../models/data/checkout-settings/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import p from"../../models/data/checkout/index.js";import m from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import f from"../../store/checkout/index.js";import{CheckStocksLineInput as g}from"../../__api/models/CheckStocksLineInput.js";import y from"../../store/cart/api.js";import{SaveCartInput as S}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as k,PaymentGatewayTypeEnum as b,TransactionStatusEnum as I}from"../../__api/types/index.js";import C from"./modelMasterPass.js";import P from'../../ext/uuid/dist/esm-node/v4.js';var A,w,j=/^\d+$/,N="undefined"==typeof localStorage,R=function(){function j(j,R,T,D,O,M,G,_,L){var U=this;this.checkout=new p,this.checkoutSettings=new u,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=A.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,d;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=A.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===A.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(A.INFO)];if(this.step!==A.PAYMENT||this.canProceedToPayment){if(![A.INFO,A.SUCCESS,A.SHIPPING,A.PAYMENT].includes(this.step))return[2,this.changeStep(A.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(A.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:w.PAYMENT_ERROR,data:n||null}),this.step!==A.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==A.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=A.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==A.SHIPPING||(null===(d=this.checkout.availableShippingMethods)||void 0===d?void 0:d.length)?this.step!==A.PAYMENT&&this.step!==A.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:w.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:w.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===A.PAYMENT&&this.isInStoreDelivery&&(this.checkout.billingAddress=new a),this.step===A.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(A.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,h.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,m.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(U,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new S(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return[4,y.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:w.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:w.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(U,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.checkStocks({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.stockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:w.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,d=s;a<d.length;a++)c=d[a],r(c);throw{type:w.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,f.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:w.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.getAvailableStockLocations({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:w.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=U.shippingCountryIds)||void 0===t?void 0:t.length)||(U.error={type:w.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(U.checkout.stockLocationId=null),U.deliveryMethod=t,U.isErrorsVisible=!1},this.initialStockCheck=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:w.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,o,a,d,c,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,f.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(c=s.data)||void 0===c?void 0:c.length)?(n=s.data,this.step===A.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===A.PAYMENT&&(console.log("2",{paymentGateways:n}),(d=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=d,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:w.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,f.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;U.store.customerStore.customer?(null===(t=U.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=U.checkoutSettings})),U.checkout.customer=new d(U.store.customerStore.customer)):U.checkout.customer||(U.checkout.customer=new d({}))},this.createShippingAddress=function(){var t;if(U.checkout.shippingAddress)U.selectedShippingAddressId=U.checkout.shippingAddress.id||"-1",U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings;else{var e=null===(t=U.store.customerStore.customer)||void 0===t?void 0:t.addresses;U.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(U.useDifferentAddress=!!localStorage.getItem("sAddr"),U.useDifferentAddress?(U.checkout.billingAddress&&(U.selectedBillingAddressId=U.checkout.billingAddress.id||"-1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):U.isInStoreDelivery?U.checkout.billingAddress=new a(n(U.checkout.billingAddress)||{}):U.checkout.billingAddress=new a(n(U.checkout.shippingAddress)||{}),U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onShippingMethodChange=function(i){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(U,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,y.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===A.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(U.selectedShippingAddressId=t,"-1"===t)U.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.shippingAddress=new a(s))}U.checkout.shippingAddress&&(U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(U.selectedBillingAddressId=t,"-1"===t)U.checkout.billingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.billingAddress=new a(s))}U.checkout.billingAddress&&(U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){U.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(U.cardData&&(!(t.length>U.cardData.cardNumber.length)||E(t))){var e=(U.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!U.installmentInfo?U.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:U.checkout.selectedPaymentGateway.id,price:U.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(U.cardData.installmentCount=1,U.installmentInfo=void 0),U.cardData.cardNumber=x(i,4).join(" "))}},this.onCardHolderNameChange=function(t){U.cardData&&(U.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(U.cardData&&(!(t.length>U.cardData.expirationDate.length)||E(t))){if(0===(null===(e=U.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(U.cardData.expirationDate=x(a,2).join(" / "))}},this.onCvcChange=function(t){U.cardData&&(t.length>U.cardData.cvv.length&&!E(t)||t.length>4||(U.cardData.cvv=t))},this.saveAddress=function(s){return t(U,void 0,void 0,(function(){var t,r,a,d,c;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:P()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return d=e.sent(),console.error(d),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){U.router.push("/cart")},this.onBackToShoppingClick=function(){U.router.push("/")},this.onProceedToShippingClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(A.SHIPPING):this.changeStep(A.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:w.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(A.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:w.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:w.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,l,u,h,p,m,v;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(d=this.mpVM.selectedCard)||void 0===d?void 0:d.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(c=this.cardData)||void 0===c?void 0:c.installmentCount)?[2]:[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name},paymentGatewayId:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===k.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===b.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[I.SUCCESS,I.AUTHORIZED].includes(r),a=r===I.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.returnSlug))throw{type:w.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(A.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){U.changeStep(A.INFO)},this.onBackToShippingClick=function(){U.changeStep(A.SHIPPING)},this.setCustomerConsentGranted=function(t){U.checkout.customer&&(U.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){U.useDifferentAddress=t,U.useDifferentAddress?(localStorage.setItem("sAddr","1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),U.checkout.billingAddress=U.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){U.shouldSaveAddress=t},this.setAddressTitle=function(t){U.addressTitle=t},this.setPaymentGateway=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,f.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==A.SUCCESS&&(t.paymentMethodType===k.CREDIT_CARD&&t.type===b.INTERNAL&&(this.cardData=new c),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){U.cardData&&(U.cardData.installmentCount=t)},this.changeStep=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return N||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){U.isContactModalVisible=t},this.checkout=j,this.checkoutSettings=R,this.router=D,this.returnPolicy=O,this.privacyPolicy=M,this.termsOfService=G,this.t=_,this.customizationProps=L,this.mpVM=new C,T&&(this.merchantSettings=T),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(j.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPrice",{get:function(){return this.step===A.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===w.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==w.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===k.CREDIT_CARD&&i.type===b.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),j}();function x(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function E(t){return t&&j.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(A||(A={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(w||(w={}));export{A as CheckoutStep,w as ErrorType,R as default};
@@ -64,7 +64,16 @@ export default class MasterPassModel {
64
64
  cards: Card[];
65
65
  selectedCard?: Card;
66
66
  constructor();
67
- get isSendConfirmationButtonDisabled(): boolean;
67
+ get isSaveCardToMasterPassPhoneNumberInputVisible(): boolean;
68
+ get isSaveCardToMasterPassPhoneNumberInputDisabled(): boolean;
69
+ /**
70
+ * Use when phone number input disabled
71
+ */
72
+ saveCardToMasterPassPhoneNumberDisabledInputValue: ({ store, checkout, }: {
73
+ store: IkasBaseStore;
74
+ checkout: IkasCheckout;
75
+ }) => string;
76
+ get isSendConfirmationButtonDisabled(): boolean | undefined;
68
77
  onSaveCardToMasterPassCheckedChange: (value: boolean) => void;
69
78
  onSaveCardToMasterPassCardNameChange: (value: string) => void;
70
79
  onSaveCardToMasterPassPhoneNumberChange: (value: string) => void;
@@ -90,9 +99,10 @@ export default class MasterPassModel {
90
99
  operationType: MasterPassOperationTypeEnum;
91
100
  phoneNumber: string;
92
101
  }) => Promise<import("src/__api/types").MasterPassTokenResponse | undefined>;
93
- phoneNumber: ({ store, checkout, }: {
102
+ phoneNumber: ({ store, checkout, withPlus, }: {
94
103
  store: IkasBaseStore;
95
104
  checkout: IkasCheckout;
105
+ withPlus?: boolean | undefined;
96
106
  }) => string | null | undefined;
97
107
  sendSmsLanguage: (store: IkasBaseStore) => string;
98
108
  /**
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__rest as s}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import n from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";import{useTranslation as i}from"../../utils/i18n.js";var c="undefined"==typeof localStorage,d=/000000[0|1]{10}/g,l=/[0|1]1100[0|1]{11}/g,u=/[0|1]11100[0|1]{10}/g,p=function(){function p(){var p=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.onSaveCardToMasterPassCheckedChange=function(e){p.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){p.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){p.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var t=e.creditCard,s=e.store,o=e.checkout,a=e.paymentGateway,n=e.callback;console.log("onSaveCardToMasterPassSendConfirmationButtonClick 1"),p.register({creditCard:t,store:s,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){p.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){p.visibleModal=void 0},this.showOtpModal=function(e){p.otpResponse.text="",p.otpResponse.status="",p.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",p.visibleModal)},this.hideOtpModal=function(){p.visibleModal=void 0,p.otpResponse.text="",p.otpResponse.status="",p.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){p.visibleModal=void 0,p.mfsResponseModalText=""},this.onSuccessModalClose=function(){p.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){p.linkCardToClient(e)},this.onOtpFormSubmit=function(e){p.otpResponse.text="",p.otpResponse.status="",p.validateTransaction(e)},this.MFS=function(){var e;if(!c){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId))return window.MFS;console.error("MFS can not use.")}},this.getToken=function(s){var o=s.cartId,a=s.paymentGatewayId,r=s.operationType,i=s.phoneNumber;return e(p,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,n({cartId:o,paymentGatewayId:a,operationType:r,phoneNumber:i})];case 1:return(e=t.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var t,s,o=e.store,a=e.checkout,n=(null===(t=o.customerStore.customer)||void 0===t?void 0:t.phone)||(null===(s=a.shippingAddress)||void 0===s?void 0:s.phone);return n&&n.includes("+")&&(n=n.replace("+","")),n},this.sendSmsLanguage=function(e){var t,s="eng";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===a.getCurrentLocale()}));o&&o.iso3&&(s=null===(t=o.iso3)||void 0===t?void 0:t.toLowerCase())}return s},this.clearSaveCardToMasterPassForm=function(){p.saveCardToMasterPass.isCheckboxChecked=!1,p.saveCardToMasterPass.phoneNumber="",p.saveCardToMasterPass.cardName="",p.saveCardToMasterPass.isSendConfirmationButtonPending=!1},this.mfsResponseHandler=function(e){return function(t,s){console.log({field:"mfsResponseHandler",response:s}),e.callback&&e.callback();var o=function(e){var t;return null===(t=null==s?void 0:s.accountStatus)||void 0===t?void 0:t.match(e)};if(o(d)&&(p.checkMasterPassData.status="noMasterPassAccount"),o(l)&&(p.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",p.showLinkCardToClientModal()),o(u)&&(p.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(p.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!s.responseDescription||(p.otpResponse.text=s.responseDescription,"1409"===s.responseCode&&(p.otpResponse.status="error")),"0000"!=s.responseCode&&""!=s.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&p.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===p.checkMasterPassData.status?p.visibleModal="linkCardToClientModalSuccess":p.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,p.clearSaveCardToMasterPassForm(),p.listCards({store:e.store,checkout:e.checkout}))),"5196"===s.responseCode&&s.responseDescription&&(p.visibleModal="mfsResponseModal",p.mfsResponseModalText=s.responseDescription),"5001"==s.responseCode||"5008"==s.responseCode){var a="5001"===s.responseCode?"bankOtp":"masterPassOtp";p.showOtpModal(a)}if("5010"==s.responseCode&&"undefined"!=typeof window)return console.log('response.responseCode == "5010"'),void window.location.assign(s.url3D+"&returnUrl="+window.location.href);console.log({source:"MFS response.responseDescription",responseDescription:s.responseDescription,response:s})}},this.showTokenErrorWithModal=function(){var e=i().t;p.visibleModal="mfsResponseModal",p.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(p,void 0,void 0,(function(){var e,a,n,i,c,d,l=o.checkout,u=o.store;return s(o,["checkout","store"]),t(this,(function(t){switch(t.label){case 0:return console.log("checkMasterPass 1"),(e=this.MFS())?(a=this.phoneNumber({store:u,checkout:l}),console.log("checkMasterPass 2"),n=l.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:l.id,paymentGatewayId:n.id,operationType:r.CHECK_MASTER_PASS_USER,phoneNumber:a})]):[2]):[2];case 1:return(i=t.sent())?(e.setClientId(n.masterPassClientId),c=this.sendSmsLanguage(u),d=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(d,this.mfsResponseHandler({source:"checkMasterPass",checkout:l,store:u})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(s){var o=s.creditCard,a=s.store,n=s.checkout,i=s.paymentGateway,c=s.callback;return e(p,void 0,void 0,(function(){var e,s,d,l;return t(this,(function(t){switch(t.label){case 0:return console.log("register 1"),(e=this.MFS())?(console.log("register 2"),(s=o.phoneNumber)&&i.masterPassClientId?(console.log("register 3"),[4,this.getToken({cartId:n.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:s})]):[2]):[2];case 1:return d=t.sent(),console.log("register 4"),(null==d?void 0:d.token)?(l=this.prepareFormData({msisdn:s,token:null==d?void 0:d.token,referenceNo:d.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:d.timeZone,sendSms:"Y",actionType:"A",clientIp:"",delinkReason:"",eActionType:"A",cardTypeFlag:"05",cpinFlag:"Y",defaultAccount:"Y",mmrpConfig:"110010",identityVerificationFlag:"Y",mobileAccountConfig:"MWA",uiChannelType:"6"}),console.log("reigster 5"),e.setClientId(i.masterPassClientId),e.register(l,this.mfsResponseHandler({source:"register",store:a,checkout:n,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(s){var o=s.store,a=s.checkout,n=s.callback;return e(p,void 0,void 0,(function(){var e,s,r;return t(this,(function(t){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(s=e.getLastToken(),r=this.sendSmsLanguage(o),e.resendOtp(s,r,this.mfsResponseHandler({source:"resendOtp",store:o,checkout:a,callback:n})),[2]):[2]}))}))},this.linkCardToClient=function(s){var o=s.store,a=s.checkout,n=s.callback;return e(p,void 0,void 0,(function(){var e,s,i,c,d;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:o,checkout:a}))&&(null==(i=a.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:a.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(c=t.sent())?(d=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:s}),e.linkCardToClient(d,this.mfsResponseHandler({source:"linkCardToClient",store:o,checkout:a,callback:n})),[2]):(n&&n(),[2])}}))}))},this.validateTransaction=function(s){var o=s.validationCode,a=s.store,n=s.cartId,i=s.paymentGateway,c=s.checkout,d=s.callback;return e(p,void 0,void 0,(function(){var e,s,l,u;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:a,checkout:c}))?[4,this.getToken({cartId:n,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(l=t.sent())?(u=this.prepareFormData({pinType:"otp",validationCode:o,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:l.token,referenceNo:l.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(u,this.mfsResponseHandler({source:"validateTransaction",store:a,checkout:c,callback:d})),[2]):[2]}}))}))},this.listCards=function(s){var o=s.store,a=s.checkout;return e(p,void 0,void 0,(function(){var e,s,n,i,c,d,l=this;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:o,checkout:a}))?(n=null===(d=a.masterPassPaymentGateway)||void 0===d?void 0:d.id,console.log("listCards paymentGatewayId",n),n?[4,this.getToken({cartId:a.id,paymentGatewayId:n,operationType:r.LIST_CARDS,phoneNumber:s})]:[2]):[2];case 1:return(i=t.sent())?(c=function(e,t){if("0000"!=t.responseCode&&""!=t.responseCode)return l.visibleModal="mfsResponseModal",l.mfsResponseModalText=t.responseDescription,console.error("mfs response.responseDescription",t.responseDescription),void console.log("TransactionID->",t.transactionId);var s=[];if(Array.isArray(t.cards))for(var o=0;o<t.cards.length;o++){var a=t.cards[o];a.paymentGatewayId=n,s.push(a)}l.cards=s,console.log("list_card response->",t),console.log("Cards",s),console.log("TransactionID->",t.transactionId)},e.listCards(s,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(s){var o=s.store,a=s.checkout,n=s.card;return e(p,void 0,void 0,(function(){var e,s,i,c;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:o,checkout:a}))?[4,this.getToken({cartId:a.id,paymentGatewayId:n.paymentGatewayId,operationType:r.DELETE_CARD,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:s,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),accountAliasName:n.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:o,checkout:a})),[2]):[2]}}))}))},o(this)}return Object.defineProperty(p.prototype,"isSendConfirmationButtonDisabled",{get:function(){return!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),p.prototype.prepareFormData=function(e){var t=new FormData;return Object.entries(e).forEach((function(e){var s=e[0],o=e[1];return t.append(s,o)})),t},p}();export{p as default};
1
+ import{__awaiter as e,__generator as s,__rest as t}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import n from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";import{useTranslation as i}from"../../utils/i18n.js";var c="undefined"==typeof localStorage,u=/000000[0|1]{10}/g,l=/[0|1]1100[0|1]{11}/g,d=/[0|1]11100[0|1]{10}/g,p=function(){function p(){var p=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.saveCardToMasterPassPhoneNumberDisabledInputValue=function(e){var s=e.store,t=e.checkout;return p.phoneNumber({store:s,checkout:t,withPlus:!0})||""},this.onSaveCardToMasterPassCheckedChange=function(e){p.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){p.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){p.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var s=e.creditCard,t=e.store,o=e.checkout,a=e.paymentGateway,n=e.callback;console.log("onSaveCardToMasterPassSendConfirmationButtonClick 1"),p.register({creditCard:s,store:t,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){p.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){p.visibleModal=void 0},this.showOtpModal=function(e){p.otpResponse.text="",p.otpResponse.status="",p.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",p.visibleModal)},this.hideOtpModal=function(){p.visibleModal=void 0,p.otpResponse.text="",p.otpResponse.status="",p.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){p.visibleModal=void 0,p.mfsResponseModalText=""},this.onSuccessModalClose=function(){p.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){p.linkCardToClient(e)},this.onOtpFormSubmit=function(e){p.otpResponse.text="",p.otpResponse.status="",p.validateTransaction(e)},this.MFS=function(){var e;if(!c){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId))return window.MFS;console.error("MFS can not use.")}},this.getToken=function(t){var o=t.cartId,a=t.paymentGatewayId,r=t.operationType,i=t.phoneNumber;return e(p,void 0,void 0,(function(){var e;return s(this,(function(s){switch(s.label){case 0:return[4,n({cartId:o,paymentGatewayId:a,operationType:r,phoneNumber:i})];case 1:return(e=s.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var s,t,o=e.store,a=e.checkout,n=e.withPlus,r=void 0!==n&&n,i=(null===(s=o.customerStore.customer)||void 0===s?void 0:s.phone)||(null===(t=a.shippingAddress)||void 0===t?void 0:t.phone);return i&&i.includes("+")&&!r&&(i=i.replace("+","")),i},this.sendSmsLanguage=function(e){var s,t="eng";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===a.getCurrentLocale()}));o&&o.iso3&&(t=null===(s=o.iso3)||void 0===s?void 0:s.toLowerCase())}return t},this.clearSaveCardToMasterPassForm=function(){p.saveCardToMasterPass.isCheckboxChecked=!1,p.saveCardToMasterPass.phoneNumber="",p.saveCardToMasterPass.cardName="",p.saveCardToMasterPass.isSendConfirmationButtonPending=!1},this.mfsResponseHandler=function(e){return function(s,t){console.log({field:"mfsResponseHandler",response:t}),e.callback&&e.callback();var o,a=function(e){var s;return null===(s=null==t?void 0:t.accountStatus)||void 0===s?void 0:s.match(e)};a(u)&&(p.checkMasterPassData.status="noMasterPassAccount",(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));a(l)&&(p.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",p.showLinkCardToClientModal(),(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));if(a(d)&&(p.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(p.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!t.responseDescription||(p.otpResponse.text=t.responseDescription,"1409"===t.responseCode&&(p.otpResponse.status="error")),"0000"!=t.responseCode&&""!=t.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&p.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===p.checkMasterPassData.status?p.visibleModal="linkCardToClientModalSuccess":p.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,p.clearSaveCardToMasterPassForm(),p.listCards({store:e.store,checkout:e.checkout}))),"5196"===t.responseCode&&t.responseDescription&&(p.visibleModal="mfsResponseModal",p.mfsResponseModalText=t.responseDescription),"5001"==t.responseCode||"5008"==t.responseCode){var n="5001"===t.responseCode?"bankOtp":"masterPassOtp";p.showOtpModal(n)}if("5010"==t.responseCode&&"undefined"!=typeof window)return console.log('response.responseCode == "5010"'),void window.location.assign(t.url3D+"&returnUrl="+window.location.href);console.log({source:"MFS response.responseDescription",responseDescription:t.responseDescription,response:t})}},this.showTokenErrorWithModal=function(){var e=i().t;p.visibleModal="mfsResponseModal",p.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(p,void 0,void 0,(function(){var e,a,n,i,c,u,l=o.checkout,d=o.store;return t(o,["checkout","store"]),s(this,(function(s){switch(s.label){case 0:return console.log("checkMasterPass 1"),(e=this.MFS())?(a=this.phoneNumber({store:d,checkout:l}),console.log("checkMasterPass 2"),n=l.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:l.id,paymentGatewayId:n.id,operationType:r.CHECK_MASTER_PASS_USER,phoneNumber:a})]):[2]):[2];case 1:return(i=s.sent())?(e.setClientId(n.masterPassClientId),c=this.sendSmsLanguage(d),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:l,store:d})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(t){var o=t.creditCard,a=t.store,n=t.checkout,i=t.paymentGateway,c=t.callback;return e(p,void 0,void 0,(function(){var e,t,u,l;return s(this,(function(s){switch(s.label){case 0:return console.log("register 1"),(e=this.MFS())?(console.log("register 2"),(t=o.phoneNumber)&&i.masterPassClientId?(console.log("register 3"),[4,this.getToken({cartId:n.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]):[2]):[2];case 1:return u=s.sent(),console.log("register 4"),(null==u?void 0:u.token)?(l=this.prepareFormData({msisdn:t,token:null==u?void 0:u.token,referenceNo:u.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:u.timeZone,sendSms:"Y",actionType:"A",clientIp:"",delinkReason:"",eActionType:"A",cardTypeFlag:"05",cpinFlag:"Y",defaultAccount:"Y",mmrpConfig:"110010",identityVerificationFlag:"Y",mobileAccountConfig:"MWA",uiChannelType:"6"}),console.log("reigster 5"),e.setClientId(i.masterPassClientId),e.register(l,this.mfsResponseHandler({source:"register",store:a,checkout:n,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,r;return s(this,(function(s){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(t=e.getLastToken(),r=this.sendSmsLanguage(o),e.resendOtp(t,r,this.mfsResponseHandler({source:"resendOtp",store:o,checkout:a,callback:n})),[2]):[2]}))}))},this.linkCardToClient=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,i,c,u;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&((t=this.phoneNumber({store:o,checkout:a}))&&(null==(i=a.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:a.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(c=s.sent())?(u=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:t}),e.linkCardToClient(u,this.mfsResponseHandler({source:"linkCardToClient",store:o,checkout:a,callback:n})),[2]):(n&&n(),[2])}}))}))},this.validateTransaction=function(t){var o=t.validationCode,a=t.store,n=t.cartId,i=t.paymentGateway,c=t.checkout,u=t.callback;return e(p,void 0,void 0,(function(){var e,t,l,d;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:a,checkout:c}))?[4,this.getToken({cartId:n,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(l=s.sent())?(d=this.prepareFormData({pinType:"otp",validationCode:o,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:l.token,referenceNo:l.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(d,this.mfsResponseHandler({source:"validateTransaction",store:a,checkout:c,callback:u})),[2]):[2]}}))}))},this.listCards=function(t){var o=t.store,a=t.checkout;return e(p,void 0,void 0,(function(){var e,t,n,i,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?(n=null===(u=a.masterPassPaymentGateway)||void 0===u?void 0:u.id,console.log("listCards paymentGatewayId",n),n?[4,this.getToken({cartId:a.id,paymentGatewayId:n,operationType:r.LIST_CARDS,phoneNumber:t})]:[2]):[2];case 1:return(i=s.sent())?(c=function(e,s){if("0000"!=s.responseCode&&""!=s.responseCode)return l.visibleModal="mfsResponseModal",l.mfsResponseModalText=s.responseDescription,console.error("mfs response.responseDescription",s.responseDescription),void console.log("TransactionID->",s.transactionId);var t=[];if(Array.isArray(s.cards))for(var o=0;o<s.cards.length;o++){var a=s.cards[o];a.paymentGatewayId=n,t.push(a)}l.cards=t,console.log("list_card response->",s),console.log("Cards",t),console.log("TransactionID->",s.transactionId)},e.listCards(t,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(t){var o=t.store,a=t.checkout,n=t.card;return e(p,void 0,void 0,(function(){var e,t,i,c;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?[4,this.getToken({cartId:a.id,paymentGatewayId:n.paymentGatewayId,operationType:r.DELETE_CARD,phoneNumber:t})]:[2];case 1:return(i=s.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:t,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),accountAliasName:n.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:o,checkout:a})),[2]):[2]}}))}))},o(this)}return Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputVisible",{get:function(){return("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||this.checkMasterPassData.status,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputDisabled",{get:function(){return!("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)||("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||"noMasterPassAccount"===this.checkMasterPassData.status)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSendConfirmationButtonDisabled",{get:function(){if(this)return!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),p.prototype.prepareFormData=function(e){var s=new FormData;return Object.entries(e).forEach((function(e){var t=e[0],o=e[1];return s.append(t,o)})),s},p}();export{p as default};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as r}from"mobx-react-lite";import{Checkbox as s}from"../../../components/checkbox/index.js";import o from"../../../components/customer-addresses/model.js";import t from"../../../components/customer-addresses/index.js";import"../../../../../storefront/index.js";import'../../../../../ext/lodash/isArguments.js';import'../../../../../ext/lodash/isBuffer.js';import'../../../../../ext/lodash/isTypedArray.js';import'../../../../../ext/lodash/_baseGetTag.js';import{useTranslation as n}from"../../../../../utils/i18n.js";var i=r((function(r){var i=r.vm,m=n().t,d=e.useMemo((function(){return new o(i,"billing")}),[i]);return e.createElement(e.Fragment,null,e.createElement("div",{style:{marginTop:"32px",marginBottom:i.useDifferentAddress?"24px":"0px"}},"address"===i.deliveryMethod&&e.createElement(s,{value:!i.useDifferentAddress,hasError:i.isErrorsVisible&&!i.isTermsAndConditionsChecked,label:m("checkout-page:useShippingForBilling"),onChange:function(e){return i.setUseDifferentAddress(!e)}})),i.useDifferentAddress&&e.createElement(t,{vm:d}))}));export{i as BillingAddress};
1
+ import*as e from"react";import{observer as r}from"mobx-react-lite";import{Checkbox as s}from"../../../components/checkbox/index.js";import o from"../../../components/customer-addresses/model.js";import t from"../../../components/customer-addresses/index.js";import"../../../../../storefront/index.js";import'../../../../../ext/lodash/isArguments.js';import'../../../../../ext/lodash/isBuffer.js';import'../../../../../ext/lodash/isTypedArray.js';import'../../../../../ext/lodash/_baseGetTag.js';import{useTranslation as n}from"../../../../../utils/i18n.js";var i=r((function(r){var i=r.vm,d=n().t,m=e.useMemo((function(){return new o(i,"billing")}),[i]);return e.useEffect((function(){"in-store"===i.deliveryMethod&&i.setUseDifferentAddress(!0)}),[i]),e.createElement(e.Fragment,null,e.createElement("div",{style:{marginTop:"32px",marginBottom:i.useDifferentAddress?"24px":"0px"}},"address"===i.deliveryMethod&&e.createElement(s,{value:!i.useDifferentAddress,hasError:i.isErrorsVisible&&!i.isTermsAndConditionsChecked,label:d("checkout-page:useShippingForBilling"),onChange:function(e){return i.setUseDifferentAddress(!e)}})),i.useDifferentAddress&&e.createElement(t,{vm:m}))}));export{i as BillingAddress};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as o}from"../../components/button/index.js";import{CART_LS_KEY as a}from"../../../../store/cart/index.js";import i from"./style.module.scss.js";import s from"../../components/svg/success-circle.js";import r from"../../components/expandable-section/index.js";import d from"../../components/credit-card-form/svg/amex.js";import n from"../../components/credit-card-form/svg/master-card.js";import l from"../../components/credit-card-form/svg/troy.js";import m from"../../components/credit-card-form/svg/visa.js";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as c}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/city/index.js";import"mobx";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute-value/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../../../models/data/customer-attribute/index.js";import"../../../../models/data/customer-review/index.js";import"../../../../models/data/customer-review-summary/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/merchant-settings/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/adjustment/index.js";import"../../../../models/data/order/gift-line/index.js";import"../../../../models/data/order/invoice/index.js";import"../../../../models/data/order/line-item/discount/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/option/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/tracking-info/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/payment-method/index.js";import"../../../../models/data/order/refund/line-item/index.js";import"../../../../models/data/order/shipping-line/index.js";import"../../../../models/data/order/tax-line/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../../../models/data/product-filter/index.js";import"../../../../models/data/product-campaign/campaign/index.js";import"../../../../models/data/product-campaign/filter/index.js";import"../../../../models/data/product-option-set/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/theme/theme.js";import"../../../../models/theme/page/index.js";import"../../../../models/theme/component/prop/index.js";import"../../../../models/theme/page/component/prop-value/link.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-detail/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/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"../../../../models/theme/settings/index.js";import"../../../../models/theme/custom-data/index.js";import"../../../../models/data/payment-gateway/index.js";import{PaymentMethodEnum as p,PaymentGatewayTypeEnum as v,OrderPackageStatusEnum as E,TransactionCardAssociationEnum as x}from"../../../../__api/types/index.js";var f=t((function(t){var E,f,j,h,k,T,N=t.vm,y=u().t;e.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(a);e&&e===N.checkout.id&&localStorage.removeItem(a)}}),[]);var I=((null===(E=N.checkout.customer)||void 0===E?void 0:E.firstName)||"")+" "+((null===(f=N.checkout.customer)||void 0===f?void 0:f.lastName)||""),L=((null===(j=N.checkout.shippingAddress)||void 0===j?void 0:j.firstName)||"")+" "+((null===(h=N.checkout.shippingAddress)||void 0===h?void 0:h.lastName)||""),A=N.paymentGateways.find((function(e){var t;return e.id===(null===(t=N.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),D=null===(k=N.successTransaction)||void 0===k?void 0:k.paymentMethodDetail,S=e.useMemo((function(){var t,o,a,s;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:paymentMethod")),A&&e.createElement(e.Fragment,null,!!A.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:A.logoUrl})),!A.logoUrl&&e.createElement("div",{className:i.InfoText},A.paymentMethodType===p.CREDIT_CARD&&A.type===v.INTERNAL?y("checkout-page:creditCard"):A.name),!!A.description&&A.type!==v.EXTERNAL&&e.createElement("div",{className:i.InfoText},e.createElement("div",{dangerouslySetInnerHTML:{__html:A.description}}))),"CREDIT_CARD"===(null===(t=N.successTransaction)||void 0===t?void 0:t.paymentMethod)&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},e.createElement("div",{className:i.CardLogoContainer},function(){var t,o;switch(null===(o=null===(t=N.successTransaction)||void 0===t?void 0:t.paymentMethodDetail)||void 0===o?void 0:o.cardAssociation){case x.AMERICAN_EXPRESS:return e.createElement(d,null);case x.MASTER_CARD:return e.createElement(n,null);case x.TROY:return e.createElement(l,null);case x.VISA:return e.createElement(m,null);default:return e.createElement("div",null)}}()),e.createElement("span",null,"**** ".concat((null==D?void 0:D.lastFourDigits)||""))),(null===(o=null==D?void 0:D.installment)||void 0===o?void 0:o.installmentCount)&&D.installment.installmentCount>1&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},"".concat(D.installment.installmentCount," ").concat(y("checkout-page:installments"))),null!==D.installment.installmentPrice&&e.createElement("div",{className:i.InfoText},"".concat(D.installment.installmentCount," x ").concat(c(D.installment.installmentPrice,N.checkout.currencyCode)))))),"address"===N.deliveryMethod&&e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:billingAddress")),!!(null===(a=N.checkout.billingAddress)||void 0===a?void 0:a.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},N.checkout.billingAddress.company),e.createElement("div",{className:i.InfoText},null===(s=N.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),C=e.useMemo((function(){var t,o,a,s,r;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(t=N.checkout.customer)||void 0===t?void 0:t.email),e.createElement("div",{className:i.InfoText},I),!!(null===(o=N.checkout.shippingAddress)||void 0===o?void 0:o.phone)&&e.createElement("div",{className:i.InfoText},null===(a=N.checkout.shippingAddress)||void 0===a?void 0:a.phone)),e.createElement("div",null,"in-store"===N.deliveryMethod&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:receiver")),e.createElement("div",{className:[i.InfoText,i.withMBottom].join(" ")},L)),e.createElement("div",{className:i.InfoTitle},"address"===N.deliveryMethod?y("checkout-page:shippingAddress"):y("checkout-page:pickUpLocation")),!!(null===(s=N.checkout.shippingAddress)||void 0===s?void 0:s.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},N.checkout.shippingAddress.company),e.createElement("div",{className:i.InfoText},null===(r=N.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return e.createElement("div",{className:i.StepSuccess},e.createElement("div",{className:i.SuccessTitleContainer},e.createElement(s,null),e.createElement("span",{className:i.SuccessTitle},y("checkout-page:orderSuccessTitle"))),e.createElement("div",{className:i.SuccessSubTitle},y("address"===N.deliveryMethod?"checkout-page:orderSuccessDescription":"checkout-page:orderSuccessInStoreDeliveryDescription",{customerName:I})),e.createElement("div",{className:[i.InfoGrid,i.WithBorder].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:orderNoAndDate")),e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},"#"+(N.checkout.orderNumber||"")),e.createElement("div",{className:i.InfoText},N.checkout.dateStr),e.createElement(g,{vm:N})),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(T=N.checkout.customer)||void 0===T?void 0:T.email),e.createElement("div",{className:i.InfoText},I))),e.createElement(r,{title:y("checkout-page:paymentSummary")},S),e.createElement(r,{title:y("checkout-page:shippingSummary")},C),e.createElement("div",{className:i.Actions},e.createElement("div",{className:i.HelpText},e.createElement("span",null,y("checkout-page:helpCtaQuestion")),e.createElement("span",{className:i.Cta,onClick:function(){return N.setContactModalVisible(!0)}},y("checkout-page:helpCta"))),e.createElement(o,{text:y("checkout-page:actions.backToShopping"),onClick:N.onBackToShoppingClick,style:{flex:"0 0 auto"}})))})),g=t((function(t){var o,a=t.vm,s=u().t,r=i.Yellow;switch(a.checkout.orderPackageStatus){case E.FULFILLED:case E.PARTIALLY_FULFILLED:case E.DELIVERED:case E.PARTIALLY_DELIVERED:r=i.Green;break;case E.CANCELLED:case E.PARTIALLY_CANCELLED:case E.CANCEL_REJECTED:case E.CANCEL_REQUESTED:r=i.Red}return e.createElement("div",{className:[i.OrderStatus,r].join(" ")},a.checkout.orderPackageStatus?null===(o=[{types:[E.UNFULFILLED],text:s("checkout-page:orderPackageStatus.unfulfilled")},{types:[E.READY_FOR_SHIPMENT],text:s("checkout-page:orderPackageStatus.readyForShipment")},{types:[E.PARTIALLY_FULFILLED],text:s("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[E.FULFILLED],text:s("checkout-page:orderPackageStatus.fulfilled")},{types:[E.DELIVERED,E.PARTIALLY_DELIVERED],text:s("checkout-page:orderPackageStatus.delivered")},{types:[E.UNABLE_TO_DELIVER],text:s("checkout-page:orderPackageStatus.unableToDeliver")},{types:[E.CANCELLED,E.PARTIALLY_CANCELLED],text:s("checkout-page:orderPackageStatus.cancelled")},{types:[E.CANCEL_REJECTED],text:s("checkout-page:orderPackageStatus.cancelRejected")},{types:[E.REFUNDED,E.PARTIALLY_REFUNDED],text:s("checkout-page:orderPackageStatus.refunded")},{types:[E.REFUND_REQUEST_ACCEPTED],text:s("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[E.REFUND_REJECTED],text:s("checkout-page:orderPackageStatus.refundRejected")},{types:[E.REFUND_REQUESTED],text:s("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(a.checkout.orderPackageStatus)})))||void 0===o?void 0:o.text:"")}));export{f as StepSuccess};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as o}from"../../components/button/index.js";import{CART_LS_KEY as a}from"../../../../store/cart/index.js";import i from"./style.module.scss.js";import s from"../../components/svg/success-circle.js";import r from"../../components/expandable-section/index.js";import d from"../../components/credit-card-form/svg/amex.js";import n from"../../components/credit-card-form/svg/master-card.js";import l from"../../components/credit-card-form/svg/troy.js";import m from"../../components/credit-card-form/svg/visa.js";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as c}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/city/index.js";import"mobx";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute-value/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../../../models/data/customer-attribute/index.js";import"../../../../models/data/customer-review/index.js";import"../../../../models/data/customer-review-summary/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/merchant-settings/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/adjustment/index.js";import"../../../../models/data/order/gift-line/index.js";import"../../../../models/data/order/invoice/index.js";import"../../../../models/data/order/line-item/discount/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/option/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/tracking-info/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/payment-method/index.js";import"../../../../models/data/order/refund/line-item/index.js";import"../../../../models/data/order/shipping-line/index.js";import"../../../../models/data/order/tax-line/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../../../models/data/product-filter/index.js";import"../../../../models/data/product-campaign/campaign/index.js";import"../../../../models/data/product-campaign/filter/index.js";import"../../../../models/data/product-option-set/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/theme/theme.js";import"../../../../models/theme/page/index.js";import"../../../../models/theme/component/prop/index.js";import"../../../../models/theme/page/component/prop-value/link.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-detail/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/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"../../../../models/theme/settings/index.js";import"../../../../models/theme/custom-data/index.js";import"../../../../models/data/payment-gateway/index.js";import{PaymentMethodEnum as p,PaymentGatewayTypeEnum as v,OrderPackageStatusEnum as E,TransactionCardAssociationEnum as x}from"../../../../__api/types/index.js";var f=t((function(t){var E,f,j,h,k,T,N=t.vm,y=u().t;e.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(a);e&&e===N.checkout.id&&localStorage.removeItem(a)}}),[]);var I=((null===(E=N.checkout.customer)||void 0===E?void 0:E.firstName)||"")+" "+((null===(f=N.checkout.customer)||void 0===f?void 0:f.lastName)||""),L=((null===(j=N.checkout.shippingAddress)||void 0===j?void 0:j.firstName)||"")+" "+((null===(h=N.checkout.shippingAddress)||void 0===h?void 0:h.lastName)||""),A=N.paymentGateways.find((function(e){var t;return e.id===(null===(t=N.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),D=null===(k=N.successTransaction)||void 0===k?void 0:k.paymentMethodDetail,S=e.useMemo((function(){var t,o,a,s;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:paymentMethod")),A&&e.createElement(e.Fragment,null,!!A.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:A.logoUrl})),!A.logoUrl&&e.createElement("div",{className:i.InfoText},A.paymentMethodType===p.CREDIT_CARD&&A.type===v.INTERNAL?y("checkout-page:creditCard"):A.name),!!A.description&&A.type!==v.EXTERNAL&&e.createElement("div",{className:i.InfoText},e.createElement("div",{dangerouslySetInnerHTML:{__html:A.description}}))),"CREDIT_CARD"===(null===(t=N.successTransaction)||void 0===t?void 0:t.paymentMethod)&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},e.createElement("div",{className:i.CardLogoContainer},function(){var t,o;switch(null===(o=null===(t=N.successTransaction)||void 0===t?void 0:t.paymentMethodDetail)||void 0===o?void 0:o.cardAssociation){case x.AMERICAN_EXPRESS:return e.createElement(d,null);case x.MASTER_CARD:return e.createElement(n,null);case x.TROY:return e.createElement(l,null);case x.VISA:return e.createElement(m,null);default:return e.createElement("div",null)}}()),e.createElement("span",null,"**** ".concat((null==D?void 0:D.lastFourDigits)||""))),(null===(o=null==D?void 0:D.installment)||void 0===o?void 0:o.installmentCount)&&D.installment.installmentCount>1&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},"".concat(D.installment.installmentCount," ").concat(y("checkout-page:installments"))),null!==D.installment.installmentPrice&&e.createElement("div",{className:i.InfoText},"".concat(D.installment.installmentCount," x ").concat(c(D.installment.installmentPrice,N.checkout.currencyCode)))))),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:billingAddress")),!!(null===(a=N.checkout.billingAddress)||void 0===a?void 0:a.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},N.checkout.billingAddress.company),e.createElement("div",{className:i.InfoText},null===(s=N.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),C=e.useMemo((function(){var t,o,a,s,r;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(t=N.checkout.customer)||void 0===t?void 0:t.email),e.createElement("div",{className:i.InfoText},I),!!(null===(o=N.checkout.shippingAddress)||void 0===o?void 0:o.phone)&&e.createElement("div",{className:i.InfoText},null===(a=N.checkout.shippingAddress)||void 0===a?void 0:a.phone)),e.createElement("div",null,"in-store"===N.deliveryMethod&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:receiver")),e.createElement("div",{className:[i.InfoText,i.withMBottom].join(" ")},L)),e.createElement("div",{className:i.InfoTitle},"address"===N.deliveryMethod?y("checkout-page:shippingAddress"):y("checkout-page:pickUpLocation")),!!(null===(s=N.checkout.shippingAddress)||void 0===s?void 0:s.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},N.checkout.shippingAddress.company),e.createElement("div",{className:i.InfoText},null===(r=N.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return e.createElement("div",{className:i.StepSuccess},e.createElement("div",{className:i.SuccessTitleContainer},e.createElement(s,null),e.createElement("span",{className:i.SuccessTitle},y("checkout-page:orderSuccessTitle"))),e.createElement("div",{className:i.SuccessSubTitle},y("address"===N.deliveryMethod?"checkout-page:orderSuccessDescription":"checkout-page:orderSuccessInStoreDeliveryDescription",{customerName:I})),e.createElement("div",{className:[i.InfoGrid,i.WithBorder].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:orderNoAndDate")),e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},"#"+(N.checkout.orderNumber||"")),e.createElement("div",{className:i.InfoText},N.checkout.dateStr),e.createElement(g,{vm:N})),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},y("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(T=N.checkout.customer)||void 0===T?void 0:T.email),e.createElement("div",{className:i.InfoText},I))),e.createElement(r,{title:y("checkout-page:paymentSummary")},S),e.createElement(r,{title:y("checkout-page:shippingSummary")},C),e.createElement("div",{className:i.Actions},e.createElement("div",{className:i.HelpText},e.createElement("span",null,y("checkout-page:helpCtaQuestion")),e.createElement("span",{className:i.Cta,onClick:function(){return N.setContactModalVisible(!0)}},y("checkout-page:helpCta"))),e.createElement(o,{text:y("checkout-page:actions.backToShopping"),onClick:N.onBackToShoppingClick,style:{flex:"0 0 auto"}})))})),g=t((function(t){var o,a=t.vm,s=u().t,r=i.Yellow;switch(a.checkout.orderPackageStatus){case E.FULFILLED:case E.PARTIALLY_FULFILLED:case E.DELIVERED:case E.PARTIALLY_DELIVERED:r=i.Green;break;case E.CANCELLED:case E.PARTIALLY_CANCELLED:case E.CANCEL_REJECTED:case E.CANCEL_REQUESTED:r=i.Red}return e.createElement("div",{className:[i.OrderStatus,r].join(" ")},a.checkout.orderPackageStatus?null===(o=[{types:[E.UNFULFILLED],text:s("checkout-page:orderPackageStatus.unfulfilled")},{types:[E.READY_FOR_SHIPMENT],text:s("checkout-page:orderPackageStatus.readyForShipment")},{types:[E.PARTIALLY_FULFILLED],text:s("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[E.FULFILLED],text:s("checkout-page:orderPackageStatus.fulfilled")},{types:[E.DELIVERED,E.PARTIALLY_DELIVERED],text:s("checkout-page:orderPackageStatus.delivered")},{types:[E.UNABLE_TO_DELIVER],text:s("checkout-page:orderPackageStatus.unableToDeliver")},{types:[E.CANCELLED,E.PARTIALLY_CANCELLED],text:s("checkout-page:orderPackageStatus.cancelled")},{types:[E.CANCEL_REJECTED],text:s("checkout-page:orderPackageStatus.cancelRejected")},{types:[E.REFUNDED,E.PARTIALLY_REFUNDED],text:s("checkout-page:orderPackageStatus.refunded")},{types:[E.REFUND_REQUEST_ACCEPTED],text:s("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[E.REFUND_REJECTED],text:s("checkout-page:orderPackageStatus.refundRejected")},{types:[E.REFUND_REQUESTED],text:s("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(a.checkout.orderPackageStatus)})))||void 0===o?void 0:o.text:"")}));export{f as StepSuccess};
@@ -1 +1 @@
1
- var e=[["axios@0.21.4","/Users/uoy/Development/ikas/ikas-storefront"]],s="axios@0.21.4",a="axios@0.21.4",r=!1,i="sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",t="/axios",o={},n={type:"version",registry:!0,raw:"axios@0.21.4",name:"axios",escapedName:"axios",rawSpec:"0.21.4",saveSpec:null,fetchSpec:"0.21.4"},p=["/"],d="https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",m="0.21.4",c="/Users/uoy/Development/ikas/ikas-storefront",l={name:"Matt Zabriskie"},u={"./lib/adapters/http.js":"./lib/adapters/xhr.js"},x={url:"https://github.com/axios/axios/issues"},g=[{path:"./dist/axios.min.js",threshold:"5kB"}],h={"follow-redirects":"^1.14.0"},b="Promise based HTTP client for the browser and node.js",k={coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},j="https://axios-http.com",v="dist/axios.min.js",f=["xhr","http","ajax","promise","node"],w="MIT",_="index.js",y="axios",H={type:"git",url:"git+https://github.com/axios/axios.git"},N={build:"NODE_ENV=production grunt build",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",examples:"node ./examples/server.js",fix:"eslint --fix lib/**/*.js",postversion:"git push && git push --tags",preversion:"npm test",start:"node ./sandbox/server.js",test:"grunt test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},V="./index.d.ts",q="dist/axios.min.js",A="0.21.4",D={_args:e,_from:"axios@0.21.4",_id:a,_inBundle:false,_integrity:i,_location:"/axios",_phantomChildren:o,_requested:n,_requiredBy:p,_resolved:d,_spec:"0.21.4",_where:c,author:l,browser:u,bugs:x,bundlesize:g,dependencies:h,description:b,devDependencies:k,homepage:"https://axios-http.com",jsdelivr:"dist/axios.min.js",keywords:f,license:"MIT",main:"index.js",name:"axios",repository:H,scripts:N,typings:"./index.d.ts",unpkg:q,version:"0.21.4"};export{e as _args,s as _from,a as _id,r as _inBundle,i as _integrity,t as _location,o as _phantomChildren,n as _requested,p as _requiredBy,d as _resolved,m as _spec,c as _where,l as author,u as browser,x as bugs,g as bundlesize,D as default,h as dependencies,b as description,k as devDependencies,j as homepage,v as jsdelivr,f as keywords,w as license,_ as main,y as name,H as repository,N as scripts,V as typings,q as unpkg,A as version};
1
+ var s=[["axios@0.21.4","/Users/ikas/Projects/ikas-storefront"]],e="axios@0.21.4",a="axios@0.21.4",r=!1,i="sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",t="/axios",o={},n={type:"version",registry:!0,raw:"axios@0.21.4",name:"axios",escapedName:"axios",rawSpec:"0.21.4",saveSpec:null,fetchSpec:"0.21.4"},d=["/"],c="https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",p="0.21.4",m="/Users/ikas/Projects/ikas-storefront",l={name:"Matt Zabriskie"},u={"./lib/adapters/http.js":"./lib/adapters/xhr.js"},x={url:"https://github.com/axios/axios/issues"},g=[{path:"./dist/axios.min.js",threshold:"5kB"}],h={"follow-redirects":"^1.14.0"},b="Promise based HTTP client for the browser and node.js",j={coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},k="https://axios-http.com",v="dist/axios.min.js",f=["xhr","http","ajax","promise","node"],w="MIT",_="index.js",y="axios",H={type:"git",url:"git+https://github.com/axios/axios.git"},N={build:"NODE_ENV=production grunt build",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",examples:"node ./examples/server.js",fix:"eslint --fix lib/**/*.js",postversion:"git push && git push --tags",preversion:"npm test",start:"node ./sandbox/server.js",test:"grunt test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},V="./index.d.ts",q="dist/axios.min.js",A="0.21.4",P={_args:s,_from:"axios@0.21.4",_id:a,_inBundle:false,_integrity:i,_location:"/axios",_phantomChildren:o,_requested:n,_requiredBy:d,_resolved:c,_spec:"0.21.4",_where:m,author:l,browser:u,bugs:x,bundlesize:g,dependencies:h,description:b,devDependencies:j,homepage:"https://axios-http.com",jsdelivr:"dist/axios.min.js",keywords:f,license:"MIT",main:"index.js",name:"axios",repository:H,scripts:N,typings:"./index.d.ts",unpkg:q,version:"0.21.4"};export{s as _args,e as _from,a as _id,r as _inBundle,i as _integrity,t as _location,o as _phantomChildren,n as _requested,d as _requiredBy,c as _resolved,p as _spec,m as _where,l as author,u as browser,x as bugs,g as bundlesize,P as default,h as dependencies,b as description,j as devDependencies,k as homepage,v as jsdelivr,f as keywords,w as license,_ as main,y as name,H as repository,N as scripts,V as typings,q as unpkg,A as version};