@ikas/storefront 0.0.102 → 0.0.103

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 (53) hide show
  1. package/build/__generated__/global-types.d.ts +22 -1
  2. package/build/api/cart/__generated__/getCart.d.ts +4 -0
  3. package/build/api/cart/__generated__/saveItemToCart.d.ts +4 -0
  4. package/build/api/checkout/__generated__/checkStocks.d.ts +3 -3
  5. package/build/api/checkout/index.d.ts +1 -1
  6. package/build/api/country/__generated__/getAvailableShippingCountries.d.ts +3 -0
  7. package/build/api/country/__generated__/getMyCountry.d.ts +3 -0
  8. package/build/api/country/__generated__/listCountry.d.ts +2 -0
  9. package/build/api/country/index.d.ts +2 -1
  10. package/build/api/index.d.ts +0 -2
  11. package/build/api/storefront/__generated__/getStorefront.d.ts +39 -10
  12. package/build/api/storefront/index.d.ts +1 -1
  13. package/build/components/checkout/index.d.ts +3 -0
  14. package/build/components/checkout/model.d.ts +4 -3
  15. package/build/index.es.js +728 -431
  16. package/build/index.js +730 -434
  17. package/build/models/data/cart/index.d.ts +9 -0
  18. package/build/models/data/country/index.d.ts +2 -0
  19. package/build/models/data/sales-channel/index.d.ts +12 -0
  20. package/build/models/data/storefront/{storefront-domain → domain}/index.d.ts +1 -0
  21. package/build/models/data/storefront/index.d.ts +17 -6
  22. package/build/models/data/storefront/localization/index.d.ts +7 -0
  23. package/build/models/data/storefront/routing/index.d.ts +9 -0
  24. package/build/models/data/storefront/theme/index.d.ts +13 -0
  25. package/build/models/data/storefront/theme-localization/index.d.ts +12 -0
  26. package/build/models/ui/product-list/index.d.ts +1 -1
  27. package/build/pages/404.d.ts +1 -0
  28. package/build/pages/[slug]/index.d.ts +1 -0
  29. package/build/pages/account/addresses.d.ts +1 -0
  30. package/build/pages/account/favorite-products.d.ts +1 -0
  31. package/build/pages/account/forgot-password.d.ts +1 -0
  32. package/build/pages/account/index.d.ts +1 -0
  33. package/build/pages/account/login.d.ts +1 -0
  34. package/build/pages/account/orders/[id].d.ts +1 -0
  35. package/build/pages/account/orders/index.d.ts +1 -0
  36. package/build/pages/account/recover-password.d.ts +1 -0
  37. package/build/pages/account/register.d.ts +1 -0
  38. package/build/pages/cart.d.ts +1 -0
  39. package/build/pages/checkout/[id].d.ts +4 -0
  40. package/build/pages/home.d.ts +1 -0
  41. package/build/pages/pages/[slug].d.ts +1 -0
  42. package/build/pages/search.d.ts +1 -0
  43. package/build/store/base.d.ts +13 -0
  44. package/build/storefront/index.d.ts +18 -0
  45. package/build/utils/providers/page-data.d.ts +10 -0
  46. package/build/utils/settings.d.ts +142 -0
  47. package/package.json +1 -1
  48. package/build/api/product-stock-location/__generated__/listProductStockLocation.d.ts +0 -13
  49. package/build/api/product-stock-location/index.d.ts +0 -4
  50. package/build/api/theme/index.d.ts +0 -4
  51. package/build/models/data/storefront/stockfront-location/index.d.ts +0 -5
  52. package/build/models/data/storefront/stockfront-route/index.d.ts +0 -5
  53. package/build/models/data/storefront/storefront-region/index.d.ts +0 -18
package/build/index.es.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { makeAutoObservable, toJS, runInAction, reaction, makeObservable, computed, observable, action, configure } from 'mobx';
2
- import fs from 'fs';
3
- import getConfig from 'next/config';
4
2
  import React, { createElement, Fragment, useState, useEffect, useCallback, useRef, useMemo } from 'react';
3
+ import getConfig from 'next/config';
5
4
  import { observer } from 'mobx-react-lite';
6
5
  import { useRouter } from 'next/router';
7
6
  import Image$1 from 'next/image';
8
7
  import Link from 'next/link';
9
8
  import Head from 'next/head';
9
+ import fs from 'fs';
10
10
  import dynamic from 'next/dynamic';
11
+ import Error$1 from 'next/error';
11
12
 
12
13
  /*! *****************************************************************************
13
14
  Copyright (c) Microsoft Corporation.
@@ -10871,10 +10872,37 @@ var IkasStorefrontConfig = /** @class */ (function () {
10871
10872
  IkasStorefrontConfig.components = components;
10872
10873
  IkasStorefrontConfig.config = config;
10873
10874
  IkasStorefrontConfig.apiUrlOverride = apiUrlOverride || null;
10875
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
10876
+ this.storefrontId = config.storefrontId;
10877
+ }
10878
+ };
10879
+ IkasStorefrontConfig.initWithJson = function (json) {
10880
+ try {
10881
+ Object.entries(json).forEach(function (_a) {
10882
+ var key = _a[0], value = _a[1];
10883
+ //@ts-ignore
10884
+ IkasStorefrontConfig[key] = value;
10885
+ });
10886
+ }
10887
+ catch (err) {
10888
+ console.log(err);
10889
+ }
10890
+ };
10891
+ IkasStorefrontConfig.getJson = function () {
10892
+ return {
10893
+ storefrontId: IkasStorefrontConfig.storefrontId || null,
10894
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId || null,
10895
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId || null,
10896
+ salesChannelId: IkasStorefrontConfig.salesChannelId || null,
10897
+ priceListId: IkasStorefrontConfig.priceListId || null,
10898
+ stockLocationIds: IkasStorefrontConfig.stockLocationIds || null,
10899
+ routings: JSON.parse(JSON.stringify(IkasStorefrontConfig.routings)) || null,
10900
+ };
10874
10901
  };
10875
10902
  IkasStorefrontConfig.components = {};
10876
10903
  IkasStorefrontConfig.config = {};
10877
10904
  IkasStorefrontConfig.apiUrlOverride = null;
10905
+ IkasStorefrontConfig.routings = [];
10878
10906
  return IkasStorefrontConfig;
10879
10907
  }());
10880
10908
 
@@ -11003,6 +11031,7 @@ var IkasProductDetailPropValueProvider = /** @class */ (function () {
11003
11031
  return [2 /*return*/, null];
11004
11032
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
11005
11033
  productIdList: [this.productDetailPropValue.productId],
11034
+ priceListId: IkasStorefrontConfig.priceListId,
11006
11035
  })];
11007
11036
  case 1:
11008
11037
  productSearchResponse = _b.sent();
@@ -11811,11 +11840,15 @@ var IkasPageDataProvider = /** @class */ (function () {
11811
11840
  return {
11812
11841
  props: {
11813
11842
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11843
+ pageSpecificDataStr: this.pageSpecificData
11844
+ ? JSON.stringify(this.pageSpecificData || {})
11845
+ : "",
11814
11846
  page: toJS(this.page) || null,
11815
11847
  settingsStr: JSON.stringify(this.theme.settings || {}),
11816
11848
  merchantSettings: this.merchantSettings
11817
11849
  ? JSON.stringify(this.merchantSettings)
11818
11850
  : null,
11851
+ configJson: IkasStorefrontConfig.getJson(),
11819
11852
  },
11820
11853
  };
11821
11854
  },
@@ -12032,6 +12065,7 @@ var IkasPageDataProvider = /** @class */ (function () {
12032
12065
  return [2 /*return*/];
12033
12066
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
12034
12067
  productIdList: [metaDataResponse.metaData.targetId],
12068
+ priceListId: IkasStorefrontConfig.priceListId,
12035
12069
  })];
12036
12070
  case 2:
12037
12071
  productsResponse = _b.sent();
@@ -12790,6 +12824,10 @@ var IkasCart = /** @class */ (function () {
12790
12824
  : [];
12791
12825
  this.merchantId = data.merchantId || "";
12792
12826
  this.totalPrice = data.totalPrice || 0;
12827
+ this.salesChannelId = data.salesChannelId || "";
12828
+ this.storefrontId = data.storefrontId || null;
12829
+ this.storefrontRoutingId = data.storefrontRoutingId || null;
12830
+ this.storefrontThemeId = data.storefrontThemeId || null;
12793
12831
  makeAutoObservable(this);
12794
12832
  }
12795
12833
  Object.defineProperty(IkasCart.prototype, "totalTax", {
@@ -15817,7 +15855,7 @@ var MAX_CVC_LENGTH = 4;
15817
15855
  var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
15818
15856
  var isServer$1 = typeof localStorage === "undefined";
15819
15857
  var CheckoutViewModel = /** @class */ (function () {
15820
- function CheckoutViewModel(checkout, queryParams, router) {
15858
+ function CheckoutViewModel(checkout, queryParams, router, returnPolicy, privacyPolicy, termsOfService) {
15821
15859
  var _this = this;
15822
15860
  this.checkout = new IkasCheckout();
15823
15861
  this.storefront = null;
@@ -15923,7 +15961,7 @@ var CheckoutViewModel = /** @class */ (function () {
15923
15961
  variantId: i.variant.id,
15924
15962
  productId: i.variant.productId,
15925
15963
  }); });
15926
- return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines)];
15964
+ return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, IkasStorefrontConfig.stockLocationIds || [])];
15927
15965
  case 1:
15928
15966
  result = _b.sent();
15929
15967
  if (!result) {
@@ -15936,7 +15974,7 @@ var CheckoutViewModel = /** @class */ (function () {
15936
15974
  data = unavailableItems.map(function (item) { return ({
15937
15975
  variant: _this.cart.items.find(function (i) { return i.variant.id === item.variantId; })
15938
15976
  .variant,
15939
- availableQuantity: item.availableQuantity,
15977
+ availableQuantity: item.stockCount,
15940
15978
  }); });
15941
15979
  throw {
15942
15980
  type: ErrorType.STOCK_ERROR,
@@ -15953,7 +15991,7 @@ var CheckoutViewModel = /** @class */ (function () {
15953
15991
  switch (_b.label) {
15954
15992
  case 0:
15955
15993
  _a = this;
15956
- return [4 /*yield*/, IkasCountryAPI.listShippingCountries()];
15994
+ return [4 /*yield*/, IkasCountryAPI.listShippingCountries(IkasStorefrontConfig.storefrontId)];
15957
15995
  case 1:
15958
15996
  _a.shippingCountryIds = _b.sent();
15959
15997
  return [2 /*return*/];
@@ -16029,30 +16067,6 @@ var CheckoutViewModel = /** @class */ (function () {
16029
16067
  }
16030
16068
  });
16031
16069
  }); };
16032
- this.getStorefront = function () { return __awaiter(_this, void 0, void 0, function () {
16033
- var storefront;
16034
- return __generator(this, function (_a) {
16035
- switch (_a.label) {
16036
- case 0:
16037
- if (!IkasStorefrontConfig.config.storefrontId || !!this.storefront)
16038
- return [2 /*return*/];
16039
- _a.label = 1;
16040
- case 1:
16041
- _a.trys.push([1, 3, , 4]);
16042
- return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.config.storefrontId)];
16043
- case 2:
16044
- storefront = _a.sent();
16045
- if (storefront) {
16046
- this.storefront = storefront;
16047
- }
16048
- return [3 /*break*/, 4];
16049
- case 3:
16050
- _a.sent();
16051
- return [3 /*break*/, 4];
16052
- case 4: return [2 /*return*/];
16053
- }
16054
- });
16055
- }); };
16056
16070
  this.createCustomer = function () {
16057
16071
  if (_this.customerStore.customer) {
16058
16072
  _this.checkout.customer = _this.customerStore.customer;
@@ -16072,7 +16086,7 @@ var CheckoutViewModel = /** @class */ (function () {
16072
16086
  _this.checkout.billingAddress || new IkasOrderAddress();
16073
16087
  }
16074
16088
  else {
16075
- _this.checkout.billingAddress = new IkasOrderAddress(cloneDeep_1(_this.checkout.shippingAddress) || {});
16089
+ _this.checkout.billingAddress = _this.checkout.shippingAddress;
16076
16090
  }
16077
16091
  }
16078
16092
  };
@@ -16184,7 +16198,7 @@ var CheckoutViewModel = /** @class */ (function () {
16184
16198
  _this.router.push("/");
16185
16199
  };
16186
16200
  this.onProceedToShippingClick = function () { return __awaiter(_this, void 0, void 0, function () {
16187
- var newAddress, customer, err_3;
16201
+ var newAddress, customer, err_2;
16188
16202
  return __generator(this, function (_a) {
16189
16203
  switch (_a.label) {
16190
16204
  case 0:
@@ -16214,12 +16228,12 @@ var CheckoutViewModel = /** @class */ (function () {
16214
16228
  this.changeStep(CheckoutStep.SHIPPING);
16215
16229
  return [3 /*break*/, 7];
16216
16230
  case 6:
16217
- err_3 = _a.sent();
16218
- if (err_3.type) {
16219
- this.error = err_3;
16231
+ err_2 = _a.sent();
16232
+ if (err_2.type) {
16233
+ this.error = err_2;
16220
16234
  }
16221
16235
  else {
16222
- console.log(err_3);
16236
+ console.log(err_2);
16223
16237
  this.error = {
16224
16238
  type: ErrorType.UNKNOWN,
16225
16239
  };
@@ -16231,7 +16245,7 @@ var CheckoutViewModel = /** @class */ (function () {
16231
16245
  });
16232
16246
  }); };
16233
16247
  this.onProceedToPaymentClick = function () { return __awaiter(_this, void 0, void 0, function () {
16234
- var err_4;
16248
+ var err_3;
16235
16249
  return __generator(this, function (_a) {
16236
16250
  switch (_a.label) {
16237
16251
  case 0:
@@ -16251,12 +16265,12 @@ var CheckoutViewModel = /** @class */ (function () {
16251
16265
  this.changeStep(CheckoutStep.PAYMENT);
16252
16266
  return [3 /*break*/, 4];
16253
16267
  case 3:
16254
- err_4 = _a.sent();
16255
- if (err_4.type) {
16256
- this.error = err_4;
16268
+ err_3 = _a.sent();
16269
+ if (err_3.type) {
16270
+ this.error = err_3;
16257
16271
  }
16258
16272
  else {
16259
- console.log(err_4);
16273
+ console.log(err_3);
16260
16274
  this.error = {
16261
16275
  type: ErrorType.UNKNOWN,
16262
16276
  };
@@ -16268,7 +16282,7 @@ var CheckoutViewModel = /** @class */ (function () {
16268
16282
  });
16269
16283
  }); };
16270
16284
  this.performPayment = function () { return __awaiter(_this, void 0, void 0, function () {
16271
- var response, transactionStatus, err_5;
16285
+ var response, transactionStatus, err_4;
16272
16286
  return __generator(this, function (_a) {
16273
16287
  switch (_a.label) {
16274
16288
  case 0:
@@ -16299,7 +16313,6 @@ var CheckoutViewModel = /** @class */ (function () {
16299
16313
  IkasTransactionStatusEnum.SUCCESS,
16300
16314
  IkasTransactionStatusEnum.AUTHORIZED,
16301
16315
  ].includes(transactionStatus)) {
16302
- localStorage.removeItem(USE_DIFFERENT_ADDRESS_KEY);
16303
16316
  this.changeStep(CheckoutStep.SUCCESS);
16304
16317
  }
16305
16318
  else if (transactionStatus === IkasTransactionStatusEnum.PENDING &&
@@ -16315,10 +16328,10 @@ var CheckoutViewModel = /** @class */ (function () {
16315
16328
  }
16316
16329
  return [3 /*break*/, 6];
16317
16330
  case 5:
16318
- err_5 = _a.sent();
16319
- if (err_5.type) {
16320
- console.log(err_5);
16321
- this.error = err_5;
16331
+ err_4 = _a.sent();
16332
+ if (err_4.type) {
16333
+ console.log(err_4);
16334
+ this.error = err_4;
16322
16335
  }
16323
16336
  else {
16324
16337
  this.error = {
@@ -16397,6 +16410,9 @@ var CheckoutViewModel = /** @class */ (function () {
16397
16410
  }); };
16398
16411
  this.checkout = checkout;
16399
16412
  this.router = router;
16413
+ this.returnPolicy = returnPolicy;
16414
+ this.privacyPolicy = privacyPolicy;
16415
+ this.termsOfService = termsOfService;
16400
16416
  this.init(queryParams);
16401
16417
  makeAutoObservable(this);
16402
16418
  }
@@ -16407,15 +16423,6 @@ var CheckoutViewModel = /** @class */ (function () {
16407
16423
  enumerable: false,
16408
16424
  configurable: true
16409
16425
  });
16410
- Object.defineProperty(CheckoutViewModel.prototype, "storefrontRegion", {
16411
- get: function () {
16412
- var _a;
16413
- return ((_a = this.storefront) === null || _a === void 0 ? void 0 : _a.regions.length) ? this.storefront.regions[0]
16414
- : undefined;
16415
- },
16416
- enumerable: false,
16417
- configurable: true
16418
- });
16419
16426
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
16420
16427
  get: function () {
16421
16428
  var _this = this;
@@ -17079,6 +17086,7 @@ var IkasCustomerStore = /** @class */ (function () {
17079
17086
  return [2 /*return*/, []];
17080
17087
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
17081
17088
  productIdList: favoriteProductsResult.map(function (fP) { return fP.productId; }),
17089
+ priceListId: IkasStorefrontConfig.priceListId,
17082
17090
  })];
17083
17091
  case 2:
17084
17092
  productsResult = _b.sent();
@@ -21936,7 +21944,10 @@ var IkasProductList = /** @class */ (function () {
21936
21944
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21937
21945
  get: function () {
21938
21946
  var _a;
21939
- return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) || !!this._searchKeyword);
21947
+ return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) ||
21948
+ !!this._searchKeyword ||
21949
+ (this._pageType !== IkasThemePageType.CATEGORY &&
21950
+ !!this._filterCategoryId));
21940
21951
  },
21941
21952
  enumerable: false,
21942
21953
  configurable: true
@@ -21999,13 +22010,20 @@ var IkasProductList = /** @class */ (function () {
21999
22010
  });
22000
22011
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
22001
22012
  get: function () {
22002
- var _a;
22013
+ var _this = this;
22014
+ var _a, _b, _c;
22003
22015
  var queryParams = {};
22004
22016
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
22005
22017
  queryParams[f.key] = f.keyList;
22006
22018
  });
22007
22019
  if (this._searchKeyword)
22008
22020
  queryParams.s = this._searchKeyword;
22021
+ if (this._pageType !== IkasThemePageType.CATEGORY &&
22022
+ this._filterCategoryId) {
22023
+ var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
22024
+ if (slug)
22025
+ queryParams.c = slug;
22026
+ }
22009
22027
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
22010
22028
  },
22011
22029
  enumerable: false,
@@ -22060,6 +22078,7 @@ var IkasProductList = /** @class */ (function () {
22060
22078
  categoryIdList: this._filterCategoryId
22061
22079
  ? [this._filterCategoryId]
22062
22080
  : undefined,
22081
+ priceListId: IkasStorefrontConfig.priceListId,
22063
22082
  query: this._searchKeyword,
22064
22083
  })];
22065
22084
  case 1: return [2 /*return*/, _c.sent()];
@@ -22087,6 +22106,7 @@ var IkasProductList = /** @class */ (function () {
22087
22106
  };
22088
22107
  IkasProductList.prototype.applyQueryParamFilters = function (queryParams) {
22089
22108
  var _this = this;
22109
+ var _a;
22090
22110
  try {
22091
22111
  queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach(function (value, key) {
22092
22112
  var _a;
@@ -22098,6 +22118,15 @@ var IkasProductList = /** @class */ (function () {
22098
22118
  var querySearch = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("s");
22099
22119
  if (querySearch)
22100
22120
  this._searchKeyword = querySearch;
22121
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
22122
+ var queryCategory_1 = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
22123
+ if (queryCategory_1) {
22124
+ var filterCategory = (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.slug === queryCategory_1; });
22125
+ if (filterCategory) {
22126
+ this._filterCategoryId = filterCategory.id;
22127
+ }
22128
+ }
22129
+ }
22101
22130
  }
22102
22131
  catch (err) {
22103
22132
  console.log(err);
@@ -22144,12 +22173,32 @@ var IkasProductList = /** @class */ (function () {
22144
22173
  var _a;
22145
22174
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22146
22175
  this._searchKeyword = "";
22176
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
22177
+ this._filterCategoryId = undefined;
22178
+ }
22147
22179
  this.applyFilters();
22148
22180
  };
22149
- IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
22181
+ IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22150
22182
  var _a;
22151
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22152
- (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22183
+ if (disableRoute === void 0) { disableRoute = false; }
22184
+ return __awaiter(this, void 0, void 0, function () {
22185
+ return __generator(this, function (_b) {
22186
+ switch (_b.label) {
22187
+ case 0:
22188
+ if (!disableRoute) return [3 /*break*/, 2];
22189
+ this._filterCategoryId = filterCategory.id;
22190
+ return [4 /*yield*/, this.applyFilters()];
22191
+ case 1:
22192
+ _b.sent();
22193
+ return [3 /*break*/, 3];
22194
+ case 2:
22195
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22196
+ (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22197
+ _b.label = 3;
22198
+ case 3: return [2 /*return*/];
22199
+ }
22200
+ });
22201
+ });
22153
22202
  };
22154
22203
  IkasProductList.prototype.toJSON = function () {
22155
22204
  return {
@@ -24237,7 +24286,7 @@ var IkasCartAPI = /** @class */ (function () {
24237
24286
  return __generator(this, function (_b) {
24238
24287
  switch (_b.label) {
24239
24288
  case 0:
24240
- MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24289
+ MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24241
24290
  _b.label = 1;
24242
24291
  case 1:
24243
24292
  _b.trys.push([1, 3, , 4]);
@@ -24272,7 +24321,7 @@ var IkasCartAPI = /** @class */ (function () {
24272
24321
  return __generator(this, function (_b) {
24273
24322
  switch (_b.label) {
24274
24323
  case 0:
24275
- QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24324
+ QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24276
24325
  _b.label = 1;
24277
24326
  case 1:
24278
24327
  _b.trys.push([1, 3, , 4]);
@@ -24744,13 +24793,13 @@ var IkasCheckoutAPI = /** @class */ (function () {
24744
24793
  });
24745
24794
  });
24746
24795
  };
24747
- IkasCheckoutAPI.checkStocks = function (lines) {
24796
+ IkasCheckoutAPI.checkStocks = function (lines, stockLocationIdList) {
24748
24797
  return __awaiter(this, void 0, void 0, function () {
24749
24798
  var QUERY, _a, data, errors, err_7;
24750
24799
  return __generator(this, function (_b) {
24751
24800
  switch (_b.label) {
24752
24801
  case 0:
24753
- QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "], ["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "])));
24802
+ QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "], ["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "])));
24754
24803
  _b.label = 1;
24755
24804
  case 1:
24756
24805
  _b.trys.push([1, 3, , 4]);
@@ -24760,6 +24809,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
24760
24809
  query: QUERY,
24761
24810
  variables: {
24762
24811
  lines: lines,
24812
+ stockLocationIdList: stockLocationIdList,
24763
24813
  },
24764
24814
  })];
24765
24815
  case 2:
@@ -24842,7 +24892,7 @@ var IkasCountryAPI = /** @class */ (function () {
24842
24892
  return __generator(this, function (_b) {
24843
24893
  switch (_b.label) {
24844
24894
  case 0:
24845
- QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24895
+ QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24846
24896
  _b.label = 1;
24847
24897
  case 1:
24848
24898
  _b.trys.push([1, 3, , 4]);
@@ -24858,6 +24908,8 @@ var IkasCountryAPI = /** @class */ (function () {
24858
24908
  return [2 /*return*/, data.listCountry.map(function (c) { return ({
24859
24909
  id: c.id,
24860
24910
  name: pascalCase(c.locationTranslations.tr),
24911
+ native: c.native || "",
24912
+ iso2: c.iso2 || undefined,
24861
24913
  iso3: c.iso3 || undefined,
24862
24914
  phoneCode: c.phoneCode || undefined,
24863
24915
  }); })];
@@ -24871,13 +24923,13 @@ var IkasCountryAPI = /** @class */ (function () {
24871
24923
  });
24872
24924
  });
24873
24925
  };
24874
- IkasCountryAPI.listShippingCountries = function () {
24926
+ IkasCountryAPI.listShippingCountries = function (storefrontId) {
24875
24927
  return __awaiter(this, void 0, void 0, function () {
24876
24928
  var QUERY, _a, data, errors, err_2;
24877
24929
  return __generator(this, function (_b) {
24878
24930
  switch (_b.label) {
24879
24931
  case 0:
24880
- QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "], ["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "])));
24932
+ QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "], ["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "])));
24881
24933
  _b.label = 1;
24882
24934
  case 1:
24883
24935
  _b.trys.push([1, 3, , 4]);
@@ -24885,6 +24937,9 @@ var IkasCountryAPI = /** @class */ (function () {
24885
24937
  .getClient()
24886
24938
  .query({
24887
24939
  query: QUERY,
24940
+ variables: {
24941
+ storefrontId: storefrontId,
24942
+ },
24888
24943
  })];
24889
24944
  case 2:
24890
24945
  _a = _b.sent(), data = _a.data, errors = _a.errors;
@@ -24903,9 +24958,34 @@ var IkasCountryAPI = /** @class */ (function () {
24903
24958
  });
24904
24959
  });
24905
24960
  };
24961
+ IkasCountryAPI.getMyCountry = function () {
24962
+ return __awaiter(this, void 0, void 0, function () {
24963
+ var QUERY, data, err_3;
24964
+ return __generator(this, function (_a) {
24965
+ switch (_a.label) {
24966
+ case 0:
24967
+ QUERY = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n query getMyCountry {\n getMyCountry\n }\n "], ["\n query getMyCountry {\n getMyCountry\n }\n "])));
24968
+ _a.label = 1;
24969
+ case 1:
24970
+ _a.trys.push([1, 3, , 4]);
24971
+ return [4 /*yield*/, apollo.getClient().query({
24972
+ query: QUERY,
24973
+ })];
24974
+ case 2:
24975
+ data = (_a.sent()).data;
24976
+ return [2 /*return*/, data.getMyCountry];
24977
+ case 3:
24978
+ err_3 = _a.sent();
24979
+ console.log(err_3);
24980
+ return [3 /*break*/, 4];
24981
+ case 4: return [2 /*return*/];
24982
+ }
24983
+ });
24984
+ });
24985
+ };
24906
24986
  return IkasCountryAPI;
24907
24987
  }());
24908
- var templateObject_1$5, templateObject_2$3;
24988
+ var templateObject_1$5, templateObject_2$3, templateObject_3$1;
24909
24989
 
24910
24990
  var IkasCustomerAPI = /** @class */ (function () {
24911
24991
  function IkasCustomerAPI() {
@@ -24990,7 +25070,7 @@ var IkasCustomerAPI = /** @class */ (function () {
24990
25070
  return __generator(this, function (_b) {
24991
25071
  switch (_b.label) {
24992
25072
  case 0:
24993
- MUTATION = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
25073
+ MUTATION = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
24994
25074
  _b.label = 1;
24995
25075
  case 1:
24996
25076
  _b.trys.push([1, 3, , 4]);
@@ -25306,7 +25386,7 @@ var IkasCustomerAPI = /** @class */ (function () {
25306
25386
  };
25307
25387
  return IkasCustomerAPI;
25308
25388
  }());
25309
- var templateObject_1$6, templateObject_2$4, templateObject_3$1, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25389
+ var templateObject_1$6, templateObject_2$4, templateObject_3$2, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25310
25390
 
25311
25391
  var IkasDistrictAPI = /** @class */ (function () {
25312
25392
  function IkasDistrictAPI() {
@@ -25759,7 +25839,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25759
25839
  return __generator(this, function (_b) {
25760
25840
  switch (_b.label) {
25761
25841
  case 0:
25762
- SAVE_FAVORITE_PRODUCT = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25842
+ SAVE_FAVORITE_PRODUCT = src(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25763
25843
  _b.label = 1;
25764
25844
  case 1:
25765
25845
  _b.trys.push([1, 3, , 4]);
@@ -25785,7 +25865,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25785
25865
  };
25786
25866
  return IkasFavoriteProductAPI;
25787
25867
  }());
25788
- var templateObject_1$c, templateObject_2$6, templateObject_3$2;
25868
+ var templateObject_1$c, templateObject_2$6, templateObject_3$3;
25789
25869
 
25790
25870
  var IkasContactFormAPI = /** @class */ (function () {
25791
25871
  function IkasContactFormAPI() {
@@ -25878,150 +25958,6 @@ var IkasStateAPI = /** @class */ (function () {
25878
25958
  }());
25879
25959
  var templateObject_1$e;
25880
25960
 
25881
- var IkasStorefrontDomain = /** @class */ (function () {
25882
- function IkasStorefrontDomain(data) {
25883
- if (data === void 0) { data = {}; }
25884
- this.id = data.id || "";
25885
- this.merchantDomainId = data.merchantDomainId || "";
25886
- this.name = data.name || "";
25887
- this.redirectDomainName = data.redirectDomainName || null;
25888
- makeAutoObservable(this);
25889
- }
25890
- return IkasStorefrontDomain;
25891
- }());
25892
-
25893
- var IkasStorefrontLocation = /** @class */ (function () {
25894
- function IkasStorefrontLocation(data) {
25895
- if (data === void 0) { data = {}; }
25896
- this.countryId = data.countryId || "";
25897
- this.stateId = data.stateId || null;
25898
- makeAutoObservable(this);
25899
- }
25900
- return IkasStorefrontLocation;
25901
- }());
25902
-
25903
- var IkasStorefrontRoute = /** @class */ (function () {
25904
- function IkasStorefrontRoute(data) {
25905
- if (data === void 0) { data = {}; }
25906
- this.domainId = data.domainId || "";
25907
- this.useSubPath = data.useSubPath || false;
25908
- makeAutoObservable(this);
25909
- }
25910
- return IkasStorefrontRoute;
25911
- }());
25912
-
25913
- var IkasStorefrontRegion = /** @class */ (function () {
25914
- function IkasStorefrontRegion(data) {
25915
- if (data === void 0) { data = {}; }
25916
- // Extra
25917
- this.theme = new IkasTheme();
25918
- this.id = data.id || "";
25919
- this.locale = data.locale || "";
25920
- this.themeJSON = data.themeJSON || "";
25921
- this.shipping = data.shipping || null;
25922
- this.paymentSettingsId = data.paymentSettingsId || null;
25923
- this.priceListId = data.priceListId || null;
25924
- this.locations = data.locations
25925
- ? data.locations.map(function (o) { return new IkasStorefrontLocation(o); })
25926
- : [];
25927
- this.routes = data.routes
25928
- ? data.routes.map(function (o) { return new IkasStorefrontRoute(o); })
25929
- : null;
25930
- this.termsOfService = data.termsOfService || "";
25931
- this.privacyPolicy = data.privacyPolicy || "";
25932
- this.returnPolicy = data.returnPolicy || "";
25933
- try {
25934
- this.theme = this.themeJSON
25935
- ? new IkasTheme(JSON.parse(this.themeJSON))
25936
- : new IkasTheme();
25937
- }
25938
- catch (err) { }
25939
- makeAutoObservable(this);
25940
- }
25941
- return IkasStorefrontRegion;
25942
- }());
25943
-
25944
- var IkasStorefront = /** @class */ (function () {
25945
- function IkasStorefront(data) {
25946
- if (data === void 0) { data = {}; }
25947
- this.id = data.id || "";
25948
- this.name = data.name || "";
25949
- this.themeId = data.themeId || "";
25950
- this.themeVersionId = data.themeVersionId || "";
25951
- this.userId = data.userId || "";
25952
- this.domains = data.domains
25953
- ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
25954
- : [];
25955
- this.regions = data.regions
25956
- ? data.regions.map(function (o) { return new IkasStorefrontRegion(o); })
25957
- : [];
25958
- makeAutoObservable(this);
25959
- }
25960
- return IkasStorefront;
25961
- }());
25962
-
25963
- var IkasStorefrontAPI = /** @class */ (function () {
25964
- function IkasStorefrontAPI() {
25965
- }
25966
- IkasStorefrontAPI.getStorefront = function (storefrontId) {
25967
- return __awaiter(this, void 0, void 0, function () {
25968
- var QUERY, _a, data, errors;
25969
- return __generator(this, function (_b) {
25970
- switch (_b.label) {
25971
- case 0:
25972
- QUERY = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "], ["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "])));
25973
- _b.label = 1;
25974
- case 1:
25975
- _b.trys.push([1, 3, , 4]);
25976
- return [4 /*yield*/, apollo
25977
- .getClient()
25978
- .query({
25979
- query: QUERY,
25980
- variables: {
25981
- storefrontId: storefrontId,
25982
- },
25983
- })];
25984
- case 2:
25985
- _a = _b.sent(), data = _a.data, errors = _a.errors;
25986
- if (errors && errors.length) {
25987
- console.log(errors);
25988
- }
25989
- if (data)
25990
- return [2 /*return*/, new IkasStorefront(data.getStorefront)];
25991
- return [3 /*break*/, 4];
25992
- case 3:
25993
- _b.sent();
25994
- return [3 /*break*/, 4];
25995
- case 4: return [2 /*return*/, new IkasStorefront()];
25996
- }
25997
- });
25998
- });
25999
- };
26000
- return IkasStorefrontAPI;
26001
- }());
26002
- var templateObject_1$f;
26003
-
26004
- var IkasThemeAPI = /** @class */ (function () {
26005
- function IkasThemeAPI() {
26006
- }
26007
- IkasThemeAPI.fetchTheme = function () {
26008
- return new Promise(function (resolve, reject) {
26009
- var serverRuntimeConfig = getConfig().serverRuntimeConfig;
26010
- var themeJSONPath = serverRuntimeConfig.THEME_JSON_PATH || "./src/theme.json";
26011
- fs.readFile(themeJSONPath, {
26012
- flag: "a+",
26013
- }, function (err, file) {
26014
- if (err) {
26015
- return reject(err);
26016
- }
26017
- var result = file.length ? JSON.parse(file.toString()) : {};
26018
- resolve(new IkasTheme(result));
26019
- });
26020
- });
26021
- };
26022
- return IkasThemeAPI;
26023
- }());
26024
-
26025
25961
  var IkasVariantTypeAPI = /** @class */ (function () {
26026
25962
  function IkasVariantTypeAPI() {
26027
25963
  }
@@ -26031,7 +25967,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26031
25967
  return __generator(this, function (_b) {
26032
25968
  switch (_b.label) {
26033
25969
  case 0:
26034
- LIST_VARIANT_TYPE = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
25970
+ LIST_VARIANT_TYPE = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
26035
25971
  _b.label = 1;
26036
25972
  case 1:
26037
25973
  _b.trys.push([1, 3, , 4]);
@@ -26077,7 +26013,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26077
26013
  };
26078
26014
  return IkasVariantTypeAPI;
26079
26015
  }());
26080
- var templateObject_1$g;
26016
+ var templateObject_1$f;
26081
26017
 
26082
26018
  function styleInject(css, ref) {
26083
26019
  if ( ref === void 0 ) ref = {};
@@ -27267,6 +27203,11 @@ var IkasCartStore = /** @class */ (function () {
27267
27203
  name: product.name,
27268
27204
  },
27269
27205
  },
27206
+ priceListId: IkasStorefrontConfig.priceListId || null,
27207
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27208
+ storefrontId: IkasStorefrontConfig.storefrontId,
27209
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27210
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27270
27211
  };
27271
27212
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27272
27213
  case 1:
@@ -27307,6 +27248,11 @@ var IkasCartStore = /** @class */ (function () {
27307
27248
  name: item.variant.name,
27308
27249
  },
27309
27250
  },
27251
+ priceListId: IkasStorefrontConfig.priceListId || null,
27252
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27253
+ storefrontId: IkasStorefrontConfig.storefrontId,
27254
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27255
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27310
27256
  };
27311
27257
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27312
27258
  case 1:
@@ -27669,9 +27615,11 @@ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27669
27615
 
27670
27616
  var IkasCheckoutPage = observer(function (_a) {
27671
27617
  var _b, _c, _d;
27672
- var checkout = _a.checkout, queryParams = _a.queryParams;
27618
+ var checkout = _a.checkout, returnPolicy = _a.returnPolicy, privacyPolicy = _a.privacyPolicy, termsOfService = _a.termsOfService, queryParams = _a.queryParams;
27673
27619
  var router = useRouter();
27674
- var vm = useState(function () { return new CheckoutViewModel(checkout, queryParams, router); })[0];
27620
+ var vm = useState(function () {
27621
+ return new CheckoutViewModel(checkout, queryParams, router, returnPolicy, privacyPolicy, termsOfService);
27622
+ })[0];
27675
27623
  useEffect(function () {
27676
27624
  Analytics.beginCheckout(vm.checkout);
27677
27625
  Analytics.checkoutStep(vm.checkout, vm.step);
@@ -27696,46 +27644,18 @@ var IkasCheckoutPage = observer(function (_a) {
27696
27644
  var onPolicyModalClose = function () {
27697
27645
  setPolicyModalText("");
27698
27646
  };
27699
- var onReturnPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27700
- var _a, _b;
27701
- return __generator(this, function (_c) {
27702
- switch (_c.label) {
27703
- case 0: return [4 /*yield*/, vm.getStorefront()];
27704
- case 1:
27705
- _c.sent();
27706
- console.log((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.returnPolicy);
27707
- setPolicyModalTitle("Para İade Politikası");
27708
- setPolicyModalText(((_b = vm.storefrontRegion) === null || _b === void 0 ? void 0 : _b.returnPolicy) || "");
27709
- return [2 /*return*/];
27710
- }
27711
- });
27712
- }); };
27713
- var onPrivacyPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27714
- var _a;
27715
- return __generator(this, function (_b) {
27716
- switch (_b.label) {
27717
- case 0: return [4 /*yield*/, vm.getStorefront()];
27718
- case 1:
27719
- _b.sent();
27720
- setPolicyModalTitle("Gizlilik Politikası");
27721
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.privacyPolicy) || "");
27722
- return [2 /*return*/];
27723
- }
27724
- });
27725
- }); };
27726
- var onTermsOfServiceClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27727
- var _a;
27728
- return __generator(this, function (_b) {
27729
- switch (_b.label) {
27730
- case 0: return [4 /*yield*/, vm.getStorefront()];
27731
- case 1:
27732
- _b.sent();
27733
- setPolicyModalTitle("Hizmet Şartları");
27734
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.termsOfService) || "");
27735
- return [2 /*return*/];
27736
- }
27737
- });
27738
- }); };
27647
+ var onReturnPolicyClick = function () {
27648
+ setPolicyModalTitle("Para İade Politikası");
27649
+ setPolicyModalText(vm.returnPolicy);
27650
+ };
27651
+ var onPrivacyPolicyClick = function () {
27652
+ setPolicyModalTitle("Gizlilik Politikası");
27653
+ setPolicyModalText(vm.privacyPolicy);
27654
+ };
27655
+ var onTermsOfServiceClick = function () {
27656
+ setPolicyModalTitle("Hizmet Şartları");
27657
+ setPolicyModalText(vm.termsOfService);
27658
+ };
27739
27659
  var onErrorClose = function () {
27740
27660
  vm.error = undefined;
27741
27661
  };
@@ -27838,6 +27758,9 @@ var IkasPage = observer(function (_a) {
27838
27758
  if (page) {
27839
27759
  store.currentPageType = page.type;
27840
27760
  }
27761
+ useEffect(function () {
27762
+ store.checkLocalization();
27763
+ }, []);
27841
27764
  var renderComponent = function (pageComponent, index) {
27842
27765
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
27843
27766
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -28355,24 +28278,358 @@ var index = /*#__PURE__*/Object.freeze({
28355
28278
  Image: Image
28356
28279
  });
28357
28280
 
28281
+ var IkasStorefrontLocalization = /** @class */ (function () {
28282
+ function IkasStorefrontLocalization(data) {
28283
+ this.id = data.id || "";
28284
+ this.isDefault = data.isDefault || false;
28285
+ this.locale = data.locale || "";
28286
+ this.name = data.name || "";
28287
+ }
28288
+ return IkasStorefrontLocalization;
28289
+ }());
28290
+
28291
+ var IkasStorefrontDomain = /** @class */ (function () {
28292
+ function IkasStorefrontDomain(data) {
28293
+ if (data === void 0) { data = {}; }
28294
+ this.id = data.id || "";
28295
+ this.merchantDomainId = data.merchantDomainId || "";
28296
+ this.name = data.name || "";
28297
+ this.redirectDomainName = data.redirectDomainName || null;
28298
+ this.isDefault = data.isDefault || false;
28299
+ makeAutoObservable(this);
28300
+ }
28301
+ return IkasStorefrontDomain;
28302
+ }());
28303
+
28304
+ var IkasStorefrontRouting = /** @class */ (function () {
28305
+ function IkasStorefrontRouting(data) {
28306
+ this.id = data.id || "";
28307
+ this.countryCodes = data.countryCodes || null;
28308
+ this.domain = data.domain || null;
28309
+ this.locale = data.locale || "";
28310
+ this.path = data.path || null;
28311
+ this.priceListId = data.priceListId || null;
28312
+ }
28313
+ return IkasStorefrontRouting;
28314
+ }());
28315
+
28316
+ var IkasStorefrontThemeStatus;
28317
+ (function (IkasStorefrontThemeStatus) {
28318
+ IkasStorefrontThemeStatus["WAITING"] = "WAITING";
28319
+ IkasStorefrontThemeStatus["READY"] = "READY";
28320
+ })(IkasStorefrontThemeStatus || (IkasStorefrontThemeStatus = {}));
28321
+ var IkasStorefrontTheme = /** @class */ (function () {
28322
+ function IkasStorefrontTheme(data) {
28323
+ this.id = data.id || "";
28324
+ this.isMainTheme = data.isMainTheme || false;
28325
+ this.name = data.name || "";
28326
+ this.status = data.status || IkasStorefrontThemeStatus.WAITING;
28327
+ this.themeId = data.themeId || "";
28328
+ this.themeVersionId = data.themeVersionId || "";
28329
+ }
28330
+ return IkasStorefrontTheme;
28331
+ }());
28332
+
28333
+ var StorefrontStatus;
28334
+ (function (StorefrontStatus) {
28335
+ StorefrontStatus["WAITING"] = "WAITING";
28336
+ StorefrontStatus["READY"] = "READY";
28337
+ })(StorefrontStatus || (StorefrontStatus = {}));
28338
+ var IkasStorefront = /** @class */ (function () {
28339
+ function IkasStorefront(data) {
28340
+ if (data === void 0) { data = {}; }
28341
+ this.id = data.id || "";
28342
+ this.name = data.name || "";
28343
+ this.status = data.status || StorefrontStatus.WAITING;
28344
+ this.mainStorefrontThemeId = data.mainStorefrontThemeId || null;
28345
+ this.emailSettingsId = data.emailSettingsId || null;
28346
+ this.salesChannelId = data.salesChannelId || null;
28347
+ this.gtmId = data.gtmId || null;
28348
+ this.fbpId = data.fbpId || null;
28349
+ // Sub Models
28350
+ this.localizations = data.localizations
28351
+ ? data.localizations.map(function (l) { return new IkasStorefrontLocalization(l); })
28352
+ : [];
28353
+ this.routings = data.routings
28354
+ ? data.routings.map(function (r) { return new IkasStorefrontRouting(r); })
28355
+ : [];
28356
+ this.domains = data.domains
28357
+ ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
28358
+ : [];
28359
+ this.themes = data.themes
28360
+ ? data.themes.map(function (t) { return new IkasStorefrontTheme(t); })
28361
+ : [];
28362
+ }
28363
+ return IkasStorefront;
28364
+ }());
28365
+
28366
+ var IkasSalesChannel = /** @class */ (function () {
28367
+ function IkasSalesChannel(data) {
28368
+ if (data === void 0) { data = {}; }
28369
+ var _a;
28370
+ this.id = data.id || "";
28371
+ this.name = data.name || "";
28372
+ this.priceListId = data.priceListId || "";
28373
+ this.stockLocations =
28374
+ ((_a = data.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return new IkasSalesChannelStockLocation(sl); })) ||
28375
+ [];
28376
+ }
28377
+ return IkasSalesChannel;
28378
+ }());
28379
+ var IkasSalesChannelStockLocation = /** @class */ (function () {
28380
+ function IkasSalesChannelStockLocation(data) {
28381
+ this.id = data.id || "";
28382
+ this.order = data.order || 0;
28383
+ }
28384
+ return IkasSalesChannelStockLocation;
28385
+ }());
28386
+
28387
+ var IkasStorefrontThemeLocalization = /** @class */ (function () {
28388
+ function IkasStorefrontThemeLocalization(data) {
28389
+ this.id = data.id || "";
28390
+ this.locale = data.locale || "";
28391
+ this.storefrontId = data.storefrontId || "";
28392
+ this.storefrontThemeId = data.storefrontThemeId || "";
28393
+ this.themeJson = data.themeJson
28394
+ ? new IkasTheme(data.themeJson)
28395
+ : new IkasTheme();
28396
+ this.privacyPolicy = data.privacyPolicy || null;
28397
+ this.returnPolicy = data.returnPolicy || null;
28398
+ this.termsOfService = data.termsOfService || null;
28399
+ }
28400
+ return IkasStorefrontThemeLocalization;
28401
+ }());
28402
+
28403
+ var IkasStorefrontAPI = /** @class */ (function () {
28404
+ function IkasStorefrontAPI() {
28405
+ }
28406
+ IkasStorefrontAPI.getStorefront = function (id) {
28407
+ return __awaiter(this, void 0, void 0, function () {
28408
+ var QUERY, _a, data, errors, err_1;
28409
+ return __generator(this, function (_b) {
28410
+ switch (_b.label) {
28411
+ case 0:
28412
+ QUERY = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "], ["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "])));
28413
+ _b.label = 1;
28414
+ case 1:
28415
+ _b.trys.push([1, 3, , 4]);
28416
+ return [4 /*yield*/, apollo
28417
+ .getClient()
28418
+ .query({
28419
+ query: QUERY,
28420
+ variables: {
28421
+ id: id,
28422
+ },
28423
+ })];
28424
+ case 2:
28425
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
28426
+ if (errors && errors.length) {
28427
+ console.log(errors);
28428
+ }
28429
+ if (data)
28430
+ return [2 /*return*/, new IkasStorefront(data.getStorefront)];
28431
+ return [3 /*break*/, 4];
28432
+ case 3:
28433
+ err_1 = _b.sent();
28434
+ console.log(err_1);
28435
+ return [3 /*break*/, 4];
28436
+ case 4: return [2 /*return*/];
28437
+ }
28438
+ });
28439
+ });
28440
+ };
28441
+ return IkasStorefrontAPI;
28442
+ }());
28443
+ var templateObject_1$g;
28444
+
28445
+ var SettingsHelper = /** @class */ (function () {
28446
+ function SettingsHelper() {
28447
+ }
28448
+ SettingsHelper.readLocalTheme = function () {
28449
+ return new Promise(function (resolve, reject) {
28450
+ var themeJSONPath = "./src/theme.json";
28451
+ fs.readFile(themeJSONPath, {
28452
+ flag: "a+",
28453
+ }, function (err, file) {
28454
+ if (err) {
28455
+ return reject(err);
28456
+ }
28457
+ var result = file.length ? JSON.parse(file.toString()) : {};
28458
+ resolve(new IkasTheme(result));
28459
+ });
28460
+ });
28461
+ };
28462
+ SettingsHelper.readSettingsFile = function () {
28463
+ return new Promise(function (resolve) {
28464
+ var serverRuntimeConfig = getConfig().serverRuntimeConfig;
28465
+ var settingsPath = serverRuntimeConfig.SETTINGS;
28466
+ fs.readFile(settingsPath, {
28467
+ flag: "a+",
28468
+ }, function (err, file) {
28469
+ if (err) {
28470
+ console.error("SETTINGS FILE READ ERROR!!!");
28471
+ console.error(err);
28472
+ return resolve(null);
28473
+ }
28474
+ var result = file.length ? JSON.parse(file.toString()) : {};
28475
+ resolve(result);
28476
+ });
28477
+ });
28478
+ };
28479
+ SettingsHelper.getSettings = function (locale) {
28480
+ var _this = this;
28481
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28482
+ var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, themeLocalizationPath, routing_1;
28483
+ return __generator(this, function (_a) {
28484
+ switch (_a.label) {
28485
+ case 0:
28486
+ isLocal = process.env.NEXT_PUBLIC_ENV === "local";
28487
+ if (!isLocal) return [3 /*break*/, 3];
28488
+ if (!IkasStorefrontConfig.storefrontId) {
28489
+ console.error("Missing storefrontId in the config.json file!");
28490
+ return [2 /*return*/, resolve(null)];
28491
+ }
28492
+ return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.storefrontId)];
28493
+ case 1:
28494
+ storefrontResponse = _a.sent();
28495
+ if (!storefrontResponse)
28496
+ return [2 /*return*/, resolve(null)];
28497
+ storefront = storefrontResponse;
28498
+ return [4 /*yield*/, SettingsHelper.readLocalTheme()];
28499
+ case 2:
28500
+ localTheme = _a.sent();
28501
+ resolve({
28502
+ storefront: storefront,
28503
+ themeLocalization: new IkasStorefrontThemeLocalization({
28504
+ themeJson: localTheme,
28505
+ }),
28506
+ salesChannel: new IkasSalesChannel({
28507
+ id: storefront.salesChannelId,
28508
+ }),
28509
+ routing: storefront.routings.length
28510
+ ? storefront.routings[0]
28511
+ : new IkasStorefrontRouting({}),
28512
+ });
28513
+ return [3 /*break*/, 5];
28514
+ case 3: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
28515
+ case 4:
28516
+ settings = _a.sent();
28517
+ if (!settings)
28518
+ return [2 /*return*/, resolve(null)];
28519
+ storefront_1 = new IkasStorefront(settings.storefront);
28520
+ salesChannel_1 = new IkasSalesChannel(settings.salesChannel);
28521
+ localizationMap = settings.localizationMap;
28522
+ themeLocalizationPath = localizationMap[locale];
28523
+ routing_1 = storefront_1.routings.find(function (r) { return r.id === locale || r.path === locale; });
28524
+ if (!themeLocalizationPath || !routing_1) {
28525
+ console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!");
28526
+ return [2 /*return*/, resolve(null)];
28527
+ }
28528
+ fs.readFile(themeLocalizationPath, {
28529
+ flag: "a+",
28530
+ }, function (err, file) {
28531
+ if (err) {
28532
+ console.error("THEME LOCALZIATION FILE READ ERROR!!!");
28533
+ console.error(err);
28534
+ return resolve(null);
28535
+ }
28536
+ var result = file.length ? JSON.parse(file.toString()) : {};
28537
+ resolve({
28538
+ storefront: storefront_1,
28539
+ themeLocalization: new IkasStorefrontThemeLocalization(result),
28540
+ salesChannel: salesChannel_1,
28541
+ routing: routing_1,
28542
+ });
28543
+ });
28544
+ _a.label = 5;
28545
+ case 5: return [2 /*return*/];
28546
+ }
28547
+ });
28548
+ }); });
28549
+ };
28550
+ SettingsHelper.getPageData = function (context, isServer, pageType) {
28551
+ var _a;
28552
+ return __awaiter(this, void 0, void 0, function () {
28553
+ var locale, settings, storefront, themeLocalization, salesChannel, routing, provider;
28554
+ return __generator(this, function (_b) {
28555
+ switch (_b.label) {
28556
+ case 0:
28557
+ locale = context.locale || context.defaultLocale || "en";
28558
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28559
+ case 1:
28560
+ settings = _b.sent();
28561
+ if (!settings ||
28562
+ !settings.storefront.mainStorefrontThemeId ||
28563
+ !settings.storefront.salesChannelId) {
28564
+ return [2 /*return*/, {
28565
+ props: {},
28566
+ notFound: true,
28567
+ }];
28568
+ }
28569
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, salesChannel = settings.salesChannel, routing = settings.routing;
28570
+ IkasStorefrontConfig.storefrontId = storefront.id;
28571
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28572
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28573
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28574
+ IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
28575
+ IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
28576
+ IkasStorefrontConfig.routings = storefront.routings;
28577
+ provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
28578
+ return [4 /*yield*/, provider.getPageData()];
28579
+ case 2:
28580
+ _b.sent();
28581
+ if (!provider.page) {
28582
+ return [2 /*return*/, {
28583
+ props: {},
28584
+ notFound: true,
28585
+ }];
28586
+ }
28587
+ if (isServer)
28588
+ return [2 /*return*/, provider.nextPageData];
28589
+ else
28590
+ return [2 /*return*/, {
28591
+ props: provider.nextPageData.props,
28592
+ revalidate: 60,
28593
+ }];
28594
+ }
28595
+ });
28596
+ });
28597
+ };
28598
+ SettingsHelper.getStaticProps = function (context, pageType) {
28599
+ return __awaiter(this, void 0, void 0, function () {
28600
+ return __generator(this, function (_a) {
28601
+ switch (_a.label) {
28602
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28603
+ case 1: return [2 /*return*/, _a.sent()];
28604
+ }
28605
+ });
28606
+ });
28607
+ };
28608
+ SettingsHelper.getServerSideProps = function (context, pageType) {
28609
+ return __awaiter(this, void 0, void 0, function () {
28610
+ return __generator(this, function (_a) {
28611
+ switch (_a.label) {
28612
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28613
+ case 1: return [2 /*return*/, _a.sent()];
28614
+ }
28615
+ });
28616
+ });
28617
+ };
28618
+ return SettingsHelper;
28619
+ }());
28620
+
28358
28621
  var Page = function (_a) {
28359
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28622
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28623
+ IkasStorefrontConfig.initWithJson(configJson);
28360
28624
  var router = useRouter();
28361
28625
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28362
28626
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28363
28627
  };
28364
28628
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28365
- var theme, provider;
28366
28629
  return __generator(this, function (_a) {
28367
28630
  switch (_a.label) {
28368
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28369
- case 1:
28370
- theme = _a.sent();
28371
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.INDEX);
28372
- return [4 /*yield*/, provider.getPageData()];
28373
- case 2:
28374
- _a.sent();
28375
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28631
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.INDEX)];
28632
+ case 1: return [2 /*return*/, _a.sent()];
28376
28633
  }
28377
28634
  });
28378
28635
  }); };
@@ -28384,7 +28641,8 @@ var home = /*#__PURE__*/Object.freeze({
28384
28641
  });
28385
28642
 
28386
28643
  var Page$1 = function (_a) {
28387
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28644
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28645
+ IkasStorefrontConfig.initWithJson(configJson);
28388
28646
  var router = useRouter();
28389
28647
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28390
28648
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28414,6 +28672,7 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28414
28672
  productMetaData = metaData.filter(function (m) { return m.targetType && m.targetType === IkasHTMLMetaDataTargetType.PRODUCT; });
28415
28673
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
28416
28674
  productIdList: productMetaData.map(function (p) { return p.targetId; }),
28675
+ priceListId: IkasStorefrontConfig.priceListId,
28417
28676
  })];
28418
28677
  case 2:
28419
28678
  productsResponse = _b.sent();
@@ -28460,25 +28719,10 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28460
28719
  });
28461
28720
  }); };
28462
28721
  var getStaticProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28463
- var theme, provider;
28464
28722
  return __generator(this, function (_a) {
28465
28723
  switch (_a.label) {
28466
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28467
- case 1:
28468
- theme = _a.sent();
28469
- provider = new IkasPageDataProvider(theme, context.params, undefined);
28470
- return [4 /*yield*/, provider.getPageData()];
28471
- case 2:
28472
- _a.sent();
28473
- if (!provider.page) {
28474
- return [2 /*return*/, {
28475
- notFound: true,
28476
- }];
28477
- }
28478
- return [2 /*return*/, {
28479
- props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: JSON.stringify(provider.pageSpecificData || {}) }),
28480
- revalidate: 60,
28481
- }];
28724
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context)];
28725
+ case 1: return [2 /*return*/, _a.sent()];
28482
28726
  }
28483
28727
  });
28484
28728
  }); };
@@ -28517,25 +28761,52 @@ var index$2 = /*#__PURE__*/Object.freeze({
28517
28761
  });
28518
28762
 
28519
28763
  var Page$2 = function (_a) {
28520
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28764
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28765
+ IkasStorefrontConfig.initWithJson(configJson);
28521
28766
  var router = useRouter();
28522
28767
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28523
28768
  return (createElement(IkasPage, { page: page, settingsStr: settingsStr, propValues: propValues }));
28524
28769
  };
28525
28770
  var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28526
- var theme, customPages, customPagePaths;
28771
+ var allSettings, customPagePaths;
28527
28772
  return __generator(this, function (_a) {
28528
28773
  switch (_a.label) {
28529
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28774
+ case 0:
28775
+ if (!context.locales)
28776
+ return [2 /*return*/, {
28777
+ paths: [],
28778
+ fallback: "blocking",
28779
+ }];
28780
+ return [4 /*yield*/, Promise.all(context.locales.map(function (locale) { return SettingsHelper.getSettings(locale); }))];
28530
28781
  case 1:
28531
- theme = _a.sent();
28532
- customPages = theme.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28533
- customPagePaths = customPages.map(function (p) { return ({
28534
- slug: p.slug,
28535
- }); });
28782
+ allSettings = (_a.sent());
28783
+ customPagePaths = [];
28784
+ allSettings.forEach(function (_a) {
28785
+ var themeLocalization = _a.themeLocalization, routing = _a.routing;
28786
+ if (!themeLocalization)
28787
+ return;
28788
+ var customPages = themeLocalization.themeJson.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28789
+ customPages.forEach(function (customPage) {
28790
+ if (customPage.slug &&
28791
+ !customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
28792
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
28793
+ customPagePaths.push({
28794
+ params: { slug: customPage.slug },
28795
+ });
28796
+ }
28797
+ else {
28798
+ customPagePaths.push({
28799
+ params: { slug: customPage.slug },
28800
+ locale: routing.path || routing.id,
28801
+ });
28802
+ }
28803
+ }
28804
+ });
28805
+ });
28536
28806
  return [2 /*return*/, {
28537
28807
  paths: customPagePaths.map(function (p) { return ({
28538
- params: p,
28808
+ params: p.params,
28809
+ locale: p.locale,
28539
28810
  }); }),
28540
28811
  fallback: "blocking",
28541
28812
  }];
@@ -28543,17 +28814,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28543
28814
  });
28544
28815
  }); };
28545
28816
  var getStaticProps$2 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28546
- var theme, provider;
28547
28817
  return __generator(this, function (_a) {
28548
28818
  switch (_a.label) {
28549
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28550
- case 1:
28551
- theme = _a.sent();
28552
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CUSTOM);
28553
- return [4 /*yield*/, provider.getPageData()];
28554
- case 2:
28555
- _a.sent();
28556
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28819
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.CUSTOM)];
28820
+ case 1: return [2 /*return*/, _a.sent()];
28557
28821
  }
28558
28822
  });
28559
28823
  }); };
@@ -28566,18 +28830,37 @@ var _slug_ = /*#__PURE__*/Object.freeze({
28566
28830
  });
28567
28831
 
28568
28832
  var CheckoutPage = function (_a) {
28569
- var checkoutStr = _a.checkoutStr, queryParams = _a.queryParams;
28833
+ var checkoutStr = _a.checkoutStr, configJson = _a.configJson, others = __rest(_a, ["checkoutStr", "configJson"]);
28834
+ IkasStorefrontConfig.initWithJson(configJson);
28570
28835
  Analytics.disableHTML();
28571
28836
  var checkout = new IkasCheckout(JSON.parse(checkoutStr));
28572
- return createElement(IkasCheckoutPage, { checkout: checkout, queryParams: queryParams });
28837
+ return createElement(IkasCheckoutPage, __assign({ checkout: checkout }, others));
28573
28838
  };
28574
28839
  var _id_ = observer(CheckoutPage);
28575
28840
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28576
- var id, redirect, checkout;
28841
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28577
28842
  return __generator(this, function (_a) {
28578
28843
  switch (_a.label) {
28579
28844
  case 0:
28580
28845
  id = context.query.id;
28846
+ locale = context.locale || context.defaultLocale || "en";
28847
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28848
+ case 1:
28849
+ settings = _a.sent();
28850
+ // TODO maybe remove this and convert this page to static
28851
+ if (!settings ||
28852
+ !settings.storefront.mainStorefrontThemeId ||
28853
+ !settings.storefront.salesChannelId) {
28854
+ return [2 /*return*/, {
28855
+ props: {},
28856
+ notFound: true,
28857
+ }];
28858
+ }
28859
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, routing = settings.routing;
28860
+ IkasStorefrontConfig.storefrontId = storefront.id;
28861
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28862
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28863
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28581
28864
  redirect = function () {
28582
28865
  context.res.writeHead(302, { Location: "/" });
28583
28866
  context.res.end();
@@ -28587,12 +28870,15 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28587
28870
  return [2 /*return*/, redirect()];
28588
28871
  }
28589
28872
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
28590
- case 1:
28873
+ case 2:
28591
28874
  checkout = _a.sent();
28592
28875
  if (checkout) {
28593
28876
  return [2 /*return*/, {
28594
28877
  props: {
28595
28878
  checkoutStr: JSON.stringify(checkout),
28879
+ returnPolicy: themeLocalization.returnPolicy || "",
28880
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28881
+ termsOfService: themeLocalization.termsOfService || "",
28596
28882
  queryParams: context.query,
28597
28883
  },
28598
28884
  }];
@@ -28611,23 +28897,17 @@ var _id_$1 = /*#__PURE__*/Object.freeze({
28611
28897
  });
28612
28898
 
28613
28899
  var Page$3 = function (_a) {
28614
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28900
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28901
+ IkasStorefrontConfig.initWithJson(configJson);
28615
28902
  var router = useRouter();
28616
28903
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28617
28904
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28618
28905
  };
28619
28906
  var getStaticProps$3 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28620
- var theme, provider;
28621
28907
  return __generator(this, function (_a) {
28622
28908
  switch (_a.label) {
28623
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28624
- case 1:
28625
- theme = _a.sent();
28626
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ACCOUNT);
28627
- return [4 /*yield*/, provider.getPageData()];
28628
- case 2:
28629
- _a.sent();
28630
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28909
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ACCOUNT)];
28910
+ case 1: return [2 /*return*/, _a.sent()];
28631
28911
  }
28632
28912
  });
28633
28913
  }); };
@@ -28639,23 +28919,17 @@ var index$3 = /*#__PURE__*/Object.freeze({
28639
28919
  });
28640
28920
 
28641
28921
  var Page$4 = function (_a) {
28642
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28922
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28923
+ IkasStorefrontConfig.initWithJson(configJson);
28643
28924
  var router = useRouter();
28644
28925
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28645
28926
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28646
28927
  };
28647
28928
  var getStaticProps$4 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28648
- var theme, provider;
28649
28929
  return __generator(this, function (_a) {
28650
28930
  switch (_a.label) {
28651
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28652
- case 1:
28653
- theme = _a.sent();
28654
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ADDRESSES);
28655
- return [4 /*yield*/, provider.getPageData()];
28656
- case 2:
28657
- _a.sent();
28658
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28931
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ADDRESSES)];
28932
+ case 1: return [2 /*return*/, _a.sent()];
28659
28933
  }
28660
28934
  });
28661
28935
  }); };
@@ -28667,23 +28941,17 @@ var addresses = /*#__PURE__*/Object.freeze({
28667
28941
  });
28668
28942
 
28669
28943
  var Page$5 = function (_a) {
28670
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28944
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28945
+ IkasStorefrontConfig.initWithJson(configJson);
28671
28946
  var router = useRouter();
28672
28947
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28673
28948
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28674
28949
  };
28675
28950
  var getStaticProps$5 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28676
- var theme, provider;
28677
28951
  return __generator(this, function (_a) {
28678
28952
  switch (_a.label) {
28679
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28680
- case 1:
28681
- theme = _a.sent();
28682
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDERS);
28683
- return [4 /*yield*/, provider.getPageData()];
28684
- case 2:
28685
- _a.sent();
28686
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28953
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.ORDERS)];
28954
+ case 1: return [2 /*return*/, _a.sent()];
28687
28955
  }
28688
28956
  });
28689
28957
  }); };
@@ -28695,23 +28963,17 @@ var index$4 = /*#__PURE__*/Object.freeze({
28695
28963
  });
28696
28964
 
28697
28965
  var Page$6 = function (_a) {
28698
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28966
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28967
+ IkasStorefrontConfig.initWithJson(configJson);
28699
28968
  var router = useRouter();
28700
28969
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28701
28970
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28702
28971
  };
28703
28972
  var getServerSideProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28704
- var theme, provider;
28705
28973
  return __generator(this, function (_a) {
28706
28974
  switch (_a.label) {
28707
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28708
- case 1:
28709
- theme = _a.sent();
28710
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDER_DETAIL);
28711
- return [4 /*yield*/, provider.getPageData()];
28712
- case 2:
28713
- _a.sent();
28714
- return [2 /*return*/, provider.nextPageData];
28975
+ case 0: return [4 /*yield*/, SettingsHelper.getServerSideProps(context, IkasThemePageType.ORDER_DETAIL)];
28976
+ case 1: return [2 /*return*/, _a.sent()];
28715
28977
  }
28716
28978
  });
28717
28979
  }); };
@@ -28723,23 +28985,17 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
28723
28985
  });
28724
28986
 
28725
28987
  var Page$7 = function (_a) {
28726
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28988
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28989
+ IkasStorefrontConfig.initWithJson(configJson);
28727
28990
  var router = useRouter();
28728
28991
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28729
28992
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28730
28993
  };
28731
28994
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28732
- var theme, provider;
28733
28995
  return __generator(this, function (_a) {
28734
28996
  switch (_a.label) {
28735
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28736
- case 1:
28737
- theme = _a.sent();
28738
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.LOGIN);
28739
- return [4 /*yield*/, provider.getPageData()];
28740
- case 2:
28741
- _a.sent();
28742
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28997
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.LOGIN)];
28998
+ case 1: return [2 /*return*/, _a.sent()];
28743
28999
  }
28744
29000
  });
28745
29001
  }); };
@@ -28751,23 +29007,17 @@ var login = /*#__PURE__*/Object.freeze({
28751
29007
  });
28752
29008
 
28753
29009
  var Page$8 = function (_a) {
28754
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29010
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29011
+ IkasStorefrontConfig.initWithJson(configJson);
28755
29012
  var router = useRouter();
28756
29013
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28757
29014
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28758
29015
  };
28759
29016
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28760
- var theme, provider;
28761
29017
  return __generator(this, function (_a) {
28762
29018
  switch (_a.label) {
28763
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28764
- case 1:
28765
- theme = _a.sent();
28766
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.REGISTER);
28767
- return [4 /*yield*/, provider.getPageData()];
28768
- case 2:
28769
- _a.sent();
28770
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29019
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.REGISTER)];
29020
+ case 1: return [2 /*return*/, _a.sent()];
28771
29021
  }
28772
29022
  });
28773
29023
  }); };
@@ -28779,23 +29029,17 @@ var register = /*#__PURE__*/Object.freeze({
28779
29029
  });
28780
29030
 
28781
29031
  var Page$9 = function (_a) {
28782
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29032
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29033
+ IkasStorefrontConfig.initWithJson(configJson);
28783
29034
  var router = useRouter();
28784
29035
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28785
29036
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28786
29037
  };
28787
29038
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28788
- var theme, provider;
28789
29039
  return __generator(this, function (_a) {
28790
29040
  switch (_a.label) {
28791
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28792
- case 1:
28793
- theme = _a.sent();
28794
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FORGOT_PASSWORD);
28795
- return [4 /*yield*/, provider.getPageData()];
28796
- case 2:
28797
- _a.sent();
28798
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29041
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FORGOT_PASSWORD)];
29042
+ case 1: return [2 /*return*/, _a.sent()];
28799
29043
  }
28800
29044
  });
28801
29045
  }); };
@@ -28807,23 +29051,17 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
28807
29051
  });
28808
29052
 
28809
29053
  var Page$a = function (_a) {
28810
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29054
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29055
+ IkasStorefrontConfig.initWithJson(configJson);
28811
29056
  var router = useRouter();
28812
29057
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28813
29058
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28814
29059
  };
28815
29060
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28816
- var theme, provider;
28817
29061
  return __generator(this, function (_a) {
28818
29062
  switch (_a.label) {
28819
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28820
- case 1:
28821
- theme = _a.sent();
28822
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.RECOVER_PASSWORD);
28823
- return [4 /*yield*/, provider.getPageData()];
28824
- case 2:
28825
- _a.sent();
28826
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29063
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.RECOVER_PASSWORD)];
29064
+ case 1: return [2 /*return*/, _a.sent()];
28827
29065
  }
28828
29066
  });
28829
29067
  }); };
@@ -28835,7 +29073,8 @@ var recoverPassword = /*#__PURE__*/Object.freeze({
28835
29073
  });
28836
29074
 
28837
29075
  var Page$b = function (_a) {
28838
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29076
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29077
+ IkasStorefrontConfig.initWithJson(configJson);
28839
29078
  var router = useRouter();
28840
29079
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28841
29080
  var store = IkasStorefrontConfig.store;
@@ -28845,17 +29084,10 @@ var Page$b = function (_a) {
28845
29084
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28846
29085
  };
28847
29086
  var getStaticProps$a = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28848
- var theme, provider;
28849
29087
  return __generator(this, function (_a) {
28850
29088
  switch (_a.label) {
28851
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28852
- case 1:
28853
- theme = _a.sent();
28854
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CART);
28855
- return [4 /*yield*/, provider.getPageData()];
28856
- case 2:
28857
- _a.sent();
28858
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29089
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.CART)];
29090
+ case 1: return [2 /*return*/, _a.sent()];
28859
29091
  }
28860
29092
  });
28861
29093
  }); };
@@ -28878,23 +29110,17 @@ var editor$1 = /*#__PURE__*/Object.freeze({
28878
29110
  });
28879
29111
 
28880
29112
  var Page$d = function (_a) {
28881
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29113
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29114
+ IkasStorefrontConfig.initWithJson(configJson);
28882
29115
  var router = useRouter();
28883
29116
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28884
29117
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28885
29118
  };
28886
29119
  var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28887
- var theme, provider;
28888
29120
  return __generator(this, function (_a) {
28889
29121
  switch (_a.label) {
28890
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28891
- case 1:
28892
- theme = _a.sent();
28893
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FAVORITE_PRODUCTS);
28894
- return [4 /*yield*/, provider.getPageData()];
28895
- case 2:
28896
- _a.sent();
28897
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29122
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FAVORITE_PRODUCTS)];
29123
+ case 1: return [2 /*return*/, _a.sent()];
28898
29124
  }
28899
29125
  });
28900
29126
  }); };
@@ -28906,7 +29132,8 @@ var favoriteProducts = /*#__PURE__*/Object.freeze({
28906
29132
  });
28907
29133
 
28908
29134
  var Page$e = function (_a) {
28909
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29135
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29136
+ IkasStorefrontConfig.initWithJson(configJson);
28910
29137
  var router = useRouter();
28911
29138
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28912
29139
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28920,17 +29147,10 @@ var Page$e = function (_a) {
28920
29147
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28921
29148
  };
28922
29149
  var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28923
- var theme, provider;
28924
29150
  return __generator(this, function (_a) {
28925
29151
  switch (_a.label) {
28926
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28927
- case 1:
28928
- theme = _a.sent();
28929
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.SEARCH);
28930
- return [4 /*yield*/, provider.getPageData()];
28931
- case 2:
28932
- _a.sent();
28933
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29152
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.SEARCH)];
29153
+ case 1: return [2 /*return*/, _a.sent()];
28934
29154
  }
28935
29155
  });
28936
29156
  }); };
@@ -28942,23 +29162,29 @@ var search = /*#__PURE__*/Object.freeze({
28942
29162
  });
28943
29163
 
28944
29164
  var Page$f = function (_a) {
28945
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29165
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29166
+ if (!propValuesStr || !page)
29167
+ return createElement(Error$1, { statusCode: 404 });
29168
+ IkasStorefrontConfig.initWithJson(configJson);
28946
29169
  var router = useRouter();
28947
29170
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28948
29171
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28949
29172
  };
28950
29173
  var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28951
- var theme, provider;
29174
+ var props;
28952
29175
  return __generator(this, function (_a) {
28953
29176
  switch (_a.label) {
28954
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
29177
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.NOT_FOUND)];
28955
29178
  case 1:
28956
- theme = _a.sent();
28957
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.NOT_FOUND);
28958
- return [4 /*yield*/, provider.getPageData()];
28959
- case 2:
28960
- _a.sent();
28961
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29179
+ props = _a.sent();
29180
+ //@ts-ignore
29181
+ if (props.notFound)
29182
+ return [2 /*return*/, {
29183
+ props: {},
29184
+ revalidate: 60,
29185
+ }];
29186
+ else
29187
+ return [2 /*return*/, props];
28962
29188
  }
28963
29189
  });
28964
29190
  }); };
@@ -28975,13 +29201,84 @@ configure({
28975
29201
  var IkasBaseStore = /** @class */ (function () {
28976
29202
  function IkasBaseStore() {
28977
29203
  this.currentPageType = null;
29204
+ this.localeOptions = [];
29205
+ this.showLocaleOptions = false;
29206
+ this.localeChecked = false;
28978
29207
  this.customerStore = new IkasCustomerStore(this);
28979
29208
  this.cartStore = new IkasCartStore(this);
28980
29209
  makeObservable(this, {
28981
29210
  currentPageType: observable,
29211
+ localeOptions: observable,
29212
+ showLocaleOptions: observable,
28982
29213
  });
28983
29214
  }
29215
+ IkasBaseStore.prototype.checkLocalization = function () {
29216
+ return __awaiter(this, void 0, void 0, function () {
29217
+ var myCountryCode, currentRouting, correctRouting, isCorrectLocale, countries_1, localeOptions_1;
29218
+ return __generator(this, function (_a) {
29219
+ switch (_a.label) {
29220
+ case 0:
29221
+ if (this.localeChecked)
29222
+ return [2 /*return*/];
29223
+ if (typeof window === undefined) {
29224
+ console.warn("checkRegion should be called on the client side!");
29225
+ return [2 /*return*/];
29226
+ }
29227
+ return [4 /*yield*/, IkasCountryAPI.getMyCountry()];
29228
+ case 1:
29229
+ myCountryCode = _a.sent();
29230
+ currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
29231
+ if (!(currentRouting && myCountryCode)) return [3 /*break*/, 3];
29232
+ correctRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); });
29233
+ isCorrectLocale = IkasStorefrontConfig.storefrontRoutingId === (correctRouting === null || correctRouting === void 0 ? void 0 : correctRouting.id);
29234
+ return [4 /*yield*/, IkasCountryAPI.listCountries()];
29235
+ case 2:
29236
+ countries_1 = _a.sent();
29237
+ localeOptions_1 = [];
29238
+ IkasStorefrontConfig.routings.map(function (r) {
29239
+ var _a;
29240
+ if ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length) {
29241
+ r.countryCodes.forEach(function (countryCode) {
29242
+ var _a;
29243
+ var country = countries_1.find(function (c) { return c.iso2 === countryCode; });
29244
+ localeOptions_1.push({
29245
+ id: v4(),
29246
+ countryName: (country === null || country === void 0 ? void 0 : country.native) || (country === null || country === void 0 ? void 0 : country.name) || "",
29247
+ routing: r,
29248
+ isRecommended: ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode)) || false,
29249
+ });
29250
+ });
29251
+ }
29252
+ else {
29253
+ localeOptions_1.push({
29254
+ id: v4(),
29255
+ routing: r,
29256
+ isRecommended: !IkasStorefrontConfig.routings.some(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); }),
29257
+ });
29258
+ }
29259
+ });
29260
+ this.localeOptions = localeOptions_1;
29261
+ if (!isCorrectLocale) {
29262
+ this.showLocaleOptions = true;
29263
+ }
29264
+ this.localeChecked = true;
29265
+ _a.label = 3;
29266
+ case 3: return [2 /*return*/];
29267
+ }
29268
+ });
29269
+ });
29270
+ };
29271
+ IkasBaseStore.prototype.setLocalization = function (localeOption) {
29272
+ document.cookie = "NEXT_LOCALE=" + (localeOption.routing.path || localeOption.routing.id) + "; expires=Thu, 1 Dec 2050 12:00:00 UTC";
29273
+ if (localeOption.routing.domain) {
29274
+ window.location.replace("https://" + localeOption.routing.domain);
29275
+ }
29276
+ else {
29277
+ window.location.replace(window.location.origin +
29278
+ (localeOption.routing.path ? "/" + localeOption.routing.path : ""));
29279
+ }
29280
+ };
28984
29281
  return IkasBaseStore;
28985
29282
  }());
28986
29283
 
28987
- export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, Analytics, AnalyticsBody, AnalyticsHead, cart as CartPage, _id_$1 as CheckoutPage, ContactForm, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, favoriteProducts as FavoriteProductsPage, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, IkasAmountTypeEnum$1 as IkasAmountTypeEnum, IkasApplicableProductFilterValue, IkasBaseStore, IkasBrand, IkasBrandAPI, IkasBrandList, IkasBrandListPropValue, IkasBrandListSortType, IkasBrandListType, IkasBrandPropValue, IkasCardAssociation, IkasCardType, IkasCartAPI, IkasCategory, IkasCategoryAPI, IkasCategoryList, IkasCategoryListPropValue, IkasCategoryListSortType, IkasCategoryListType, IkasCategoryPropValue, IkasCheckout, IkasCheckoutAPI, IkasCheckoutPage, IkasCheckoutRecoveryEmailStatus, IkasCheckoutRecoveryStatus, IkasCheckoutStatus, IkasCityAPI, IkasContactForm, IkasContactFormAPI, IkasCountryAPI, IkasCustomer, IkasCustomerAPI, IkasCustomerAddress, IkasDistrictAPI, IkasFavoriteProduct, IkasFavoriteProductAPI, IkasHTMLMetaData, IkasHTMLMetaDataAPI, IkasHTMLMetaDataTargetType, IkasImage, IkasLinkPropValue, IkasLinkType, IkasMerchantAPI, IkasMerchantSettings, IkasNavigationLink, IkasOrder, IkasOrderCancelledReason, IkasOrderLineItem, IkasOrderPackageFulfillStatus, IkasOrderPackageStatus, IkasOrderPaymentStatus, IkasOrderShippingMethod, IkasOrderStatus, IkasOrderTransaction, IkasPage, IkasPageComponentPropValue, IkasPageDataProvider, IkasPageEditor, IkasPageHead, IkasPaymentMethod, IkasProduct, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductFilter, IkasProductFilterDisplayType, IkasProductFilterSettings, IkasProductFilterSortType, IkasProductFilterType, IkasProductFilterValue, IkasProductList, IkasProductListPropValue, IkasProductListSortType, IkasProductListType, IkasProductPrice, IkasProductSearchAPI, IkasProductType, IkasProductVariant, IkasProductVariantType, IkasShippingMethod, IkasShippingMethodEnum, IkasStateAPI, IkasStorefrontAPI, IkasStorefrontConfig, IkasTheme, IkasThemeAPI, IkasThemeComponent, IkasThemeComponentProp, IkasThemeComponentPropType, IkasThemeCustomData, IkasThemeCustomDataType, IkasThemePage, IkasThemePageComponent, IkasThemePageType, IkasThemeSettings, IkasTransactionStatusEnum, IkasTransactionTypeEnum, IkasVariantSelectionType, IkasVariantType, IkasVariantTypeAPI, IkasVariantValue, Image, home as IndexPage, LessThanRule, LoginForm, login as LoginPage, MaxRule, MinRule, _404 as NotFoundPage, _id_$2 as OrderDetailPage, OrderLineItemStatusEnum$1 as OrderLineItemStatusEnum, index$4 as OrdersPage, PhoneRule, RangeValue, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, search as SearchPage, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, parseRangeStr, pascalCase, stringToSlug, validatePhoneNumber };
29284
+ export { AccountInfoForm, index$3 as AccountPage, AddressForm, addresses as AddressesPage, Analytics, AnalyticsBody, AnalyticsHead, cart as CartPage, _id_$1 as CheckoutPage, ContactForm, _slug_ as CustomPage, editor$1 as EditorPage, EmailRule, EqualsRule, favoriteProducts as FavoriteProductsPage, ForgotPasswordForm, forgotPassword as ForgotPasswordPage, IkasAmountTypeEnum$1 as IkasAmountTypeEnum, IkasApplicableProductFilterValue, IkasBaseStore, IkasBrand, IkasBrandAPI, IkasBrandList, IkasBrandListPropValue, IkasBrandListSortType, IkasBrandListType, IkasBrandPropValue, IkasCardAssociation, IkasCardType, IkasCartAPI, IkasCategory, IkasCategoryAPI, IkasCategoryList, IkasCategoryListPropValue, IkasCategoryListSortType, IkasCategoryListType, IkasCategoryPropValue, IkasCheckout, IkasCheckoutAPI, IkasCheckoutPage, IkasCheckoutRecoveryEmailStatus, IkasCheckoutRecoveryStatus, IkasCheckoutStatus, IkasCityAPI, IkasContactForm, IkasContactFormAPI, IkasCountryAPI, IkasCustomer, IkasCustomerAPI, IkasCustomerAddress, IkasDistrictAPI, IkasFavoriteProduct, IkasFavoriteProductAPI, IkasHTMLMetaData, IkasHTMLMetaDataAPI, IkasHTMLMetaDataTargetType, IkasImage, IkasLinkPropValue, IkasLinkType, IkasMerchantAPI, IkasMerchantSettings, IkasNavigationLink, IkasOrder, IkasOrderCancelledReason, IkasOrderLineItem, IkasOrderPackageFulfillStatus, IkasOrderPackageStatus, IkasOrderPaymentStatus, IkasOrderShippingMethod, IkasOrderStatus, IkasOrderTransaction, IkasPage, IkasPageComponentPropValue, IkasPageDataProvider, IkasPageEditor, IkasPageHead, IkasPaymentMethod, IkasProduct, IkasProductAttribute, IkasProductAttributeAPI, IkasProductAttributeValue, IkasProductDetail, IkasProductDetailPropValue, IkasProductFilter, IkasProductFilterDisplayType, IkasProductFilterSettings, IkasProductFilterSortType, IkasProductFilterType, IkasProductFilterValue, IkasProductList, IkasProductListPropValue, IkasProductListSortType, IkasProductListType, IkasProductPrice, IkasProductSearchAPI, IkasProductType, IkasProductVariant, IkasProductVariantType, IkasShippingMethod, IkasShippingMethodEnum, IkasStateAPI, IkasStorefrontConfig, IkasTheme, IkasThemeComponent, IkasThemeComponentProp, IkasThemeComponentPropType, IkasThemeCustomData, IkasThemeCustomDataType, IkasThemePage, IkasThemePageComponent, IkasThemePageType, IkasThemeSettings, IkasTransactionStatusEnum, IkasTransactionTypeEnum, IkasVariantSelectionType, IkasVariantType, IkasVariantTypeAPI, IkasVariantValue, Image, home as IndexPage, LessThanRule, LoginForm, login as LoginPage, MaxRule, MinRule, _404 as NotFoundPage, _id_$2 as OrderDetailPage, OrderLineItemStatusEnum$1 as OrderLineItemStatusEnum, index$4 as OrdersPage, PhoneRule, RangeValue, RecoverPasswordForm, recoverPassword as RecoverPasswordPage, RegisterForm, register as RegisterPage, RequiredRule, search as SearchPage, index$2 as SlugPage, ValidationRule, Validator, ValidatorErrorType, apollo, decodeBase64, formatMoney, parseRangeStr, pascalCase, stringToSlug, validatePhoneNumber };