@ikas/storefront 6.1.0-beta.19 → 6.1.0-beta.190

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.
Files changed (170) hide show
  1. package/build/analytics/analytics.d.ts +3 -3
  2. package/build/analytics/analytics.js +1 -1
  3. package/build/analytics/googleAnalytics.js +1 -1
  4. package/build/analytics/googleTagManager.d.ts +3 -2
  5. package/build/analytics/googleTagManager.js +1 -1
  6. package/build/analytics/ikasV3.d.ts +6 -0
  7. package/build/analytics/ikasV3.js +1 -1
  8. package/build/components/checkout/components/address-form/index.js +1 -1
  9. package/build/components/checkout/components/address-form/model.d.ts +5 -0
  10. package/build/components/checkout/components/address-form/model.js +1 -1
  11. package/build/components/checkout/components/adyen/index.js +1 -1
  12. package/build/components/checkout/components/button/index.d.ts +1 -0
  13. package/build/components/checkout/components/button/index.js +1 -1
  14. package/build/components/checkout/components/button/style.module.scss.js +1 -1
  15. package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
  16. package/build/components/checkout/components/cart-summary/cart-item/style.module.scss.js +1 -1
  17. package/build/components/checkout/components/cart-summary/index.d.ts +2 -1
  18. package/build/components/checkout/components/cart-summary/index.js +1 -1
  19. package/build/components/checkout/components/cart-summary/style.module.scss.js +1 -1
  20. package/build/components/checkout/components/customer-addresses/index.d.ts +1 -0
  21. package/build/components/checkout/components/customer-addresses/index.js +1 -1
  22. package/build/components/checkout/components/error/stock-error/index.js +1 -1
  23. package/build/components/checkout/components/form-item/index.js +1 -1
  24. package/build/components/checkout/components/form-item/model.d.ts +5 -3
  25. package/build/components/checkout/components/form-item/model.js +1 -1
  26. package/build/components/checkout/components/form-item/style.module.scss.js +1 -1
  27. package/build/components/checkout/components/hepsipay/index.d.ts +9 -0
  28. package/build/components/checkout/components/hepsipay/index.js +1 -0
  29. package/build/components/checkout/components/input-with-button/style.module.scss.js +1 -1
  30. package/build/components/checkout/components/modal/index.d.ts +1 -0
  31. package/build/components/checkout/components/modal/index.js +1 -1
  32. package/build/components/checkout/components/modal/style.module.scss.js +1 -1
  33. package/build/components/checkout/components/offer-product/index.js +1 -1
  34. package/build/components/checkout/components/phone-number-input/index.d.ts +1 -1
  35. package/build/components/checkout/components/phone-number-input/index.js +1 -1
  36. package/build/components/checkout/components/quick-registration/completed.js +1 -1
  37. package/build/components/checkout/components/quick-registration/index.js +1 -1
  38. package/build/components/checkout/components/stripe/checkout-form.js +1 -1
  39. package/build/components/checkout/components/svg/coupon-code-tag.d.ts +6 -0
  40. package/build/components/checkout/components/svg/coupon-code-tag.js +1 -0
  41. package/build/components/checkout/components/svg/credit-balance.d.ts +6 -0
  42. package/build/components/checkout/components/svg/credit-balance.js +1 -0
  43. package/build/components/checkout/components/svg/gift-cart-tag.d.ts +6 -0
  44. package/build/components/checkout/components/svg/gift-cart-tag.js +1 -0
  45. package/build/components/checkout/components/svg/store-credit-tag.d.ts +6 -0
  46. package/build/components/checkout/components/svg/store-credit-tag.js +1 -0
  47. package/build/components/checkout/components/svg/subscription.d.ts +6 -0
  48. package/build/components/checkout/components/svg/subscription.js +1 -0
  49. package/build/components/checkout/index.js +1 -1
  50. package/build/components/checkout/model.d.ts +25 -6
  51. package/build/components/checkout/model.js +1 -1
  52. package/build/components/checkout/steps/step-info/index.js +1 -1
  53. package/build/components/checkout/steps/step-payment/billing-address/index.js +1 -1
  54. package/build/components/checkout/steps/step-payment/index.js +1 -1
  55. package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
  56. package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.d.ts +7 -0
  57. package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.js +1 -0
  58. package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/style.module.scss.js +1 -0
  59. package/build/components/checkout/steps/step-shipping/index.js +1 -1
  60. package/build/components/checkout/steps/step-success/index.js +1 -1
  61. package/build/components/image/index.d.ts +1 -0
  62. package/build/components/image/index.js +1 -1
  63. package/build/components/index.d.ts +2 -0
  64. package/build/components/page/head.js +1 -1
  65. package/build/components/page/index.d.ts +6 -0
  66. package/build/components/page/index.js +1 -1
  67. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  68. package/build/components/page-editor/model.js +1 -1
  69. package/build/components/paypal-express-checkout/index.d.ts +9 -0
  70. package/build/components/paypal-express-checkout/index.js +1 -0
  71. package/build/components/plain-image/index.d.ts +13 -0
  72. package/build/components/plain-image/index.js +1 -0
  73. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/formatIncompletePhoneNumber.js +1 -0
  74. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/getCountries.js +1 -0
  75. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/formatIncompletePhoneNumber.js +1 -0
  76. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountries.js +1 -0
  77. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountryCallingCode.js +1 -0
  78. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/isSupportedCountry.js +1 -0
  79. package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/parsePhoneNumber.js +1 -0
  80. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/ObserverComponent.js +1 -0
  81. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/index.js +1 -0
  82. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/observer.js +1 -0
  83. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/useObserver.js +1 -0
  84. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/UniversalFinalizationRegistry.js +1 -0
  85. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/assertEnvironment.js +1 -0
  86. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerBatching.js +1 -0
  87. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerFinalizationRegistry.js +1 -0
  88. package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/printDebugValue.js +1 -0
  89. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/checkbox-item-view/index.js +1 -1
  90. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/index.js +1 -1
  91. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/input-item-view/index.js +1 -1
  92. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/get-countries.js +1 -0
  93. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/index.js +1 -0
  94. package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/index.js +1 -1
  95. package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -1
  96. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/form-settings/index.js +1 -1
  97. package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js +1 -1
  98. package/build/hooks/useCustomerReviews.d.ts +2 -0
  99. package/build/hooks/useCustomerReviews.js +1 -1
  100. package/build/hooks/useStore.js +1 -1
  101. package/build/index.js +1 -1
  102. package/build/models/data/checkout-settings/index.d.ts +1 -0
  103. package/build/models/data/checkout-settings/index.js +1 -1
  104. package/build/models/data/customer/review/index.d.ts +4 -1
  105. package/build/models/data/customer/review/index.js +1 -1
  106. package/build/models/data/index.d.ts +1 -0
  107. package/build/models/data/order/gift-card-line/index.d.ts +2 -1
  108. package/build/models/data/order/gift-card-line/index.js +1 -1
  109. package/build/models/data/order/index.d.ts +1 -0
  110. package/build/models/data/order/index.js +1 -1
  111. package/build/models/data/order/line-item/bundle-product-settings/index.d.ts +7 -0
  112. package/build/models/data/order/line-item/bundle-product-settings/index.js +1 -0
  113. package/build/models/data/order/line-item/index.d.ts +4 -0
  114. package/build/models/data/order/line-item/index.js +1 -1
  115. package/build/models/data/order/line-item/order-line-item-subscription-plan/index.d.ts +8 -0
  116. package/build/models/data/order/line-item/order-line-item-subscription-plan/index.js +1 -0
  117. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.d.ts +6 -0
  118. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.js +1 -0
  119. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.d.ts +14 -0
  120. package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.js +1 -0
  121. package/build/models/data/order/order-transaction-with-prices/index.d.ts +1 -0
  122. package/build/models/data/order/order-transaction-with-prices/index.js +1 -1
  123. package/build/models/data/product/campaign-offer/index.d.ts +2 -0
  124. package/build/models/data/product/campaign-offer/index.js +1 -1
  125. package/build/models/data/product/filter/index.d.ts +2 -0
  126. package/build/models/data/product/filter/index.js +1 -1
  127. package/build/models/data/product/index.d.ts +8 -0
  128. package/build/models/data/product/index.js +1 -1
  129. package/build/models/data/product/translations/index.d.ts +7 -0
  130. package/build/models/data/product/translations/index.js +1 -0
  131. package/build/models/data/product/variant/bundle-settings/bundle-product/index.js +1 -1
  132. package/build/models/data/product/variant/index.d.ts +3 -0
  133. package/build/models/data/product/variant/index.js +1 -1
  134. package/build/models/data/product/variant/subscription-plan/index.d.ts +12 -0
  135. package/build/models/data/product/variant/subscription-plan/index.js +1 -0
  136. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-discount/index.d.ts +6 -0
  137. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.d.ts +23 -0
  138. package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.js +1 -0
  139. package/build/models/data/store-credit-balance/index.d.ts +26 -0
  140. package/build/models/data/store-credit-balance/index.js +1 -0
  141. package/build/models/data/theme-json/component/prop/index.d.ts +1 -0
  142. package/build/models/data/theme-json/component/prop/index.js +1 -1
  143. package/build/models/data/theme-json/custom-data/index.d.ts +1 -0
  144. package/build/models/data/theme-json/custom-data/index.js +1 -1
  145. package/build/models/ui/customer-review-list/index.d.ts +8 -0
  146. package/build/models/ui/customer-review-list/index.js +1 -1
  147. package/build/models/ui/product-list/index.d.ts +17 -0
  148. package/build/models/ui/product-list/index.js +1 -1
  149. package/build/models/ui/validator/form/login.d.ts +20 -6
  150. package/build/models/ui/validator/form/login.js +1 -1
  151. package/build/models/ui/validator/form/register.d.ts +15 -6
  152. package/build/models/ui/validator/form/register.js +1 -1
  153. package/build/pages/checkout.js +1 -1
  154. package/build/store/cart/index.d.ts +1 -0
  155. package/build/store/cart/index.js +1 -1
  156. package/build/store/checkout/index.d.ts +4 -1
  157. package/build/store/checkout/index.js +1 -1
  158. package/build/store/customer/api.d.ts +15 -2
  159. package/build/store/customer/api.js +1 -1
  160. package/build/store/customer/index.d.ts +40 -5
  161. package/build/store/customer/index.js +1 -1
  162. package/build/store/product/index.d.ts +1 -0
  163. package/build/utils/helper.d.ts +1 -0
  164. package/build/utils/helper.js +1 -1
  165. package/package.json +13 -12
  166. package/build/components/popup/index.js +0 -1
  167. package/build/components/popup/renderer/index.js +0 -1
  168. package/build/components/popup/renderer/model.js +0 -1
  169. package/build/components/popup/utils/index.js +0 -1
  170. package/build/store/storefront-popup/index.js +0 -1
@@ -0,0 +1,23 @@
1
+ import { IkasSubscriptionPlanDurationUnitType, IkasSubscriptionPlanPaymentType, IkasSubscriptionPlanStatus, IkasProductSubscriptionPlanPeriod as IProductSubscriptionPlanPeriod } from "@ikas/storefront-models";
2
+ import { IkasProductSubscriptionPlanDiscount } from "../product-subscription-plan-discount";
3
+ import { IkasProduct } from "../../..";
4
+ export declare class IkasProductSubscriptionPlanPeriod implements IProductSubscriptionPlanPeriod {
5
+ cutOffDay: number | null;
6
+ discount: IkasProductSubscriptionPlanDiscount | null;
7
+ durationUnit: IkasSubscriptionPlanDurationUnitType;
8
+ durationValue: number;
9
+ id: string;
10
+ maxOrders: number | null;
11
+ paymentType: IkasSubscriptionPlanPaymentType;
12
+ scheduledOrderDay: number | null;
13
+ status: IkasSubscriptionPlanStatus;
14
+ title: string;
15
+ isSelected: boolean;
16
+ product: IkasProduct | null;
17
+ constructor(data: IProductSubscriptionPlanPeriod);
18
+ get periodPrice(): number;
19
+ get formattedPeriodPrice(): string;
20
+ get totalPeriodPrice(): number;
21
+ get formattedTotalPeriodPrice(): string;
22
+ setProduct: (product: IkasProduct) => void;
23
+ }
@@ -0,0 +1 @@
1
+ import{IkasOrderAmountType as t,IkasSubscriptionPlanPaymentType as e}from"@ikas/storefront-models";import{makeAutoObservable as i}from"mobx";import{formatCurrency as r}from"../../../../../../utils/currency.js";var o=function(){function o(t){var e=this;this.isSelected=!1,this.product=null,this.setProduct=function(t){e.product=t,e.product.selectedVariantValues=e.product.variants[0].variantValues},this.cutOffDay=t.cutOffDay,this.discount=t.discount,this.durationUnit=t.durationUnit,this.durationValue=t.durationValue,this.id=t.id,this.maxOrders=t.maxOrders,this.paymentType=t.paymentType,this.scheduledOrderDay=t.scheduledOrderDay,this.status=t.status,this.title=t.title,this.isSelected=t.isSelected||!1,i(this)}return Object.defineProperty(o.prototype,"periodPrice",{get:function(){var e,i,r=null!==(i=null===(e=this.product)||void 0===e?void 0:e.selectedVariant.finalPrice)&&void 0!==i?i:0;return r-(this.discount?this.discount.type===t.AMOUNT?this.discount.amount:r*(this.discount.amount/100):0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedPeriodPrice",{get:function(){var t,e;return r(this.periodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"totalPeriodPrice",{get:function(){return this.periodPrice*(this.paymentType===e.POST_PAID?1:this.maxOrders||1)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedTotalPeriodPrice",{get:function(){var t,e;return r(this.totalPeriodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),o}();export{o as IkasProductSubscriptionPlanPeriod};
@@ -0,0 +1,26 @@
1
+ import { IkasStoreCreditBalance as IStoreCreditBalance } from "@ikas/storefront-models";
2
+ import { IkasStoreCredit as IStoreCredit } from "@ikas/storefront-models";
3
+ import { IkasStoreCreditSalesChannel as IStoreCreditSalesChannel, IkasStoreCreditType } from "@ikas/storefront-models";
4
+ export declare class IkasStoreCreditBalance implements IStoreCreditBalance {
5
+ amount: number;
6
+ storeCredits: IkasStoreCredit[];
7
+ constructor(data: IStoreCreditBalance);
8
+ }
9
+ export declare class IkasStoreCredit implements IStoreCredit {
10
+ usedAmount: number;
11
+ usedAllAmount: boolean | null;
12
+ type: IkasStoreCreditType;
13
+ salesChannels: IkasStoreCreditSalesChannel[];
14
+ minimumRequiredCartAmount: number | null;
15
+ customerId: string | null;
16
+ code: string;
17
+ amount: number;
18
+ active: boolean;
19
+ constructor(data: IStoreCredit);
20
+ }
21
+ export declare class IkasStoreCreditSalesChannel implements IStoreCreditSalesChannel {
22
+ salesChannelId: string;
23
+ storefrontId: string | null;
24
+ storefrontRoutingId: string | null;
25
+ constructor(data: IStoreCreditSalesChannel);
26
+ }
@@ -0,0 +1 @@
1
+ import{makeAutoObservable as t}from"mobx";var s=function(t){this.amount=t.amount,this.storeCredits=t.storeCredits.map((function(t){return new n(t)}))},n=function(s){this.usedAmount=s.usedAmount,this.usedAllAmount=s.usedAllAmount,this.type=s.type,this.salesChannels=s.salesChannels,this.minimumRequiredCartAmount=s.minimumRequiredCartAmount,this.customerId=s.customerId,this.code=s.code,this.amount=s.amount,this.active=s.active,t(this)},e=function(s){this.salesChannelId=s.salesChannelId,this.storefrontId=s.storefrontId,this.storefrontRoutingId=s.storefrontRoutingId,t(this)};export{n as IkasStoreCredit,s as IkasStoreCreditBalance,e as IkasStoreCreditSalesChannel};
@@ -18,6 +18,7 @@ export declare class IkasThemeJsonComponentProp implements IThemeJsonComponentPr
18
18
  };
19
19
  excludedFields?: string[] | null;
20
20
  excludedFieldsCategory?: string[] | null;
21
+ isFacetListNotSent?: boolean;
21
22
  constructor(data: Partial<IkasThemeJsonComponentProp>);
22
23
  }
23
24
  export { IkasThemeJsonComponentPropType };
@@ -1 +1 @@
1
- import{IkasThemeJsonComponentPropType as e}from"@ikas/storefront-models";export{IkasThemeJsonComponentPropType}from"@ikas/storefront-models";import{makeAutoObservable as t}from"mobx";var i=function(i){this.translations={},this.id=i.id||Date.now()+"",this.name=i.name||"",this.displayName=i.displayName||"",this.description=i.description||"",this.type=i.type||e.TEXT,this.isRequired=i.isRequired||!1,this.customDataId=i.customDataId||null,this.requiredPropId=i.requiredPropId,this.requiredEnumOptionId=i.requiredEnumOptionId,this.requiredEnumOptionValue=i.requiredEnumOptionValue,this.attributeTypes=i.attributeTypes||null,this.sliderData=i.sliderData||{},this.translations=i.translations||{},this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[],t(this)};export{i as IkasThemeJsonComponentProp};
1
+ import{IkasThemeJsonComponentPropType as t}from"@ikas/storefront-models";export{IkasThemeJsonComponentPropType}from"@ikas/storefront-models";import{makeAutoObservable as e}from"mobx";var i=function(i){this.translations={},this.id=i.id||Date.now()+"",this.name=i.name||"",this.displayName=i.displayName||"",this.description=i.description||"",this.type=i.type||t.TEXT,this.isRequired=i.isRequired||!1,this.customDataId=i.customDataId||null,this.requiredPropId=i.requiredPropId,this.requiredEnumOptionId=i.requiredEnumOptionId,this.requiredEnumOptionValue=i.requiredEnumOptionValue,this.attributeTypes=i.attributeTypes||null,this.sliderData=i.sliderData||{},this.translations=i.translations||{},this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[],this.isFacetListNotSent=i.isFacetListNotSent||!1,e(this)};export{i as IkasThemeJsonComponentProp};
@@ -21,6 +21,7 @@ export declare class IkasThemeJsonCustomData implements IThemeJsonCustomData {
21
21
  parent?: IkasThemeJsonCustomData | null;
22
22
  excludedFields?: string[] | null;
23
23
  excludedFieldsCategory?: string[] | null;
24
+ isFacetListNotSent?: boolean;
24
25
  constructor(data?: Partial<IkasThemeJsonCustomData>);
25
26
  get flat(): IkasThemeJsonCustomData[];
26
27
  toJSON(): this;
@@ -1 +1 @@
1
- import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import i from"lodash/flatten";import{IkasThemeJsonComponentPropType as e}from"@ikas/storefront-models";var s=function(){function s(i){void 0===i&&(i={});var a,l=this;this.translations={},this.customDataId=null,this.id=i.id||"",this.name=i.name||null,this.description=i.description||null,this.typescriptName=i.name||null,this.type=i.type||e.TEXT,this.isRequired=void 0===i.isRequired||i.isRequired,this.translations=i.translations||{},this.key=i.key||null,this.parent=i.parent||null,this.itemCount=i.itemCount||null,this.attributeTypes=i.attributeTypes||null,this.enumOptions=(null===(a=i.enumOptions)||void 0===a?void 0:a.map((function(t){return new n(t)})))||null,this.customDataId=i.customDataId||null,this.sliderData=i.sliderData||{},this.isRoot=i.isRoot||!1,this.nestedData=i.nestedData?i.nestedData.map((function(i){return new s(t(t({},i),{parent:l}))})):null,this.type!==e.STATIC_LIST||this.itemCount||(this.itemCount=1),this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[]}return Object.defineProperty(s.prototype,"flat",{get:function(){if(!this.nestedData||!this.nestedData.length)return[this];var t=i(this.nestedData.map((function(t){return t.flat}))),e=[];return e.push(this),e=e.concat(t)},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){var i=t({},this);return delete i.parent,i},s}(),n=function(t){void 0===t&&(t={}),this.translations={},this.id=t.id||"",this.displayName=t.displayName||"",this.value=t.value||"",this.translations=t.translations||{}},a=function(t){void 0===t&&(t={}),this.name=t.name||null,this.description=t.description||null},l=function(t){void 0===t&&(t={}),this.displayName=t.displayName||null};export{s as IkasThemeJsonCustomData,l as IkasThemeJsonCustomDataEnumOptionTranslation,a as IkasThemeJsonCustomDataTranslation,n as IkasThemeJsonEnumOption};
1
+ import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import i from"lodash/flatten";import{IkasThemeJsonComponentPropType as e}from"@ikas/storefront-models";var s=function(){function s(i){void 0===i&&(i={});var a,o=this;this.translations={},this.customDataId=null,this.id=i.id||"",this.name=i.name||null,this.description=i.description||null,this.typescriptName=i.name||null,this.type=i.type||e.TEXT,this.isRequired=void 0===i.isRequired||i.isRequired,this.translations=i.translations||{},this.key=i.key||null,this.parent=i.parent||null,this.itemCount=i.itemCount||null,this.attributeTypes=i.attributeTypes||null,this.enumOptions=(null===(a=i.enumOptions)||void 0===a?void 0:a.map((function(t){return new n(t)})))||null,this.customDataId=i.customDataId||null,this.sliderData=i.sliderData||{},this.isRoot=i.isRoot||!1,this.nestedData=i.nestedData?i.nestedData.map((function(i){return new s(t(t({},i),{parent:o}))})):null,this.type!==e.STATIC_LIST||this.itemCount||(this.itemCount=1),this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[],this.isFacetListNotSent=i.isFacetListNotSent||!1}return Object.defineProperty(s.prototype,"flat",{get:function(){if(!this.nestedData||!this.nestedData.length)return[this];var t=i(this.nestedData.map((function(t){return t.flat}))),e=[];return e.push(this),e=e.concat(t)},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){var i=t({},this);return delete i.parent,i},s}(),n=function(t){void 0===t&&(t={}),this.translations={},this.id=t.id||"",this.displayName=t.displayName||"",this.value=t.value||"",this.translations=t.translations||{}},a=function(t){void 0===t&&(t={}),this.name=t.name||null,this.description=t.description||null},o=function(t){void 0===t&&(t={}),this.displayName=t.displayName||null};export{s as IkasThemeJsonCustomData,o as IkasThemeJsonCustomDataEnumOptionTranslation,a as IkasThemeJsonCustomDataTranslation,n as IkasThemeJsonEnumOption};
@@ -9,6 +9,8 @@ export declare class IkasCustomerReviewList {
9
9
  private _productId?;
10
10
  private _hasImage?;
11
11
  private _productIds?;
12
+ private _locale?;
13
+ private _sortWithImagesFirst?;
12
14
  private _isLoading;
13
15
  constructor(data: IkasCustomerReviewListParams);
14
16
  get limit(): number;
@@ -21,6 +23,8 @@ export declare class IkasCustomerReviewList {
21
23
  get isLoading(): boolean;
22
24
  get hasImage(): boolean | undefined;
23
25
  get productIds(): string[] | null | undefined;
26
+ get locale(): string | undefined;
27
+ get sortWithImagesFirst(): boolean | undefined;
24
28
  private listCustomerReviews;
25
29
  getInitial: () => Promise<void>;
26
30
  getPrev: () => Promise<void>;
@@ -34,10 +38,13 @@ export declare class IkasCustomerReviewList {
34
38
  initialized: boolean;
35
39
  minPage: number | null | undefined;
36
40
  productId: string | null | undefined;
41
+ locale: string | undefined;
42
+ sortWithImagesFirst: boolean | undefined;
37
43
  };
38
44
  }
39
45
  export declare type IkasCustomerReviewListParams = {
40
46
  data?: IkasCustomerReview[];
47
+ locale?: string;
41
48
  limit?: number;
42
49
  page?: number;
43
50
  count?: number;
@@ -46,4 +53,5 @@ export declare type IkasCustomerReviewListParams = {
46
53
  productId?: string;
47
54
  productIds?: string[] | null;
48
55
  hasImage?: boolean;
56
+ sortWithImagesFirst?: boolean;
49
57
  };
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as r}from"mobx";import o from"../../../store/customer/api.js";import n from"../../../store/product/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"../../data/customer/address/region/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import{IkasCustomerReview as s}from"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../data/state/index.js";import"../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../data/storefront-popup/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var d=function(){function d(e){var a=this;this._initialized=!1,this._minPage=null,this._productId=null,this._hasImage=!1,this._productIds=null,this._isLoading=!1,this.getInitial=function(){return t(a,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page,this.limit,this.hasImage,this.productIds)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(a,void 0,void 0,(function(){var t,e,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviews(t,this.limit,this.hasImage,this.productIds)];case 2:return e=i.sent(),this.data=(null===(r=e.data)||void 0===r?void 0:r.data.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(a,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page+1,this.limit,this.hasImage,this.productIds)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(a,void 0,void 0,(function(){var t,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(e,this.limit,this.hasImage,this.productIds)];case 2:return t=i.sent(),this.data=(null===(r=t.data)||void 0===r?void 0:r.data)||[],this._count=(null===(o=t.data)||void 0===o?void 0:o.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new s(t)})):[],this._limit=e.limit||5,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._hasImage=e.hasImage||!1,this._minPage=e.minPage,this._productId=e.productId||null,this._productIds=e.productIds||null,r(this)}return Object.defineProperty(d.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasImage",{get:function(){return this._hasImage},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"productIds",{get:function(){return this._productIds},enumerable:!1,configurable:!0}),d.prototype.listCustomerReviews=function(r,s,d,u){var p,c,m;return t(this,void 0,void 0,(function(){var t,l,h;return i(this,(function(i){switch(i.label){case 0:return[4,o.listCustomerReviews(e(e(e({},this._productId?{productId:this._productId}:{}),{input:{salesChannelId:a.getSalesChannelId()||""},pagination:{page:r,limit:s},hasImage:d}),u?{productIds:u}:{}))];case 1:return t=i.sent(),!(null===(p=t.data)||void 0===p?void 0:p.data)||this._productId?[3,3]:(l=null===(c=null==t?void 0:t.data)||void 0===c?void 0:c.data.map((function(t){return null==t?void 0:t.productId})),[4,n.searchProducts({input:{productIdList:l}})]);case 2:h=i.sent(),t.data.data=null===(m=null==t?void 0:t.data)||void 0===m?void 0:m.data.map((function(t){var i,a,r=null===(a=null===(i=null==h?void 0:h.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.find((function(i){return i.id===t.productId}));return e(e({},t),{product:r})})).filter((function(t){return t.product&&!t.product.deleted})),i.label=3;case 3:return[2,t]}}))}))},d.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId}},d}();export{d as IkasCustomerReviewList};
1
+ import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as r}from"mobx";import o from"../../../store/customer/api.js";import s from"../../../store/product/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"../../data/customer/address/region/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import{IkasCustomerReview as n}from"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../data/state/index.js";import"../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../data/storefront-popup/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var d=function(){function d(e){var a,o=this;this._initialized=!1,this._minPage=null,this._productId=null,this._hasImage=!1,this._productIds=null,this._isLoading=!1,this.getInitial=function(){return t(o,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page,this.limit,this.hasImage,this.productIds,this.locale,this.sortWithImagesFirst)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(o,void 0,void 0,(function(){var t,e,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviews(t,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return e=i.sent(),this.data=(null===(r=e.data)||void 0===r?void 0:r.data.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(o,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page+1,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(o,void 0,void 0,(function(){var t,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(e,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return t=i.sent(),this.data=(null===(r=t.data)||void 0===r?void 0:r.data)||[],this._count=(null===(o=t.data)||void 0===o?void 0:o.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new n(t)})):[],this._limit=e.limit||5,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._hasImage=e.hasImage||!1,this._minPage=e.minPage,this._productId=e.productId||null,this._productIds=e.productIds||null,this._locale=e.locale||void 0,this._sortWithImagesFirst=null!==(a=e.sortWithImagesFirst)&&void 0!==a?a:void 0,r(this)}return Object.defineProperty(d.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasImage",{get:function(){return this._hasImage},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"productIds",{get:function(){return this._productIds},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"locale",{get:function(){return this._locale},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"sortWithImagesFirst",{get:function(){return this._sortWithImagesFirst},enumerable:!1,configurable:!0}),d.prototype.listCustomerReviews=function(r,n,d,u,p,c){var l,m,h;return void 0===c&&(c=!0),t(this,void 0,void 0,(function(){var t,g,f;return i(this,(function(i){switch(i.label){case 0:return[4,o.listCustomerReviews(e(e(e({},this._productId?{productId:this._productId}:{}),{input:{salesChannelId:a.getSalesChannelId()||""},pagination:{page:r,limit:n},hasImage:d,locale:p,sortWithImagesFirst:c}),u?{productIds:u}:{}))];case 1:return t=i.sent(),!(null===(l=t.data)||void 0===l?void 0:l.data)||this._productId?[3,3]:(g=null===(m=null==t?void 0:t.data)||void 0===m?void 0:m.data.map((function(t){return null==t?void 0:t.productId})),[4,s.searchProducts({input:{productIdList:g}})]);case 2:f=i.sent(),t.data.data=null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.data.map((function(t){var i,a,r=null===(a=null===(i=null==f?void 0:f.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.find((function(i){return i.id===t.productId}));return e(e({},t),{product:r})})).filter((function(t){return t.product&&!t.product.deleted})),i.label=3;case 3:return[2,t]}}))}))},d.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId,locale:this._locale,sortWithImagesFirst:this._sortWithImagesFirst}},d}();export{d as IkasCustomerReviewList};
@@ -13,6 +13,8 @@ export declare class IkasProductList {
13
13
  private _infiniteScrollPage;
14
14
  private _count;
15
15
  private _searchKeyword;
16
+ private _enableSuggestions?;
17
+ private _baseCategoryIdList;
16
18
  private _initialized;
17
19
  private _minPage?;
18
20
  private _productListPropValue;
@@ -27,17 +29,26 @@ export declare class IkasProductList {
27
29
  private _fetchRequestTime;
28
30
  private router?;
29
31
  private _excludedFields?;
32
+ private _isFacetListNotSent?;
30
33
  private _disabledSortTypes?;
34
+ private _suggestions?;
35
+ private _suggestionCategoryId;
31
36
  constructor(data: IkasProductListParams | IkasProductList, router?: NextRouter);
32
37
  get sort(): IkasProductListSortType;
33
38
  get limit(): number;
34
39
  get pageType(): IkasThemeJsonPageType;
35
40
  get page(): number;
36
41
  get minPage(): number;
42
+ get baseCategoryIdList(): string[] | null;
37
43
  get count(): number;
38
44
  get pageCount(): number;
39
45
  get searchKeyword(): string;
40
46
  set searchKeyword(value: string);
47
+ get enableSuggestions(): boolean | null | undefined;
48
+ set enableSuggestions(value: boolean | null | undefined);
49
+ get suggestions(): IkasSearchSuggestion[] | null | undefined;
50
+ get suggestionCategoryId(): string | null;
51
+ set suggestionCategoryId(value: string | null);
41
52
  get isInitialized(): boolean;
42
53
  get isFilterable(): boolean;
43
54
  get isFiltered(): boolean | undefined;
@@ -124,6 +135,7 @@ export declare type IkasProductListParams = {
124
135
  recommendedProductData?: IkasRecommendedProductProps | null;
125
136
  viewedTogetherProductData?: IkasViewedTogetherProductProps | null;
126
137
  excludedFields?: string[] | null;
138
+ isFacetListNotSent?: boolean;
127
139
  disabledSortTypes?: IkasProductListSortByTypeEnum[] | null;
128
140
  };
129
141
  export declare enum IkasProductListType {
@@ -167,3 +179,8 @@ export declare enum IkasRelatedProductsType {
167
179
  CATEGORY = "CATEGORY",
168
180
  BRAND = "BRAND"
169
181
  }
182
+ export declare type IkasSearchSuggestion = {
183
+ brandId: string | null;
184
+ categoryId: string | null;
185
+ term: string;
186
+ };
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";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{IkasThemeJsonPageType as o,IkasCategoryProductsOrderType as a,IkasThemeJsonStockPreference as n}from"@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"../../data/customer/address/region/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/region/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/order-transaction-with-prices/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{IkasProductFilter as c,IkasProductFilterValue as u}from"../../data/product/filter/index.js";import"../../data/product/campaign-offer/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/shipping-zone/state/city/district/region/index.js";import"../../data/state/index.js";import"../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../data/storefront-popup/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m,GetSuggestedProductsMethodEnum as g}from"@ikas/storefront-api";import{IkasStorefrontConfig as _}from"@ikas/storefront-config";import{Analytics as v}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import{stringToSlug as y,IkasProductVariantFunctions as E}from"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/ikas-address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import"../../../pages/account/activate.js";import{IkasBaseStore as I}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var S,C,P,T,A,D=function(){function S(a,n){var u=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this._recommendedProductData=null,this._viewedTogetherProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this._excludedFields=null,this._disabledSortTypes=null,this.applyFilters=function(){return t(u,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[o.CATEGORY,o.BRAND,o.SEARCH].includes(this._pageType)?(t&&this.setQueryParams(),[2]):[2]}}))}))},this.getSelectedVariant=function(t){return t.variants[0]},this.getInitial=function(r,s){return t(u,void 0,void 0,(function(){var t,o,a,n,d,c,u,p,h,f,m,g,_,v,y,S=this;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),o=s?this._page:1,a=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(o=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(o=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(o=1,a=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,I.getInstance().customerStore.getLastViewedProducts()];case 8:return(c=e.sent())&&c.length?(n=c.map((function(t){return t.productId})),d=I.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(p=I.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(o||1,a||10,n)];case 12:p=e.sent(),e.label=13;case 13:return(u=p)&&this._fetchRequestTime===t?(h=[],!d&&this.isLastViewed&&I.getInstance().customerStore.setSavedLastViewedProductsResponse(u),this.isStatic||this.isLastViewed?(f=this.isStatic?this._productListPropValue.productIds:I.getInstance().customerStore._lastViewedProducts,h=(null==f?void 0:f.map((function(t){var e,r,s=null===(r=null===(e=u.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),o=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)&&E.hasStock(o)||(o=null==s?void 0:s.variants.find((function(t){return t.isActive&&E.hasStock(t)}))),s&&o)return new l(i(i({},s),{selectedVariantValues:o.variantValues}))})).filter((function(t){return!!t})))||[]):h=(null===(_=null===(g=u.data)||void 0===g?void 0:g.data)||void 0===_?void 0:_.map((function(t){var e=S.getSelectedVariant(t);return new l(i(i({},t),{selectedVariantValues:e.variantValues}))})))||[],this.applyFacets(null===(v=u.data)||void 0===v?void 0:v.facets),this.data=h,this._count=(null===(y=u.data)||void 0===y?void 0:y.count)||0,this._initialized=!0,this._page=o||1,this._minPage=this.page,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return m=e.sent(),console.log(m),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n,d,c=this;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(a=r.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=c.getSelectedVariant(t);return new l(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n,d=this;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(a=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.map((function(t){var e=d.getSelectedVariant(t);return new l(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(u,void 0,void 0,(function(){var t,s,o,a,n,d,c=this;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=c.getSelectedVariant(t);return new l(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;u._infiniteScrollPage!==t&&(u._infiniteScrollPage=t,_.getIsEditor()||null===(e=u.router)||void 0===e||e.replace("".concat(location.pathname).concat(u.queryParams?"?"+u.queryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){u.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){v.search(u._searchKeyword,u.data.length)}),1e3);var p=a,h=a;if(this.data=a.data?a.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||C.ALL,this._pageType=a.pageType,this._sort=a.sort||a.productListPropValue.initialSort||P.LAST_ADDED,this._limit=a.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=a.page||1,this._minPage=a.minPage||null,this._count=a.count||0,this._searchKeyword=a.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._recommendedProductData=p.recommendedProductData||h._recommendedProductData||null,this._viewedTogetherProductData=p.viewedTogetherProductData||h._viewedTogetherProductData||null,this._excludedFields=p.excludedFields||h._excludedFields||null,this._disabledSortTypes=p.disabledSortTypes||h._disabledSortTypes||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=a.filters?a.filters.map((function(t){return new c(t,u)})):null,this._filterCategories=a.filterCategories?a.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.setIsFilteredForProducts(),this.setIsStaticForProducts(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===C.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(S.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFilterable",{get:function(){return this._type===C.ALL||this._type===C.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==o.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStatic",{get:function(){return this._type===C.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isDiscounted",{get:function(){return this._type===C.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommended",{get:function(){return this._type===C.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLastViewed",{get:function(){return this._type===C.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRelatedProducts",{get:function(){return this._type===C.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommendedProducts",{get:function(){return this._type===C.RECOMMENDED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isViewedTogetherProducts",{get:function(){return this._type===C.VIEWED_TOGETHER},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isSearch",{get:function(){return this._type===C.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"queryParams",{get:function(){var t,e,i,r,s=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[y(t.name)]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._sort&&(a.o=b[this._sort]),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==o.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))a.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(a.c=d)}}return h.stringify(a,{arrayFormat:"comma",encode:!1})},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[C.ALL,C.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"disabledSortTypes",{get:function(){return this._disabledSortTypes},enumerable:!1,configurable:!0}),S.prototype.setIsFilteredForProducts=function(){var t=this;this.data.forEach((function(e){return e.isFiltered=t.isFiltered||!1}))},S.prototype.setIsStaticForProducts=function(){var t=this;this.data.forEach((function(e){return e.isStatic=t.isStatic||!1}))},S.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[C.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=P.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=P.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=P.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=P.INCREASING_PRICE;break;case a.NEWEST:this._sort=P.LAST_ADDED;break;case a.OLDEST:this._sort=P.FIRST_ADDED;break;case a.MANUALLY:this._sort=P.FEATURED}},S.prototype.getSortParams=function(){var t,e;switch(this._sort){case P.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case P.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case P.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case P.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case P.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case P.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case P.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case P.DEFAULT:t=void 0,e=void 0;break;case P.AVERAGE_RATING:t=f.DESC,e=m.AVERAGE_RATING;break;case P.REVIEW_COUNT:t=f.DESC,e=m.REVIEW_COUNT;break;case P.SALE_COUNT:t=f.DESC,e=m.SALE_COUNT;break;case P.A_Z:t=f.ASC,e=m.NAME;break;case P.Z_A:t=f.DESC,e=m.NAME}if(t&&e)return{direction:t,type:e}},S.prototype.searchProducts=function(i,r,s){var a,d,c;return t(this,void 0,void 0,(function(){var t,l,h,f,m;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(a=this.filters)||void 0===a||a.forEach((function(e){e.valueList.length&&t.push(new u({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getSuggestedProducts({priceListId:_.getPriceListId(),salesChannelId:_.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:_.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:case 7:return[2,e.sent()];case 2:return this.isRecommendedProducts&&this._recommendedProductData?[4,p.getSuggestedProducts({priceListId:_.getPriceListId(),salesChannelId:_.getSalesChannelId(),brandIds:this._recommendedProductData.brandIds,categoryIds:this._recommendedProductData.categoryIds,locale:_.getCurrentLocale()})]:[3,4];case 4:return this.isViewedTogetherProducts&&this._viewedTogetherProductData?[4,p.getSuggestedProducts({priceListId:_.getPriceListId(),salesChannelId:_.getSalesChannelId(),method:g.VIEWED_TOGETHER,productIds:this._viewedTogetherProductData.productIds,locale:_.getCurrentLocale()})]:[3,6];case 6:return m={input:{page:i,perPage:r,productIdList:this.isStatic?null===(c=this._productListPropValue.productIds)||void 0===c?void 0:c.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===o.BRAND&&this._type!==C.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:_.getPriceListId(),salesChannelId:_.getSalesChannelId(),query:this._searchKeyword,order:f?[f]:[],showStockOption:_.getStockPreference()||n.SHOW_ALL}},[4,p.searchProducts(m,this._excludedFields)]}}))}))},S.prototype.getFilters=function(){var i,r,s,a;return t(this,void 0,void 0,(function(){var t,n,d=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:_.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new c(t,d)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this._disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,this.pageType!==o.CATEGORY&&this._filterCategoryId&&(n=null===(a=this._filterCategories)||void 0===a?void 0:a.find((function(t){return t.id===d._filterCategoryId})))&&(n.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},S.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e||t.name===e||y(t.name)===y(e)}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");r&&(this._searchKeyword=r);var s=null==t?void 0:t.get("o");if(s){var a=parseInt(s),n=Object.entries(b).find((function(t){return t[1]===a}));n&&(this._sort=n[0])}if(this._pageType!==o.CATEGORY){var d=null==t?void 0:t.get("c"),c=null==d?void 0:d.split(",");c&&c.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=c.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},S.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=o.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},S.prototype.setQueryParams=function(){var t;!this.isBrowser()||this.isSearch||_.getIsEditor()||null===(t=this.router)||void 0===t||t.replace("".concat(location.pathname).concat(this.queryParams?"?"+this.queryParams:""),void 0,{shallow:!0})},S.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==o.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},S.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent()&&this.setQueryParams(),[2]}}))}))},S.prototype.onFilterCategoryClick=function(i,r){var s,o;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:_.getIsEditor()||null===(o=I.getInstance().router)||void 0===o||o.push(i.href+(this.queryParams?"?"+this.queryParams:"")),t.label=3;case 3:return[2]}}))}))},S.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue}},S.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},S.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},S.prototype.isBrowser=function(){return"undefined"!=typeof window},S.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){I.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},S.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?v.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===C.ALL&&v.viewListing(this.data)},S}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS",t.VIEWED_TOGETHER="VIEWED_TOGETHER",t.RECOMMENDED_PRODUCTS="RECOMMENDED_PRODUCTS"}(C||(C={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT",t.AVERAGE_RATING="AVERAGE_RATING",t.REVIEW_COUNT="REVIEW_COUNT",t.SALE_COUNT="SALE_COUNT",t.A_Z="A_Z",t.Z_A="Z_A"}(P||(P={})),function(t){t.AVERAGE_RATING="AVERAGE_RATING",t.CREATED_AT="CREATED_AT",t.DISCOUNT_RATIO="DISCOUNT_RATIO",t.MANUAL_SORT="MANUAL_SORT",t.NAME="NAME",t.PRICE="PRICE",t.REVIEW_COUNT="REVIEW_COUNT",t.SALE_COUNT="SALE_COUNT"}(T||(T={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(A||(A={}));var b=((S={})[P.INCREASING_PRICE]=1,S[P.DECREASING_PRICE]=2,S[P.LAST_ADDED]=3,S[P.FIRST_ADDED]=4,S[P.INCREASING_DISCOUNT]=5,S[P.DECRASING_DISCOUNT]=6,S[P.FEATURED]=7,S[P.DEFAULT]=8,S[P.AVERAGE_RATING]=9,S[P.REVIEW_COUNT]=10,S[P.SALE_COUNT]=11,S[P.A_Z]=12,S[P.Z_A]=13,S);export{D as IkasProductList,T as IkasProductListSortByTypeEnum,P as IkasProductListSortType,C as IkasProductListType,A as IkasRelatedProductsType};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";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{IkasThemeJsonPageType as o,IkasCategoryProductsOrderType as a,IkasThemeJsonStockPreference as n,IkasProductFilterType as d,IkasProductFilterDisplayType as u}from"@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"../../data/customer/address/region/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as c}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/region/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/order-transaction-with-prices/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{IkasProductFilter as l,IkasProductFilterValue as p}from"../../data/product/filter/index.js";import"../../data/product/campaign-offer/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as h}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/shipping-zone/state/city/district/region/index.js";import"../../data/state/index.js";import"../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../data/storefront-popup/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";import g from"../../../store/product/index.js";import f from"query-string";import{SortByDirectionEnum as m,SortByTypeEnum as _,GetSuggestedProductsMethodEnum as y}from"@ikas/storefront-api";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{Analytics as I}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import{stringToSlug as E,IkasProductVariantFunctions as S}from"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../../../components/paypal-express-checkout/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/ikas-address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import"../../../pages/account/activate.js";import{IkasBaseStore as C}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var b,P,T,D,A,j=function(){function b(a,n){var d=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._enableSuggestions=null,this._baseCategoryIdList=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this._recommendedProductData=null,this._viewedTogetherProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this._excludedFields=null,this._isFacetListNotSent=!1,this._disabledSortTypes=null,this._suggestions=null,this._suggestionCategoryId=null,this.applyFilters=function(){return t(d,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[o.CATEGORY,o.BRAND,o.SEARCH].includes(this._pageType)?(t&&this.setQueryParams(),[2]):[2]}}))}))},this.getSelectedVariant=function(t){return t.variants[0]},this.getInitial=function(r,s){return t(d,void 0,void 0,(function(){var t,o,a,n,d,u,c,l,p,g,f,m,_,y,v,I,E=this;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),o=s?this._page:1,a=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(o=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(o=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(o=1,a=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,C.getInstance().customerStore.getLastViewedProducts()];case 8:return(u=e.sent())&&u.length?(n=u.map((function(t){return t.productId})),d=C.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(l=C.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(o||1,a||10,n)];case 12:l=e.sent(),e.label=13;case 13:return(c=l)&&this._fetchRequestTime===t?(p=[],!d&&this.isLastViewed&&C.getInstance().customerStore.setSavedLastViewedProductsResponse(c),this.isStatic||this.isLastViewed?(g=this.isStatic?this._productListPropValue.productIds:C.getInstance().customerStore._lastViewedProducts,p=(null==g?void 0:g.map((function(t){var e,r,s=null===(r=null===(e=c.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),o=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)&&S.hasStock(o)||(o=null==s?void 0:s.variants.find((function(t){return t.isActive&&S.hasStock(t)}))),s&&o)return new h(i(i({},s),{selectedVariantValues:o.variantValues}))})).filter((function(t){return!!t})))||[]):p=(null===(_=null===(m=c.data)||void 0===m?void 0:m.data)||void 0===_?void 0:_.map((function(t){var e=E.getSelectedVariant(t);return new h(i(i({},t),{selectedVariantValues:e.variantValues}))})))||[],this.applyFacets(null===(y=c.data)||void 0===y?void 0:y.facets),this.data=p,this._count=(null===(v=c.data)||void 0===v?void 0:v.count)||0,this._initialized=!0,this._page=o||1,this._minPage=this.page,this._suggestions=null===(I=c.data)||void 0===I?void 0:I.suggestions,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return f=e.sent(),console.log(f),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(d,void 0,void 0,(function(){var t,r,s,o,a,n,d,u=this;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(a=r.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=u.getSelectedVariant(t);return new h(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(d,void 0,void 0,(function(){var t,r,s,o,a,n,d=this;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(a=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.map((function(t){var e=d.getSelectedVariant(t);return new h(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(d,void 0,void 0,(function(){var t,s,o,a,n,d,u=this;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=u.getSelectedVariant(t);return new h(i(i({},t),{selectedVariantValues:e.variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;d._infiniteScrollPage!==t&&(d._infiniteScrollPage=t,v.getIsEditor()||null===(e=d.router)||void 0===e||e.replace("".concat(location.pathname).concat(d.queryParams?"?"+d.queryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){d.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){I.search(d._searchKeyword,d.data.length)}),1e3);var u=a,p=a;if(this.data=a.data?a.data.map((function(t){return new h(t)})):[],this._type=u.type||p._type||u.productListPropValue.productListType||p._productListPropValue.productListType||P.ALL,this._pageType=a.pageType,this._sort=a.sort||a.productListPropValue.initialSort||T.LAST_ADDED,this._limit=a.limit||u.productListPropValue.initialLimit||p._productListPropValue.initialLimit||20,this._page=a.page||1,this._minPage=a.minPage||null,this._count=a.count||0,this._searchKeyword=a.searchKeyword||"",this._productListPropValue=u.productListPropValue||p._productListPropValue,this._filterBrandId=u.filterBrandId||p._filterBrandId||null,this._filterCategoryId=u.filterCategoryId||p._filterCategoryId||null,this._relatedProductData=u.relatedProductData||p._relatedProductData||null,this._recommendedProductData=u.recommendedProductData||p._recommendedProductData||null,this._viewedTogetherProductData=u.viewedTogetherProductData||p._viewedTogetherProductData||null,this._excludedFields=u.excludedFields||p._excludedFields||null,this._isFacetListNotSent=u.isFacetListNotSent||p._isFacetListNotSent||!1,this._disabledSortTypes=u.disabledSortTypes||p._disabledSortTypes||null,this._recommendFor=u.recommendFor||p._recommendFor,this.filters=a.filters?a.filters.map((function(t){return new l(t,d)})):null,this._filterCategories=a.filterCategories?a.filterCategories.map((function(t){return new c(t)})):null,this.pageSpecificData=u.pageSpecificData||p.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.setIsFilteredForProducts(),this.setIsStaticForProducts(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===P.SEARCH)){var g=this.pageType===o.PRODUCT?void 0:this.getQueryParams();this.getInitial(g,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(b.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"baseCategoryIdList",{get:function(){return this._baseCategoryIdList},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"enableSuggestions",{get:function(){return this._enableSuggestions},set:function(t){this._enableSuggestions=t},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"suggestions",{get:function(){return this._suggestions},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"suggestionCategoryId",{get:function(){return this._suggestionCategoryId},set:function(t){this._suggestionCategoryId=t},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isFilterable",{get:function(){return this._type===P.ALL||this._type===P.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==o.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isStatic",{get:function(){return this._type===P.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isDiscounted",{get:function(){return this._type===P.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isRecommended",{get:function(){return this._type===P.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isLastViewed",{get:function(){return this._type===P.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isRelatedProducts",{get:function(){return this._type===P.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isRecommendedProducts",{get:function(){return this._type===P.RECOMMENDED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isViewedTogetherProducts",{get:function(){return this._type===P.VIEWED_TOGETHER},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isSearch",{get:function(){return this._type===P.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"queryParams",{get:function(){var t,e,i,r,s=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[E(t.name)]=t.isDiscountStatusFilter?t.keyList.map((function(e){return t.discountStatusMapping[e]})):t.keyList)})),this._searchKeyword&&(a.s=encodeURIComponent(this._searchKeyword)),this._sort&&(a.o=R[this._sort]),this._baseCategoryIdList&&(a.bc=this._baseCategoryIdList),this._suggestionCategoryId&&(a.suggestionCategoryId=this._suggestionCategoryId),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==o.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))a.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(a.c=d)}}return f.stringify(a,{arrayFormat:"comma",encode:!1})},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[P.ALL,P.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"disabledSortTypes",{get:function(){return this._disabledSortTypes},enumerable:!1,configurable:!0}),b.prototype.setIsFilteredForProducts=function(){var t=this;this.data.forEach((function(e){return e.isFiltered=t.isFiltered||!1}))},b.prototype.setIsStaticForProducts=function(){var t=this;this.data.forEach((function(e){return e.isStatic=t.isStatic||!1}))},b.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[P.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=T.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=T.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=T.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=T.INCREASING_PRICE;break;case a.NEWEST:this._sort=T.LAST_ADDED;break;case a.OLDEST:this._sort=T.FIRST_ADDED;break;case a.MANUALLY:this._sort=T.FEATURED}},b.prototype.getSortParams=function(){var t,e;switch(this._sort){case T.INCREASING_PRICE:t=m.ASC,e=_.PRICE;break;case T.DECREASING_PRICE:t=m.DESC,e=_.PRICE;break;case T.FIRST_ADDED:t=m.ASC,e=_.CREATED_AT;break;case T.LAST_ADDED:t=m.DESC,e=_.CREATED_AT;break;case T.INCREASING_DISCOUNT:t=m.ASC,e=_.DISCOUNT_RATIO;break;case T.DECRASING_DISCOUNT:t=m.DESC,e=_.DISCOUNT_RATIO;break;case T.FEATURED:if(this.isSearch)return;t=m.ASC,e=_.MANUAL_SORT;break;case T.DEFAULT:t=void 0,e=void 0;break;case T.AVERAGE_RATING:t=m.DESC,e=_.AVERAGE_RATING;break;case T.REVIEW_COUNT:t=m.DESC,e=_.REVIEW_COUNT;break;case T.SALE_COUNT:t=m.DESC,e=_.SALE_COUNT;break;case T.A_Z:t=m.ASC,e=_.NAME;break;case T.Z_A:t=m.DESC,e=_.NAME}if(t&&e)return{direction:t,type:e}},b.prototype.searchProducts=function(r,s,a){var c,l,h,f,m,_;return t(this,void 0,void 0,(function(){var t,I,E,S,C,b,T,D,A,j,R=this;return e(this,(function(e){switch(e.label){case 0:return t=[],I=[],null===(c=this.filters)||void 0===c||c.forEach((function(e){e.valueList.length&&t.push(new p({id:e.id,type:e.type,displayType:e.displayType,valueList:e.isDiscountStatusFilter?e.valueList.map((function(t){return e.discountStatusMapping[t]})):e.valueList})),e.isFacetFilter&&!R._isFacetListNotSent&&I.push({id:e.id,type:e.type,displayType:e.displayType})})),(E=null===(l=new URLSearchParams(location.search))||void 0===l?void 0:l.get("suggestion"))&&(S=JSON.parse(decodeURIComponent(E)),(C=S.brandId)&&((b=null===(h=this.filters)||void 0===h?void 0:h.find((function(t){return"brand"===t.id&&t.type===d.BRAND})))&&(T=null===(f=b.values)||void 0===f?void 0:f.find((function(t){return t.id===C})))&&b.applyQueryParam(T.name),t.push(new p({id:"brand",type:d.BRAND,displayType:u.BOX,valueList:[C]}))),S.categoryId&&(this._filterCategoryId=S.categoryId),this._searchKeyword=""),D=null===(m=this._filterCategories)||void 0===m?void 0:m.filter((function(t){return t.isSelected})).map((function(t){return t.id})),A=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,g.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:v.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:case 7:return[2,e.sent()];case 2:return this.isRecommendedProducts&&this._recommendedProductData?[4,g.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),brandIds:this._recommendedProductData.brandIds,categoryIds:this._recommendedProductData.categoryIds,locale:v.getCurrentLocale()})]:[3,4];case 4:return this.isViewedTogetherProducts&&this._viewedTogetherProductData?[4,g.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),method:y.VIEWED_TOGETHER,productIds:this._viewedTogetherProductData.productIds,locale:v.getCurrentLocale()})]:[3,6];case 6:return j={input:i(i(i(i({page:r,perPage:s},this.enableSuggestions?{enableSuggestions:this.enableSuggestions}:{}),{productIdList:this.isStatic?null===(_=this._productListPropValue.productIds)||void 0===_?void 0:_.map((function(t){return t.productId})):a,filterList:t,facetList:I}),this.baseCategoryIdList?{baseCategoryIdList:this.baseCategoryIdList}:{}),{brandId:this._pageType===o.BRAND&&this._type!==P.SEARCH?this._filterBrandId:void 0,categoryIdList:D&&D.length?D:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),query:this._searchKeyword,order:A?[A]:[],showStockOption:v.getStockPreference()||n.SHOW_ALL})},[4,g.searchProducts(j,this._excludedFields)]}}))}))},b.prototype.getFilters=function(){var i,r,s,a;return t(this,void 0,void 0,(function(){var t,n,d=this;return e(this,(function(e){switch(e.label){case 0:return[4,g.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:v.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new l(t,d)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this._disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,this.pageType!==o.CATEGORY&&this._filterCategoryId&&(n=null===(a=this._filterCategories)||void 0===a?void 0:a.find((function(t){return t.id===d._filterCategoryId})))&&(n.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},b.prototype.applyQueryParamFilters=function(t){var e,i,r=this;try{null==t||t.forEach((function(t,e){var i,s=null===(i=r.filters)||void 0===i?void 0:i.find((function(t){return t.key===e||t.name===e||E(t.name)===E(e)}));s&&s.applyQueryParam(t)}));var s=null==t?void 0:t.get("s");s&&(this._searchKeyword=s);var a=null==t?void 0:t.get("o");if(a){var n=parseInt(a),d=Object.entries(R).find((function(t){return t[1]===n}));d&&(this._sort=d[0])}if(this._pageType!==o.CATEGORY){var u=null==t?void 0:t.get("c"),c=null==u?void 0:u.split(",");c&&c.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=c.some((function(e){return e===t.slug}))})))}if(this._pageType===o.SEARCH){var l=null==t?void 0:t.get("bc"),p=null==l?void 0:l.split(",");p&&(this._baseCategoryIdList=p);var h=null===(i=new URLSearchParams(location.search))||void 0===i?void 0:i.get("suggestion");if(h){var g=JSON.parse(decodeURIComponent(h)).categoryId;g&&(this.suggestionCategoryId=g)}var f=null==t?void 0:t.get("suggestionCategoryId");f&&(this.suggestionCategoryId=f,this._filterCategoryId=f,this._searchKeyword="")}}catch(t){console.log(t)}},b.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=e.isDiscountStatusFilter?e.discountStatusMapping[t.id]:t.id,r=o.values.find((function(t){return t.id===i}));r?t.resultCount=r.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},b.prototype.setQueryParams=function(){var t;!this.isBrowser()||this.isSearch||v.getIsEditor()||null===(t=this.router)||void 0===t||t.replace("".concat(location.pathname).concat(this.queryParams?"?"+this.queryParams:""),void 0,{shallow:!0})},b.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==o.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},b.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent()&&this.setQueryParams(),[2]}}))}))},b.prototype.onFilterCategoryClick=function(i,r){var s,o;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:v.getIsEditor()||null===(o=C.getInstance().router)||void 0===o||o.push(i.href+(this.queryParams?"?"+this.queryParams:"")),t.label=3;case 3:return[2]}}))}))},b.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue}},b.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},b.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},b.prototype.isBrowser=function(){return"undefined"!=typeof window},b.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){C.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},b.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?I.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===P.ALL&&I.viewListing(this.data)},b}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS",t.VIEWED_TOGETHER="VIEWED_TOGETHER",t.RECOMMENDED_PRODUCTS="RECOMMENDED_PRODUCTS"}(P||(P={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT",t.AVERAGE_RATING="AVERAGE_RATING",t.REVIEW_COUNT="REVIEW_COUNT",t.SALE_COUNT="SALE_COUNT",t.A_Z="A_Z",t.Z_A="Z_A"}(T||(T={})),function(t){t.AVERAGE_RATING="AVERAGE_RATING",t.CREATED_AT="CREATED_AT",t.DISCOUNT_RATIO="DISCOUNT_RATIO",t.MANUAL_SORT="MANUAL_SORT",t.NAME="NAME",t.PRICE="PRICE",t.REVIEW_COUNT="REVIEW_COUNT",t.SALE_COUNT="SALE_COUNT"}(D||(D={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(A||(A={}));var R=((b={})[T.INCREASING_PRICE]=1,b[T.DECREASING_PRICE]=2,b[T.LAST_ADDED]=3,b[T.FIRST_ADDED]=4,b[T.INCREASING_DISCOUNT]=5,b[T.DECRASING_DISCOUNT]=6,b[T.FEATURED]=7,b[T.DEFAULT]=8,b[T.AVERAGE_RATING]=9,b[T.REVIEW_COUNT]=10,b[T.SALE_COUNT]=11,b[T.A_Z]=12,b[T.Z_A]=13,b);export{j as IkasProductList,D as IkasProductListSortByTypeEnum,T as IkasProductListSortType,P as IkasProductListType,A as IkasRelatedProductsType};
@@ -1,4 +1,5 @@
1
1
  import { LoginResponseErrorCode } from "../../../../store/customer";
2
+ import { EmailRule, MinRule, RequiredRule, PhoneRule } from "../rules";
2
3
  declare type LoginFormProps<T> = {
3
4
  message: {
4
5
  requiredRule: ((model: T) => string) | string;
@@ -7,23 +8,34 @@ declare type LoginFormProps<T> = {
7
8
  };
8
9
  };
9
10
  declare type LoginFormModel = {
10
- email: string;
11
- password: string;
11
+ email?: string;
12
+ password?: string;
13
+ isSmsLogin?: boolean;
14
+ phone?: string | null;
12
15
  };
13
16
  export declare class LoginForm {
14
17
  private model;
15
18
  private validator;
19
+ private message;
16
20
  constructor(props: LoginFormProps<LoginFormModel>);
21
+ validatorRules: (includePhoneRule?: boolean) => (RequiredRule<LoginFormModel> | EmailRule<LoginFormModel> | MinRule<LoginFormModel> | PhoneRule<LoginFormModel>)[];
22
+ get phone(): string | null | undefined;
23
+ set phone(value: string | null | undefined);
17
24
  get hasError(): boolean;
18
- get email(): string;
19
- set email(value: string);
20
- get password(): string;
21
- set password(value: string);
25
+ get email(): string | undefined;
26
+ set email(value: string | undefined);
27
+ get password(): string | undefined;
28
+ set password(value: string | undefined);
22
29
  get emailErrorMessage(): string | undefined;
23
30
  get passwordErrorMessage(): string | undefined;
31
+ get phoneErrorMessage(): string | undefined;
32
+ get isSmsLogin(): boolean | undefined;
33
+ set isSmsLogin(value: boolean | undefined);
24
34
  get redirect(): string | null | undefined;
25
35
  onEmailChange: (value: string) => void;
26
36
  onPasswordChange: (value: string) => void;
37
+ onSmsLoginChange: (value: boolean, flowId?: string | null) => void;
38
+ onPhoneChange: (value: string) => void;
27
39
  validateAll(): Promise<boolean>;
28
40
  login(): Promise<LoginResponse>;
29
41
  }
@@ -31,5 +43,7 @@ declare type LoginResponse = {
31
43
  isFormError: boolean;
32
44
  isSuccess: boolean;
33
45
  errorCodes: LoginResponseErrorCode[];
46
+ otpSend: boolean;
47
+ flowId: string | null;
34
48
  };
35
49
  export {};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as r}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as t,observable as o,action as i}from"mobx";import{Validator as a}from"../index.js";import{IkasBaseStore as n}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{RequiredRule as l,EmailRule as u,MinRule as d}from"../rules/index.js";var m=function(){function m(e){var r=this;this.model={email:"",password:""},this.onEmailChange=function(e){r.email=e},this.onPasswordChange=function(e){r.password=e},s(this,{emailErrorMessage:t,passwordErrorMessage:t,hasError:t,redirect:t,email:t,password:t,model:o,validateAll:i,login:i}),this.validator=new a(this.model,[new l({fieldKey:"email",valuePath:"email",message:e.message.requiredRule}),new l({fieldKey:"password",valuePath:"password",message:e.message.requiredRule}),new u({fieldKey:"email",valuePath:"email",message:e.message.emailRule}),new d({fieldKey:"password",valuePath:"password",minValue:6,message:e.message.minRule})])}return Object.defineProperty(m.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),m.prototype.validateAll=function(){return this.validator.validateAll()},m.prototype.login=function(){return e(this,void 0,void 0,(function(){var e,s;return r(this,(function(r){switch(r.label){case 0:return e={isFormError:!1,isSuccess:!1,errorCodes:[]},[4,this.validateAll()];case 1:if(r.sent())return e.isFormError=!0,[2,e];r.label=2;case 2:return r.trys.push([2,4,,5]),[4,n.getInstance().customerStore.customerLogin(this.model.email,this.model.password)];case 3:return s=r.sent(),e.isSuccess=s.isSuccess,e.errorCodes=s.errorCodes,[2,e];case 4:return r.sent(),[2,e];case 5:return[2]}}))}))},m}();export{m as LoginForm};
1
+ import{__awaiter as e,__generator as r,__spreadArray as o}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as t,observable as i,action as n}from"mobx";import{Validator as a}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as u,RequiredRule as d,EmailRule as m,MinRule as p}from"../rules/index.js";var h=function(){function h(e){var r=this;this.model={email:"",password:"",isSmsLogin:!1,phone:null},this.validatorRules=function(e){return void 0===e&&(e=!1),o([new d({fieldKey:"email",valuePath:"email",message:r.message.requiredRule}),new d({fieldKey:"password",valuePath:"password",message:r.message.requiredRule}),new m({fieldKey:"email",valuePath:"email",message:r.message.emailRule}),new p({fieldKey:"password",valuePath:"password",minValue:6,message:r.message.minRule})],e?[new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})]:[],!0)},this.onEmailChange=function(e){r.email=e},this.onPasswordChange=function(e){r.password=e},this.onSmsLoginChange=function(e,s){e?(r.validator.setRules(o(o([new d({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule}),new u({fieldKey:"phone",valuePath:"phone",message:r.message.phoneRule})],s?[new d({fieldKey:"email",valuePath:"email",message:r.message.requiredRule})]:[],!0),s?[new m({fieldKey:"email",valuePath:"email",message:r.message.emailRule})]:[],!0)),r.model.email=void 0,r.model.password=void 0):r.validator.setRules(r.validatorRules()),r.isSmsLogin=e},this.onPhoneChange=function(e){r.phone=e},s(this,{emailErrorMessage:t,passwordErrorMessage:t,hasError:t,redirect:t,email:t,password:t,model:i,validateAll:n,login:n,phoneErrorMessage:t}),this.message=e.message,this.validator=new a(this.model,this.validatorRules())}return Object.defineProperty(h.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isSmsLogin",{get:function(){return this.model.isSmsLogin},set:function(e){this.model.isSmsLogin=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),h.prototype.validateAll=function(){return this.validator.validateAll()},h.prototype.login=function(){return e(this,void 0,void 0,(function(){var e,o;return r(this,(function(r){switch(r.label){case 0:return e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},[4,this.validateAll()];case 1:if(r.sent())return e.isFormError=!0,[2,e];r.label=2;case 2:return r.trys.push([2,4,,5]),[4,l.getInstance().customerStore.customerLogin(this.model.email,this.model.password,this.isSmsLogin?this.model.phone:void 0)];case 3:return o=r.sent(),e.isSuccess=o.isSuccess,e.errorCodes=o.errorCodes,e.otpSend=o.otpSend||!1,e.flowId=o.flowId||null,[2,e];case 4:return r.sent(),[2,e];case 5:return[2]}}))}))},h}();export{h as LoginForm};
@@ -12,11 +12,13 @@ declare type RegisterFormProps<T> = {
12
12
  declare type RegisterFormModel = {
13
13
  firstName: string;
14
14
  lastName: string;
15
- email: string;
16
- password: string;
15
+ email?: string;
16
+ password?: string;
17
17
  attributes?: IkasCustomerAttributeValue[];
18
18
  isMarketingAccepted?: boolean;
19
19
  phone?: string | null;
20
+ isSmsRegister?: boolean;
21
+ flowId?: string | null;
20
22
  };
21
23
  declare type AttributeValue = {
22
24
  isChecked?: boolean;
@@ -44,12 +46,16 @@ export declare class RegisterForm {
44
46
  set firstName(value: string);
45
47
  get lastName(): string;
46
48
  set lastName(value: string);
47
- get email(): string;
48
- set email(value: string);
49
- get password(): string;
50
- set password(value: string);
49
+ get email(): string | undefined;
50
+ set email(value: string | undefined);
51
+ get password(): string | undefined;
52
+ set password(value: string | undefined);
51
53
  get isMarketingAccepted(): boolean | undefined;
52
54
  set isMarketingAccepted(value: boolean | undefined);
55
+ get flowId(): string | null | undefined;
56
+ set flowId(value: string | null | undefined);
57
+ get isSmsRegister(): boolean | undefined;
58
+ set isSmsRegister(value: boolean | undefined);
53
59
  get phone(): string | null | undefined;
54
60
  set phone(value: string | null | undefined);
55
61
  get hasError(): boolean;
@@ -67,6 +73,7 @@ export declare class RegisterForm {
67
73
  onEmailChange: (value: string) => void;
68
74
  onPasswordChange: (value: string) => void;
69
75
  onPhoneChange: (value: string) => void;
76
+ onSmsRegisterChange: (isSmsRegister: boolean, flowId?: string | null) => void;
70
77
  setCustomerAttributes: (customerAttributes: IkasCustomerAttribute[]) => void;
71
78
  private getAttributeValue;
72
79
  onAttributeChange: (attributeId: string, value: boolean | string | string[]) => void;
@@ -75,6 +82,8 @@ export declare class RegisterForm {
75
82
  validateAll(): Promise<boolean | undefined>;
76
83
  register(): Promise<{
77
84
  isSuccess: boolean;
85
+ flowId: string | null;
86
+ otpSend: boolean;
78
87
  errorCodes: import("@ikas/storefront-api").IkasRegisterError[];
79
88
  isFormError: boolean;
80
89
  }>;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as o,observable as s,action as n}from"mobx";import d from"lodash/toNumber";import{Validator as u}from"../index.js";import{IkasBaseStore as m}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as l,RequiredRule as p,EmailRule as c,MinRule as f}from"../rules/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{IkasCustomerAttributeType as b,IkasCustomerAttributeRegisterPageRequirement as h}from"@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"../../../data/customer/address/region/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../../data/state/index.js";import"../../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../data/storefront-popup/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var g=function(){function g(t){var e=this;this.model={firstName:"",lastName:"",email:"",password:"",attributes:void 0,isMarketingAccepted:!1,phone:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(t){return void 0===t&&(t=!1),r([new p({fieldKey:"firstName",valuePath:"firstName",message:e.message.requiredRule}),new p({fieldKey:"lastName",valuePath:"lastName",message:e.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:e.message.requiredRule}),new p({fieldKey:"password",valuePath:"password",message:e.message.requiredRule}),new c({fieldKey:"email",valuePath:"email",message:e.message.emailRule}),new f({fieldKey:"password",valuePath:"password",minValue:6,message:e.message.minRule})],t?[new l({fieldKey:"phone",valuePath:"phone",message:e.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(t){e.firstName=t},this.onLastNameChange=function(t){e.lastName=t},this.onEmailChange=function(t){e.email=t},this.onPasswordChange=function(t){e.password=t},this.onPhoneChange=function(t){e.phone=t},this.setCustomerAttributes=function(t){e._customerAttributes=(null==t?void 0:t.filter((function(t){return t.registerPageRequirement!==h.INVISIBLE})).map((function(t){return{attribute:t,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:t.registerPageRequirement===h.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(t,r){var i;if(e._customerAttributes){var a=e._customerAttributes.find((function(e){return e.attribute.id===t}));if(a){var o=null===(i=e._customerAttributes)||void 0===i?void 0:i.findIndex((function(e){return e.attribute.id===t}));void 0!==o&&-1!==o&&(e._customerAttributes[o].attributeValue=e.getAttributeValue(a.attribute,r),e.validateCustomerAttribute())}}},a(this,{emailErrorMessage:o,passwordErrorMessage:o,firstNameErrorMessage:o,lastNameErrorMessage:o,phoneErrorMessage:o,hasError:o,redirect:o,model:s,validateAll:n,register:n,customerAttributes:o,_customerAttributes:s}),this.message=t.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(g.prototype,"firstName",{get:function(){return this.model.firstName},set:function(t){this.model.firstName=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastName",{get:function(){return this.model.lastName},set:function(t){this.model.lastName=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"email",{get:function(){return this.model.email},set:function(t){this.model.email=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"password",{get:function(){return this.model.password},set:function(t){this.model.password=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(t){this.model.isMarketingAccepted=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phone",{get:function(){return this.model.phone},set:function(t){this.model.phone=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phoneErrorMessage",{get:function(){var t;return null===(t=this.validator.results.phone)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"attributes",{get:function(){return this.model.attributes},set:function(t){this.model.attributes=t},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),g.prototype.getAttributeValue=function(t,e){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};return"string"!=typeof e||t.type!==b.TEXT&&t.type!==b.DATETIME&&t.type!==b.DATE&&t.type!==b.CHOICE||(r.value=e),"string"==typeof e&&t.type===b.NUMERIC&&(Number.isInteger(d(e))?r.value=e:r.value=e.slice(0,-1)),"boolean"==typeof e&&t.type===b.BOOLEAN&&(r.isChecked=e),"object"==typeof e&&t.type===b.MULTIPLE_CHOICE&&(r.selectedIdList=e),r},Object.defineProperty(g.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(t){return void 0!==t.attributeValue.value||void 0!==t.attributeValue.isChecked||void 0!==t.attributeValue.selectedIdList})))return null;var t=[];return this._customerAttributes.map((function(e){var r=e.attributeValue,i=r.selectedIdList,a=r.isChecked,o=r.value;void 0!==i&&b.MULTIPLE_CHOICE&&i.map((function(r){t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:r,value:null})})),e.attribute.type===b.BOOLEAN&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==o&&(e.attribute.type!==b.TEXT&&e.attribute.type!==b.NUMERIC||t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:o.toString()}),e.attribute.type===b.CHOICE&&t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:o,value:null}),e.attribute.type!==b.DATETIME&&e.attribute.type!==b.DATE||t.push({customerAttributeId:e.attribute.id,customerAttributeOptionId:null,value:new Date(o).getTime().toString()}))})),t},enumerable:!1,configurable:!0}),g.prototype.validateCustomerAttribute=function(){var t,e=this;this._customerAttributes=null===(t=this._customerAttributes)||void 0===t?void 0:t.map((function(t){var r;return t.validator.isRequired&&e.isFormSubmit&&(t.attribute.type===b.BOOLEAN||t.attributeValue.value||(null===(r=t.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(t.validator.hasError=!1,t.validator.message=""):(t.validator.hasError=!0,t.validator.message="string"==typeof e.message.requiredRule?e.message.requiredRule:e.message.requiredRule(e.model))),t}))},g.prototype.validateAll=function(){var r;return t(this,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return t=e.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(t){return t.validator.hasError})),[2,t||i]}}))}))},g.prototype.register=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this.isFormSubmit=!0,t={isFormError:!1,isSuccess:!1,errorCodes:[]},this.email&&(this.email=this.email.trim()),this.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(e.sent())return t.isFormError=!0,[2,t];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,m.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0,this.model.phone)];case 3:return r=e.sent(),[2,i(i({},t),r)];case 4:return e.sent(),[2,t];case 5:return[2]}}))}))},g}();export{g as RegisterForm};
1
+ import{__awaiter as e,__generator as t,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as o,observable as s,action as n}from"mobx";import d from"lodash/toNumber";import{Validator as u}from"../index.js";import{IkasBaseStore as l}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as m,RequiredRule as p,EmailRule as c,MinRule as f}from"../rules/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{IkasCustomerAttributeType as g,IkasCustomerAttributeRegisterPageRequirement as h}from"@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"../../../data/customer/address/region/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/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/region/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/order-transaction-with-prices/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/campaign-offer/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../../data/state/index.js";import"../../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../../data/storefront-popup/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var b=function(){function b(e){var t=this;this.model={firstName:"",lastName:"",email:void 0,password:void 0,attributes:void 0,isMarketingAccepted:!1,phone:null,isSmsRegister:!1,flowId:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(e){return void 0===e&&(e=!1),r([new p({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new p({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new p({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new c({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new f({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})],e?[new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.firstName=e},this.onLastNameChange=function(e){t.lastName=e},this.onEmailChange=function(e){t.email=e},this.onPasswordChange=function(e){t.password=e},this.onPhoneChange=function(e){t.phone=e},this.onSmsRegisterChange=function(e,i){e?(t.validator.setRules(r(r(r(r([new p({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule}),new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})],i?[new p({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule})]:[],!0),i?[new p({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule})]:[],!0),i?[new p({fieldKey:"email",valuePath:"email",message:t.message.requiredRule})]:[],!0),i?[new c({fieldKey:"email",valuePath:"email",message:t.message.emailRule})]:[],!0)),t.model.password=void 0):t.validator.setRules(t.validatorRules()),t.isSmsRegister=e},this.setCustomerAttributes=function(e){t._customerAttributes=(null==e?void 0:e.filter((function(e){return e.registerPageRequirement!==h.INVISIBLE})).map((function(e){return{attribute:e,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:e.registerPageRequirement===h.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(e,r){var i;if(t._customerAttributes){var a=t._customerAttributes.find((function(t){return t.attribute.id===e}));if(a){var o=null===(i=t._customerAttributes)||void 0===i?void 0:i.findIndex((function(t){return t.attribute.id===e}));void 0!==o&&-1!==o&&(t._customerAttributes[o].attributeValue=t.getAttributeValue(a.attribute,r),t.validateCustomerAttribute())}}},a(this,{emailErrorMessage:o,passwordErrorMessage:o,firstNameErrorMessage:o,lastNameErrorMessage:o,phoneErrorMessage:o,hasError:o,redirect:o,model:s,validateAll:n,register:n,customerAttributes:o,_customerAttributes:s}),this.message=e.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(b.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(e){this.model.isMarketingAccepted=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"flowId",{get:function(){return this.model.flowId},set:function(e){this.model.flowId=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isSmsRegister",{get:function(){return this.model.isSmsRegister},set:function(e){this.model.isSmsRegister=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"firstNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.firstName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"lastNameErrorMessage",{get:function(){var e;return null===(e=this.validator.results.lastName)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"emailErrorMessage",{get:function(){var e;return null===(e=this.validator.results.email)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"passwordErrorMessage",{get:function(){var e;return null===(e=this.validator.results.password)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"attributes",{get:function(){return this.model.attributes},set:function(e){this.model.attributes=e},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),b.prototype.getAttributeValue=function(e,t){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};return"string"!=typeof t||e.type!==g.TEXT&&e.type!==g.DATETIME&&e.type!==g.DATE&&e.type!==g.CHOICE||(r.value=t),"string"==typeof t&&e.type===g.NUMERIC&&(Number.isInteger(d(t))?r.value=t:r.value=t.slice(0,-1)),"boolean"==typeof t&&e.type===g.BOOLEAN&&(r.isChecked=t),"object"==typeof t&&e.type===g.MULTIPLE_CHOICE&&(r.selectedIdList=t),r},Object.defineProperty(b.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(e){return void 0!==e.attributeValue.value||void 0!==e.attributeValue.isChecked||void 0!==e.attributeValue.selectedIdList})))return null;var e=[];return this._customerAttributes.map((function(t){var r=t.attributeValue,i=r.selectedIdList,a=r.isChecked,o=r.value;void 0!==i&&g.MULTIPLE_CHOICE&&i.map((function(r){e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:r,value:null})})),t.attribute.type===g.BOOLEAN&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==o&&(t.attribute.type!==g.TEXT&&t.attribute.type!==g.NUMERIC||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:o.toString()}),t.attribute.type===g.CHOICE&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:o,value:null}),t.attribute.type!==g.DATETIME&&t.attribute.type!==g.DATE||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:new Date(o).getTime().toString()}))})),e},enumerable:!1,configurable:!0}),b.prototype.validateCustomerAttribute=function(){var e,t=this;this._customerAttributes=null===(e=this._customerAttributes)||void 0===e?void 0:e.map((function(e){var r;return e.validator.isRequired&&t.isFormSubmit&&(e.attribute.type===g.BOOLEAN||e.attributeValue.value||(null===(r=e.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(e.validator.hasError=!1,e.validator.message=""):(e.validator.hasError=!0,e.validator.message="string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.model))),e}))},b.prototype.validateAll=function(){var r;return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return e=t.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(e){return e.validator.hasError})),[2,e||i]}}))}))},b.prototype.register=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return this.isFormSubmit=!0,e={isFormError:!1,isSuccess:!1,errorCodes:[],otpSend:!1,flowId:null},this.email&&(this.email=this.email.trim()),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,l.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0,this.model.phone,this.flowId?this.flowId:void 0)];case 3:return r=t.sent(),[2,i(i({},e),r)];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},b}();export{b as RegisterForm};