@ikas/storefront 0.0.101 → 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 -430
  16. package/build/index.js +730 -433
  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 = 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:
@@ -16314,10 +16328,10 @@ var CheckoutViewModel = /** @class */ (function () {
16314
16328
  }
16315
16329
  return [3 /*break*/, 6];
16316
16330
  case 5:
16317
- err_5 = _a.sent();
16318
- if (err_5.type) {
16319
- console.log(err_5);
16320
- this.error = err_5;
16331
+ err_4 = _a.sent();
16332
+ if (err_4.type) {
16333
+ console.log(err_4);
16334
+ this.error = err_4;
16321
16335
  }
16322
16336
  else {
16323
16337
  this.error = {
@@ -16396,6 +16410,9 @@ var CheckoutViewModel = /** @class */ (function () {
16396
16410
  }); };
16397
16411
  this.checkout = checkout;
16398
16412
  this.router = router;
16413
+ this.returnPolicy = returnPolicy;
16414
+ this.privacyPolicy = privacyPolicy;
16415
+ this.termsOfService = termsOfService;
16399
16416
  this.init(queryParams);
16400
16417
  makeAutoObservable(this);
16401
16418
  }
@@ -16406,15 +16423,6 @@ var CheckoutViewModel = /** @class */ (function () {
16406
16423
  enumerable: false,
16407
16424
  configurable: true
16408
16425
  });
16409
- Object.defineProperty(CheckoutViewModel.prototype, "storefrontRegion", {
16410
- get: function () {
16411
- var _a;
16412
- return ((_a = this.storefront) === null || _a === void 0 ? void 0 : _a.regions.length) ? this.storefront.regions[0]
16413
- : undefined;
16414
- },
16415
- enumerable: false,
16416
- configurable: true
16417
- });
16418
16426
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
16419
16427
  get: function () {
16420
16428
  var _this = this;
@@ -17078,6 +17086,7 @@ var IkasCustomerStore = /** @class */ (function () {
17078
17086
  return [2 /*return*/, []];
17079
17087
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
17080
17088
  productIdList: favoriteProductsResult.map(function (fP) { return fP.productId; }),
17089
+ priceListId: IkasStorefrontConfig.priceListId,
17081
17090
  })];
17082
17091
  case 2:
17083
17092
  productsResult = _b.sent();
@@ -21935,7 +21944,10 @@ var IkasProductList = /** @class */ (function () {
21935
21944
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21936
21945
  get: function () {
21937
21946
  var _a;
21938
- 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));
21939
21951
  },
21940
21952
  enumerable: false,
21941
21953
  configurable: true
@@ -21998,13 +22010,20 @@ var IkasProductList = /** @class */ (function () {
21998
22010
  });
21999
22011
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
22000
22012
  get: function () {
22001
- var _a;
22013
+ var _this = this;
22014
+ var _a, _b, _c;
22002
22015
  var queryParams = {};
22003
22016
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
22004
22017
  queryParams[f.key] = f.keyList;
22005
22018
  });
22006
22019
  if (this._searchKeyword)
22007
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
+ }
22008
22027
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
22009
22028
  },
22010
22029
  enumerable: false,
@@ -22059,6 +22078,7 @@ var IkasProductList = /** @class */ (function () {
22059
22078
  categoryIdList: this._filterCategoryId
22060
22079
  ? [this._filterCategoryId]
22061
22080
  : undefined,
22081
+ priceListId: IkasStorefrontConfig.priceListId,
22062
22082
  query: this._searchKeyword,
22063
22083
  })];
22064
22084
  case 1: return [2 /*return*/, _c.sent()];
@@ -22086,6 +22106,7 @@ var IkasProductList = /** @class */ (function () {
22086
22106
  };
22087
22107
  IkasProductList.prototype.applyQueryParamFilters = function (queryParams) {
22088
22108
  var _this = this;
22109
+ var _a;
22089
22110
  try {
22090
22111
  queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach(function (value, key) {
22091
22112
  var _a;
@@ -22097,6 +22118,15 @@ var IkasProductList = /** @class */ (function () {
22097
22118
  var querySearch = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("s");
22098
22119
  if (querySearch)
22099
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
+ }
22100
22130
  }
22101
22131
  catch (err) {
22102
22132
  console.log(err);
@@ -22143,12 +22173,32 @@ var IkasProductList = /** @class */ (function () {
22143
22173
  var _a;
22144
22174
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22145
22175
  this._searchKeyword = "";
22176
+ if (this._pageType !== IkasThemePageType.CATEGORY) {
22177
+ this._filterCategoryId = undefined;
22178
+ }
22146
22179
  this.applyFilters();
22147
22180
  };
22148
- IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
22181
+ IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22149
22182
  var _a;
22150
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22151
- (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
+ });
22152
22202
  };
22153
22203
  IkasProductList.prototype.toJSON = function () {
22154
22204
  return {
@@ -24236,7 +24286,7 @@ var IkasCartAPI = /** @class */ (function () {
24236
24286
  return __generator(this, function (_b) {
24237
24287
  switch (_b.label) {
24238
24288
  case 0:
24239
- 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 "])));
24240
24290
  _b.label = 1;
24241
24291
  case 1:
24242
24292
  _b.trys.push([1, 3, , 4]);
@@ -24271,7 +24321,7 @@ var IkasCartAPI = /** @class */ (function () {
24271
24321
  return __generator(this, function (_b) {
24272
24322
  switch (_b.label) {
24273
24323
  case 0:
24274
- 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 "])));
24275
24325
  _b.label = 1;
24276
24326
  case 1:
24277
24327
  _b.trys.push([1, 3, , 4]);
@@ -24743,13 +24793,13 @@ var IkasCheckoutAPI = /** @class */ (function () {
24743
24793
  });
24744
24794
  });
24745
24795
  };
24746
- IkasCheckoutAPI.checkStocks = function (lines) {
24796
+ IkasCheckoutAPI.checkStocks = function (lines, stockLocationIdList) {
24747
24797
  return __awaiter(this, void 0, void 0, function () {
24748
24798
  var QUERY, _a, data, errors, err_7;
24749
24799
  return __generator(this, function (_b) {
24750
24800
  switch (_b.label) {
24751
24801
  case 0:
24752
- 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 "])));
24753
24803
  _b.label = 1;
24754
24804
  case 1:
24755
24805
  _b.trys.push([1, 3, , 4]);
@@ -24759,6 +24809,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
24759
24809
  query: QUERY,
24760
24810
  variables: {
24761
24811
  lines: lines,
24812
+ stockLocationIdList: stockLocationIdList,
24762
24813
  },
24763
24814
  })];
24764
24815
  case 2:
@@ -24841,7 +24892,7 @@ var IkasCountryAPI = /** @class */ (function () {
24841
24892
  return __generator(this, function (_b) {
24842
24893
  switch (_b.label) {
24843
24894
  case 0:
24844
- 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 "])));
24845
24896
  _b.label = 1;
24846
24897
  case 1:
24847
24898
  _b.trys.push([1, 3, , 4]);
@@ -24857,6 +24908,8 @@ var IkasCountryAPI = /** @class */ (function () {
24857
24908
  return [2 /*return*/, data.listCountry.map(function (c) { return ({
24858
24909
  id: c.id,
24859
24910
  name: pascalCase(c.locationTranslations.tr),
24911
+ native: c.native || "",
24912
+ iso2: c.iso2 || undefined,
24860
24913
  iso3: c.iso3 || undefined,
24861
24914
  phoneCode: c.phoneCode || undefined,
24862
24915
  }); })];
@@ -24870,13 +24923,13 @@ var IkasCountryAPI = /** @class */ (function () {
24870
24923
  });
24871
24924
  });
24872
24925
  };
24873
- IkasCountryAPI.listShippingCountries = function () {
24926
+ IkasCountryAPI.listShippingCountries = function (storefrontId) {
24874
24927
  return __awaiter(this, void 0, void 0, function () {
24875
24928
  var QUERY, _a, data, errors, err_2;
24876
24929
  return __generator(this, function (_b) {
24877
24930
  switch (_b.label) {
24878
24931
  case 0:
24879
- 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 "])));
24880
24933
  _b.label = 1;
24881
24934
  case 1:
24882
24935
  _b.trys.push([1, 3, , 4]);
@@ -24884,6 +24937,9 @@ var IkasCountryAPI = /** @class */ (function () {
24884
24937
  .getClient()
24885
24938
  .query({
24886
24939
  query: QUERY,
24940
+ variables: {
24941
+ storefrontId: storefrontId,
24942
+ },
24887
24943
  })];
24888
24944
  case 2:
24889
24945
  _a = _b.sent(), data = _a.data, errors = _a.errors;
@@ -24902,9 +24958,34 @@ var IkasCountryAPI = /** @class */ (function () {
24902
24958
  });
24903
24959
  });
24904
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
+ };
24905
24986
  return IkasCountryAPI;
24906
24987
  }());
24907
- var templateObject_1$5, templateObject_2$3;
24988
+ var templateObject_1$5, templateObject_2$3, templateObject_3$1;
24908
24989
 
24909
24990
  var IkasCustomerAPI = /** @class */ (function () {
24910
24991
  function IkasCustomerAPI() {
@@ -24989,7 +25070,7 @@ var IkasCustomerAPI = /** @class */ (function () {
24989
25070
  return __generator(this, function (_b) {
24990
25071
  switch (_b.label) {
24991
25072
  case 0:
24992
- 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 "])));
24993
25074
  _b.label = 1;
24994
25075
  case 1:
24995
25076
  _b.trys.push([1, 3, , 4]);
@@ -25305,7 +25386,7 @@ var IkasCustomerAPI = /** @class */ (function () {
25305
25386
  };
25306
25387
  return IkasCustomerAPI;
25307
25388
  }());
25308
- 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;
25309
25390
 
25310
25391
  var IkasDistrictAPI = /** @class */ (function () {
25311
25392
  function IkasDistrictAPI() {
@@ -25758,7 +25839,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25758
25839
  return __generator(this, function (_b) {
25759
25840
  switch (_b.label) {
25760
25841
  case 0:
25761
- 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 "])));
25762
25843
  _b.label = 1;
25763
25844
  case 1:
25764
25845
  _b.trys.push([1, 3, , 4]);
@@ -25784,7 +25865,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25784
25865
  };
25785
25866
  return IkasFavoriteProductAPI;
25786
25867
  }());
25787
- var templateObject_1$c, templateObject_2$6, templateObject_3$2;
25868
+ var templateObject_1$c, templateObject_2$6, templateObject_3$3;
25788
25869
 
25789
25870
  var IkasContactFormAPI = /** @class */ (function () {
25790
25871
  function IkasContactFormAPI() {
@@ -25877,150 +25958,6 @@ var IkasStateAPI = /** @class */ (function () {
25877
25958
  }());
25878
25959
  var templateObject_1$e;
25879
25960
 
25880
- var IkasStorefrontDomain = /** @class */ (function () {
25881
- function IkasStorefrontDomain(data) {
25882
- if (data === void 0) { data = {}; }
25883
- this.id = data.id || "";
25884
- this.merchantDomainId = data.merchantDomainId || "";
25885
- this.name = data.name || "";
25886
- this.redirectDomainName = data.redirectDomainName || null;
25887
- makeAutoObservable(this);
25888
- }
25889
- return IkasStorefrontDomain;
25890
- }());
25891
-
25892
- var IkasStorefrontLocation = /** @class */ (function () {
25893
- function IkasStorefrontLocation(data) {
25894
- if (data === void 0) { data = {}; }
25895
- this.countryId = data.countryId || "";
25896
- this.stateId = data.stateId || null;
25897
- makeAutoObservable(this);
25898
- }
25899
- return IkasStorefrontLocation;
25900
- }());
25901
-
25902
- var IkasStorefrontRoute = /** @class */ (function () {
25903
- function IkasStorefrontRoute(data) {
25904
- if (data === void 0) { data = {}; }
25905
- this.domainId = data.domainId || "";
25906
- this.useSubPath = data.useSubPath || false;
25907
- makeAutoObservable(this);
25908
- }
25909
- return IkasStorefrontRoute;
25910
- }());
25911
-
25912
- var IkasStorefrontRegion = /** @class */ (function () {
25913
- function IkasStorefrontRegion(data) {
25914
- if (data === void 0) { data = {}; }
25915
- // Extra
25916
- this.theme = new IkasTheme();
25917
- this.id = data.id || "";
25918
- this.locale = data.locale || "";
25919
- this.themeJSON = data.themeJSON || "";
25920
- this.shipping = data.shipping || null;
25921
- this.paymentSettingsId = data.paymentSettingsId || null;
25922
- this.priceListId = data.priceListId || null;
25923
- this.locations = data.locations
25924
- ? data.locations.map(function (o) { return new IkasStorefrontLocation(o); })
25925
- : [];
25926
- this.routes = data.routes
25927
- ? data.routes.map(function (o) { return new IkasStorefrontRoute(o); })
25928
- : null;
25929
- this.termsOfService = data.termsOfService || "";
25930
- this.privacyPolicy = data.privacyPolicy || "";
25931
- this.returnPolicy = data.returnPolicy || "";
25932
- try {
25933
- this.theme = this.themeJSON
25934
- ? new IkasTheme(JSON.parse(this.themeJSON))
25935
- : new IkasTheme();
25936
- }
25937
- catch (err) { }
25938
- makeAutoObservable(this);
25939
- }
25940
- return IkasStorefrontRegion;
25941
- }());
25942
-
25943
- var IkasStorefront = /** @class */ (function () {
25944
- function IkasStorefront(data) {
25945
- if (data === void 0) { data = {}; }
25946
- this.id = data.id || "";
25947
- this.name = data.name || "";
25948
- this.themeId = data.themeId || "";
25949
- this.themeVersionId = data.themeVersionId || "";
25950
- this.userId = data.userId || "";
25951
- this.domains = data.domains
25952
- ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
25953
- : [];
25954
- this.regions = data.regions
25955
- ? data.regions.map(function (o) { return new IkasStorefrontRegion(o); })
25956
- : [];
25957
- makeAutoObservable(this);
25958
- }
25959
- return IkasStorefront;
25960
- }());
25961
-
25962
- var IkasStorefrontAPI = /** @class */ (function () {
25963
- function IkasStorefrontAPI() {
25964
- }
25965
- IkasStorefrontAPI.getStorefront = function (storefrontId) {
25966
- return __awaiter(this, void 0, void 0, function () {
25967
- var QUERY, _a, data, errors;
25968
- return __generator(this, function (_b) {
25969
- switch (_b.label) {
25970
- case 0:
25971
- 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 "])));
25972
- _b.label = 1;
25973
- case 1:
25974
- _b.trys.push([1, 3, , 4]);
25975
- return [4 /*yield*/, apollo
25976
- .getClient()
25977
- .query({
25978
- query: QUERY,
25979
- variables: {
25980
- storefrontId: storefrontId,
25981
- },
25982
- })];
25983
- case 2:
25984
- _a = _b.sent(), data = _a.data, errors = _a.errors;
25985
- if (errors && errors.length) {
25986
- console.log(errors);
25987
- }
25988
- if (data)
25989
- return [2 /*return*/, new IkasStorefront(data.getStorefront)];
25990
- return [3 /*break*/, 4];
25991
- case 3:
25992
- _b.sent();
25993
- return [3 /*break*/, 4];
25994
- case 4: return [2 /*return*/, new IkasStorefront()];
25995
- }
25996
- });
25997
- });
25998
- };
25999
- return IkasStorefrontAPI;
26000
- }());
26001
- var templateObject_1$f;
26002
-
26003
- var IkasThemeAPI = /** @class */ (function () {
26004
- function IkasThemeAPI() {
26005
- }
26006
- IkasThemeAPI.fetchTheme = function () {
26007
- return new Promise(function (resolve, reject) {
26008
- var serverRuntimeConfig = getConfig().serverRuntimeConfig;
26009
- var themeJSONPath = serverRuntimeConfig.THEME_JSON_PATH || "./src/theme.json";
26010
- fs.readFile(themeJSONPath, {
26011
- flag: "a+",
26012
- }, function (err, file) {
26013
- if (err) {
26014
- return reject(err);
26015
- }
26016
- var result = file.length ? JSON.parse(file.toString()) : {};
26017
- resolve(new IkasTheme(result));
26018
- });
26019
- });
26020
- };
26021
- return IkasThemeAPI;
26022
- }());
26023
-
26024
25961
  var IkasVariantTypeAPI = /** @class */ (function () {
26025
25962
  function IkasVariantTypeAPI() {
26026
25963
  }
@@ -26030,7 +25967,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26030
25967
  return __generator(this, function (_b) {
26031
25968
  switch (_b.label) {
26032
25969
  case 0:
26033
- 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 "])));
26034
25971
  _b.label = 1;
26035
25972
  case 1:
26036
25973
  _b.trys.push([1, 3, , 4]);
@@ -26076,7 +26013,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26076
26013
  };
26077
26014
  return IkasVariantTypeAPI;
26078
26015
  }());
26079
- var templateObject_1$g;
26016
+ var templateObject_1$f;
26080
26017
 
26081
26018
  function styleInject(css, ref) {
26082
26019
  if ( ref === void 0 ) ref = {};
@@ -27266,6 +27203,11 @@ var IkasCartStore = /** @class */ (function () {
27266
27203
  name: product.name,
27267
27204
  },
27268
27205
  },
27206
+ priceListId: IkasStorefrontConfig.priceListId || null,
27207
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27208
+ storefrontId: IkasStorefrontConfig.storefrontId,
27209
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27210
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27269
27211
  };
27270
27212
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27271
27213
  case 1:
@@ -27306,6 +27248,11 @@ var IkasCartStore = /** @class */ (function () {
27306
27248
  name: item.variant.name,
27307
27249
  },
27308
27250
  },
27251
+ priceListId: IkasStorefrontConfig.priceListId || null,
27252
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27253
+ storefrontId: IkasStorefrontConfig.storefrontId,
27254
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27255
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27309
27256
  };
27310
27257
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27311
27258
  case 1:
@@ -27668,9 +27615,11 @@ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27668
27615
 
27669
27616
  var IkasCheckoutPage = observer(function (_a) {
27670
27617
  var _b, _c, _d;
27671
- var checkout = _a.checkout, queryParams = _a.queryParams;
27618
+ var checkout = _a.checkout, returnPolicy = _a.returnPolicy, privacyPolicy = _a.privacyPolicy, termsOfService = _a.termsOfService, queryParams = _a.queryParams;
27672
27619
  var router = useRouter();
27673
- 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];
27674
27623
  useEffect(function () {
27675
27624
  Analytics.beginCheckout(vm.checkout);
27676
27625
  Analytics.checkoutStep(vm.checkout, vm.step);
@@ -27695,46 +27644,18 @@ var IkasCheckoutPage = observer(function (_a) {
27695
27644
  var onPolicyModalClose = function () {
27696
27645
  setPolicyModalText("");
27697
27646
  };
27698
- var onReturnPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27699
- var _a, _b;
27700
- return __generator(this, function (_c) {
27701
- switch (_c.label) {
27702
- case 0: return [4 /*yield*/, vm.getStorefront()];
27703
- case 1:
27704
- _c.sent();
27705
- console.log((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.returnPolicy);
27706
- setPolicyModalTitle("Para İade Politikası");
27707
- setPolicyModalText(((_b = vm.storefrontRegion) === null || _b === void 0 ? void 0 : _b.returnPolicy) || "");
27708
- return [2 /*return*/];
27709
- }
27710
- });
27711
- }); };
27712
- var onPrivacyPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27713
- var _a;
27714
- return __generator(this, function (_b) {
27715
- switch (_b.label) {
27716
- case 0: return [4 /*yield*/, vm.getStorefront()];
27717
- case 1:
27718
- _b.sent();
27719
- setPolicyModalTitle("Gizlilik Politikası");
27720
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.privacyPolicy) || "");
27721
- return [2 /*return*/];
27722
- }
27723
- });
27724
- }); };
27725
- var onTermsOfServiceClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27726
- var _a;
27727
- return __generator(this, function (_b) {
27728
- switch (_b.label) {
27729
- case 0: return [4 /*yield*/, vm.getStorefront()];
27730
- case 1:
27731
- _b.sent();
27732
- setPolicyModalTitle("Hizmet Şartları");
27733
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.termsOfService) || "");
27734
- return [2 /*return*/];
27735
- }
27736
- });
27737
- }); };
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
+ };
27738
27659
  var onErrorClose = function () {
27739
27660
  vm.error = undefined;
27740
27661
  };
@@ -27837,6 +27758,9 @@ var IkasPage = observer(function (_a) {
27837
27758
  if (page) {
27838
27759
  store.currentPageType = page.type;
27839
27760
  }
27761
+ useEffect(function () {
27762
+ store.checkLocalization();
27763
+ }, []);
27840
27764
  var renderComponent = function (pageComponent, index) {
27841
27765
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
27842
27766
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -28354,24 +28278,358 @@ var index = /*#__PURE__*/Object.freeze({
28354
28278
  Image: Image
28355
28279
  });
28356
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
+
28357
28621
  var Page = function (_a) {
28358
- 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);
28359
28624
  var router = useRouter();
28360
28625
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28361
28626
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28362
28627
  };
28363
28628
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28364
- var theme, provider;
28365
28629
  return __generator(this, function (_a) {
28366
28630
  switch (_a.label) {
28367
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28368
- case 1:
28369
- theme = _a.sent();
28370
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.INDEX);
28371
- return [4 /*yield*/, provider.getPageData()];
28372
- case 2:
28373
- _a.sent();
28374
- 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()];
28375
28633
  }
28376
28634
  });
28377
28635
  }); };
@@ -28383,7 +28641,8 @@ var home = /*#__PURE__*/Object.freeze({
28383
28641
  });
28384
28642
 
28385
28643
  var Page$1 = function (_a) {
28386
- 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);
28387
28646
  var router = useRouter();
28388
28647
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28389
28648
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28413,6 +28672,7 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28413
28672
  productMetaData = metaData.filter(function (m) { return m.targetType && m.targetType === IkasHTMLMetaDataTargetType.PRODUCT; });
28414
28673
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
28415
28674
  productIdList: productMetaData.map(function (p) { return p.targetId; }),
28675
+ priceListId: IkasStorefrontConfig.priceListId,
28416
28676
  })];
28417
28677
  case 2:
28418
28678
  productsResponse = _b.sent();
@@ -28459,25 +28719,10 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28459
28719
  });
28460
28720
  }); };
28461
28721
  var getStaticProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28462
- var theme, provider;
28463
28722
  return __generator(this, function (_a) {
28464
28723
  switch (_a.label) {
28465
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28466
- case 1:
28467
- theme = _a.sent();
28468
- provider = new IkasPageDataProvider(theme, context.params, undefined);
28469
- return [4 /*yield*/, provider.getPageData()];
28470
- case 2:
28471
- _a.sent();
28472
- if (!provider.page) {
28473
- return [2 /*return*/, {
28474
- notFound: true,
28475
- }];
28476
- }
28477
- return [2 /*return*/, {
28478
- props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: JSON.stringify(provider.pageSpecificData || {}) }),
28479
- revalidate: 60,
28480
- }];
28724
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context)];
28725
+ case 1: return [2 /*return*/, _a.sent()];
28481
28726
  }
28482
28727
  });
28483
28728
  }); };
@@ -28516,25 +28761,52 @@ var index$2 = /*#__PURE__*/Object.freeze({
28516
28761
  });
28517
28762
 
28518
28763
  var Page$2 = function (_a) {
28519
- 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);
28520
28766
  var router = useRouter();
28521
28767
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28522
28768
  return (createElement(IkasPage, { page: page, settingsStr: settingsStr, propValues: propValues }));
28523
28769
  };
28524
28770
  var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28525
- var theme, customPages, customPagePaths;
28771
+ var allSettings, customPagePaths;
28526
28772
  return __generator(this, function (_a) {
28527
28773
  switch (_a.label) {
28528
- 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); }))];
28529
28781
  case 1:
28530
- theme = _a.sent();
28531
- customPages = theme.pages.filter(function (p) { return p.type === IkasThemePageType.CUSTOM; });
28532
- customPagePaths = customPages.map(function (p) { return ({
28533
- slug: p.slug,
28534
- }); });
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
+ });
28535
28806
  return [2 /*return*/, {
28536
28807
  paths: customPagePaths.map(function (p) { return ({
28537
- params: p,
28808
+ params: p.params,
28809
+ locale: p.locale,
28538
28810
  }); }),
28539
28811
  fallback: "blocking",
28540
28812
  }];
@@ -28542,17 +28814,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28542
28814
  });
28543
28815
  }); };
28544
28816
  var getStaticProps$2 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28545
- var theme, provider;
28546
28817
  return __generator(this, function (_a) {
28547
28818
  switch (_a.label) {
28548
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28549
- case 1:
28550
- theme = _a.sent();
28551
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CUSTOM);
28552
- return [4 /*yield*/, provider.getPageData()];
28553
- case 2:
28554
- _a.sent();
28555
- 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()];
28556
28821
  }
28557
28822
  });
28558
28823
  }); };
@@ -28565,18 +28830,37 @@ var _slug_ = /*#__PURE__*/Object.freeze({
28565
28830
  });
28566
28831
 
28567
28832
  var CheckoutPage = function (_a) {
28568
- var checkoutStr = _a.checkoutStr, queryParams = _a.queryParams;
28833
+ var checkoutStr = _a.checkoutStr, configJson = _a.configJson, others = __rest(_a, ["checkoutStr", "configJson"]);
28834
+ IkasStorefrontConfig.initWithJson(configJson);
28569
28835
  Analytics.disableHTML();
28570
28836
  var checkout = new IkasCheckout(JSON.parse(checkoutStr));
28571
- return createElement(IkasCheckoutPage, { checkout: checkout, queryParams: queryParams });
28837
+ return createElement(IkasCheckoutPage, __assign({ checkout: checkout }, others));
28572
28838
  };
28573
28839
  var _id_ = observer(CheckoutPage);
28574
28840
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28575
- var id, redirect, checkout;
28841
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28576
28842
  return __generator(this, function (_a) {
28577
28843
  switch (_a.label) {
28578
28844
  case 0:
28579
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;
28580
28864
  redirect = function () {
28581
28865
  context.res.writeHead(302, { Location: "/" });
28582
28866
  context.res.end();
@@ -28586,12 +28870,15 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28586
28870
  return [2 /*return*/, redirect()];
28587
28871
  }
28588
28872
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
28589
- case 1:
28873
+ case 2:
28590
28874
  checkout = _a.sent();
28591
28875
  if (checkout) {
28592
28876
  return [2 /*return*/, {
28593
28877
  props: {
28594
28878
  checkoutStr: JSON.stringify(checkout),
28879
+ returnPolicy: themeLocalization.returnPolicy || "",
28880
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28881
+ termsOfService: themeLocalization.termsOfService || "",
28595
28882
  queryParams: context.query,
28596
28883
  },
28597
28884
  }];
@@ -28610,23 +28897,17 @@ var _id_$1 = /*#__PURE__*/Object.freeze({
28610
28897
  });
28611
28898
 
28612
28899
  var Page$3 = function (_a) {
28613
- 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);
28614
28902
  var router = useRouter();
28615
28903
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28616
28904
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28617
28905
  };
28618
28906
  var getStaticProps$3 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28619
- var theme, provider;
28620
28907
  return __generator(this, function (_a) {
28621
28908
  switch (_a.label) {
28622
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28623
- case 1:
28624
- theme = _a.sent();
28625
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ACCOUNT);
28626
- return [4 /*yield*/, provider.getPageData()];
28627
- case 2:
28628
- _a.sent();
28629
- 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()];
28630
28911
  }
28631
28912
  });
28632
28913
  }); };
@@ -28638,23 +28919,17 @@ var index$3 = /*#__PURE__*/Object.freeze({
28638
28919
  });
28639
28920
 
28640
28921
  var Page$4 = function (_a) {
28641
- 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);
28642
28924
  var router = useRouter();
28643
28925
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28644
28926
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28645
28927
  };
28646
28928
  var getStaticProps$4 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28647
- var theme, provider;
28648
28929
  return __generator(this, function (_a) {
28649
28930
  switch (_a.label) {
28650
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28651
- case 1:
28652
- theme = _a.sent();
28653
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ADDRESSES);
28654
- return [4 /*yield*/, provider.getPageData()];
28655
- case 2:
28656
- _a.sent();
28657
- 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()];
28658
28933
  }
28659
28934
  });
28660
28935
  }); };
@@ -28666,23 +28941,17 @@ var addresses = /*#__PURE__*/Object.freeze({
28666
28941
  });
28667
28942
 
28668
28943
  var Page$5 = function (_a) {
28669
- 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);
28670
28946
  var router = useRouter();
28671
28947
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28672
28948
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28673
28949
  };
28674
28950
  var getStaticProps$5 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28675
- var theme, provider;
28676
28951
  return __generator(this, function (_a) {
28677
28952
  switch (_a.label) {
28678
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28679
- case 1:
28680
- theme = _a.sent();
28681
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDERS);
28682
- return [4 /*yield*/, provider.getPageData()];
28683
- case 2:
28684
- _a.sent();
28685
- 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()];
28686
28955
  }
28687
28956
  });
28688
28957
  }); };
@@ -28694,23 +28963,17 @@ var index$4 = /*#__PURE__*/Object.freeze({
28694
28963
  });
28695
28964
 
28696
28965
  var Page$6 = function (_a) {
28697
- 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);
28698
28968
  var router = useRouter();
28699
28969
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28700
28970
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28701
28971
  };
28702
28972
  var getServerSideProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28703
- var theme, provider;
28704
28973
  return __generator(this, function (_a) {
28705
28974
  switch (_a.label) {
28706
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28707
- case 1:
28708
- theme = _a.sent();
28709
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.ORDER_DETAIL);
28710
- return [4 /*yield*/, provider.getPageData()];
28711
- case 2:
28712
- _a.sent();
28713
- 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()];
28714
28977
  }
28715
28978
  });
28716
28979
  }); };
@@ -28722,23 +28985,17 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
28722
28985
  });
28723
28986
 
28724
28987
  var Page$7 = function (_a) {
28725
- 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);
28726
28990
  var router = useRouter();
28727
28991
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28728
28992
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28729
28993
  };
28730
28994
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28731
- var theme, provider;
28732
28995
  return __generator(this, function (_a) {
28733
28996
  switch (_a.label) {
28734
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28735
- case 1:
28736
- theme = _a.sent();
28737
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.LOGIN);
28738
- return [4 /*yield*/, provider.getPageData()];
28739
- case 2:
28740
- _a.sent();
28741
- 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()];
28742
28999
  }
28743
29000
  });
28744
29001
  }); };
@@ -28750,23 +29007,17 @@ var login = /*#__PURE__*/Object.freeze({
28750
29007
  });
28751
29008
 
28752
29009
  var Page$8 = function (_a) {
28753
- 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);
28754
29012
  var router = useRouter();
28755
29013
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28756
29014
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28757
29015
  };
28758
29016
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28759
- var theme, provider;
28760
29017
  return __generator(this, function (_a) {
28761
29018
  switch (_a.label) {
28762
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28763
- case 1:
28764
- theme = _a.sent();
28765
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.REGISTER);
28766
- return [4 /*yield*/, provider.getPageData()];
28767
- case 2:
28768
- _a.sent();
28769
- 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()];
28770
29021
  }
28771
29022
  });
28772
29023
  }); };
@@ -28778,23 +29029,17 @@ var register = /*#__PURE__*/Object.freeze({
28778
29029
  });
28779
29030
 
28780
29031
  var Page$9 = function (_a) {
28781
- 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);
28782
29034
  var router = useRouter();
28783
29035
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28784
29036
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28785
29037
  };
28786
29038
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28787
- var theme, provider;
28788
29039
  return __generator(this, function (_a) {
28789
29040
  switch (_a.label) {
28790
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28791
- case 1:
28792
- theme = _a.sent();
28793
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FORGOT_PASSWORD);
28794
- return [4 /*yield*/, provider.getPageData()];
28795
- case 2:
28796
- _a.sent();
28797
- 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()];
28798
29043
  }
28799
29044
  });
28800
29045
  }); };
@@ -28806,23 +29051,17 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
28806
29051
  });
28807
29052
 
28808
29053
  var Page$a = function (_a) {
28809
- 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);
28810
29056
  var router = useRouter();
28811
29057
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28812
29058
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28813
29059
  };
28814
29060
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28815
- var theme, provider;
28816
29061
  return __generator(this, function (_a) {
28817
29062
  switch (_a.label) {
28818
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28819
- case 1:
28820
- theme = _a.sent();
28821
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.RECOVER_PASSWORD);
28822
- return [4 /*yield*/, provider.getPageData()];
28823
- case 2:
28824
- _a.sent();
28825
- 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()];
28826
29065
  }
28827
29066
  });
28828
29067
  }); };
@@ -28834,7 +29073,8 @@ var recoverPassword = /*#__PURE__*/Object.freeze({
28834
29073
  });
28835
29074
 
28836
29075
  var Page$b = function (_a) {
28837
- 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);
28838
29078
  var router = useRouter();
28839
29079
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28840
29080
  var store = IkasStorefrontConfig.store;
@@ -28844,17 +29084,10 @@ var Page$b = function (_a) {
28844
29084
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28845
29085
  };
28846
29086
  var getStaticProps$a = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28847
- var theme, provider;
28848
29087
  return __generator(this, function (_a) {
28849
29088
  switch (_a.label) {
28850
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28851
- case 1:
28852
- theme = _a.sent();
28853
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.CART);
28854
- return [4 /*yield*/, provider.getPageData()];
28855
- case 2:
28856
- _a.sent();
28857
- 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()];
28858
29091
  }
28859
29092
  });
28860
29093
  }); };
@@ -28877,23 +29110,17 @@ var editor$1 = /*#__PURE__*/Object.freeze({
28877
29110
  });
28878
29111
 
28879
29112
  var Page$d = function (_a) {
28880
- 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);
28881
29115
  var router = useRouter();
28882
29116
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28883
29117
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28884
29118
  };
28885
29119
  var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28886
- var theme, provider;
28887
29120
  return __generator(this, function (_a) {
28888
29121
  switch (_a.label) {
28889
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28890
- case 1:
28891
- theme = _a.sent();
28892
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.FAVORITE_PRODUCTS);
28893
- return [4 /*yield*/, provider.getPageData()];
28894
- case 2:
28895
- _a.sent();
28896
- 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()];
28897
29124
  }
28898
29125
  });
28899
29126
  }); };
@@ -28905,7 +29132,8 @@ var favoriteProducts = /*#__PURE__*/Object.freeze({
28905
29132
  });
28906
29133
 
28907
29134
  var Page$e = function (_a) {
28908
- 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);
28909
29137
  var router = useRouter();
28910
29138
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28911
29139
  var initialPropValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
@@ -28919,17 +29147,10 @@ var Page$e = function (_a) {
28919
29147
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28920
29148
  };
28921
29149
  var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28922
- var theme, provider;
28923
29150
  return __generator(this, function (_a) {
28924
29151
  switch (_a.label) {
28925
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28926
- case 1:
28927
- theme = _a.sent();
28928
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.SEARCH);
28929
- return [4 /*yield*/, provider.getPageData()];
28930
- case 2:
28931
- _a.sent();
28932
- 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()];
28933
29154
  }
28934
29155
  });
28935
29156
  }); };
@@ -28941,23 +29162,29 @@ var search = /*#__PURE__*/Object.freeze({
28941
29162
  });
28942
29163
 
28943
29164
  var Page$f = function (_a) {
28944
- 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);
28945
29169
  var router = useRouter();
28946
29170
  var propValues = useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router); }, [propValuesStr]);
28947
29171
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28948
29172
  };
28949
29173
  var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28950
- var theme, provider;
29174
+ var props;
28951
29175
  return __generator(this, function (_a) {
28952
29176
  switch (_a.label) {
28953
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
29177
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.NOT_FOUND)];
28954
29178
  case 1:
28955
- theme = _a.sent();
28956
- provider = new IkasPageDataProvider(theme, context.params, IkasThemePageType.NOT_FOUND);
28957
- return [4 /*yield*/, provider.getPageData()];
28958
- case 2:
28959
- _a.sent();
28960
- 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];
28961
29188
  }
28962
29189
  });
28963
29190
  }); };
@@ -28974,13 +29201,84 @@ configure({
28974
29201
  var IkasBaseStore = /** @class */ (function () {
28975
29202
  function IkasBaseStore() {
28976
29203
  this.currentPageType = null;
29204
+ this.localeOptions = [];
29205
+ this.showLocaleOptions = false;
29206
+ this.localeChecked = false;
28977
29207
  this.customerStore = new IkasCustomerStore(this);
28978
29208
  this.cartStore = new IkasCartStore(this);
28979
29209
  makeObservable(this, {
28980
29210
  currentPageType: observable,
29211
+ localeOptions: observable,
29212
+ showLocaleOptions: observable,
28981
29213
  });
28982
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
+ };
28983
29281
  return IkasBaseStore;
28984
29282
  }());
28985
29283
 
28986
- 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 };