@ikas/storefront 4.1.14 → 4.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as r}from"mobx-react-lite";import{FormItem as a}from"../form-item/index.js";import{FormItemType as o,FormItemInputMode as n}from"../form-item/model.js";import i from"./model.js";import{Checkbox as l}from"../checkbox/index.js";import s from"../../styles/common.module.scss.js";import c from"../../style.module.scss.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";import{IkasCheckoutRequirement as m}from"@ikas/storefront-models";var u=r((function(r){var a,o=d().t,n=t.useMemo((function(){return new i(e({},r))}),[]);return t.useEffect((function(){Object.entries(r).forEach((function(e){n[e[0]]=e[1]}))}),Object.values(r)),"in-store"===r.deliveryMethod?t.createElement("div",null,t.createElement("div",{className:[s.Grid,s.Grid2].join(" ")},t.createElement(v,e({},r,{vm:n})),t.createElement(E,e({},r,{vm:n})),t.createElement("div",null)," "),!!n.address.checkoutSettings&&n.address.checkoutSettings.phoneRequirement!==m.INVISIBLE&&t.createElement("div",{className:c.RowPB},t.createElement(R,e({},r,{vm:n})),t.createElement("div",null)," ")):t.createElement("div",null,n.allowTitleChange&&t.createElement("div",{className:c.RowPB},t.createElement(h,e({},r,{vm:n}))),t.createElement("div",{className:[s.Grid,s.Grid2].join(" ")},t.createElement(v,e({},r,{vm:n})),t.createElement(E,e({},r,{vm:n})),t.createElement("div",null)," "),!!n.address.checkoutSettings&&n.address.checkoutSettings.identityNumberRequirement!==m.INVISIBLE&&t.createElement("div",{className:c.RowPB},t.createElement(p,e({},r,{vm:n}))),(null===(a=n.address.checkoutSettings)||void 0===a?void 0:a.postalCodeRequirement)!==m.INVISIBLE?t.createElement(t.Fragment,null,t.createElement("div",{className:c.RowPB},t.createElement(g,e({},r,{vm:n}))),t.createElement("div",{className:[s.Grid,s.Grid2].join(" ")},t.createElement(C,e({},r,{vm:n})),t.createElement(f,e({},r,{vm:n})),t.createElement("div",null)," ")):t.createElement(t.Fragment,null,t.createElement("div",{className:c.RowPB},t.createElement(g,e({},r,{vm:n}))),t.createElement("div",{className:c.RowPB},t.createElement(C,e({},r,{vm:n})))),(n.countryOptions.length>1||n.hasState)&&t.createElement("div",{className:[c.RowPB,s.Grid,n.countryOptions.length>1&&n.hasState?s.Grid2:""].join(" ")},t.createElement(y,e({},r,{vm:n})),n.hasState&&t.createElement(T,e({},r,{vm:n}))),t.createElement("div",{className:[s.Grid,n.isDistrictHidden?"":s.Grid2,c.RowPB].join(" ")},n.isFreeTextCity?t.createElement(k,e({},r,{vm:n})):t.createElement(b,e({},r,{vm:n})),!n.isDistrictHidden&&(n.districtOptions.length?t.createElement(N,e({},r,{vm:n})):t.createElement(x,e({},r,{vm:n})))),!!n.address.checkoutSettings&&n.address.checkoutSettings.phoneRequirement!==m.INVISIBLE&&t.createElement("div",null,t.createElement(R,e({},r,{vm:n}))),!!n.allowCorporateInfo&&t.createElement("div",{style:{marginTop:"12px"}},t.createElement(l,{value:n.isCorporate,label:o("checkout-page:corporateInvoice"),onChange:n.onCorporateChange})),!!n.isCorporate&&t.createElement("div",{className:s.Grid,style:{marginTop:"12px"}},t.createElement(S,e({},r,{vm:n})),t.createElement(L,e({},r,{vm:n})),t.createElement(I,e({},r,{vm:n}))))})),v=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:firstName"),autocomplete:"given-name",value:n.firstName||"",onChange:n.onFirstNameChange,hasError:n.isErrorsVisible&&!(null===(r=n.address.validationResult)||void 0===r?void 0:r.firstName),errorText:i("checkout-page:firstNameError")})})),E=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:lastName"),autocomplete:"family-name",value:n.lastName||"",onChange:n.onLastNameChange,hasError:n.isErrorsVisible&&!(null===(r=n.address.validationResult)||void 0===r?void 0:r.lastName),errorText:i("checkout-page:lastNameError")})})),p=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:identityNumber"),value:n.identityNumber||"",onChange:n.onIdentityNumberChange,hasError:n.isErrorsVisible&&!(null===(r=n.address.validationResult)||void 0===r?void 0:r.identityNumber),errorText:i("checkout-page:identityNumberError")})})),h=r((function(e){var r=e.vm,n=d().t,i=r.address;return t.createElement(a,{type:o.TEXT,label:n("checkout-page:addressTitle"),value:i.title||"",onChange:r.onAddressTitleChange,hasError:r.isErrorsVisible&&!i.title,errorText:n("checkout-page:addressTitleError")})})),g=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:addressLine1"),autocomplete:"address-line1",value:n.address.addressLine1||"",onChange:n.onAddressLine1Change,hasError:n.isErrorsVisible&&!(null===(r=n.address.validationResult)||void 0===r?void 0:r.addressLine1),errorText:i("checkout-page:addressError")})})),C=r((function(e){var r=e.vm,n=d().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-line2",label:n("checkout-page:addressLine2"),value:r.address.addressLine2||"",onChange:r.onAddressLine2Change})})),f=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:postalCode"),autocomplete:"postal-code",value:n.address.postalCode||"",onChange:n.onAddressPostalCodeChange,hasError:n.isErrorsVisible&&!(null===(r=n.address.validationResult)||void 0===r?void 0:r.postalCode),errorText:i("checkout-page:postalCodeError")})})),y=r((function(e){var r,n,i=e.vm,l=d().t;return i.countryOptions.length<=1?null:t.createElement(a,{type:o.SELECT,label:l("checkout-page:country"),autocomplete:"country-name",value:(null===(r=i.country)||void 0===r?void 0:r.id)||"",onChange:i.onCountryChange,options:i.countryOptions,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.country),errorText:l("checkout-page:countryError")})})),T=r((function(e){var r,n,i=e.vm,l=d().t;return t.createElement(a,{type:o.SELECT,label:l("checkout-page:state"),value:(null===(r=i.state)||void 0===r?void 0:r.id)||"",onChange:i.onStateChange,options:i.stateOptions,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.state),errorText:l("checkout-page:stateError")})})),b=r((function(e){var r,n,i=e.vm,l=d().t;return t.createElement(a,{type:o.SELECT,label:l("checkout-page:city"),autocomplete:"off",value:(null===(r=i.city)||void 0===r?void 0:r.id)||"",onChange:i.onCityChange,options:i.cityOptions,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.city),errorText:l("checkout-page:cityError")})})),k=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-level2",label:i("checkout-page:city"),value:(null===(r=n.city)||void 0===r?void 0:r.name)||"",onChange:n.onCityInputChange})})),N=r((function(e){var r,n,i=e.vm,l=d().t;return t.createElement(a,{type:o.SELECT,label:l("checkout-page:district"),autocomplete:"off",value:(null===(r=i.district)||void 0===r?void 0:r.id)||"",onChange:i.onDistrictChange,options:i.districtOptions,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.district),errorText:l("checkout-page:districtError")})})),x=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-level3",label:i("checkout-page:district"),value:(null===(r=n.district)||void 0===r?void 0:r.name)||"",onChange:n.onDistrictInputChange})})),R=r((function(e){var r,i=e.vm,l=d().t;return t.createElement(a,{type:o.TEL,inputMode:n.TEL,label:l("checkout-page:phone"),autocomplete:"tel",value:i.phone||"",onChange:i.onPhoneChange,hasError:i.isErrorsVisible&&!(null===(r=i.address.validationResult)||void 0===r?void 0:r.phone),currentCountryCode:i.myCountryCode,errorText:l("checkout-page:phoneError")})})),S=r((function(e){var r=e.vm,n=d().t;return t.createElement(a,{type:o.TEXT,label:n("checkout-page:companyName"),value:r.address.company||"",onChange:r.onCompanyChange})})),L=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:taxOffice"),value:(null===(r=n.address)||void 0===r?void 0:r.taxOffice)||"",onChange:n.onTaxOfficeChange})})),I=r((function(e){var r,n=e.vm,i=d().t;return t.createElement(a,{type:o.TEXT,label:i("checkout-page:taxNumber"),value:(null===(r=n.address)||void 0===r?void 0:r.taxNumber)||"",onChange:n.onTaxNumberChange})}));export{u as AddressForm};
1
+ import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as r}from"mobx-react-lite";import{FormItem as a}from"../form-item/index.js";import{FormItemType as o,FormItemInputMode as n}from"../form-item/model.js";import i from"./model.js";import{Checkbox as l}from"../checkbox/index.js";import s from"../../styles/common.module.scss.js";import d from"../../style.module.scss.js";import"@ikas/storefront-config";import{useTranslation as c}from"../../../../utils/i18n.js";import{IkasCheckoutRequirement as u}from"@ikas/storefront-models";var m=r((function(r){var a=t.useMemo((function(){return new i(e({},r))}),[]);return t.useEffect((function(){Object.entries(r).forEach((function(e){a[e[0]]=e[1]}))}),Object.values(r)),"in-store"===r.deliveryMethod?t.createElement(v,{props:r,vm:a}):t.createElement(p,{props:r,vm:a})})),v=r((function(r){var a=r.props,o=r.vm;return c().t,t.createElement("div",null,t.createElement("div",{className:[s.Grid,s.Grid2].join(" ")},t.createElement(E,e({},a,{vm:o})),t.createElement(h,e({},a,{vm:o})),t.createElement("div",null)," "),!!o.address.checkoutSettings&&o.address.checkoutSettings.phoneRequirement!==u.INVISIBLE&&t.createElement("div",{className:d.RowPB},t.createElement(j,e({},a,{vm:o})),t.createElement("div",null)," "))})),p=r((function(r){var a,o,n,i=r.props,u=r.vm,m=c().t,v=function(r){switch(r){case"firstName":return t.createElement(E,e({},i,{vm:u}));case"lastName":return t.createElement(h,e({},i,{vm:u}));case"addressLine1":return t.createElement(b,e({},i,{vm:u}));case"addressLine2":return t.createElement(y,e({},i,{vm:u}));case"postalCode":return t.createElement(C,e({},i,{vm:u}));case"identityNumber":return t.createElement(f,e({},i,{vm:u}));case"country":return t.createElement(T,e({},i,{vm:u}));case"state":return t.createElement(k,e({},i,{vm:u}));case"city":return u.address.isFreeTextCity?t.createElement(N,e({},i,{vm:u})):t.createElement(L,e({},i,{vm:u}));case"district":return u.address.isFreeTextDistrict?t.createElement(R,e({},i,{vm:u})):t.createElement(x,e({},i,{vm:u}));case"phone":return t.createElement(j,e({},i,{vm:u}));case"company":return t.createElement(O,e({},i,{vm:u}));case"taxNumber":return t.createElement(X,e({},i,{vm:u}));case"taxOffice":return t.createElement(V,e({},i,{vm:u}));default:return null}},p=function(e){return t.createElement(t.Fragment,null,1===e.length&&t.createElement("div",{className:d.RowPB},e.map((function(e){return v(e)}))),2===e.length&&t.createElement("div",{className:[s.Grid,s.Grid2].join(" ")},e.map((function(e){return v(e)})),t.createElement("div",null)," "),3===e.length&&t.createElement("div",{className:[s.Grid,s.Grid2,s.Grid3].join(" ")},e.map((function(e){return v(e)})),t.createElement("div",null)," "))};return t.createElement("div",null,u.allowTitleChange&&t.createElement("div",{className:d.RowPB},t.createElement(g,e({},i,{vm:u}))),u.countryOptions.length<=1?null===(a=u.address.addressFormatIgnoreCountry)||void 0===a?void 0:a.map((function(e){return p(e)})):null===(o=u.address.addressFormat)||void 0===o?void 0:o.map((function(e){return p(e)})),!!u.allowCorporateInfo&&t.createElement("div",{style:{marginTop:"12px"}},t.createElement(l,{value:u.isCorporate,label:m("checkout-page:corporateInvoice"),onChange:u.onCorporateChange})),!!u.isCorporate&&(null===(n=u.address.billingFormat)||void 0===n?void 0:n.map((function(e){return p(e)}))))})),E=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.firstName)||l("checkout-page:firstName"),autocomplete:"given-name",value:i.firstName||"",onChange:i.onFirstNameChange,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.firstName),errorText:l("checkout-page:firstNameError")})})),h=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.lastName)||l("checkout-page:lastName"),autocomplete:"family-name",value:i.lastName||"",onChange:i.onLastNameChange,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.lastName),errorText:l("checkout-page:lastNameError")})})),f=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.identityNumber)||l("checkout-page:identityNumber"),value:i.identityNumber||"",onChange:i.onIdentityNumberChange,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.identityNumber),errorText:l("checkout-page:identityNumberError")})})),g=r((function(e){var r=e.vm,n=c().t;return t.createElement(a,{type:o.TEXT,label:n("checkout-page:addressTitle"),value:r.address.title||"",onChange:r.onAddressTitleChange,hasError:r.isErrorsVisible&&!r.address.title,errorText:n("checkout-page:addressTitleError")})})),b=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.addressLine1)||l("checkout-page:addressLine1"),autocomplete:"address-line1",value:i.address.addressLine1||"",onChange:i.onAddressLine1Change,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.addressLine1),errorText:l("checkout-page:addressError")})})),y=r((function(e){var r,n=e.vm,i=c().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-line2",label:(null===(r=n.address.fieldLabels)||void 0===r?void 0:r.addressLine2)||i("checkout-page:addressLine2"),value:n.address.addressLine2||"",onChange:n.onAddressLine2Change})})),C=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.postalCode)||l("checkout-page:postalCode"),autocomplete:"postal-code",value:i.address.postalCode||"",onChange:i.onAddressPostalCodeChange,hasError:i.isErrorsVisible&&!(null===(n=i.address.validationResult)||void 0===n?void 0:n.postalCode),errorText:l("checkout-page:postalCodeError")})})),T=r((function(e){var r,n,i,l=e.vm,s=c().t;return l.countryOptions.length<=1?null:t.createElement(a,{type:o.SELECT,label:(null===(r=l.address.fieldLabels)||void 0===r?void 0:r.country)||s("checkout-page:country"),autocomplete:"country-name",value:(null===(n=l.country)||void 0===n?void 0:n.id)||"",onChange:l.onCountryChange,options:l.countryOptions,hasError:l.isErrorsVisible&&!(null===(i=l.address.validationResult)||void 0===i?void 0:i.country),errorText:s("checkout-page:countryError")})})),k=r((function(e){var r,n,i,l=e.vm,s=c().t;return t.createElement(a,{type:o.SELECT,label:(null===(r=l.address.fieldLabels)||void 0===r?void 0:r.state)||s("checkout-page:state"),value:(null===(n=l.state)||void 0===n?void 0:n.id)||"",onChange:l.onStateChange,options:l.stateOptions,hasError:l.isErrorsVisible&&!(null===(i=l.address.validationResult)||void 0===i?void 0:i.state),errorText:s("checkout-page:stateError")})})),L=r((function(e){var r,n,i,l=e.vm,s=c().t;return t.createElement(a,{type:o.SELECT,label:(null===(r=l.address.fieldLabels)||void 0===r?void 0:r.city)||s("checkout-page:city"),autocomplete:"off",value:(null===(n=l.city)||void 0===n?void 0:n.id)||"",onChange:l.onCityChange,options:l.cityOptions,hasError:l.isErrorsVisible&&!(null===(i=l.address.validationResult)||void 0===i?void 0:i.city),errorText:s("checkout-page:cityError")})})),N=r((function(e){var r,n,i,l=e.vm,s=c().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-level2",label:(null===(r=l.address.fieldLabels)||void 0===r?void 0:r.city)||s("checkout-page:city"),value:(null===(n=l.city)||void 0===n?void 0:n.name)||"",hasError:l.isErrorsVisible&&!(null===(i=l.address.validationResult)||void 0===i?void 0:i.city),onChange:l.onCityInputChange,errorText:s("checkout-page:cityError")})})),x=r((function(e){var r,n,i,l=e.vm,s=c().t;return t.createElement(a,{type:o.SELECT,label:(null===(r=l.address.fieldLabels)||void 0===r?void 0:r.district)||s("checkout-page:district"),autocomplete:"off",value:(null===(n=l.district)||void 0===n?void 0:n.id)||"",onChange:l.onDistrictChange,options:l.districtOptions,hasError:l.isErrorsVisible&&!(null===(i=l.address.validationResult)||void 0===i?void 0:i.district),errorText:s("checkout-page:districtError")})})),R=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,autocomplete:"address-level3",label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.district)||l("checkout-page:district"),value:(null===(n=i.district)||void 0===n?void 0:n.name)||"",onChange:i.onDistrictInputChange})})),j=r((function(e){var r,i,l,s=e.vm,d=c().t;return t.createElement(a,{type:o.TEL,inputMode:n.TEL,label:(null===(r=s.address.fieldLabels)||void 0===r?void 0:r.phone)||d("checkout-page:phone"),autocomplete:"tel",value:s.phone||"",onChange:s.onPhoneChange,hasError:s.isErrorsVisible&&!(null===(i=s.address.validationResult)||void 0===i?void 0:i.phone),currentCountryCode:(null===(l=s.address.country)||void 0===l?void 0:l.iso2)||s.myCountryCode,errorText:d("checkout-page:phoneError")})})),O=r((function(e){var r,n=e.vm,i=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=n.address.fieldLabels)||void 0===r?void 0:r.companyName)||i("checkout-page:companyName"),value:n.address.company||"",onChange:n.onCompanyChange})})),V=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.taxOffice)||l("checkout-page:taxOffice"),value:(null===(n=i.address)||void 0===n?void 0:n.taxOffice)||"",onChange:i.onTaxOfficeChange})})),X=r((function(e){var r,n,i=e.vm,l=c().t;return t.createElement(a,{type:o.TEXT,label:(null===(r=i.address.fieldLabels)||void 0===r?void 0:r.taxNumber)||l("checkout-page:taxNumber"),value:(null===(n=i.address)||void 0===n?void 0:n.taxNumber)||"",onChange:i.onTaxNumberChange})}));export{m as AddressForm};
@@ -1,8 +1,8 @@
1
- import { IkasOrderAddress } from "../../../../models/data/order/address";
2
- import { IkasCountry, IkasState, IkasCity, IkasDistrict, IkasCustomerAddress, IkasOrderAddressCountry, IkasOrderAddressCity, IkasOrderAddressDistrict } from "../../../../models";
1
+ import { IkasCountry, IkasState, IkasCity, IkasDistrict, IkasOrderAddressCountry, IkasOrderAddressCity, IkasOrderAddressDistrict } from "../../../../models";
2
+ import IkasCheckoutAddress from "../../../../models/data/checkout/ikas-checkout-address";
3
3
  declare type Callback = ((value: string) => void) | null | undefined;
4
4
  export interface AddressFormViewModelParams {
5
- address: IkasOrderAddress | IkasCustomerAddress;
5
+ address: IkasCheckoutAddress;
6
6
  isCorporate?: boolean;
7
7
  isErrorsVisible: boolean;
8
8
  isCustomerAddress?: boolean;
@@ -14,7 +14,7 @@ export interface AddressFormViewModelParams {
14
14
  deliveryMethod?: "address" | "in-store";
15
15
  }
16
16
  export default class AddressFormViewModel {
17
- address: IkasOrderAddress | IkasCustomerAddress;
17
+ address: IkasCheckoutAddress;
18
18
  isCorporate: boolean;
19
19
  isErrorsVisible: boolean;
20
20
  isCustomerAddress?: boolean;
@@ -33,10 +33,10 @@ export default class AddressFormViewModel {
33
33
  get lastName(): string;
34
34
  get phone(): string | null;
35
35
  get identityNumber(): string | null;
36
- get country(): IkasOrderAddressCountry | import("../../../../models").IkasCustomerAddressCountry | null;
37
- get state(): import("../../../../models").IkasOrderAddressState | import("../../../../models").IkasCustomerAddressState | null;
38
- get city(): IkasOrderAddressCity | import("../../../../models").IkasCustomerAddressCity | null;
39
- get district(): IkasOrderAddressDistrict | import("../../../../models").IkasCustomerAddressDistrict | null;
36
+ get country(): IkasOrderAddressCountry | null;
37
+ get state(): import("../../../../models").IkasOrderAddressState | null;
38
+ get city(): IkasOrderAddressCity | null;
39
+ get district(): IkasOrderAddressDistrict | null;
40
40
  get countryOptions(): {
41
41
  label: string;
42
42
  value: string;
@@ -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 r from"lodash/sortBy";import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import{IkasOrderAddressCity as o}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/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{stringSorter as a,capitalize as l}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as u,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import c from"../../../../store/location/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";var h=function(){function h(i){var r=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(r,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(r,void 0,void 0,(function(){var t,i,s,r,o,n,d,a,l=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,c.getMyCountry()];case 1:t=e.sent(),this.myCountryCode=t.data,e.label=2;case 2:return[4,c.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:p.getCurrentLocale()})];case 3:return i=e.sent(),s=i.data||[],r=p.getCurrentRouting(),(null===(a=null==r?void 0:r.countryCodes)||void 0===a?void 0:a.length)?s=s.filter((function(t){var e;return t.iso2&&(null===(e=r.countryCodes)||void 0===e?void 0:e.includes(t.iso2))})):(o=p.getRoutings().filter((function(t){return t.id!==p.getStorefrontRoutingId()})),s=s.filter((function(t){return t.iso2&&!o.some((function(e){var i;return null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2)}))}))),this.countries=s,1!==this.countries.length||this.country?this.myCountryCode&&!this.country&&(n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))&&this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id),[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(r,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listState({countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(r,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.state)||void 0===i?void 0:i.id)||!(null===(s=this.country)||void 0===s?void 0:s.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.cities=t.data||[],[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(r,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.city)||void 0===i?void 0:i.id)||this.isDistrictHidden)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listDistrict({cityId:{eq:this.city.id},stateId:(null===(s=this.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){r.firstNameChangeCallback&&r.firstNameChangeCallback(t),r.address.firstName=t},this.onLastNameChange=function(t){r.lastNameChangeCallback&&r.lastNameChangeCallback(t),r.address.lastName=t},this.onPhoneChange=function(t){r.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(r.address.identityNumber=t):r.address.identityNumber=""},this.onAddressTitleChange=function(t){r.address.title=t},this.onAddressLine1Change=function(t){r.address.addressLine1=t},this.onAddressLine2Change=function(t){r.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){r.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=r.country)||void 0===e?void 0:e.id)!==t){var i=r.countries.find((function(e){return e.id===t}));r.address.country=new n({id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null}),r.address.state=null,r.address.city=null,r.address.district=null,r.states=[],r.cities=[],r.districts=[],r.listStates()}},this.onStateChange=function(t){var e;if((null===(e=r.state)||void 0===e?void 0:e.id)!==t){var i=r.states.find((function(e){return e.id===t}));r.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},r.address.city=null,r.address.district=null,r.cities=[],r.districts=[],r.listCities()}},this.onCityChange=function(t){var e;if((null===(e=r.city)||void 0===e?void 0:e.id)!==t){var i=r.cities.find((function(e){return e.id===t}));r.address.city=new o({id:i.id,name:i.name}),r.address.district=null,r.districts=[],r.listDistricts()}},this.onCityInputChange=function(t){r.districts=[],r.address.city=new o({id:void 0,name:t})},this.onDistrictChange=function(t){var e;if((null===(e=r.district)||void 0===e?void 0:e.id)!==t){var i=r.districts.find((function(e){return e.id===t}));r.address.district=new d({id:i.id,name:i.name})}},this.onDistrictInputChange=function(t){r.address.district=new d({id:void 0,name:t})},this.onCorporateChange=function(t){r.isCorporate=t,t||(r.address.company=null,r.address.taxNumber=null,r.address.taxOffice=null)},this.onCompanyChange=function(t){r.address.company=t},this.onTaxNumberChange=function(t){r.address.taxNumber=t},this.onTaxOfficeChange=function(t){r.address.taxOffice=t},this.address=i.address,this.isCorporate=i.isCorporate||!1,this.isErrorsVisible=i.isErrorsVisible||!1,this.isCustomerAddress=i.isCustomerAddress||!1,this.allowedCountryIds=i.allowedCountryIds,this.allowCorporateInfo=i.allowCorporateInfo||!1,this.allowTitleChange=i.allowTitleChange||!1,this.firstNameChangeCallback=i.firstNameChangeCallback||null,this.lastNameChangeCallback=i.lastNameChangeCallback||null,s(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"stateOptions",{get:function(){var t=this.states.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"cityOptions",{get:function(){return r(this.cities,"order").map(this.modelToOption)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"districtOptions",{get:function(){var t=this.districts.map((function(t){return i(i({},t),{name:l(t.name)})})).map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isFreeTextCity",{get:function(){var t=this;return u.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),h}();export{h 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 r from"lodash/sortBy";import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import{IkasOrderAddressCity as o}from"../../../../models/data/order/address/city/index.js";import{IkasOrderAddressCountry as n}from"../../../../models/data/order/address/country/index.js";import{IkasOrderAddressDistrict as d}from"../../../../models/data/order/address/district/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/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{stringSorter as a,capitalize as l}from"../../../../utils/helper.js";import{FREE_TEXT_CITY_COUNTRY_LIST as u,DISTRICT_HIDDEN_COUNTRY_LIST as m}from"../../../../utils/constants.js";import c from"../../../../store/location/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";var h=function(){function h(i){var r=this;this.isCorporate=!1,this.isErrorsVisible=!1,this.allowedCountryIds=null,this.allowCorporateInfo=!1,this.allowTitleChange=!1,this.firstNameChangeCallback=null,this.lastNameChangeCallback=null,this.countries=[],this.states=[],this.cities=[],this.districts=[],this.myCountryCode=null,this.fillDropdownOptions=function(){return t(r,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.listCountries()];case 1:return t.sent(),[4,this.listStates()];case 2:return t.sent(),[4,this.listCities()];case 3:return t.sent(),[4,this.listDistricts()];case 4:return t.sent(),[2]}}))}))},this.listCountries=function(){return t(r,void 0,void 0,(function(){var t,i,s,r,o,n,d,a,l=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),this.myCountryCode?[3,2]:[4,c.getMyCountry()];case 1:t=e.sent(),this.myCountryCode=t.data,e.label=2;case 2:return[4,c.listCountry({id:(null===(d=this.allowedCountryIds)||void 0===d?void 0:d.length)?{in:this.allowedCountryIds}:void 0,locale:p.getCurrentLocale()})];case 3:return i=e.sent(),s=i.data||[],r=p.getCurrentRouting(),(null===(a=null==r?void 0:r.countryCodes)||void 0===a?void 0:a.length)?s=s.filter((function(t){var e;return t.iso2&&(null===(e=r.countryCodes)||void 0===e?void 0:e.includes(t.iso2))})):(o=p.getRoutings().filter((function(t){return t.id!==p.getStorefrontRoutingId()})),s=s.filter((function(t){return t.iso2&&!o.some((function(e){var i;return null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2)}))}))),this.countries=s,1!==this.countries.length||this.country?this.countries.length&&this.myCountryCode&&!this.country&&((n=this.countries.find((function(t){return t.iso2===l.myCountryCode})))?this.onCountryChange(n.id):this.onCountryChange(this.countries[0].id)):this.onCountryChange(this.countries[0].id),[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},this.listStates=function(){return t(r,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listState({countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listCities=function(){return t(r,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.state)||void 0===i?void 0:i.id)||!(null===(s=this.country)||void 0===s?void 0:s.id))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listCity({stateId:{eq:this.state.id},countryId:{eq:this.country.id}})];case 2:return t=e.sent(),this.cities=t.data||[],[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.listDistricts=function(){return t(r,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.city)||void 0===i?void 0:i.id)||this.isDistrictHidden)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.listDistrict({cityId:{eq:this.city.id},stateId:(null===(s=this.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],this.districts.length?this.address.isDistrictRequired=!0:this.address.isDistrictRequired=!1,[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.modelToOption=function(t){return{label:t.name,value:t.id+""}},this.onFirstNameChange=function(t){r.firstNameChangeCallback&&r.firstNameChangeCallback(t),r.address.firstName=t},this.onLastNameChange=function(t){r.lastNameChangeCallback&&r.lastNameChangeCallback(t),r.address.lastName=t},this.onPhoneChange=function(t){r.address.phone=t},this.onIdentityNumberChange=function(t){t?t.length<=11&&(r.address.identityNumber=t):r.address.identityNumber=""},this.onAddressTitleChange=function(t){r.address.title=t},this.onAddressLine1Change=function(t){r.address.addressLine1=t},this.onAddressLine2Change=function(t){r.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){r.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=r.country)||void 0===e?void 0:e.id)!==t){var i=r.countries.find((function(e){return e.id===t}));r.address.country=new n({id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null}),r.address.state=null,r.address.city=null,r.address.district=null,r.address.phone=null,r.states=[],r.cities=[],r.districts=[],r.listStates()}},this.onStateChange=function(t){var e;if((null===(e=r.state)||void 0===e?void 0:e.id)!==t){var i=r.states.find((function(e){return e.id===t}));r.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},r.address.city=null,r.address.district=null,r.cities=[],r.districts=[],r.listCities()}},this.onCityChange=function(t){var e;if((null===(e=r.city)||void 0===e?void 0:e.id)!==t){var i=r.cities.find((function(e){return e.id===t}));r.address.city=new o({id:i.id,name:i.name}),r.address.district=null,r.districts=[],r.listDistricts()}},this.onCityInputChange=function(t){r.districts=[],r.address.city=new o({id:void 0,name:t})},this.onDistrictChange=function(t){var e;if((null===(e=r.district)||void 0===e?void 0:e.id)!==t){var i=r.districts.find((function(e){return e.id===t}));r.address.district=new d({id:i.id,name:i.name})}},this.onDistrictInputChange=function(t){r.address.district=new d({id:void 0,name:t})},this.onCorporateChange=function(t){r.isCorporate=t,t||(r.address.company=null,r.address.taxNumber=null,r.address.taxOffice=null)},this.onCompanyChange=function(t){r.address.company=t},this.onTaxNumberChange=function(t){r.address.taxNumber=t},this.onTaxOfficeChange=function(t){r.address.taxOffice=t},this.address=i.address,this.isCorporate=i.isCorporate||!1,this.isErrorsVisible=i.isErrorsVisible||!1,this.isCustomerAddress=i.isCustomerAddress||!1,this.allowedCountryIds=i.allowedCountryIds,this.allowCorporateInfo=i.allowCorporateInfo||!1,this.allowTitleChange=i.allowTitleChange||!1,this.firstNameChangeCallback=i.firstNameChangeCallback||null,this.lastNameChangeCallback=i.lastNameChangeCallback||null,s(this,{firstNameChangeCallback:!1,lastNameChangeCallback:!1}),this.fillDropdownOptions()}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.address.firstName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.address.lastName},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.address.phone},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"identityNumber",{get:function(){return this.address.identityNumber},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"country",{get:function(){return this.address.country},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"state",{get:function(){return this.address.state},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"city",{get:function(){return this.address.city},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"district",{get:function(){return this.address.district},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"countryOptions",{get:function(){var t=this.countries.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"stateOptions",{get:function(){var t=this.states.map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"cityOptions",{get:function(){return r(this.cities,"order").map(this.modelToOption)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"districtOptions",{get:function(){var t=this.districts.map((function(t){return i(i({},t),{name:l(t.name)})})).map(this.modelToOption);return t.sort((function(t,e){return a(t.label,e.label)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isFreeTextCity",{get:function(){var t=this;return u.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isDistrictHidden",{get:function(){var t=this;return m.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),h}();export{h as default};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import s from"../../style.module.scss.js";import r from"../select-box/index.js";import{AddressForm as d}from"../address-form/index.js";import{Checkbox as i}from"../checkbox/index.js";import{FormItem as a}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"@ikas/storefront-config";import{useTranslation as u}from"../../../../utils/i18n.js";import v from"../delivery-methods/index.js";import{CheckoutStep as p}from"../../model.js";var g=t((function(t){var d,i=t.vm,a=u().t,o=e.useMemo((function(){return e.createElement("div",null,e.createElement(h,{vm:i}),e.createElement(k,{vm:i}))}),[i]),g=e.useMemo((function(){return e.createElement("div",null,e.createElement(E,{vm:i}))}),[i]),C=e.useState("-1"),f=C[0],A=C[1];e.useEffect((function(){i.vm.checkout.stockLocationId&&A(i.vm.checkout.stockLocationId)}),[]);var y=function(e){if(!e.address)return"";var t=[];return e.address.address&&t.push(e.address.address),e.address.postalCode&&t.push(e.address.postalCode),e.address.district&&e.address.district.name&&t.push(e.address.district.name),e.address.city&&e.address.city.name&&t.push(e.address.city.name),e.address.state&&e.address.state.name&&"Default"!==e.address.state.name&&t.push(e.address.state.name),e.address.country&&e.address.country.name&&t.push(e.address.country.name),t.join(", ")};return e.createElement(e.Fragment,null,!!m.getPickupStockLocationIds()&&!i.vm.isDigitalOnly&&i.vm.availableStockLocations.length>0&&i.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:i.vm.deliveryMethod,onClick:function(e){"address"===e&&A("-1"),i.vm.onDeliveryMethodChange(e)}})),e.createElement("div",{className:l.FormSectionTitle},"address"===i.vm.deliveryMethod?e.createElement("div",{className:l.Title},i.editingCustomerAddress?a("checkout-page:editAddress"):"billing"===i.addressType?a("checkout-page:billingAddress"):a("checkout-page:shippingAddress")):i.vm.step===p.PAYMENT?e.createElement("div",{className:l.Title},a("checkout-page:billingAddress")):e.createElement("div",{className:l.Title},a("checkout-page:pickUpLocation"),e.createElement("span",{className:n.ErrorMessage},i.vm.isErrorsVisible&&!i.vm.checkout.stockLocationId&&a("checkout-page:errorPickupLocationRequired"))),!!i.editingCustomerAddress&&e.createElement("div",{className:n.CancelEdit,onClick:i.onCancelEditAddressClick},a("checkout-page:actions.cancel"))),!!i.vm.store.customerStore.customer&&!i.editingCustomerAddress&&("address"===i.vm.deliveryMethod||i.vm.step===p.PAYMENT&&"in-store"===i.vm.deliveryMethod)&&e.createElement("div",{className:s.RowPB},null===(d=i.vm.store.customerStore.customer.addresses)||void 0===d?void 0:d.map((function(t){return e.createElement(r,{key:t.id,label:t.title||"",isSelected:t.id===i.selectedAddressId,rightContent:e.createElement("div",{onClick:function(){return i.onEditAddressClick(t)}},a("checkout-page:actions.edit")),bottomContent:e.createElement("div",{className:n.AddressText},t.addressText),bottomContentVisible:!0,hasError:!t.isValid,errorText:a("checkout-page:missingAddressFields"),onClick:function(){return t.id!==i.selectedAddressId&&i.onAddressSelect(t)}})})),e.createElement(r,{label:a("checkout-page:newAddress"),isSelected:"-1"===i.selectedAddressId,bottomContent:o,onClick:function(){return"-1"!==i.selectedAddressId&&i.onAddressSelect()}})),i.vm.store.customerStore.customer||i.vm.step!==p.INFO||"address"!==i.vm.deliveryMethod?i.vm.step===p.PAYMENT&&!i.vm.store.customerStore.customer&&o:o,"in-store"===i.vm.deliveryMethod&&e.createElement("div",{className:s.RowPB},i.vm.stockLocations.map((function(t){return function(e){return e.address&&e.address.address&&e.address.city&&e.address.country&&i.vm.availableStockLocations.find((function(t){return t.id===e.id}))}(t)&&e.createElement(r,{key:t.id,label:t.name||"",isSelected:f===t.id,bottomContent:e.createElement("div",null,e.createElement("div",{className:n.AddressText},y(t)),t.deliveryTime&&e.createElement("div",{className:n.DeliveryTime},a("checkout-page:stockLocation.deliveryTime.".concat(t.deliveryTime)))),bottomContentVisible:!0,onClick:function(){i.vm.onStockLocationChange(t),A(t.id)}})}))),"in-store"===i.vm.deliveryMethod&&i.vm.step!==p.PAYMENT&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},a("checkout-page:recipientsInfo"))),g),!!i.editingCustomerAddress&&e.createElement(h,{vm:i}),!!i.editingCustomerAddress&&e.createElement("div",{className:n.EditAddressActions},e.createElement(c,{style:{width:"100%"},text:a("checkout-page:deleteAddress"),isLine:!0,isLoading:i.isDeleteAddressLoading,isDisabled:i.isEditAddressLoading,onClick:i.onDeleteAddressClick}),e.createElement(c,{style:{width:"100%",marginTop:i.vm.store.customerStore.customer?"0px":"32px"},text:a("checkout-page:actions.save"),isLoading:i.isEditAddressLoading,isDisabled:i.isDeleteAddressLoading,onClick:i.onSaveAddressClick})))})),h=t((function(t){var s=t.vm;return e.createElement(d,{address:s.editingCustomerAddress||s.address,isErrorsVisible:s.isEditAddressErrorsVisible||s.vm.isErrorsVisible,allowedCountryIds:s.vm.shippingCountryIds||void 0,allowCorporateInfo:"billing"===s.addressType,firstNameChangeCallback:s.firstNameChangeCallback,lastNameChangeCallback:s.lastNameChangeCallback,allowTitleChange:!!s.editingCustomerAddress,deliveryMethod:"address"})})),E=t((function(t){var s=t.vm;return e.createElement(d,{address:s.editingCustomerAddress||s.address,isErrorsVisible:s.isEditAddressErrorsVisible||s.vm.isErrorsVisible,firstNameChangeCallback:s.firstNameChangeCallback,lastNameChangeCallback:s.lastNameChangeCallback,deliveryMethod:"in-store"})})),k=t((function(t){var s=t.vm,r=u().t;return s.vm.store.customerStore.customer&&"-1"===s.selectedAddressId?e.createElement("div",{style:{marginTop:"12px"}},e.createElement(i,{value:s.vm.shouldSaveAddress,label:r("checkout-page:saveAddressCta"),onChange:s.vm.setShouldSaveAddress}),s.vm.shouldSaveAddress&&e.createElement("div",{style:{marginTop:"8px"}},e.createElement(a,{type:o.TEXT,label:r("checkout-page:addressTitle"),value:s.vm.addressTitle,onChange:s.vm.setAddressTitle}))):null}));export{h as CustomerAddressForm,E as RecipientForm,k as SaveAddressCheckboxAndTitle,g as default};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import s from"../../style.module.scss.js";import r from"../select-box/index.js";import{AddressForm as d}from"../address-form/index.js";import{Checkbox as i}from"../checkbox/index.js";import{FormItem as a}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"@ikas/storefront-config";import{useTranslation as u}from"../../../../utils/i18n.js";import v from"../delivery-methods/index.js";import{CheckoutStep as p}from"../../model.js";var g=t((function(t){var d,i=t.vm,a=u().t,o=e.useMemo((function(){return e.createElement("div",null,e.createElement(h,{vm:i}),e.createElement(k,{vm:i}))}),[i]),g=e.useMemo((function(){return e.createElement("div",null,e.createElement(E,{vm:i}))}),[i]),C=e.useState("-1"),f=C[0],A=C[1];e.useEffect((function(){i.vm.checkout.stockLocationId&&A(i.vm.checkout.stockLocationId)}),[]);var y=function(e){if(!e.address)return"";var t=[];return e.address.address&&t.push(e.address.address),e.address.postalCode&&t.push(e.address.postalCode),e.address.district&&e.address.district.name&&t.push(e.address.district.name),e.address.city&&e.address.city.name&&t.push(e.address.city.name),e.address.state&&e.address.state.name&&"Default"!==e.address.state.name&&t.push(e.address.state.name),e.address.country&&e.address.country.name&&t.push(e.address.country.name),t.join(", ")};return e.createElement(e.Fragment,null,!!m.getPickupStockLocationIds()&&!i.vm.isDigitalOnly&&i.vm.availableStockLocations.length>0&&i.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:i.vm.deliveryMethod,onClick:function(e){"address"===e&&A("-1"),i.vm.onDeliveryMethodChange(e)}})),e.createElement("div",{className:l.FormSectionTitle},"address"===i.vm.deliveryMethod?e.createElement("div",{className:l.Title},i.editingCustomerAddress?a("checkout-page:editAddress"):"billing"===i.addressType?a("checkout-page:billingAddress"):a("checkout-page:shippingAddress")):i.vm.step===p.PAYMENT?e.createElement("div",{className:l.Title},a("checkout-page:billingAddress")):e.createElement("div",{className:l.Title},a("checkout-page:pickUpLocation"),e.createElement("span",{className:n.ErrorMessage},i.vm.isErrorsVisible&&!i.vm.checkout.stockLocationId&&a("checkout-page:errorPickupLocationRequired"))),!!i.editingCustomerAddress&&e.createElement("div",{className:n.CancelEdit,onClick:i.onCancelEditAddressClick},a("checkout-page:actions.cancel"))),!!i.vm.store.customerStore.customer&&!i.editingCustomerAddress&&("address"===i.vm.deliveryMethod||i.vm.step===p.PAYMENT&&"in-store"===i.vm.deliveryMethod)&&e.createElement("div",{className:s.RowPB},null===(d=i.vm.customerAddresses)||void 0===d?void 0:d.map((function(t){return e.createElement(r,{key:t.id,label:t.title||"",isSelected:t.id===i.selectedAddressId,rightContent:e.createElement("div",{onClick:function(){return i.onEditAddressClick(t)}},a("checkout-page:actions.edit")),bottomContent:e.createElement("div",{className:n.AddressText},t.addressText),bottomContentVisible:!0,hasError:!t.isValidAddress,errorText:a("checkout-page:missingAddressFields"),onClick:function(){return t.id!==i.selectedAddressId&&i.onAddressSelect(t)}})})),e.createElement(r,{label:a("checkout-page:newAddress"),isSelected:"-1"===i.selectedAddressId,bottomContent:o,onClick:function(){return"-1"!==i.selectedAddressId&&i.onAddressSelect()}})),i.vm.store.customerStore.customer||i.vm.step!==p.INFO||"address"!==i.vm.deliveryMethod?i.vm.step===p.PAYMENT&&!i.vm.store.customerStore.customer&&o:o,"in-store"===i.vm.deliveryMethod&&e.createElement("div",{className:s.RowPB},i.vm.stockLocations.map((function(t){return function(e){return e.address&&e.address.address&&e.address.city&&e.address.country&&i.vm.availableStockLocations.find((function(t){return t.id===e.id}))}(t)&&e.createElement(r,{key:t.id,label:t.name||"",isSelected:f===t.id,bottomContent:e.createElement("div",null,e.createElement("div",{className:n.AddressText},y(t)),t.deliveryTime&&e.createElement("div",{className:n.DeliveryTime},a("checkout-page:stockLocation.deliveryTime.".concat(t.deliveryTime)))),bottomContentVisible:!0,onClick:function(){i.vm.onStockLocationChange(t),A(t.id)}})}))),"in-store"===i.vm.deliveryMethod&&i.vm.step!==p.PAYMENT&&e.createElement(e.Fragment,null,e.createElement("div",{className:l.FormSectionTitle},e.createElement("div",{className:l.Title},a("checkout-page:recipientsInfo"))),g),!!i.editingCustomerAddress&&e.createElement(h,{vm:i}),!!i.editingCustomerAddress&&e.createElement("div",{className:n.EditAddressActions},e.createElement(c,{style:{width:"100%"},text:a("checkout-page:deleteAddress"),isLine:!0,isLoading:i.isDeleteAddressLoading,isDisabled:i.isEditAddressLoading,onClick:i.onDeleteAddressClick}),e.createElement(c,{style:{width:"100%",marginTop:i.vm.store.customerStore.customer?"0px":"32px"},text:a("checkout-page:actions.save"),isLoading:i.isEditAddressLoading,isDisabled:i.isDeleteAddressLoading,onClick:i.onSaveAddressClick})))})),h=t((function(t){var s=t.vm;return e.createElement(d,{address:s.editingCustomerAddress||s.address,isErrorsVisible:s.isEditAddressErrorsVisible||s.vm.isErrorsVisible,allowedCountryIds:s.vm.shippingCountryIds||void 0,allowCorporateInfo:"billing"===s.addressType,firstNameChangeCallback:s.firstNameChangeCallback,lastNameChangeCallback:s.lastNameChangeCallback,allowTitleChange:!!s.editingCustomerAddress,deliveryMethod:"address"})})),E=t((function(t){var s=t.vm;return e.createElement(d,{address:s.editingCustomerAddress||s.address,isErrorsVisible:s.isEditAddressErrorsVisible||s.vm.isErrorsVisible,firstNameChangeCallback:s.firstNameChangeCallback,lastNameChangeCallback:s.lastNameChangeCallback,deliveryMethod:"in-store"})})),k=t((function(t){var s=t.vm,r=u().t;return s.vm.store.customerStore.customer&&"-1"===s.selectedAddressId?e.createElement("div",{style:{marginTop:"12px"}},e.createElement(i,{value:s.vm.shouldSaveAddress,label:r("checkout-page:saveAddressCta"),onChange:s.vm.setShouldSaveAddress}),s.vm.shouldSaveAddress&&e.createElement("div",{style:{marginTop:"8px"}},e.createElement(a,{type:o.TEXT,label:r("checkout-page:addressTitle"),value:s.vm.addressTitle,onChange:s.vm.setAddressTitle}))):null}));export{h as CustomerAddressForm,E as RecipientForm,k as SaveAddressCheckboxAndTitle,g as default};
@@ -1,18 +1,18 @@
1
- import { IkasCustomerAddress } from "../../../../models";
2
1
  import CheckoutViewModel from "../../model";
2
+ import IkasCheckoutAddress from "../../../../models/data/checkout/ikas-checkout-address";
3
3
  export declare type AddressType = "shipping" | "billing";
4
4
  export default class CustomerAddressesViewModel {
5
5
  vm: CheckoutViewModel;
6
6
  addressType: AddressType;
7
- editingCustomerAddress: IkasCustomerAddress | null;
7
+ editingCustomerAddress: IkasCheckoutAddress | null;
8
8
  isDeleteAddressLoading: boolean;
9
9
  isEditAddressLoading: boolean;
10
10
  isEditAddressErrorsVisible: boolean;
11
11
  constructor(vm: CheckoutViewModel, addressType: AddressType);
12
- get address(): import("../../../../models").IkasOrderAddress | null;
12
+ get address(): IkasCheckoutAddress | null;
13
13
  get selectedAddressId(): string | undefined;
14
- onAddressSelect: (address?: IkasCustomerAddress) => void;
15
- onEditAddressClick: (address?: IkasCustomerAddress) => void;
14
+ onAddressSelect: (address?: IkasCheckoutAddress) => void;
15
+ onEditAddressClick: (address?: IkasCheckoutAddress) => void;
16
16
  onCancelEditAddressClick: () => void;
17
17
  onDeleteAddressClick: () => Promise<void>;
18
18
  onSaveAddressClick: () => Promise<void>;
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import{makeAutoObservable as s}from"mobx";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import{IkasCustomerAddress as i}from"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/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 d from"lodash/cloneDeep";var o=function(){function o(o,r){var a=this;this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=function(e){("shipping"===a.addressType?a.vm.onSelectedShippingAddressIdChange:a.vm.onSelectedBillingAddressIdChange)((null==e?void 0:e.id)||"-1")},this.onEditAddressClick=function(e){var t=new i(d(e));t.checkoutSettings=a.vm.checkoutSettings,a.editingCustomerAddress=t},this.onCancelEditAddressClick=function(){a.isDeleteAddressLoading||a.isEditAddressLoading||(a.editingCustomerAddress=null)},this.onDeleteAddressClick=function(){return e(a,void 0,void 0,(function(){var e,s,i,o,r,a=this;return t(this,(function(t){switch(t.label){case 0:if(-1===(e=null===(o=null===(i=this.vm.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===o?void 0:o.findIndex((function(e){var t;return e.id===(null===(t=a.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];s=d(this.vm.store.customerStore.customer),null===(r=s.addresses)||void 0===r||r.splice(e,1),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isDeleteAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(this.editingCustomerAddress=null),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isDeleteAddressLoading=!1,[7];case 5:return[2]}}))}))},this.onSaveAddressClick=function(){return e(a,void 0,void 0,(function(){var e,s,i,o,r,a,m,n=this;return t(this,(function(t){switch(t.label){case 0:if(this.isDeleteAddressLoading||this.isEditAddressLoading)return[2];if(!(null===(i=this.editingCustomerAddress)||void 0===i?void 0:i.isValid))return this.isEditAddressErrorsVisible=!0,[2];if(-1===(e=null===(r=null===(o=this.vm.store.customerStore.customer)||void 0===o?void 0:o.addresses)||void 0===r?void 0:r.findIndex((function(e){var t;return e.id===(null===(t=n.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];(s=d(this.vm.store.customerStore.customer)).addresses[e]=this.editingCustomerAddress,t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isEditAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(null===(m=null===(a=this.vm.store.customerStore.customer)||void 0===a?void 0:a.addresses)||void 0===m||m.forEach((function(e){return e.checkoutSettings=n.vm.checkoutSettings})),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isEditAddressLoading=!1,[7];case 5:return[2]}}))}))},this.firstNameChangeCallback=function(e){(!a.vm.checkout.hasCustomer&&"shipping"===a.addressType||a.vm.isDigitalOnly)&&(a.vm.checkout.customer.firstName=e)},this.lastNameChangeCallback=function(e){(!a.vm.checkout.hasCustomer&&"shipping"===a.addressType||a.vm.isDigitalOnly)&&(a.vm.checkout.customer.lastName=e)},this.vm=o,this.addressType=r,s(this)}return Object.defineProperty(o.prototype,"address",{get:function(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"selectedAddressId",{get:function(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId},enumerable:!1,configurable:!0}),o}();export{o as default};
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import"../../../../models/data/blog/category/index.js";import"../../../../models/data/blog/content/index.js";import"../../../../models/data/blog/meta-data/index.js";import"../../../../models/data/blog/tag/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"@ikas/storefront-models";import{makeAutoObservable as s}from"mobx";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import{IkasCustomerAddress as i}from"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/option/value/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/transaction/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/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 d from"lodash/cloneDeep";import o from"../../../../models/data/checkout/ikas-checkout-address.js";var r=function(){function r(r,a){var m=this;this.editingCustomerAddress=null,this.isDeleteAddressLoading=!1,this.isEditAddressLoading=!1,this.isEditAddressErrorsVisible=!1,this.onAddressSelect=function(e){("shipping"===m.addressType?m.vm.onSelectedShippingAddressIdChange:m.vm.onSelectedBillingAddressIdChange)((null==e?void 0:e.id)||"-1")},this.onEditAddressClick=function(e){var t=new o(d(e));t.countrySettings=m.vm.countrySettings,t.checkoutSettings=m.vm.checkoutSettings,m.editingCustomerAddress=t},this.onCancelEditAddressClick=function(){m.isDeleteAddressLoading||m.isEditAddressLoading||(m.editingCustomerAddress=null)},this.onDeleteAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,i,o,r,a=this;return t(this,(function(t){switch(t.label){case 0:if(-1===(e=null===(o=null===(i=this.vm.store.customerStore.customer)||void 0===i?void 0:i.addresses)||void 0===o?void 0:o.findIndex((function(e){var t;return e.id===(null===(t=a.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];s=d(this.vm.store.customerStore.customer),null===(r=s.addresses)||void 0===r||r.splice(e,1),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isDeleteAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(this.editingCustomerAddress=null),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isDeleteAddressLoading=!1,[7];case 5:return[2]}}))}))},this.onSaveAddressClick=function(){return e(m,void 0,void 0,(function(){var e,s,o,r,a,m,n,l=this;return t(this,(function(t){switch(t.label){case 0:if(this.isDeleteAddressLoading||this.isEditAddressLoading)return[2];if(!(null===(o=this.editingCustomerAddress)||void 0===o?void 0:o.isValidAddress))return this.isEditAddressErrorsVisible=!0,[2];if(-1===(e=null===(a=null===(r=this.vm.store.customerStore.customer)||void 0===r?void 0:r.addresses)||void 0===a?void 0:a.findIndex((function(e){var t;return e.id===(null===(t=l.editingCustomerAddress)||void 0===t?void 0:t.id)})))||void 0===e)return[3,5];(s=d(this.vm.store.customerStore.customer)).addresses[e]=new i(this.editingCustomerAddress),t.label=1;case 1:return t.trys.push([1,3,4,5]),this.isEditAddressLoading=!0,[4,this.vm.store.customerStore.saveCustomer(s)];case 2:return t.sent()&&(null===(n=null===(m=this.vm.store.customerStore.customer)||void 0===m?void 0:m.addresses)||void 0===n||n.forEach((function(e){return e.checkoutSettings=l.vm.checkoutSettings})),this.onAddressSelect(this.editingCustomerAddress),this.editingCustomerAddress=null,this.isEditAddressErrorsVisible=!1),[3,5];case 3:return t.sent(),[3,5];case 4:return this.isEditAddressLoading=!1,[7];case 5:return[2]}}))}))},this.firstNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.firstName=e)},this.lastNameChangeCallback=function(e){(!m.vm.checkout.hasCustomer&&"shipping"===m.addressType||m.vm.isDigitalOnly)&&(m.vm.checkout.customer.lastName=e)},this.vm=r,this.addressType=a,s(this)}return Object.defineProperty(r.prototype,"address",{get:function(){return"shipping"===this.addressType?this.vm.checkout.shippingAddress:this.vm.checkout.billingAddress},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"selectedAddressId",{get:function(){return"shipping"===this.addressType?this.vm.selectedShippingAddressId:this.vm.selectedBillingAddressId},enumerable:!1,configurable:!0}),r}();export{r as default};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as r}from"mobx-react-lite";import n,{formatIncompletePhoneNumber as l,getCountryCallingCode as o,parseIncompletePhoneNumber as s}from"libphonenumber-js";import c from"./get-countries.js";import u from"./style.module.scss.js";var i=r((function(r){var i=r.defaultCountry,m=r.disabled,v=void 0!==m&&m,f=r.placeholder,d=r.value,g=r.onChange,p=a.useState([]),b=p[0],E=p[1],h=a.useState(i||"TR"),y=h[0],N=h[1],C=a.useState(""),F=C[0],S=C[1];a.useEffect((function(){j();var e=y;if(d){var t=n(d);t&&t.country&&(e=t.country),S(l(d,e))}else x(e);N(e)}),[]);var j=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,c()];case 1:return e=t.sent(),E(e),[2]}}))}))},x=function(e){var t=o(e);S("+".concat(t))},k=function(e){return l(e,y)};return a.createElement(a.Fragment,null,a.createElement("div",{className:u.SelectFlag},a.createElement("div",{className:u.FlagContainer},a.createElement("div",{className:u.Flag},a.createElement("img",{className:u.FlagImage,alt:y,src:"https://cdn.myikas.com/sf/assets/flags/3x2/".concat(y,".svg")}),a.createElement("div",{className:u.Arrow})),a.createElement("select",{className:u.Select,value:y,onChange:function(e){if(e.target.value){var t=e.target.value;N(t),x(t)}},disabled:v},b.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)}))))),a.createElement("input",{type:"tel",autoComplete:"tel",className:u.Input,value:F,onChange:function(e){var t=b.find((function(t){var a;return t.value===(null===(a=n(e.target.value))||void 0===a?void 0:a.country)}));t&&N(t.value);var a=k(e.target.value);S(a),g(a?s(a):e.target.value)},placeholder:f,disabled:v}))}));export{i as PhoneNumberInput};
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as r}from"mobx-react-lite";import n,{formatIncompletePhoneNumber as l,getCountryCallingCode as o,parseIncompletePhoneNumber as s}from"libphonenumber-js";import c from"./get-countries.js";import u from"./style.module.scss.js";var i=r((function(r){var i=r.defaultCountry,m=r.disabled,v=void 0!==m&&m,f=r.placeholder,d=r.value,g=r.onChange,p=a.useState([]),b=p[0],E=p[1],h=a.useState(i||"TR"),y=h[0],N=h[1],C=a.useState(""),F=C[0],S=C[1];a.useEffect((function(){j();var e=y;if(d){var t=n(d);t&&t.country&&(e=t.country),S(l(d,e))}else x(e);N(e)}),[i]);var j=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,c()];case 1:return e=t.sent(),E(e),[2]}}))}))},x=function(e){var t=o(e);S("+".concat(t))},k=function(e){return l(e,y)};return a.createElement(a.Fragment,null,a.createElement("div",{className:u.SelectFlag},a.createElement("div",{className:u.FlagContainer},a.createElement("div",{className:u.Flag},a.createElement("img",{className:u.FlagImage,alt:y,src:"https://cdn.myikas.com/sf/assets/flags/3x2/".concat(y,".svg")}),a.createElement("div",{className:u.Arrow})),a.createElement("select",{className:u.Select,value:y,onChange:function(e){if(e.target.value){var t=e.target.value;N(t),x(t)}},disabled:v},b.map((function(e){return a.createElement("option",{key:e.value,value:e.value},e.label)}))))),a.createElement("input",{type:"tel",autoComplete:"tel",className:u.Input,value:F,onChange:function(e){var t=b.find((function(t){var a;return t.value===(null===(a=n(e.target.value))||void 0===a?void 0:a.country)}));t&&N(t.value);var a=k(e.target.value);S(a),g(a?s(a):e.target.value)},placeholder:f,disabled:v}))}));export{i as PhoneNumberInput};
@@ -0,0 +1,114 @@
1
+ import { IkasCheckoutRequirement, IkasCheckoutSettings, IkasOrderAddress } from "@ikas/storefront-models";
2
+ export interface AddressFormViewModelParams {
3
+ checkoutSettings?: IkasCheckoutSettings;
4
+ }
5
+ export default class CountrySettingsModel {
6
+ private _initialized;
7
+ private _addressFormCountrySettings;
8
+ private _addressFormCountryLabels;
9
+ private checkoutSettings?;
10
+ constructor(data: AddressFormViewModelParams);
11
+ init: () => Promise<void>;
12
+ get initialized(): boolean;
13
+ waitUntilInitialized: () => Promise<unknown>;
14
+ getCountrySettings: (country: string) => IkasAddressFormCountrySettings;
15
+ getCountryLabels: (country: string) => IkasAddressFormCountryLabels;
16
+ getFieldSettings: (country: string) => IkasAddressFormFields;
17
+ getFieldLabels: (country: string) => {
18
+ firstName?: string | undefined;
19
+ lastName?: string | undefined;
20
+ identityNumber?: string | undefined;
21
+ addressLine1?: string | undefined;
22
+ addressLine2?: string | undefined;
23
+ postalCode?: string | undefined;
24
+ country?: string | undefined;
25
+ state?: string | undefined;
26
+ city?: string | undefined;
27
+ district?: string | undefined;
28
+ phone?: string | undefined;
29
+ companyName?: string | undefined;
30
+ taxOffice?: string | undefined;
31
+ taxNumber?: string | undefined;
32
+ } | undefined;
33
+ getAddressFormatView: (addressFormat: string) => string[][];
34
+ getBillingFormatView: (billingFormat: string) => string[][];
35
+ getAddressFormat: (country: string) => string[][];
36
+ getBillingFormat: (country: string) => string[][];
37
+ getAddressFormatIgnoreCountry: (country: string) => string[][];
38
+ getValidationResult: (address: IkasOrderAddress) => {
39
+ firstName: boolean;
40
+ lastName: boolean;
41
+ addressLine1: boolean;
42
+ country: boolean;
43
+ state: boolean;
44
+ city: boolean;
45
+ district: boolean;
46
+ phone: boolean;
47
+ postalCode: boolean;
48
+ identityNumber: boolean;
49
+ } | undefined;
50
+ isValidAddress(address: IkasOrderAddress): boolean;
51
+ isValidField: (field: string, fieldSettings: AddressFormField | undefined, checkoutRequirement?: IkasCheckoutRequirement | null) => boolean;
52
+ isFreeTextCity(country: string): boolean | undefined;
53
+ isFreeTextDistrict(country: string): boolean | undefined;
54
+ getAddressFormCountrySettings: () => Promise<void>;
55
+ getAddressFormCountryLabels: () => Promise<void>;
56
+ }
57
+ export declare const countryFormsLocales: string[];
58
+ export declare type IkasAddressFormCountrySettings = {
59
+ id: string;
60
+ addressFormat: string;
61
+ billingFormat: string;
62
+ code: string;
63
+ iso2: string;
64
+ iso3: string;
65
+ phoneCode: string;
66
+ fields: IkasAddressFormFields;
67
+ };
68
+ export declare type IkasAddressFormFields = {
69
+ firstName?: AddressFormField;
70
+ lastName?: AddressFormField;
71
+ identityNumber?: AddressFormField;
72
+ addressLine1?: AddressFormField;
73
+ addressLine2?: AddressFormField;
74
+ postalCode?: AddressFormField;
75
+ country?: AddressFormField;
76
+ state?: AddressFormField;
77
+ city?: AddressFormField;
78
+ district?: AddressFormField;
79
+ phone?: AddressFormField;
80
+ };
81
+ declare type AddressFormField = {
82
+ required?: boolean;
83
+ type?: IkasAddressFormInputType;
84
+ regex?: string;
85
+ };
86
+ declare enum IkasAddressFormInputType {
87
+ TEXT = "text",
88
+ DROPDOWN = "dropdown"
89
+ }
90
+ export declare type IkasAddressFormCountryLabels = {
91
+ name: string;
92
+ fields: AddressFormFieldsType;
93
+ };
94
+ declare type AddressFormFieldsType = {
95
+ firstName?: AddressFormLabelType;
96
+ lastName?: AddressFormLabelType;
97
+ identityNumber?: AddressFormLabelType;
98
+ addressLine1?: AddressFormLabelType;
99
+ addressLine2?: AddressFormLabelType;
100
+ postalCode?: AddressFormLabelType;
101
+ country?: AddressFormLabelType;
102
+ state?: AddressFormLabelType;
103
+ city?: AddressFormLabelType;
104
+ district?: AddressFormLabelType;
105
+ phone?: AddressFormLabelType;
106
+ companyName?: AddressFormLabelType;
107
+ taxOffice?: AddressFormLabelType;
108
+ taxNumber?: AddressFormLabelType;
109
+ };
110
+ declare type AddressFormLabelType = {
111
+ placeholder?: string;
112
+ label?: string;
113
+ };
114
+ export {};
@@ -0,0 +1 @@
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{IkasCheckoutRequirement as r}from"@ikas/storefront-models";import s from"lodash/difference";import o from"lodash/mapValues";import{validatePhoneNumber as u,validateByRegexString as d}from"@ikas/storefront-model-functions/src/utils/helper";var a,l=function(){function l(a){var l=this;this._initialized=!1,this.init=function(){return t(l,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return t.sent(),[4,this.getAddressFormCountryLabels()];case 2:return t.sent(),this._initialized=!0,[2]}}))}))},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){l.initialized&&(clearInterval(e),t(null))}),100)}))},this.getCountrySettings=function(t){return l._addressFormCountrySettings.countrySettings[t]},this.getCountryLabels=function(t){return l._addressFormCountryLabels.countryLabels[t]},this.getFieldSettings=function(t){return l.getCountrySettings(t).fields},this.getFieldLabels=function(t){var e=l.getCountryLabels(t);if(e)return o(e.fields,(function(t,e){return null==t?void 0:t.label}))},this.getAddressFormatView=function(t){return l._addressFormCountrySettings.addressFormats[t]},this.getBillingFormatView=function(t){return l._addressFormCountrySettings.billingFormats[t]},this.getAddressFormat=function(t){var e=l.getCountrySettings(t),i=l.getAddressFormatView(e.addressFormat);if(l.checkoutSettings&&i){var n=[];return l.checkoutSettings.identityNumberRequirement===r.INVISIBLE&&n.push("identityNumber"),l.checkoutSettings.postalCodeRequirement===r.INVISIBLE&&n.push("postalCode"),l.checkoutSettings.phoneRequirement===r.INVISIBLE&&n.push("phone"),i.map((function(t){return s(t,n)}))||[]}return i},this.getBillingFormat=function(t){var e=l.getCountrySettings(t);return l.getBillingFormatView(e.billingFormat)},this.getAddressFormatIgnoreCountry=function(t){return l.getAddressFormat(t).map((function(t){return s(t,["country"])}))},this.getValidationResult=function(t){var e,i,n,s,o,d,a=l.getFieldSettings((null===(e=t.country)||void 0===e?void 0:e.iso2)||"TR");if(l.checkoutSettings&&a){var c=!!t.phone&&t.phone.length>=10&&u(t.phone);return{firstName:l.isValidField(t.firstName,a.firstName),lastName:l.isValidField(t.lastName,a.lastName),addressLine1:l.isValidField(t.addressLine1,a.addressLine1),country:l.isValidField((null===(i=t.country)||void 0===i?void 0:i.name)||"",a.country),state:l.isValidField((null===(n=t.state)||void 0===n?void 0:n.name)||"",a.state),city:l.isValidField((null===(s=t.city)||void 0===s?void 0:s.name)||"",a.city),district:l.isValidField((null===(o=t.district)||void 0===o?void 0:o.name)||"",a.district),phone:(null===(d=a.phone)||void 0===d?void 0:d.regex)?l.isValidField(t.phone||"",a.phone,l.checkoutSettings.phoneRequirement):!(l.checkoutSettings.phoneRequirement===r.MANDATORY||l.checkoutSettings.phoneRequirement===r.OPTIONAL&&t.phone)||c,postalCode:l.isValidField(t.postalCode||"",a.postalCode,l.checkoutSettings.postalCodeRequirement),identityNumber:l.isValidField(t.identityNumber||"",a.identityNumber,l.checkoutSettings.identityNumberRequirement)}}},this.isValidField=function(t,e,i){var n=!0,s=i?i===r.MANDATORY:(null==e?void 0:e.required)||!1,o=!!(null==e?void 0:e.regex)||!1;return s&&!o&&(n=!!t),s&&o&&(n=!!t||d(t,e.regex)),!s&&o&&t&&(n=d(t,e.regex)),n},this.getAddressFormCountrySettings=function(){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return"https://cdn.myikas.com/sf/static/location/settings.json",[4,fetch("https://cdn.myikas.com/sf/static/location/settings.json")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this._addressFormCountrySettings=t,[2]}}))}))},this.getAddressFormCountryLabels=function(){return t(l,void 0,void 0,(function(){var t,i,r;return e(this,(function(e){switch(e.label){case 0:return t=n.getCurrentLocale(),c.find((function(e){return e===t}))||(t="en"),i="https://cdn.myikas.com/sf/static/location/".concat(t,".json"),[4,fetch(i)];case 1:return[4,e.sent().json()];case 2:return r=e.sent(),this._addressFormCountryLabels=r,[2]}}))}))},this.checkoutSettings=a.checkoutSettings,this.init(),i(this)}return Object.defineProperty(l.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),l.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return t}))},l.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===a.TEXT},l.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===a.TEXT},l}(),c=["tr","de","en","it","es","fr","ru"];!function(t){t.TEXT="text",t.DROPDOWN="dropdown"}(a||(a={}));export{c as countryFormsLocales,l as default};
@@ -12,6 +12,8 @@ import { APIResponse } from "@ikas/fe-api-client";
12
12
  import { CreateStripePaymentIntentResponse, RetrieveInstallmentInfoResponse, UpdateCartCampaignOfferInput, CreateKlarnaTokenResponse } from "@ikas/storefront-api";
13
13
  import { IkasBaseStore } from "../../store";
14
14
  import { RetrieveInstallmentInfoQueryParams, SaveCartInput } from "@ikas/storefront-api";
15
+ import CountrySettingsModel from "./country-settings-model";
16
+ import IkasCheckoutAddress from "../../models/data/checkout/ikas-checkout-address";
15
17
  export declare type IUnavailableItems = {
16
18
  item: IkasOrderLineItem;
17
19
  stockCount: number;
@@ -46,6 +48,7 @@ export default class CheckoutViewModel {
46
48
  isKlarnaPaymentCompleted: boolean;
47
49
  checkoutCampaignOffer: CampaignOfferType | undefined;
48
50
  postCheckoutCampaignOffer: CampaignOfferType | undefined;
51
+ countrySettings: CountrySettingsModel;
49
52
  returnPolicy: string;
50
53
  privacyPolicy: string;
51
54
  termsOfService: string;
@@ -87,6 +90,7 @@ export default class CheckoutViewModel {
87
90
  get store(): IkasBaseStore;
88
91
  get canPerformPayment(): boolean | undefined;
89
92
  get isDigitalOnly(): boolean;
93
+ get customerAddresses(): IkasCheckoutAddress[] | undefined;
90
94
  saveCart: () => Promise<import("../../models").IkasCart | null | undefined>;
91
95
  inStockDeliveryInputData: (input: SaveCartInput) => Promise<SaveCartInput>;
92
96
  checkStocks: () => Promise<void>;
@@ -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"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasTransactionStatus as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasCartCampaignOfferStatus as d,IkasCampaignOfferTargetPageType as u,IkasOrderShippingMethod as l}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as h}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as p}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as m}from"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as f}from"../../models/data/order/address/index.js";import{IkasOrderCustomer as g}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as v}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/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 y from"./components/credit-card-form/model.js";import k from"../../store/customer/api.js";import S from"../../store/checkout/index.js";import b from"../../store/cart/api.js";import C,{MFS_ELEMENT_ID as I,MFS_SCRIPT_URL as P}from"./modelMasterPass.js";import A from"../../store/product/index.js";import{IkasBaseStore as w}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as N}from"@ikas/storefront-config";import{Analytics as O}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as j,CheckStocksLineInput as E}from"@ikas/storefront-api";var R,x,T=/^\d+$/,D="undefined"==typeof localStorage,G=function(){function T(l,m,T,G,_,V,U,K,F,H){var B=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=R.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(B,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,w.getInstance().customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(B,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(N.getIsEditor())return this.step=R.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===R.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(R.INFO)];if(this.step!==R.PAYMENT||this.canProceedToPayment){if(this.step===R.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(R.INFO)];if(![R.INFO,R.SUCCESS,R.SHIPPING,R.PAYMENT].includes(this.step))return[2,this.changeStep(R.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(R.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:x.PAYMENT_ERROR,data:n||null}),this.step!==R.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!==R.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=R.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==R.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==R.PAYMENT&&this.step!==R.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:x.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:x.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===R.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(R.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,O.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,k.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(B,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new j(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==R.INFO&&this.step!==R.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,b.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:x.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:x.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(B,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(B,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;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,S.checkStocks({lines:t.map((function(t){return new E(t)})),stockLocationIdList:(null===(u=N.getStockLocationIds())||void 0===u?void 0:u.length)?N.getStockLocationIds():null})];case 1:if(!(i=e.sent()).isSuccess)throw{type:x.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:x.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(B,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(B,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,w.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(B,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,S.getAvailableShippingCountries({salesChannelId:N.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return N.getPickupStockLocationIds()?[4,S.listStockLocation({id:{in:N.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:x.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return N.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,S.getAvailableStockLocations({lines:t.map((function(t){return new E(t)})),stockLocationIdList:N.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:x.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=B.shippingCountryIds)||void 0===t?void 0:t.length)||(B.error={type:x.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(B.checkout.stockLocationId=null),B.deliveryMethod=t,B.isErrorsVisible=!1},this.initialStockCheck=function(){return t(B,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 void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:x.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(B,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=N.getPaymentGateways().map((function(t){return t.id})),[4,S.listPaymentGateway({id:t?void 0:{in:i},locale:N.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===R.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(N.getPaymentGateways(),"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),this.step===R.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=I,d.src=P,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:w.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:x.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(B,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,S.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;B.store.customerStore.customer?(null===(t=B.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=B.checkoutSettings})),B.checkout.customer=new g(B.store.customerStore.customer)):B.checkout.customer=new g(B.checkout.customer||{})},this.createShippingAddress=function(){if(!B.isDigitalOnly)if(B.isInStoreDelivery)B.checkout.shippingAddress&&(B.checkout.shippingAddress.checkoutSettings=B.checkoutSettings);else if(B.checkout.shippingAddress){if(B.store.customerStore.customer){var t=null==(e=B.store.customerStore.customer.addresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=B.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return B.onSelectedShippingAddressIdChange(t.id),void(B.checkout.shippingAddress.checkoutSettings=B.checkoutSettings)}B.checkout.shippingAddress=new f(n(B.checkout.shippingAddress)||{}),B.checkout.shippingAddress.checkoutSettings=B.checkoutSettings}else if(B.store.customerStore.customer){var e=B.store.customerStore.customer.addresses;B.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else B.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(B.useDifferentAddress=!!localStorage.getItem("sAddr"),B.checkout.billingAddress){if(B.store.customerStore.customer){var t=null==(e=B.store.customerStore.customer.addresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=B.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return B.onSelectedBillingAddressIdChange(t.id),void(B.checkout.billingAddress.checkoutSettings=B.checkoutSettings)}B.checkout.billingAddress=new f(n(B.checkout.billingAddress)||{}),B.checkout.billingAddress.checkoutSettings=B.checkoutSettings}else if(B.store.customerStore.customer){var e=B.store.customerStore.customer.addresses;B.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else B.onSelectedBillingAddressIdChange("-1"),B.useDifferentAddress||!B.checkout.shippingAddress||B.isInStoreDelivery||(B.checkout.billingAddress=new f(n(B.checkout.shippingAddress)),B.checkout.billingAddress.checkoutSettings=B.checkoutSettings)},this.onShippingMethodChange=function(i){return t(B,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 h(t)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(B,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(B,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,5,,6]),[4,b.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===R.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=new h(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}))),e.label=4;case 4:return[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(B.selectedShippingAddressId=t,"-1"===t)B.checkout.shippingAddress=new f;else{var s=null===(i=null===(e=B.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(B.checkout.shippingAddress=new f(s))}B.checkout.shippingAddress&&(B.checkout.shippingAddress.checkoutSettings=B.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(B.selectedBillingAddressId=t,"-1"===t)B.checkout.billingAddress=new f;else{var s=null===(i=null===(e=B.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(B.checkout.billingAddress=new f(s))}B.checkout.billingAddress&&(B.checkout.billingAddress.checkoutSettings=B.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){B.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(B.cardData&&(!(t.length>B.cardData.cardNumber.length)||L(t))){var e=(B.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!B.installmentInfo?B.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:B.checkout.selectedPaymentGateway.id,price:B.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(B.cardData.installmentCount=1,B.installmentInfo=void 0),B.cardData.cardNumber=M(i,4).join(" "))}},this.onCardHolderNameChange=function(t){B.cardData&&(B.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(B.cardData&&(!(t.length>B.cardData.expirationDate.length)||L(t))){if(0===(null===(e=B.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(B.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(B.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(B.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(B.cardData.expirationDate=M(d,2).join(" / "))}},this.onCvcChange=function(t){B.cardData&&(t.length>B.cardData.cvv.length&&!L(t)||t.length>4||(B.cardData.cvv=t))},this.saveAddress=function(s){return t(B,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,m,f,g,v=this;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===(h=this.store.customerStore.customer.addresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=null===(m=this.store.customerStore.customer.addresses)||void 0===m?void 0:m.map((function(t){return t.id})),o=new p(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),null===(f=this.store.customerStore.customer.addresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=v.checkoutSettings})),c=null===(g=this.store.customerStore.customer.addresses)||void 0===g?void 0:g.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==r?void 0:r.includes(t))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){B.router.push("/cart")},this.onBackToShoppingClick=function(){B.router.push("/")},this.onGoToLoginClick=function(){B.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(B,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(R.SHIPPING):this.changeStep(R.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:x.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(B,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.changeStep(R.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:x.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(B,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(R.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:x.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"!==this.deliveryMethod?[3,5]:[4,this.saveAddress("billing")];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:x.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:x.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(B,void 0,void 0,(function(){var t,i,s,n,r,d,u,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,S.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,S.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,d=r&&[o.SUCCESS,o.AUTHORIZED].includes(r),u=r===o.PENDING,d?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!u||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:x.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(B,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(R.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){B.changeStep(R.INFO)},this.onBackToShippingClick=function(){B.changeStep(R.SHIPPING)},this.setCustomerConsentGranted=function(t){B.checkout.customer&&(B.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){B.useDifferentAddress=t,B.useDifferentAddress?(localStorage.setItem("sAddr","1"),B.checkout.billingAddress=B.checkout.billingAddress||new f):(localStorage.removeItem("sAddr"),B.checkout.billingAddress=B.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){B.shouldSaveAddress=t},this.setAddressTitle=function(t){B.addressTitle=t},this.setPaymentGateway=function(i){return t(B,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&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,S.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"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,S.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return this.checkout.selectedPaymentGateway=t,this.step!==R.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new y,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){B.cardData&&(B.cardData.installmentCount=t)},this.changeStep=function(i){return t(B,void 0,void 0,(function(){return e(this,(function(t){return D||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(B,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){B.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(B,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===d.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,A.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new v(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(B,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(u.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(u.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(B,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,b.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=new h(t.data),i.accepted&&this.step===R.SUCCESS?this.changeStep(R.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(B,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,k.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=l,this.checkoutSettings=m,this.router=T,this.returnPolicy=G,this.privacyPolicy=_,this.termsOfService=V,this.imprint=U,this.shippingPolicy=K,this.t=F,this.customizationProps=H,this.mpVM=new C,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(T.prototype,"merchantSettings",{get:function(){return new m(N.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(T.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(T.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(T.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=w.getInstance().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(T.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(T.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"finalPrice",{get:function(){return this.step===R.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===x.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==x.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(T.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(T.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(T.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&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"store",{get:function(){return w.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(T.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)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),T}();function M(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function L(t){return t&&T.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(R||(R={})),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"}(x||(x={}));export{R as CheckoutStep,x as ErrorType,G 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"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasTransactionStatus as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasCartCampaignOfferStatus as d,IkasCampaignOfferTargetPageType as u,IkasOrderShippingMethod as l}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as h}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as p}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as m}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import{IkasOrderCustomer as f}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as g}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/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 v from"./components/credit-card-form/model.js";import y from"../../store/customer/api.js";import S from"../../store/checkout/index.js";import k from"../../store/cart/api.js";import b,{MFS_ELEMENT_ID as C,MFS_SCRIPT_URL as I}from"./modelMasterPass.js";import P from"../../store/product/index.js";import{IkasBaseStore as A}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as w}from"@ikas/storefront-config";import{Analytics as N}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as O,CheckStocksLineInput as j}from"@ikas/storefront-api";import E from"./country-settings-model.js";import R from"../../models/data/checkout/ikas-checkout-address.js";var x,T,D=/^\d+$/,G="undefined"==typeof localStorage,M=function(){function D(l,m,D,M,V,U,K,F,H,B){var Y=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=x.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.countrySettings.waitUntilInitialized()];case 1:return t.sent(),[4,A.getInstance().customerStore.waitUntilInitialized()];case 2:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(w.getIsEditor())return this.step=x.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===x.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(x.INFO)];if(this.step!==x.PAYMENT||this.canProceedToPayment){if(this.step===x.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(x.INFO)];if(![x.INFO,x.SUCCESS,x.SHIPPING,x.PAYMENT].includes(this.step))return[2,this.changeStep(x.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(x.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:T.PAYMENT_ERROR,data:n||null}),this.step!==x.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!==x.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=x.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==x.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==x.PAYMENT&&this.step!==x.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:T.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:T.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===x.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(x.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,N.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,y.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(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new O(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==x.INFO&&this.step!==x.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,k.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:T.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:T.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,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(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;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,S.checkStocks({lines:t.map((function(t){return new j(t)})),stockLocationIdList:(null===(u=w.getStockLocationIds())||void 0===u?void 0:u.length)?w.getStockLocationIds():null})];case 1:if(!(i=e.sent()).isSuccess)throw{type:T.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:T.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(Y,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,A.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,S.getAvailableShippingCountries({salesChannelId:w.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return w.getPickupStockLocationIds()?[4,S.listStockLocation({id:{in:w.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:T.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return w.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,S.getAvailableStockLocations({lines:t.map((function(t){return new j(t)})),stockLocationIdList:w.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:T.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:T.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,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 void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:T.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=w.getPaymentGateways().map((function(t){return t.id})),[4,S.listPaymentGateway({id:t?void 0:{in:i},locale:w.getCurrentLocale(),transactionAmount:this.checkout.totalFinalPrice})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===x.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(w.getPaymentGateways(),"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),this.step===x.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id=C,d.src=I,d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:A.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:T.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,S.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;Y.store.customerStore.customer?(null===(t=Y.customerAddresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new f(Y.store.customerStore.customer)):Y.checkout.customer=new f(Y.checkout.customer||{})},this.createShippingAddress=function(){if(!Y.isDigitalOnly)if(Y.isInStoreDelivery)Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings);else if(Y.checkout.shippingAddress){if(Y.store.customerStore.customer){var t=null==(e=Y.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=Y.checkout.shippingAddress)||void 0===e?void 0:e.id)}));if(t)return Y.onSelectedShippingAddressIdChange(t.id||"-1"),void(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)}Y.checkout.shippingAddress=new R(n(Y.checkout.shippingAddress)||{}),Y.checkout.shippingAddress.countrySettings=Y.countrySettings,Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings}else if(Y.store.customerStore.customer){var e=Y.customerAddresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else Y.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.checkout.billingAddress){if(Y.store.customerStore.customer){var t=null==(e=Y.customerAddresses)?void 0:e.find((function(t){var e;return t.id===(null===(e=Y.checkout.billingAddress)||void 0===e?void 0:e.id)}));if(t)return Y.onSelectedBillingAddressIdChange(t.id||"-1"),void(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)}Y.checkout.billingAddress=new R(n(Y.checkout.billingAddress)||{}),Y.checkout.billingAddress.countrySettings=Y.countrySettings,Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings}else if(Y.store.customerStore.customer){var e=Y.customerAddresses;Y.onSelectedBillingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}else Y.onSelectedBillingAddressIdChange("-1"),Y.useDifferentAddress||!Y.checkout.shippingAddress||Y.isInStoreDelivery||(Y.checkout.billingAddress=new R(n(Y.checkout.shippingAddress)),Y.checkout.billingAddress.countrySettings=Y.countrySettings,Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onShippingMethodChange=function(i){return t(Y,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 h(t,this.countrySettings)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,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,5,,6]),[4,k.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===x.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),this.mpVM.selectedCard&&this.mpVM.selectedCard.Value1?[4,this.retrieveInstallmentInfo({input:{binNumber:this.mpVM.selectedCard.Value1.slice(0,6),paymentGatewayId:this.mpVM.selectedCard.paymentGatewayId,price:s.totalFinalPrice}})]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:s&&(r=this.checkout,this.checkout=new h(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway}),this.countrySettings)),e.label=4;case 4:return[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new R,Y.checkout.shippingAddress.countrySettings=Y.countrySettings;else{var i=null===(e=Y.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(Y.checkout.shippingAddress=new R(i),Y.checkout.shippingAddress.countrySettings=Y.countrySettings)}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new R,Y.checkout.billingAddress.countrySettings=Y.countrySettings;else{var i=null===(e=Y.customerAddresses)||void 0===e?void 0:e.find((function(e){return e.id===t}));i&&(Y.checkout.billingAddress=new R(i),Y.checkout.billingAddress.countrySettings=Y.countrySettings)}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||_(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=L(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||_(t))){if(0===(null===(e=Y.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&2===n.length){var a=parseInt(s),c=parseInt(n);o=a<=12?a:c,r=c>12?c:a;if(!isNaN(r)&&!isNaN(o))return void(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var d=t.split(" / ").join("");d.length>4||(Y.cardData.expirationDate=L(d,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!_(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,o,a,c,d,u,l,h,m,f,g,v=this;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===(h=this.customerAddresses)||void 0===h?void 0:h.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=null===(m=this.customerAddresses)||void 0===m?void 0:m.map((function(t){return t.id})),o=new p(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(o),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),null===(f=this.customerAddresses)||void 0===f||f.forEach((function(t){return t.checkoutSettings=v.checkoutSettings})),c=null===(g=this.customerAddresses)||void 0===g?void 0:g.map((function(t){return t.id})),d=null==c?void 0:c.filter((function(t){return!(null==r?void 0:r.includes(t))})),u=(null==d?void 0:d.length)?d[0]:void 0,"shipping"===s?(this.checkout.shippingAddress.id=u||"",this.selectedShippingAddressId=u||"-1"):(this.checkout.billingAddress.id=u||"",this.selectedBillingAddressId=u||"-1"),e.label=2;case 2:return[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onGoToLoginClick=function(){Y.router.push("/account/login")},this.onProceedToShippingClick=function(){return t(Y,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(x.SHIPPING):this.changeStep(x.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:T.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(Y,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.changeStep(x.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:T.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,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(x.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:T.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.canPerformPayment?(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna?[4,this.saveCart()]:[3,2]):(this.isErrorsVisible=!0,[2]);case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,8,,9]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),"address"!==this.deliveryMethod?[3,5]:[4,this.saveAddress("billing")];case 4:e.sent(),e.label=5;case 5:return[4,this.saveCart()];case 6:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 7:return e.sent(),[3,9];case 8:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:T.UNKNOWN},this.isStepLoading=!1,[3,9];case 9:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked?(this.isErrorsVisible=!0,[2]):this.isKlarna?[4,this.saveCart()]:[3,2];case 1:return e.sent(),this.setIsKlarnaPaymentCompleted(!0),[2];case 2:return e.trys.push([2,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCart()];case 4:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(i=e.sent()).type?this.error=i:this.error={type:T.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,d,u,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,S.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,S.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,d=r&&[o.SUCCESS,o.AUTHORIZED].includes(r),u=r===o.PENDING,d?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!u||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:T.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(Y,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(x.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(x.INFO)},this.onBackToShippingClick=function(){Y.changeStep(x.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new R,Y.checkout.billingAddress.countrySettings=Y.countrySettings):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,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&&"1"===t.value})))||this.stripeResponse?[3,2]:[4,S.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"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,S.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return this.checkout.selectedPaymentGateway=t,this.step!==x.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new v,t.masterPassClientId&&(console.log("called 1511 ikas log"),this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return G||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,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){Y.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===d.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,P.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new g(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(u.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(u.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,k.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data&&(this.checkout=new h(t.data,this.countrySettings),i.accepted&&this.step===x.SUCCESS?this.changeStep(x.INFO):this.changeStep(this.step)),[2]}}))}))},this.registerCustomer=function(i){return t(Y,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(e){switch(e.label){case 0:return this.checkout.customer?(t=this.checkout.customer,s=t.firstName,n=t.lastName,r=t.email,s&&n&&r?[4,y.register({orderId:this.checkout.id,firstName:s,lastName:n,email:r,password:i})]:[3,2]):[3,2];case 1:return[2,e.sent()];case 2:return[2]}}))}))},this.checkout=l,this.checkoutSettings=m,this.router=D,this.returnPolicy=M,this.privacyPolicy=V,this.termsOfService=U,this.imprint=K,this.shippingPolicy=F,this.t=H,this.customizationProps=B,this.mpVM=new b,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.countrySettings=new E({checkoutSettings:this.checkoutSettings}),this.init(),s(this)}return Object.defineProperty(D.prototype,"merchantSettings",{get:function(){return new m(w.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(D.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(D.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(D.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=A.getInstance().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(D.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(D.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"finalPrice",{get:function(){return this.step===x.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===T.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"hasQuickRegistration",{get:function(){return this.checkoutSettings.isQuickRegistrationEnabled&&this.checkout.customer&&this.checkout.customer.isGuestCheckout},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValidAddress:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValidAddress)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==T.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(D.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(D.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(D.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&&"1"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"store",{get:function(){return A.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(D.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.isValidAddress),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"customerAddresses",{get:function(){var t,e,s=this;return 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 new R(i({countrySettings:s.countrySettings},t))}))},enumerable:!1,configurable:!0}),D}();function L(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function _(t){return t&&D.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(x||(x={})),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"}(T||(T={}));export{x as CheckoutStep,T as ErrorType,M as default};
@@ -9,5 +9,5 @@ export declare class IkasCart extends IkasOrder implements ICart {
9
9
  shippingSettingsId: string | null;
10
10
  shippingZoneRateId: string | null;
11
11
  stockLocationId: string | null;
12
- constructor(data: Partial<ICart>);
12
+ constructor(data: Partial<ICart>, removeObservableAddresses?: boolean);
13
13
  }
@@ -1 +1 @@
1
- import{__extends as n}from'./../../../ext/tslib/tslib.es6.js';import{IkasCartCampaignOffer as i}from"./campaign-offer/index.js";import{IkasAvailableShippingMethod as o}from"./available-shipping-method/index.js";import{IkasOrder as e}from"../order/index.js";import{makeObservable as t,observable as l}from"mobx";var p=function(e){function p(n){var p,a,s=this;return(s=e.call(this,n)||this).availableShippingMethods=null,s.campaignOffers=null,s.couponCode=null,s.shippingSettingsId=null,s.shippingZoneRateId=null,s.stockLocationId=null,s.availableShippingMethods=(null===(p=n.availableShippingMethods)||void 0===p?void 0:p.map((function(n){return new o(n)})))||null,s.campaignOffers=(null===(a=n.campaignOffers)||void 0===a?void 0:a.map((function(n){return new i(n)})))||null,s.couponCode=n.couponCode||null,s.shippingSettingsId=n.shippingSettingsId||null,s.shippingZoneRateId=n.shippingZoneRateId||null,s.stockLocationId=n.stockLocationId||null,t(s,{availableShippingMethods:l,campaignOffers:l,couponCode:l,shippingSettingsId:l,shippingZoneRateId:l,stockLocationId:l}),s}return n(p,e),p}(e);export{p as IkasCart};
1
+ import{__extends as n}from'./../../../ext/tslib/tslib.es6.js';import{IkasCartCampaignOffer as i}from"./campaign-offer/index.js";import{IkasAvailableShippingMethod as o}from"./available-shipping-method/index.js";import{IkasOrder as e}from"../order/index.js";import{makeObservable as t,observable as l}from"mobx";var p=function(e){function p(n,p){var a,s,d=this;return(d=e.call(this,n,p)||this).availableShippingMethods=null,d.campaignOffers=null,d.couponCode=null,d.shippingSettingsId=null,d.shippingZoneRateId=null,d.stockLocationId=null,d.availableShippingMethods=(null===(a=n.availableShippingMethods)||void 0===a?void 0:a.map((function(n){return new o(n)})))||null,d.campaignOffers=(null===(s=n.campaignOffers)||void 0===s?void 0:s.map((function(n){return new i(n)})))||null,d.couponCode=n.couponCode||null,d.shippingSettingsId=n.shippingSettingsId||null,d.shippingZoneRateId=n.shippingZoneRateId||null,d.stockLocationId=n.stockLocationId||null,t(d,{availableShippingMethods:l,campaignOffers:l,couponCode:l,shippingSettingsId:l,shippingZoneRateId:l,stockLocationId:l}),d}return n(p,e),p}(e);export{p as IkasCart};
@@ -0,0 +1,47 @@
1
+ import CountrySettingsModel from "../../../components/checkout/country-settings-model";
2
+ import { IkasOrderAddress } from "../order/address";
3
+ declare type IkasCheckoutAddressConstructorData = {
4
+ countrySettings?: CountrySettingsModel | null;
5
+ title?: string | null;
6
+ } & IkasOrderAddress;
7
+ export default class IkasCheckoutAddress extends IkasOrderAddress {
8
+ countrySettings: CountrySettingsModel | null;
9
+ title: string | null;
10
+ constructor(data?: Partial<IkasCheckoutAddressConstructorData>);
11
+ get addressFormat(): string[][] | undefined;
12
+ get addressFormatIgnoreCountry(): string[][] | undefined;
13
+ get billingFormat(): string[][] | undefined;
14
+ get countryCode(): string;
15
+ get validationResult(): {
16
+ firstName: boolean;
17
+ lastName: boolean;
18
+ addressLine1: boolean;
19
+ country: boolean;
20
+ state: boolean;
21
+ city: boolean;
22
+ district: boolean;
23
+ phone: boolean;
24
+ postalCode: boolean;
25
+ identityNumber: boolean;
26
+ } | undefined;
27
+ get isValidAddress(): boolean | undefined;
28
+ get fieldLabels(): {
29
+ firstName?: string | undefined;
30
+ lastName?: string | undefined;
31
+ identityNumber?: string | undefined;
32
+ addressLine1?: string | undefined;
33
+ addressLine2?: string | undefined;
34
+ postalCode?: string | undefined;
35
+ country?: string | undefined;
36
+ state?: string | undefined;
37
+ city?: string | undefined;
38
+ district?: string | undefined;
39
+ phone?: string | undefined;
40
+ companyName?: string | undefined;
41
+ taxOffice?: string | undefined;
42
+ taxNumber?: string | undefined;
43
+ } | undefined;
44
+ get isFreeTextCity(): boolean | undefined;
45
+ get isFreeTextDistrict(): boolean | undefined;
46
+ }
47
+ export {};
@@ -0,0 +1 @@
1
+ import{__extends as t}from'./../../../ext/tslib/tslib.es6.js';import{makeObservable as e,observable as r}from"mobx";import{IkasOrderAddress as i}from"../order/address/index.js";var n=function(i){function n(t){void 0===t&&(t={});var n=i.call(this,t)||this;return n.countrySettings=t.countrySettings||null,n.title=t.title||null,e(n,{countrySettings:r,title:r}),n}return t(n,i),Object.defineProperty(n.prototype,"addressFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"addressFormatIgnoreCountry",{get:function(){if(this.countrySettings)return this.countrySettings.getAddressFormatIgnoreCountry(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"billingFormat",{get:function(){if(this.countrySettings)return this.countrySettings.getBillingFormat(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"countryCode",{get:function(){var t;return(null===(t=this.country)||void 0===t?void 0:t.iso2)||"TR"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"validationResult",{get:function(){if(this.countrySettings)return this.countrySettings.getValidationResult(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isValidAddress",{get:function(){if(this.countrySettings)return this.countrySettings.isValidAddress(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fieldLabels",{get:function(){if(this.countrySettings)return this.countrySettings.getFieldLabels(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isFreeTextCity",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextCity(this.countryCode)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isFreeTextDistrict",{get:function(){if(this.countrySettings)return this.countrySettings.isFreeTextDistrict(this.countryCode)},enumerable:!1,configurable:!0}),n}(i);export{n as default};
@@ -1,6 +1,8 @@
1
1
  import { IkasCart } from "../cart";
2
2
  import { IkasCheckout as ICheckout } from "@ikas/storefront-models";
3
3
  import { IkasPaymentGateway } from "../payment-gateway";
4
+ import IkasCheckoutAddress from "./ikas-checkout-address";
5
+ import CountrySettingsModel from "../../../components/checkout/country-settings-model";
4
6
  declare type IkasCheckoutConstructorData = {
5
7
  appliedCouponCode?: string | null;
6
8
  selectedPaymentGateway?: IkasPaymentGateway | null;
@@ -10,7 +12,9 @@ export declare class IkasCheckout extends IkasCart implements ICheckout {
10
12
  appliedCouponCode?: string | null;
11
13
  selectedPaymentGateway?: IkasPaymentGateway | null;
12
14
  masterPassPaymentGateway?: IkasPaymentGateway | null;
13
- constructor(data: Partial<IkasCheckoutConstructorData>);
15
+ billingAddress: IkasCheckoutAddress | null;
16
+ shippingAddress: IkasCheckoutAddress | null;
17
+ constructor(data: Partial<IkasCheckoutConstructorData>, countrySettings?: CountrySettingsModel);
14
18
  get isComplete(): boolean;
15
19
  get $totalFinalPrice(): number;
16
20
  get $totalFinalPriceTaxModifier(): number;
@@ -1 +1 @@
1
- import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasCart as t}from"../cart/index.js";import{IkasCheckoutFunctions as a,IkasOrderFunctions as r}from"@ikas/storefront-model-functions";import{formatCurrency as o}from"../../../utils/currency.js";import{makeObservable as i,observable as n,computed as l}from"mobx";import{formatDate as c}from"../../../utils/helper.js";var s=function(t){function s(e){var a=t.call(this,e)||this;return a.appliedCouponCode=null,a.selectedPaymentGateway=null,a.masterPassPaymentGateway=null,a.appliedCouponCode=e.couponCode,a.selectedPaymentGateway=e.selectedPaymentGateway,a.masterPassPaymentGateway=e.masterPassPaymentGateway,i(a,{appliedCouponCode:n,selectedPaymentGateway:n,masterPassPaymentGateway:n,isComplete:l,$totalFinalPrice:l,$totalFinalPriceTaxModifier:l,$totalTax:l,$formattedTotalTax:l,$formattedTotalFinalPrice:l}),a}return e(s,t),Object.defineProperty(s.prototype,"isComplete",{get:function(){return a.isComplete(this)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"$totalFinalPrice",{get:function(){return this.selectedPaymentGateway?a.getTotalFinalPrice(this,this.selectedPaymentGateway):this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"$totalFinalPriceTaxModifier",{get:function(){return this.$totalFinalPrice/this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"$totalTax",{get:function(){return r.getTotalTax(this)*this.$totalFinalPriceTaxModifier},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"$formattedTotalTax",{get:function(){return o(this.$totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"$formattedTotalFinalPrice",{get:function(){return o(this.$totalFinalPrice,this.currencyCode,this.currencySymbol)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"dateStr",{get:function(){var e=new Date;return e.setTime(this.updatedAt),c(e)},enumerable:!1,configurable:!0}),s}(t);export{s as IkasCheckout};
1
+ import{__extends as e,__assign as t}from'./../../../ext/tslib/tslib.es6.js';import{IkasCart as r}from"../cart/index.js";import{IkasCheckoutFunctions as i,IkasOrderFunctions as a}from"@ikas/storefront-model-functions";import{formatCurrency as n}from"../../../utils/currency.js";import{makeObservable as o,observable as l,computed as s}from"mobx";import{formatDate as c}from"../../../utils/helper.js";import d from"./ikas-checkout-address.js";var u=function(r){function u(e,i){var a=r.call(this,e,!0)||this;return a.appliedCouponCode=null,a.selectedPaymentGateway=null,a.masterPassPaymentGateway=null,a.billingAddress=null,a.shippingAddress=null,a.appliedCouponCode=e.couponCode,a.selectedPaymentGateway=e.selectedPaymentGateway,a.masterPassPaymentGateway=e.masterPassPaymentGateway,a.billingAddress=e.billingAddress?new d(t({countrySettings:i},e.billingAddress)):null,a.shippingAddress=e.shippingAddress?new d(t({countrySettings:i},e.shippingAddress)):null,o(a,{appliedCouponCode:l,selectedPaymentGateway:l,masterPassPaymentGateway:l,billingAddress:l,shippingAddress:l,isComplete:s,$totalFinalPrice:s,$totalFinalPriceTaxModifier:s,$totalTax:s,$formattedTotalTax:s,$formattedTotalFinalPrice:s}),a}return e(u,r),Object.defineProperty(u.prototype,"isComplete",{get:function(){return i.isComplete(this)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPrice",{get:function(){return this.selectedPaymentGateway?i.getTotalFinalPrice(this,this.selectedPaymentGateway):this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalFinalPriceTaxModifier",{get:function(){return this.$totalFinalPrice/this.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$totalTax",{get:function(){return a.getTotalTax(this)*this.$totalFinalPriceTaxModifier},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalTax",{get:function(){return n(this.$totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"$formattedTotalFinalPrice",{get:function(){return n(this.$totalFinalPrice,this.currencyCode,this.currencySymbol)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"dateStr",{get:function(){var e=new Date;return e.setTime(this.updatedAt),c(e)},enumerable:!1,configurable:!0}),u}(r);export{u as IkasCheckout};
@@ -4,7 +4,7 @@ import { IkasCheckoutOption } from "./option";
4
4
  import { IkasCheckoutSettingsPrice } from "./price";
5
5
  export declare class IkasCheckoutSettings extends IkasBaseModel implements ICheckoutSettings {
6
6
  giftPackagePriceList: IkasCheckoutSettingsPrice[] | null;
7
- identityNumberRequirement: IkasCheckoutRequirement;
7
+ identityNumberRequirement: IkasCheckoutRequirement | null;
8
8
  isAccountRequired: boolean;
9
9
  isGiftPackageEnabled: boolean | null;
10
10
  isQuickRegistrationEnabled: boolean | null;
@@ -1 +1 @@
1
- import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';export{IkasCheckoutRequirement}from"@ikas/storefront-models";import{IkasBaseModel as i}from"../base/index.js";import{IkasCheckoutOption as o}from"./option/index.js";import{IkasCheckoutSettingsPrice as t}from"./price/index.js";var n=function(i){function n(e){var n,s,r=this;return(r=i.call(this,e)||this).giftPackagePriceList=null,r.isGiftPackageEnabled=null,r.isShowPostalCode=null,r.isTermsAndConditionsDefaultChecked=null,r.options=null,r.postalCodeRequirement=null,r.showCheckoutNote=null,r.giftPackagePriceList=(null===(n=e.giftPackagePriceList)||void 0===n?void 0:n.map((function(e){return new t(e)})))||null,r.identityNumberRequirement=e.identityNumberRequirement,r.isAccountRequired=e.isAccountRequired,r.isGiftPackageEnabled=e.isGiftPackageEnabled,r.isQuickRegistrationEnabled=e.isQuickRegistrationEnabled,r.isShowPostalCode=e.isShowPostalCode,r.isTermsAndConditionsDefaultChecked=e.isTermsAndConditionsDefaultChecked,r.options=(null===(s=e.options)||void 0===s?void 0:s.map((function(e){return new o(e)})))||null,r.phoneRequirement=e.phoneRequirement,r.postalCodeRequirement=e.postalCodeRequirement||null,r.showCheckoutNote=e.showCheckoutNote||null,r.showTermsAndConditionsCheckbox=e.showTermsAndConditionsCheckbox,r.storefrontId=e.storefrontId,r}return e(n,i),n}(i);export{n as IkasCheckoutSettings};
1
+ import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';export{IkasCheckoutRequirement}from"@ikas/storefront-models";import{IkasBaseModel as i}from"../base/index.js";import{IkasCheckoutOption as o}from"./option/index.js";import{IkasCheckoutSettingsPrice as t}from"./price/index.js";var n=function(i){function n(e){var n,s,r=this;return(r=i.call(this,e)||this).giftPackagePriceList=null,r.identityNumberRequirement=null,r.isGiftPackageEnabled=null,r.isShowPostalCode=null,r.isTermsAndConditionsDefaultChecked=null,r.options=null,r.postalCodeRequirement=null,r.showCheckoutNote=null,r.giftPackagePriceList=(null===(n=e.giftPackagePriceList)||void 0===n?void 0:n.map((function(e){return new t(e)})))||null,r.identityNumberRequirement=e.identityNumberRequirement,r.isAccountRequired=e.isAccountRequired,r.isGiftPackageEnabled=e.isGiftPackageEnabled,r.isQuickRegistrationEnabled=e.isQuickRegistrationEnabled,r.isShowPostalCode=e.isShowPostalCode,r.isTermsAndConditionsDefaultChecked=e.isTermsAndConditionsDefaultChecked,r.options=(null===(s=e.options)||void 0===s?void 0:s.map((function(e){return new o(e)})))||null,r.phoneRequirement=e.phoneRequirement,r.postalCodeRequirement=e.postalCodeRequirement||null,r.showCheckoutNote=e.showCheckoutNote||null,r.showTermsAndConditionsCheckbox=e.showTermsAndConditionsCheckbox,r.storefrontId=e.storefrontId,r}return e(n,i),n}(i);export{n as IkasCheckoutSettings};
@@ -1 +1 @@
1
- import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import{IkasOrderAddressFunctions as i}from"@ikas/storefront-model-functions";import{makeAutoObservable as e}from"mobx";import{IkasCheckoutSettings as s}from"../../checkout-settings/index.js";var n=function(){function n(t){void 0===t&&(t={}),this.addressLine2=null,this.company=null,this.id=null,this.identityNumber=null,this.phone=null,this.postalCode=null,this.taxNumber=null,this.taxOffice=null,this.country=null,this.state=null,this.city=null,this.district=null,this.checkoutSettings=null,this.addressLine1=t.addressLine1||"",this.addressLine2=t.addressLine2||null,this.company=t.company||null,this.firstName=t.firstName||"",this.id=t.id||null,this.identityNumber=t.identityNumber||null,this.isDefault=t.isDefault||!1,this.lastName=t.lastName||"",this.phone=t.phone||null,this.postalCode=t.postalCode||null,this.taxNumber=t.taxNumber||null,this.taxOffice=t.taxOffice||null,this.country=t.country||null,this.state=t.state||null,this.city=t.city||null,this.district=t.district||null,this.checkoutSettings=t.checkoutSettings?new s(t.checkoutSettings):null,this.isDistrictRequired=t.isDistrictRequired||!1,e(this)}return Object.defineProperty(n.prototype,"addressText",{get:function(){return i.getAddressText(this)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"validationResult",{get:function(){if(this.checkoutSettings)return i.getValidationResult(this,this.checkoutSettings,this.isDistrictRequired||!1)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isValid",{get:function(){return!!this.checkoutSettings&&i.isValidAddress(this,this.checkoutSettings,this.isDistrictRequired||!1)},enumerable:!1,configurable:!0}),n.prototype.toJSON=function(){var i=t({},this);return delete i.checkoutSettings,delete i.isDistrictRequired,i},n}();export{n as IkasOrderAddress};
1
+ import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import{IkasOrderAddressFunctions as i}from"@ikas/storefront-model-functions";import{makeObservable as e,observable as s,computed as n}from"mobx";import{IkasCheckoutSettings as l}from"../../checkout-settings/index.js";var r=function(){function r(t){void 0===t&&(t={}),this.addressLine2=null,this.company=null,this.id=null,this.identityNumber=null,this.phone=null,this.postalCode=null,this.taxNumber=null,this.taxOffice=null,this.country=null,this.state=null,this.city=null,this.district=null,this.checkoutSettings=null,this.addressLine1=t.addressLine1||"",this.addressLine2=t.addressLine2||null,this.company=t.company||null,this.firstName=t.firstName||"",this.id=t.id||null,this.identityNumber=t.identityNumber||null,this.isDefault=t.isDefault||!1,this.lastName=t.lastName||"",this.phone=t.phone||null,this.postalCode=t.postalCode||null,this.taxNumber=t.taxNumber||null,this.taxOffice=t.taxOffice||null,this.country=t.country||null,this.state=t.state||null,this.city=t.city||null,this.district=t.district||null,this.checkoutSettings=t.checkoutSettings?new l(t.checkoutSettings):null,this.isDistrictRequired=t.isDistrictRequired||!1,e(this,{addressLine1:s,addressLine2:s,company:s,firstName:s,id:s,identityNumber:s,isDefault:s,lastName:s,phone:s,postalCode:s,taxNumber:s,taxOffice:s,country:s,state:s,city:s,district:s,addressText:n,validationResult:n,isValid:n})}return Object.defineProperty(r.prototype,"addressText",{get:function(){return i.getAddressText(this)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"validationResult",{get:function(){if(this.checkoutSettings)return i.getValidationResult(this,this.checkoutSettings,this.isDistrictRequired||!1)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isValid",{get:function(){return!!this.checkoutSettings&&i.isValidAddress(this,this.checkoutSettings,this.isDistrictRequired||!1)},enumerable:!1,configurable:!0}),r.prototype.toJSON=function(){var i=t({},this);return delete i.checkoutSettings,delete i.isDistrictRequired,i},r}();export{r as IkasOrderAddress};
@@ -44,7 +44,7 @@ export declare class IkasOrder extends IkasBaseModel implements IOrder {
44
44
  totalFinalPrice: number;
45
45
  totalPrice: number;
46
46
  refundSettings?: IkasOrderRefundSettings | null;
47
- constructor(data: Partial<IOrderConstructorData>);
47
+ constructor(data: Partial<IOrderConstructorData>, removeObservableAddresses?: boolean);
48
48
  get items(): IkasOrderLineItem[];
49
49
  get itemCount(): number;
50
50
  get itemQuantity(): number;
@@ -1 +1 @@
1
- import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasOrderAddress as t}from"./address/index.js";import{IkasOrderShippingLine as n}from"./shipping-line/index.js";import{IkasOrderLineItem as r}from"./line-item/index.js";import{IkasOrderCustomer as o}from"./customer/index.js";import{IkasOrderGiftPackageLine as i}from"./gift-line/index.js";import{IkasInvoice as u}from"./invoice/index.js";import{IkasOrderPaymentMethod as l}from"./payment-method/index.js";import{IkasOrderAdjustment as a}from"./adjustment/index.js";import{IkasOrderPackage as s}from"./package/index.js";import{IkasOrderTaxLine as d}from"./tax-line/index.js";import{IkasBaseModel as c}from"../base/index.js";import{IkasOrderShippingMethod as m,IkasOrderStatus as f}from"@ikas/storefront-models";export{IkasOrderCancelReason,IkasOrderPackageStatus,IkasOrderPaymentStatus,IkasOrderShippingMethod,IkasOrderStatus}from"@ikas/storefront-models";import{makeObservable as p,observable as g,computed as b}from"mobx";import{IkasOrderFunctions as y}from"@ikas/storefront-model-functions";import{formatCurrency as h}from"../../../utils/currency.js";var P=function(c){function P(e){var y,h,P,j,k,A,S,v,x,I,O=this;return(O=c.call(this,e)||this).billingAddress=null,O.cancelReason=null,O.cancelledAt=null,O.currencySymbol=null,O.customer=null,O.customerId=null,O.giftPackageLines=null,O.giftPackageNote=null,O.invoices=null,O.isGiftPackage=null,O.note=null,O.orderAdjustments=null,O.orderNumber=null,O.orderPackageStatus=null,O.orderPackages=null,O.orderPaymentStatus=null,O.orderedAt=null,O.paymentMethods=null,O.shippingAddress=null,O.shippingLines=null,O.taxLines=null,O.billingAddress=e.billingAddress?new t(e.billingAddress):null,O.cancelReason=e.cancelReason||null,O.cancelledAt=e.cancelledAt||null,O.currencyCode=e.currencyCode||"",O.currencySymbol=e.currencySymbol||null,O.customer=e.customer?new o(e.customer):null,O.customerId=e.customerId||null,O.giftPackageLines=(null===(y=e.giftPackageLines)||void 0===y?void 0:y.map((function(e){return new i(e)})))||null,O.giftPackageNote=e.giftPackageNote||null,O.invoices=(null===(h=e.invoices)||void 0===h?void 0:h.map((function(e){return new u(e)})))||null,O.isGiftPackage=e.isGiftPackage||null,O.note=e.note||null,O.orderAdjustments=(null===(P=e.orderAdjustments)||void 0===P?void 0:P.map((function(e){return new a(e)})))||null,O.orderLineItems=(null===(j=e.orderLineItems)||void 0===j?void 0:j.map((function(e){return new r(e)})).filter((function(e){return!e.deleted})))||[],O.orderNumber=e.orderNumber||null,O.orderPackageStatus=e.orderPackageStatus||null,O.orderPackages=(null===(k=e.orderPackages)||void 0===k?void 0:k.map((function(e){return new s(e)})))||null,O.orderPaymentStatus=e.orderPaymentStatus||null,O.orderedAt=e.orderedAt||null,O.paymentMethods=(null===(A=e.paymentMethods)||void 0===A?void 0:A.map((function(e){return new l(e)})))||null,O.shippingAddress=e.shippingAddress?new t(e.shippingAddress):null,O.shippingLines=(null===(S=e.shippingLines)||void 0===S?void 0:S.map((function(e){return new n(e)})))||null,O.shippingMethod=e.shippingMethod||m.SHIPMENT,O.status=e.status||f.CREATED,O.taxLines=(null===(v=e.taxLines)||void 0===v?void 0:v.map((function(e){return new d(e)})))||null,O.totalFinalPrice=null!==(x=e.totalFinalPrice)&&void 0!==x?x:0,O.totalPrice=null!==(I=e.totalPrice)&&void 0!==I?I:0,O.refundSettings=e.refundSettings,p(O,{billingAddress:g,cancelReason:g,cancelledAt:g,currencyCode:g,currencySymbol:g,customer:g,customerId:g,giftPackageLines:g,giftPackageNote:g,invoices:g,isGiftPackage:g,note:g,orderAdjustments:g,orderLineItems:g,orderNumber:g,orderPackageStatus:g,orderPackages:g,orderPaymentStatus:g,orderedAt:g,paymentMethods:g,shippingAddress:g,shippingLines:g,shippingMethod:g,status:g,taxLines:g,totalFinalPrice:g,totalPrice:g,refundSettings:g,items:b,itemCount:b,refundableItems:b,unfullfilledItems:b,refundedItems:b,totalTax:b,formattedTotalTax:b,shippingTotal:b,formattedShippingTotal:b,formattedTotalFinalPrice:b,formattedTotalPrice:b,hasCustomer:b,hasValidCustomerEmail:b,customerFullName:b,formattedDate:b,couponAdjustment:b,nonCouponAdjustments:b}),O}return e(P,c),Object.defineProperty(P.prototype,"items",{get:function(){return this.orderLineItems},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"itemCount",{get:function(){var e;return(null===(e=this.items)||void 0===e?void 0:e.length)||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"itemQuantity",{get:function(){return this.items.reduce((function(e,t){return e+t.quantity}),0)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"refundableItems",{get:function(){return this.refundSettings?y.getRefundableItems(this,this.refundSettings):[]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"unfullfilledItems",{get:function(){return y.getUnfullfilledItems(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"refundedItems",{get:function(){return y.getRefundedItems(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"totalTax",{get:function(){return y.getTotalTax(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalTax",{get:function(){return h(this.totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"shippingTotal",{get:function(){return y.getShippingTotal(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedShippingTotal",{get:function(){return h(this.shippingTotal,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalFinalPrice",{get:function(){return h(this.totalFinalPrice,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalPrice",{get:function(){return h(this.totalPrice,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasCustomer",{get:function(){return y.hasCustomer(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasValidCustomerEmail",{get:function(){return y.hasValidCustomerEmail(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerFullName",{get:function(){return y.getCustomerFullName(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedDate",{get:function(){return y.getFormattedDate(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"couponAdjustment",{get:function(){return y.getCouponAdjustment(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"nonCouponAdjustments",{get:function(){return y.getNonCouponAdjustments(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRefundEnabled",{get:function(){return!this.refundableItems.some((function(e){return null===e.refundQuantity}))},enumerable:!1,configurable:!0}),P}(c);export{P as IkasOrder};
1
+ import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasOrderAddress as t}from"./address/index.js";import{IkasOrderShippingLine as n}from"./shipping-line/index.js";import{IkasOrderLineItem as r}from"./line-item/index.js";import{IkasOrderCustomer as o}from"./customer/index.js";import{IkasOrderGiftPackageLine as i}from"./gift-line/index.js";import{IkasInvoice as u}from"./invoice/index.js";import{IkasOrderPaymentMethod as l}from"./payment-method/index.js";import{IkasOrderAdjustment as s}from"./adjustment/index.js";import{IkasOrderPackage as a}from"./package/index.js";import{IkasOrderTaxLine as d}from"./tax-line/index.js";import{IkasBaseModel as c}from"../base/index.js";import{IkasOrderShippingMethod as m,IkasOrderStatus as p}from"@ikas/storefront-models";export{IkasOrderCancelReason,IkasOrderPackageStatus,IkasOrderPaymentStatus,IkasOrderShippingMethod,IkasOrderStatus}from"@ikas/storefront-models";import{makeObservable as f,observable as g,computed as b}from"mobx";import{IkasOrderFunctions as y}from"@ikas/storefront-model-functions";import{formatCurrency as h}from"../../../utils/currency.js";var P=function(c){function P(e,y){var h,P,j,A,k,v,S,x,I,O,C=this;(C=c.call(this,e)||this).billingAddress=null,C.cancelReason=null,C.cancelledAt=null,C.currencySymbol=null,C.customer=null,C.customerId=null,C.giftPackageLines=null,C.giftPackageNote=null,C.invoices=null,C.isGiftPackage=null,C.note=null,C.orderAdjustments=null,C.orderNumber=null,C.orderPackageStatus=null,C.orderPackages=null,C.orderPaymentStatus=null,C.orderedAt=null,C.paymentMethods=null,C.shippingAddress=null,C.shippingLines=null,C.taxLines=null,C.billingAddress=e.billingAddress?new t(e.billingAddress):null,C.cancelReason=e.cancelReason||null,C.cancelledAt=e.cancelledAt||null,C.currencyCode=e.currencyCode||"",C.currencySymbol=e.currencySymbol||null,C.customer=e.customer?new o(e.customer):null,C.customerId=e.customerId||null,C.giftPackageLines=(null===(h=e.giftPackageLines)||void 0===h?void 0:h.map((function(e){return new i(e)})))||null,C.giftPackageNote=e.giftPackageNote||null,C.invoices=(null===(P=e.invoices)||void 0===P?void 0:P.map((function(e){return new u(e)})))||null,C.isGiftPackage=e.isGiftPackage||null,C.note=e.note||null,C.orderAdjustments=(null===(j=e.orderAdjustments)||void 0===j?void 0:j.map((function(e){return new s(e)})))||null,C.orderLineItems=(null===(A=e.orderLineItems)||void 0===A?void 0:A.map((function(e){return new r(e)})).filter((function(e){return!e.deleted})))||[],C.orderNumber=e.orderNumber||null,C.orderPackageStatus=e.orderPackageStatus||null,C.orderPackages=(null===(k=e.orderPackages)||void 0===k?void 0:k.map((function(e){return new a(e)})))||null,C.orderPaymentStatus=e.orderPaymentStatus||null,C.orderedAt=e.orderedAt||null,C.paymentMethods=(null===(v=e.paymentMethods)||void 0===v?void 0:v.map((function(e){return new l(e)})))||null,C.shippingAddress=e.shippingAddress?new t(e.shippingAddress):null,C.shippingLines=(null===(S=e.shippingLines)||void 0===S?void 0:S.map((function(e){return new n(e)})))||null,C.shippingMethod=e.shippingMethod||m.SHIPMENT,C.status=e.status||p.CREATED,C.taxLines=(null===(x=e.taxLines)||void 0===x?void 0:x.map((function(e){return new d(e)})))||null,C.totalFinalPrice=null!==(I=e.totalFinalPrice)&&void 0!==I?I:0,C.totalPrice=null!==(O=e.totalPrice)&&void 0!==O?O:0,C.refundSettings=e.refundSettings;var T={billingAddress:g,cancelReason:g,cancelledAt:g,currencyCode:g,currencySymbol:g,customer:g,customerId:g,giftPackageLines:g,giftPackageNote:g,invoices:g,isGiftPackage:g,note:g,orderAdjustments:g,orderLineItems:g,orderNumber:g,orderPackageStatus:g,orderPackages:g,orderPaymentStatus:g,orderedAt:g,paymentMethods:g,shippingAddress:g,shippingLines:g,shippingMethod:g,status:g,taxLines:g,totalFinalPrice:g,totalPrice:g,refundSettings:g,items:b,itemCount:b,refundableItems:b,unfullfilledItems:b,refundedItems:b,totalTax:b,formattedTotalTax:b,shippingTotal:b,formattedShippingTotal:b,formattedTotalFinalPrice:b,formattedTotalPrice:b,hasCustomer:b,hasValidCustomerEmail:b,customerFullName:b,formattedDate:b,couponAdjustment:b,nonCouponAdjustments:b};return y&&(delete T.billingAddress,delete T.shippingAddress),f(C,T),C}return e(P,c),Object.defineProperty(P.prototype,"items",{get:function(){return this.orderLineItems},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"itemCount",{get:function(){var e;return(null===(e=this.items)||void 0===e?void 0:e.length)||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"itemQuantity",{get:function(){return this.items.reduce((function(e,t){return e+t.quantity}),0)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"refundableItems",{get:function(){return this.refundSettings?y.getRefundableItems(this,this.refundSettings):[]},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"unfullfilledItems",{get:function(){return y.getUnfullfilledItems(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"refundedItems",{get:function(){return y.getRefundedItems(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"totalTax",{get:function(){return y.getTotalTax(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalTax",{get:function(){return h(this.totalTax,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"shippingTotal",{get:function(){return y.getShippingTotal(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedShippingTotal",{get:function(){return h(this.shippingTotal,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalFinalPrice",{get:function(){return h(this.totalFinalPrice,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedTotalPrice",{get:function(){return h(this.totalPrice,this.currencyCode,this.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasCustomer",{get:function(){return y.hasCustomer(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasValidCustomerEmail",{get:function(){return y.hasValidCustomerEmail(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerFullName",{get:function(){return y.getCustomerFullName(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"formattedDate",{get:function(){return y.getFormattedDate(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"couponAdjustment",{get:function(){return y.getCouponAdjustment(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"nonCouponAdjustments",{get:function(){return y.getNonCouponAdjustments(this)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"isRefundEnabled",{get:function(){return!this.refundableItems.some((function(e){return null===e.refundQuantity}))},enumerable:!1,configurable:!0}),P}(c);export{P as IkasOrder};
@@ -1 +1 @@
1
- import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as r,observable as n,action as d}from"mobx";import a from"lodash/cloneDeep";import{Validator as o}from"../index.js";import{PhoneRule as u,RequiredRule as l}from"../rules/index.js";import{listCountry as c,listState as m,listCity as h,listDistrict as p}from"@ikas/storefront-api";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as g}from"../../../../utils/constants.js";import{IkasBaseStore as v}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import{IkasCustomerAddress as y}from"../../../data/customer/address/index.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(g){var b=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.validatorRules=function(e){return void 0===e&&(e=!1),t([new l({model:b.address,fieldKey:"firstName",valuePath:"firstName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"lastName",valuePath:"lastName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"addressLine1",valuePath:"addressLine1",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"country",valuePath:"country",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"state",valuePath:"state",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"city",valuePath:"city",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"title",valuePath:"title",message:b.message.requiredRule})],e?[new u({model:b.address,fieldKey:"phone",valuePath:"phone",message:b.message.phoneRule})]:[],!0)},this.onTitleChange=function(t){b.address.title=t},this.onFirstNameChange=function(t){b.address.firstName=t},this.onLastNameChange=function(t){b.address.lastName=t},this.onPhoneChange=function(t){b.address.phone=t,t||b.validator.setRules(b.validatorRules())},this.onAddressLine1Change=function(t){b.address.addressLine1=t},this.onAddressLine2Change=function(t){b.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){b.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=b.address.country)||void 0===e?void 0:e.id)!==t){var i=b.countries.find((function(e){return e.id===t}));b.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:null,iso3:null},b.address.state=null,b.address.city=null,b.address.district=null,b.states=[],b.cities=[],b.districts=[],b.listStates()}},this.onStateChange=function(t){var e;if((null===(e=b.address.state)||void 0===e?void 0:e.id)!==t){var i=b.states.find((function(e){return e.id===t}));b.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},b.address.city=null,b.address.district=null,b.cities=[],b.districts=[],b.listCities()}},this.onCityChange=function(t){var e;if((null===(e=b.address.city)||void 0===e?void 0:e.id)!==t){var i=b.cities.find((function(e){return e.id===t}));b.address.city={id:i.id,name:i.name,code:null},b.address.district=null,b.districts=[],b.listDistricts()}},this.onCityInputChange=function(t){b.districts=[],b.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=b.address.district)||void 0===e?void 0:e.id)!==t){var i=b.districts.find((function(e){return e.id===t}));b.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){b.address.district={id:null,name:t,code:null}},this.listCountries=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,c({})];case 1:return t=i.sent(),e=f.getCurrentRouting(),s=t.data||[],(null===(r=null==e?void 0:e.countryCodes)||void 0===r?void 0:r.length)&&(s=s.filter((function(t){var i;return t.iso2&&(null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return i.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,m({countryId:{eq:this.address.country.id}})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return i.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.state)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,h({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.cities=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.city)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,p({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.validateAll=function(){return b.validator.validateAll()},this.submit=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return t={isFormError:!1,isSuccess:!1},this.address.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(i.sent())return t.isFormError=!0,[2,t];if(!(e=a(v.getInstance().customerStore.customer))||!this.address)return[2,t];(null==e?void 0:e.addresses)||(e.addresses=[]),this.isEdit?e.addresses[this.editingAddressIndex]=this.address:e.addresses.push(this.address),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,v.getInstance().customerStore.saveCustomer(e)];case 3:return i.sent()&&(t.isSuccess=!0),[2,t];case 4:return i.sent(),[2,t];case 5:return[2]}}))}))},s(this,{hasValidatorError:r,isEdit:r,results:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:n,states:n,cities:n,districts:n,_isCountriesPending:n,_isStatesPending:n,_isCitiesPending:n,_isDistrictsPending:n,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:d,validateAll:d,submit:d}),this.address=g.address||new y({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=g.message,this.validator=new o(this.address,this.validatorRules()),this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){var t=this;return g.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=v.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasValidatorError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"results",{get:function(){return this.validator.results},enumerable:!1,configurable:!0}),x}();export{x as AddressForm};
1
+ import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as r,observable as n,action as d}from"mobx";import a from"lodash/cloneDeep";import{Validator as o}from"../index.js";import{PhoneRule as u,RequiredRule as l}from"../rules/index.js";import{listCountry as c,listState as m,listCity as h,listDistrict as p}from"@ikas/storefront-api";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as g}from"../../../../utils/constants.js";import{IkasBaseStore as v}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import{IkasCustomerAddress as y}from"../../../data/customer/address/index.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(g){var b=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.validatorRules=function(e){return void 0===e&&(e=!1),t([new l({model:b.address,fieldKey:"firstName",valuePath:"firstName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"lastName",valuePath:"lastName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"addressLine1",valuePath:"addressLine1",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"country",valuePath:"country",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"state",valuePath:"state",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"city",valuePath:"city",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"title",valuePath:"title",message:b.message.requiredRule})],e?[new u({model:b.address,fieldKey:"phone",valuePath:"phone",message:b.message.phoneRule})]:[],!0)},this.onTitleChange=function(t){b.address.title=t},this.onFirstNameChange=function(t){b.address.firstName=t},this.onLastNameChange=function(t){b.address.lastName=t},this.onPhoneChange=function(t){b.address.phone=t,t||b.validator.setRules(b.validatorRules())},this.onAddressLine1Change=function(t){b.address.addressLine1=t},this.onAddressLine2Change=function(t){b.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){b.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=b.address.country)||void 0===e?void 0:e.id)!==t){var i=b.countries.find((function(e){return e.id===t}));b.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},b.address.state=null,b.address.city=null,b.address.district=null,b.states=[],b.cities=[],b.districts=[],b.listStates()}},this.onStateChange=function(t){var e;if((null===(e=b.address.state)||void 0===e?void 0:e.id)!==t){var i=b.states.find((function(e){return e.id===t}));b.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},b.address.city=null,b.address.district=null,b.cities=[],b.districts=[],b.listCities()}},this.onCityChange=function(t){var e;if((null===(e=b.address.city)||void 0===e?void 0:e.id)!==t){var i=b.cities.find((function(e){return e.id===t}));b.address.city={id:i.id,name:i.name,code:null},b.address.district=null,b.districts=[],b.listDistricts()}},this.onCityInputChange=function(t){b.districts=[],b.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=b.address.district)||void 0===e?void 0:e.id)!==t){var i=b.districts.find((function(e){return e.id===t}));b.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){b.address.district={id:null,name:t,code:null}},this.listCountries=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,c({})];case 1:return t=i.sent(),e=f.getCurrentRouting(),s=t.data||[],(null===(r=null==e?void 0:e.countryCodes)||void 0===r?void 0:r.length)&&(s=s.filter((function(t){var i;return t.iso2&&(null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return i.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,m({countryId:{eq:this.address.country.id}})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return i.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.state)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,h({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.cities=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.city)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,p({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.validateAll=function(){return b.validator.validateAll()},this.submit=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return t={isFormError:!1,isSuccess:!1},this.address.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(i.sent())return t.isFormError=!0,[2,t];if(!(e=a(v.getInstance().customerStore.customer))||!this.address)return[2,t];(null==e?void 0:e.addresses)||(e.addresses=[]),this.isEdit?e.addresses[this.editingAddressIndex]=this.address:e.addresses.push(this.address),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,v.getInstance().customerStore.saveCustomer(e)];case 3:return i.sent()&&(t.isSuccess=!0),[2,t];case 4:return i.sent(),[2,t];case 5:return[2]}}))}))},s(this,{hasValidatorError:r,isEdit:r,results:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:n,states:n,cities:n,districts:n,_isCountriesPending:n,_isStatesPending:n,_isCitiesPending:n,_isDistrictsPending:n,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:d,validateAll:d,submit:d}),this.address=g.address||new y({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=g.message,this.validator=new o(this.address,this.validatorRules()),this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){var t=this;return g.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=v.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasValidatorError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"results",{get:function(){return this.validator.results},enumerable:!1,configurable:!0}),x}();export{x as AddressForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.1.14",
3
+ "version": "4.2.0-beta.1",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {},
20
20
  "devDependencies": {
21
- "@ikas/storefront-api": "^4.1.14",
22
- "@ikas/storefront-config": "^4.1.14",
23
- "@ikas/storefront-model-functions": "^4.1.14",
24
- "@ikas/storefront-models": "^4.1.14",
25
- "@ikas/storefront-providers": "^4.1.14",
21
+ "@ikas/storefront-api": "^4.2.0-beta.1",
22
+ "@ikas/storefront-config": "^4.2.0-beta.1",
23
+ "@ikas/storefront-model-functions": "^4.2.0-beta.1",
24
+ "@ikas/storefront-models": "^4.2.0-beta.1",
25
+ "@ikas/storefront-providers": "^4.2.0-beta.1",
26
26
  "@rollup/plugin-commonjs": "^22.0.0",
27
27
  "@rollup/plugin-json": "^4.1.0",
28
28
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "libphonenumber-js": "^1.10.6"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.1.14",
56
- "@ikas/storefront-config": "^4.1.14",
57
- "@ikas/storefront-model-functions": "^4.1.14",
58
- "@ikas/storefront-models": "^4.1.14",
59
- "@ikas/storefront-providers": "^4.1.14",
55
+ "@ikas/storefront-api": "^4.2.0-beta.1",
56
+ "@ikas/storefront-config": "^4.2.0-beta.1",
57
+ "@ikas/storefront-model-functions": "^4.2.0-beta.1",
58
+ "@ikas/storefront-models": "^4.2.0-beta.1",
59
+ "@ikas/storefront-providers": "^4.2.0-beta.1",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",