@crystaldesign/diva-core 25.10.0-beta.8 → 25.11.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/build/esm/{ModalsWrapper-4932816e.js → ModalsWrapper-05e0697b.js} +2 -1
  2. package/build/esm/{index-f677e78c.js → index-657042c3.js} +352 -331
  3. package/build/esm/{index-c93cd09e.js → index-d505a038.js} +2 -1
  4. package/build/esm/index.js +2 -1
  5. package/build/types/core/src/externalTypes.d.ts +7 -0
  6. package/build/types/core/src/externalTypes.d.ts.map +1 -1
  7. package/build/types/core/src/handler/AuthorizationHandler/index.d.ts +6 -2
  8. package/build/types/core/src/handler/AuthorizationHandler/index.d.ts.map +1 -1
  9. package/build/types/core/src/store/AuthorizationStore.d.ts.map +1 -1
  10. package/build/types/core/src/store/BrowserStateStore.d.ts +2 -13
  11. package/build/types/core/src/store/BrowserStateStore.d.ts.map +1 -1
  12. package/build/types/core/src/store/ConfigurationStore.d.ts +1 -8
  13. package/build/types/core/src/store/ConfigurationStore.d.ts.map +1 -1
  14. package/build/types/core/src/store/ContentStore.d.ts +1 -1
  15. package/build/types/core/src/store/ContentStore.d.ts.map +1 -1
  16. package/build/types/core/src/store/RootStore.d.ts +21 -6
  17. package/build/types/core/src/store/RootStore.d.ts.map +1 -1
  18. package/build/types/core/src/types.d.ts +14 -10
  19. package/build/types/core/src/types.d.ts.map +1 -1
  20. package/build/types/core/src/utils/i18n.d.ts +2 -4
  21. package/build/types/core/src/utils/i18n.d.ts.map +1 -1
  22. package/build/umd/124.diva-core.umd.min.js +2 -0
  23. package/build/umd/124.diva-core.umd.min.js.LICENSE.txt +1 -0
  24. package/build/umd/171.diva-core.umd.min.js +2 -0
  25. package/build/umd/171.diva-core.umd.min.js.LICENSE.txt +1 -0
  26. package/build/umd/490.diva-core.umd.min.js +2 -0
  27. package/build/umd/490.diva-core.umd.min.js.LICENSE.txt +1 -0
  28. package/build/umd/{53.diva-core.umd.min.js → 60.diva-core.umd.min.js} +2 -2
  29. package/build/umd/60.diva-core.umd.min.js.LICENSE.txt +1 -0
  30. package/build/umd/{184.diva-core.umd.min.js → 795.diva-core.umd.min.js} +2 -2
  31. package/build/umd/795.diva-core.umd.min.js.LICENSE.txt +1 -0
  32. package/build/umd/diva-core.umd.min.js +6 -6
  33. package/build/umd/report.html +1 -1
  34. package/package.json +11 -10
  35. package/build/umd/184.diva-core.umd.min.js.LICENSE.txt +0 -1
  36. package/build/umd/427.diva-core.umd.min.js +0 -2
  37. package/build/umd/427.diva-core.umd.min.js.LICENSE.txt +0 -1
  38. package/build/umd/53.diva-core.umd.min.js.LICENSE.txt +0 -1
  39. package/build/umd/68.diva-core.umd.min.js +0 -2
  40. package/build/umd/68.diva-core.umd.min.js.LICENSE.txt +0 -1
  41. package/build/umd/989.diva-core.umd.min.js +0 -2
  42. package/build/umd/989.diva-core.umd.min.js.LICENSE.txt +0 -1
@@ -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.8"};
50
+ const env = {"STAGE":"production","VERSION":"25.11.0-beta.1"};
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) {
@@ -8349,6 +8325,7 @@ var LOG$4 = getLogger('Framework', 'root');
8349
8325
  var RootStore = /*#__PURE__*/function () {
8350
8326
  function RootStore(_ref) {
8351
8327
  var _ref2,
8328
+ _apiConfig$adminServi,
8352
8329
  _this = this;
8353
8330
  var components = _ref.components,
8354
8331
  spinnerClass = _ref.spinnerClass,
@@ -8374,7 +8351,6 @@ var RootStore = /*#__PURE__*/function () {
8374
8351
  _defineProperty(this, "_onEvent", void 0);
8375
8352
  _defineProperty(this, "events", []);
8376
8353
  _defineProperty(this, "_initializing", true);
8377
- _defineProperty(this, "_language", 'de');
8378
8354
  _defineProperty(this, "_loginMode", (_ref2 = localStorage.getItem(LOGINMODE_LOCALSTORAGE_KEY)) !== null && _ref2 !== void 0 ? _ref2 : 'offline');
8379
8355
  _defineProperty(this, "_apiHandler", void 0);
8380
8356
  _defineProperty(this, "_productHandler", void 0);
@@ -8389,9 +8365,7 @@ var RootStore = /*#__PURE__*/function () {
8389
8365
  _defineProperty(this, "_initalComponent", void 0);
8390
8366
  makeObservable(this, {
8391
8367
  _initializing: observable,
8392
- _language: observable,
8393
8368
  _loginMode: observable,
8394
- language: computed,
8395
8369
  changeLanguage: action,
8396
8370
  changeLoginMode: action,
8397
8371
  initializing: computed
@@ -8400,6 +8374,7 @@ var RootStore = /*#__PURE__*/function () {
8400
8374
  //be compatible with the deprecated configProvider setting
8401
8375
  var apiConfig = defaultApiConfig ? _objectSpread$7({}, defaultApiConfig) : {};
8402
8376
  !apiConfig.adminService && configProvider ? apiConfig.adminService = configProvider : false;
8377
+ apiConfig.baseUrl = apiConfig.baseUrl ? apiConfig.baseUrl : (_apiConfig$adminServi = apiConfig.adminService) === null || _apiConfig$adminServi === void 0 ? void 0 : _apiConfig$adminServi.replace(/\/admin\/?$/, '');
8403
8378
  this.dataStore = new DataStore(this);
8404
8379
  this.authorizationStore = new AuthorizationStore(this);
8405
8380
  this.configurationStore = new ConfigurationStore(this, identifier, apiConfig, domain);
@@ -8416,18 +8391,19 @@ var RootStore = /*#__PURE__*/function () {
8416
8391
  this._supportHandler = new SupportHandler(this);
8417
8392
  this._authorizationHandler = new AuthorizationHandler(this);
8418
8393
  this._clientArticleHandler = new ClientArticleHandler(this);
8419
-
8420
- //every time the organizationId changes call initCache,
8421
- //no idea what it does
8422
8394
  DivaUtils.loginMode = this._loginMode;
8423
8395
  reaction(function () {
8424
- var _this$configurationSt;
8396
+ var _this$configurationSt, _this$configurationSt2;
8425
8397
  return {
8426
- namespace: (_this$configurationSt = _this.configurationStore.locales) === null || _this$configurationSt === void 0 ? void 0 : _this$configurationSt.namespace
8398
+ namespace: (_this$configurationSt = _this.configurationStore.locales) === null || _this$configurationSt === void 0 ? void 0 : _this$configurationSt.namespace,
8399
+ languages: (_this$configurationSt2 = _this.configurationStore.locales) === null || _this$configurationSt2 === void 0 ? void 0 : _this$configurationSt2.available
8427
8400
  };
8428
8401
  }, function (value, prev) {
8429
- if (!instance.isInitialized || value.namespace == prev.namespace) return;
8402
+ if (!instance.isInitialized || value.namespace == prev.namespace && value.languages == prev.languages) return;
8430
8403
  if (value.namespace) changeNamespace(value.namespace);else changeNamespace('default');
8404
+ if (value.languages && !value.languages.includes(instance.language)) {
8405
+ instance.changeLanguage(value.languages[0]);
8406
+ }
8431
8407
  });
8432
8408
  autorun(function () {
8433
8409
  DivaUtils.initPriceFormat(_this.configurationStore.priceFormat);
@@ -8460,10 +8436,8 @@ var RootStore = /*#__PURE__*/function () {
8460
8436
  }));
8461
8437
  } else {
8462
8438
  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);
8439
+ if (['de', 'en', 'fr', 'it'].includes(lang) && _this2.authorizationStore.loginState !== 'anon') {
8440
+ _this2._authorizationHandler.updateUserLanguage(lang);
8467
8441
  }
8468
8442
  });
8469
8443
  }
@@ -8471,15 +8445,6 @@ var RootStore = /*#__PURE__*/function () {
8471
8445
  });
8472
8446
  }
8473
8447
 
8474
- /**
8475
- * The current language of the application
8476
- */
8477
- }, {
8478
- key: "language",
8479
- get: function get() {
8480
- return this._language;
8481
- }
8482
-
8483
8448
  /**
8484
8449
  * Changes the current userMode
8485
8450
  * @param mode the new mode
@@ -8520,8 +8485,8 @@ var RootStore = /*#__PURE__*/function () {
8520
8485
  }, {
8521
8486
  key: "languages",
8522
8487
  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'];
8488
+ var _this$configurationSt3, _this$configurationSt4;
8489
+ 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
8490
  }
8526
8491
 
8527
8492
  /**
@@ -8710,7 +8675,7 @@ var RootStore = /*#__PURE__*/function () {
8710
8675
  value: (function () {
8711
8676
  var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(telemetry, identifier, organizationId, domain, language, component, analyticsProps) {
8712
8677
  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;
8678
+ var _this$_initalComponen, _this$_initalComponen2, _configuration$pwa, _this$contentStore$cu, urlState, storedOrganization, initialOrganization, initAuthPromise, 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
8679
  return _regeneratorRuntime.wrap(function _callee$(_context) {
8715
8680
  while (1) switch (_context.prev = _context.next) {
8716
8681
  case 0:
@@ -8738,17 +8703,20 @@ var RootStore = /*#__PURE__*/function () {
8738
8703
  return this.browserStateStore.loadUrlState();
8739
8704
  case 7:
8740
8705
  urlState = _context.sent;
8741
- storedLanguage = this.browserStateStore.getStoredLanguage();
8742
8706
  storedOrganization = this.browserStateStore.getStoredOrganization(); //the inital state is derived in the fallowing order: component params > url > browserstore > configuration
8743
8707
  initialOrganization = organizationId || urlState.organization || storedOrganization;
8744
- initialLanguage = language || urlState.language || storedLanguage;
8708
+ //only authorize earlier if organizationId is provided (i.e. it is loaded as component)
8709
+ if (organizationId) {
8710
+ initAuthPromise = this.initializeAuthorization(organizationId);
8711
+ }
8745
8712
  LOG$4.startTransaction({
8746
8713
  event: 'onLoadConfig',
8747
8714
  message: 'loading Config',
8748
8715
  eventId: 'LOAD_CONFIG'
8749
8716
  });
8750
-
8751
- //load core configuration based on initaly available information
8717
+ localizationPromise = init({
8718
+ apiConfig: this.configurationStore.apiConfig
8719
+ }); //load core configuration based on initaly available information
8752
8720
  _context.next = 15;
8753
8721
  return this.configurationStore.fetchConfiguration({
8754
8722
  identifier: identifier,
@@ -8770,53 +8738,7 @@ var RootStore = /*#__PURE__*/function () {
8770
8738
  message: 'load server data',
8771
8739
  eventId: 'LOAD_SERVER_DATA'
8772
8740
  });
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();
8741
+ this.initializeTelemetry(telemetry, configuration.environment, configuration.applicationEnvironment, configuration.applicationName, analyticsProps);
8820
8742
  if (configuration.cssCustomFile) {
8821
8743
  header = document.getElementsByTagName('HEAD')[0];
8822
8744
  if (header) DivaUtils.loadCSS(configuration.cssCustomFile, header, undefined);
@@ -8836,26 +8758,19 @@ var RootStore = /*#__PURE__*/function () {
8836
8758
  }
8837
8759
  });
8838
8760
  });
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
- }
8761
+ localizationPromise.then(function () {
8762
+ var warningText = _this4.t('init.deploymentwarntext', '');
8763
+ if (warningText.trim() !== '' && _this4.doShowInitWarnBanner) {
8764
+ var _this4$contentStore;
8765
+ (_this4$contentStore = _this4.contentStore) === null || _this4$contentStore === void 0 || _this4$contentStore.openBanner({
8766
+ key: 'InitialWarningBanner',
8767
+ type: 'WARNING',
8768
+ title: _this4.t('modals.warning', 'Warnung'),
8769
+ text: warningText,
8770
+ useLocalStorage: true
8771
+ });
8772
+ }
8773
+ });
8859
8774
  LOG$4.successTransaction('LOAD_SERVER_DATA');
8860
8775
  LOG$4.startTransaction({
8861
8776
  event: 'onLoadUserData',
@@ -8864,148 +8779,119 @@ var RootStore = /*#__PURE__*/function () {
8864
8779
  });
8865
8780
 
8866
8781
  //load userdata
8867
- _context.prev = 40;
8782
+ _context.prev = 28;
8868
8783
  if (!urlState.authdata) {
8869
- _context.next = 65;
8784
+ _context.next = 53;
8870
8785
  break;
8871
8786
  }
8872
- authObject = JSON.parse(atob(urlState.authdata));
8787
+ authObject = urlState.authdata;
8873
8788
  _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;
8789
+ _context.next = _context.t0 === 'openIdCallback' ? 34 : _context.t0 === 'resetPassword' ? 36 : _context.t0 === 'confirmEmail' ? 38 : _context.t0 === 'acceptInvitation' ? 40 : 50;
8875
8790
  break;
8876
- case 46:
8791
+ case 34:
8877
8792
  if (authObject.error) {
8878
- LOG$4.errorTransaction('LOAD_USER_DATA', 'CORE_0006', authObject.error);
8793
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code = authObject.code) !== null && _authObject$code !== void 0 ? _authObject$code : 'CORE_0006', authObject.error);
8879
8794
  this.authorizationStore.showLogin(false, true);
8880
8795
  } else {
8881
- initialOrganization = authObject.organizationId;
8882
8796
  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
8797
  this.browserStateStore.setStoredLoginMethod(urlState.component.parameters.provider);
8884
8798
  }
8885
8799
  this.browserStateStore.setStoredNToken(authObject.token, authObject.expiresBy);
8886
8800
  }
8887
- return _context.abrupt("break", 63);
8888
- case 48:
8801
+ return _context.abrupt("break", 51);
8802
+ case 36:
8889
8803
  if (authObject.error) {
8890
- LOG$4.errorTransaction('LOAD_USER_DATA', authObject.code, authObject.error);
8804
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code2 = authObject.code) !== null && _authObject$code2 !== void 0 ? _authObject$code2 : 'CORE_0006', authObject.error);
8891
8805
  this.loadingAndErrorStore.setError(authObject.error);
8892
8806
  } else {
8893
8807
  this.authorizationStore.showChangePassword(authObject.token);
8894
8808
  }
8895
- return _context.abrupt("break", 63);
8896
- case 50:
8809
+ return _context.abrupt("break", 51);
8810
+ case 38:
8897
8811
  if (authObject.error) {
8898
- LOG$4.errorTransaction('LOAD_USER_DATA', authObject.code, authObject.error);
8812
+ LOG$4.errorTransaction('LOAD_USER_DATA', (_authObject$code3 = authObject.code) !== null && _authObject$code3 !== void 0 ? _authObject$code3 : 'CORE_0006', authObject.error);
8899
8813
  this.loadingAndErrorStore.setError(authObject.error);
8900
8814
  } else {
8901
8815
  verifyEmailToken = authObject.token;
8902
8816
  }
8903
- return _context.abrupt("break", 63);
8904
- case 52:
8817
+ return _context.abrupt("break", 51);
8818
+ case 40:
8905
8819
  if (!authObject.error) {
8906
- _context.next = 57;
8820
+ _context.next = 45;
8907
8821
  break;
8908
8822
  }
8909
- LOG$4.errorTransaction('LOAD_INVITATION', authObject.code, authObject.error);
8823
+ LOG$4.errorTransaction('LOAD_INVITATION', (_authObject$code4 = authObject.code) !== null && _authObject$code4 !== void 0 ? _authObject$code4 : 'CORE_0006', authObject.error);
8910
8824
  this.loadingAndErrorStore.setError(authObject.error);
8911
- _context.next = 61;
8825
+ _context.next = 49;
8912
8826
  break;
8913
- case 57:
8827
+ case 45:
8914
8828
  if (!this.browserStateStore.getStoredNToken()) {
8915
- _context.next = 60;
8829
+ _context.next = 48;
8916
8830
  break;
8917
8831
  }
8918
- _context.next = 60;
8832
+ _context.next = 48;
8919
8833
  return this.authorizationStore.logout(undefined, undefined, undefined, true);
8834
+ case 48:
8835
+ 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);
8836
+ case 49:
8837
+ return _context.abrupt("break", 51);
8838
+ case 50:
8839
+ return _context.abrupt("break", 51);
8840
+ case 51:
8841
+ _context.next = 53;
8842
+ break;
8843
+ case 53:
8844
+ LOG$4.successTransaction('LOAD_USER_DATA');
8845
+ if (!initAuthPromise) {
8846
+ _context.next = 60;
8847
+ break;
8848
+ }
8849
+ _context.next = 57;
8850
+ return initAuthPromise;
8851
+ case 57:
8852
+ initialOrganization = _context.sent;
8853
+ _context.next = 63;
8854
+ break;
8920
8855
  case 60:
8921
- this.authorizationStore.showWelcomeScreen(authObject.additionalParams.isNewUser, authObject.token, authObject.additionalParams.invitationOrgId);
8922
- case 61:
8923
- return _context.abrupt("break", 63);
8856
+ _context.next = 62;
8857
+ return this.initializeAuthorization(initialOrganization || ((_this$configurationSt5 = this.configurationStore.organizations) === null || _this$configurationSt5 === void 0 ? void 0 : _this$configurationSt5[0]));
8924
8858
  case 62:
8925
- return _context.abrupt("break", 63);
8859
+ initialOrganization = _context.sent;
8926
8860
  case 63:
8927
- _context.next = 65;
8928
- break;
8929
- case 65:
8930
- LOG$4.successTransaction('LOAD_USER_DATA');
8931
8861
  if (!(!this.browserStateStore.getStoredNToken() && this.configurationStore.hasAuthentication)) {
8932
- _context.next = 80;
8862
+ _context.next = 67;
8933
8863
  break;
8934
8864
  }
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
8865
+ //if user is not logged in, show login form and exit initialization
8866
+ //The overwritten initComponent params get saved in restrictedComponent. this will later be evaluated in getRedirectUrl
8949
8867
  this.contentStore.restrictedComponent = this._initalComponent;
8950
8868
  this.authorizationStore.showLogin(urlState.debugLogin, false, initialOrganization);
8951
8869
  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:
8870
+ case 67:
8985
8871
  if (!verifyEmailToken) {
8986
- _context.next = 108;
8872
+ _context.next = 73;
8987
8873
  break;
8988
8874
  }
8989
- _context.next = 105;
8875
+ _context.next = 70;
8990
8876
  return this.apiHandler.verifyEmail({
8991
8877
  token: verifyEmailToken
8992
8878
  });
8993
- case 105:
8879
+ case 70:
8994
8880
  email = _context.sent;
8995
- _context.next = 108;
8881
+ _context.next = 73;
8996
8882
  return flowResult(this.authorizationStore.login(email, undefined, true, initialOrganization));
8997
- case 108:
8998
- _context.next = 113;
8883
+ case 73:
8884
+ _context.next = 78;
8999
8885
  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') {
8886
+ case 75:
8887
+ _context.prev = 75;
8888
+ _context.t1 = _context["catch"](28);
8889
+ if (_context.t1 instanceof DivaError && _context.t1.name == 'AUTH_0006') {
9004
8890
  LOG$4.errorTransaction('INITIALIZE_CORE', 'AUTH_0006', 'Existing verification token not valid.');
9005
8891
  } else {
9006
8892
  LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0006', 'An error occured during initialization.');
9007
8893
  }
9008
- case 113:
8894
+ case 78:
9009
8895
  this.initalizeView();
9010
8896
  if (this.jwt) {
9011
8897
  DivaUtils.businessMetrics.jwtSetter = this.jwt;
@@ -9016,41 +8902,181 @@ var RootStore = /*#__PURE__*/function () {
9016
8902
  identifier: identifier,
9017
8903
  organizationId: this.dataStore.organizationId,
9018
8904
  domain: domain,
9019
- language: this._language,
8905
+ language: instance.language,
9020
8906
  component: (_this$contentStore$cu = this.contentStore.currentComponent) === null || _this$contentStore$cu === void 0 ? void 0 : _this$contentStore$cu.type
9021
8907
  });
9022
- _context.next = 123;
8908
+ _context.next = 88;
9023
8909
  break;
9024
- case 118:
9025
- _context.prev = 118;
9026
- _context.t5 = _context["catch"](1);
8910
+ case 83:
8911
+ _context.prev = 83;
8912
+ _context.t2 = _context["catch"](1);
9027
8913
  this.loadingAndErrorStore.toggleLoading('initalize', false);
9028
- this.loadingAndErrorStore.setError(_context.t5);
9029
- LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0000', _context.t5.message, {
8914
+ this.loadingAndErrorStore.setError(_context.t2);
8915
+ LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0000', _context.t2.message, {
9030
8916
  identifier: identifier,
9031
8917
  organizationId: this.dataStore.organizationId,
9032
8918
  domain: domain,
9033
- language: this._language,
8919
+ language: instance.language,
9034
8920
  component: (_this$contentStore$cu2 = this.contentStore.currentComponent) === null || _this$contentStore$cu2 === void 0 ? void 0 : _this$contentStore$cu2.type
9035
8921
  });
9036
- case 123:
9037
- _context.prev = 123;
8922
+ case 88:
8923
+ _context.prev = 88;
9038
8924
  this.loadingAndErrorStore.toggleLoading('initalize');
9039
8925
  runInAction(function () {
9040
8926
  _this4._initializing = false;
9041
8927
  });
9042
- return _context.finish(123);
9043
- case 127:
8928
+ return _context.finish(88);
8929
+ case 92:
9044
8930
  case "end":
9045
8931
  return _context.stop();
9046
8932
  }
9047
- }, _callee, this, [[1, 118, 123, 127], [40, 110], [67, 72], [81, 87], [92, 97]]);
8933
+ }, _callee, this, [[1, 83, 88, 92], [28, 75]]);
9048
8934
  }));
9049
8935
  function initialize(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
9050
8936
  return _initialize.apply(this, arguments);
9051
8937
  }
9052
8938
  return initialize;
8939
+ }()
8940
+ /**
8941
+ * initalize cookiebot, telemetry and business metrics
8942
+ *
8943
+ * @param telemetry if telemetry is enabled
8944
+ * @param environment defines if we are running in development or production
8945
+ * @param applicationEnvironment defines if we are running in seller or web
8946
+ * @param applicationName the name of the application
8947
+ * @param analyticsProps the analytics props
8948
+ */
8949
+ )
8950
+ }, {
8951
+ key: "initializeTelemetry",
8952
+ value: (function () {
8953
+ var _initializeTelemetry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(telemetry) {
8954
+ var _this5 = this;
8955
+ var environment,
8956
+ applicationEnvironment,
8957
+ applicationName,
8958
+ analyticsProps,
8959
+ telemetrySettings,
8960
+ enableApm,
8961
+ _args2 = arguments;
8962
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
8963
+ while (1) switch (_context2.prev = _context2.next) {
8964
+ case 0:
8965
+ environment = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'PROD';
8966
+ applicationEnvironment = _args2.length > 2 ? _args2[2] : undefined;
8967
+ applicationName = _args2.length > 3 ? _args2[3] : undefined;
8968
+ analyticsProps = _args2.length > 4 ? _args2[4] : undefined;
8969
+ telemetrySettings = this.configurationStore.telemetrySettings;
8970
+ enableApm = telemetry && (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.apm) != false;
8971
+ if (telemetry && telemetrySettings !== null && telemetrySettings !== void 0 && telemetrySettings.cookieBotCbid) {
8972
+ initCookieBot(telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.cookieBotCbid, function (consent) {
8973
+ if (consent.statistics) {
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
+ }
8976
+ if (consent.necessary) {
8977
+ _this5.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8978
+ }
8979
+ }, function (reason) {
8980
+ LOG$4.error(new DivaError('Cookiebot initialization failed', {
8981
+ code: 'CORE_0009',
8982
+ custom: {
8983
+ reason: reason
8984
+ }
8985
+ }));
8986
+ 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);
8987
+ _this5.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8988
+ });
8989
+ } else {
8990
+ 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);
8991
+ this.initializeBusinessMetrics(telemetry, environment, applicationEnvironment, telemetrySettings, analyticsProps);
8992
+ }
8993
+ apmIsInitalized();
8994
+ case 8:
8995
+ case "end":
8996
+ return _context2.stop();
8997
+ }
8998
+ }, _callee2, this);
8999
+ }));
9000
+ function initializeTelemetry(_x8) {
9001
+ return _initializeTelemetry.apply(this, arguments);
9002
+ }
9003
+ return initializeTelemetry;
9004
+ }()
9005
+ /**
9006
+ * initalize business metrics
9007
+ *
9008
+ * @param telementryActive if telemetry is enabled
9009
+ * @param environment defines if we are running in development or production
9010
+ * @param applicationEnvironment defines if we are running in seller or web
9011
+ * @param telemetryActive the telemetry settings
9012
+ * @param analyticsProps the analytics props
9013
+ */
9014
+ )
9015
+ }, {
9016
+ key: "initializeBusinessMetrics",
9017
+ value: (function () {
9018
+ var _initializeBusinessMetrics = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(telemetryActive, environment, applicationEnvironment, telemetrySettings, analyticsProps) {
9019
+ var disableDivaAnalyticsLocalStorage, disableDivaAnalytics, enableBusinessMetrics, myUserAgentInfo;
9020
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
9021
+ while (1) switch (_context3.prev = _context3.next) {
9022
+ case 0:
9023
+ disableDivaAnalyticsLocalStorage = localStorage.getItem('disableDivaAnalytics');
9024
+ disableDivaAnalytics = disableDivaAnalyticsLocalStorage !== undefined && disableDivaAnalyticsLocalStorage !== null && disableDivaAnalyticsLocalStorage === 'true';
9025
+ enableBusinessMetrics = telemetrySettings && (telemetrySettings.businessEvents == undefined || (telemetrySettings === null || telemetrySettings === void 0 ? void 0 : telemetrySettings.businessEvents)) && telemetryActive && !disableDivaAnalytics;
9026
+ if (enableBusinessMetrics) {
9027
+ _context3.next = 5;
9028
+ break;
9029
+ }
9030
+ return _context3.abrupt("return");
9031
+ case 5:
9032
+ myUserAgentInfo = getUserAgentInfo();
9033
+ 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);
9034
+ case 7:
9035
+ case "end":
9036
+ return _context3.stop();
9037
+ }
9038
+ }, _callee3, this);
9039
+ }));
9040
+ function initializeBusinessMetrics(_x9, _x10, _x11, _x12, _x13) {
9041
+ return _initializeBusinessMetrics.apply(this, arguments);
9042
+ }
9043
+ return initializeBusinessMetrics;
9053
9044
  }())
9045
+ }, {
9046
+ key: "initializeAuthorization",
9047
+ value: function () {
9048
+ var _initializeAuthorization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(initialOrganization) {
9049
+ var organizationId;
9050
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
9051
+ while (1) switch (_context4.prev = _context4.next) {
9052
+ case 0:
9053
+ _context4.prev = 0;
9054
+ _context4.next = 3;
9055
+ return flowResult(this.authorizationStore.autorize(initialOrganization, this.browserStateStore.getStoredNToken()));
9056
+ case 3:
9057
+ organizationId = _context4.sent;
9058
+ _context4.next = 6;
9059
+ return flowResult(this.dataStore.updateOrganizationInternal(organizationId));
9060
+ case 6:
9061
+ return _context4.abrupt("return", organizationId);
9062
+ case 9:
9063
+ _context4.prev = 9;
9064
+ _context4.t0 = _context4["catch"](0);
9065
+ this.loadingAndErrorStore.setError(_context4.t0);
9066
+ LOG$4.errorTransaction('INITIALIZE_CORE', 'CORE_0002', 'Error initializing Organization');
9067
+ this.loadingAndErrorStore.setError(_context4.t0, 'CORE_0002', true);
9068
+ return _context4.abrupt("return", initialOrganization);
9069
+ case 15:
9070
+ case "end":
9071
+ return _context4.stop();
9072
+ }
9073
+ }, _callee4, this, [[0, 9]]);
9074
+ }));
9075
+ function initializeAuthorization(_x14) {
9076
+ return _initializeAuthorization.apply(this, arguments);
9077
+ }
9078
+ return initializeAuthorization;
9079
+ }()
9054
9080
  }, {
9055
9081
  key: "initalizeView",
9056
9082
  value: function initalizeView() {
@@ -9621,7 +9647,7 @@ var SideMenu$1 = observer(SideMenu);
9621
9647
  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
9648
  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
9649
  var LazyModals$1 = /*#__PURE__*/React.lazy(function () {
9624
- return import('./ModalsWrapper-4932816e.js');
9650
+ return import('./ModalsWrapper-05e0697b.js');
9625
9651
  });
9626
9652
  function Fullscreen(_ref) {
9627
9653
  var inAbsoluteFullscreen = _ref.inAbsoluteFullscreen;
@@ -10079,10 +10105,10 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
10079
10105
  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
10106
  var LOG$2 = getLogger('Framework', 'Root');
10081
10107
  var LazyAuth = /*#__PURE__*/React.lazy(function () {
10082
- return import('./index-c93cd09e.js');
10108
+ return import('./index-d505a038.js');
10083
10109
  });
10084
10110
  var LazyModals = /*#__PURE__*/React.lazy(function () {
10085
- return import('./ModalsWrapper-4932816e.js');
10111
+ return import('./ModalsWrapper-05e0697b.js');
10086
10112
  });
10087
10113
  function ContentComponent() {
10088
10114
  var context = useDivaCoreContext();
@@ -10484,21 +10510,16 @@ var MockedRootStore = /*#__PURE__*/function () {
10484
10510
  key: "initialize",
10485
10511
  value: function () {
10486
10512
  var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
10487
- var _this$data$language;
10488
10513
  return _regeneratorRuntime.wrap(function _callee$(_context) {
10489
10514
  while (1) switch (_context.prev = _context.next) {
10490
10515
  case 0:
10491
10516
  if (this.data.priceFormat) DivaUtils.initPriceFormat(this.data.priceFormat);
10492
10517
  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
10518
+ init(_objectSpread(_objectSpread({}, this.data.locales), {}, {
10519
+ apiConfig: this.apiConfig
10497
10520
  }));
10498
- case 4:
10499
- this._language = _context.sent;
10500
10521
  this.initalized();
10501
- case 6:
10522
+ case 4:
10502
10523
  case "end":
10503
10524
  return _context.stop();
10504
10525
  }