@eui/core 16.0.0-next.1 → 16.0.0-next.3

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