@eui/core 13.0.0-beta.14 → 13.0.0-beta.18

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 (210) hide show
  1. package/docs/classes/ActivatedRouteAction.html +43 -43
  2. package/docs/classes/AddApiQueueItemAction.html +43 -43
  3. package/docs/classes/AddAppLoadedConfigModulesAction.html +43 -43
  4. package/docs/classes/ApiQueueServiceMock.html +26 -526
  5. package/docs/classes/AsyncStorageService.html +43 -469
  6. package/docs/classes/AsyncStorageServiceMock.html +40 -1225
  7. package/docs/classes/EmptyApiQueueAction.html +43 -43
  8. package/docs/classes/EuiCoreRootGuardClass.html +8 -6
  9. package/docs/classes/EuiError.html +8 -6
  10. package/docs/classes/I18nResourceImpl.html +25 -26
  11. package/docs/classes/InitStoreAction.html +43 -43
  12. package/docs/classes/LogServiceMock.html +10 -10
  13. package/docs/classes/OpenIdConnectServiceMock.html +10 -46
  14. package/docs/classes/RemoveApiQueueItemAction.html +43 -43
  15. package/docs/classes/RouterMock.html +77 -84
  16. package/docs/classes/StorageService.html +31 -36
  17. package/docs/classes/StorageServiceMock.html +16 -479
  18. package/docs/classes/StoreMock.html +41 -47
  19. package/docs/classes/TranslateServiceMock.html +251 -270
  20. package/docs/classes/UpdateAppConnectionAction.html +43 -43
  21. package/docs/classes/UpdateAppStatusAction.html +43 -43
  22. package/docs/classes/UpdateAppVersionAction.html +43 -43
  23. package/docs/classes/UpdateCurrentModuleAction.html +43 -43
  24. package/docs/classes/UpdateI18nStateAction.html +43 -43
  25. package/docs/classes/UpdateLocaleStateAction.html +43 -43
  26. package/docs/classes/UpdateNotificationsListAction.html +43 -43
  27. package/docs/classes/UpdateUserDashboardAction.html +43 -43
  28. package/docs/classes/UpdateUserDetailsAction.html +43 -43
  29. package/docs/classes/UpdateUserPreferencesAction.html +43 -43
  30. package/docs/classes/UpdateUserRightsAction.html +43 -43
  31. package/docs/classes/UpdateUserStateAction.html +43 -43
  32. package/docs/classes/UxErrorManager.html +39 -43
  33. package/docs/dependencies.html +44 -41
  34. package/docs/directives/TranslateMockDirective.html +9 -7
  35. package/docs/index.html +7 -6
  36. package/docs/injectables/ApiQueueService.html +33 -40
  37. package/docs/injectables/CoreAppEffects.html +98 -99
  38. package/docs/injectables/EuiPermissionService.html +26 -31
  39. package/docs/injectables/GlobalErrorHandler.html +12 -11
  40. package/docs/injectables/I18nLoader.html +28 -30
  41. package/docs/injectables/I18nService.html +42 -48
  42. package/docs/injectables/I18nServiceMock.html +32 -569
  43. package/docs/injectables/LocalForageService.html +75 -1549
  44. package/docs/injectables/LocalStorageService.html +38 -499
  45. package/docs/injectables/LocaleService.html +23 -28
  46. package/docs/injectables/LocaleServiceMock.html +21 -198
  47. package/docs/injectables/LogService.html +11 -10
  48. package/docs/injectables/OpenIdConnectService.html +10 -10
  49. package/docs/injectables/SessionStorageService.html +38 -499
  50. package/docs/injectables/StoreService.html +24 -28
  51. package/docs/injectables/StoreServiceMock.html +18 -360
  52. package/docs/injectables/UserService.html +24 -27
  53. package/docs/injectables/UserServiceMock.html +31 -196
  54. package/docs/injectables/UxAppShellService.html +299 -355
  55. package/docs/injectables/UxDynamicComponentService.html +16 -16
  56. package/docs/injectables/UxDynamicMenuService.html +38 -40
  57. package/docs/injectables/UxErrorFeedbackService.html +42 -48
  58. package/docs/injectables/UxTimezoneService.html +18 -22
  59. package/docs/interceptors/AddLangParamInterceptor.html +11 -10
  60. package/docs/interceptors/CachePreventionInterceptor.html +11 -10
  61. package/docs/interceptors/CorsSecurityInterceptor.html +11 -10
  62. package/docs/interceptors/CsrfPreventionInterceptor.html +11 -10
  63. package/docs/interceptors/EuLoginSessionTimeoutHandlingInterceptor.html +11 -10
  64. package/docs/interceptors/HttpErrorHandlerInterceptor.html +11 -10
  65. package/docs/interceptors/OpenIdConnectInterceptor.html +35 -35
  66. package/docs/interceptors/UxRequestErrorModelInterceptor.html +11 -10
  67. package/docs/interfaces/LoadedResources.html +37 -12
  68. package/docs/interfaces/LoadedResourcesError.html +28 -10
  69. package/docs/interfaces/ModuleLoadEvent.html +37 -12
  70. package/docs/interfaces/OpenIdConnectUserDetails.html +64 -18
  71. package/docs/interfaces/ResourceError.html +37 -12
  72. package/docs/interfaces/TimeZone.html +28 -10
  73. package/docs/interfaces/UIState.html +325 -76
  74. package/docs/js/libs/prism.js +46 -14
  75. package/docs/js/menu-wc.js +76 -79
  76. package/docs/js/menu-wc_es5.js +60 -0
  77. package/docs/js/menu.js +15 -11
  78. package/docs/js/search/lunr.min.js +3 -3
  79. package/docs/js/search/search_index.js +2 -2
  80. package/docs/license.html +6 -5
  81. package/docs/miscellaneous/enumerations.html +18 -17
  82. package/docs/miscellaneous/functions.html +261 -140
  83. package/docs/miscellaneous/typealiases.html +18 -17
  84. package/docs/miscellaneous/variables.html +1719 -1811
  85. package/docs/modules/CoreModule.html +13 -14
  86. package/docs/modules/I18nModule.html +11 -11
  87. package/docs/modules/LogModule.html +16 -16
  88. package/docs/modules/TranslateMockModule.html +8 -6
  89. package/docs/modules.html +6 -5
  90. package/docs/pipes/TranslateMockPipe.html +10 -9
  91. package/docs/styles/bootstrap.min.css +4 -3
  92. package/docs/styles/compodoc.css +41 -33
  93. package/docs/styles/dark.css +113 -0
  94. package/docs/styles/laravel.css +52 -6
  95. package/docs/styles/material.css +31 -7
  96. package/docs/styles/original.css +12 -6
  97. package/docs/styles/postmark.css +23 -7
  98. package/docs/styles/prism.css +169 -135
  99. package/docs/styles/readthedocs.css +22 -11
  100. package/docs/styles/stripe.css +48 -5
  101. package/docs/styles/vagrant.css +42 -6
  102. package/{esm2015/eui-core.js → esm2020/eui-core.mjs} +0 -0
  103. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  104. package/{esm2015/lib/eui-core.module.js → esm2020/lib/eui-core.module.mjs} +5 -5
  105. package/{esm2015/lib/helpers/date-helpers.js → esm2020/lib/helpers/date-helpers.mjs} +0 -0
  106. package/{esm2015/lib/helpers/dom-helpers.js → esm2020/lib/helpers/dom-helpers.mjs} +0 -0
  107. package/{esm2015/lib/helpers/event-helpers.js → esm2020/lib/helpers/event-helpers.mjs} +0 -0
  108. package/{esm2015/lib/helpers/form-helpers.js → esm2020/lib/helpers/form-helpers.mjs} +0 -0
  109. package/{esm2015/lib/helpers/format-helpers.js → esm2020/lib/helpers/format-helpers.mjs} +0 -0
  110. package/{esm2015/lib/helpers/http-helpers.js → esm2020/lib/helpers/http-helpers.mjs} +0 -0
  111. package/{esm2015/lib/helpers/index.js → esm2020/lib/helpers/index.mjs} +0 -0
  112. package/{esm2015/lib/helpers/utils.js → esm2020/lib/helpers/utils.mjs} +0 -0
  113. package/{esm2015/lib/interceptors/add-lang-param.interceptor.js → esm2020/lib/interceptors/add-lang-param.interceptor.mjs} +4 -4
  114. package/{esm2015/lib/interceptors/cache-prevention.interceptor.js → esm2020/lib/interceptors/cache-prevention.interceptor.mjs} +4 -4
  115. package/{esm2015/lib/interceptors/cors-security.interceptor.js → esm2020/lib/interceptors/cors-security.interceptor.mjs} +4 -4
  116. package/{esm2015/lib/interceptors/csrf-prevention.interceptor.js → esm2020/lib/interceptors/csrf-prevention.interceptor.mjs} +4 -4
  117. package/esm2020/lib/interceptors/eu-login-session-timeout-handling.interceptor.mjs +61 -0
  118. package/{esm2015/lib/interceptors/index.js → esm2020/lib/interceptors/index.mjs} +0 -0
  119. package/{esm2015/lib/interceptors/openid/index.js → esm2020/lib/interceptors/openid/index.mjs} +0 -0
  120. package/esm2020/lib/interceptors/openid/openid-connect.interceptor.mjs +146 -0
  121. package/{esm2015/lib/interceptors/openid/openid-connect.service.js → esm2020/lib/interceptors/openid/openid-connect.service.mjs} +4 -4
  122. package/{esm2015/lib/interceptors/openid/openid-connect.service.mock.js → esm2020/lib/interceptors/openid/openid-connect.service.mock.mjs} +0 -0
  123. package/{esm2015/lib/interceptors/ux-request-error-model.interceptor.js → esm2020/lib/interceptors/ux-request-error-model.interceptor.mjs} +4 -4
  124. package/{esm2015/lib/services/app/eui-init-app.js → esm2020/lib/services/app/eui-init-app.mjs} +0 -0
  125. package/esm2020/lib/services/app/eui-pre-init-app.mjs +42 -0
  126. package/{esm2015/lib/services/app/eui-startup.js → esm2020/lib/services/app/eui-startup.mjs} +0 -0
  127. package/{esm2015/lib/services/app/factories/log.js → esm2020/lib/services/app/factories/log.mjs} +0 -0
  128. package/{esm2015/lib/services/app/index.js → esm2020/lib/services/app/index.mjs} +0 -0
  129. package/esm2020/lib/services/config/defaults.mjs +63 -0
  130. package/{esm2015/lib/services/config/tokens.js → esm2020/lib/services/config/tokens.mjs} +5 -2
  131. package/{esm2015/lib/services/errors/eui.error.js → esm2020/lib/services/errors/eui.error.mjs} +0 -0
  132. package/{esm2015/lib/services/errors/global-error-handler.js → esm2020/lib/services/errors/global-error-handler.mjs} +4 -4
  133. package/{esm2015/lib/services/errors/http-error-handler-callback-functions.js → esm2020/lib/services/errors/http-error-handler-callback-functions.mjs} +0 -0
  134. package/{esm2015/lib/services/errors/http-error-handler.interceptor.js → esm2020/lib/services/errors/http-error-handler.interceptor.mjs} +4 -4
  135. package/{esm2015/lib/services/errors/index.js → esm2020/lib/services/errors/index.mjs} +0 -0
  136. package/{esm2015/lib/services/i18n/i18n.loader.js → esm2020/lib/services/i18n/i18n.loader.mjs} +4 -4
  137. package/{esm2015/lib/services/i18n/i18n.resource.js → esm2020/lib/services/i18n/i18n.resource.mjs} +0 -0
  138. package/esm2020/lib/services/i18n/i18n.service.mjs +222 -0
  139. package/{esm2015/lib/services/i18n/i18n.service.mock.js → esm2020/lib/services/i18n/i18n.service.mock.mjs} +4 -4
  140. package/{esm2015/lib/services/i18n/index.js → esm2020/lib/services/i18n/index.mjs} +0 -0
  141. package/{esm2015/lib/services/index.js → esm2020/lib/services/index.mjs} +0 -0
  142. package/{esm2015/lib/services/locale/index.js → esm2020/lib/services/locale/index.mjs} +0 -0
  143. package/esm2020/lib/services/locale/locale.service.mjs +250 -0
  144. package/{esm2015/lib/services/log/index.js → esm2020/lib/services/log/index.mjs} +0 -0
  145. package/{esm2015/lib/services/log/log.module.js → esm2020/lib/services/log/log.module.mjs} +5 -5
  146. package/{esm2015/lib/services/log/log.service.js → esm2020/lib/services/log/log.service.mjs} +4 -4
  147. package/{esm2015/lib/services/log/log.service.mock.js → esm2020/lib/services/log/log.service.mock.mjs} +0 -0
  148. package/{esm2015/lib/services/permission/permission.service.js → esm2020/lib/services/permission/permission.service.mjs} +5 -5
  149. package/{esm2015/lib/services/queue/api-queue.service.js → esm2020/lib/services/queue/api-queue.service.mjs} +4 -4
  150. package/{esm2015/lib/services/queue/api-queue.service.mock.js → esm2020/lib/services/queue/api-queue.service.mock.mjs} +0 -0
  151. package/{esm2015/lib/services/queue/index.js → esm2020/lib/services/queue/index.mjs} +0 -0
  152. package/{esm2015/lib/services/storage/async-storage.service.js → esm2020/lib/services/storage/async-storage.service.mjs} +0 -0
  153. package/{esm2015/lib/services/storage/async-storage.service.mock.js → esm2020/lib/services/storage/async-storage.service.mock.mjs} +0 -0
  154. package/{esm2015/lib/services/storage/index.js → esm2020/lib/services/storage/index.mjs} +0 -0
  155. package/{esm2015/lib/services/storage/local-forage.service.js → esm2020/lib/services/storage/local-forage.service.mjs} +4 -4
  156. package/{esm2015/lib/services/storage/local-storage.service.js → esm2020/lib/services/storage/local-storage.service.mjs} +4 -4
  157. package/{esm2015/lib/services/storage/session-storage.service.js → esm2020/lib/services/storage/session-storage.service.mjs} +4 -4
  158. package/{esm2015/lib/services/storage/storage.service.js → esm2020/lib/services/storage/storage.service.mjs} +0 -0
  159. package/{esm2015/lib/services/storage/storage.service.mock.js → esm2020/lib/services/storage/storage.service.mock.mjs} +0 -0
  160. package/{esm2015/lib/services/store/actions/app.actions.js → esm2020/lib/services/store/actions/app.actions.mjs} +0 -0
  161. package/{esm2015/lib/services/store/actions/i18n.actions.js → esm2020/lib/services/store/actions/i18n.actions.mjs} +0 -0
  162. package/{esm2015/lib/services/store/actions/index.js → esm2020/lib/services/store/actions/index.mjs} +0 -0
  163. package/{esm2015/lib/services/store/actions/locale.actions.js → esm2020/lib/services/store/actions/locale.actions.mjs} +0 -0
  164. package/{esm2015/lib/services/store/actions/notifications.actions.js → esm2020/lib/services/store/actions/notifications.actions.mjs} +0 -0
  165. package/{esm2015/lib/services/store/actions/user.actions.js → esm2020/lib/services/store/actions/user.actions.mjs} +0 -0
  166. package/{esm2015/lib/services/store/effects/app.effects.js → esm2020/lib/services/store/effects/app.effects.mjs} +5 -5
  167. package/{esm2015/lib/services/store/effects/index.js → esm2020/lib/services/store/effects/index.mjs} +0 -0
  168. package/{esm2015/lib/services/store/index.js → esm2020/lib/services/store/index.mjs} +0 -0
  169. package/esm2020/lib/services/store/reducers/app.reducers.mjs +57 -0
  170. package/{esm2015/lib/services/store/reducers/core.reducers.js → esm2020/lib/services/store/reducers/core.reducers.mjs} +0 -0
  171. package/esm2020/lib/services/store/reducers/i18n.reducers.mjs +18 -0
  172. package/{esm2015/lib/services/store/reducers/index.js → esm2020/lib/services/store/reducers/index.mjs} +0 -0
  173. package/esm2020/lib/services/store/reducers/locale.reducers.mjs +18 -0
  174. package/esm2020/lib/services/store/reducers/meta.reducers.mjs +91 -0
  175. package/{esm2015/lib/services/store/reducers/notifications.reducers.js → esm2020/lib/services/store/reducers/notifications.reducers.mjs} +0 -0
  176. package/esm2020/lib/services/store/reducers/user.reducers.mjs +43 -0
  177. package/{esm2015/lib/services/store/store.service.js → esm2020/lib/services/store/store.service.mjs} +4 -4
  178. package/{esm2015/lib/services/store/store.service.mock.js → esm2020/lib/services/store/store.service.mock.mjs} +4 -4
  179. package/{esm2015/lib/services/user/index.js → esm2020/lib/services/user/index.mjs} +0 -0
  180. package/{esm2015/lib/services/user/user.service.js → esm2020/lib/services/user/user.service.mjs} +4 -4
  181. package/{esm2015/lib/services/user/user.service.mock.js → esm2020/lib/services/user/user.service.mock.mjs} +4 -4
  182. package/esm2020/lib/services/ux-app-shell.service.mjs +633 -0
  183. package/{esm2015/lib/services/ux-dynamic-component/ux-dynamic-component.service.js → esm2020/lib/services/ux-dynamic-component/ux-dynamic-component.service.mjs} +4 -4
  184. package/{esm2015/lib/services/ux-dynamic-menu/ux-dynamic-menu.service.js → esm2020/lib/services/ux-dynamic-menu/ux-dynamic-menu.service.mjs} +4 -4
  185. package/{esm2015/lib/services/ux-error-feedback/ux-error-feedback.service.js → esm2020/lib/services/ux-error-feedback/ux-error-feedback.service.mjs} +4 -4
  186. package/{esm2015/lib/services/ux-error-feedback/ux-error-handler.operator.js → esm2020/lib/services/ux-error-feedback/ux-error-handler.operator.mjs} +0 -0
  187. package/{esm2015/lib/services/ux-timezone.service.js → esm2020/lib/services/ux-timezone.service.mjs} +4 -4
  188. package/fesm2015/{eui-core.js → eui-core.mjs} +270 -247
  189. package/fesm2015/eui-core.mjs.map +1 -0
  190. package/fesm2020/eui-core.mjs +4592 -0
  191. package/fesm2020/eui-core.mjs.map +1 -0
  192. package/lib/services/locale/locale.service.d.ts.map +1 -1
  193. package/lib/services/permission/permission.service.d.ts +1 -1
  194. package/lib/services/permission/permission.service.d.ts.map +1 -1
  195. package/package.json +19 -6
  196. package/bundles/eui-core.umd.js +0 -5323
  197. package/bundles/eui-core.umd.js.map +0 -1
  198. package/esm2015/lib/interceptors/eu-login-session-timeout-handling.interceptor.js +0 -61
  199. package/esm2015/lib/interceptors/openid/openid-connect.interceptor.js +0 -146
  200. package/esm2015/lib/services/app/eui-pre-init-app.js +0 -47
  201. package/esm2015/lib/services/config/defaults.js +0 -49
  202. package/esm2015/lib/services/i18n/i18n.service.js +0 -219
  203. package/esm2015/lib/services/locale/locale.service.js +0 -255
  204. package/esm2015/lib/services/store/reducers/app.reducers.js +0 -49
  205. package/esm2015/lib/services/store/reducers/i18n.reducers.js +0 -15
  206. package/esm2015/lib/services/store/reducers/locale.reducers.js +0 -15
  207. package/esm2015/lib/services/store/reducers/meta.reducers.js +0 -92
  208. package/esm2015/lib/services/store/reducers/user.reducers.js +0 -43
  209. package/esm2015/lib/services/ux-app-shell.service.js +0 -584
  210. package/fesm2015/eui-core.js.map +0 -1
@@ -0,0 +1,4592 @@
1
+ import * as i1 from '@eui/base';
2
+ import { LogLevel, ConsoleAppender, Logger, LoggerMock, mergeAll, getI18nLoaderConfig, EuiLazyService, getI18nServiceConfigFromBase, getI18nState, getLastAddedModule, getBrowserDefaultLanguage, UxEuLanguages, getActiveLang, initialAppState, initialUserState, initialNotificationsState, initialI18nState, initialLocaleState, xhr, getApiQueue, getApiQueueItem, EuiService, getUserRights, getUserState, UxPublishErrorFeedbackEvent, UxClearErrorFeedbackEvent, getLocaleServiceConfigFromBase, getLocaleState, transformToUxHttpResponse } from '@eui/base';
3
+ export * from '@eui/base';
4
+ import * as i0 from '@angular/core';
5
+ import { InjectionToken, Injectable, Inject, Injector, NgModule, Optional, APP_INITIALIZER, EventEmitter, PLATFORM_ID, SkipSelf, ErrorHandler, LOCALE_ID } from '@angular/core';
6
+ import * as i1$2 from '@angular/common/http';
7
+ import { HttpClientModule, HttpErrorResponse, HttpResponse, HttpHeaders, HttpEventType } from '@angular/common/http';
8
+ import * as extendProxy from 'extend';
9
+ import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
10
+ import { MomentDateAdapter } from '@angular/material-moment-adapter';
11
+ import { LOCATION_INITIALIZED, DOCUMENT, isPlatformBrowser, getLocaleId, registerLocaleData } from '@angular/common';
12
+ import * as i1$1 from '@ngrx/store';
13
+ import { createSelector } from '@ngrx/store';
14
+ import { throwError, forkJoin, of, BehaviorSubject, defer, merge, fromEvent, Observable, Subject, from } from 'rxjs';
15
+ import { debounceTime, distinctUntilChanged, map, catchError, switchMap, tap, filter, take, mapTo, mergeMap, concatMap, takeUntil } from 'rxjs/operators';
16
+ import { __decorate, __metadata } from 'tslib';
17
+ import * as i2 from '@ngx-translate/core';
18
+ import { TranslateLoader } from '@ngx-translate/core';
19
+ import * as i1$3 from '@ngrx/effects';
20
+ import { ofType, Effect } from '@ngrx/effects';
21
+ import * as i2$1 from '@angular/router';
22
+ import { NavigationEnd } from '@angular/router';
23
+ import isEqual from 'lodash-es/isEqual';
24
+ import get from 'lodash-es/get';
25
+ import { By } from '@angular/platform-browser';
26
+ import { FormGroup, FormArray } from '@angular/forms';
27
+ import { DomPortalOutlet, ComponentPortal, PortalInjector } from '@angular/cdk/portal';
28
+ import * as lf from 'localforage';
29
+
30
+ /** default log configuration */
31
+ const DEFAULT_LOG_CONFIG = {
32
+ baseLoggerName: 'root',
33
+ logLevel: LogLevel.ERROR,
34
+ logAppenders: {
35
+ type: ConsoleAppender,
36
+ prefixFormat: '[{level}]',
37
+ },
38
+ };
39
+ const DEFAULT_I18N_SERVICE_CONFIG = {
40
+ languages: ['en'],
41
+ defaultLanguage: 'en',
42
+ };
43
+ const DEFAULT_I18N_LOADER_CONFIG = {};
44
+ const DEFAULT_LOCALE_SERVICE_CONFIG = {
45
+ id: 'en',
46
+ available: ['en'],
47
+ registered: ['en'],
48
+ bindWithTranslate: false,
49
+ affectGlobalLocale: false
50
+ };
51
+ const DEFAULT_HTTP_ERROR_HANDLER_CONFIG = {
52
+ routes: [],
53
+ };
54
+ const DEFAULT_GLOBAL_CONFIG = {
55
+ showConnectionStatus: true,
56
+ i18n: {
57
+ i18nService: {
58
+ ...DEFAULT_I18N_SERVICE_CONFIG,
59
+ },
60
+ i18nLoader: {
61
+ ...DEFAULT_I18N_LOADER_CONFIG,
62
+ },
63
+ },
64
+ locale: {
65
+ ...DEFAULT_LOCALE_SERVICE_CONFIG
66
+ },
67
+ user: {
68
+ defaultUserPreferences: {
69
+ locale: {
70
+ ...DEFAULT_LOCALE_SERVICE_CONFIG
71
+ }
72
+ }
73
+ }
74
+ };
75
+ const DEFAULT_EUI_APP_CONFIG = {
76
+ global: {
77
+ ...DEFAULT_GLOBAL_CONFIG,
78
+ },
79
+ };
80
+ const DEFAULT_EUI_ENV_CONFIG = {
81
+ envAppHandlersConfig: {},
82
+ };
83
+ const DEFAULT_EUI_CONFIG = {
84
+ appConfig: {
85
+ ...DEFAULT_EUI_APP_CONFIG,
86
+ },
87
+ environment: {
88
+ ...DEFAULT_EUI_ENV_CONFIG,
89
+ },
90
+ };
91
+
92
+ const extend$1 = extendProxy.default || extendProxy;
93
+ const EUI_CONFIG_TOKEN = new InjectionToken('EuiConfig');
94
+ const MODULE_NAME_TOKEN = new InjectionToken('moduleName');
95
+ const MODULE_CONFIG_TOKEN = new InjectionToken('moduleConfig');
96
+ const CONFIG_TOKEN = new InjectionToken('finalConfigToken');
97
+ const GLOBAL_CONFIG_TOKEN = new InjectionToken('globalConfig');
98
+ const BASE_NAME_TOKEN = new InjectionToken('baseName');
99
+ const ROOT_LOG_CONFIG_TOKEN = new InjectionToken('logConfig');
100
+ const SHOW_CONNECTION_STATUS_TOKEN = new InjectionToken('SHOW_CONNECTION_STATUS');
101
+ const HTTP_ERROR_HANDLER_CONFIG_TOKEN = new InjectionToken('HTTP_ERROR_HANDLER_CONFIG');
102
+ function getGlobalConfig(appConfig) {
103
+ return Object.assign(DEFAULT_EUI_CONFIG.appConfig.global, appConfig && appConfig.global);
104
+ }
105
+ function getShowConnectionStatus(globalConfig) {
106
+ return Object.assign({}, DEFAULT_EUI_CONFIG.appConfig.global.showConnectionStatus, globalConfig && globalConfig.showConnectionStatus);
107
+ }
108
+ function getModuleConfig(appConfig, moduleName) {
109
+ return Object.assign({}, appConfig && appConfig.modules && appConfig.modules[moduleName]);
110
+ }
111
+ function getHttpErrorHandlingConfig(appConfig) {
112
+ return Object.assign({}, appConfig && appConfig.httpErrorHandler);
113
+ }
114
+ function getRootLogConfig(appConfig) {
115
+ return Object.assign({}, appConfig && appConfig.log);
116
+ }
117
+ function prepareEuiAppConfigToken(euiConfig) {
118
+ const environment = euiConfig && euiConfig.environment;
119
+ const merge = environment.envDynamicConfig
120
+ && environment.envDynamicConfig.merge && Array.isArray(environment.envDynamicConfig.merge)
121
+ ? environment.envDynamicConfig.merge : [];
122
+ const isDeepMerge = environment.envDynamicConfig
123
+ && environment.envDynamicConfig.deepMerge
124
+ ? environment.envDynamicConfig.deepMerge : false;
125
+ const envAppJsonConfig = environment && environment.loadedEnvDynamicConfig;
126
+ const initialAppConfig = euiConfig && euiConfig.appConfig;
127
+ const envAppHandlersConfig = environment && environment.envAppHandlersConfig;
128
+ const envHandlersMergedAppConfig = mergeAppHandlerConfigToAppConfig(initialAppConfig, envAppHandlersConfig);
129
+ const finalConfig = mergeAppJsonConfigToAppConfig(envHandlersMergedAppConfig, envAppJsonConfig, merge, isDeepMerge);
130
+ return finalConfig;
131
+ }
132
+ function mergeAppHandlerConfigToAppConfig(euiAppConfig, envAppHandler) {
133
+ return Object.assign({}, euiAppConfig, envAppHandler);
134
+ }
135
+ function mergeAppJsonConfigToAppConfig(euiAppConfig, envAppJsonConfig, merge, isDeepMerge) {
136
+ const deepMerged = {};
137
+ if (merge && merge.length > 0) {
138
+ merge.forEach((key) => {
139
+ if (envAppJsonConfig[key] && typeof envAppJsonConfig[key] === 'object'
140
+ && euiAppConfig[key] && typeof euiAppConfig[key] === 'object') {
141
+ if (isDeepMerge) {
142
+ deepMerged[key] = {};
143
+ extend$1(true, deepMerged[key], euiAppConfig[key], envAppJsonConfig[key]);
144
+ }
145
+ else {
146
+ envAppJsonConfig[key] = {
147
+ ...euiAppConfig[key],
148
+ ...envAppJsonConfig[key],
149
+ };
150
+ }
151
+ }
152
+ });
153
+ }
154
+ return Object.assign({}, euiAppConfig, envAppJsonConfig, deepMerged);
155
+ }
156
+
157
+ const BASE_LOGGER_NAME_TOKEN = new InjectionToken('BASE_LOGGER_NAME');
158
+ const LOG_LEVEL_TOKEN = new InjectionToken('LOG_LEVEL');
159
+ const LOG_APPENDERS_TOKEN = new InjectionToken('LOG_APPENDERS');
160
+ /**
161
+ * Log service, responsible for getting or creating loggers. It itself acts as a base logger
162
+ */
163
+ class LogService extends Logger {
164
+ constructor(name, level, appenders) {
165
+ super(name, level, appenders);
166
+ this.name = name;
167
+ this.level = level;
168
+ this.appenders = appenders;
169
+ /** the list of persistent loggers */
170
+ this.loggers = {};
171
+ }
172
+ /**
173
+ * Gets a logger by name. If the logger does not exist, it is created
174
+ * @param loggerName logger name
175
+ * @param persist optional parameter. Set it to true if you want to reuse the logger. By default, it is set to false
176
+ * @returns the logger
177
+ */
178
+ getLogger(loggerName, persist = false) {
179
+ // create the logger, if necessary
180
+ const logger = persist && this.loggers[loggerName] || new Logger(loggerName, this.level, this.appenders);
181
+ // if the logger is persistent, add it to the list of persistent loggers
182
+ if (persist) {
183
+ this.loggers[loggerName] = logger;
184
+ }
185
+ return logger;
186
+ }
187
+ }
188
+ /** @nocollapse */ /** @nocollapse */ LogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogService, deps: [{ token: BASE_LOGGER_NAME_TOKEN }, { token: LOG_LEVEL_TOKEN }, { token: LOG_APPENDERS_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
189
+ /** @nocollapse */ /** @nocollapse */ LogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogService });
190
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogService, decorators: [{
191
+ type: Injectable
192
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
193
+ type: Inject,
194
+ args: [BASE_LOGGER_NAME_TOKEN]
195
+ }] }, { type: i1.LogLevel, decorators: [{
196
+ type: Inject,
197
+ args: [LOG_LEVEL_TOKEN]
198
+ }] }, { type: undefined, decorators: [{
199
+ type: Inject,
200
+ args: [LOG_APPENDERS_TOKEN]
201
+ }] }]; } });
202
+
203
+ const LOG_INSTANCES = {};
204
+ /**
205
+ * Helper function to check if the log config is defined.
206
+ * Does not check only for empty object, because the config can have other (non-log) parameters
207
+ * @params config log configuration
208
+ * @returns true/false
209
+ */
210
+ function isLogConfigDefined(config) {
211
+ return config && ('baseLoggerName' in config || 'logLevel' in config || 'logAppenders' in config);
212
+ }
213
+ /**
214
+ * Helper function to provide a list of log appenders from a log configuration
215
+ * @params config log configuration
216
+ * @returns an array of log appenders
217
+ */
218
+ function getLogAppendersConfig(config = DEFAULT_LOG_CONFIG, injector = null) {
219
+ config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
220
+ config.logAppenders = config.logAppenders || [];
221
+ config.logAppenders = Array.isArray(config.logAppenders) ? config.logAppenders : [config.logAppenders];
222
+ return config.logAppenders.map(logAppender => {
223
+ const appenderType = typeof logAppender === 'object' ? logAppender.type : logAppender;
224
+ const appenderParams = typeof logAppender === 'object' ? logAppender : undefined;
225
+ return new appenderType(appenderParams, injector);
226
+ });
227
+ }
228
+ /**
229
+ * Helper function to provide an instance of LogService from a configuration
230
+ * @params config log configuration
231
+ * @returns an instance of log service
232
+ */
233
+ function logServiceFactory(config = DEFAULT_LOG_CONFIG, injector = null) {
234
+ // add the default values to config
235
+ config = Object.assign({}, DEFAULT_LOG_CONFIG, config);
236
+ // extract parameters from config
237
+ const logLevel = config.logLevel;
238
+ const logAppenders = getLogAppendersConfig(config, injector);
239
+ // return an instance of LogService
240
+ return new LogService(config.baseLoggerName, logLevel, logAppenders);
241
+ }
242
+ function euiLogServiceFactory(injector, rootBaseLoggerName, rootConfig, childBaseLoggerName = null, childConfig = {}) {
243
+ // determine if the configuration is for non-root modules
244
+ const forChild = isLogConfigDefined(childConfig);
245
+ const baseLoggerName = forChild ? childBaseLoggerName : rootBaseLoggerName;
246
+ // create the proper configuration
247
+ const config = Object.assign({ baseLoggerName: baseLoggerName }, forChild ? Object.assign({}, rootConfig, childConfig) : rootConfig);
248
+ // re-use the log service or create a new instance
249
+ const logService = LOG_INSTANCES[baseLoggerName] || logServiceFactory(config, injector);
250
+ LOG_INSTANCES[baseLoggerName] = logService;
251
+ return logService;
252
+ }
253
+
254
+ class LogServiceMock extends LoggerMock {
255
+ getLogger() {
256
+ return new LoggerMock();
257
+ }
258
+ }
259
+
260
+ const LOG_MODULE_CONFIG_TOKEN = new InjectionToken('LOG_CONFIG');
261
+ /**
262
+ * Log Module
263
+ */
264
+ class LogModule {
265
+ /** method called in your root module to provide the LogService */
266
+ static forRoot(config = DEFAULT_LOG_CONFIG) {
267
+ return {
268
+ ngModule: LogModule,
269
+ providers: [
270
+ { provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
271
+ { provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
272
+ ],
273
+ };
274
+ }
275
+ /** method called in your other (non root, lazy loaded) modules to import a different instance of LogService */
276
+ static forChild(config = DEFAULT_LOG_CONFIG) {
277
+ return {
278
+ ngModule: LogModule,
279
+ providers: [
280
+ { provide: LOG_MODULE_CONFIG_TOKEN, useValue: config },
281
+ { provide: LogService, useFactory: logServiceFactory, deps: [LOG_MODULE_CONFIG_TOKEN, Injector] },
282
+ ],
283
+ };
284
+ }
285
+ }
286
+ /** @nocollapse */ /** @nocollapse */ LogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
287
+ /** @nocollapse */ /** @nocollapse */ LogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogModule });
288
+ /** @nocollapse */ /** @nocollapse */ LogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogModule });
289
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LogModule, decorators: [{
290
+ type: NgModule
291
+ }] });
292
+
293
+ var CoreAppActionTypes;
294
+ (function (CoreAppActionTypes) {
295
+ CoreAppActionTypes["INIT_STORE"] = "[App] Init store";
296
+ CoreAppActionTypes["UPDATE_APP_VERSION"] = "[App] Update version";
297
+ CoreAppActionTypes["UPDATE_APP_CONNECTION"] = "[App] Update connection";
298
+ CoreAppActionTypes["ADD_APP_LOADED_CONFIG_MODULES"] = "[App] Update app loaded config modules";
299
+ CoreAppActionTypes["UPDATE_APP_STATUS"] = "[App] Update status";
300
+ CoreAppActionTypes["UPDATE_CURRENT_MODULE"] = "[App] Update current module";
301
+ CoreAppActionTypes["ACTIVATED_ROUTE"] = "[App] Activated route";
302
+ CoreAppActionTypes["ADD_API_QUEUE_ITEM"] = "[App] Add API queue item";
303
+ CoreAppActionTypes["REMOVE_API_QUEUE_ITEM"] = "[App] Remove API queue item";
304
+ CoreAppActionTypes["EMPTY_API_QUEUE"] = "[App] empty API queue";
305
+ })(CoreAppActionTypes || (CoreAppActionTypes = {}));
306
+ class InitStoreAction {
307
+ constructor(payload) {
308
+ this.payload = payload;
309
+ this.type = CoreAppActionTypes.INIT_STORE;
310
+ }
311
+ }
312
+ class UpdateAppVersionAction {
313
+ constructor(payload) {
314
+ this.payload = payload;
315
+ this.type = CoreAppActionTypes.UPDATE_APP_VERSION;
316
+ }
317
+ }
318
+ class UpdateAppConnectionAction {
319
+ constructor(payload) {
320
+ this.payload = payload;
321
+ this.type = CoreAppActionTypes.UPDATE_APP_CONNECTION;
322
+ }
323
+ }
324
+ class AddAppLoadedConfigModulesAction {
325
+ constructor(payload) {
326
+ this.payload = payload;
327
+ this.type = CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES;
328
+ }
329
+ }
330
+ class UpdateAppStatusAction {
331
+ constructor(payload) {
332
+ this.payload = payload;
333
+ this.type = CoreAppActionTypes.UPDATE_APP_STATUS;
334
+ }
335
+ }
336
+ class UpdateCurrentModuleAction {
337
+ constructor(payload) {
338
+ this.payload = payload;
339
+ this.type = CoreAppActionTypes.UPDATE_CURRENT_MODULE;
340
+ }
341
+ }
342
+ class ActivatedRouteAction {
343
+ constructor(payload) {
344
+ this.payload = payload;
345
+ this.type = CoreAppActionTypes.ACTIVATED_ROUTE;
346
+ }
347
+ }
348
+ class AddApiQueueItemAction {
349
+ constructor(payload) {
350
+ this.payload = payload;
351
+ this.type = CoreAppActionTypes.ADD_API_QUEUE_ITEM;
352
+ }
353
+ }
354
+ class RemoveApiQueueItemAction {
355
+ constructor(payload) {
356
+ this.payload = payload;
357
+ this.type = CoreAppActionTypes.REMOVE_API_QUEUE_ITEM;
358
+ }
359
+ }
360
+ class EmptyApiQueueAction {
361
+ constructor(payload) {
362
+ this.payload = payload;
363
+ this.type = CoreAppActionTypes.EMPTY_API_QUEUE;
364
+ }
365
+ }
366
+
367
+ var BrowserStorageType;
368
+ (function (BrowserStorageType) {
369
+ BrowserStorageType[BrowserStorageType["local"] = 0] = "local";
370
+ BrowserStorageType[BrowserStorageType["session"] = 1] = "session";
371
+ })(BrowserStorageType || (BrowserStorageType = {}));
372
+ // todo should stay here but all the store directory should be moved upper level
373
+ class StoreService {
374
+ constructor(store, logService) {
375
+ this.store = store;
376
+ this.logService = logService;
377
+ /**
378
+ * autoSave handlers to call before saving in local Storage
379
+ */
380
+ this._autoSaveHandlers = {};
381
+ /** storage instance e.g. localStorage, sessionStorage */
382
+ this._storage = localStorage;
383
+ }
384
+ // use init with just version info, to update to user state, UserService.updateState
385
+ // initializeStore(version?: string, userDetails?: BaseUserDetails) {
386
+ // this.dispatch(new InitStoreAction({ version, userDetails }));
387
+ // }
388
+ init(version, storageType) {
389
+ this.dispatch(new InitStoreAction({ version }));
390
+ this._storage = storageType === BrowserStorageType.session ? sessionStorage : localStorage;
391
+ }
392
+ addAutoSaveHandler(stateSlice, handler) {
393
+ if (!this.store) {
394
+ if (this.logService) {
395
+ this.logService.warn('StoreService.addAutoSaveHandler() not available without NGRX');
396
+ }
397
+ return;
398
+ }
399
+ this._autoSaveHandlers[stateSlice] = handler;
400
+ }
401
+ handleAutoSave() {
402
+ if (!this.store) {
403
+ return;
404
+ }
405
+ this.store
406
+ .pipe(debounceTime(1000), distinctUntilChanged())
407
+ .subscribe(state => {
408
+ this.saveState(state);
409
+ });
410
+ }
411
+ /**
412
+ * Proxy to NGRX store.dispatch()
413
+ * that allows to intercept if the store is present
414
+ */
415
+ dispatch(action) {
416
+ if (this.store) {
417
+ return this.store.dispatch(action);
418
+ }
419
+ }
420
+ /**
421
+ * Proxy to NGRX store.select()
422
+ * that allows to intercept if the store is present
423
+ */
424
+ select(key) {
425
+ if (!this.store) {
426
+ return throwError(new Error('NGRX Store not configured'));
427
+ }
428
+ return this.store.select(key);
429
+ }
430
+ /**
431
+ * filters and save the state with the Browser storage
432
+ * @param state type of CoreState
433
+ */
434
+ saveState(state) {
435
+ let stateToSave = {
436
+ app: state.app,
437
+ };
438
+ if (state.user) {
439
+ const { userId, preferences } = state.user;
440
+ stateToSave.user = { userId, preferences };
441
+ }
442
+ Object.keys(this._autoSaveHandlers).forEach((sliceState) => {
443
+ const handler = this._autoSaveHandlers[sliceState];
444
+ stateToSave = Object.assign(stateToSave, { [sliceState]: handler(state[sliceState]) });
445
+ });
446
+ try {
447
+ const serializedState = JSON.stringify(stateToSave);
448
+ this._storage.setItem('state', serializedState);
449
+ }
450
+ catch (err) {
451
+ // Ignore write errors.
452
+ }
453
+ }
454
+ }
455
+ /** @nocollapse */ /** @nocollapse */ StoreService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreService, deps: [{ token: i1$1.Store, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
456
+ /** @nocollapse */ /** @nocollapse */ StoreService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreService, providedIn: 'root' });
457
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreService, decorators: [{
458
+ type: Injectable,
459
+ args: [{
460
+ providedIn: 'root',
461
+ }]
462
+ }], ctorParameters: function () { return [{ type: i1$1.Store, decorators: [{
463
+ type: Optional
464
+ }] }, { type: LogService, decorators: [{
465
+ type: Optional
466
+ }] }]; } });
467
+
468
+ function euiInitApp(injector) {
469
+ return () => {
470
+ return new Promise((resolve) => {
471
+ const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
472
+ locationInitialized.then(() => {
473
+ const appConfig = injector.get(CONFIG_TOKEN);
474
+ // necessary config parameters
475
+ const appVersion = appConfig && appConfig.versions && appConfig.versions.app;
476
+ const storageType = appConfig && appConfig.saveStateStorage;
477
+ const storeService = injector.get(StoreService);
478
+ storeService.init(appVersion, storageType);
479
+ storeService.handleAutoSave();
480
+ resolve(null);
481
+ });
482
+ });
483
+ };
484
+ }
485
+
486
+ function getCoreProviders() {
487
+ return [
488
+ // core config
489
+ ...getDependencyProviders(),
490
+ { provide: BASE_NAME_TOKEN, useValue: 'eui-core' },
491
+ // app config
492
+ { provide: CONFIG_TOKEN, useFactory: prepareEuiAppConfigToken, deps: [EUI_CONFIG_TOKEN] },
493
+ // global config
494
+ { provide: GLOBAL_CONFIG_TOKEN, useFactory: getGlobalConfig, deps: [CONFIG_TOKEN] },
495
+ { provide: ROOT_LOG_CONFIG_TOKEN, useFactory: getRootLogConfig, deps: [CONFIG_TOKEN] },
496
+ { provide: SHOW_CONNECTION_STATUS_TOKEN, useFactory: getShowConnectionStatus, deps: [GLOBAL_CONFIG_TOKEN] },
497
+ { provide: LogService, useFactory: euiLogServiceFactory, deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN] },
498
+ { provide: HTTP_ERROR_HANDLER_CONFIG_TOKEN, useFactory: getHttpErrorHandlingConfig, deps: [CONFIG_TOKEN] },
499
+ { provide: APP_INITIALIZER, useFactory: euiInitApp, multi: true, deps: [Injector] },
500
+ ];
501
+ }
502
+ function getDependencyProviders() {
503
+ return [
504
+ { provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
505
+ ];
506
+ }
507
+ function getCoreChildProviders(moduleName) {
508
+ return [
509
+ // module config
510
+ { provide: MODULE_NAME_TOKEN, useValue: moduleName },
511
+ { provide: MODULE_CONFIG_TOKEN, useFactory: getModuleConfig, deps: [CONFIG_TOKEN, MODULE_NAME_TOKEN] },
512
+ // log config
513
+ {
514
+ provide: LogService,
515
+ useFactory: euiLogServiceFactory,
516
+ deps: [Injector, BASE_NAME_TOKEN, ROOT_LOG_CONFIG_TOKEN, MODULE_NAME_TOKEN, MODULE_CONFIG_TOKEN],
517
+ },
518
+ ];
519
+ }
520
+
521
+ var CoreI18nActionTypes;
522
+ (function (CoreI18nActionTypes) {
523
+ CoreI18nActionTypes["UPDATE_I18N_STATE"] = "[I18n] Update I18n State";
524
+ })(CoreI18nActionTypes || (CoreI18nActionTypes = {}));
525
+ class UpdateI18nStateAction {
526
+ constructor(payload) {
527
+ this.payload = payload;
528
+ this.type = CoreI18nActionTypes.UPDATE_I18N_STATE;
529
+ }
530
+ }
531
+
532
+ var CoreUserActionTypes;
533
+ (function (CoreUserActionTypes) {
534
+ CoreUserActionTypes["UPDATE_USER_STATE"] = "[User] Update User state";
535
+ CoreUserActionTypes["UPDATE_USER_DETAILS"] = "[User] Update details";
536
+ CoreUserActionTypes["UPDATE_USER_PREFERENCES"] = "[User] Update preferences";
537
+ CoreUserActionTypes["UPDATE_USER_RIGHTS"] = "[User] Update rights";
538
+ CoreUserActionTypes["UPDATE_USER_DASHBOARD"] = "[User] Update dashboard";
539
+ })(CoreUserActionTypes || (CoreUserActionTypes = {}));
540
+ class UpdateUserStateAction {
541
+ constructor(payload) {
542
+ this.payload = payload;
543
+ this.type = CoreUserActionTypes.UPDATE_USER_STATE;
544
+ }
545
+ }
546
+ class UpdateUserDetailsAction {
547
+ constructor(payload) {
548
+ this.payload = payload;
549
+ this.type = CoreUserActionTypes.UPDATE_USER_DETAILS;
550
+ }
551
+ }
552
+ class UpdateUserPreferencesAction {
553
+ constructor(payload) {
554
+ this.payload = payload;
555
+ this.type = CoreUserActionTypes.UPDATE_USER_PREFERENCES;
556
+ }
557
+ }
558
+ class UpdateUserRightsAction {
559
+ constructor(payload) {
560
+ this.payload = payload;
561
+ this.type = CoreUserActionTypes.UPDATE_USER_RIGHTS;
562
+ }
563
+ }
564
+ class UpdateUserDashboardAction {
565
+ constructor(payload) {
566
+ this.payload = payload;
567
+ this.type = CoreUserActionTypes.UPDATE_USER_DASHBOARD;
568
+ }
569
+ }
570
+
571
+ var CoreNotificationsActionTypes;
572
+ (function (CoreNotificationsActionTypes) {
573
+ CoreNotificationsActionTypes["UPDATE_NOTIFICATIONS_LIST"] = "[Notif] Update list";
574
+ })(CoreNotificationsActionTypes || (CoreNotificationsActionTypes = {}));
575
+ class UpdateNotificationsListAction {
576
+ constructor(payload) {
577
+ this.payload = payload;
578
+ this.type = CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST;
579
+ }
580
+ }
581
+
582
+ var CoreLocaleActionTypes;
583
+ (function (CoreLocaleActionTypes) {
584
+ CoreLocaleActionTypes["UPDATE_LOCALE_STATE"] = "[Locale] Update Locale State";
585
+ })(CoreLocaleActionTypes || (CoreLocaleActionTypes = {}));
586
+ class UpdateLocaleStateAction {
587
+ constructor(payload) {
588
+ this.payload = payload;
589
+ this.type = CoreLocaleActionTypes.UPDATE_LOCALE_STATE;
590
+ }
591
+ }
592
+
593
+ class I18nResourceImpl {
594
+ /**
595
+ * Resource constructor
596
+ * @param prefix the prefix of the resource
597
+ * @param suffix the suffix of the resource, optional parameter
598
+ * @param compileTranslations compiler function, optional parameter
599
+ */
600
+ constructor(prefix, suffix = '', compileTranslationsFn = (translations) => {
601
+ return translations;
602
+ }) {
603
+ this.prefix = prefix;
604
+ this.suffix = suffix;
605
+ this.compileTranslationsFn = compileTranslationsFn;
606
+ }
607
+ /**
608
+ * Translations pre-processor
609
+ * @param translations the object to be pre-processed
610
+ * @param lang the translations language
611
+ * @returns the pre-processed translations
612
+ */
613
+ compileTranslations(translations, lang) {
614
+ return this.compileTranslationsFn(translations, lang);
615
+ }
616
+ /**
617
+ * Indicates whether other object is equal-to this one.
618
+ * @param obj the reference object with which to compare
619
+ * @returns true if this object is the same as obj, false otherwise
620
+ */
621
+ equals(obj) {
622
+ return this.prefix === obj.prefix && this.suffix === obj.suffix;
623
+ }
624
+ /**
625
+ * The path to the resource
626
+ * @param lang the resource language
627
+ * @returns the path
628
+ */
629
+ getPath(lang) {
630
+ return `${this.prefix}${lang}${this.suffix}`;
631
+ }
632
+ }
633
+
634
+ class I18nLoader {
635
+ constructor(http, logService, euiAppConfig) {
636
+ this.http = http;
637
+ this.logService = logService;
638
+ this.euiAppConfig = euiAppConfig;
639
+ this.resources = [];
640
+ // create the resources from the config object
641
+ const i18nConfig = this.euiAppConfig.global && this.euiAppConfig.global.i18n;
642
+ const i18nLoaderConfig = i18nConfig && i18nConfig.i18nLoader;
643
+ this.resources.push(...this.createResources(i18nLoaderConfig));
644
+ }
645
+ /**
646
+ * Gets the translations from the server
647
+ * @param lang
648
+ * @returns Observable<any>
649
+ */
650
+ getTranslation(lang) {
651
+ return this.loadResources(this.resources, lang).pipe(map((loadedResources) => {
652
+ return loadedResources.translations;
653
+ }));
654
+ }
655
+ /**
656
+ * Adds resources
657
+ * @param config loader configuration
658
+ * @returns Observable<any> | false
659
+ */
660
+ addResources(config) {
661
+ // create the resources
662
+ let resources = this.createResources(config);
663
+ // filter the resources first, to avoid duplicates
664
+ resources = resources.filter(resource => !this.resources.some(res => res.equals(resource)));
665
+ // add the new resources to the list of existing resources
666
+ this.resources.push(...resources);
667
+ // return the filtered resources
668
+ return resources;
669
+ }
670
+ /**
671
+ * Removes resources from the loader instance
672
+ */
673
+ removeResources(removedResources) {
674
+ this.resources = this.resources.filter(res => !removedResources.some((removedResource) => removedResource.equals(res)));
675
+ }
676
+ /**
677
+ * Loads an array of resources, by language
678
+ * @param resources the definition of the resources
679
+ * @param lang the resource language to load
680
+ * @returns Observable<any>
681
+ */
682
+ loadResources(resources, lang) {
683
+ // if there are resources to load
684
+ if (Array.isArray(resources) && resources.length > 0) {
685
+ // load all the resources in an array of Observable
686
+ const requests = resources.map(resource => this.loadResource(resource, lang));
687
+ // group all the observables with forkJoin and deep merge them
688
+ return forkJoin(requests).pipe(map(response => {
689
+ const successResp = [];
690
+ const errResp = [];
691
+ response.forEach((item) => {
692
+ if (item.isError) {
693
+ errResp.push({ resource: item.resource, error: item.error });
694
+ }
695
+ else {
696
+ successResp.push(item);
697
+ }
698
+ });
699
+ if (successResp.length === response.length) {
700
+ return { hasError: false, translations: mergeAll(successResp) };
701
+ }
702
+ else {
703
+ return { hasError: true, translations: mergeAll(successResp), errors: errResp };
704
+ }
705
+ }));
706
+ }
707
+ else {
708
+ // no resources to load
709
+ return of({ hasError: false, translations: {} });
710
+ }
711
+ }
712
+ /**
713
+ * Create resources from a config file
714
+ * @param config loader configuration
715
+ * @returns I18nResourceImpl[] resources
716
+ */
717
+ createResources(config) {
718
+ // use the default config as a reference base
719
+ config = getI18nLoaderConfig(config);
720
+ const resources = [];
721
+ // extract the i18n folders from config
722
+ const i18nFolders = Array.isArray(config.i18nFolders) ?
723
+ config.i18nFolders : (config.i18nFolders ? [config.i18nFolders] : []);
724
+ if (i18nFolders) {
725
+ // add the i18n folders to resources
726
+ resources.push(...i18nFolders.map(folder => new I18nResourceImpl(`assets/${folder}/`, '.json')));
727
+ }
728
+ // extract the i18n services from config
729
+ const i18nServices = Array.isArray(config.i18nServices) ?
730
+ config.i18nServices : (config.i18nServices ? [config.i18nServices] : []);
731
+ if (i18nServices) {
732
+ // add the i18n services to resources
733
+ resources.push(...i18nServices.map(service => new I18nResourceImpl(service)));
734
+ }
735
+ // extract the i18n resources from config
736
+ const i18nResources = Array.isArray(config.i18nResources) ?
737
+ config.i18nResources : (config.i18nResources ? [config.i18nResources] : []);
738
+ if (i18nResources) {
739
+ // add the i18n resources to resources
740
+ resources.push(...i18nResources.map(resource => new I18nResourceImpl(resource.prefix, resource.suffix, this.getResourceCompileFunction(resource.compileTranslations))));
741
+ }
742
+ return resources;
743
+ }
744
+ /**
745
+ * Loads a resource, by language
746
+ * @param resource the definition of the resource
747
+ * @param lang the resource language to load
748
+ * @returns Observable<any>
749
+ */
750
+ loadResource(resource, lang) {
751
+ // the path to the resource
752
+ const path = resource.getPath(lang);
753
+ // load the translations from the path
754
+ return this.http.get(path)
755
+ .pipe(
756
+ // preprocess the translations using the resource compiler
757
+ map((translations) => resource.compileTranslations(translations, lang)), map((translations) => {
758
+ // resource loaded properly, send a info message
759
+ if (this.logService) {
760
+ this.logService.info(`I18n resource loaded from path ${path}`);
761
+ }
762
+ // return the translations
763
+ return translations;
764
+ }), catchError((err) => {
765
+ // resource not loaded properly, send a warning message
766
+ if (this.logService) {
767
+ this.logService.warn(`I18n resource NOT loaded from path ${path}`, err);
768
+ }
769
+ const resourceError = { error: `I18n resource NOT loaded from path ${path}`, resource, isError: true };
770
+ return of(resourceError);
771
+ }));
772
+ }
773
+ getResourceCompileFunction(id) {
774
+ const customHandlers = this.euiAppConfig.customHandler;
775
+ if (customHandlers && typeof customHandlers[id] === 'function') {
776
+ return customHandlers[id];
777
+ }
778
+ return undefined;
779
+ }
780
+ }
781
+ /** @nocollapse */ /** @nocollapse */ I18nLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nLoader, deps: [{ token: i1$2.HttpClient }, { token: LogService, optional: true }, { token: CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
782
+ /** @nocollapse */ /** @nocollapse */ I18nLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nLoader });
783
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nLoader, decorators: [{
784
+ type: Injectable
785
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: LogService, decorators: [{
786
+ type: Optional
787
+ }] }, { type: undefined, decorators: [{
788
+ type: Inject,
789
+ args: [CONFIG_TOKEN]
790
+ }] }]; } });
791
+ const translateConfig = {
792
+ loader: {
793
+ provide: TranslateLoader,
794
+ useClass: I18nLoader,
795
+ },
796
+ };
797
+
798
+ class I18nService extends EuiLazyService {
799
+ constructor(baseGlobalConfig, translateService, logService, store, document) {
800
+ super({ activeLang: 'en' });
801
+ this.baseGlobalConfig = baseGlobalConfig;
802
+ this.translateService = translateService;
803
+ this.logService = logService;
804
+ this.store = store;
805
+ this.document = document;
806
+ this.config = getI18nServiceConfigFromBase(this.baseGlobalConfig);
807
+ this.onModuleLoad = new BehaviorSubject({ ready: false, name: null });
808
+ }
809
+ getState(keyOrMapFn) {
810
+ return this.store.select(getI18nState);
811
+ }
812
+ updateState(langState) {
813
+ this.updateHTMLDOMLang(langState.activeLang);
814
+ this.store.dispatch(new UpdateI18nStateAction(langState));
815
+ }
816
+ init(langState) {
817
+ const initLang = langState && langState.activeLang ? langState.activeLang : this.preparedDefaultLanguage();
818
+ const initState = {
819
+ ...langState,
820
+ activeLang: initLang,
821
+ };
822
+ if (typeof initLang === 'string') {
823
+ super.initEuiService(this.store);
824
+ this.updateState(initState);
825
+ return this.setup(initLang);
826
+ }
827
+ return of({ success: false, error: 'Initial active lang should be string' });
828
+ }
829
+ /**
830
+ * A pipe function that could serve as a wrapper of another observable
831
+ * e.g. ngx-translate i18n.onReady('my_module').pipe(switchMap(()=>translate.get('eui.KEY')));
832
+ * WARNING: onReady will emit only once for a loaded Module, going to another and then going back will not result
833
+ * into another emission.
834
+ * @param moduleName the name of the module that has been given through the eUI globalConfig. In case non provided
835
+ * fetch module name from the state.
836
+ */
837
+ onReady(moduleName) {
838
+ return this.onModuleLoad.pipe(switchMap((evt) => moduleName ? of(evt) :
839
+ this.store.select(getLastAddedModule).pipe(tap(m => moduleName = m), map(() => evt))),
840
+ // emit only if event emitted matches the module name and is ready
841
+ filter((evt) => evt.ready === true && evt.name === moduleName),
842
+ // make sure that observable completes
843
+ take(1));
844
+ }
845
+ lazyLoad(config) {
846
+ const moduleId = Math.floor((Math.random() * 100000) + 1).toLocaleString();
847
+ return this.addResources(config, moduleId);
848
+ }
849
+ lazyLoadInit(moduleConfig, moduleName) {
850
+ const i18nLoaderConfig = moduleConfig;
851
+ // add resources
852
+ return this.addResources(i18nLoaderConfig, moduleName);
853
+ }
854
+ /**
855
+ * Add resources based of a config loader
856
+ * @param config I18nLoaderConfig
857
+ * @return Promise<EuiServiceStatus> an EuiServiceStatus when translation has fully loaded
858
+ */
859
+ addResources(config, moduleName) {
860
+ // emit that module is loading
861
+ this.onModuleLoad.next({ ready: false, name: moduleName });
862
+ const loader = this.translateService.currentLoader;
863
+ if (loader instanceof I18nLoader) {
864
+ const langSubscription = [];
865
+ const i18nLoader = loader;
866
+ // add the resources to the loader
867
+ const resources = i18nLoader.addResources(config);
868
+ // manually load the resources for the CURRENT language and add them to the translate service
869
+ langSubscription.push(i18nLoader.loadResources(resources, this.translateService.currentLang)
870
+ .pipe(take(1), tap((loadedResources) => {
871
+ // add the new set of translations to the current language
872
+ this.translateService.setTranslation(this.translateService.currentLang, loadedResources.translations, true);
873
+ if (loadedResources.hasError) {
874
+ i18nLoader.removeResources(loadedResources.errors.map(err => err.resource));
875
+ }
876
+ })));
877
+ // if the current language is different than the DEFAULT language
878
+ if (this.translateService.currentLang !== this.translateService.defaultLang) {
879
+ // manually load the resources for the default language and add them to the translate service
880
+ langSubscription.push(i18nLoader.loadResources(resources, this.translateService.defaultLang)
881
+ .pipe(take(1), tap((loadedResources) => {
882
+ this.translateService.setTranslation(this.translateService.defaultLang, loadedResources.translations, true);
883
+ if (loadedResources.hasError) {
884
+ i18nLoader.removeResources(loadedResources.errors.map(err => err.resource));
885
+ }
886
+ })));
887
+ }
888
+ return forkJoin(langSubscription).pipe(map((loadedResourcesArr) => {
889
+ return !loadedResourcesArr[0].hasError ?
890
+ { success: true } :
891
+ { success: false, error: loadedResourcesArr[0].errors };
892
+ }), tap(() => {
893
+ // emit status of module loading progress
894
+ this.onModuleLoad.next({ ready: true, name: moduleName });
895
+ }), catchError(error => {
896
+ // emit status of module loading progress
897
+ this.onModuleLoad.next({ ready: true, name: moduleName, error: error });
898
+ return of({ success: false, error: error });
899
+ }));
900
+ }
901
+ else {
902
+ return of({ success: false, error: 'currentLoader is not an I18nLoader.' });
903
+ }
904
+ }
905
+ /**
906
+ * Prepares the default language
907
+ */
908
+ preparedDefaultLanguage() {
909
+ const browserPref = getBrowserDefaultLanguage();
910
+ // If user has browser preferred lang, and that language is part of the languages array
911
+ if (browserPref && this.config.languages && UxEuLanguages.getLanguageCodes(this.config.languages).includes(browserPref)) {
912
+ return browserPref;
913
+ }
914
+ return this.config.defaultLanguage;
915
+ }
916
+ /**
917
+ * @param default_language if given default language to override default language coming from the
918
+ * configuration token.
919
+ */
920
+ setup(initLanguage) {
921
+ // use the default config as a reference base
922
+ this.config = Object.assign({}, DEFAULT_I18N_SERVICE_CONFIG, this.config);
923
+ // configure the translate config service
924
+ if (this.config.languages) {
925
+ this.translateService.addLangs(UxEuLanguages.getLanguageCodes(this.config.languages));
926
+ if (this.logService) {
927
+ this.logService.info(`I18n accepted languages set to ${UxEuLanguages.getLanguageCodes(this.config.languages)}`);
928
+ }
929
+ }
930
+ // set the current language, causing to load translations
931
+ return this.translateService
932
+ .use(initLanguage)
933
+ .pipe(tap(() => {
934
+ this.bindActiveLangStateToTranslateService();
935
+ this.bindTranslateServiceLangChangeToState();
936
+ if (this.config.defaultLanguage) {
937
+ this.setDefaultLanguage(this.config.defaultLanguage);
938
+ }
939
+ }), map(() => {
940
+ return { success: true };
941
+ }), catchError((error) => {
942
+ return of({ success: false, error: error });
943
+ }));
944
+ }
945
+ bindActiveLangStateToTranslateService() {
946
+ this.store.select(getActiveLang).subscribe((lang) => {
947
+ if (lang !== null && (this.translateService.currentLang !== lang)) {
948
+ this.use(lang);
949
+ }
950
+ });
951
+ }
952
+ bindTranslateServiceLangChangeToState() {
953
+ this.translateService.onLangChange.subscribe((event) => {
954
+ if (this.stateInstance.activeLang !== event.lang) {
955
+ this.updateState({ activeLang: event.lang });
956
+ }
957
+ if (this.logService) {
958
+ this.logService.info(`I18n current language set to ${event.lang}`);
959
+ }
960
+ });
961
+ }
962
+ setDefaultLanguage(defaultLanguage) {
963
+ // removed, current language is already calculated in init, setup function fill use it directly, not default
964
+ // this.translateService.currentLang = default_language || this.config.defaultLanguage;
965
+ this.translateService.setDefaultLang(defaultLanguage);
966
+ if (this.logService) {
967
+ this.logService.info(`I18n default language set to ${defaultLanguage}`);
968
+ }
969
+ }
970
+ /**
971
+ * change the currently used language
972
+ * @param lang is the language code based on the convention you used e.g. (en or en-EN)
973
+ * @returns Observable that returns an object contain the object translation for given language after language
974
+ * fully loaded.
975
+ */
976
+ use(lang) {
977
+ return this.translateService.use(lang);
978
+ }
979
+ /**
980
+ * updates the HTML element lang attribute
981
+ * @private
982
+ */
983
+ updateHTMLDOMLang(lang) {
984
+ this.document.documentElement.lang = lang;
985
+ }
986
+ }
987
+ /** @nocollapse */ /** @nocollapse */ I18nService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nService, deps: [{ token: GLOBAL_CONFIG_TOKEN }, { token: i2.TranslateService }, { token: LogService, optional: true }, { token: StoreService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
988
+ /** @nocollapse */ /** @nocollapse */ I18nService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nService, providedIn: 'root' });
989
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nService, decorators: [{
990
+ type: Injectable,
991
+ args: [{
992
+ providedIn: 'root',
993
+ }]
994
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
995
+ type: Inject,
996
+ args: [GLOBAL_CONFIG_TOKEN]
997
+ }] }, { type: i2.TranslateService }, { type: LogService, decorators: [{
998
+ type: Optional
999
+ }] }, { type: StoreService }, { type: Document, decorators: [{
1000
+ type: Inject,
1001
+ args: [DOCUMENT]
1002
+ }] }]; } });
1003
+
1004
+ class I18nServiceMock extends I18nService {
1005
+ constructor() {
1006
+ super(null, null, null, null, null);
1007
+ this.DEFAULT_LANGUAGE = 'en';
1008
+ }
1009
+ get onLangChange() {
1010
+ return new EventEmitter();
1011
+ }
1012
+ addResources() {
1013
+ return of({ success: true });
1014
+ }
1015
+ get currentLanguage() {
1016
+ return this.DEFAULT_LANGUAGE;
1017
+ }
1018
+ getState() {
1019
+ return of({ activeLang: this.DEFAULT_LANGUAGE });
1020
+ }
1021
+ updateState(i18nState) {
1022
+ this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1023
+ }
1024
+ init(i18nState) {
1025
+ this.DEFAULT_LANGUAGE = i18nState.activeLang || 'en';
1026
+ return of({ success: true });
1027
+ }
1028
+ lazyLoadInit() {
1029
+ return of({ success: true });
1030
+ }
1031
+ }
1032
+ /** @nocollapse */ /** @nocollapse */ I18nServiceMock.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1033
+ /** @nocollapse */ /** @nocollapse */ I18nServiceMock.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nServiceMock });
1034
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: I18nServiceMock, decorators: [{
1035
+ type: Injectable
1036
+ }], ctorParameters: function () { return []; } });
1037
+
1038
+ const initialState = {
1039
+ appName: '',
1040
+ appShortName: '',
1041
+ appSubTitle: '',
1042
+ userInfos: null,
1043
+ userSubInfos: null,
1044
+ impersonatedUserInfos: null,
1045
+ isSidebarOpen: false,
1046
+ isSidebarHover: false,
1047
+ isSidebarActive: false,
1048
+ isSidebarInnerActive: false,
1049
+ isSidebarStateCloseWithIcons: false,
1050
+ hasSidebar: false,
1051
+ hasHeader: false,
1052
+ hasHeaderLogo: false,
1053
+ hasHeaderEnvironment: false,
1054
+ environmentValue: '',
1055
+ isSidebarHidden: false,
1056
+ hasToolbar: false,
1057
+ windowWidth: 0,
1058
+ windowHeight: 0,
1059
+ mainContentHeight: 0,
1060
+ pageHeaderHeight: 0,
1061
+ wrapperClasses: '',
1062
+ breakpoint: '',
1063
+ breakpoints: {
1064
+ isMobile: false,
1065
+ isTablet: false,
1066
+ isLtDesktop: false,
1067
+ isDesktop: false,
1068
+ isXL: false,
1069
+ isXXL: false,
1070
+ },
1071
+ menuLinks: [],
1072
+ sidebarLinks: [],
1073
+ combinedLinks: [],
1074
+ isBlockDocumentActive: false,
1075
+ deviceInfo: null,
1076
+ activeLanguage: 'en',
1077
+ languages: UxEuLanguages.getLanguages(),
1078
+ appMetadata: null,
1079
+ hasModalActive: false,
1080
+ isDimmerActive: false,
1081
+ };
1082
+ // TODO: this service needs to be transferred in the respective component
1083
+ class UxAppShellService {
1084
+ constructor(config, http, platformId, router, storeService, i18nService) {
1085
+ this.config = config;
1086
+ this.http = http;
1087
+ this.platformId = platformId;
1088
+ this.router = router;
1089
+ this.storeService = storeService;
1090
+ this.i18nService = i18nService;
1091
+ this.growlMessages = [];
1092
+ this.isGrowlSticky = false;
1093
+ this.growlLife = 3000;
1094
+ this.growlPosition = 'bottom-right';
1095
+ this.growlCallback = null;
1096
+ this.activeModals = [];
1097
+ this.openModalId = new BehaviorSubject('');
1098
+ this.cssVars = [];
1099
+ let stateWithConfig = initialState;
1100
+ const languages = config?.i18n?.i18nService?.languages || initialState.languages;
1101
+ const defaultLanguage = config?.i18n?.i18nService?.defaultLanguage || initialState.activeLanguage;
1102
+ stateWithConfig = {
1103
+ ...stateWithConfig, ...{
1104
+ languages: languages,
1105
+ activeLanguage: defaultLanguage,
1106
+ },
1107
+ };
1108
+ this._state$ = new BehaviorSubject(stateWithConfig);
1109
+ this._breakpoint$ = new BehaviorSubject('');
1110
+ this._breakpoints$ = new BehaviorSubject({});
1111
+ this.bindActiveLanguageToAppShellState();
1112
+ if (isPlatformBrowser(this.platformId)) {
1113
+ router.events
1114
+ .subscribe((event) => {
1115
+ if (event instanceof NavigationEnd) {
1116
+ window.scrollTo(0, 0);
1117
+ }
1118
+ });
1119
+ }
1120
+ }
1121
+ // -------------------
1122
+ get state$() {
1123
+ return this._state$.asObservable();
1124
+ }
1125
+ // -------------------
1126
+ // exposed observables
1127
+ get breakpoint$() {
1128
+ return this._breakpoint$.asObservable();
1129
+ }
1130
+ get breakpoints$() {
1131
+ return this._breakpoints$.asObservable();
1132
+ }
1133
+ // ----------------
1134
+ // state operations
1135
+ // ----------------
1136
+ get state() {
1137
+ return this._state$.getValue();
1138
+ }
1139
+ get isSidebarOpen() {
1140
+ return this.state.isSidebarOpen;
1141
+ }
1142
+ // Edit mode
1143
+ get isDimmerActive() {
1144
+ return this.state.isDimmerActive;
1145
+ }
1146
+ // ----------------------------
1147
+ // public setters and functions
1148
+ // ----------------------------
1149
+ set isSidebarOpen(isOpen) {
1150
+ this.setState({
1151
+ ...this.state,
1152
+ isSidebarOpen: isOpen,
1153
+ });
1154
+ }
1155
+ set isSidebarHover(isHover) {
1156
+ this.setState({
1157
+ ...this.state,
1158
+ isSidebarHover: isHover,
1159
+ });
1160
+ }
1161
+ get isSidebarHover() {
1162
+ return this.state.isSidebarHover;
1163
+ }
1164
+ set isSidebarActive(isActive) {
1165
+ this.setState({
1166
+ ...this.state,
1167
+ isSidebarActive: isActive,
1168
+ });
1169
+ }
1170
+ set isSidebarInnerActive(isOpen) {
1171
+ this.setState({
1172
+ ...this.state,
1173
+ isSidebarInnerActive: isOpen,
1174
+ });
1175
+ }
1176
+ set sidebarLinks(links) {
1177
+ this.setState({
1178
+ ...this.state,
1179
+ sidebarLinks: links,
1180
+ });
1181
+ }
1182
+ set menuLinks(links) {
1183
+ this.setState({
1184
+ ...this.state,
1185
+ menuLinks: links,
1186
+ });
1187
+ }
1188
+ set isBlockDocumentActive(isActive) {
1189
+ this.setState({
1190
+ ...this.state,
1191
+ isBlockDocumentActive: isActive,
1192
+ });
1193
+ }
1194
+ // Edit mode
1195
+ set isDimmerActive(isActive) {
1196
+ this.setState({
1197
+ ...this.state,
1198
+ isDimmerActive: isActive,
1199
+ });
1200
+ }
1201
+ setState(nextState, updateI18 = true) {
1202
+ let breakpoint, breakpoints, wrapperClasses;
1203
+ let combinedLinks;
1204
+ const state = this.state;
1205
+ // check if window width has been updated from previous state
1206
+ if (this.state.windowWidth !== nextState.windowWidth) {
1207
+ breakpoint = this.getBreakpoint(nextState.windowWidth);
1208
+ breakpoints = this.getBreakpoints(breakpoint);
1209
+ this._breakpoint$.next(breakpoint);
1210
+ this._breakpoints$.next(breakpoints);
1211
+ // if not propagate the old ones without doing any calculations
1212
+ }
1213
+ else {
1214
+ breakpoint = state.breakpoint;
1215
+ breakpoints = state.breakpoints;
1216
+ }
1217
+ // finally get the wrapper classes when both the state and breakpoint are known
1218
+ wrapperClasses = this.getWrapperClasses(nextState, breakpoint);
1219
+ // check if the menuLinks or sidebarLinks have changed from previous state
1220
+ if (this.state.menuLinks !== nextState.menuLinks || this.state.sidebarLinks !== nextState.sidebarLinks) {
1221
+ combinedLinks = [...nextState.menuLinks, ...nextState.sidebarLinks];
1222
+ }
1223
+ else {
1224
+ combinedLinks = this.state.combinedLinks;
1225
+ }
1226
+ const stateBeforeUpdate = { ...this.state };
1227
+ // we put it all together with the calculated properties
1228
+ this._state$.next({
1229
+ ...nextState,
1230
+ wrapperClasses,
1231
+ breakpoint,
1232
+ breakpoints,
1233
+ combinedLinks,
1234
+ });
1235
+ // update the Store Language
1236
+ if (updateI18 && nextState.activeLanguage !== stateBeforeUpdate.activeLanguage) {
1237
+ this.i18nService.updateState({ activeLang: nextState.activeLanguage });
1238
+ }
1239
+ }
1240
+ /**
1241
+ * Emits a slice from the state whether that changes
1242
+ * @param key can be 'key' or 'key.sub.sub'
1243
+ */
1244
+ getState(key) {
1245
+ return defer(() => {
1246
+ // check if key exists
1247
+ return key ? this.state$.pipe(map((state) => get(state, key)), filter((state) => state), distinctUntilChanged((x, y) => isEqual(x, y))) : this.state$;
1248
+ });
1249
+ }
1250
+ sidebarToggle() {
1251
+ this.isSidebarOpen = !this.state.isSidebarOpen;
1252
+ }
1253
+ // Edit mode
1254
+ dimmerActiveToggle() {
1255
+ const isActive = this.isDimmerActive;
1256
+ this.setState({
1257
+ ...this.state,
1258
+ isDimmerActive: !isActive,
1259
+ });
1260
+ this.activateEditModeCssVars(!isActive);
1261
+ }
1262
+ setDimmerActiveState(activeState) {
1263
+ this.setState({
1264
+ ...this.state,
1265
+ isDimmerActive: activeState,
1266
+ });
1267
+ this.activateEditModeCssVars(activeState);
1268
+ }
1269
+ activateEditModeCssVars(isActive) {
1270
+ if (isActive) {
1271
+ this._setCssVarValue('--eui-docpage-navigation-z-index', 'inherit'); // Reset doc-page-navigation-column z-index
1272
+ this._setCssVarValue('--eui-z-index-sidebar', 'inherit'); // Reset eui-app-sidebar z-index
1273
+ this._setCssVarValue('--eui-z-index-root', 'inherit'); // Reset eui-app-main-content z-index
1274
+ }
1275
+ else {
1276
+ this._setCssVarValue('--eui-docpage-navigation-z-index', '2'); // Restore doc-page-navigation-column z-index
1277
+ this._setCssVarValue('--eui-z-index-sidebar', '1044'); // Restore eui-app-sidebar z-index
1278
+ this._setCssVarValue('--eui-z-index-root', '1'); // Restore eui-app-main-content z-index
1279
+ }
1280
+ }
1281
+ // --------------
1282
+ // public methods
1283
+ // --------------
1284
+ fetchAppMetadata(metadataFilePath = 'assets/app-metadata.json') {
1285
+ this.getJson(metadataFilePath)
1286
+ .then((data) => {
1287
+ this.setState({
1288
+ ...this.state,
1289
+ appMetadata: data,
1290
+ });
1291
+ });
1292
+ }
1293
+ activateSidebar() {
1294
+ this.setState({
1295
+ ...this.state,
1296
+ hasSidebar: true,
1297
+ });
1298
+ if (!this.state.isSidebarHidden) {
1299
+ this.activateSidebarCssVars();
1300
+ }
1301
+ }
1302
+ activateSidebarHeader() {
1303
+ this.activateSidebarHeaderCssVars();
1304
+ }
1305
+ activateSidebarFooter() {
1306
+ this.activateSidebarFooterCssVars();
1307
+ }
1308
+ activateHeader() {
1309
+ this.setState({
1310
+ ...this.state,
1311
+ hasHeader: true,
1312
+ });
1313
+ this.activateHeaderCssVars();
1314
+ }
1315
+ activateToolbar() {
1316
+ this.setState({
1317
+ ...this.state,
1318
+ hasToolbar: true,
1319
+ });
1320
+ this.activateToolbarCssVars();
1321
+ }
1322
+ fetchCssVars() {
1323
+ const cssVarNames = [
1324
+ '--eui-app-header-height-default',
1325
+ '--eui-app-header-height-active',
1326
+ '--eui-app-header-height-shrink',
1327
+ '--eui-app-toolbar-height-default',
1328
+ '--eui-app-toolbar-height-active',
1329
+ '--eui-app-sidebar-width-default',
1330
+ '--eui-app-sidebar-width-active',
1331
+ '--eui-app-sidebar-width-close-default',
1332
+ '--eui-app-sidebar-width-close-active',
1333
+ '--eui-app-sidebar-header-height-default',
1334
+ '--eui-app-sidebar-header-height-active',
1335
+ '--eui-app-sidebar-footer-height-default',
1336
+ '--eui-app-sidebar-footer-height-active',
1337
+ ];
1338
+ this.cssVars = cssVarNames.map((v) => {
1339
+ return { key: v, value: this.getCssVarValue(v) };
1340
+ });
1341
+ }
1342
+ initCssVars() {
1343
+ this.setCssVar('--eui-app-header-height-default', '--eui-app-header-height');
1344
+ this.setCssVar('--eui-app-toolbar-height-default', '--eui-app-toolbar-height');
1345
+ this.setCssVar('--eui-app-sidebar-width-default', '--eui-app-sidebar-width');
1346
+ this.setCssVar('--eui-app-sidebar-width-close-default', '--eui-app-sidebar-width-close');
1347
+ this.setCssVar('--eui-app-sidebar-header-height-default', '--eui-app-sidebar-header-height');
1348
+ this.setCssVar('--eui-app-sidebar-footer-height-default', '--eui-app-sidebar-footer-height');
1349
+ }
1350
+ activateHeaderCssVars() {
1351
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
1352
+ }
1353
+ activateToolbarCssVars() {
1354
+ this.setCssVar('--eui-app-toolbar-height-active', '--eui-app-toolbar-height');
1355
+ }
1356
+ activateFooterCssVars() {
1357
+ this.setCssVar('--eui-app-footer-height-active', '--eui-app-footer-height');
1358
+ }
1359
+ setHeaderShrinkCssVar(active) {
1360
+ if (active) {
1361
+ this.setCssVar('--eui-app-header-height-shrink', '--eui-app-header-height');
1362
+ }
1363
+ else {
1364
+ this.setCssVar('--eui-app-header-height-active', '--eui-app-header-height');
1365
+ }
1366
+ }
1367
+ activateSidebarCssVars() {
1368
+ this.setCssVar('--eui-app-sidebar-width-active', '--eui-app-sidebar-width');
1369
+ this.setCssVar('--eui-app-sidebar-width-close-active', '--eui-app-sidebar-width-close');
1370
+ }
1371
+ activateSidebarHeaderCssVars() {
1372
+ this.setCssVar('--eui-app-sidebar-header-height-active', '--eui-app-sidebar-header-height');
1373
+ }
1374
+ activateSidebarFooterCssVars() {
1375
+ this.setCssVar('--eui-app-sidebar-footer-height-active', '--eui-app-sidebar-footer-height');
1376
+ }
1377
+ /**
1378
+ * displays a growl UxMessage item, isSticky
1379
+ */
1380
+ growl(msg, isSticky, isMultiple, life, position, callback) {
1381
+ if (msg.severity !== 'info' && msg.severity !== 'warning' && msg.severity !== 'success' && msg.severity !== 'danger') {
1382
+ throw new Error('UxAppShellService.growl() ERROR : message severity must be either : success, warning, info, danger');
1383
+ }
1384
+ else {
1385
+ if (isMultiple === undefined || !isMultiple) {
1386
+ this.growlMessages = [];
1387
+ }
1388
+ this.growlMessages = this.growlMessages.concat(msg);
1389
+ msg.life = life;
1390
+ msg.sticky = isSticky;
1391
+ if (life === undefined || isNaN(life)) {
1392
+ if (msg.severity === 'danger') {
1393
+ isSticky = true;
1394
+ }
1395
+ else {
1396
+ this.growlLife = 3000;
1397
+ }
1398
+ }
1399
+ else {
1400
+ this.growlLife = life;
1401
+ }
1402
+ if (isSticky) {
1403
+ this.isGrowlSticky = isSticky;
1404
+ }
1405
+ else {
1406
+ this.isGrowlSticky = false;
1407
+ }
1408
+ if (position) {
1409
+ this.growlPosition = position;
1410
+ }
1411
+ if (callback) {
1412
+ this.growlCallback = callback;
1413
+ }
1414
+ else {
1415
+ this.growlCallback = () => {
1416
+ };
1417
+ }
1418
+ }
1419
+ }
1420
+ clearGrowl() {
1421
+ this.growlMessages = [];
1422
+ }
1423
+ growlSuccess(msg, position) {
1424
+ this.growl({ severity: 'success', summary: 'SUCCESS', detail: msg }, false, false, undefined, position);
1425
+ }
1426
+ growlError(msg, position) {
1427
+ this.growl({ severity: 'danger', summary: 'ERROR', detail: msg }, false, false, undefined, position);
1428
+ }
1429
+ // date helpers
1430
+ growlWarning(msg, position) {
1431
+ this.growl({ severity: 'warning', summary: 'WARNING', detail: msg }, false, false, undefined, position);
1432
+ }
1433
+ growlInfo(msg, position) {
1434
+ this.growl({ severity: 'info', summary: 'INFO', detail: msg }, false, false, undefined, position);
1435
+ }
1436
+ openModal(modalId) {
1437
+ document.body.classList.add('modal-open');
1438
+ if (!modalId) {
1439
+ modalId = 'single_modal';
1440
+ }
1441
+ this.activeModals.push({
1442
+ id: modalId,
1443
+ isOpen: true,
1444
+ });
1445
+ setTimeout(() => {
1446
+ const el = document.getElementById(modalId + '-close-button');
1447
+ if (el) {
1448
+ el.focus();
1449
+ }
1450
+ }, 100);
1451
+ }
1452
+ openMessageBox(messageBoxId) {
1453
+ if (!messageBoxId) {
1454
+ messageBoxId = 'messagebox_modal';
1455
+ }
1456
+ this.openModal(messageBoxId);
1457
+ }
1458
+ closeMessageBox(messageBoxId) {
1459
+ if (!messageBoxId) {
1460
+ messageBoxId = 'messagebox_modal';
1461
+ }
1462
+ this.closeModal(messageBoxId);
1463
+ }
1464
+ isModalOpen(modalId) {
1465
+ if (!modalId) {
1466
+ modalId = 'single_modal';
1467
+ }
1468
+ if (this.activeModals.length) {
1469
+ let modalIndex = this.findModalIndex(modalId);
1470
+ if (modalIndex !== -1) {
1471
+ return this.activeModals[modalIndex].isOpen;
1472
+ }
1473
+ }
1474
+ return false;
1475
+ }
1476
+ // Positions helpers
1477
+ closeModal(modalId) {
1478
+ if (!modalId) {
1479
+ modalId = 'single_modal';
1480
+ }
1481
+ /**
1482
+ * Make sure we find the modal before splicing the activeModals array
1483
+ */
1484
+ const index = this.findModalIndex(modalId);
1485
+ if (index >= 0) {
1486
+ this.activeModals.splice(index, 1);
1487
+ }
1488
+ if (this.activeModals && this.activeModals.length <= 0) {
1489
+ document.body.classList.remove('modal-open');
1490
+ }
1491
+ else {
1492
+ // If there is still another (parent) modal dialog open, ensure it is focused upon to be able to close is with the ESC key:
1493
+ const lastModalId = this.activeModals[this.activeModals.length - 1].id;
1494
+ if (lastModalId) {
1495
+ setTimeout(() => {
1496
+ const el = document.getElementById(lastModalId + '-close-button');
1497
+ if (el) {
1498
+ el.focus();
1499
+ }
1500
+ }, 100);
1501
+ }
1502
+ }
1503
+ }
1504
+ findModalIndex(modalId) {
1505
+ let index = -1;
1506
+ if (this.activeModals.length) {
1507
+ for (let i = 0; i < this.activeModals.length; i++) {
1508
+ if (this.activeModals[i].id === modalId) {
1509
+ index = i;
1510
+ break;
1511
+ }
1512
+ }
1513
+ }
1514
+ return index;
1515
+ }
1516
+ // ---------------
1517
+ // private getters
1518
+ // ---------------
1519
+ getCssVarValue(inputProperty) {
1520
+ return getComputedStyle(document.documentElement).getPropertyValue(inputProperty);
1521
+ }
1522
+ setCssVar(inputProperty, outputProperty) {
1523
+ const cssVarValue = this.cssVars.filter(v => v.key === inputProperty)[0].value;
1524
+ this._setCssVarValue(outputProperty, cssVarValue);
1525
+ // console.log(inputProperty, outputProperty, cssVarValue);
1526
+ }
1527
+ _setCssVarValue(varName, varValue) {
1528
+ document.documentElement.style.setProperty(varName, varValue);
1529
+ }
1530
+ getWrapperClasses(state, breakpoint) {
1531
+ let classes = [];
1532
+ classes.push(breakpoint);
1533
+ if (state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
1534
+ classes.push('sidebar-state-open');
1535
+ }
1536
+ if (!state.isSidebarOpen && (state.isSidebarActive || state.isSidebarInnerActive)) {
1537
+ classes.push('sidebar-state-close');
1538
+ }
1539
+ if (state.isSidebarActive) {
1540
+ classes.push('sidebar-active');
1541
+ }
1542
+ if (state.isSidebarInnerActive) {
1543
+ classes.push('sidebar-inner-active');
1544
+ }
1545
+ if (state.isSidebarStateCloseWithIcons) {
1546
+ classes.push('sidebar-state-close-with-icons');
1547
+ }
1548
+ // NEW APP-SHELL props
1549
+ if (state.isSidebarHidden) {
1550
+ classes.push('sidebar--hidden');
1551
+ }
1552
+ if (state.isSidebarOpen) {
1553
+ classes.push('sidebar--open');
1554
+ }
1555
+ else {
1556
+ classes.push('sidebar--close');
1557
+ }
1558
+ if (state.isSidebarHover) {
1559
+ classes.push('sidebar--hover');
1560
+ }
1561
+ if (state.deviceInfo && state.deviceInfo.isFF) {
1562
+ classes.push('ff');
1563
+ }
1564
+ if (state.deviceInfo && state.deviceInfo.isIE) {
1565
+ classes.push('ie');
1566
+ }
1567
+ if (state.deviceInfo && state.deviceInfo.isIE11) {
1568
+ classes.push('ie11');
1569
+ }
1570
+ if (state.deviceInfo && state.deviceInfo.isChrome) {
1571
+ classes.push('chrome');
1572
+ }
1573
+ return classes.join(' ');
1574
+ }
1575
+ getBreakpoint(windowWidth) {
1576
+ let bkp = '';
1577
+ switch (true) {
1578
+ case (windowWidth >= 0 && windowWidth < 576):
1579
+ bkp = 'xs';
1580
+ break;
1581
+ case (windowWidth >= 576 && windowWidth < 768):
1582
+ bkp = 'sm';
1583
+ break;
1584
+ case (windowWidth >= 768 && windowWidth < 992):
1585
+ bkp = 'md';
1586
+ break;
1587
+ case (windowWidth >= 992 && windowWidth < 1200):
1588
+ bkp = 'lg';
1589
+ break;
1590
+ case (windowWidth >= 1200 && windowWidth < 1400):
1591
+ bkp = 'xl';
1592
+ break;
1593
+ case (windowWidth >= 1400):
1594
+ bkp = 'xxl';
1595
+ break;
1596
+ }
1597
+ return bkp;
1598
+ }
1599
+ getBreakpoints(bkp) {
1600
+ return {
1601
+ isMobile: (bkp === 'xs' || bkp === 'sm'),
1602
+ isTablet: bkp === 'md',
1603
+ isLtDesktop: (bkp === 'xs' || bkp === 'sm' || bkp === 'md'),
1604
+ isDesktop: bkp === 'lg',
1605
+ isXL: bkp === 'xl',
1606
+ isXXL: bkp === 'xxl',
1607
+ };
1608
+ }
1609
+ getJson(url) {
1610
+ return this.http
1611
+ .get(url)
1612
+ .toPromise()
1613
+ .then(this.extractData)
1614
+ .catch(this.handleError);
1615
+ }
1616
+ extractData(res) {
1617
+ const body = res;
1618
+ return body || {};
1619
+ }
1620
+ handleError(error) {
1621
+ console.error('An error occurred', error);
1622
+ return Promise.reject(error.message || error);
1623
+ }
1624
+ bindActiveLanguageToAppShellState() {
1625
+ this.storeService.select(getActiveLang).subscribe((activeLang) => {
1626
+ if (activeLang !== this.state.activeLanguage) {
1627
+ this.setState({
1628
+ ...this.state,
1629
+ activeLanguage: activeLang,
1630
+ }, false);
1631
+ }
1632
+ });
1633
+ }
1634
+ }
1635
+ /** @nocollapse */ /** @nocollapse */ UxAppShellService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxAppShellService, deps: [{ token: GLOBAL_CONFIG_TOKEN, optional: true }, { token: i1$2.HttpClient }, { token: PLATFORM_ID }, { token: i2$1.Router }, { token: StoreService }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1636
+ /** @nocollapse */ /** @nocollapse */ UxAppShellService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxAppShellService, providedIn: 'root' });
1637
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxAppShellService, decorators: [{
1638
+ type: Injectable,
1639
+ args: [{
1640
+ providedIn: 'root',
1641
+ }]
1642
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1643
+ type: Optional
1644
+ }, {
1645
+ type: Inject,
1646
+ args: [GLOBAL_CONFIG_TOKEN]
1647
+ }] }, { type: i1$2.HttpClient }, { type: Object, decorators: [{
1648
+ type: Inject,
1649
+ args: [PLATFORM_ID]
1650
+ }] }, { type: i2$1.Router }, { type: StoreService }, { type: I18nService, decorators: [{
1651
+ type: Optional
1652
+ }] }]; } });
1653
+
1654
+ class CoreAppEffects {
1655
+ constructor(actions, showConnectionStatus, translateService, asService) {
1656
+ this.actions = actions;
1657
+ this.showConnectionStatus = showConnectionStatus;
1658
+ this.translateService = translateService;
1659
+ this.asService = asService;
1660
+ this.getAppConnectionInformation = merge(fromEvent(window, 'online').pipe(mapTo(true)), fromEvent(window, 'offline').pipe(mapTo(false))).pipe(map(connected => new UpdateAppConnectionAction(connected)));
1661
+ this.activatedRoute = this.actions
1662
+ .pipe(ofType(CoreAppActionTypes.ACTIVATED_ROUTE), map((action) => action.payload), mergeMap(route => {
1663
+ // extract the module name, if defined
1664
+ const module = route.snapshot.data['module'] || 'undefined';
1665
+ return [
1666
+ new UpdateCurrentModuleAction(module),
1667
+ ];
1668
+ }));
1669
+ this.updateAppConnection = this.actions
1670
+ .pipe(ofType(CoreAppActionTypes.UPDATE_APP_CONNECTION), map((action) => action.payload), tap(connected => {
1671
+ // if the user needs to be informed about the connection status
1672
+ if (this.showConnectionStatus) {
1673
+ if (connected) {
1674
+ this.translateService.get('eui.CONNECTED').subscribe((translation) => {
1675
+ this.asService.growl({ severity: 'success', summary: 'MESSAGE', detail: translation }, true, false);
1676
+ });
1677
+ }
1678
+ else {
1679
+ this.translateService.get('eui.NOTCONNECTED').subscribe((translation) => {
1680
+ this.asService.growl({ severity: 'danger', summary: 'ERROR', detail: translation }, true, false);
1681
+ });
1682
+ }
1683
+ }
1684
+ }));
1685
+ }
1686
+ }
1687
+ /** @nocollapse */ /** @nocollapse */ CoreAppEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreAppEffects, deps: [{ token: i1$3.Actions }, { token: SHOW_CONNECTION_STATUS_TOKEN }, { token: i2.TranslateService }, { token: UxAppShellService }], target: i0.ɵɵFactoryTarget.Injectable });
1688
+ /** @nocollapse */ /** @nocollapse */ CoreAppEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreAppEffects });
1689
+ __decorate([
1690
+ Effect(),
1691
+ __metadata("design:type", Observable)
1692
+ ], CoreAppEffects.prototype, "getAppConnectionInformation", void 0);
1693
+ __decorate([
1694
+ Effect(),
1695
+ __metadata("design:type", Observable)
1696
+ ], CoreAppEffects.prototype, "activatedRoute", void 0);
1697
+ __decorate([
1698
+ Effect({ dispatch: false }),
1699
+ __metadata("design:type", Object)
1700
+ ], CoreAppEffects.prototype, "updateAppConnection", void 0);
1701
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreAppEffects, decorators: [{
1702
+ type: Injectable
1703
+ }], ctorParameters: function () { return [{ type: i1$3.Actions }, { type: undefined, decorators: [{
1704
+ type: Inject,
1705
+ args: [SHOW_CONNECTION_STATUS_TOKEN]
1706
+ }] }, { type: i2.TranslateService }, { type: UxAppShellService }]; }, propDecorators: { getAppConnectionInformation: [], activatedRoute: [], updateAppConnection: [] } });
1707
+
1708
+ const CoreModuleEffects = [CoreAppEffects];
1709
+
1710
+ const updateAppVersion = (state, action) => ({ ...state, version: action.payload });
1711
+ const updateAppConnection = (state, action) => ({ ...state, connected: action.payload });
1712
+ const AddAppLoadedConfigModules = (state, action) => ({
1713
+ ...state,
1714
+ loadedConfigModules: {
1715
+ lastAddedModule: action.payload.moduleName,
1716
+ modulesConfig: {
1717
+ ...state.loadedConfigModules.modulesConfig,
1718
+ [action.payload.moduleName]: {
1719
+ ...action.payload.moduleConfig,
1720
+ },
1721
+ },
1722
+ },
1723
+ });
1724
+ const updateAppStatus = (state, action) => ({ ...state, status: action.payload });
1725
+ const updateCurrentModule = (state, action) => {
1726
+ return Object.assign({}, state, { currentModule: action.payload });
1727
+ };
1728
+ const addApiQueueItem = (state, action) => {
1729
+ // apply the timestamp to the queue item
1730
+ const apiQueueItem = Object.assign({}, action.payload.item, { timestamp: new Date().getTime() });
1731
+ // update the queue
1732
+ const apiQueue = Object.assign({}, state.apiQueue, { [action.payload.id]: apiQueueItem });
1733
+ return Object.assign({}, state, { apiQueue });
1734
+ };
1735
+ const removeApiQueueItem = (state, action) => {
1736
+ // remove the specified id from the list of item ids and recreate the apiQueue from the remaining ids
1737
+ const apiQueue = Object.keys(state.apiQueue).filter(id => id !== action.payload).reduce((queue, key) => {
1738
+ queue[key] = state.apiQueue[key];
1739
+ return queue;
1740
+ }, {});
1741
+ return Object.assign({}, state, { apiQueue });
1742
+ };
1743
+ const emptyApiQueue = (state, action) => {
1744
+ // remove all items in the Api Queue
1745
+ return Object.assign({}, state, { apiQueue: {} });
1746
+ };
1747
+ const actionToReducerMap$4 = {
1748
+ [CoreAppActionTypes.UPDATE_APP_VERSION]: updateAppVersion,
1749
+ [CoreAppActionTypes.UPDATE_APP_CONNECTION]: updateAppConnection,
1750
+ [CoreAppActionTypes.ADD_APP_LOADED_CONFIG_MODULES]: AddAppLoadedConfigModules,
1751
+ [CoreAppActionTypes.UPDATE_APP_STATUS]: updateAppStatus,
1752
+ [CoreAppActionTypes.UPDATE_CURRENT_MODULE]: updateCurrentModule,
1753
+ [CoreAppActionTypes.ADD_API_QUEUE_ITEM]: addApiQueueItem,
1754
+ [CoreAppActionTypes.REMOVE_API_QUEUE_ITEM]: removeApiQueueItem,
1755
+ [CoreAppActionTypes.EMPTY_API_QUEUE]: emptyApiQueue,
1756
+ };
1757
+ const coreAppReducers = (state = initialAppState, action) => {
1758
+ if (actionToReducerMap$4[action.type]) {
1759
+ return actionToReducerMap$4[action.type](state, action);
1760
+ }
1761
+ // if the action type is not in the map, call the base reducers method
1762
+ return state;
1763
+ };
1764
+
1765
+ const updateUser = (state, action) => {
1766
+ let fullName = action.payload.fullName;
1767
+ if (!fullName) {
1768
+ fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
1769
+ }
1770
+ return Object.assign({}, state, action.payload, { fullName });
1771
+ };
1772
+ const updateUserDetails = (state, action) => {
1773
+ let fullName = action.payload.fullName;
1774
+ if (!fullName) {
1775
+ fullName = `${action.payload.firstName || ''} ${action.payload.lastName || ''}`.trim();
1776
+ }
1777
+ // todo should be checked if state.details is really there
1778
+ const details = Object.assign({}, state.details, action.payload, { fullName });
1779
+ return Object.assign({}, state, details);
1780
+ };
1781
+ const updateUserPreferences = (state, action) => {
1782
+ const preferences = Object.assign({}, state.preferences, action.payload);
1783
+ return Object.assign({}, state, { preferences });
1784
+ };
1785
+ const updateUserRights = (state, action) => Object.assign({}, state, { rights: [...action.payload] });
1786
+ const updateUserDashboard = (state, action) => {
1787
+ // apply the dashboard to preferences
1788
+ const preferences = Object.assign({}, state.preferences, { dashboard: action.payload });
1789
+ // update the state
1790
+ return { ...state, preferences };
1791
+ };
1792
+ const actionToReducerMap$3 = {
1793
+ [CoreUserActionTypes.UPDATE_USER_DETAILS]: updateUserDetails,
1794
+ [CoreUserActionTypes.UPDATE_USER_PREFERENCES]: updateUserPreferences,
1795
+ [CoreUserActionTypes.UPDATE_USER_STATE]: updateUser,
1796
+ [CoreUserActionTypes.UPDATE_USER_RIGHTS]: updateUserRights,
1797
+ [CoreUserActionTypes.UPDATE_USER_DASHBOARD]: updateUserDashboard,
1798
+ };
1799
+ const coreUserReducers = (state = initialUserState, action) => {
1800
+ if (actionToReducerMap$3[action.type]) {
1801
+ return actionToReducerMap$3[action.type](state, action);
1802
+ }
1803
+ return state;
1804
+ };
1805
+
1806
+ const updateNotificationsList = (state, action) => {
1807
+ return Object.assign({}, state, { list: [...action.payload] });
1808
+ };
1809
+ const actionToReducerMap$2 = {
1810
+ [CoreNotificationsActionTypes.UPDATE_NOTIFICATIONS_LIST]: updateNotificationsList,
1811
+ };
1812
+ const coreNotificationsReducers = (state = initialNotificationsState, action) => {
1813
+ if (actionToReducerMap$2[action.type]) {
1814
+ return actionToReducerMap$2[action.type](state, action);
1815
+ }
1816
+ return state;
1817
+ };
1818
+
1819
+ const updateI18nState = (state, action) => {
1820
+ return {
1821
+ ...state,
1822
+ ...action.payload,
1823
+ };
1824
+ };
1825
+ const actionToReducerMap$1 = {
1826
+ [CoreI18nActionTypes.UPDATE_I18N_STATE]: updateI18nState,
1827
+ };
1828
+ const corI18nReducers = (state = initialI18nState, action) => {
1829
+ if (actionToReducerMap$1[action.type]) {
1830
+ return actionToReducerMap$1[action.type](state, action);
1831
+ }
1832
+ return state;
1833
+ };
1834
+
1835
+ const updateLocaleState = (state, action) => {
1836
+ return {
1837
+ ...state,
1838
+ ...action.payload,
1839
+ };
1840
+ };
1841
+ const actionToReducerMap = {
1842
+ [CoreLocaleActionTypes.UPDATE_LOCALE_STATE]: updateLocaleState,
1843
+ };
1844
+ const coreLocaleReducers = (state = initialLocaleState, action) => {
1845
+ if (actionToReducerMap[action.type]) {
1846
+ return actionToReducerMap[action.type](state, action);
1847
+ }
1848
+ return state;
1849
+ };
1850
+
1851
+ const coreReducers = Object.assign({}, {
1852
+ app: coreAppReducers,
1853
+ user: coreUserReducers,
1854
+ notifications: coreNotificationsReducers,
1855
+ i18n: corI18nReducers,
1856
+ locale: coreLocaleReducers,
1857
+ });
1858
+
1859
+ const extend = extendProxy.default || extendProxy;
1860
+ /**
1861
+ * Utility meta-reducer to load the state from the local storage
1862
+ * @param reducer the action reducer
1863
+ */
1864
+ function localStorageSync(reducer) {
1865
+ return cb(reducer, localStorage);
1866
+ }
1867
+ /**
1868
+ * Utility meta-reducer to load the state from the session storage
1869
+ * @param reducer the action reducer
1870
+ */
1871
+ function sessionStorageSync(reducer) {
1872
+ return cb(reducer, sessionStorage);
1873
+ }
1874
+ // Keys that are allowed to be synced with NgRx state from BrowserStorage
1875
+ const disallowedKeys = ['loadedConfigModules', 'connect', 'currentModule', 'status', 'apiQueue'];
1876
+ /**
1877
+ * filters the AppState by removing those keys from the state and return a new state Object
1878
+ * @param app the AppState
1879
+ */
1880
+ const filterAppState = (app) => {
1881
+ // in case app is undefined or null it should return empty object
1882
+ if (!app) {
1883
+ return {};
1884
+ }
1885
+ return Object.keys(app)
1886
+ // select keys that are present in the allowed list
1887
+ .filter(key => !disallowedKeys.includes(key))
1888
+ // build a new object with only the allowed properties
1889
+ .reduce((obj, key) => {
1890
+ obj[key] = app[key];
1891
+ return obj;
1892
+ }, {});
1893
+ };
1894
+ /**
1895
+ *
1896
+ * @param storageType
1897
+ */
1898
+ const loadState = (storage = localStorage) => {
1899
+ try {
1900
+ // by default falls back to localStorage
1901
+ const serializedState = storage.getItem('state');
1902
+ if (serializedState === null) {
1903
+ return undefined;
1904
+ }
1905
+ // deserialize state
1906
+ let state = JSON.parse(serializedState);
1907
+ // filter AppState and replace
1908
+ state = { ...state, app: filterAppState(state?.app) };
1909
+ return state;
1910
+ }
1911
+ catch (err) {
1912
+ return undefined;
1913
+ }
1914
+ };
1915
+ const cb = (reducer, storage) => {
1916
+ return function (state, action) {
1917
+ if (action.type === CoreAppActionTypes.INIT_STORE) {
1918
+ // This action must be dispatched from an app initializer
1919
+ // We load the state from a storage and compare the version and userId with the provided ones.
1920
+ // If they are the same, we merge the local state into the initial state.
1921
+ // If there is a mismatch, we don't merge the local state, but update only the initial state.
1922
+ // load the state from the localStorage
1923
+ const localState = loadState(storage);
1924
+ // extract the details about user and app version from the action payload
1925
+ const payload = action.payload;
1926
+ const payloadVersion = payload?.version;
1927
+ if (localState) {
1928
+ // TODO: Why all these checks here? What is the purpose of this code?
1929
+ // extract the details about user and app version from the storage state
1930
+ const localVersion = localState?.app?.version;
1931
+ // const localUserId = localState.user && localState.user.userId;
1932
+ const isVersionOK = (!localVersion || !payloadVersion || localVersion === payloadVersion);
1933
+ // const isUserIdOK = (localUserId === payloadUserId);
1934
+ // update the entire state with deep merge of states, if the version and user are the same
1935
+ if (isVersionOK) {
1936
+ state = extend(true, {}, state, localState);
1937
+ }
1938
+ }
1939
+ // update the app version, if defined
1940
+ if (payloadVersion) {
1941
+ state = { ...state, app: { ...state?.app, version: payloadVersion } };
1942
+ }
1943
+ }
1944
+ return reducer(state, action);
1945
+ };
1946
+ };
1947
+
1948
+ class StoreServiceMock extends StoreService {
1949
+ constructor() {
1950
+ super(null, null);
1951
+ }
1952
+ init() {
1953
+ }
1954
+ addAutoSaveHandler() {
1955
+ }
1956
+ handleAutoSave() {
1957
+ }
1958
+ dispatch() {
1959
+ }
1960
+ select() {
1961
+ return of({});
1962
+ }
1963
+ }
1964
+ /** @nocollapse */ /** @nocollapse */ StoreServiceMock.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1965
+ /** @nocollapse */ /** @nocollapse */ StoreServiceMock.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreServiceMock });
1966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: StoreServiceMock, decorators: [{
1967
+ type: Injectable
1968
+ }], ctorParameters: function () { return []; } });
1969
+
1970
+ const CORE_ROOT_GUARD = new InjectionToken('Internal Theme ForRoot Guard');
1971
+ class CoreModule {
1972
+ constructor(guard, parentModule, injector) {
1973
+ // if there is a parentModule, a new instance is created in a lazy loaded module
1974
+ if (parentModule) {
1975
+ // extract the i18n service and the i18n loader config
1976
+ // todo, this thing should be achieved by store, and localization service dependency should be removed
1977
+ const storeService = injector.get(StoreService);
1978
+ const moduleName = injector.get(MODULE_NAME_TOKEN);
1979
+ const moduleConfig = injector.get(MODULE_CONFIG_TOKEN);
1980
+ storeService.dispatch(new AddAppLoadedConfigModulesAction({ moduleName, moduleConfig }));
1981
+ }
1982
+ }
1983
+ /**
1984
+ * No more providing config from forRoot, you have to use EUI_CONFIG_TOKEN to pass config via providers.
1985
+ */
1986
+ static forRoot() {
1987
+ return {
1988
+ ngModule: CoreModule,
1989
+ providers: [
1990
+ {
1991
+ provide: EuiCoreRootGuardClass,
1992
+ useFactory: euiCoreRootGuardClass,
1993
+ deps: [],
1994
+ },
1995
+ {
1996
+ provide: CORE_ROOT_GUARD,
1997
+ useFactory: createEuiCoreRootGuard,
1998
+ deps: [[EuiCoreRootGuardClass, new Optional(), new SkipSelf()]],
1999
+ },
2000
+ ...getCoreProviders(),
2001
+ ],
2002
+ };
2003
+ }
2004
+ static forChild(moduleName) {
2005
+ return {
2006
+ ngModule: CoreModule,
2007
+ providers: getCoreChildProviders(moduleName),
2008
+ };
2009
+ }
2010
+ }
2011
+ /** @nocollapse */ /** @nocollapse */ CoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreModule, deps: [{ token: CORE_ROOT_GUARD, optional: true }, { token: CoreModule, optional: true, skipSelf: true }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule });
2012
+ /** @nocollapse */ /** @nocollapse */ CoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreModule, imports: [HttpClientModule] });
2013
+ /** @nocollapse */ /** @nocollapse */ CoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreModule, imports: [[
2014
+ HttpClientModule,
2015
+ ]] });
2016
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CoreModule, decorators: [{
2017
+ type: NgModule,
2018
+ args: [{
2019
+ imports: [
2020
+ HttpClientModule,
2021
+ ],
2022
+ }]
2023
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2024
+ type: Optional
2025
+ }, {
2026
+ type: Inject,
2027
+ args: [CORE_ROOT_GUARD]
2028
+ }] }, { type: CoreModule, decorators: [{
2029
+ type: Optional
2030
+ }, {
2031
+ type: SkipSelf
2032
+ }] }, { type: i0.Injector }]; } });
2033
+ function createEuiCoreRootGuard(core) {
2034
+ if (core) {
2035
+ throw new TypeError(`CoreModule.forRoot() called twice. Feature modules should use ThemeModule.forChild() instead.`);
2036
+ }
2037
+ return 'guarded';
2038
+ }
2039
+ class EuiCoreRootGuardClass {
2040
+ constructor() {
2041
+ }
2042
+ }
2043
+ function euiCoreRootGuardClass() {
2044
+ return new EuiCoreRootGuardClass();
2045
+ }
2046
+
2047
+ /**
2048
+ * Function to be used before the AppModule is bootstrapped. It is currently used to load dynamic configurations.
2049
+ * It needs to be added in your application main.ts file.
2050
+ * @param envConfig the current environment configuration
2051
+ * @returns the updated environment configuration, as a promise
2052
+ */
2053
+ async function preInitApp(envConfig) {
2054
+ const envDynamicConfig = envConfig && envConfig.envDynamicConfig;
2055
+ if (envDynamicConfig) {
2056
+ // load the local configuration file, if defined
2057
+ const euiAppJsonConfig = await loadEuiDynamicEnvironmentConfig(envDynamicConfig.uri, envDynamicConfig.configTimeout || 2000);
2058
+ envConfig.loadedEnvDynamicConfig = euiAppJsonConfig;
2059
+ return envConfig;
2060
+ }
2061
+ return envConfig;
2062
+ }
2063
+ /**
2064
+ * Function to load asynchronously a dynamic configuration (from a local path or a web service)
2065
+ * @param url the path to the configuration
2066
+ * @param timeout possible timeout
2067
+ * @returns EuiAppJsonConfig promise
2068
+ */
2069
+ async function loadEuiDynamicEnvironmentConfig(url, timeout) {
2070
+ // if the url is specified
2071
+ if (url) {
2072
+ // fetch the config
2073
+ try {
2074
+ return await xhr({
2075
+ url: url,
2076
+ timeout: timeout,
2077
+ });
2078
+ }
2079
+ catch (error) {
2080
+ // send a warning to the console
2081
+ console.warn('Dynamic configuration cannot be loaded from url', url, error);
2082
+ }
2083
+ }
2084
+ // the dynamic config is not loaded
2085
+ return null;
2086
+ }
2087
+
2088
+ const errorCodes = {
2089
+ ERR_GENERIC: 'ERR_GENERIC',
2090
+ };
2091
+ const messages = {
2092
+ ERR_GENERIC: 'An error occured',
2093
+ };
2094
+ class ErrorSubClass {
2095
+ constructor(code, msg, args) {
2096
+ if (!msg && code && code in messages) {
2097
+ if (typeof messages[code] === 'function') {
2098
+ msg = messages[code](...args.messageParams);
2099
+ }
2100
+ else {
2101
+ msg = messages[code];
2102
+ }
2103
+ }
2104
+ this.name = 'ErrorSubClass';
2105
+ this.message = msg;
2106
+ this.code = code;
2107
+ this.stack = (new Error(msg)).stack;
2108
+ if (args) {
2109
+ Object.keys(args).forEach((k) => {
2110
+ if (k !== 'messageParams') {
2111
+ this[k] = args[k];
2112
+ }
2113
+ });
2114
+ }
2115
+ }
2116
+ }
2117
+ // This replaces the "extends" on the Class
2118
+ // ErrorSubClass.prototype = <any>Object.create(Error.prototype);
2119
+ class EuiError extends ErrorSubClass {
2120
+ constructor(code = errorCodes.ERR_GENERIC, msg, args) {
2121
+ super(code, msg, args);
2122
+ this.name = 'EuiError';
2123
+ }
2124
+ }
2125
+
2126
+ class GlobalErrorHandler extends ErrorHandler {
2127
+ constructor(logService) {
2128
+ super();
2129
+ this.logService = logService;
2130
+ }
2131
+ handleError(error) {
2132
+ // log error
2133
+ this.logService.error(error.message || error.toString());
2134
+ // throw error;
2135
+ super.handleError(error);
2136
+ }
2137
+ }
2138
+ /** @nocollapse */ /** @nocollapse */ GlobalErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
2139
+ /** @nocollapse */ /** @nocollapse */ GlobalErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: GlobalErrorHandler, providedIn: 'root' });
2140
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: GlobalErrorHandler, decorators: [{
2141
+ type: Injectable,
2142
+ args: [{
2143
+ providedIn: 'root',
2144
+ }]
2145
+ }], ctorParameters: function () { return [{ type: LogService }]; } });
2146
+
2147
+ class HttpErrorHandlerInterceptor {
2148
+ constructor(config = DEFAULT_HTTP_ERROR_HANDLER_CONFIG, injector, router) {
2149
+ this.config = config;
2150
+ this.injector = injector;
2151
+ this.router = router;
2152
+ }
2153
+ intercept(req, next) {
2154
+ return next.handle(req)
2155
+ .pipe(tap(() => {
2156
+ }, (error) => {
2157
+ // in case of http error
2158
+ if (error instanceof HttpErrorResponse) {
2159
+ const routeConfig = this.getRouteConfig(error);
2160
+ const rule = routeConfig && (routeConfig[error.status] || routeConfig.default);
2161
+ if (typeof rule === 'string') {
2162
+ // perform a redirect
2163
+ this.router.navigate([rule]);
2164
+ }
2165
+ else if (typeof rule === 'function') {
2166
+ // callback function
2167
+ rule.call(null, error, this.injector);
2168
+ }
2169
+ }
2170
+ }));
2171
+ }
2172
+ /**
2173
+ * Search in the configuration for the first matching route
2174
+ * @param error http error response
2175
+ * @returns HttpErrorRouteConfig or null
2176
+ */
2177
+ getRouteConfig(error) {
2178
+ // filter the routes
2179
+ const routes = this.config.routes.filter((route) => {
2180
+ const regex = new RegExp('^' + route.path.split('*').join('.*') + '$');
2181
+ return regex.test(error.url) && (typeof route[error.status] !== 'undefined' || typeof route.default !== 'undefined');
2182
+ });
2183
+ // return the first matching route, if any
2184
+ return routes.length > 0 ? routes[0] : null;
2185
+ }
2186
+ }
2187
+ /** @nocollapse */ /** @nocollapse */ HttpErrorHandlerInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: HttpErrorHandlerInterceptor, deps: [{ token: HTTP_ERROR_HANDLER_CONFIG_TOKEN }, { token: i0.Injector }, { token: i2$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2188
+ /** @nocollapse */ /** @nocollapse */ HttpErrorHandlerInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: HttpErrorHandlerInterceptor });
2189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: HttpErrorHandlerInterceptor, decorators: [{
2190
+ type: Injectable
2191
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2192
+ type: Inject,
2193
+ args: [HTTP_ERROR_HANDLER_CONFIG_TOKEN]
2194
+ }] }, { type: i0.Injector }, { type: i2$1.Router }]; } });
2195
+
2196
+ function AlertHttpErrorCallbackFn(error) {
2197
+ alert(error.statusText);
2198
+ }
2199
+ function ConsoleHttpErrorCallbackFn(error) {
2200
+ console.error('HttpError', error);
2201
+ }
2202
+ function LogHttpErrorCallbackFn(error, injector) {
2203
+ const logService = injector.get(LogService);
2204
+ logService.error('HttpError', error);
2205
+ }
2206
+ function GrowlHttpErrorCallbackFn(error, injector) {
2207
+ const asService = injector.get(UxAppShellService);
2208
+ asService.growlError(error.statusText);
2209
+ }
2210
+
2211
+ class ApiQueueService {
2212
+ constructor(store, http, logService) {
2213
+ this.store = store;
2214
+ this.http = http;
2215
+ this.logService = logService;
2216
+ }
2217
+ /**
2218
+ * Adds an item in the queue by dispatching an action to the store.
2219
+ * @param id - The id of the item inside the queue.
2220
+ * WARNING if matches any other queue item id will overwrite it.
2221
+ * @param item - an item for Queue
2222
+ */
2223
+ addQueueItem(id, item) {
2224
+ const allowedMethods = ['post', 'put', 'get'];
2225
+ if (allowedMethods.indexOf(item.method) < 0) {
2226
+ throw new Error(`[ApiQueue] method "${item.method}" is not allowed`);
2227
+ }
2228
+ this.store.dispatch(new AddApiQueueItemAction({ id, item }));
2229
+ }
2230
+ /**
2231
+ * Subscribes to the store to retrieve queue and then converts the queue object to an array of items.
2232
+ * @return An Observable of array of all items inside the current queue (ApiQueueItem[])
2233
+ */
2234
+ getQueue() {
2235
+ return this.store.select(getApiQueue)
2236
+ .pipe(take(1), map((queue) => {
2237
+ const queueArray = queue && Object.values(queue);
2238
+ if (!queueArray || queueArray.length < 1) {
2239
+ this.logService.warn('No items in the queue exist.');
2240
+ }
2241
+ return queueArray;
2242
+ }));
2243
+ }
2244
+ /**
2245
+ * Subscribes to the store to retrieve an item from the queue.
2246
+ * @param id - id of the item inside the queue
2247
+ * @return An Observable of ApiQueueItem type
2248
+ */
2249
+ getQueueItem(id) {
2250
+ return this.store.select(getApiQueueItem(id))
2251
+ .pipe(take(1), map((queue) => {
2252
+ if (!queue) {
2253
+ this.logService.warn(`Queue item with id "${id}" does not exist`);
2254
+ return null;
2255
+ }
2256
+ return queue;
2257
+ }));
2258
+ }
2259
+ /**
2260
+ * Removes a given item from the queue.
2261
+ * @param id - id of the item inside the queue
2262
+ */
2263
+ removeQueueItem(id) {
2264
+ this.store.dispatch(new RemoveApiQueueItemAction(id));
2265
+ }
2266
+ /**
2267
+ * Removes all items placed in the queue.
2268
+ */
2269
+ removeAllQueueItem() {
2270
+ this.store.dispatch(new EmptyApiQueueAction(null));
2271
+ }
2272
+ /**
2273
+ * Process an item from the queue.
2274
+ * @param id - id of the item inside the queue
2275
+ * @return An Observable of type any
2276
+ */
2277
+ processQueueItem(id) {
2278
+ return this.store.select(getApiQueueItem(id))
2279
+ .pipe(take(1), switchMap((queue) => {
2280
+ if (!queue) {
2281
+ this.logService.warn(`Queue item with id "${id}" does not exist`);
2282
+ // tslint:disable-next-line:deprecation
2283
+ return of(null);
2284
+ }
2285
+ return this.buildHttpRequest(id, queue);
2286
+ }));
2287
+ }
2288
+ /**
2289
+ * Process all the items inside the queue.
2290
+ * @param [continueOnError=true] - in case of an item request fails continue with the rest in queue
2291
+ * @return An Observable with an array which contains all responses from all items in queue.
2292
+ */
2293
+ processAllQueueItems(continueOnError = true) {
2294
+ return this.store.select(getApiQueue)
2295
+ .pipe(map((queue) => Object.entries(queue)
2296
+ .map(([key, value]) => this.buildHttpRequest(key, value).pipe(catchError((error) => {
2297
+ this.logService.error(`Queue Item with id ${key} failed.`, error.message, error.stack);
2298
+ if (!continueOnError) {
2299
+ throw error;
2300
+ }
2301
+ // tslint:disable-next-line:deprecation
2302
+ return of(error);
2303
+ })))), switchMap((obsQueue) => forkJoin(Array.from(obsQueue))));
2304
+ }
2305
+ /**
2306
+ * Process all items in queue after it order them based on their timestamp. Beware that order
2307
+ * matter in execution of Http Request in queue. When a request completes only then next will begin. Emission
2308
+ * or Http response follows order.
2309
+ * @param [ascending=true] - sets the order of queue items based on timestamp
2310
+ */
2311
+ processAllQueueItemsSequential(ascending = true) {
2312
+ return this.store.select(getApiQueue).pipe(concatMap((queue) => Object.entries(queue)
2313
+ .sort((a, b) => ascending ? this.sortOnTimestamp(a, b) : this.sortOnTimestamp(b, a))
2314
+ .map(([id, item]) => this.buildHttpRequest(id, item))));
2315
+ }
2316
+ /**
2317
+ * Short dates ascending based on input
2318
+ * @param a - Date one
2319
+ * @param b - Date two
2320
+ *
2321
+ * @beta
2322
+ */
2323
+ sortOnTimestamp(a, b) {
2324
+ return +new Date(a[1].timestamp) - +new Date(b[1].timestamp);
2325
+ }
2326
+ /**
2327
+ * build and HttpRequest Observable based on the given queue.
2328
+ * After successful request completion removes the item from the queue.
2329
+ * @param id - id of the item inside the queue
2330
+ * @param item - the item of the queue that matches the id.
2331
+ * @return An Observable of HttpClient Request
2332
+ */
2333
+ buildHttpRequest(id, item) {
2334
+ return this.http[item.method.toLowerCase()](item.uri, item.payload)
2335
+ .pipe(tap(() => this.removeQueueItem(id)));
2336
+ }
2337
+ }
2338
+ /** @nocollapse */ /** @nocollapse */ ApiQueueService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: ApiQueueService, deps: [{ token: StoreService }, { token: i1$2.HttpClient }, { token: LogService }], target: i0.ɵɵFactoryTarget.Injectable });
2339
+ /** @nocollapse */ /** @nocollapse */ ApiQueueService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: ApiQueueService, providedIn: 'root' });
2340
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: ApiQueueService, decorators: [{
2341
+ type: Injectable,
2342
+ args: [{
2343
+ providedIn: 'root',
2344
+ }]
2345
+ }], ctorParameters: function () { return [{ type: StoreService }, { type: i1$2.HttpClient }, { type: LogService }]; } });
2346
+
2347
+ class ApiQueueServiceMock extends ApiQueueService {
2348
+ constructor() {
2349
+ super(null, null, null);
2350
+ }
2351
+ getQueue() {
2352
+ // tslint:disable-next-line:deprecation
2353
+ return of([]);
2354
+ }
2355
+ getQueueItem(id) {
2356
+ // tslint:disable-next-line:deprecation
2357
+ return of(null);
2358
+ }
2359
+ removeAllQueueItem() { }
2360
+ processAllQueueItems() {
2361
+ // tslint:disable-next-line:deprecation
2362
+ return of({});
2363
+ }
2364
+ addQueueItem() { }
2365
+ removeQueueItem() { }
2366
+ processQueueItem() {
2367
+ // tslint:disable-next-line:deprecation
2368
+ return of({});
2369
+ }
2370
+ }
2371
+
2372
+ const diffDays = (dateStart, dateEnd) => {
2373
+ return Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
2374
+ };
2375
+ const diffDaysFromToday = (date) => {
2376
+ return diffDays(new Date(), date);
2377
+ };
2378
+
2379
+ /**
2380
+ * Provides read-only equivalent of jQuery's position function:
2381
+ * http://api.jquery.com/position/
2382
+ */
2383
+ const position = (nativeEl) => {
2384
+ let elBCR = offset(nativeEl);
2385
+ let offsetParentBCR = { top: 0, left: 0 };
2386
+ let offsetParentEl = parentOffsetEl(nativeEl);
2387
+ if (offsetParentEl !== document) {
2388
+ offsetParentBCR = offset(offsetParentEl);
2389
+ offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
2390
+ offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
2391
+ }
2392
+ let boundingClientRect = nativeEl.getBoundingClientRect();
2393
+ return {
2394
+ width: boundingClientRect.width || nativeEl.offsetWidth,
2395
+ height: boundingClientRect.height || nativeEl.offsetHeight,
2396
+ top: elBCR.top - offsetParentBCR.top,
2397
+ left: elBCR.left - offsetParentBCR.left
2398
+ };
2399
+ };
2400
+ /**
2401
+ * Provides read-only equivalent of jQuery's offset function:
2402
+ * http://api.jquery.com/offset/
2403
+ */
2404
+ const offset = (nativeEl) => {
2405
+ let boundingClientRect = nativeEl.getBoundingClientRect();
2406
+ return {
2407
+ width: boundingClientRect.width || nativeEl.offsetWidth,
2408
+ height: boundingClientRect.height || nativeEl.offsetHeight,
2409
+ top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
2410
+ left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft)
2411
+ };
2412
+ };
2413
+ // PRIVATE FUNCTIONS
2414
+ const getStyle = (nativeEl, cssProp) => {
2415
+ // IE
2416
+ if (nativeEl.currentStyle) {
2417
+ return nativeEl.currentStyle[cssProp];
2418
+ }
2419
+ if (window.getComputedStyle) {
2420
+ return window.getComputedStyle(nativeEl)[cssProp];
2421
+ }
2422
+ // finally try and get inline style
2423
+ return nativeEl.style[cssProp];
2424
+ };
2425
+ /**
2426
+ * Checks if a given element is statically positioned
2427
+ */
2428
+ const isStaticPositioned = (nativeEl) => {
2429
+ return (getStyle(nativeEl, 'position') || 'static') === 'static';
2430
+ };
2431
+ /**
2432
+ * returns the closest, non-statically positioned parentOffset of a given element
2433
+ * @param nativeEl
2434
+ */
2435
+ const parentOffsetEl = (nativeEl) => {
2436
+ let offsetParent = nativeEl.offsetParent || document;
2437
+ while (offsetParent && offsetParent !== document &&
2438
+ isStaticPositioned(offsetParent)) {
2439
+ offsetParent = offsetParent.offsetParent;
2440
+ }
2441
+ return offsetParent || document;
2442
+ };
2443
+ const getViewElement = (fixture, componentClass, klass) => {
2444
+ let de, el, domElement;
2445
+ de = fixture.debugElement.query(By.css(componentClass));
2446
+ if (de) {
2447
+ el = de.nativeElement;
2448
+ if (el && klass) {
2449
+ domElement = el.querySelectorAll(klass);
2450
+ if (domElement.length <= 1) {
2451
+ domElement = el.querySelector(klass);
2452
+ }
2453
+ }
2454
+ }
2455
+ return { de, el, domElement };
2456
+ };
2457
+ const closestMatchingParent = (target, className) => {
2458
+ let element = target;
2459
+ while (element && element.nodeType === Node.ELEMENT_NODE) {
2460
+ if (element.classList.contains(className)) {
2461
+ return element;
2462
+ }
2463
+ element = element.parentElement;
2464
+ }
2465
+ return null;
2466
+ };
2467
+
2468
+ const consumeEvent = (event) => {
2469
+ if (event) {
2470
+ event.preventDefault();
2471
+ event.stopPropagation();
2472
+ event.cancelBubble = true;
2473
+ }
2474
+ return false;
2475
+ };
2476
+
2477
+ const forOwn = (object, iteratee) => {
2478
+ object = Object(object);
2479
+ Object.keys(object).forEach((key) => iteratee(object[key], key, object));
2480
+ };
2481
+ const markFormGroupTouched = (FormControls) => {
2482
+ const markFormGroupTouchedRecursive = (controls) => {
2483
+ forOwn(controls, (c, controlKey) => {
2484
+ if (c instanceof FormGroup || c instanceof FormArray) {
2485
+ markFormGroupTouchedRecursive(c.controls);
2486
+ }
2487
+ else {
2488
+ c.markAsTouched();
2489
+ c.updateValueAndValidity();
2490
+ }
2491
+ });
2492
+ };
2493
+ markFormGroupTouchedRecursive(FormControls);
2494
+ };
2495
+ const markControlsTouched = (group) => {
2496
+ Object.keys(group.controls).forEach((key) => {
2497
+ const abstractControl = group.controls[key];
2498
+ if (abstractControl instanceof FormGroup || abstractControl instanceof FormArray) {
2499
+ markControlsTouched(abstractControl);
2500
+ }
2501
+ else {
2502
+ abstractControl.markAsTouched();
2503
+ }
2504
+ });
2505
+ };
2506
+ const validateEmail = (c) => {
2507
+ /* tslint:disable */
2508
+ let EMAIL_REGEXP = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2509
+ /* tslint:enable */
2510
+ return EMAIL_REGEXP.test(c.value) ? null : {
2511
+ validateEmail: {
2512
+ valid: false
2513
+ }
2514
+ };
2515
+ };
2516
+
2517
+ /**
2518
+ * returns a random string with radix=36
2519
+ */
2520
+ const uniqueId = () => {
2521
+ return Math.random().toString(36).substr(2, 9);
2522
+ };
2523
+ /**
2524
+ * Its job is to parse number and format it based on given input.
2525
+ * @param value can be a number or a string number
2526
+ * @param fractionSize size of fraction of a number e.g. 1000.88 fraction is 2 (88) default is 2
2527
+ * @param inDecimalSeparator separator for decimal part of the number default is ','
2528
+ * @param inThousandSeparator separator for the whole part of the number default is ''
2529
+ */
2530
+ const formatNumber = (value, fractionSize = 2, inDecimalSeparator = ',', inThousandSeparator = '') => {
2531
+ if (inDecimalSeparator || inThousandSeparator) {
2532
+ console.warn('The inDecimalSeparator and inThousandSeparator are deprecated. They will be a ' +
2533
+ 'BREAKING CHANGE for eUI 9 and be replaced by localization strategy.');
2534
+ }
2535
+ let decimalSeparator = '';
2536
+ let thousandsSeparator = '';
2537
+ if (value === null || value === undefined) {
2538
+ return null;
2539
+ }
2540
+ if (typeof value === 'string') {
2541
+ // get all non characters
2542
+ let nonChars = value.match(/[^0-9]+/g) || [];
2543
+ // get all unique chars
2544
+ let uniqueChars = nonChars
2545
+ .reduce((acc, e) => acc.set(e, (acc.get(e) || 0) + 1), new Map());
2546
+ // get separators
2547
+ let separators = Array.from(uniqueChars.keys());
2548
+ // sense where decimal separator and where thousand separator is
2549
+ if (separators.length > 1) {
2550
+ // left detected separator will be thousand and second will be decimal
2551
+ thousandsSeparator = separators[0];
2552
+ decimalSeparator = separators[1];
2553
+ }
2554
+ else if (separators.length > 0) {
2555
+ // in case there is only one separator you don't know exactly who this separator is.
2556
+ // in case there are more than two occurrences means we have a thousand otherwise we'll
2557
+ // agree by conventions that is decimal
2558
+ if (nonChars.length > 1) {
2559
+ return value
2560
+ .split(separators[0])
2561
+ .join('')
2562
+ .replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2563
+ }
2564
+ else {
2565
+ return value.replace(separators[0], inDecimalSeparator)
2566
+ .replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2567
+ }
2568
+ }
2569
+ else {
2570
+ // in case there are no separators then only format based on thousand one
2571
+ return value.replace(/\B(?=(\d{3})+(?!\d))/g, inThousandSeparator);
2572
+ }
2573
+ // do the replacement of separators and parseInt
2574
+ // Beware! Always replace thousand separator first and then decimal
2575
+ value = value.split(thousandsSeparator).join('')
2576
+ .replace(decimalSeparator, '.');
2577
+ }
2578
+ decimalSeparator = inDecimalSeparator;
2579
+ thousandsSeparator = inThousandSeparator;
2580
+ const maxFraction = '0'.repeat(fractionSize);
2581
+ let [integer, fraction = maxFraction] = (value || '0').toString().split('.');
2582
+ fraction = fractionSize > 0 ? (fraction + maxFraction).substring(0, fractionSize) : '';
2583
+ // this rule makes sense only in number in case fraction is all zero
2584
+ fraction = (typeof value === 'number' && fraction === maxFraction) ? '' : decimalSeparator + fraction;
2585
+ return integer.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator) + fraction;
2586
+ };
2587
+
2588
+ const handleError = (error) => {
2589
+ let errMsg = (error.message) ? error.message :
2590
+ error.status ? `${error.status} - ${error.statusText}` : 'Server error';
2591
+ // console.error(errMsg);
2592
+ return throwError(errMsg);
2593
+ };
2594
+
2595
+ /**
2596
+ * check if a value is null or undefined. If it's not both returns true otherwise false
2597
+ * @param value
2598
+ */
2599
+ function isDefined(value) {
2600
+ return value !== undefined && value !== null;
2601
+ }
2602
+
2603
+ class EuiPermissionService extends EuiService {
2604
+ constructor(log, store) {
2605
+ super([]);
2606
+ this.log = log;
2607
+ this.store = store;
2608
+ if (log) {
2609
+ this.logger = log.getLogger('core.PermissionService');
2610
+ }
2611
+ }
2612
+ /**
2613
+ * initialize the service by providing a state
2614
+ * @param rights
2615
+ */
2616
+ init(rights) {
2617
+ super.initEuiService();
2618
+ if (Array.isArray(rights)) {
2619
+ this.updateState(rights);
2620
+ return of({ success: true });
2621
+ }
2622
+ if (this.logger) {
2623
+ this.logger.error('Init object should be instance of BaseUserState');
2624
+ }
2625
+ return of({ success: false, error: 'Init object should be instance of BaseUserState' });
2626
+ }
2627
+ get userRights() {
2628
+ return this.stateInstance;
2629
+ }
2630
+ /**
2631
+ * get the user's Rights from the state
2632
+ */
2633
+ getState() {
2634
+ return this.store.select(getUserRights);
2635
+ }
2636
+ /**
2637
+ * update the state with the given user's rights
2638
+ * @param rights
2639
+ */
2640
+ updateState(rights) {
2641
+ this.store.dispatch(new UpdateUserRightsAction(rights || []));
2642
+ }
2643
+ /**
2644
+ * accepts a string of right and or a permission. In string first comes the right and or followed by permission in
2645
+ * a dot separated way e.g. 'RIGHT.PERMISSION' or 'RIGHT'. The string can contain more that 2 separated fields.
2646
+ * In that case the last field should be the permission and all the others a Right. e.g. 'RIGHT1.RIGHT2.PERMISSION'
2647
+ * The last part is useful where you want a user to have multiple rights and the permission of the last right.
2648
+ * @param rightsAndPermission
2649
+ */
2650
+ checkAttributePermission(rightsAndPermission) {
2651
+ const permProps = rightsAndPermission.split('.');
2652
+ const rightId = permProps[0];
2653
+ const hasRight = this.checkRight(rightId);
2654
+ if (hasRight) {
2655
+ if (permProps.length === 2) {
2656
+ // in case of 'RIGHT.PERMISSION'
2657
+ const permission = permProps[1];
2658
+ return this.checkPermission(rightId, permission);
2659
+ }
2660
+ else if (permProps.length > 2) {
2661
+ // in case of 'RIGHT1.RIGHT2.....PERMISSION' string call recursively
2662
+ return this.checkAttributePermission(rightsAndPermission.slice(rightId.length + 1));
2663
+ }
2664
+ }
2665
+ return hasRight;
2666
+ }
2667
+ /**
2668
+ * check if a user has the right.
2669
+ * @param rightId the id of Right
2670
+ */
2671
+ checkRight(rightId) {
2672
+ return this.userRights.some(right => right && right.id === rightId);
2673
+ }
2674
+ /**
2675
+ * check if a user has that right and that right has the permission given.
2676
+ * @param rightId the right of the user
2677
+ * @param permission the permission of the right
2678
+ */
2679
+ checkPermission(rightId, permission) {
2680
+ // the user has to have that right and that right has to have the given permission
2681
+ return this.userRights.some(right => right &&
2682
+ right.id === rightId &&
2683
+ right.permissions &&
2684
+ right.permissions.includes(permission));
2685
+ }
2686
+ /**
2687
+ * checks whether a user have all rights passed as an argument
2688
+ * @param rights an array of UxUserRight
2689
+ */
2690
+ haveAllRights(rights) {
2691
+ if (!isDefined(rights)) {
2692
+ throw Error(`The rights should be an array but instead it's not defined!`);
2693
+ }
2694
+ return rights.every((right) => this.userRights.find((uRight) => uRight.id === right.id));
2695
+ }
2696
+ }
2697
+ /** @nocollapse */ /** @nocollapse */ EuiPermissionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuiPermissionService, deps: [{ token: LogService, optional: true }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable });
2698
+ /** @nocollapse */ /** @nocollapse */ EuiPermissionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuiPermissionService, providedIn: 'root' });
2699
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuiPermissionService, decorators: [{
2700
+ type: Injectable,
2701
+ args: [{
2702
+ providedIn: 'root',
2703
+ }]
2704
+ }], ctorParameters: function () { return [{ type: LogService, decorators: [{
2705
+ type: Optional
2706
+ }] }, { type: StoreService }]; } });
2707
+
2708
+ class UxDynamicMenuService {
2709
+ // TODO: it should be moved euiservice, or it should be static
2710
+ // TODO: can we moved that service inside the module of the component that's using it?
2711
+ constructor(uxPermission, store) {
2712
+ this.uxPermission = uxPermission;
2713
+ this.store = store;
2714
+ this.menuLinks = [];
2715
+ this.store.select(getUserState).subscribe((user) => {
2716
+ if (user.menuLinks) {
2717
+ this.menuLinks = user.menuLinks;
2718
+ }
2719
+ });
2720
+ }
2721
+ getMenuLinks() {
2722
+ return this.menuLinks;
2723
+ }
2724
+ filterUxLinksWithRights(links) {
2725
+ return links.filter((link) => {
2726
+ if (link.hasChildren) {
2727
+ link.children = this.filterUxLinksWithRights(link.children);
2728
+ }
2729
+ // First check if the user is denied access:
2730
+ if (link.deniedRightId) {
2731
+ if (this.uxPermission.checkRight(link.deniedRightId)) {
2732
+ return false;
2733
+ }
2734
+ }
2735
+ if (link.deniedRightIds) {
2736
+ for (const deniedRightId of link.deniedRightIds) {
2737
+ if (this.uxPermission.checkRight(deniedRightId)) {
2738
+ return false;
2739
+ }
2740
+ }
2741
+ }
2742
+ // Then check if the user needs to be allowed access explicitly:
2743
+ if (link.allowedRightId) {
2744
+ return this.uxPermission.checkRight(link.allowedRightId);
2745
+ }
2746
+ if (link.allowedRightIds) {
2747
+ for (const allowedRightId of link.allowedRightIds) {
2748
+ if (this.uxPermission.checkRight(allowedRightId)) {
2749
+ return true;
2750
+ }
2751
+ }
2752
+ // User doesn't have one of the allowed rights. Deny access:
2753
+ return false;
2754
+ }
2755
+ // Access to the menu item is not denied, therefore allow it:
2756
+ return true;
2757
+ });
2758
+ }
2759
+ }
2760
+ /** @nocollapse */ /** @nocollapse */ UxDynamicMenuService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicMenuService, deps: [{ token: EuiPermissionService }, { token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable });
2761
+ /** @nocollapse */ /** @nocollapse */ UxDynamicMenuService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicMenuService, providedIn: 'root' });
2762
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicMenuService, decorators: [{
2763
+ type: Injectable,
2764
+ args: [{
2765
+ providedIn: 'root',
2766
+ }]
2767
+ }], ctorParameters: function () { return [{ type: EuiPermissionService }, { type: StoreService }]; } });
2768
+
2769
+ function withUxErrorManager(errorManager) {
2770
+ return function (source$) {
2771
+ return new Observable(observer => {
2772
+ const wrapper = {
2773
+ next: value => {
2774
+ errorManager.clearError();
2775
+ observer.next(value);
2776
+ },
2777
+ error: (err) => {
2778
+ errorManager.publishError(err);
2779
+ },
2780
+ };
2781
+ return source$.subscribe(wrapper);
2782
+ });
2783
+ };
2784
+ }
2785
+
2786
+ class UxErrorFeedbackService {
2787
+ constructor(asService, translateService) {
2788
+ this.asService = asService;
2789
+ this.translateService = translateService;
2790
+ this.errors = new Subject();
2791
+ }
2792
+ /**
2793
+ * Publishes errors to targeted components
2794
+ */
2795
+ publishError(err, instanceId, groupId, accumulate) {
2796
+ if (instanceId) {
2797
+ this.errors.next(new UxPublishErrorFeedbackEvent(err.uxHttpErrorOutput, instanceId, groupId, accumulate));
2798
+ }
2799
+ else {
2800
+ this.errors.next(new UxPublishErrorFeedbackEvent(err.uxHttpErrorOutput, undefined, groupId, accumulate));
2801
+ }
2802
+ }
2803
+ /**
2804
+ * Growl errors
2805
+ */
2806
+ growlError(err) {
2807
+ const feedBacks = err.uxHttpErrorOutput.getFeedBacks();
2808
+ const isGrowlSticky = false;
2809
+ const isGrowlMultiple = true;
2810
+ const growlLife = 10000;
2811
+ const position = 'bottom-right';
2812
+ feedBacks.forEach((feedback) => this.translateService.get(feedback.msgId).pipe(take(1)).subscribe((translate) => {
2813
+ this.asService.growl({
2814
+ severity: feedback.severity || 'danger',
2815
+ summary: 'ERROR',
2816
+ detail: translate,
2817
+ }, isGrowlSticky, isGrowlMultiple, growlLife, position);
2818
+ }));
2819
+ }
2820
+ clearError(id, groupId) {
2821
+ this.errors.next(new UxClearErrorFeedbackEvent(id, groupId));
2822
+ }
2823
+ createLocalErrorManager() {
2824
+ return new UxErrorManager(this);
2825
+ }
2826
+ createGlobalErrorManager() {
2827
+ return new UxErrorManager(this, true);
2828
+ }
2829
+ }
2830
+ /** @nocollapse */ /** @nocollapse */ UxErrorFeedbackService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxErrorFeedbackService, deps: [{ token: UxAppShellService }, { token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
2831
+ /** @nocollapse */ /** @nocollapse */ UxErrorFeedbackService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxErrorFeedbackService, providedIn: 'root' });
2832
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxErrorFeedbackService, decorators: [{
2833
+ type: Injectable,
2834
+ args: [{
2835
+ providedIn: 'root'
2836
+ }]
2837
+ }], ctorParameters: function () { return [{ type: UxAppShellService }, { type: i2.TranslateService }]; } });
2838
+ class UxErrorManager {
2839
+ constructor(uxErrorFeedbackService, isGlobal) {
2840
+ this.uxErrorFeedbackService = uxErrorFeedbackService;
2841
+ this.isGlobal = isGlobal;
2842
+ this.httpErrorOperator = withUxErrorManager(this);
2843
+ this.id = Math.random().toString();
2844
+ }
2845
+ publishError(err, groupId, accumulate) {
2846
+ if (!this.isGlobal) {
2847
+ this.uxErrorFeedbackService.publishError(err, this.id, groupId, accumulate);
2848
+ }
2849
+ else {
2850
+ this.uxErrorFeedbackService.publishError(err, undefined, groupId, accumulate);
2851
+ }
2852
+ }
2853
+ clearError(groupId) {
2854
+ if (!this.isGlobal) {
2855
+ this.uxErrorFeedbackService.clearError(this.id, groupId);
2856
+ }
2857
+ else {
2858
+ this.uxErrorFeedbackService.clearError(undefined, groupId);
2859
+ }
2860
+ }
2861
+ growlError(err) {
2862
+ this.uxErrorFeedbackService.growlError(err);
2863
+ }
2864
+ errors() {
2865
+ if (!this.isGlobal) {
2866
+ return this.uxErrorFeedbackService.errors.pipe(filter((evt) => evt.id === this.id));
2867
+ }
2868
+ else {
2869
+ return this.uxErrorFeedbackService.errors.pipe(filter((evt) => !evt.id));
2870
+ }
2871
+ }
2872
+ }
2873
+
2874
+ const DYNAMIC_COMPONENT_CONFIG = new InjectionToken('DYNAMIC_COMPONENT_CONFIG');
2875
+ class UxDynamicComponentService {
2876
+ constructor(componentFactoryResolver, injector, appRef) {
2877
+ this.componentFactoryResolver = componentFactoryResolver;
2878
+ this.injector = injector;
2879
+ this.appRef = appRef;
2880
+ }
2881
+ /**
2882
+ * Adds a component to portal host dynamically
2883
+ * @param component The component to be injected
2884
+ * @param el The element reference for the component to be injected
2885
+ * @param config The data to be passed (config) for the DYNAMIC_COMPONENT_CONFIG token
2886
+ */
2887
+ add(component, el, config) {
2888
+ // Create a portalHost from a DOM element
2889
+ this.portalHost = new DomPortalOutlet(el ? el.nativeElement : document.body, this.componentFactoryResolver, this.appRef, this.injector);
2890
+ // Locate the component factory for the ComponentToIncludeDynamicallyComponent
2891
+ this.portal = new ComponentPortal(component, null, config ? this.createInjector(config) : null);
2892
+ // Attach portal to host
2893
+ this.portalComponentInstance = this.portalHost.attach(this.portal);
2894
+ if (config) {
2895
+ Object.assign(config, {
2896
+ portalHostRef: this.portalHost,
2897
+ portalRef: this.portal,
2898
+ portalComponentInstanceRef: this.portalComponentInstance,
2899
+ });
2900
+ }
2901
+ return {
2902
+ portalHost: this.portalHost,
2903
+ portal: this.portal,
2904
+ portalComponentInstance: this.portalComponentInstance
2905
+ };
2906
+ }
2907
+ /**
2908
+ * detaches a portalHost
2909
+ * @param portalHostRef reference of portal host to be detached
2910
+ */
2911
+ remove(portalHostRef) {
2912
+ portalHostRef.detach();
2913
+ this.portalHost = null;
2914
+ this.portal = null;
2915
+ this.portalComponentInstance = null;
2916
+ }
2917
+ /**
2918
+ * creates an Custom injector to be used when providing custom injection tokens to components inside a portal
2919
+ * @param data to be used by DYNAMIC_COMPONENT_CONFIG token
2920
+ */
2921
+ createInjector(data) {
2922
+ const injectorTokens = new WeakMap();
2923
+ injectorTokens.set(DYNAMIC_COMPONENT_CONFIG, data);
2924
+ return new PortalInjector(this.injector, injectorTokens);
2925
+ }
2926
+ }
2927
+ /** @nocollapse */ /** @nocollapse */ UxDynamicComponentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicComponentService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable });
2928
+ /** @nocollapse */ /** @nocollapse */ UxDynamicComponentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicComponentService, providedIn: 'root' });
2929
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxDynamicComponentService, decorators: [{
2930
+ type: Injectable,
2931
+ args: [{ providedIn: 'root' }]
2932
+ }], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ApplicationRef }]; } });
2933
+
2934
+ const UX_COUNTRIES = {
2935
+ AF: 'Afghanistan',
2936
+ AX: 'Aland Islands',
2937
+ AL: 'Albania',
2938
+ DZ: 'Algeria',
2939
+ AS: 'American Samoa',
2940
+ AD: 'Andorra',
2941
+ AO: 'Angola',
2942
+ AI: 'Anguilla',
2943
+ AQ: 'Antarctica',
2944
+ AG: 'Antigua and Barbuda',
2945
+ AR: 'Argentina',
2946
+ AM: 'Armenia',
2947
+ AW: 'Aruba',
2948
+ AU: 'Australia',
2949
+ AT: 'Austria',
2950
+ AZ: 'Azerbaijan',
2951
+ BS: 'Bahamas',
2952
+ BH: 'Bahrain',
2953
+ BD: 'Bangladesh',
2954
+ BB: 'Barbados',
2955
+ BY: 'Belarus',
2956
+ BE: 'Belgium',
2957
+ BZ: 'Belize',
2958
+ BJ: 'Benin',
2959
+ BM: 'Bermuda',
2960
+ BT: 'Bhutan',
2961
+ BO: 'Bolivia',
2962
+ BA: 'Bosnia and Herzegovina',
2963
+ BW: 'Botswana',
2964
+ BV: 'Bouvet Island',
2965
+ BR: 'Brazil',
2966
+ VG: 'British Virgin Islands',
2967
+ IO: 'British Indian Ocean Territory',
2968
+ BN: 'Brunei Darussalam',
2969
+ BG: 'Bulgaria',
2970
+ BF: 'Burkina Faso',
2971
+ BI: 'Burundi',
2972
+ KH: 'Cambodia',
2973
+ CM: 'Cameroon',
2974
+ CA: 'Canada',
2975
+ CV: 'Cape Verde',
2976
+ KY: 'Cayman Islands',
2977
+ CF: 'Central African Republic',
2978
+ TD: 'Chad',
2979
+ CL: 'Chile',
2980
+ CN: 'China',
2981
+ HK: 'Hong Kong',
2982
+ MO: 'Macao',
2983
+ CX: 'Christmas Island',
2984
+ CC: 'Cocos (Keeling) Islands',
2985
+ CO: 'Colombia',
2986
+ KM: 'Comoros',
2987
+ CG: 'Congo (Brazzaville)',
2988
+ CD: 'Congo, (Kinshasa)',
2989
+ CK: 'Cook Islands',
2990
+ CR: 'Costa Rica',
2991
+ CI: 'Côte d\'Ivoire',
2992
+ HR: 'Croatia',
2993
+ CU: 'Cuba',
2994
+ CY: 'Cyprus',
2995
+ CZ: 'Czech Republic',
2996
+ DK: 'Denmark',
2997
+ DJ: 'Djibouti',
2998
+ DM: 'Dominica',
2999
+ DO: 'Dominican Republic',
3000
+ EC: 'Ecuador',
3001
+ EG: 'Egypt',
3002
+ SV: 'El Salvador',
3003
+ GQ: 'Equatorial Guinea',
3004
+ ER: 'Eritrea',
3005
+ EE: 'Estonia',
3006
+ ET: 'Ethiopia',
3007
+ FK: 'Falkland Islands (Malvinas)',
3008
+ FO: 'Faroe Islands',
3009
+ FJ: 'Fiji',
3010
+ FI: 'Finland',
3011
+ FR: 'France',
3012
+ GF: 'French Guiana',
3013
+ PF: 'French Polynesia',
3014
+ TF: 'French Southern Territories',
3015
+ GA: 'Gabon',
3016
+ GM: 'Gambia',
3017
+ GE: 'Georgia',
3018
+ DE: 'Germany',
3019
+ GH: 'Ghana',
3020
+ GI: 'Gibraltar',
3021
+ GR: 'Greece',
3022
+ GL: 'Greenland',
3023
+ GD: 'Grenada',
3024
+ GP: 'Guadeloupe',
3025
+ GU: 'Guam',
3026
+ GT: 'Guatemala',
3027
+ GG: 'Guernsey',
3028
+ GN: 'Guinea',
3029
+ GW: 'Guinea-Bissau',
3030
+ GY: 'Guyana',
3031
+ HT: 'Haiti',
3032
+ HM: 'Heard and Mcdonald Islands',
3033
+ VA: 'Vatican City State',
3034
+ HN: 'Honduras',
3035
+ HU: 'Hungary',
3036
+ IS: 'Iceland',
3037
+ IN: 'India',
3038
+ ID: 'Indonesia',
3039
+ IR: 'Iran',
3040
+ IQ: 'Iraq',
3041
+ IE: 'Ireland',
3042
+ IM: 'Isle of Man',
3043
+ IL: 'Israel',
3044
+ IT: 'Italy',
3045
+ JM: 'Jamaica',
3046
+ JP: 'Japan',
3047
+ JE: 'Jersey',
3048
+ JO: 'Jordan',
3049
+ KZ: 'Kazakhstan',
3050
+ KE: 'Kenya',
3051
+ KI: 'Kiribati',
3052
+ KP: 'Korea (North)',
3053
+ KR: 'Korea (South)',
3054
+ KW: 'Kuwait',
3055
+ KG: 'Kyrgyzstan',
3056
+ LA: 'Lao PDR',
3057
+ LV: 'Latvia',
3058
+ LB: 'Lebanon',
3059
+ LS: 'Lesotho',
3060
+ LR: 'Liberia',
3061
+ LY: 'Libya',
3062
+ LI: 'Liechtenstein',
3063
+ LT: 'Lithuania',
3064
+ LU: 'Luxembourg',
3065
+ MK: 'Macedonia',
3066
+ MG: 'Madagascar',
3067
+ MW: 'Malawi',
3068
+ MY: 'Malaysia',
3069
+ MV: 'Maldives',
3070
+ ML: 'Mali',
3071
+ MT: 'Malta',
3072
+ MH: 'Marshall Islands',
3073
+ MQ: 'Martinique',
3074
+ MR: 'Mauritania',
3075
+ MU: 'Mauritius',
3076
+ YT: 'Mayotte',
3077
+ MX: 'Mexico',
3078
+ FM: 'Micronesia',
3079
+ MD: 'Moldova',
3080
+ MC: 'Monaco',
3081
+ MN: 'Mongolia',
3082
+ ME: 'Montenegro',
3083
+ MS: 'Montserrat',
3084
+ MA: 'Morocco',
3085
+ MZ: 'Mozambique',
3086
+ MM: 'Myanmar',
3087
+ NA: 'Namibia',
3088
+ NR: 'Nauru',
3089
+ NP: 'Nepal',
3090
+ NL: 'Netherlands',
3091
+ AN: 'Netherlands Antilles',
3092
+ NC: 'New Caledonia',
3093
+ NZ: 'New Zealand',
3094
+ NI: 'Nicaragua',
3095
+ NE: 'Niger',
3096
+ NG: 'Nigeria',
3097
+ NU: 'Niue',
3098
+ NF: 'Norfolk Island',
3099
+ MP: 'Northern Mariana Islands',
3100
+ NO: 'Norway',
3101
+ OM: 'Oman',
3102
+ PK: 'Pakistan',
3103
+ PW: 'Palau',
3104
+ PS: 'Palestinian Territory',
3105
+ PA: 'Panama',
3106
+ PG: 'Papua New Guinea',
3107
+ PY: 'Paraguay',
3108
+ PE: 'Peru',
3109
+ PH: 'Philippines',
3110
+ PN: 'Pitcairn',
3111
+ PL: 'Poland',
3112
+ PT: 'Portugal',
3113
+ PR: 'Puerto Rico',
3114
+ QA: 'Qatar',
3115
+ RE: 'Réunion',
3116
+ RO: 'Romania',
3117
+ RU: 'Russian Federation',
3118
+ RW: 'Rwanda',
3119
+ BL: 'Saint-Barthélemy',
3120
+ SH: 'Saint Helena',
3121
+ KN: 'Saint Kitts and Nevis',
3122
+ LC: 'Saint Lucia',
3123
+ MF: 'Saint-Martin (French part)',
3124
+ PM: 'Saint Pierre and Miquelon',
3125
+ VC: 'Saint Vincent and Grenadines',
3126
+ WS: 'Samoa',
3127
+ SM: 'San Marino',
3128
+ ST: 'Sao Tome and Principe',
3129
+ SA: 'Saudi Arabia',
3130
+ SN: 'Senegal',
3131
+ RS: 'Serbia',
3132
+ SC: 'Seychelles',
3133
+ SL: 'Sierra Leone',
3134
+ SG: 'Singapore',
3135
+ SK: 'Slovakia',
3136
+ SI: 'Slovenia',
3137
+ SB: 'Solomon Islands',
3138
+ SO: 'Somalia',
3139
+ ZA: 'South Africa',
3140
+ GS: 'South Georgia and the South Sandwich Islands',
3141
+ SS: 'South Sudan',
3142
+ ES: 'Spain',
3143
+ LK: 'Sri Lanka',
3144
+ SD: 'Sudan',
3145
+ SR: 'Suriname',
3146
+ SJ: 'Svalbard and Jan Mayen Islands',
3147
+ SZ: 'Swaziland',
3148
+ SE: 'Sweden',
3149
+ CH: 'Switzerland',
3150
+ SY: 'Syria',
3151
+ TW: 'Taiwan',
3152
+ TJ: 'Tajikistan',
3153
+ TZ: 'Tanzania',
3154
+ TH: 'Thailand',
3155
+ TL: 'Timor-Leste',
3156
+ TG: 'Togo',
3157
+ TK: 'Tokelau',
3158
+ TO: 'Tonga',
3159
+ TT: 'Trinidad and Tobago',
3160
+ TN: 'Tunisia',
3161
+ TR: 'Turkey',
3162
+ TM: 'Turkmenistan',
3163
+ TC: 'Turks and Caicos Islands',
3164
+ TV: 'Tuvalu',
3165
+ UG: 'Uganda',
3166
+ UA: 'Ukraine',
3167
+ AE: 'United Arab Emirates',
3168
+ GB: 'United Kingdom (GB)',
3169
+ US: 'United States of America (USA)',
3170
+ UM: 'US Minor Outlying Islands',
3171
+ UY: 'Uruguay',
3172
+ UZ: 'Uzbekistan',
3173
+ VU: 'Vanuatu',
3174
+ VE: 'Venezuela',
3175
+ VN: 'Viet Nam',
3176
+ VI: 'Virgin Islands, US',
3177
+ WF: 'Wallis and Futuna Islands',
3178
+ EH: 'Western Sahara',
3179
+ YE: 'Yemen',
3180
+ ZM: 'Zambia',
3181
+ ZW: 'Zimbabwe'
3182
+ };
3183
+ const UX_TIMEZONES = [
3184
+ { name: 'Europe/Andorra', desc: 'Andorra - Andorra (GMT+02:00)' },
3185
+ { name: 'Asia/Dubai', desc: 'United Arab Emirates - Dubai (GMT+04:00)' },
3186
+ { name: 'Asia/Kabul', desc: 'Afghanistan - Kabul (GMT+04:30)' },
3187
+ { name: 'America/Antigua', desc: 'Antigua and Barbuda - Antigua (GMT-04:00)' },
3188
+ { name: 'America/Anguilla', desc: 'Anguilla - Anguilla (GMT-04:00)' },
3189
+ { name: 'Europe/Tirane', desc: 'Albania - Tirane (GMT+02:00)' },
3190
+ { name: 'Asia/Yerevan', desc: 'Armenia - Yerevan (GMT+04:00)' },
3191
+ { name: 'Africa/Luanda', desc: 'Angola - Luanda (GMT+01:00)' },
3192
+ { name: 'Antarctica/McMurdo', desc: 'Antarctica - McMurdo (GMT+12:00)' },
3193
+ { name: 'Antarctica/Rothera', desc: 'Antarctica - Rothera (GMT-03:00)' },
3194
+ { name: 'Antarctica/Palmer', desc: 'Antarctica - Palmer (GMT-03:00)' },
3195
+ { name: 'Antarctica/Mawson', desc: 'Antarctica - Mawson (GMT+05:00)' },
3196
+ { name: 'Antarctica/Davis', desc: 'Antarctica - Davis (GMT+07:00)' },
3197
+ { name: 'Antarctica/Casey', desc: 'Antarctica - Casey (GMT+08:00)' },
3198
+ { name: 'Antarctica/Vostok', desc: 'Antarctica - Vostok (GMT+06:00)' },
3199
+ { name: 'Antarctica/DumontDUrville', desc: 'Antarctica - DumontDUrville (GMT+10:00)' },
3200
+ { name: 'Antarctica/Syowa', desc: 'Antarctica - Syowa (GMT+03:00)' },
3201
+ { name: 'Antarctica/Troll', desc: 'Antarctica - Troll (GMT+02:00)' },
3202
+ { name: 'America/Argentina/Buenos_Aires', desc: 'Argentina - Buenos Aires (GMT-03:00)' },
3203
+ { name: 'America/Argentina/Cordoba', desc: 'Argentina - Cordoba (GMT-03:00)' },
3204
+ { name: 'America/Argentina/Salta', desc: 'Argentina - Salta (GMT-03:00)' },
3205
+ { name: 'America/Argentina/Jujuy', desc: 'Argentina - Jujuy (GMT-03:00)' },
3206
+ { name: 'America/Argentina/Tucuman', desc: 'Argentina - Tucuman (GMT-03:00)' },
3207
+ { name: 'America/Argentina/Catamarca', desc: 'Argentina - Catamarca (GMT-03:00)' },
3208
+ { name: 'America/Argentina/La_Rioja', desc: 'Argentina - La Rioja (GMT-03:00)' },
3209
+ { name: 'America/Argentina/San_Juan', desc: 'Argentina - San Juan (GMT-03:00)' },
3210
+ { name: 'America/Argentina/Mendoza', desc: 'Argentina - Mendoza (GMT-03:00)' },
3211
+ { name: 'America/Argentina/San_Luis', desc: 'Argentina - San Luis (GMT-03:00)' },
3212
+ { name: 'America/Argentina/Rio_Gallegos', desc: 'Argentina - Rio Gallegos (GMT-03:00)' },
3213
+ { name: 'America/Argentina/Ushuaia', desc: 'Argentina - Ushuaia (GMT-03:00)' },
3214
+ { name: 'Pacific/Pago_Pago', desc: 'American Samoa - Pago Pago (GMT-11:00)' },
3215
+ { name: 'Pacific/Samoa', desc: 'American Samoa - Samoa (GMT-11:00)' },
3216
+ { name: 'Europe/Vienna', desc: 'Austria - Vienna (GMT+02:00)' },
3217
+ { name: 'Australia/Lord_Howe', desc: 'Australia - Lord Howe (GMT+10:30)' },
3218
+ { name: 'Antarctica/Macquarie', desc: 'Australia - Macquarie (GMT+11:00)' },
3219
+ { name: 'Australia/Hobart', desc: 'Australia - Hobart (GMT+10:00)' },
3220
+ { name: 'Australia/Currie', desc: 'Australia - Currie (GMT+10:00)' },
3221
+ { name: 'Australia/Melbourne', desc: 'Australia - Melbourne (GMT+10:00)' },
3222
+ { name: 'Australia/Sydney', desc: 'Australia - Sydney (GMT+10:00)' },
3223
+ { name: 'Australia/Broken_Hill', desc: 'Australia - Broken Hill (GMT+09:30)' },
3224
+ { name: 'Australia/Brisbane', desc: 'Australia - Brisbane (GMT+10:00)' },
3225
+ { name: 'Australia/Lindeman', desc: 'Australia - Lindeman (GMT+10:00)' },
3226
+ { name: 'Australia/Adelaide', desc: 'Australia - Adelaide (GMT+09:30)' },
3227
+ { name: 'Australia/Darwin', desc: 'Australia - Darwin (GMT+09:30)' },
3228
+ { name: 'Australia/Perth', desc: 'Australia - Perth (GMT+08:00)' },
3229
+ { name: 'Australia/Eucla', desc: 'Australia - Eucla (GMT+08:45)' },
3230
+ { name: 'Australia/Canberra', desc: 'Australia - Canberra (GMT+10:00)' },
3231
+ { name: 'Australia/Queensland', desc: 'Australia - Queensland (GMT+10:00)' },
3232
+ { name: 'Australia/Tasmania', desc: 'Australia - Tasmania (GMT+10:00)' },
3233
+ { name: 'Australia/Victoria', desc: 'Australia - Victoria (GMT+10:00)' },
3234
+ { name: 'America/Aruba', desc: 'Aruba - Aruba (GMT-04:00)' },
3235
+ { name: 'Europe/Mariehamn', desc: 'Aland Islands - Mariehamn (GMT+03:00)' },
3236
+ { name: 'Asia/Baku', desc: 'Azerbaijan - Baku (GMT+04:00)' },
3237
+ { name: 'Europe/Sarajevo', desc: 'Bosnia and Herzegovina - Sarajevo (GMT+02:00)' },
3238
+ { name: 'America/Barbados', desc: 'Barbados - Barbados (GMT-04:00)' },
3239
+ { name: 'Asia/Dhaka', desc: 'Bangladesh - Dhaka (GMT+06:00)' },
3240
+ { name: 'Europe/Brussels', desc: 'Belgium - Brussels (GMT+02:00)' },
3241
+ { name: 'Africa/Ouagadougou', desc: 'Burkina Faso - Ouagadougou (GMT+00:00)' },
3242
+ { name: 'Europe/Sofia', desc: 'Bulgaria - Sofia (GMT+03:00)' },
3243
+ { name: 'Asia/Bahrain', desc: 'Bahrain - Bahrain (GMT+03:00)' },
3244
+ { name: 'Africa/Bujumbura', desc: 'Burundi - Bujumbura (GMT+02:00)' },
3245
+ { name: 'Africa/Porto-Novo', desc: 'Benin - Porto-Novo (GMT+01:00)' },
3246
+ { name: 'America/St_Barthelemy', desc: 'Saint-Barthélemy - St Barthelemy (GMT-04:00)' },
3247
+ { name: 'Atlantic/Bermuda', desc: 'Bermuda - Bermuda (GMT-03:00)' },
3248
+ { name: 'Asia/Brunei', desc: 'Brunei Darussalam - Brunei (GMT+08:00)' },
3249
+ { name: 'America/La_Paz', desc: 'Bolivia - La Paz (GMT-04:00)' },
3250
+ { name: 'America/Kralendijk', desc: 'BQ - Kralendijk (GMT-04:00)' },
3251
+ { name: 'America/Noronha', desc: 'Brazil - Noronha (GMT-02:00)' },
3252
+ { name: 'America/Belem', desc: 'Brazil - Belem (GMT-03:00)' },
3253
+ { name: 'America/Fortaleza', desc: 'Brazil - Fortaleza (GMT-03:00)' },
3254
+ { name: 'America/Recife', desc: 'Brazil - Recife (GMT-03:00)' },
3255
+ { name: 'America/Araguaina', desc: 'Brazil - Araguaina (GMT-03:00)' },
3256
+ { name: 'America/Maceio', desc: 'Brazil - Maceio (GMT-03:00)' },
3257
+ { name: 'America/Bahia', desc: 'Brazil - Bahia (GMT-03:00)' },
3258
+ { name: 'America/Sao_Paulo', desc: 'Brazil - Sao Paulo (GMT-03:00)' },
3259
+ { name: 'America/Campo_Grande', desc: 'Brazil - Campo Grande (GMT-04:00)' },
3260
+ { name: 'America/Cuiaba', desc: 'Brazil - Cuiaba (GMT-04:00)' },
3261
+ { name: 'America/Santarem', desc: 'Brazil - Santarem (GMT-03:00)' },
3262
+ { name: 'America/Porto_Velho', desc: 'Brazil - Porto Velho (GMT-04:00)' },
3263
+ { name: 'America/Boa_Vista', desc: 'Brazil - Boa Vista (GMT-04:00)' },
3264
+ { name: 'America/Manaus', desc: 'Brazil - Manaus (GMT-04:00)' },
3265
+ { name: 'America/Eirunepe', desc: 'Brazil - Eirunepe (GMT-05:00)' },
3266
+ { name: 'America/Rio_Branco', desc: 'Brazil - Rio Branco (GMT-05:00)' },
3267
+ { name: 'America/Nassau', desc: 'Bahamas - Nassau (GMT-04:00)' },
3268
+ { name: 'Asia/Thimphu', desc: 'Bhutan - Thimphu (GMT+06:00)' },
3269
+ { name: 'Africa/Gaborone', desc: 'Botswana - Gaborone (GMT+02:00)' },
3270
+ { name: 'Europe/Minsk', desc: 'Belarus - Minsk (GMT+03:00)' },
3271
+ { name: 'America/Belize', desc: 'Belize - Belize (GMT-06:00)' },
3272
+ { name: 'America/St_Johns', desc: 'Canada - St Johns (GMT-02:30)' },
3273
+ { name: 'America/Halifax', desc: 'Canada - Halifax (GMT-03:00)' },
3274
+ { name: 'America/Glace_Bay', desc: 'Canada - Glace Bay (GMT-03:00)' },
3275
+ { name: 'America/Moncton', desc: 'Canada - Moncton (GMT-03:00)' },
3276
+ { name: 'America/Goose_Bay', desc: 'Canada - Goose Bay (GMT-03:00)' },
3277
+ { name: 'America/Blanc-Sablon', desc: 'Canada - Blanc-Sablon (GMT-04:00)' },
3278
+ { name: 'America/Toronto', desc: 'Canada - Toronto (GMT-04:00)' },
3279
+ { name: 'America/Nipigon', desc: 'Canada - Nipigon (GMT-04:00)' },
3280
+ { name: 'America/Thunder_Bay', desc: 'Canada - Thunder Bay (GMT-04:00)' },
3281
+ { name: 'America/Iqaluit', desc: 'Canada - Iqaluit (GMT-04:00)' },
3282
+ { name: 'America/Pangnirtung', desc: 'Canada - Pangnirtung (GMT-04:00)' },
3283
+ { name: 'America/Resolute', desc: 'Canada - Resolute (GMT-05:00)' },
3284
+ { name: 'America/Atikokan', desc: 'Canada - Atikokan (GMT-05:00)' },
3285
+ { name: 'America/Rankin_Inlet', desc: 'Canada - Rankin Inlet (GMT-05:00)' },
3286
+ { name: 'America/Winnipeg', desc: 'Canada - Winnipeg (GMT-05:00)' },
3287
+ { name: 'America/Rainy_River', desc: 'Canada - Rainy River (GMT-05:00)' },
3288
+ { name: 'America/Regina', desc: 'Canada - Regina (GMT-06:00)' },
3289
+ { name: 'America/Swift_Current', desc: 'Canada - Swift Current (GMT-06:00)' },
3290
+ { name: 'America/Edmonton', desc: 'Canada - Edmonton (GMT-06:00)' },
3291
+ { name: 'America/Cambridge_Bay', desc: 'Canada - Cambridge Bay (GMT-06:00)' },
3292
+ { name: 'America/Yellowknife', desc: 'Canada - Yellowknife (GMT-06:00)' },
3293
+ { name: 'America/Inuvik', desc: 'Canada - Inuvik (GMT-06:00)' },
3294
+ { name: 'America/Creston', desc: 'Canada - Creston (GMT-07:00)' },
3295
+ { name: 'America/Dawson_Creek', desc: 'Canada - Dawson Creek (GMT-07:00)' },
3296
+ { name: 'America/Vancouver', desc: 'Canada - Vancouver (GMT-07:00)' },
3297
+ { name: 'America/Whitehorse', desc: 'Canada - Whitehorse (GMT-07:00)' },
3298
+ { name: 'America/Dawson', desc: 'Canada - Dawson (GMT-07:00)' },
3299
+ { name: 'America/Montreal', desc: 'Canada - Montreal (GMT-04:00)' },
3300
+ { name: 'Canada/Atlantic', desc: 'Canada - Atlantic (GMT-03:00)' },
3301
+ { name: 'Canada/Central', desc: 'Canada - Central (GMT-05:00)' },
3302
+ { name: 'Canada/Eastern', desc: 'Canada - Eastern (GMT-04:00)' },
3303
+ { name: 'Canada/Mountain', desc: 'Canada - Mountain (GMT-06:00)' },
3304
+ { name: 'Canada/Newfoundland', desc: 'Canada - Newfoundland (GMT-02:30)' },
3305
+ { name: 'Canada/Pacific', desc: 'Canada - Pacific (GMT-07:00)' },
3306
+ { name: 'Canada/Saskatchewan', desc: 'Canada - Saskatchewan (GMT-06:00)' },
3307
+ { name: 'Canada/Yukon', desc: 'Canada - Yukon (GMT-07:00)' },
3308
+ { name: 'Indian/Cocos', desc: 'Cocos (Keeling) Islands - Cocos (GMT+06:30)' },
3309
+ { name: 'Africa/Kinshasa', desc: 'Congo, (Kinshasa) - Kinshasa (GMT+01:00)' },
3310
+ { name: 'Africa/Lubumbashi', desc: 'Congo, (Kinshasa) - Lubumbashi (GMT+02:00)' },
3311
+ { name: 'Africa/Bangui', desc: 'Central African Republic - Bangui (GMT+01:00)' },
3312
+ { name: 'Africa/Brazzaville', desc: 'Congo (Brazzaville) - Brazzaville (GMT+01:00)' },
3313
+ { name: 'Europe/Zurich', desc: 'Switzerland - Zurich (GMT+02:00)' },
3314
+ { name: 'Africa/Abidjan', desc: 'Côte d\'Ivoire - Abidjan (GMT+00:00)' },
3315
+ { name: 'Pacific/Rarotonga', desc: 'Cook Islands - Rarotonga (GMT-10:00)' },
3316
+ { name: 'America/Santiago', desc: 'Chile - Santiago (GMT-04:00)' },
3317
+ { name: 'Pacific/Easter', desc: 'Chile - Easter (GMT-06:00)' },
3318
+ { name: 'Chile/Continental', desc: 'Chile - Continental (GMT-04:00)' },
3319
+ { name: 'Chile/EasterIsland', desc: 'Chile - EasterIsland (GMT-06:00)' },
3320
+ { name: 'Africa/Douala', desc: 'Cameroon - Douala (GMT+01:00)' },
3321
+ { name: 'Asia/Shanghai', desc: 'China - Shanghai (GMT+08:00)' },
3322
+ { name: 'Asia/Harbin', desc: 'China - Harbin (GMT+08:00)' },
3323
+ { name: 'Asia/Chongqing', desc: 'China - Chongqing (GMT+08:00)' },
3324
+ { name: 'Asia/Urumqi', desc: 'China - Urumqi (GMT+06:00)' },
3325
+ { name: 'Asia/Kashgar', desc: 'China - Kashgar (GMT+06:00)' },
3326
+ { name: 'America/Bogota', desc: 'Colombia - Bogota (GMT-05:00)' },
3327
+ { name: 'America/Costa_Rica', desc: 'Costa Rica - Costa Rica (GMT-06:00)' },
3328
+ { name: 'America/Havana', desc: 'Cuba - Havana (GMT-04:00)' },
3329
+ { name: 'Atlantic/Cape_Verde', desc: 'Cape Verde - Cape Verde (GMT-01:00)' },
3330
+ { name: 'America/Curacao', desc: 'CW - Curacao (GMT-04:00)' },
3331
+ { name: 'Indian/Christmas', desc: 'Christmas Island - Christmas (GMT+07:00)' },
3332
+ { name: 'Asia/Nicosia', desc: 'Cyprus - Nicosia (GMT+03:00)' },
3333
+ { name: 'Europe/Prague', desc: 'Czech Republic - Prague (GMT+02:00)' },
3334
+ { name: 'Europe/Berlin', desc: 'Germany - Berlin (GMT+02:00)' },
3335
+ { name: 'Africa/Djibouti', desc: 'Djibouti - Djibouti (GMT+03:00)' },
3336
+ { name: 'Europe/Copenhagen', desc: 'Denmark - Copenhagen (GMT+02:00)' },
3337
+ { name: 'America/Dominica', desc: 'Dominica - Dominica (GMT-04:00)' },
3338
+ { name: 'America/Santo_Domingo', desc: 'Dominican Republic - Santo Domingo (GMT-04:00)' },
3339
+ { name: 'Africa/Algiers', desc: 'Algeria - Algiers (GMT+01:00)' },
3340
+ { name: 'America/Guayaquil', desc: 'Ecuador - Guayaquil (GMT-05:00)' },
3341
+ { name: 'Pacific/Galapagos', desc: 'Ecuador - Galapagos (GMT-06:00)' },
3342
+ { name: 'Europe/Tallinn', desc: 'Estonia - Tallinn (GMT+03:00)' },
3343
+ { name: 'Egypt', desc: 'Egypt - Egypt (GMT+02:00)' },
3344
+ { name: 'Africa/El_Aaiun', desc: 'Western Sahara - El Aaiun (GMT+00:00)' },
3345
+ { name: 'Africa/Asmara', desc: 'Eritrea - Asmara (GMT+03:00)' },
3346
+ { name: 'Europe/Madrid', desc: 'Spain - Madrid (GMT+02:00)' },
3347
+ { name: 'Africa/Ceuta', desc: 'Spain - Ceuta (GMT+02:00)' },
3348
+ { name: 'Atlantic/Canary', desc: 'Spain - Canary (GMT+01:00)' },
3349
+ { name: 'Africa/Addis_Ababa', desc: 'Ethiopia - Addis Ababa (GMT+03:00)' },
3350
+ { name: 'Europe/Helsinki', desc: 'Finland - Helsinki (GMT+03:00)' },
3351
+ { name: 'Pacific/Fiji', desc: 'Fiji - Fiji (GMT+12:00)' },
3352
+ { name: 'Atlantic/Stanley', desc: 'Falkland Islands (Malvinas) - Stanley (GMT-03:00)' },
3353
+ { name: 'Pacific/Chuuk', desc: 'Micronesia - Chuuk (GMT+10:00)' },
3354
+ { name: 'Pacific/Pohnpei', desc: 'Micronesia - Pohnpei (GMT+11:00)' },
3355
+ { name: 'Pacific/Kosrae', desc: 'Micronesia - Kosrae (GMT+11:00)' },
3356
+ { name: 'Atlantic/Faroe', desc: 'Faroe Islands - Faroe (GMT+01:00)' },
3357
+ { name: 'Europe/Paris', desc: 'France - Paris (GMT+02:00)' },
3358
+ { name: 'Africa/Libreville', desc: 'Gabon - Libreville (GMT+01:00)' },
3359
+ { name: 'Europe/London', desc: 'United Kingdom (GB) - London (GMT+01:00)' },
3360
+ { name: 'America/Grenada', desc: 'Grenada - Grenada (GMT-04:00)' },
3361
+ { name: 'Asia/Tbilisi', desc: 'Georgia - Tbilisi (GMT+04:00)' },
3362
+ { name: 'America/Cayenne', desc: 'French Guiana - Cayenne (GMT-03:00)' },
3363
+ { name: 'Europe/Guernsey', desc: 'Guernsey - Guernsey (GMT+01:00)' },
3364
+ { name: 'Africa/Accra', desc: 'Ghana - Accra (GMT+00:00)' },
3365
+ { name: 'Europe/Gibraltar', desc: 'Gibraltar - Gibraltar (GMT+02:00)' },
3366
+ { name: 'America/Godthab', desc: 'Greenland - Godthab (GMT-02:00)' },
3367
+ { name: 'America/Danmarkshavn', desc: 'Greenland - Danmarkshavn (GMT+00:00)' },
3368
+ { name: 'America/Scoresbysund', desc: 'Greenland - Scoresbysund (GMT+00:00)' },
3369
+ { name: 'America/Thule', desc: 'Greenland - Thule (GMT-03:00)' },
3370
+ { name: 'Africa/Banjul', desc: 'Gambia - Banjul (GMT+00:00)' },
3371
+ { name: 'Africa/Conakry', desc: 'Guinea - Conakry (GMT+00:00)' },
3372
+ { name: 'America/Guadeloupe', desc: 'Guadeloupe - Guadeloupe (GMT-04:00)' },
3373
+ { name: 'Africa/Malabo', desc: 'Equatorial Guinea - Malabo (GMT+01:00)' },
3374
+ { name: 'Europe/Athens', desc: 'Greece - Athens (GMT+03:00)' },
3375
+ { name: 'Atlantic/South_Georgia', desc: 'South Georgia and the South Sandwich Islands - South Georgia (GMT-02:00)' },
3376
+ { name: 'America/Guatemala', desc: 'Guatemala - Guatemala (GMT-06:00)' },
3377
+ { name: 'Pacific/Guam', desc: 'Guam - Guam (GMT+10:00)' },
3378
+ { name: 'Africa/Bissau', desc: 'Guinea-Bissau - Bissau (GMT+00:00)' },
3379
+ { name: 'America/Guyana', desc: 'Guyana - Guyana (GMT-04:00)' },
3380
+ { name: 'Asia/Hong_Kong', desc: 'Hong Kong - Hong Kong (GMT+08:00)' },
3381
+ { name: 'America/Tegucigalpa', desc: 'Honduras - Tegucigalpa (GMT-06:00)' },
3382
+ { name: 'Europe/Zagreb', desc: 'Croatia - Zagreb (GMT+02:00)' },
3383
+ { name: 'America/Port-au-Prince', desc: 'Haiti - Port-au-Prince (GMT-04:00)' },
3384
+ { name: 'Europe/Budapest', desc: 'Hungary - Budapest (GMT+02:00)' },
3385
+ { name: 'Asia/Jakarta', desc: 'Indonesia - Jakarta (GMT+07:00)' },
3386
+ { name: 'Asia/Pontianak', desc: 'Indonesia - Pontianak (GMT+07:00)' },
3387
+ { name: 'Asia/Makassar', desc: 'Indonesia - Makassar (GMT+08:00)' },
3388
+ { name: 'Asia/Jayapura', desc: 'Indonesia - Jayapura (GMT+09:00)' },
3389
+ { name: 'Europe/Dublin', desc: 'Ireland - Dublin (GMT+01:00)' },
3390
+ { name: 'Asia/Jerusalem', desc: 'Israel - Jerusalem (GMT+03:00)' },
3391
+ { name: 'Europe/Isle_of_Man', desc: 'Isle of Man - Isle of_Man (GMT+01:00)' },
3392
+ { name: 'Asia/Kolkata', desc: 'India - Kolkata (GMT+05:30)' },
3393
+ { name: 'Indian/Chagos', desc: 'British Indian Ocean Territory - Chagos (GMT+06:00)' },
3394
+ { name: 'Asia/Baghdad', desc: 'Iraq - Baghdad (GMT+03:00)' },
3395
+ { name: 'Asia/Tehran', desc: 'Iran - Tehran (GMT+04:30)' },
3396
+ { name: 'Atlantic/Reykjavik', desc: 'Iceland - Reykjavik (GMT+00:00)' },
3397
+ { name: 'Europe/Rome', desc: 'Italy - Rome (GMT+02:00)' },
3398
+ { name: 'Europe/Jersey', desc: 'Jersey - Jersey (GMT+01:00)' },
3399
+ { name: 'America/Jamaica', desc: 'Jamaica - Jamaica (GMT-05:00)' },
3400
+ { name: 'Asia/Amman', desc: 'Jordan - Amman (GMT+03:00)' },
3401
+ { name: 'Asia/Tokyo', desc: 'Japan - Tokyo (GMT+09:00)' },
3402
+ { name: 'Africa/Nairobi', desc: 'Kenya - Nairobi (GMT+03:00)' },
3403
+ { name: 'Asia/Bishkek', desc: 'Kyrgyzstan - Bishkek (GMT+06:00)' },
3404
+ { name: 'Asia/Phnom_Penh', desc: 'Cambodia - Phnom Penh (GMT+07:00)' },
3405
+ { name: 'Pacific/Tarawa', desc: 'Kiribati - Tarawa (GMT+12:00)' },
3406
+ { name: 'Pacific/Enderbury', desc: 'Kiribati - Enderbury (GMT+13:00)' },
3407
+ { name: 'Pacific/Kiritimati', desc: 'Kiribati - Kiritimati (GMT+14:00)' },
3408
+ { name: 'Indian/Comoro', desc: 'Comoros - Comoro (GMT+03:00)' },
3409
+ { name: 'America/St_Kitts', desc: 'Saint Kitts and Nevis - St Kitts (GMT-04:00)' },
3410
+ { name: 'Asia/Pyongyang', desc: 'Korea (North) - Pyongyang (GMT+09:00)' },
3411
+ { name: 'Asia/Seoul', desc: 'Korea (South) - Seoul (GMT+09:00)' },
3412
+ { name: 'Asia/Kuwait', desc: 'Kuwait - Kuwait (GMT+03:00)' },
3413
+ { name: 'America/Cayman', desc: 'Cayman Islands - Cayman (GMT-05:00)' },
3414
+ { name: 'Asia/Almaty', desc: 'Kazakhstan - Almaty (GMT+06:00)' },
3415
+ { name: 'Asia/Qyzylorda', desc: 'Kazakhstan - Qyzylorda (GMT+06:00)' },
3416
+ { name: 'Asia/Aqtobe', desc: 'Kazakhstan - Aqtobe (GMT+05:00)' },
3417
+ { name: 'Asia/Aqtau', desc: 'Kazakhstan - Aqtau (GMT+05:00)' },
3418
+ { name: 'Asia/Oral', desc: 'Kazakhstan - Oral (GMT+05:00)' },
3419
+ { name: 'Asia/Vientiane', desc: 'Lao PDR - Vientiane (GMT+07:00)' },
3420
+ { name: 'Asia/Beirut', desc: 'Lebanon - Beirut (GMT+03:00)' },
3421
+ { name: 'America/St_Lucia', desc: 'Saint Lucia - St Lucia (GMT-04:00)' },
3422
+ { name: 'Europe/Vaduz', desc: 'Liechtenstein - Vaduz (GMT+02:00)' },
3423
+ { name: 'Asia/Colombo', desc: 'Sri Lanka - Colombo (GMT+05:30)' },
3424
+ { name: 'Africa/Monrovia', desc: 'Liberia - Monrovia (GMT+00:00)' },
3425
+ { name: 'Africa/Maseru', desc: 'Lesotho - Maseru (GMT+02:00)' },
3426
+ { name: 'Europe/Vilnius', desc: 'Lithuania - Vilnius (GMT+03:00)' },
3427
+ { name: 'Europe/Luxembourg', desc: 'Luxembourg - Luxembourg (GMT+02:00)' },
3428
+ { name: 'Europe/Riga', desc: 'Latvia - Riga (GMT+03:00)' },
3429
+ { name: 'Africa/Tripoli', desc: 'Libya - Tripoli (GMT+02:00)' },
3430
+ { name: 'Africa/Casablanca', desc: 'Morocco - Casablanca (GMT+00:00)' },
3431
+ { name: 'Europe/Monaco', desc: 'Monaco - Monaco (GMT+02:00)' },
3432
+ { name: 'Europe/Chisinau', desc: 'Moldova - Chisinau (GMT+03:00)' },
3433
+ { name: 'Europe/Podgorica', desc: 'Montenegro - Podgorica (GMT+02:00)' },
3434
+ { name: 'America/Marigot', desc: 'Saint-Martin (French part) - Marigot (GMT-04:00)' },
3435
+ { name: 'Indian/Antananarivo', desc: 'Madagascar - Antananarivo (GMT+03:00)' },
3436
+ { name: 'Pacific/Majuro', desc: 'Marshall Islands - Majuro (GMT+12:00)' },
3437
+ { name: 'Pacific/Kwajalein', desc: 'Marshall Islands - Kwajalein (GMT+12:00)' },
3438
+ { name: 'Europe/Skopje', desc: 'Macedonia - Skopje (GMT+02:00)' },
3439
+ { name: 'Africa/Bamako', desc: 'Mali - Bamako (GMT+00:00)' },
3440
+ { name: 'Asia/Rangoon', desc: 'Myanmar - Rangoon (GMT+06:30)' },
3441
+ { name: 'Asia/Ulaanbaatar', desc: 'Mongolia - Ulaanbaatar (GMT+08:00)' },
3442
+ { name: 'Asia/Hovd', desc: 'Mongolia - Hovd (GMT+07:00)' },
3443
+ { name: 'Asia/Choibalsan', desc: 'Mongolia - Choibalsan (GMT+08:00)' },
3444
+ { name: 'Asia/Macau', desc: 'Macao - Macau (GMT+08:00)' },
3445
+ { name: 'Pacific/Saipan', desc: 'Northern Mariana Islands - Saipan (GMT+10:00)' },
3446
+ { name: 'America/Martinique', desc: 'Martinique - Martinique (GMT-04:00)' },
3447
+ { name: 'Africa/Nouakchott', desc: 'Mauritania - Nouakchott (GMT+00:00)' },
3448
+ { name: 'America/Montserrat', desc: 'Montserrat - Montserrat (GMT-04:00)' },
3449
+ { name: 'Europe/Malta', desc: 'Malta - Malta (GMT+02:00)' },
3450
+ { name: 'Indian/Mauritius', desc: 'Mauritius - Mauritius (GMT+04:00)' },
3451
+ { name: 'Indian/Maldives', desc: 'Maldives - Maldives (GMT+05:00)' },
3452
+ { name: 'Africa/Blantyre', desc: 'Malawi - Blantyre (GMT+02:00)' },
3453
+ { name: 'America/Mexico_City', desc: 'Mexico - Mexico City (GMT-05:00)' },
3454
+ { name: 'America/Cancun', desc: 'Mexico - Cancun (GMT-05:00)' },
3455
+ { name: 'America/Merida', desc: 'Mexico - Merida (GMT-05:00)' },
3456
+ { name: 'America/Monterrey', desc: 'Mexico - Monterrey (GMT-05:00)' },
3457
+ { name: 'America/Matamoros', desc: 'Mexico - Matamoros (GMT-05:00)' },
3458
+ { name: 'America/Mazatlan', desc: 'Mexico - Mazatlan (GMT-06:00)' },
3459
+ { name: 'America/Chihuahua', desc: 'Mexico - Chihuahua (GMT-06:00)' },
3460
+ { name: 'America/Ojinaga', desc: 'Mexico - Ojinaga (GMT-06:00)' },
3461
+ { name: 'America/Hermosillo', desc: 'Mexico - Hermosillo (GMT-07:00)' },
3462
+ { name: 'America/Tijuana', desc: 'Mexico - Tijuana (GMT-07:00)' },
3463
+ { name: 'America/Santa_Isabel', desc: 'Mexico - Santa Isabel (GMT-07:00)' },
3464
+ { name: 'America/Bahia_Banderas', desc: 'Mexico - Bahia Banderas (GMT-05:00)' },
3465
+ { name: 'Asia/Kuala_Lumpur', desc: 'Malaysia - Kuala Lumpur (GMT+08:00)' },
3466
+ { name: 'Asia/Kuching', desc: 'Malaysia - Kuching (GMT+08:00)' },
3467
+ { name: 'Africa/Maputo', desc: 'Mozambique - Maputo (GMT+02:00)' },
3468
+ { name: 'Africa/Windhoek', desc: 'Namibia - Windhoek (GMT+02:00)' },
3469
+ { name: 'Pacific/Noumea', desc: 'New Caledonia - Noumea (GMT+11:00)' },
3470
+ { name: 'Africa/Niamey', desc: 'Niger - Niamey (GMT+01:00)' },
3471
+ { name: 'Pacific/Norfolk', desc: 'Norfolk Island - Norfolk (GMT+11:00)' },
3472
+ { name: 'Africa/Lagos', desc: 'Nigeria - Lagos (GMT+01:00)' },
3473
+ { name: 'America/Managua', desc: 'Nicaragua - Managua (GMT-06:00)' },
3474
+ { name: 'Europe/Amsterdam', desc: 'Netherlands - Amsterdam (GMT+02:00)' },
3475
+ { name: 'Europe/Oslo', desc: 'Norway - Oslo (GMT+02:00)' },
3476
+ { name: 'Asia/Kathmandu', desc: 'Nepal - Kathmandu (GMT+05:45)' },
3477
+ { name: 'Pacific/Nauru', desc: 'Nauru - Nauru (GMT+12:00)' },
3478
+ { name: 'Pacific/Niue', desc: 'Niue - Niue (GMT-11:00)' },
3479
+ { name: 'Pacific/Auckland', desc: 'New Zealand - Auckland (GMT+12:00)' },
3480
+ { name: 'Pacific/Chatham', desc: 'New Zealand - Chatham (GMT+12:45)' },
3481
+ { name: 'Asia/Muscat', desc: 'Oman - Muscat (GMT+04:00)' },
3482
+ { name: 'America/Panama', desc: 'Panama - Panama (GMT-05:00)' },
3483
+ { name: 'America/Lima', desc: 'Peru - Lima (GMT-05:00)' },
3484
+ { name: 'Pacific/Tahiti', desc: 'French Polynesia - Tahiti (GMT-10:00)' },
3485
+ { name: 'Pacific/Marquesas', desc: 'French Polynesia - Marquesas (GMT-09:30)' },
3486
+ { name: 'Pacific/Gambier', desc: 'French Polynesia - Gambier (GMT-09:00)' },
3487
+ { name: 'Pacific/Port_Moresby', desc: 'Papua New Guinea - Port Moresby (GMT+10:00)' },
3488
+ { name: 'Asia/Manila', desc: 'Philippines - Manila (GMT+08:00)' },
3489
+ { name: 'Asia/Karachi', desc: 'Pakistan - Karachi (GMT+05:00)' },
3490
+ { name: 'Europe/Warsaw', desc: 'Poland - Warsaw (GMT+02:00)' },
3491
+ { name: 'Poland', desc: 'Poland - Poland (GMT+02:00)' },
3492
+ { name: 'America/Miquelon', desc: 'Saint Pierre and Miquelon - Miquelon (GMT-02:00)' },
3493
+ { name: 'Pacific/Pitcairn', desc: 'Pitcairn - Pitcairn (GMT-08:00)' },
3494
+ { name: 'America/Puerto_Rico', desc: 'Puerto Rico - Puerto Rico (GMT-04:00)' },
3495
+ { name: 'Asia/Gaza', desc: 'Palestinian Territory - Gaza (GMT+03:00)' },
3496
+ { name: 'Asia/Hebron', desc: 'Palestinian Territory - Hebron (GMT+03:00)' },
3497
+ { name: 'Europe/Lisbon', desc: 'Portugal - Lisbon (GMT+01:00)' },
3498
+ { name: 'Atlantic/Madeira', desc: 'Portugal - Madeira (GMT+01:00)' },
3499
+ { name: 'Atlantic/Azores', desc: 'Portugal - Azores (GMT+00:00)' },
3500
+ { name: 'Pacific/Palau', desc: 'Palau - Palau (GMT+09:00)' },
3501
+ { name: 'America/Asuncion', desc: 'Paraguay - Asuncion (GMT-04:00)' },
3502
+ { name: 'Asia/Qatar', desc: 'Qatar - Qatar (GMT+03:00)' },
3503
+ { name: 'Indian/Reunion', desc: 'Réunion - Reunion (GMT+04:00)' },
3504
+ { name: 'Europe/Bucharest', desc: 'Romania - Bucharest (GMT+03:00)' },
3505
+ { name: 'Europe/Belgrade', desc: 'Serbia - Belgrade (GMT+02:00)' },
3506
+ { name: 'Europe/Kaliningrad', desc: 'Russian Federation - Kaliningrad (GMT+02:00)' },
3507
+ { name: 'Europe/Moscow', desc: 'Russian Federation - Moscow (GMT+03:00)' },
3508
+ { name: 'Europe/Volgograd', desc: 'Russian Federation - Volgograd (GMT+03:00)' },
3509
+ { name: 'Europe/Samara', desc: 'Russian Federation - Samara (GMT+04:00)' },
3510
+ { name: 'Europe/Simferopol', desc: 'Russian Federation - Simferopol (GMT+03:00)' },
3511
+ { name: 'Asia/Yekaterinburg', desc: 'Russian Federation - Yekaterinburg (GMT+05:00)' },
3512
+ { name: 'Asia/Omsk', desc: 'Russian Federation - Omsk (GMT+06:00)' },
3513
+ { name: 'Asia/Novosibirsk', desc: 'Russian Federation - Novosibirsk (GMT+07:00)' },
3514
+ { name: 'Asia/Novokuznetsk', desc: 'Russian Federation - Novokuznetsk (GMT+07:00)' },
3515
+ { name: 'Asia/Krasnoyarsk', desc: 'Russian Federation - Krasnoyarsk (GMT+07:00)' },
3516
+ { name: 'Asia/Irkutsk', desc: 'Russian Federation - Irkutsk (GMT+08:00)' },
3517
+ { name: 'Asia/Yakutsk', desc: 'Russian Federation - Yakutsk (GMT+09:00)' },
3518
+ { name: 'Asia/Khandyga', desc: 'Russian Federation - Khandyga (GMT+09:00)' },
3519
+ { name: 'Asia/Vladivostok', desc: 'Russian Federation - Vladivostok (GMT+10:00)' },
3520
+ { name: 'Asia/Sakhalin', desc: 'Russian Federation - Sakhalin (GMT+11:00)' },
3521
+ { name: 'Asia/Ust-Nera', desc: 'Russian Federation - Ust-Nera (GMT+10:00)' },
3522
+ { name: 'Asia/Magadan', desc: 'Russian Federation - Magadan (GMT+11:00)' },
3523
+ { name: 'Asia/Kamchatka', desc: 'Russian Federation - Kamchatka (GMT+12:00)' },
3524
+ { name: 'Asia/Anadyr', desc: 'Russian Federation - Anadyr (GMT+12:00)' },
3525
+ { name: 'Africa/Kigali', desc: 'Rwanda - Kigali (GMT+02:00)' },
3526
+ { name: 'Asia/Riyadh', desc: 'Saudi Arabia - Riyadh (GMT+03:00)' },
3527
+ { name: 'Pacific/Guadalcanal', desc: 'Solomon Islands - Guadalcanal (GMT+11:00)' },
3528
+ { name: 'Indian/Mahe', desc: 'Seychelles - Mahe (GMT+04:00)' },
3529
+ { name: 'Africa/Khartoum', desc: 'Sudan - Khartoum (GMT+02:00)' },
3530
+ { name: 'Europe/Stockholm', desc: 'Sweden - Stockholm (GMT+02:00)' },
3531
+ { name: 'Asia/Singapore', desc: 'Singapore - Singapore (GMT+08:00)' },
3532
+ { name: 'Atlantic/St_Helena', desc: 'Saint Helena - St Helena (GMT+00:00)' },
3533
+ { name: 'Europe/Ljubljana', desc: 'Slovenia - Ljubljana (GMT+02:00)' },
3534
+ { name: 'Arctic/Longyearbyen', desc: 'Svalbard and Jan Mayen Islands - Longyearbyen (GMT+02:00)' },
3535
+ { name: 'Europe/Bratislava', desc: 'Slovakia - Bratislava (GMT+02:00)' },
3536
+ { name: 'Africa/Freetown', desc: 'Sierra Leone - Freetown (GMT+00:00)' },
3537
+ { name: 'Europe/San_Marino', desc: 'San Marino - San Marino (GMT+02:00)' },
3538
+ { name: 'Africa/Dakar', desc: 'Senegal - Dakar (GMT+00:00)' },
3539
+ { name: 'Africa/Mogadishu', desc: 'Somalia - Mogadishu (GMT+03:00)' },
3540
+ { name: 'America/Paramaribo', desc: 'Suriname - Paramaribo (GMT-03:00)' },
3541
+ { name: 'Africa/Juba', desc: 'South Sudan - Juba (GMT+03:00)' },
3542
+ { name: 'Africa/Sao_Tome', desc: 'Sao Tome and Principe - Sao Tome (GMT+01:00)' },
3543
+ { name: 'America/El_Salvador', desc: 'El Salvador - El Salvador (GMT-06:00)' },
3544
+ { name: 'America/Lower_Princes', desc: 'SX - Lower Princes (GMT-04:00)' },
3545
+ { name: 'Asia/Damascus', desc: 'Syria - Damascus (GMT+03:00)' },
3546
+ { name: 'Africa/Mbabane', desc: 'Swaziland - Mbabane (GMT+02:00)' },
3547
+ { name: 'America/Grand_Turk', desc: 'Turks and Caicos Islands - Grand Turk (GMT-04:00)' },
3548
+ { name: 'Africa/Ndjamena', desc: 'Chad - Ndjamena (GMT+01:00)' },
3549
+ { name: 'Indian/Kerguelen', desc: 'French Southern Territories - Kerguelen (GMT+05:00)' },
3550
+ { name: 'Africa/Lome', desc: 'Togo - Lome (GMT+00:00)' },
3551
+ { name: 'Asia/Bangkok', desc: 'Thailand - Bangkok (GMT+07:00)' },
3552
+ { name: 'Asia/Dushanbe', desc: 'Tajikistan - Dushanbe (GMT+05:00)' },
3553
+ { name: 'Pacific/Fakaofo', desc: 'Tokelau - Fakaofo (GMT+13:00)' },
3554
+ { name: 'Asia/Dili', desc: 'Timor-Leste - Dili (GMT+09:00)' },
3555
+ { name: 'Asia/Ashgabat', desc: 'Turkmenistan - Ashgabat (GMT+05:00)' },
3556
+ { name: 'Africa/Tunis', desc: 'Tunisia - Tunis (GMT+01:00)' },
3557
+ { name: 'Pacific/Tongatapu', desc: 'Tonga - Tongatapu (GMT+13:00)' },
3558
+ { name: 'Europe/Istanbul', desc: 'Turkey - Istanbul (GMT+03:00)' },
3559
+ { name: 'America/Port_of_Spain', desc: 'Trinidad and Tobago - Port of_Spain (GMT-04:00)' },
3560
+ { name: 'Pacific/Funafuti', desc: 'Tuvalu - Funafuti (GMT+12:00)' },
3561
+ { name: 'Asia/Taipei', desc: 'Taiwan - Taipei (GMT+08:00)' },
3562
+ { name: 'Africa/Dar_es_Salaam', desc: 'Tanzania - Dar es_Salaam (GMT+03:00)' },
3563
+ { name: 'Europe/Kiev', desc: 'Ukraine - Kiev (GMT+03:00)' },
3564
+ { name: 'Europe/Uzhgorod', desc: 'Ukraine - Uzhgorod (GMT+03:00)' },
3565
+ { name: 'Europe/Zaporozhye', desc: 'Ukraine - Zaporozhye (GMT+03:00)' },
3566
+ { name: 'Africa/Kampala', desc: 'Uganda - Kampala (GMT+03:00)' },
3567
+ { name: 'Pacific/Johnston', desc: 'US Minor Outlying Islands - Johnston (GMT-10:00)' },
3568
+ { name: 'Pacific/Midway', desc: 'US Minor Outlying Islands - Midway (GMT-11:00)' },
3569
+ { name: 'Pacific/Wake', desc: 'US Minor Outlying Islands - Wake (GMT+12:00)' },
3570
+ { name: 'America/New_York', desc: 'United States of America (USA) - New York (GMT-04:00)' },
3571
+ { name: 'America/Detroit', desc: 'United States of America (USA) - Detroit (GMT-04:00)' },
3572
+ { name: 'America/Kentucky/Louisville', desc: 'United States of America (USA) - Louisville (GMT-04:00)' },
3573
+ { name: 'America/Kentucky/Monticello', desc: 'United States of America (USA) - Monticello (GMT-04:00)' },
3574
+ { name: 'America/Indiana/Indianapolis', desc: 'United States of America (USA) - Indianapolis (GMT-04:00)' },
3575
+ { name: 'America/Indiana/Vincennes', desc: 'United States of America (USA) - Vincennes (GMT-04:00)' },
3576
+ { name: 'America/Indiana/Winamac', desc: 'United States of America (USA) - Winamac (GMT-04:00)' },
3577
+ { name: 'America/Indiana/Marengo', desc: 'United States of America (USA) - Marengo (GMT-04:00)' },
3578
+ { name: 'America/Indiana/Petersburg', desc: 'United States of America (USA) - Petersburg (GMT-04:00)' },
3579
+ { name: 'America/Indiana/Vevay', desc: 'United States of America (USA) - Vevay (GMT-04:00)' },
3580
+ { name: 'America/Chicago', desc: 'United States of America (USA) - Chicago (GMT-05:00)' },
3581
+ { name: 'America/Indiana/Tell_City', desc: 'United States of America (USA) - Tell City (GMT-05:00)' },
3582
+ { name: 'America/Indiana/Knox', desc: 'United States of America (USA) - Knox (GMT-05:00)' },
3583
+ { name: 'America/Menominee', desc: 'United States of America (USA) - Menominee (GMT-05:00)' },
3584
+ { name: 'America/North_Dakota/Center', desc: 'United States of America (USA) - Center (GMT-05:00)' },
3585
+ { name: 'America/North_Dakota/New_Salem', desc: 'United States of America (USA) - New Salem (GMT-05:00)' },
3586
+ { name: 'America/North_Dakota/Beulah', desc: 'United States of America (USA) - Beulah (GMT-05:00)' },
3587
+ { name: 'America/Denver', desc: 'United States of America (USA) - Denver (GMT-06:00)' },
3588
+ { name: 'America/Boise', desc: 'United States of America (USA) - Boise (GMT-06:00)' },
3589
+ { name: 'America/Phoenix', desc: 'United States of America (USA) - Phoenix (GMT-07:00)' },
3590
+ { name: 'America/Los_Angeles', desc: 'United States of America (USA) - Los Angeles (GMT-07:00)' },
3591
+ { name: 'America/Anchorage', desc: 'United States of America (USA) - Anchorage (GMT-08:00)' },
3592
+ { name: 'America/Juneau', desc: 'United States of America (USA) - Juneau (GMT-08:00)' },
3593
+ { name: 'America/Sitka', desc: 'United States of America (USA) - Sitka (GMT-08:00)' },
3594
+ { name: 'America/Yakutat', desc: 'United States of America (USA) - Yakutat (GMT-08:00)' },
3595
+ { name: 'America/Nome', desc: 'United States of America (USA) - Nome (GMT-08:00)' },
3596
+ { name: 'America/Adak', desc: 'United States of America (USA) - Adak (GMT-09:00)' },
3597
+ { name: 'America/Metlakatla', desc: 'United States of America (USA) - Metlakatla (GMT-08:00)' },
3598
+ { name: 'Pacific/Honolulu', desc: 'United States of America (USA) - Honolulu (GMT-10:00)' },
3599
+ { name: 'America/Montevideo', desc: 'Uruguay - Montevideo (GMT-03:00)' },
3600
+ { name: 'Asia/Samarkand', desc: 'Uzbekistan - Samarkand (GMT+05:00)' },
3601
+ { name: 'Asia/Tashkent', desc: 'Uzbekistan - Tashkent (GMT+05:00)' },
3602
+ { name: 'Europe/Vatican', desc: 'Vatican City State - Vatican (GMT+02:00)' },
3603
+ { name: 'America/St_Vincent', desc: 'Saint Vincent and Grenadines - St Vincent (GMT-04:00)' },
3604
+ { name: 'America/Caracas', desc: 'Venezuela - Caracas (GMT-04:00)' },
3605
+ { name: 'America/Tortola', desc: 'British Virgin Islands - Tortola (GMT-04:00)' },
3606
+ { name: 'America/St_Thomas', desc: 'Virgin Islands, US - St Thomas (GMT-04:00)' },
3607
+ { name: 'Asia/Ho_Chi_Minh', desc: 'Viet Nam - Ho Chi_Minh (GMT+07:00)' },
3608
+ { name: 'Pacific/Efate', desc: 'Vanuatu - Efate (GMT+11:00)' },
3609
+ { name: 'Pacific/Wallis', desc: 'Wallis and Futuna Islands - Wallis (GMT+12:00)' },
3610
+ { name: 'Pacific/Apia', desc: 'Samoa - Apia (GMT+13:00)' },
3611
+ { name: 'Asia/Aden', desc: 'Yemen - Aden (GMT+03:00)' },
3612
+ { name: 'Indian/Mayotte', desc: 'Mayotte - Mayotte (GMT+03:00)' },
3613
+ { name: 'Africa/Johannesburg', desc: 'South Africa - Johannesburg (GMT+02:00)' },
3614
+ { name: 'Africa/Lusaka', desc: 'Zambia - Lusaka (GMT+02:00)' },
3615
+ { name: 'Africa/Harare', desc: 'Zimbabwe - Harare (GMT+02:00)' },
3616
+ ];
3617
+ // TODO: is this a service or a helper function?
3618
+ class UxTimezoneService {
3619
+ /**
3620
+ * Convert country ISO code to country name (in english)
3621
+ */
3622
+ iso2country(iso) {
3623
+ return UX_COUNTRIES[iso] ? UX_COUNTRIES[iso] : iso;
3624
+ }
3625
+ /**
3626
+ * Gets the list of ISO-codes for all countries
3627
+ */
3628
+ getCountries() {
3629
+ const res = [];
3630
+ for (const prop of Object.keys(UX_COUNTRIES)) {
3631
+ res.push(prop);
3632
+ }
3633
+ return res;
3634
+ }
3635
+ getTimezones() {
3636
+ return UX_TIMEZONES;
3637
+ }
3638
+ getTimezone(tz) {
3639
+ return UX_TIMEZONES.find((item) => {
3640
+ return item.name === tz;
3641
+ });
3642
+ }
3643
+ }
3644
+ /** @nocollapse */ /** @nocollapse */ UxTimezoneService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxTimezoneService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3645
+ /** @nocollapse */ /** @nocollapse */ UxTimezoneService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxTimezoneService });
3646
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxTimezoneService, decorators: [{
3647
+ type: Injectable
3648
+ }] });
3649
+
3650
+ /**
3651
+ * Generic storage service. Concrete storage services must extend this class
3652
+ */
3653
+ class StorageService {
3654
+ }
3655
+
3656
+ class StorageServiceMock extends StorageService {
3657
+ name() {
3658
+ return null;
3659
+ }
3660
+ get() {
3661
+ return null;
3662
+ }
3663
+ set() {
3664
+ }
3665
+ remove() {
3666
+ }
3667
+ }
3668
+
3669
+ /**
3670
+ * Generic asynchronous storage service. Concrete asynchronous storage services must extend this class
3671
+ */
3672
+ class AsyncStorageService extends StorageService {
3673
+ setAsync(key, value) {
3674
+ this.set(key, value).subscribe(() => {
3675
+ });
3676
+ }
3677
+ /**
3678
+ * asynchronous helper for remove function
3679
+ * @param key the associated key
3680
+ */
3681
+ removeAsync(key) {
3682
+ this.remove(key).subscribe(() => {
3683
+ });
3684
+ }
3685
+ }
3686
+
3687
+ class AsyncStorageServiceMock extends AsyncStorageService {
3688
+ ready() {
3689
+ // tslint:disable-next-line:deprecation
3690
+ return of({});
3691
+ }
3692
+ name() {
3693
+ return null;
3694
+ }
3695
+ get() {
3696
+ // tslint:disable-next-line:deprecation
3697
+ return of({});
3698
+ }
3699
+ set() {
3700
+ // tslint:disable-next-line:deprecation
3701
+ return of({});
3702
+ }
3703
+ remove() {
3704
+ // tslint:disable-next-line:deprecation
3705
+ return of({});
3706
+ }
3707
+ setAsync() {
3708
+ }
3709
+ removeAsync() {
3710
+ }
3711
+ }
3712
+
3713
+ /**
3714
+ * localStorage service
3715
+ */
3716
+ class LocalStorageService extends StorageService {
3717
+ constructor(log) {
3718
+ super();
3719
+ this.log = log;
3720
+ }
3721
+ /**
3722
+ * the name of the storage service
3723
+ */
3724
+ name() {
3725
+ return LocalStorageService.NAME;
3726
+ }
3727
+ /**
3728
+ * retrieve an object from local storage
3729
+ * @param key the associated key
3730
+ * @returns the value or undefined, if case of error
3731
+ */
3732
+ get(key) {
3733
+ try {
3734
+ const serialized = localStorage.getItem(key);
3735
+ return serialized && JSON.parse(serialized);
3736
+ }
3737
+ catch (err) {
3738
+ if (this.log) {
3739
+ this.log.error(this.name(), 'get', err);
3740
+ }
3741
+ return undefined;
3742
+ }
3743
+ }
3744
+ /**
3745
+ * sets an object in local storage
3746
+ * @param key the associated key
3747
+ * @param value the value to set
3748
+ */
3749
+ set(key, value) {
3750
+ try {
3751
+ const serialized = JSON.stringify(value);
3752
+ localStorage.setItem(key, serialized);
3753
+ }
3754
+ catch (err) {
3755
+ if (this.log) {
3756
+ this.log.error(this.name(), 'set', err);
3757
+ }
3758
+ }
3759
+ }
3760
+ /**
3761
+ * removes an object from local storage
3762
+ * @param key the associated key
3763
+ */
3764
+ remove(key) {
3765
+ try {
3766
+ localStorage.removeItem(key);
3767
+ }
3768
+ catch (err) {
3769
+ if (this.log) {
3770
+ this.log.error(this.name(), 'remove', err);
3771
+ }
3772
+ }
3773
+ }
3774
+ }
3775
+ LocalStorageService.NAME = 'LocalStorageService';
3776
+ /** @nocollapse */ /** @nocollapse */ LocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
3777
+ /** @nocollapse */ /** @nocollapse */ LocalStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalStorageService });
3778
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalStorageService, decorators: [{
3779
+ type: Injectable
3780
+ }], ctorParameters: function () { return [{ type: LogService, decorators: [{
3781
+ type: Optional
3782
+ }] }]; } });
3783
+
3784
+ /**
3785
+ * sessionStorage service
3786
+ */
3787
+ class SessionStorageService extends StorageService {
3788
+ constructor(log) {
3789
+ super();
3790
+ this.log = log;
3791
+ }
3792
+ /**
3793
+ * the name of the storage service
3794
+ */
3795
+ name() {
3796
+ return SessionStorageService.NAME;
3797
+ }
3798
+ /**
3799
+ * retrieve an object from session storage
3800
+ * @param key the associated key
3801
+ * @returns the value or undefined, if case of error
3802
+ */
3803
+ get(key) {
3804
+ try {
3805
+ const serialized = sessionStorage.getItem(key);
3806
+ return serialized && JSON.parse(serialized);
3807
+ }
3808
+ catch (err) {
3809
+ if (this.log) {
3810
+ this.log.error(this.name(), 'get', err);
3811
+ }
3812
+ return undefined;
3813
+ }
3814
+ }
3815
+ /**
3816
+ * sets an object in session storage
3817
+ * @param key the associated key
3818
+ * @param value the value to set
3819
+ */
3820
+ set(key, value) {
3821
+ try {
3822
+ const serialized = JSON.stringify(value);
3823
+ sessionStorage.setItem(key, serialized);
3824
+ }
3825
+ catch (err) {
3826
+ if (this.log) {
3827
+ this.log.error(this.name(), 'set', err);
3828
+ }
3829
+ }
3830
+ }
3831
+ /**
3832
+ * removes an object from session storage
3833
+ * @param key the associated key
3834
+ */
3835
+ remove(key) {
3836
+ try {
3837
+ sessionStorage.removeItem(key);
3838
+ }
3839
+ catch (err) {
3840
+ if (this.log) {
3841
+ this.log.error(this.name(), 'remove', err);
3842
+ }
3843
+ }
3844
+ }
3845
+ }
3846
+ SessionStorageService.NAME = 'SessionStorageService';
3847
+ /** @nocollapse */ /** @nocollapse */ SessionStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: SessionStorageService, deps: [{ token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
3848
+ /** @nocollapse */ /** @nocollapse */ SessionStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: SessionStorageService });
3849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: SessionStorageService, decorators: [{
3850
+ type: Injectable
3851
+ }], ctorParameters: function () { return [{ type: LogService, decorators: [{
3852
+ type: Optional
3853
+ }] }]; } });
3854
+
3855
+ /** @internal */
3856
+ const localForage = 'defineDriver' in lf ? lf : lf['default'];
3857
+ const LOCAL_FORAGE_SERVICE_CONFIG_TOKEN = new InjectionToken('LOCAL_FORAGE_SERVICE_CONFIG');
3858
+ /**
3859
+ * localforage service, using the localForage javascript library
3860
+ * https://localforage.github.io/localForage
3861
+ */
3862
+ class LocalForageService extends AsyncStorageService {
3863
+ constructor(config, log) {
3864
+ super();
3865
+ this.config = config;
3866
+ this.log = log;
3867
+ // configure localforage, if specified
3868
+ if (config) {
3869
+ localForage.config(config);
3870
+ }
3871
+ }
3872
+ /**
3873
+ * the name of the storage service
3874
+ */
3875
+ name() {
3876
+ return LocalForageService.NAME;
3877
+ }
3878
+ /**
3879
+ * reflects the readiness of the storage
3880
+ * @returns one time emission Observable<void>
3881
+ */
3882
+ ready() {
3883
+ return from(localForage.ready())
3884
+ .pipe(take(1), tap(() => {
3885
+ }, err => {
3886
+ if (this.log) {
3887
+ this.log.error(this.name(), 'ready', err);
3888
+ }
3889
+ }));
3890
+ }
3891
+ /**
3892
+ * retrieve an object from localforage
3893
+ * @param key the associated key
3894
+ * @returns one time emission Observable of value
3895
+ */
3896
+ get(key) {
3897
+ return from(localForage.getItem(key))
3898
+ .pipe(take(1), tap(() => {
3899
+ }, err => {
3900
+ if (this.log) {
3901
+ this.log.error(this.name(), 'get', err);
3902
+ }
3903
+ }));
3904
+ }
3905
+ /**
3906
+ * sets an object in localforage
3907
+ * @param key the associated key
3908
+ * @param value the value to set
3909
+ * @returns one time emission Observable
3910
+ */
3911
+ set(key, value) {
3912
+ return from(localForage.setItem(key, value))
3913
+ .pipe(take(1), tap(() => {
3914
+ }, err => {
3915
+ if (this.log) {
3916
+ this.log.error(this.name(), 'set', err);
3917
+ }
3918
+ }));
3919
+ }
3920
+ /**
3921
+ * removes an object from localforage
3922
+ * @param key the associated key
3923
+ * @returns one time emission Observable
3924
+ */
3925
+ remove(key) {
3926
+ return from(localForage.removeItem(key))
3927
+ .pipe(take(1), tap(() => {
3928
+ }, err => {
3929
+ if (this.log) {
3930
+ this.log.error(this.name(), 'remove', err);
3931
+ }
3932
+ }));
3933
+ }
3934
+ }
3935
+ LocalForageService.NAME = 'LocalForageService';
3936
+ /** @nocollapse */ /** @nocollapse */ LocalForageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalForageService, deps: [{ token: LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
3937
+ /** @nocollapse */ /** @nocollapse */ LocalForageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalForageService });
3938
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocalForageService, decorators: [{
3939
+ type: Injectable
3940
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
3941
+ type: Inject,
3942
+ args: [LOCAL_FORAGE_SERVICE_CONFIG_TOKEN]
3943
+ }, {
3944
+ type: Optional
3945
+ }] }, { type: LogService, decorators: [{
3946
+ type: Optional
3947
+ }] }]; } });
3948
+
3949
+ /**
3950
+ * Angular is using a gulp task to generate the locales that we dynamically import. This task can be found here
3951
+ * https://github.com/angular/angular/blob/master/tools/gulp-tasks/cldr/cldr-data.js
3952
+ * That task is utilizing the CLDR library to load and construct the locale for each region. This service is responsible
3953
+ * to load those locale dynamically upon request and to update the state of the eUI app.
3954
+ *
3955
+ * Parts that are handles through configuration:
3956
+ * - update of the LOCALE_ID token
3957
+ * - initial dynamical load of locales
3958
+ * - bind to translation service for locale changes
3959
+ */
3960
+ const LOCALE_ID_MAPPER = new InjectionToken('localeIdMapper');
3961
+ class LocaleService extends EuiService {
3962
+ constructor(store, baseGlobalConfig, locale_id, localeMapper, i18n, log) {
3963
+ super({ id: getLocaleId(locale_id) });
3964
+ this.store = store;
3965
+ this.baseGlobalConfig = baseGlobalConfig;
3966
+ this.locale_id = locale_id;
3967
+ this.localeMapper = localeMapper;
3968
+ this.i18n = i18n;
3969
+ this.log = log;
3970
+ this.subNotifier = new Subject();
3971
+ if (log) {
3972
+ this.logger = log.getLogger('core.LocaleService');
3973
+ }
3974
+ this.config = getLocaleServiceConfigFromBase(this.baseGlobalConfig);
3975
+ // in case no localeMapper provided, set the angular getLocaleId as default
3976
+ if (!this.localeMapper) {
3977
+ this.localeMapper = getLocaleId;
3978
+ }
3979
+ }
3980
+ ngOnDestroy() {
3981
+ this.subNotifier.next(void 0);
3982
+ this.subNotifier.complete();
3983
+ }
3984
+ getState() {
3985
+ return this.store.select(getLocaleState).pipe(takeUntil(this.subNotifier),
3986
+ // in case service didn't init fallback to LOCALE_ID token value
3987
+ map(state => state ? state : this.stateInstance ? this.stateInstance : this.locale_id));
3988
+ }
3989
+ init(state) {
3990
+ super.initEuiService();
3991
+ if (state) {
3992
+ this.stateInstance = state;
3993
+ }
3994
+ // bind language changes to locale changes
3995
+ if (this.config?.bindWithTranslate) {
3996
+ this.bindTranslateServiceLangChangeToState();
3997
+ }
3998
+ // dynamically load locale based on provided configuration
3999
+ const availableLocales = state?.available || this.config?.available || this.getBrowserLocales() || [this.currentLocale];
4000
+ return this.loadLocale(availableLocales).pipe(takeUntil(this.subNotifier), tap(() => this.updateState({ id: this.currentLocale })));
4001
+ }
4002
+ /**
4003
+ * dynamically load locale and update the state
4004
+ */
4005
+ updateState(state) {
4006
+ try {
4007
+ const id = getLocaleId(state.id);
4008
+ this.store.dispatch(new UpdateLocaleStateAction({ ...state, id }));
4009
+ // update global TOKEN ID based on configuration
4010
+ if (this.config.affectGlobalLocale) {
4011
+ this.locale_id = id;
4012
+ }
4013
+ }
4014
+ catch (e) {
4015
+ const message = `Locale for '${state.id}' is not available.
4016
+ Please use addLocale('${state.id}') first`;
4017
+ if (this.log) {
4018
+ this.logger.info(message, e);
4019
+ }
4020
+ throw new Error(message);
4021
+ }
4022
+ }
4023
+ addLocale(id) {
4024
+ return this.loadLocale(id);
4025
+ }
4026
+ get currentLocale() {
4027
+ return this.stateInstance.id;
4028
+ }
4029
+ /**
4030
+ * load and register locale data dynamically
4031
+ * @param locale array of locale to load
4032
+ */
4033
+ loadLocale(locale) {
4034
+ locale = Array.isArray(locale) ? locale : [locale];
4035
+ const localeImports = this.filterRegisteredLocales(locale).map(this.importDataAndExtraLocale.bind(this));
4036
+ // in case localeImports array is empty because locale exists, Observable still needs to complete
4037
+ if (localeImports.length < 1) {
4038
+ return of({ success: true });
4039
+ }
4040
+ return forkJoin(...localeImports).pipe(takeUntil(this.subNotifier), map(localeData => {
4041
+ // filter out null results and registerLocaleData including extra
4042
+ localeData.filter(({ data }) => data)
4043
+ .forEach(({ data, localeId, extraData }) => registerLocaleData(data, localeId, extraData));
4044
+ return { success: true };
4045
+ }), catchError(error => {
4046
+ if (this.log) {
4047
+ this.logger.debug(`Locale load error: ${error.message}`, error);
4048
+ }
4049
+ return of({ success: false, error: error });
4050
+ }));
4051
+ }
4052
+ /**
4053
+ * listen for language changes and dynamically set locale accordingly. In case of non registered locale register it
4054
+ * dynamically.
4055
+ */
4056
+ bindTranslateServiceLangChangeToState() {
4057
+ if (this.i18n) {
4058
+ this.i18n.onStateChange.pipe(takeUntil(this.subNotifier),
4059
+ // BEWARE: filter is based on convention that locale id sliced(2) will match activeLang e.g. en-US => en
4060
+ // Also, if activeLang is 'en' and locale is 'en-GB' it will not trigger locale change
4061
+ filter(state => state?.activeLang?.toLowerCase() !== this.stateInstance?.id.slice(0, 2).toLowerCase()),
4062
+ // to check if registration of locale otherwise register it
4063
+ switchMap(value => of(value).pipe(
4064
+ // getLocaleId may throw Error(`Missing locale data for the locale "${locale}".`);
4065
+ switchMap(i18state => {
4066
+ // check if activeLang is null or undefined
4067
+ if (!i18state.activeLang) {
4068
+ return throwError('Has i18nService initialized? If not make sure i18nService.init().subscribe(..)');
4069
+ }
4070
+ return of(this.localeMapper(i18state.activeLang));
4071
+ }), catchError(error => {
4072
+ if (this.log) {
4073
+ this.logger.debug(error);
4074
+ }
4075
+ return this.loadLocale(value.activeLang).pipe(filter((s) => s.success), map(() => this.localeMapper(value.activeLang)), catchError(e => {
4076
+ if (this.log) {
4077
+ this.logger.debug('Something went terribly really wrong during locale loading', e.err.message);
4078
+ }
4079
+ return of(e);
4080
+ }));
4081
+ }))),
4082
+ // update the "available" array attribute with newly registered
4083
+ switchMap(id => this.getState().pipe(take(1), map((state) => {
4084
+ const available = state?.available ? state.available : [];
4085
+ return { ...state, id, available: Array.from(new Set([...available, id])) };
4086
+ })))).subscribe((state) => {
4087
+ this.updateState(state);
4088
+ });
4089
+ }
4090
+ }
4091
+ /**
4092
+ * retrieve locales from browser
4093
+ * @param options
4094
+ */
4095
+ getBrowserLocales() {
4096
+ const browserLocales = navigator.languages === undefined ? [navigator.language] : navigator.languages;
4097
+ if (!browserLocales) {
4098
+ return undefined;
4099
+ }
4100
+ return browserLocales.map(locale => locale.trim());
4101
+ }
4102
+ /**
4103
+ * if locale is already registered filtered out.
4104
+ * @param locales A string array contains all locale id e.g. ["el", "el-CY"]
4105
+ */
4106
+ filterRegisteredLocales(locales) {
4107
+ return locales.filter((loc) => {
4108
+ try {
4109
+ getLocaleId(loc);
4110
+ return false;
4111
+ }
4112
+ catch (e) {
4113
+ return true;
4114
+ }
4115
+ });
4116
+ }
4117
+ /**
4118
+ * returns an Observable which loads the locale based on provided ID
4119
+ * @param id the locale id e.g. en, el-CY
4120
+ * @private
4121
+ */
4122
+ importLocale(id) {
4123
+ // in case of an error, catch it and return null
4124
+ return import(
4125
+ /* webpackIgnore: true */
4126
+ `@angular/common/locales/${id}`)
4127
+ .then(m => m.default)
4128
+ .catch(error => {
4129
+ if (this.log) {
4130
+ this.logger.debug(`Locale with ID: "${id}" failed to load. Error: ${error.message}`, error);
4131
+ }
4132
+ return null;
4133
+ });
4134
+ }
4135
+ /**
4136
+ * returns a Promise which loads the locale based on provided ID
4137
+ * @param id the locale id e.g. en, el-CY
4138
+ * @private
4139
+ */
4140
+ importExtraLocale(id) {
4141
+ // in case of an error, catch it and return null
4142
+ return import(
4143
+ /* webpackIgnore: true */
4144
+ `@angular/common/locales/extra/${id}`)
4145
+ .then(m => m.default)
4146
+ .catch(error => {
4147
+ if (this.log) {
4148
+ this.logger.debug(`Extra Locale with ID: "${id}" failed to load. Error: ${error.message}`, error);
4149
+ }
4150
+ return null;
4151
+ });
4152
+ }
4153
+ /**
4154
+ * Imports Locale and then Extra. It returns the Object which registerLocale(...) function needs.
4155
+ * @param localeId The id of the locale
4156
+ * @private
4157
+ */
4158
+ importDataAndExtraLocale(localeId) {
4159
+ return from(this.importLocale(localeId)).pipe(mergeMap(() => from(this.importExtraLocale(localeId)).pipe(map((data, extraData) => Object.assign({}, { data, localeId, extraData }))), 1));
4160
+ }
4161
+ }
4162
+ /** @nocollapse */ /** @nocollapse */ LocaleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocaleService, deps: [{ token: StoreService }, { token: GLOBAL_CONFIG_TOKEN }, { token: LOCALE_ID }, { token: LOCALE_ID_MAPPER, optional: true }, { token: I18nService, optional: true }, { token: LogService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
4163
+ /** @nocollapse */ /** @nocollapse */ LocaleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocaleService, providedIn: 'root' });
4164
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: LocaleService, decorators: [{
4165
+ type: Injectable,
4166
+ args: [{
4167
+ providedIn: 'root'
4168
+ }]
4169
+ }], ctorParameters: function () { return [{ type: StoreService }, { type: undefined, decorators: [{
4170
+ type: Inject,
4171
+ args: [GLOBAL_CONFIG_TOKEN]
4172
+ }] }, { type: undefined, decorators: [{
4173
+ type: Inject,
4174
+ args: [LOCALE_ID]
4175
+ }] }, { type: undefined, decorators: [{
4176
+ type: Optional
4177
+ }, {
4178
+ type: Inject,
4179
+ args: [LOCALE_ID_MAPPER]
4180
+ }] }, { type: I18nService, decorators: [{
4181
+ type: Optional
4182
+ }] }, { type: LogService, decorators: [{
4183
+ type: Optional
4184
+ }] }]; } });
4185
+
4186
+ // export const USER_API_CONFIG_TOKEN = new InjectionToken<UserApiConfig>('USER_API_CONFIG');
4187
+ // export const DEFAULT_USER_PREFERENCES_TOKEN = new InjectionToken<BaseUserPreferences>('DEFAULT_USER_PREFERENCES');
4188
+ class UserService extends EuiService {
4189
+ constructor(store) {
4190
+ super({ userId: 'annonymous' });
4191
+ this.store = store;
4192
+ }
4193
+ init(userState) {
4194
+ super.initEuiService();
4195
+ if (typeof userState === 'object' && userState.hasOwnProperty('userId')) {
4196
+ this.updateState(userState);
4197
+ return of({ success: true });
4198
+ }
4199
+ return of({ success: false, error: 'Init object should be instance of BaseUserState' });
4200
+ }
4201
+ getState(keyOrMapFn) {
4202
+ let selector = getUserState;
4203
+ if (keyOrMapFn) {
4204
+ switch (typeof keyOrMapFn) {
4205
+ case 'function':
4206
+ selector = createSelector(getUserState, keyOrMapFn);
4207
+ break;
4208
+ case 'string':
4209
+ selector = createSelector(getUserState, (state) => state[keyOrMapFn]);
4210
+ break;
4211
+ }
4212
+ }
4213
+ return this.store.select(selector);
4214
+ }
4215
+ updateState(userState) {
4216
+ this.store.dispatch(new UpdateUserStateAction(userState));
4217
+ }
4218
+ }
4219
+ /** @nocollapse */ /** @nocollapse */ UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserService, deps: [{ token: StoreService }], target: i0.ɵɵFactoryTarget.Injectable });
4220
+ /** @nocollapse */ /** @nocollapse */ UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserService, providedIn: 'root' });
4221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserService, decorators: [{
4222
+ type: Injectable,
4223
+ args: [{
4224
+ providedIn: 'root',
4225
+ }]
4226
+ }], ctorParameters: function () { return [{ type: StoreService }]; } });
4227
+
4228
+ class UserServiceMock extends UserService {
4229
+ constructor() {
4230
+ super(null);
4231
+ }
4232
+ loadUserDetails() {
4233
+ return of({ userId: 'anonymous' });
4234
+ }
4235
+ observePreferencesUpdate() {
4236
+ }
4237
+ loadUserPreferences() {
4238
+ return of({});
4239
+ }
4240
+ saveUserPreferences() {
4241
+ return of({});
4242
+ }
4243
+ mergeUserPreferences() {
4244
+ }
4245
+ userPreferences() {
4246
+ return of({});
4247
+ }
4248
+ getUserId() {
4249
+ return of('anonymous');
4250
+ }
4251
+ }
4252
+ /** @nocollapse */ /** @nocollapse */ UserServiceMock.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserServiceMock, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4253
+ /** @nocollapse */ /** @nocollapse */ UserServiceMock.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserServiceMock });
4254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UserServiceMock, decorators: [{
4255
+ type: Injectable
4256
+ }], ctorParameters: function () { return []; } });
4257
+
4258
+ const LANG_PARAM_KEY = 'X-Lang-Param';
4259
+ /**
4260
+ * Interceptor for adding the current language as parameter
4261
+ * Add the header (LANG_PARAM_KEY, <language parameter>) to your request http headers
4262
+ */
4263
+ class AddLangParamInterceptor {
4264
+ constructor(translateService) {
4265
+ this.translateService = translateService;
4266
+ }
4267
+ intercept(req, next) {
4268
+ // take the lang param name from header, if specified
4269
+ const langParam = req.headers.get(LANG_PARAM_KEY);
4270
+ // if not specified, do nothing
4271
+ if (!langParam) {
4272
+ return next.handle(req);
4273
+ }
4274
+ // take the current language from the translate service
4275
+ const langValue = this.translateService.currentLang;
4276
+ return next.handle(req.clone({
4277
+ // remove the lang param header from headers
4278
+ headers: req.headers.delete(LANG_PARAM_KEY),
4279
+ // set the lang value as new parameter
4280
+ params: req.params.set(langParam, langValue),
4281
+ }));
4282
+ }
4283
+ }
4284
+ /** @nocollapse */ /** @nocollapse */ AddLangParamInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: AddLangParamInterceptor, deps: [{ token: i2.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable });
4285
+ /** @nocollapse */ /** @nocollapse */ AddLangParamInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: AddLangParamInterceptor });
4286
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: AddLangParamInterceptor, decorators: [{
4287
+ type: Injectable
4288
+ }], ctorParameters: function () { return [{ type: i2.TranslateService }]; } });
4289
+
4290
+ class CachePreventionInterceptor {
4291
+ intercept(req, next) {
4292
+ // if Cache-Control is already specified
4293
+ if (req.headers.get('Cache-Control')) {
4294
+ // keep the current configuration
4295
+ return next.handle(req);
4296
+ }
4297
+ return next.handle(req.clone({
4298
+ // prevent the cache
4299
+ headers: req.headers.set('Cache-Control', 'No-Cache'),
4300
+ }));
4301
+ }
4302
+ }
4303
+ /** @nocollapse */ /** @nocollapse */ CachePreventionInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CachePreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4304
+ /** @nocollapse */ /** @nocollapse */ CachePreventionInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CachePreventionInterceptor });
4305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CachePreventionInterceptor, decorators: [{
4306
+ type: Injectable
4307
+ }] });
4308
+
4309
+ class CorsSecurityInterceptor {
4310
+ intercept(request, next) {
4311
+ return next.handle(request.clone({
4312
+ withCredentials: true
4313
+ }));
4314
+ }
4315
+ }
4316
+ /** @nocollapse */ /** @nocollapse */ CorsSecurityInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CorsSecurityInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4317
+ /** @nocollapse */ /** @nocollapse */ CorsSecurityInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CorsSecurityInterceptor });
4318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CorsSecurityInterceptor, decorators: [{
4319
+ type: Injectable
4320
+ }] });
4321
+
4322
+ class CsrfPreventionInterceptor {
4323
+ intercept(request, next) {
4324
+ return next.handle(request.clone({
4325
+ headers: request.headers.set('X-Requested-With', 'XMLHttpRequest'),
4326
+ }));
4327
+ }
4328
+ }
4329
+ /** @nocollapse */ /** @nocollapse */ CsrfPreventionInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CsrfPreventionInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4330
+ /** @nocollapse */ /** @nocollapse */ CsrfPreventionInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CsrfPreventionInterceptor });
4331
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CsrfPreventionInterceptor, decorators: [{
4332
+ type: Injectable
4333
+ }] });
4334
+
4335
+ // The EuLoginSessionTimeoutHandlingInterceptor assumes that the EU login client is configured with:
4336
+ // <redirectionInterceptor>eu.cec.digit.ecas.client.http.ajax.JsonAjaxRedirectionInterceptor</redirectionInterceptor>
4337
+ // WARNING: The default EU login client behaviour that provides the JSON-un-parsable login HTML page, is no longer supported!
4338
+ class EuLoginSessionTimeoutHandlingInterceptor {
4339
+ intercept(request, next) {
4340
+ return next.handle(request)
4341
+ .pipe(tap((event) => {
4342
+ this.checkRequestSuccessForEULoginSessionTimeout(request, event);
4343
+ return event;
4344
+ }, error => {
4345
+ this.checkRequestErrorForEULoginSessionTimeout(request, error);
4346
+ }));
4347
+ }
4348
+ checkRequestSuccessForEULoginSessionTimeout(request, event) {
4349
+ if (event instanceof HttpResponse) {
4350
+ if (this.isSsoResponse(event.body)) {
4351
+ this.reauthenticate(request, event);
4352
+ }
4353
+ }
4354
+ }
4355
+ checkRequestErrorForEULoginSessionTimeout(request, response) {
4356
+ // intentionally blank; meant for overriding
4357
+ }
4358
+ isSsoResponse(body) {
4359
+ if (body) {
4360
+ if (typeof body !== 'string') {
4361
+ return (body.success === false &&
4362
+ body.status === 'ECAS_AUTHENTICATION_REQUIRED' &&
4363
+ body.code === 303 &&
4364
+ body.message === 'session expired');
4365
+ }
4366
+ else {
4367
+ const html = body;
4368
+ return ((html.indexOf('<meta name="Keywords" content="EU Login, ECAS, Authentication, Security" />') >= 0 &&
4369
+ html.indexOf('<meta name="Description" content="EU Login" />') >= 0) ||
4370
+ html.indexOf('<meta name="Description" content="European Commission Authentication Service" />') >= 0 ||
4371
+ html.indexOf('<title>Mock Login Form</title>') >= 0 ||
4372
+ html.indexOf('<title>Redirecting To ECAS</title>') >= 0 ||
4373
+ html === '{ success : false, status : "ECAS_AUTHENTICATION_REQUIRED", code : 303, message : "session expired" }' ||
4374
+ html === '{ "success" : false, "status" : "ECAS_AUTHENTICATION_REQUIRED", "code" : 303, "message": "session expired" }');
4375
+ }
4376
+ }
4377
+ else {
4378
+ return false;
4379
+ }
4380
+ }
4381
+ reauthenticate(request, response) {
4382
+ // tslint:disable-next-line:deprecation
4383
+ document.location.reload();
4384
+ }
4385
+ }
4386
+ /** @nocollapse */ /** @nocollapse */ EuLoginSessionTimeoutHandlingInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4387
+ /** @nocollapse */ /** @nocollapse */ EuLoginSessionTimeoutHandlingInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor });
4388
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: EuLoginSessionTimeoutHandlingInterceptor, decorators: [{
4389
+ type: Injectable
4390
+ }] });
4391
+
4392
+ const UX_ERROR_MAPPING_HANDLER_TOKEN = new InjectionToken('UX_ERROR_MAPPING_HANDLER');
4393
+ class UxRequestErrorModelInterceptor {
4394
+ constructor(errorMappingHandler) {
4395
+ this.errorMappingHandler = errorMappingHandler;
4396
+ }
4397
+ intercept(req, next) {
4398
+ return next.handle(req)
4399
+ .pipe(catchError((err) => {
4400
+ if (this.errorMappingHandler) {
4401
+ if (err instanceof HttpErrorResponse) {
4402
+ err = transformToUxHttpResponse(err, this.errorMappingHandler);
4403
+ }
4404
+ }
4405
+ return of(err);
4406
+ }));
4407
+ }
4408
+ }
4409
+ /** @nocollapse */ /** @nocollapse */ UxRequestErrorModelInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxRequestErrorModelInterceptor, deps: [{ token: UX_ERROR_MAPPING_HANDLER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
4410
+ /** @nocollapse */ /** @nocollapse */ UxRequestErrorModelInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxRequestErrorModelInterceptor });
4411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: UxRequestErrorModelInterceptor, decorators: [{
4412
+ type: Injectable
4413
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
4414
+ type: Inject,
4415
+ args: [UX_ERROR_MAPPING_HANDLER_TOKEN]
4416
+ }] }]; } });
4417
+
4418
+ class OpenIdConnectInterceptor {
4419
+ constructor() {
4420
+ // By default, the original request should at least be retries once in case the cached API Gateway token expires:
4421
+ this.defaultMaximumRequestRetries = 1;
4422
+ // check if the OpenIdConnect is defined
4423
+ if (typeof OpenIdConnect === 'undefined') {
4424
+ console.error('Please include the script openid-login.js in your index.html file.', 'For more details, please consult the documentation regarding the Http Interceptors and OpenID Connect configuration.');
4425
+ }
4426
+ }
4427
+ intercept(request, next, retryCount = 0, retryCallback) {
4428
+ if (typeof OpenIdConnect !== 'undefined') {
4429
+ let authorizedRequest = retryCallback;
4430
+ if (!authorizedRequest) {
4431
+ authorizedRequest = new Subject();
4432
+ }
4433
+ OpenIdConnect.getAuthorizationHeaders(request.urlWithParams, (headers) => {
4434
+ let newRequest = request;
4435
+ if (headers) {
4436
+ let newHeaders = request.headers;
4437
+ if (newHeaders) {
4438
+ for (const headerName in headers) {
4439
+ if (headers.hasOwnProperty(headerName)) {
4440
+ newHeaders = newHeaders.set(headerName, headers[headerName]);
4441
+ }
4442
+ }
4443
+ }
4444
+ else {
4445
+ newHeaders = new HttpHeaders(headers);
4446
+ }
4447
+ newRequest = request.clone({
4448
+ withCredentials: false,
4449
+ headers: newHeaders,
4450
+ });
4451
+ }
4452
+ const subscription = next.handle(newRequest)
4453
+ .pipe(catchError((response) => {
4454
+ return this.handleErrorResponse(response, request, next, retryCount, authorizedRequest, subscription);
4455
+ }))
4456
+ .subscribe((httpEvent) => {
4457
+ if (httpEvent) {
4458
+ authorizedRequest.next(httpEvent);
4459
+ if (httpEvent.type === HttpEventType.Response) {
4460
+ if (subscription) {
4461
+ subscription.unsubscribe();
4462
+ }
4463
+ authorizedRequest.complete();
4464
+ }
4465
+ }
4466
+ });
4467
+ }, (errorResponse) => {
4468
+ const errorProperties = {
4469
+ error: errorResponse,
4470
+ };
4471
+ if (errorResponse) {
4472
+ errorProperties.status = errorResponse.status;
4473
+ errorProperties.statusText = errorResponse.statusText;
4474
+ }
4475
+ return this.handleErrorResponse(new HttpErrorResponse(errorProperties), request, next, retryCount, authorizedRequest, null);
4476
+ });
4477
+ return authorizedRequest;
4478
+ }
4479
+ else {
4480
+ return next.handle(request);
4481
+ }
4482
+ }
4483
+ handleErrorResponse(response, originalRequest, next, retryCount = 0, retryCallback, subscription) {
4484
+ if (response) {
4485
+ if (response.error && response.error.error === 'invalid_request') {
4486
+ // The ID token is invalid or incorrect; retrieve another one:
4487
+ OpenIdConnect.renewIdToken();
4488
+ }
4489
+ else if (this.apiGatewayTokenExpired(response)) {
4490
+ OpenIdConnect.clearCachedApiGatewayAccessToken();
4491
+ return this.retryRequest(originalRequest, response, next, retryCount, retryCallback, subscription);
4492
+ }
4493
+ else if (response.status === 401 || response.status === 403) {
4494
+ // The EU Login access token is invalid. (403)
4495
+ // The target service is unable to read the access token, for example because the EU Login session ended. (401)
4496
+ // Retry in case the access token became invalid too quickly:
4497
+ return this.retryRequest(originalRequest, response, next, retryCount, retryCallback, subscription);
4498
+ }
4499
+ else if (response.status === 0) {
4500
+ // One of the access token requests or the original request was not sent.
4501
+ // Most likely one of the CORS pre-flight requests failed, or the browser is offline.
4502
+ console.warn('The OpenID Connect call may have issues:\n' +
4503
+ '* the CORS pre-flight requests for the OpenID Connect access tokens or for the REST call could be failing\n' +
4504
+ '* the browser could be currently offline.');
4505
+ }
4506
+ }
4507
+ if (subscription) {
4508
+ subscription.unsubscribe();
4509
+ }
4510
+ if (retryCallback) {
4511
+ retryCallback.error(response);
4512
+ retryCallback.complete();
4513
+ }
4514
+ return throwError(response);
4515
+ }
4516
+ retryRequest(originalRequest, response, next, retryCount = 0, retryCallback, subscription) {
4517
+ if (retryCount < this.maximumRequestRetries()) {
4518
+ this.intercept(originalRequest, next, retryCount + 1, retryCallback);
4519
+ }
4520
+ else {
4521
+ console.error('The OpenID Connect call may have issues:\n' +
4522
+ '* the client ID could be invalid\n' +
4523
+ '* the API Gateway access token could be invalid\n' +
4524
+ '* the EU Login access token for the target service could be invalid.');
4525
+ if (subscription) {
4526
+ subscription.unsubscribe();
4527
+ }
4528
+ if (retryCallback) {
4529
+ retryCallback.error(response);
4530
+ retryCallback.complete();
4531
+ }
4532
+ }
4533
+ return of(null);
4534
+ }
4535
+ apiGatewayTokenExpired(response) {
4536
+ if (response && response.status === 401) {
4537
+ const message = '' + response.error;
4538
+ return message.indexOf('<ams:code>900901</ams:code>') >= 0;
4539
+ }
4540
+ else {
4541
+ return false;
4542
+ }
4543
+ }
4544
+ maximumRequestRetries() {
4545
+ if (OpenIdConnect.config && OpenIdConnect.config.maximumRequestRetries >= 0) {
4546
+ return OpenIdConnect.config.maximumRequestRetries;
4547
+ }
4548
+ else {
4549
+ return this.defaultMaximumRequestRetries;
4550
+ }
4551
+ }
4552
+ }
4553
+ /** @nocollapse */ /** @nocollapse */ OpenIdConnectInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4554
+ /** @nocollapse */ /** @nocollapse */ OpenIdConnectInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectInterceptor });
4555
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectInterceptor, decorators: [{
4556
+ type: Injectable
4557
+ }], ctorParameters: function () { return []; } });
4558
+
4559
+ class OpenIdConnectService {
4560
+ getUserDetails() {
4561
+ if (OpenIdConnect) {
4562
+ const detailsString = sessionStorage.getItem(OpenIdConnect.SESSION_STORAGE_KEY_USER_DETAILS);
4563
+ return detailsString ? JSON.parse(detailsString) : null;
4564
+ }
4565
+ else {
4566
+ return null;
4567
+ }
4568
+ }
4569
+ }
4570
+ /** @nocollapse */ /** @nocollapse */ OpenIdConnectService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4571
+ /** @nocollapse */ /** @nocollapse */ OpenIdConnectService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectService, providedIn: 'root' });
4572
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: OpenIdConnectService, decorators: [{
4573
+ type: Injectable,
4574
+ args: [{
4575
+ providedIn: 'root'
4576
+ }]
4577
+ }] });
4578
+
4579
+ class OpenIdConnectServiceMock extends OpenIdConnectService {
4580
+ getUserDetails() {
4581
+ return null;
4582
+ }
4583
+ }
4584
+
4585
+ /* BASE PACKAGE */
4586
+
4587
+ /**
4588
+ * Generated bundle index. Do not edit.
4589
+ */
4590
+
4591
+ export { ActivatedRouteAction, AddApiQueueItemAction, AddAppLoadedConfigModulesAction, AddLangParamInterceptor, AlertHttpErrorCallbackFn, ApiQueueService, ApiQueueServiceMock, AsyncStorageService, AsyncStorageServiceMock, BASE_LOGGER_NAME_TOKEN, BASE_NAME_TOKEN, BrowserStorageType, CONFIG_TOKEN, CORE_ROOT_GUARD, CachePreventionInterceptor, ConsoleHttpErrorCallbackFn, CoreAppActionTypes, CoreAppEffects, CoreI18nActionTypes, CoreLocaleActionTypes, CoreModule, CoreModuleEffects, CoreNotificationsActionTypes, CoreUserActionTypes, CorsSecurityInterceptor, CsrfPreventionInterceptor, DYNAMIC_COMPONENT_CONFIG, EUI_CONFIG_TOKEN, EmptyApiQueueAction, ErrorSubClass, EuLoginSessionTimeoutHandlingInterceptor, EuiCoreRootGuardClass, EuiError, EuiPermissionService, GLOBAL_CONFIG_TOKEN, GlobalErrorHandler, GrowlHttpErrorCallbackFn, HTTP_ERROR_HANDLER_CONFIG_TOKEN, HttpErrorHandlerInterceptor, I18nLoader, I18nResourceImpl, I18nService, I18nServiceMock, InitStoreAction, LANG_PARAM_KEY, LOCALE_ID_MAPPER, LOCAL_FORAGE_SERVICE_CONFIG_TOKEN, LOG_APPENDERS_TOKEN, LOG_LEVEL_TOKEN, LocalForageService, LocalStorageService, LocaleService, LogHttpErrorCallbackFn, LogModule, LogService, LogServiceMock, MODULE_CONFIG_TOKEN, MODULE_NAME_TOKEN, OpenIdConnectInterceptor, OpenIdConnectService, OpenIdConnectServiceMock, ROOT_LOG_CONFIG_TOKEN, RemoveApiQueueItemAction, SHOW_CONNECTION_STATUS_TOKEN, SessionStorageService, StorageService, StorageServiceMock, StoreService, StoreServiceMock, UX_COUNTRIES, UX_ERROR_MAPPING_HANDLER_TOKEN, UX_TIMEZONES, UpdateAppConnectionAction, UpdateAppStatusAction, UpdateAppVersionAction, UpdateCurrentModuleAction, UpdateI18nStateAction, UpdateLocaleStateAction, UpdateNotificationsListAction, UpdateUserDashboardAction, UpdateUserDetailsAction, UpdateUserPreferencesAction, UpdateUserRightsAction, UpdateUserStateAction, UserService, UserServiceMock, UxAppShellService, UxDynamicComponentService, UxDynamicMenuService, UxErrorFeedbackService, UxErrorManager, UxRequestErrorModelInterceptor, UxTimezoneService, closestMatchingParent, consumeEvent, corI18nReducers, coreAppReducers, coreLocaleReducers, coreNotificationsReducers, coreUserReducers, createEuiCoreRootGuard, diffDays, diffDaysFromToday, errorCodes, euiCoreRootGuardClass, formatNumber, getGlobalConfig, getHttpErrorHandlingConfig, getModuleConfig, getRootLogConfig, getShowConnectionStatus, getViewElement, handleError, isDefined, loadEuiDynamicEnvironmentConfig, loadState, localForage, localStorageSync, markControlsTouched, markFormGroupTouched, mergeAppHandlerConfigToAppConfig, mergeAppJsonConfigToAppConfig, offset, position, preInitApp, prepareEuiAppConfigToken, coreReducers as reducers, sessionStorageSync, translateConfig, uniqueId, validateEmail, withUxErrorManager };
4592
+ //# sourceMappingURL=eui-core.mjs.map