@crystaldesign/diva-core 25.10.0-beta.2 → 25.10.0-beta.20

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.
@@ -19,6 +19,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
19
19
  import MobileDetect from 'mobile-detect';
20
20
  import platform from 'platform';
21
21
  import i18n from 'i18next';
22
+ import LanguageDetector from 'i18next-browser-languagedetector';
22
23
  import HttpApi from 'i18next-http-backend';
23
24
  import * as CoreStyles from '@mui/material/styles';
24
25
  import { StyledEngineProvider, ThemeProvider, createTheme } from '@mui/material/styles';
@@ -46,7 +47,7 @@ import { actions } from '@storybook/addon-actions';
46
47
  import * as Styles from '@mui/styles';
47
48
 
48
49
  (function() {
49
- const env = {"STAGE":"production","VERSION":"25.10.0-beta.2"};
50
+ const env = {"STAGE":"production","VERSION":"25.10.0-beta.20"};
50
51
  try {
51
52
  if (process) {
52
53
  process.env = Object.assign({}, process.env);
@@ -1595,75 +1596,71 @@ var DataStore = /*#__PURE__*/function () {
1595
1596
  }]);
1596
1597
  }();
1597
1598
 
1598
- var instance = i18n.createInstance();
1599
- function init(_x) {
1600
- return _init.apply(this, arguments);
1601
- }
1602
- function _init() {
1603
- _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
1604
- var url, namespace, available, defaultLng, apiConfig;
1605
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1606
- while (1) switch (_context.prev = _context.next) {
1607
- case 0:
1608
- url = _ref.url, namespace = _ref.namespace, available = _ref.available, defaultLng = _ref.defaultLng, apiConfig = _ref.apiConfig;
1609
- return _context.abrupt("return", new Promise(function (resolve, reject) {
1610
- var loadPath = "".concat(apiConfig.adminService, "/locales?lng={{lng}}&ns={{ns}}");
1611
- if (url) {
1612
- loadPath = url.includes('{{lng}}') ? url : "".concat(url, "?lng={{lng}}&ns={{ns}}");
1613
- }
1614
- var namespaces = ['default'];
1615
- if (namespace) {
1616
- namespaces.push(namespace);
1617
- }
1618
- var lang = defaultLng || (available === null || available === void 0 ? void 0 : available[0]) || 'de';
1619
- var initOptions = {
1620
- lng: lang,
1621
- debug: false,
1622
- defaultNS: namespace !== null && namespace !== void 0 ? namespace : 'default',
1623
- fallbackNS: 'default',
1624
- ns: namespaces,
1625
- supportedLngs: available || [defaultLng || 'de'],
1626
- interpolation: {
1627
- escapeValue: false // not needed for react as it escapes by default
1628
- },
1629
- backend: {
1630
- loadPath: loadPath,
1631
- crossDomain: true
1632
- }
1633
- };
1634
- instance.use(HttpApi).init(initOptions, function (error) {
1635
- if (error) {
1636
- reject(error);
1637
- } else {
1638
- resolve(lang);
1639
- }
1640
- });
1641
- }));
1642
- case 2:
1643
- case "end":
1644
- return _context.stop();
1599
+ var instance = i18n.createInstance().use(HttpApi).use(LanguageDetector);
1600
+ function init(_ref) {
1601
+ var apiConfig = _ref.apiConfig;
1602
+ if (instance.isInitialized) {
1603
+ return Promise.resolve();
1604
+ } else if (instance.isInitializing) {
1605
+ return new Promise(function (resolve, reject) {
1606
+ instance.on('loaded', function () {
1607
+ resolve();
1608
+ });
1609
+ instance.on('failedLoading', function (error) {
1610
+ reject(error);
1611
+ });
1612
+ });
1613
+ }
1614
+ return new Promise(function (resolve, reject) {
1615
+ var loadPath = "".concat(apiConfig.adminService, "/locales?lng={{lng}}&ns={{ns}}");
1616
+ var initOptions = {
1617
+ debug: false,
1618
+ defaultNS: 'default',
1619
+ fallbackNS: 'default',
1620
+ ns: ['default'],
1621
+ fallbackLng: false,
1622
+ supportedLngs: ['de', 'en', 'it', 'fr'],
1623
+ interpolation: {
1624
+ escapeValue: false // not needed for react as it escapes by default
1625
+ },
1626
+ detection: {
1627
+ order: ['querystring', 'localStorage', 'navigator'],
1628
+ lookupQuerystring: 'lang'
1629
+ },
1630
+ backend: {
1631
+ loadPath: loadPath,
1632
+ crossDomain: true
1645
1633
  }
1646
- }, _callee);
1647
- }));
1648
- return _init.apply(this, arguments);
1634
+ };
1635
+ instance.init(initOptions, function (error) {
1636
+ if (error) {
1637
+ reject(error);
1638
+ }
1639
+ resolve();
1640
+ });
1641
+ });
1649
1642
  }
1650
- function changeNamespace(_x2) {
1643
+ function changeNamespace(_x) {
1651
1644
  return _changeNamespace.apply(this, arguments);
1652
1645
  }
1653
1646
  function _changeNamespace() {
1654
- _changeNamespace = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(namespace) {
1655
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1656
- while (1) switch (_context2.prev = _context2.next) {
1647
+ _changeNamespace = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(namespace) {
1648
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1649
+ while (1) switch (_context.prev = _context.next) {
1657
1650
  case 0:
1658
- instance.options.ns = [namespace, 'default'];
1659
- instance.options.defaultNS = namespace;
1660
- _context2.next = 4;
1661
- return instance.reloadResources(undefined, namespace);
1651
+ if (instance.hasLoadedNamespace(namespace)) {
1652
+ _context.next = 3;
1653
+ break;
1654
+ }
1655
+ _context.next = 3;
1656
+ return instance.loadNamespaces([namespace]);
1657
+ case 3:
1658
+ instance.setDefaultNamespace(namespace);
1662
1659
  case 4:
1663
1660
  case "end":
1664
- return _context2.stop();
1661
+ return _context.stop();
1665
1662
  }
1666
- }, _callee2);
1663
+ }, _callee);
1667
1664
  }));
1668
1665
  return _changeNamespace.apply(this, arguments);
1669
1666
  }
@@ -2015,14 +2012,14 @@ var ContentWrapper = observer(function (_ref2) {
2015
2012
  overflow: 'hidden'
2016
2013
  },
2017
2014
  className: (isPortrait ? ' portrait' : '') + (isMobile ? ' mobile' : '') + (isMobile && !isPortrait ? ' landscape' : '') + (context.dataStore.isMobile ? ' actual-mobile' : ''),
2018
- children: /*#__PURE__*/jsx(I18nextProvider, {
2019
- i18n: instance,
2020
- children: /*#__PURE__*/jsx(ErrorBoundary, {
2021
- root: context,
2022
- children: /*#__PURE__*/jsx(ThemeProvider, {
2023
- theme: context.contentStore.materialUiTheme,
2024
- children: /*#__PURE__*/jsx(Suspense, {
2025
- fallback: /*#__PURE__*/jsx(Fallback, {}),
2015
+ children: /*#__PURE__*/jsx(Suspense, {
2016
+ fallback: /*#__PURE__*/jsx(Fallback, {}),
2017
+ children: /*#__PURE__*/jsx(I18nextProvider, {
2018
+ i18n: instance,
2019
+ children: /*#__PURE__*/jsx(ErrorBoundary, {
2020
+ root: context,
2021
+ children: /*#__PURE__*/jsx(ThemeProvider, {
2022
+ theme: context.contentStore.materialUiTheme,
2026
2023
  children: children
2027
2024
  })
2028
2025
  })
@@ -2287,7 +2284,7 @@ var ContentStore = /*#__PURE__*/function () {
2287
2284
  Object.entries(parameters || {}).forEach(function (param) {
2288
2285
  return param[1] ? params.append(param[0], param[1]) : false;
2289
2286
  });
2290
- params.append('lang', this.root.language);
2287
+ params.append('lang', instance.language);
2291
2288
  params.append('organizationId', this.root.dataStore.organizationId);
2292
2289
  return url.href;
2293
2290
  }
@@ -2387,7 +2384,7 @@ var ContentStore = /*#__PURE__*/function () {
2387
2384
  callback: function callback(accept) {
2388
2385
  if (accept) {
2389
2386
  var _config5;
2390
- var url = "".concat(window.location.origin).concat((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.route, "?lang=").concat(_this2.root.language, "&organizationId=").concat(parent._id);
2387
+ var url = "".concat(window.location.origin).concat((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.route, "?lang=").concat(instance.language, "&organizationId=").concat(parent._id);
2391
2388
  _this2.openInNewTab({
2392
2389
  url: url,
2393
2390
  openInNewTab: true
@@ -3197,7 +3194,9 @@ var ContentStore = /*#__PURE__*/function () {
3197
3194
  var dialogText = _ref4.dialogText,
3198
3195
  showDialog = _ref4.showDialog,
3199
3196
  callback = _ref4.callback,
3200
- content = _ref4.content;
3197
+ content = _ref4.content,
3198
+ mailSendCallback = _ref4.mailSendCallback,
3199
+ dialogAcceptMailSend = _ref4.dialogAcceptMailSend;
3201
3200
  return /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
3202
3201
  var accepted, _content$language$toU, _content$language;
3203
3202
  return _regeneratorRuntime.wrap(function _callee3$(_context5) {
@@ -3233,7 +3232,7 @@ var ContentStore = /*#__PURE__*/function () {
3233
3232
  case 6:
3234
3233
  if (showDialog !== false) _this9.root.loadingAndErrorStore.toggleLoading('sendingEmail');
3235
3234
  _context5.prev = 7;
3236
- content.language = (_content$language$toU = (_content$language = content.language) === null || _content$language === void 0 ? void 0 : _content$language.toUpperCase()) !== null && _content$language$toU !== void 0 ? _content$language$toU : _this9.root.language.toUpperCase();
3235
+ content.language = (_content$language$toU = (_content$language = content.language) === null || _content$language === void 0 ? void 0 : _content$language.toUpperCase()) !== null && _content$language$toU !== void 0 ? _content$language$toU : instance.language.toUpperCase();
3237
3236
  _context5.next = 11;
3238
3237
  return _this9.root.apiHandler.sendEmail({
3239
3238
  content: content,
@@ -3246,7 +3245,13 @@ var ContentStore = /*#__PURE__*/function () {
3246
3245
  if (showDialog !== false) {
3247
3246
  _this9.openModal({
3248
3247
  text: _this9.root.t('email.send.success'),
3249
- accept: true
3248
+ accept: dialogAcceptMailSend !== null && dialogAcceptMailSend !== void 0 ? dialogAcceptMailSend : true,
3249
+ reject: dialogAcceptMailSend ? true : false,
3250
+ callback: function callback(accept) {
3251
+ if (accept && mailSendCallback) {
3252
+ mailSendCallback === null || mailSendCallback === void 0 || mailSendCallback();
3253
+ }
3254
+ }
3250
3255
  });
3251
3256
  }
3252
3257
  }
@@ -3506,7 +3511,7 @@ var ContentStore = /*#__PURE__*/function () {
3506
3511
  key: "materialUiTheme",
3507
3512
  get: function get() {
3508
3513
  var theme = this.root.configurationStore.theme;
3509
- return createTheme(theme, this.getLang(this.root.language));
3514
+ return createTheme(theme, this.getLang(instance.language));
3510
3515
  }
3511
3516
 
3512
3517
  /**
@@ -3641,9 +3646,7 @@ var ContentStore = /*#__PURE__*/function () {
3641
3646
  Object.entries(parameters || {}).forEach(function (param) {
3642
3647
  return param[1] ? params.append(param[0], param[1]) : false;
3643
3648
  });
3644
- if (this.root.language) {
3645
- params.append('lang', this.root.language);
3646
- }
3649
+ params.append('lang', instance.language);
3647
3650
  if ((_this$root$dataStore$8 = this.root.dataStore.organization) !== null && _this$root$dataStore$8 !== void 0 && _this$root$dataStore$8._id) {
3648
3651
  params.append('organizationId', this.root.dataStore.organization._id);
3649
3652
  }
@@ -3924,7 +3927,6 @@ var _default = /*#__PURE__*/function () {
3924
3927
  var LOG$7 = getLogger('Framework', 'BrowserStateStore');
3925
3928
  var BANNER_STATE_LOCALSTORAGE_KEY = 'diva-banner-state';
3926
3929
  var NTOKEN_LOCALSTORAGE_KEY = 'diva-ntoken';
3927
- var LANGUAGE_LOCALSTORAGE_KEY = 'diva-language';
3928
3930
  var ORGANIZATION_LOCALSTORAGE_KEY = 'diva-organization';
3929
3931
  var LOGIN_METHOD_LOCALSTORAGE_KEY = 'diva-login-method';
3930
3932
  var BrowserStateStore = /*#__PURE__*/function () {
@@ -3959,7 +3961,7 @@ var BrowserStateStore = /*#__PURE__*/function () {
3959
3961
  value: (function () {
3960
3962
  var _loadUrlState = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
3961
3963
  var _route, _searchParams$get;
3962
- var searchParams, currentUrl, state, route;
3964
+ var searchParams, currentUrl, state, route, authdataString, _state$authdata;
3963
3965
  return _regeneratorRuntime.wrap(function _callee$(_context) {
3964
3966
  while (1) switch (_context.prev = _context.next) {
3965
3967
  case 0:
@@ -3980,17 +3982,14 @@ var BrowserStateStore = /*#__PURE__*/function () {
3980
3982
  };
3981
3983
  state.organization = (_searchParams$get = searchParams.get('organizationId')) !== null && _searchParams$get !== void 0 ? _searchParams$get : undefined;
3982
3984
  searchParams["delete"]('organizationId');
3983
-
3984
- //for backwards compatibilty, if the channelId is set in the url, use that one as organization and update the url in the browser
3985
- if (searchParams.get('channelId')) {
3986
- state.organization = searchParams.get('channelId');
3987
- searchParams["delete"]('channelId');
3988
- currentUrl.searchParams.set('organizationId', state.organization);
3989
- currentUrl.searchParams["delete"]('channelId');
3985
+ authdataString = searchParams.get('authdata') || undefined;
3986
+ if (authdataString) {
3987
+ state.authdata = JSON.parse(atob(authdataString));
3988
+ if ((_state$authdata = state.authdata) !== null && _state$authdata !== void 0 && _state$authdata.organizationId) {
3989
+ state.organization = state.authdata.organizationId;
3990
+ }
3990
3991
  }
3991
- state.language = searchParams.get('lang') || undefined;
3992
3992
  searchParams["delete"]('lang');
3993
- state.authdata = searchParams.get('authdata') || undefined;
3994
3993
  searchParams["delete"]('authdata');
3995
3994
  searchParams.forEach(function (value, key) {
3996
3995
  state.component.parameters[key] = value;
@@ -3999,7 +3998,7 @@ var BrowserStateStore = /*#__PURE__*/function () {
3999
3998
  currentUrl.searchParams["delete"]('authdata');
4000
3999
  history.replaceState(null, '', currentUrl.href);
4001
4000
  return _context.abrupt("return", state);
4002
- case 19:
4001
+ case 18:
4003
4002
  case "end":
4004
4003
  return _context.stop();
4005
4004
  }
@@ -4170,30 +4169,6 @@ var BrowserStateStore = /*#__PURE__*/function () {
4170
4169
  }
4171
4170
  }
4172
4171
 
4173
- /**
4174
- * Get the currently stored language
4175
- */
4176
- }, {
4177
- key: "getStoredLanguage",
4178
- value: function getStoredLanguage() {
4179
- return localStorage.getItem(LANGUAGE_LOCALSTORAGE_KEY) || undefined;
4180
- }
4181
-
4182
- /**
4183
- * Updates or removes language in storage
4184
- *
4185
- * @param language the new language or undefined to remove it
4186
- */
4187
- }, {
4188
- key: "setStoredLanguage",
4189
- value: function setStoredLanguage(language) {
4190
- if (language) {
4191
- localStorage.setItem(LANGUAGE_LOCALSTORAGE_KEY, language);
4192
- } else {
4193
- localStorage.removeItem(LANGUAGE_LOCALSTORAGE_KEY);
4194
- }
4195
- }
4196
-
4197
4172
  /**
4198
4173
  * Applies the current state represented by the url to the application
4199
4174
  */
@@ -4210,16 +4185,13 @@ var BrowserStateStore = /*#__PURE__*/function () {
4210
4185
  return this.loadUrlState();
4211
4186
  case 3:
4212
4187
  state = _context2.sent;
4213
- if (state.language) {
4214
- this.root.changeLanguage(state.language);
4215
- }
4216
4188
  if (state.organization) {
4217
4189
  this.root.dataStore.updateOrganization(state.organization);
4218
4190
  }
4219
4191
  if (state.component) {
4220
4192
  this.root.contentStore.openComponent(state.component);
4221
4193
  }
4222
- case 7:
4194
+ case 6:
4223
4195
  case "end":
4224
4196
  return _context2.stop();
4225
4197
  }
@@ -4238,7 +4210,7 @@ var BrowserStateStore = /*#__PURE__*/function () {
4238
4210
  key: "enableUrlSyncronization",
4239
4211
  value: function enableUrlSyncronization() {
4240
4212
  var _this2 = this;
4241
- autorun(function () {
4213
+ var updateFunction = function updateFunction() {
4242
4214
  var _this2$root$authoriza;
4243
4215
  if (!_this2.isUrlSyncEnabled) {
4244
4216
  return;
@@ -4255,19 +4227,23 @@ var BrowserStateStore = /*#__PURE__*/function () {
4255
4227
  }
4256
4228
  var componentState = _this2.root.contentStore.getState(componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.type);
4257
4229
  url = new URL("".concat(location.origin).concat((_componentState$path = componentState.path) !== null && _componentState$path !== void 0 ? _componentState$path : componentConfig.route));
4258
- url.searchParams.append('lang', _this2.root.language);
4259
- url.searchParams.append('organizationId', _this2.root.dataStore.organizationId);
4230
+ url.searchParams.set('lang', instance.language);
4231
+ url.searchParams.set('organizationId', _this2.root.dataStore.organizationId);
4260
4232
  Object.entries(componentState.parameters || {}).forEach(function (_ref) {
4261
4233
  var _ref2 = _slicedToArray(_ref, 2),
4262
4234
  key = _ref2[0],
4263
4235
  value = _ref2[1];
4264
- return url.searchParams.append(key, value);
4236
+ return url.searchParams.set(key, value);
4265
4237
  });
4266
4238
  }
4267
4239
  if (_this2._url != url.href) {
4268
4240
  _this2.setUrl(url.href);
4269
4241
  history.pushState(null, '', url.href);
4270
4242
  }
4243
+ };
4244
+ instance.on('languageChanged', updateFunction);
4245
+ autorun(function () {
4246
+ return updateFunction();
4271
4247
  }, {
4272
4248
  name: 'onUrlChange'
4273
4249
  });
@@ -4802,7 +4778,7 @@ var AuthorizationStore = /*#__PURE__*/function () {
4802
4778
  var parameters = (_componentConfig = componentConfig) !== null && _componentConfig !== void 0 && _componentConfig.type ? (_this$root$contentSto = this.root.contentStore.getState((_componentConfig2 = componentConfig) === null || _componentConfig2 === void 0 ? void 0 : _componentConfig2.type)) === null || _this$root$contentSto === void 0 ? void 0 : _this$root$contentSto.parameters : undefined;
4803
4779
  if (!parameters && (_componentConfig3 = componentConfig) !== null && _componentConfig3 !== void 0 && _componentConfig3.parameters) parameters = componentConfig.parameters;
4804
4780
  var redirectUrl = new URL("".concat(location.origin).concat((_componentConfig4 = componentConfig) !== null && _componentConfig4 !== void 0 && _componentConfig4.route ? componentConfig.route : ''));
4805
- redirectUrl.searchParams.append('lang', this.root.language);
4781
+ redirectUrl.searchParams.append('lang', instance.language);
4806
4782
  redirectUrl.searchParams.append('organizationId', currentOrganization !== null && currentOrganization !== void 0 ? currentOrganization : this.root.dataStore.organizationId);
4807
4783
  if (provider) redirectUrl.searchParams.append('provider', provider);
4808
4784
  Object.entries(parameters || {}).forEach(function (_ref) {
@@ -8374,7 +8350,6 @@ var RootStore = /*#__PURE__*/function () {
8374
8350
  _defineProperty(this, "_onEvent", void 0);
8375
8351
  _defineProperty(this, "events", []);
8376
8352
  _defineProperty(this, "_initializing", true);
8377
- _defineProperty(this, "_language", 'de');
8378
8353
  _defineProperty(this, "_loginMode", (_ref2 = localStorage.getItem(LOGINMODE_LOCALSTORAGE_KEY)) !== null && _ref2 !== void 0 ? _ref2 : 'offline');
8379
8354
  _defineProperty(this, "_apiHandler", void 0);
8380
8355
  _defineProperty(this, "_productHandler", void 0);
@@ -8389,9 +8364,7 @@ var RootStore = /*#__PURE__*/function () {
8389
8364
  _defineProperty(this, "_initalComponent", void 0);
8390
8365
  makeObservable(this, {
8391
8366
  _initializing: observable,
8392
- _language: observable,
8393
8367
  _loginMode: observable,
8394
- language: computed,
8395
8368
  changeLanguage: action,
8396
8369
  changeLoginMode: action,
8397
8370
  initializing: computed
@@ -8416,18 +8389,19 @@ var RootStore = /*#__PURE__*/function () {
8416
8389
  this._supportHandler = new SupportHandler(this);
8417
8390
  this._authorizationHandler = new AuthorizationHandler(this);
8418
8391
  this._clientArticleHandler = new ClientArticleHandler(this);
8419
-
8420
- //every time the organizationId changes call initCache,
8421
- //no idea what it does
8422
8392
  DivaUtils.loginMode = this._loginMode;
8423
8393
  reaction(function () {
8424
- var _this$configurationSt;
8394
+ var _this$configurationSt, _this$configurationSt2;
8425
8395
  return {
8426
- namespace: (_this$configurationSt = _this.configurationStore.locales) === null || _this$configurationSt === void 0 ? void 0 : _this$configurationSt.namespace
8396
+ namespace: (_this$configurationSt = _this.configurationStore.locales) === null || _this$configurationSt === void 0 ? void 0 : _this$configurationSt.namespace,
8397
+ languages: (_this$configurationSt2 = _this.configurationStore.locales) === null || _this$configurationSt2 === void 0 ? void 0 : _this$configurationSt2.available
8427
8398
  };
8428
8399
  }, function (value, prev) {
8429
- if (!instance.isInitialized || value.namespace == prev.namespace) return;
8400
+ if (!instance.isInitialized || value.namespace == prev.namespace && value.languages == prev.languages) return;
8430
8401
  if (value.namespace) changeNamespace(value.namespace);else changeNamespace('default');
8402
+ if (value.languages && !value.languages.includes(instance.language)) {
8403
+ instance.changeLanguage(value.languages[0]);
8404
+ }
8431
8405
  });
8432
8406
  autorun(function () {
8433
8407
  DivaUtils.initPriceFormat(_this.configurationStore.priceFormat);
@@ -8460,10 +8434,8 @@ var RootStore = /*#__PURE__*/function () {
8460
8434
  }));
8461
8435
  } else {
8462
8436
  runInAction(function () {
8463
- _this2._language = lang;
8464
- _this2.browserStateStore.setStoredLanguage(_this2._language);
8465
- if (['de', 'en', 'fr', 'it'].includes(_this2._language) && _this2.authorizationStore.loginState !== 'anon') {
8466
- _this2._authorizationHandler.updateUserLanguage(_this2._language);
8437
+ if (['de', 'en', 'fr', 'it'].includes(lang) && _this2.authorizationStore.loginState !== 'anon') {
8438
+ _this2._authorizationHandler.updateUserLanguage(lang);
8467
8439
  }
8468
8440
  });
8469
8441
  }
@@ -8471,15 +8443,6 @@ var RootStore = /*#__PURE__*/function () {
8471
8443
  });
8472
8444
  }
8473
8445
 
8474
- /**
8475
- * The current language of the application
8476
- */
8477
- }, {
8478
- key: "language",
8479
- get: function get() {
8480
- return this._language;
8481
- }
8482
-
8483
8446
  /**
8484
8447
  * Changes the current userMode
8485
8448
  * @param mode the new mode
@@ -8520,8 +8483,8 @@ var RootStore = /*#__PURE__*/function () {
8520
8483
  }, {
8521
8484
  key: "languages",
8522
8485
  get: function get() {
8523
- var _this$configurationSt2, _this$configurationSt3;
8524
- return (_this$configurationSt2 = (_this$configurationSt3 = this.configurationStore.locales) === null || _this$configurationSt3 === void 0 ? void 0 : _this$configurationSt3.available) !== null && _this$configurationSt2 !== void 0 ? _this$configurationSt2 : ['de'];
8486
+ var _this$configurationSt3, _this$configurationSt4;
8487
+ return (_this$configurationSt3 = (_this$configurationSt4 = this.configurationStore.locales) === null || _this$configurationSt4 === void 0 ? void 0 : _this$configurationSt4.available) !== null && _this$configurationSt3 !== void 0 ? _this$configurationSt3 : ['de'];
8525
8488
  }
8526
8489
 
8527
8490
  /**
@@ -8710,7 +8673,7 @@ var RootStore = /*#__PURE__*/function () {
8710
8673
  value: (function () {
8711
8674
  var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(telemetry, identifier, organizationId, domain, language, component, analyticsProps) {
8712
8675
  var _this4 = this;
8713
- var _this$_initalComponen, _this$_initalComponen2, _configuration$pwa, _this$contentStore$cu, urlState, storedLanguage, storedOrganization, initialOrganization, initialLanguage, configuration, initLocalesResult, telemetrySettings, enableApm, disableDivaAnalyticsLocalStorage, disableDivaAnalytics, enableBusinessMetrics, _configuration$enviro5, _configuration$enviro6, myUserAgentInfo, header, manifest, result, warningText, _this$contentStore, verifyEmailToken, authObject, _urlState$component, _initialOrganization, email, _this$contentStore$cu2;
8676
+ var _this$_initalComponen, _this$_initalComponen2, _configuration$pwa, _this$contentStore$cu, urlState, storedOrganization, initialOrganization, localizationPromise, configuration, header, manifest, verifyEmailToken, authObject, _authObject$code, _urlState$component, _authObject$code2, _authObject$code3, _authObject$code4, _authObject$additiona, _authObject$additiona2, _this$configurationSt5, email, _this$contentStore$cu2;
8714
8677
  return _regeneratorRuntime.wrap(function _callee$(_context) {
8715
8678
  while (1) switch (_context.prev = _context.next) {
8716
8679
  case 0:
@@ -8738,17 +8701,19 @@ var RootStore = /*#__PURE__*/function () {
8738
8701
  return this.browserStateStore.loadUrlState();
8739
8702
  case 7:
8740
8703
  urlState = _context.sent;
8741
- storedLanguage = this.browserStateStore.getStoredLanguage();
8742
8704
  storedOrganization = this.browserStateStore.getStoredOrganization(); //the inital state is derived in the fallowing order: component params > url > browserstore > configuration
8743
8705
  initialOrganization = organizationId || urlState.organization || storedOrganization;
8744
- initialLanguage = language || urlState.language || storedLanguage;
8706
+ if (initialOrganization) {
8707
+ this.initializeAuthorization(initialOrganization);
8708
+ }
8745
8709
  LOG$4.startTransaction({
8746
8710
  event: 'onLoadConfig',
8747
8711
  message: 'loading Config',
8748
8712
  eventId: 'LOAD_CONFIG'
8749
8713
  });
8750
-
8751
- //load core configuration based on initaly available information
8714
+ localizationPromise = init({
8715
+ apiConfig: this.configurationStore.apiConfig
8716
+ }); //load core configuration based on initaly available information
8752
8717
  _context.next = 15;
8753
8718
  return this.configurationStore.fetchConfiguration({
8754
8719
  identifier: identifier,
@@ -8770,53 +8735,7 @@ var RootStore = /*#__PURE__*/function () {
8770
8735
  message: 'load server data',
8771
8736
  eventId: 'LOAD_SERVER_DATA'
8772
8737
  });
8773
-
8774
- //async load locales data
8775
- initLocalesResult = init(_objectSpread$7(_objectSpread$7({}, this.configurationStore.locales), {}, {
8776
- defaultLng: initialLanguage,
8777
- apiConfig: this.configurationStore.apiConfig
8778
- }));
8779
- telemetrySettings = this.configurationStore.telemetrySettings;
8780
- enableApm = telemetry && (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) != false;
8781
- disableDivaAnalyticsLocalStorage = localStorage.getItem('disableDivaAnalytics');
8782
- disableDivaAnalytics = disableDivaAnalyticsLocalStorage !== undefined && disableDivaAnalyticsLocalStorage !== null && disableDivaAnalyticsLocalStorage === 'true';
8783
- enableBusinessMetrics = telemetrySettings && (telemetrySettings.businessEvents == undefined || (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.businessEvents)) && telemetry && !disableDivaAnalytics;
8784
- if (telemetry && telemetrySettings !== null && telemetrySettings !== void 0 && telemetrySettings.cookieBotCbid) {
8785
- initCookieBot(telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.cookieBotCbid, function (consent) {
8786
- if (consent.statistics) {
8787
- var _configuration$enviro;
8788
- init$1(enableApm, (_configuration$enviro = configuration.environment) !== null && _configuration$enviro !== void 0 ? _configuration$enviro : 'PROD', configuration.applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8789
- }
8790
- if (consent.necessary && enableBusinessMetrics) {
8791
- var _configuration$enviro2;
8792
- var myUserAgentInfo = getUserAgentInfo();
8793
- DivaUtils.businessMetrics.init("production" != 'development', // true, - to local test on PETERPC
8794
- (_configuration$enviro2 = configuration.environment) !== null && _configuration$enviro2 !== void 0 ? _configuration$enviro2 : 'PROD', window.DIVA_VERSION, _this4.apiConfig.analyticsService, _this4.jwt, telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.personalData, myUserAgentInfo.family, myUserAgentInfo.os, myUserAgentInfo.deviceName, myUserAgentInfo.browser, myUserAgentInfo.screenWidth, myUserAgentInfo.screenHeight, myUserAgentInfo.osVersion, configuration.applicationEnvironment, initialLanguage, analyticsProps);
8795
- }
8796
- }, function (reason) {
8797
- var _configuration$enviro3;
8798
- LOG$4.error(new DivaError('Cookiebot initialization failed', {
8799
- code: 'CORE_0009',
8800
- custom: {
8801
- reason: reason
8802
- }
8803
- }));
8804
- init$1(enableApm, (_configuration$enviro3 = configuration.environment) !== null && _configuration$enviro3 !== void 0 ? _configuration$enviro3 : 'PROD', configuration.applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8805
- if (enableBusinessMetrics) {
8806
- var _configuration$enviro4;
8807
- var myUserAgentInfo = getUserAgentInfo();
8808
- DivaUtils.businessMetrics.init("production" != 'development', (_configuration$enviro4 = configuration.environment) !== null && _configuration$enviro4 !== void 0 ? _configuration$enviro4 : 'PROD', window.DIVA_VERSION, _this4.apiConfig.analyticsService, _this4.jwt, telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.personalData, myUserAgentInfo.family, myUserAgentInfo.os, myUserAgentInfo.deviceName, myUserAgentInfo.browser, myUserAgentInfo.screenWidth, myUserAgentInfo.screenHeight, myUserAgentInfo.osVersion, configuration.applicationEnvironment, initialLanguage, analyticsProps);
8809
- }
8810
- });
8811
- } else {
8812
- init$1(enableApm, (_configuration$enviro5 = configuration.environment) !== null && _configuration$enviro5 !== void 0 ? _configuration$enviro5 : 'PROD', configuration.applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8813
- if (enableBusinessMetrics) {
8814
- myUserAgentInfo = getUserAgentInfo();
8815
- DivaUtils.businessMetrics.init("production" != 'development', // true, - to local test on PETERPC
8816
- (_configuration$enviro6 = configuration.environment) !== null && _configuration$enviro6 !== void 0 ? _configuration$enviro6 : 'PROD', window.DIVA_VERSION, this.apiConfig.analyticsService, this.jwt, telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.personalData, myUserAgentInfo.family, myUserAgentInfo.os, myUserAgentInfo.deviceName, myUserAgentInfo.browser, myUserAgentInfo.screenWidth, myUserAgentInfo.screenHeight, myUserAgentInfo.osVersion, configuration.applicationEnvironment, initialLanguage, analyticsProps);
8817
- }
8818
- }
8819
- apmIsInitalized();
8738
+ this.initializeTelemetry(telemetry, configuration.environment, configuration.applicationEnvironment, configuration.applicationName, analyticsProps);
8820
8739
  if (configuration.cssCustomFile) {
8821
8740
  header = document.getElementsByTagName('HEAD')[0];
8822
8741
  if (header) DivaUtils.loadCSS(configuration.cssCustomFile, header, undefined);
@@ -8836,26 +8755,19 @@ var RootStore = /*#__PURE__*/function () {
8836
8755
  }
8837
8756
  });
8838
8757
  });
8839
-
8840
- //wait for all asnyc processes to finish and set the last state data
8841
- _context.next = 34;
8842
- return initLocalesResult;
8843
- case 34:
8844
- result = _context.sent;
8845
- runInAction(function () {
8846
- _this4._language = result;
8847
- _this4.browserStateStore.setStoredLanguage(_this4._language);
8848
- });
8849
- warningText = this.t('init.deploymentwarntext', '');
8850
- if (warningText.trim() !== '' && this.doShowInitWarnBanner) {
8851
- (_this$contentStore = this.contentStore) === null || _this$contentStore === void 0 || _this$contentStore.openBanner({
8852
- key: 'InitialWarningBanner',
8853
- type: 'WARNING',
8854
- title: this.t('modals.warning', 'Warnung'),
8855
- text: warningText,
8856
- useLocalStorage: true
8857
- });
8858
- }
8758
+ localizationPromise.then(function () {
8759
+ var warningText = _this4.t('init.deploymentwarntext', '');
8760
+ if (warningText.trim() !== '' && _this4.doShowInitWarnBanner) {
8761
+ var _this4$contentStore;
8762
+ (_this4$contentStore = _this4.contentStore) === null || _this4$contentStore === void 0 || _this4$contentStore.openBanner({
8763
+ key: 'InitialWarningBanner',
8764
+ type: 'WARNING',
8765
+ title: _this4.t('modals.warning', 'Warnung'),
8766
+ text: warningText,
8767
+ useLocalStorage: true
8768
+ });
8769
+ }
8770
+ });
8859
8771
  LOG$4.successTransaction('LOAD_SERVER_DATA');
8860
8772
  LOG$4.startTransaction({
8861
8773
  event: 'onLoadUserData',
@@ -8864,148 +8776,110 @@ var RootStore = /*#__PURE__*/function () {
8864
8776
  });
8865
8777
 
8866
8778
  //load userdata
8867
- _context.prev = 40;
8779
+ _context.prev = 28;
8868
8780
  if (!urlState.authdata) {
8869
- _context.next = 65;
8781
+ _context.next = 53;
8870
8782
  break;
8871
8783
  }
8872
- authObject = JSON.parse(atob(urlState.authdata));
8784
+ authObject = urlState.authdata;
8873
8785
  _context.t0 = authObject === null || authObject === void 0 ? void 0 : authObject.path;
8874
- _context.next = _context.t0 === 'openIdCallback' ? 46 : _context.t0 === 'resetPassword' ? 48 : _context.t0 === 'confirmEmail' ? 50 : _context.t0 === 'acceptInvitation' ? 52 : 62;
8786
+ _context.next = _context.t0 === 'openIdCallback' ? 34 : _context.t0 === 'resetPassword' ? 36 : _context.t0 === 'confirmEmail' ? 38 : _context.t0 === 'acceptInvitation' ? 40 : 50;
8875
8787
  break;
8876
- case 46:
8788
+ case 34:
8877
8789
  if (authObject.error) {
8878
- LOG$4.errorTransaction('LOAD_USER_DATA', 'CORE_0006', authObject.error);
8790
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code = authObject.code) !== null && _authObject$code !== void 0 ? _authObject$code : 'CORE_0006', authObject.error);
8879
8791
  this.authorizationStore.showLogin(false, true);
8880
8792
  } else {
8881
- initialOrganization = authObject.organizationId;
8882
8793
  if (urlState !== null && urlState !== void 0 && (_urlState$component = urlState.component) !== null && _urlState$component !== void 0 && (_urlState$component = _urlState$component.parameters) !== null && _urlState$component !== void 0 && _urlState$component.provider) {
8883
8794
  this.browserStateStore.setStoredLoginMethod(urlState.component.parameters.provider);
8884
8795
  }
8885
8796
  this.browserStateStore.setStoredNToken(authObject.token, authObject.expiresBy);
8886
8797
  }
8887
- return _context.abrupt("break", 63);
8888
- case 48:
8798
+ return _context.abrupt("break", 51);
8799
+ case 36:
8889
8800
  if (authObject.error) {
8890
- LOG$4.errorTransaction('LOAD_USER_DATA', authObject.code, authObject.error);
8801
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code2 = authObject.code) !== null && _authObject$code2 !== void 0 ? _authObject$code2 : 'CORE_0006', authObject.error);
8891
8802
  this.loadingAndErrorStore.setError(authObject.error);
8892
8803
  } else {
8893
8804
  this.authorizationStore.showChangePassword(authObject.token);
8894
8805
  }
8895
- return _context.abrupt("break", 63);
8896
- case 50:
8806
+ return _context.abrupt("break", 51);
8807
+ case 38:
8897
8808
  if (authObject.error) {
8898
- LOG$4.errorTransaction('LOAD_USER_DATA', authObject.code, authObject.error);
8809
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code3 = authObject.code) !== null && _authObject$code3 !== void 0 ? _authObject$code3 : 'CORE_0006', authObject.error);
8899
8810
  this.loadingAndErrorStore.setError(authObject.error);
8900
8811
  } else {
8901
8812
  verifyEmailToken = authObject.token;
8902
8813
  }
8903
- return _context.abrupt("break", 63);
8904
- case 52:
8814
+ return _context.abrupt("break", 51);
8815
+ case 40:
8905
8816
  if (!authObject.error) {
8906
- _context.next = 57;
8817
+ _context.next = 45;
8907
8818
  break;
8908
8819
  }
8909
- LOG$4.errorTransaction('LOAD_INVITATION', authObject.code, authObject.error);
8820
+ LOG$4.errorTransaction('LOAD_INVITATION', (_authObject$code4 = authObject.code) !== null && _authObject$code4 !== void 0 ? _authObject$code4 : 'CORE_0006', authObject.error);
8910
8821
  this.loadingAndErrorStore.setError(authObject.error);
8911
- _context.next = 61;
8822
+ _context.next = 49;
8912
8823
  break;
8913
- case 57:
8824
+ case 45:
8914
8825
  if (!this.browserStateStore.getStoredNToken()) {
8915
- _context.next = 60;
8826
+ _context.next = 48;
8916
8827
  break;
8917
8828
  }
8918
- _context.next = 60;
8829
+ _context.next = 48;
8919
8830
  return this.authorizationStore.logout(undefined, undefined, undefined, true);
8920
- case 60:
8921
- this.authorizationStore.showWelcomeScreen(authObject.additionalParams.isNewUser, authObject.token, authObject.additionalParams.invitationOrgId);
8922
- case 61:
8923
- return _context.abrupt("break", 63);
8924
- case 62:
8925
- return _context.abrupt("break", 63);
8926
- case 63:
8927
- _context.next = 65;
8831
+ case 48:
8832
+ this.authorizationStore.showWelcomeScreen((_authObject$additiona = authObject.additionalParams) === null || _authObject$additiona === void 0 ? void 0 : _authObject$additiona.isNewUser, authObject.token, (_authObject$additiona2 = authObject.additionalParams) === null || _authObject$additiona2 === void 0 ? void 0 : _authObject$additiona2.invitationOrgId);
8833
+ case 49:
8834
+ return _context.abrupt("break", 51);
8835
+ case 50:
8836
+ return _context.abrupt("break", 51);
8837
+ case 51:
8838
+ _context.next = 53;
8928
8839
  break;
8929
- case 65:
8840
+ case 53:
8930
8841
  LOG$4.successTransaction('LOAD_USER_DATA');
8842
+ if (initialOrganization) {
8843
+ _context.next = 57;
8844
+ break;
8845
+ }
8846
+ _context.next = 57;
8847
+ return this.initializeAuthorization((_this$configurationSt5 = this.configurationStore.organizations) === null || _this$configurationSt5 === void 0 ? void 0 : _this$configurationSt5[0]);
8848
+ case 57:
8931
8849
  if (!(!this.browserStateStore.getStoredNToken() && this.configurationStore.hasAuthentication)) {
8932
- _context.next = 80;
8850
+ _context.next = 61;
8933
8851
  break;
8934
8852
  }
8935
- _context.prev = 67;
8936
- _context.next = 70;
8937
- return flowResult(this.authorizationStore.autorize((_initialOrganization = initialOrganization) !== null && _initialOrganization !== void 0 ? _initialOrganization : configuration.organizations[0]));
8938
- case 70:
8939
- _context.next = 77;
8940
- break;
8941
- case 72:
8942
- _context.prev = 72;
8943
- _context.t1 = _context["catch"](67);
8944
- this.loadingAndErrorStore.setError(_context.t1);
8945
- LOG$4.errorTransaction('INITIALIZE_CORE', _context.t1.code, 'Organization Error');
8946
- return _context.abrupt("return");
8947
- case 77:
8948
- //now Login Page opens. The overwritten initComponent params get saved in restrictedComponent. this will later be evaluated in getRedirectUrl
8853
+ //if user is not logged in, show login form and exit initialization
8854
+ //The overwritten initComponent params get saved in restrictedComponent. this will later be evaluated in getRedirectUrl
8949
8855
  this.contentStore.restrictedComponent = this._initalComponent;
8950
8856
  this.authorizationStore.showLogin(urlState.debugLogin, false, initialOrganization);
8951
8857
  return _context.abrupt("return");
8952
- case 80:
8953
- //user is either logged in or no authentication is required
8954
- if (!initialOrganization && !this.configurationStore.hasAuthentication) {
8955
- //if no authentication, fallback to first organization in config
8956
- initialOrganization = configuration.organizations[0];
8957
- }
8958
- _context.prev = 81;
8959
- _context.next = 84;
8960
- return flowResult(this.authorizationStore.autorize(initialOrganization, this.browserStateStore.getStoredNToken()));
8961
- case 84:
8962
- initialOrganization = _context.sent;
8963
- _context.next = 92;
8964
- break;
8965
- case 87:
8966
- _context.prev = 87;
8967
- _context.t2 = _context["catch"](81);
8968
- LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0002', 'Error initializing Organization');
8969
- this.loadingAndErrorStore.setError(_context.t2, 'CORE_0002', true);
8970
- return _context.abrupt("return");
8971
- case 92:
8972
- _context.prev = 92;
8973
- _context.next = 95;
8974
- return flowResult(this.dataStore.updateOrganizationInternal(initialOrganization));
8975
- case 95:
8976
- _context.next = 102;
8977
- break;
8978
- case 97:
8979
- _context.prev = 97;
8980
- _context.t3 = _context["catch"](92);
8981
- LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0002', 'Error updating Organization');
8982
- this.loadingAndErrorStore.setError(_context.t3);
8983
- return _context.abrupt("return");
8984
- case 102:
8858
+ case 61:
8985
8859
  if (!verifyEmailToken) {
8986
- _context.next = 108;
8860
+ _context.next = 67;
8987
8861
  break;
8988
8862
  }
8989
- _context.next = 105;
8863
+ _context.next = 64;
8990
8864
  return this.apiHandler.verifyEmail({
8991
8865
  token: verifyEmailToken
8992
8866
  });
8993
- case 105:
8867
+ case 64:
8994
8868
  email = _context.sent;
8995
- _context.next = 108;
8869
+ _context.next = 67;
8996
8870
  return flowResult(this.authorizationStore.login(email, undefined, true, initialOrganization));
8997
- case 108:
8998
- _context.next = 113;
8871
+ case 67:
8872
+ _context.next = 72;
8999
8873
  break;
9000
- case 110:
9001
- _context.prev = 110;
9002
- _context.t4 = _context["catch"](40);
9003
- if (_context.t4 instanceof DivaError && _context.t4.name == 'AUTH_0006') {
8874
+ case 69:
8875
+ _context.prev = 69;
8876
+ _context.t1 = _context["catch"](28);
8877
+ if (_context.t1 instanceof DivaError && _context.t1.name == 'AUTH_0006') {
9004
8878
  LOG$4.errorTransaction('INITIALIZE_CORE', 'AUTH_0006', 'Existing verification token not valid.');
9005
8879
  } else {
9006
8880
  LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0006', 'An error occured during initialization.');
9007
8881
  }
9008
- case 113:
8882
+ case 72:
9009
8883
  this.initalizeView();
9010
8884
  if (this.jwt) {
9011
8885
  DivaUtils.businessMetrics.jwtSetter = this.jwt;
@@ -9016,41 +8890,182 @@ var RootStore = /*#__PURE__*/function () {
9016
8890
  identifier: identifier,
9017
8891
  organizationId: this.dataStore.organizationId,
9018
8892
  domain: domain,
9019
- language: this._language,
8893
+ language: instance.language,
9020
8894
  component: (_this$contentStore$cu = this.contentStore.currentComponent) === null || _this$contentStore$cu === void 0 ? void 0 : _this$contentStore$cu.type
9021
8895
  });
9022
- _context.next = 123;
8896
+ _context.next = 82;
9023
8897
  break;
9024
- case 118:
9025
- _context.prev = 118;
9026
- _context.t5 = _context["catch"](1);
8898
+ case 77:
8899
+ _context.prev = 77;
8900
+ _context.t2 = _context["catch"](1);
9027
8901
  this.loadingAndErrorStore.toggleLoading('initalize', false);
9028
- this.loadingAndErrorStore.setError(_context.t5);
9029
- LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0000', _context.t5.message, {
8902
+ this.loadingAndErrorStore.setError(_context.t2);
8903
+ LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0000', _context.t2.message, {
9030
8904
  identifier: identifier,
9031
8905
  organizationId: this.dataStore.organizationId,
9032
8906
  domain: domain,
9033
- language: this._language,
8907
+ language: instance.language,
9034
8908
  component: (_this$contentStore$cu2 = this.contentStore.currentComponent) === null || _this$contentStore$cu2 === void 0 ? void 0 : _this$contentStore$cu2.type
9035
8909
  });
9036
- case 123:
9037
- _context.prev = 123;
8910
+ case 82:
8911
+ _context.prev = 82;
9038
8912
  this.loadingAndErrorStore.toggleLoading('initalize');
9039
8913
  runInAction(function () {
9040
8914
  _this4._initializing = false;
9041
8915
  });
9042
- return _context.finish(123);
9043
- case 127:
8916
+ return _context.finish(82);
8917
+ case 86:
9044
8918
  case "end":
9045
8919
  return _context.stop();
9046
8920
  }
9047
- }, _callee, this, [[1, 118, 123, 127], [40, 110], [67, 72], [81, 87], [92, 97]]);
8921
+ }, _callee, this, [[1, 77, 82, 86], [28, 69]]);
9048
8922
  }));
9049
8923
  function initialize(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
9050
8924
  return _initialize.apply(this, arguments);
9051
8925
  }
9052
8926
  return initialize;
8927
+ }()
8928
+ /**
8929
+ * initalize cookiebot, telemetry and business metrics
8930
+ *
8931
+ * @param telemetry if telemetry is enabled
8932
+ * @param environment defines if we are running in development or production
8933
+ * @param applicationEnvironment defines if we are running in seller or web
8934
+ * @param applicationName the name of the application
8935
+ * @param analyticsProps the analytics props
8936
+ */
8937
+ )
8938
+ }, {
8939
+ key: "initializeTelemetry",
8940
+ value: (function () {
8941
+ var _initializeTelemetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(telemetry) {
8942
+ var _this5 = this;
8943
+ var environment,
8944
+ applicationEnvironment,
8945
+ applicationName,
8946
+ analyticsProps,
8947
+ telemetrySettings,
8948
+ enableApm,
8949
+ _args2 = arguments;
8950
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
8951
+ while (1) switch (_context2.prev = _context2.next) {
8952
+ case 0:
8953
+ environment = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'PROD';
8954
+ applicationEnvironment = _args2.length > 2 ? _args2[2] : undefined;
8955
+ applicationName = _args2.length > 3 ? _args2[3] : undefined;
8956
+ analyticsProps = _args2.length > 4 ? _args2[4] : undefined;
8957
+ telemetrySettings = this.configurationStore.telemetrySettings;
8958
+ enableApm = telemetry && (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) != false;
8959
+ if (telemetry && telemetrySettings !== null && telemetrySettings !== void 0 && telemetrySettings.cookieBotCbid) {
8960
+ initCookieBot(telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.cookieBotCbid, function (consent) {
8961
+ if (consent.statistics) {
8962
+ init$1(enableApm, environment, applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8963
+ }
8964
+ if (consent.necessary) {
8965
+ _this5.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8966
+ }
8967
+ }, function (reason) {
8968
+ LOG$4.error(new DivaError('Cookiebot initialization failed', {
8969
+ code: 'CORE_0009',
8970
+ custom: {
8971
+ reason: reason
8972
+ }
8973
+ }));
8974
+ init$1(enableApm, environment, applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8975
+ _this5.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8976
+ });
8977
+ } else {
8978
+ init$1(enableApm, environment, applicationName, typeof (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) == 'string' ? telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm : undefined);
8979
+ this.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8980
+ }
8981
+ apmIsInitalized();
8982
+ case 8:
8983
+ case "end":
8984
+ return _context2.stop();
8985
+ }
8986
+ }, _callee2, this);
8987
+ }));
8988
+ function initializeTelemetry(_x8) {
8989
+ return _initializeTelemetry.apply(this, arguments);
8990
+ }
8991
+ return initializeTelemetry;
8992
+ }()
8993
+ /**
8994
+ * initalize business metrics
8995
+ *
8996
+ * @param telementryActive if telemetry is enabled
8997
+ * @param environment defines if we are running in development or production
8998
+ * @param applicationEnvironment defines if we are running in seller or web
8999
+ * @param telemetryActive the telemetry settings
9000
+ * @param analyticsProps the analytics props
9001
+ */
9002
+ )
9003
+ }, {
9004
+ key: "initializeBusinessMetrics",
9005
+ value: (function () {
9006
+ var _initializeBusinessMetrics = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(telemetryActive, environment, applicationEnvironment, telemetrySettings, analyticsProps) {
9007
+ var disableDivaAnalyticsLocalStorage, disableDivaAnalytics, enableBusinessMetrics, myUserAgentInfo;
9008
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
9009
+ while (1) switch (_context3.prev = _context3.next) {
9010
+ case 0:
9011
+ disableDivaAnalyticsLocalStorage = localStorage.getItem('disableDivaAnalytics');
9012
+ disableDivaAnalytics = disableDivaAnalyticsLocalStorage !== undefined && disableDivaAnalyticsLocalStorage !== null && disableDivaAnalyticsLocalStorage === 'true';
9013
+ enableBusinessMetrics = telemetrySettings && (telemetrySettings.businessEvents == undefined || (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.businessEvents)) && telemetryActive && !disableDivaAnalytics;
9014
+ if (enableBusinessMetrics) {
9015
+ _context3.next = 5;
9016
+ break;
9017
+ }
9018
+ return _context3.abrupt("return");
9019
+ case 5:
9020
+ myUserAgentInfo = getUserAgentInfo();
9021
+ DivaUtils.businessMetrics.init("production" != 'development', environment, window.DIVA_VERSION, this.apiConfig.analyticsService, this.jwt, telemetrySettings.personalData, myUserAgentInfo.family, myUserAgentInfo.os, myUserAgentInfo.deviceName, myUserAgentInfo.browser, myUserAgentInfo.screenWidth, myUserAgentInfo.screenHeight, myUserAgentInfo.osVersion, applicationEnvironment, instance.language, analyticsProps);
9022
+ case 7:
9023
+ case "end":
9024
+ return _context3.stop();
9025
+ }
9026
+ }, _callee3, this);
9027
+ }));
9028
+ function initializeBusinessMetrics(_x9, _x10, _x11, _x12, _x13) {
9029
+ return _initializeBusinessMetrics.apply(this, arguments);
9030
+ }
9031
+ return initializeBusinessMetrics;
9053
9032
  }())
9033
+ }, {
9034
+ key: "initializeAuthorization",
9035
+ value: function () {
9036
+ var _initializeAuthorization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(initialOrganization) {
9037
+ var organizationId;
9038
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
9039
+ while (1) switch (_context4.prev = _context4.next) {
9040
+ case 0:
9041
+ _context4.prev = 0;
9042
+ _context4.next = 3;
9043
+ return flowResult(this.authorizationStore.autorize(initialOrganization, this.browserStateStore.getStoredNToken()));
9044
+ case 3:
9045
+ organizationId = _context4.sent;
9046
+ _context4.next = 6;
9047
+ return flowResult(this.dataStore.updateOrganizationInternal(organizationId));
9048
+ case 6:
9049
+ _context4.next = 14;
9050
+ break;
9051
+ case 8:
9052
+ _context4.prev = 8;
9053
+ _context4.t0 = _context4["catch"](0);
9054
+ this.loadingAndErrorStore.setError(_context4.t0);
9055
+ LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0002', 'Error initializing Organization');
9056
+ this.loadingAndErrorStore.setError(_context4.t0, 'CORE_0002', true);
9057
+ return _context4.abrupt("return");
9058
+ case 14:
9059
+ case "end":
9060
+ return _context4.stop();
9061
+ }
9062
+ }, _callee4, this, [[0, 8]]);
9063
+ }));
9064
+ function initializeAuthorization(_x14) {
9065
+ return _initializeAuthorization.apply(this, arguments);
9066
+ }
9067
+ return initializeAuthorization;
9068
+ }()
9054
9069
  }, {
9055
9070
  key: "initalizeView",
9056
9071
  value: function initalizeView() {
@@ -9621,7 +9636,7 @@ var SideMenu$1 = observer(SideMenu);
9621
9636
  function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9622
9637
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9623
9638
  var LazyModals$1 = /*#__PURE__*/React.lazy(function () {
9624
- return import('./ModalsWrapper-02ea1849.js');
9639
+ return import('./ModalsWrapper-6f905201.js');
9625
9640
  });
9626
9641
  function Fullscreen(_ref) {
9627
9642
  var inAbsoluteFullscreen = _ref.inAbsoluteFullscreen;
@@ -10079,10 +10094,10 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
10079
10094
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10080
10095
  var LOG$2 = getLogger('Framework', 'Root');
10081
10096
  var LazyAuth = /*#__PURE__*/React.lazy(function () {
10082
- return import('./index-42d5057d.js');
10097
+ return import('./index-c94e6531.js');
10083
10098
  });
10084
10099
  var LazyModals = /*#__PURE__*/React.lazy(function () {
10085
- return import('./ModalsWrapper-02ea1849.js');
10100
+ return import('./ModalsWrapper-6f905201.js');
10086
10101
  });
10087
10102
  function ContentComponent() {
10088
10103
  var context = useDivaCoreContext();
@@ -10484,21 +10499,16 @@ var MockedRootStore = /*#__PURE__*/function () {
10484
10499
  key: "initialize",
10485
10500
  value: function () {
10486
10501
  var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
10487
- var _this$data$language;
10488
10502
  return _regeneratorRuntime.wrap(function _callee$(_context) {
10489
10503
  while (1) switch (_context.prev = _context.next) {
10490
10504
  case 0:
10491
10505
  if (this.data.priceFormat) DivaUtils.initPriceFormat(this.data.priceFormat);
10492
10506
  updateCssThemeVariables(this.container, this.theme);
10493
- _context.next = 4;
10494
- return init(_objectSpread(_objectSpread({}, this.data.locales), {}, {
10495
- apiConfig: this.apiConfig,
10496
- defaultLng: (_this$data$language = this.data.language) !== null && _this$data$language !== void 0 ? _this$data$language : this.language
10507
+ init(_objectSpread(_objectSpread({}, this.data.locales), {}, {
10508
+ apiConfig: this.apiConfig
10497
10509
  }));
10498
- case 4:
10499
- this._language = _context.sent;
10500
10510
  this.initalized();
10501
- case 6:
10511
+ case 4:
10502
10512
  case "end":
10503
10513
  return _context.stop();
10504
10514
  }