@sunbird-cb/utils 1.0.9 → 1.0.12

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.
@@ -1,20 +1,20 @@
1
- import { __assign, __values, __read, __awaiter, __generator } from 'tslib';
1
+ import { __assign, __awaiter, __generator, __values, __read } from 'tslib';
2
2
  import { Injectable, ɵɵdefineInjectable, ɵɵinject, EventEmitter, Component, Inject, Output, NgModule, Directive, Input, HostBinding, HostListener, ElementRef, ViewChild, Pipe, LOCALE_ID } from '@angular/core';
3
3
  import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
4
4
  import { MatSnackBar } from '@angular/material/snack-bar';
5
5
  import { BehaviorSubject, ReplaySubject, fromEvent, timer, of, forkJoin, Subject } from 'rxjs';
6
6
  import { Breakpoints, BreakpointObserver } from '@angular/cdk/layout';
7
- import { map, debounceTime, distinctUntilChanged, throttleTime, catchError, mergeMap, filter, retry } from 'rxjs/operators';
7
+ import { map, debounceTime, distinctUntilChanged, throttleTime, filter, catchError, mergeMap, retry } from 'rxjs/operators';
8
8
  import { CommonModule } from '@angular/common';
9
9
  import { MatIconModule, MatButtonModule, MatDialogModule, MatToolbarModule, MatCardModule, MatTooltipModule, MatSliderModule, MatProgressSpinnerModule, MatDialogRef as MatDialogRef$1 } from '@angular/material';
10
10
  import { ImageCropperModule } from 'ngx-image-cropper';
11
- import { NavigationEnd, Router, ActivatedRoute } from '@angular/router';
12
- import { Platform } from '@angular/cdk/platform';
13
11
  import { HttpClient } from '@angular/common/http';
12
+ import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
13
+ import { Platform } from '@angular/cdk/platform';
14
+ import { NavigationEnd, Router, ActivatedRoute } from '@angular/router';
14
15
  import moment from 'moment';
15
16
  import _, { orderBy } from 'lodash';
16
17
  import { DomSanitizer } from '@angular/platform-browser';
17
- import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
18
18
 
19
19
  var ConfigurationsService = (function () {
20
20
  function ConfigurationsService() {
@@ -1486,1771 +1486,1783 @@ var HorizontalScrollerModule = (function () {
1486
1486
  return HorizontalScrollerModule;
1487
1487
  }());
1488
1488
 
1489
- function IWindowMobileAppModified() { }
1490
- if (false) {
1491
- IWindowMobileAppModified.prototype.appRef;
1492
- IWindowMobileAppModified.prototype.webkit;
1493
- }
1494
- var RANDOM_ID_PER_USER = 0;
1495
- function IRecursiveData() { }
1496
- if (false) {
1497
- IRecursiveData.prototype.identifier;
1498
- IRecursiveData.prototype.children;
1499
- }
1500
- var UtilityService = (function () {
1501
- function UtilityService(http, platform, router, route) {
1502
- var _this = this;
1503
- this.http = http;
1504
- this.platform = platform;
1505
- this.router = router;
1506
- this.route = route;
1507
- this.currentRouteData = [];
1508
- this.router.events.subscribe((function (event) {
1509
- if (event instanceof NavigationEnd) {
1510
- var snapshot = _this.route.snapshot;
1511
- var firstChild = snapshot.root.firstChild;
1512
- _this.getChildRouteData(snapshot, firstChild);
1513
- }
1514
- }));
1489
+ var LoggerService = (function () {
1490
+ function LoggerService(configSvc) {
1491
+ this.configSvc = configSvc;
1492
+ this.consoleError = console.error;
1493
+ this.consoleInfo = console.info;
1494
+ this.consoleLog = console.log;
1495
+ this.consoleWarn = console.warn;
1496
+ this.noConsole = (function () { });
1515
1497
  }
1516
- UtilityService.prototype.getChildRouteData = function (snapshot, firstChild) {
1517
- if (firstChild) {
1518
- if (firstChild.data) {
1519
- this.currentRouteData.push(firstChild.data);
1520
- }
1521
- if (firstChild.firstChild) {
1522
- this.getChildRouteData(snapshot, firstChild.firstChild);
1523
- }
1524
- }
1525
- };
1526
- Object.defineProperty(UtilityService.prototype, "randomId", {
1527
- get: function () {
1528
- return RANDOM_ID_PER_USER + 1;
1529
- },
1530
- enumerable: true,
1531
- configurable: true
1532
- });
1533
- UtilityService.prototype.getJson = function (url) {
1534
- return this.http.get(url);
1535
- };
1536
- UtilityService.prototype.getLeafNodes = function (node, nodes) {
1537
- var _this = this;
1538
- if ((node.children || []).length === 0) {
1539
- nodes.push(node);
1540
- }
1541
- else {
1542
- if (node.children) {
1543
- node.children.forEach((function (child) {
1544
- _this.getLeafNodes(child, nodes);
1545
- }));
1546
- }
1547
- }
1548
- return nodes;
1549
- };
1550
- UtilityService.prototype.getPath = function (node, id) {
1551
- var path = [];
1552
- this.hasPath(node, path, id);
1553
- return path;
1554
- };
1555
- UtilityService.prototype.hasPath = function (node, pathArr, id) {
1556
- var _this = this;
1557
- if (node == null) {
1558
- return false;
1559
- }
1560
- pathArr.push(node);
1561
- if (node.identifier === id) {
1562
- return true;
1563
- }
1564
- var children = node.children || [];
1565
- if (children.some((function (u) { return _this.hasPath(u, pathArr, id); }))) {
1566
- return true;
1567
- }
1568
- pathArr.pop();
1569
- return false;
1570
- };
1571
- Object.defineProperty(UtilityService.prototype, "isMobile", {
1572
- get: function () {
1573
- if (this.isIos || this.isAndroid) {
1574
- return true;
1575
- }
1576
- return false;
1577
- },
1578
- enumerable: true,
1579
- configurable: true
1580
- });
1581
- Object.defineProperty(UtilityService.prototype, "isIos", {
1498
+ Object.defineProperty(LoggerService.prototype, "error", {
1582
1499
  get: function () {
1583
- return this.platform.IOS;
1500
+ return this.consoleError;
1584
1501
  },
1585
1502
  enumerable: true,
1586
1503
  configurable: true
1587
1504
  });
1588
- Object.defineProperty(UtilityService.prototype, "isAndroid", {
1505
+ Object.defineProperty(LoggerService.prototype, "info", {
1589
1506
  get: function () {
1590
- return this.platform.ANDROID;
1507
+ return this.configSvc.isProduction ? this.noConsole : this.consoleInfo;
1591
1508
  },
1592
1509
  enumerable: true,
1593
1510
  configurable: true
1594
1511
  });
1595
- Object.defineProperty(UtilityService.prototype, "isAndroidApp", {
1512
+ Object.defineProperty(LoggerService.prototype, "log", {
1596
1513
  get: function () {
1597
- return Boolean(window.appRef);
1514
+ return this.configSvc.isProduction ? this.noConsole : this.consoleLog;
1598
1515
  },
1599
1516
  enumerable: true,
1600
1517
  configurable: true
1601
1518
  });
1602
- Object.defineProperty(UtilityService.prototype, "iOsAppRef", {
1519
+ Object.defineProperty(LoggerService.prototype, "warn", {
1603
1520
  get: function () {
1604
- if (window.webkit &&
1605
- window.webkit.messageHandlers &&
1606
- window.webkit.messageHandlers.appRef) {
1607
- return window.webkit.messageHandlers.appRef;
1608
- }
1609
- return null;
1521
+ return this.configSvc.isProduction ? this.noConsole : this.consoleWarn;
1610
1522
  },
1611
1523
  enumerable: true,
1612
1524
  configurable: true
1613
1525
  });
1614
- UtilityService.prototype.setRouteData = function (data) {
1615
- this.currentRouteData = data;
1526
+ LoggerService.prototype.removeConsoleAccess = function () {
1527
+ if (this.configSvc.isProduction) {
1528
+ return;
1529
+ }
1530
+ var noConsoleWithError = (function () {
1531
+ throw new Error('Console Functions Usage Are Not Allowed.');
1532
+ });
1533
+ console.warn = noConsoleWithError;
1534
+ console.info = noConsoleWithError;
1535
+ console.error = noConsoleWithError;
1616
1536
  };
1617
- Object.defineProperty(UtilityService.prototype, "routeData", {
1618
- get: function () {
1619
- var data = {
1620
- module: '',
1621
- pageId: '',
1622
- };
1623
- this.currentRouteData.map((function (rd) {
1624
- if (rd.pageId) {
1625
- data.pageId = data.pageId + "/" + rd.pageId;
1626
- }
1627
- if (rd.module) {
1628
- data.module = rd.module;
1629
- }
1630
- }));
1631
- return data;
1632
- },
1633
- enumerable: true,
1634
- configurable: true
1635
- });
1636
- UtilityService.decorators = [
1537
+ LoggerService.decorators = [
1637
1538
  { type: Injectable, args: [{
1638
1539
  providedIn: 'root',
1639
1540
  },] }
1640
1541
  ];
1641
- UtilityService.ctorParameters = function () { return [
1642
- { type: HttpClient },
1643
- { type: Platform },
1644
- { type: Router },
1645
- { type: ActivatedRoute }
1542
+ LoggerService.ctorParameters = function () { return [
1543
+ { type: ConfigurationsService }
1646
1544
  ]; };
1647
- /** @nocollapse */ UtilityService.ngInjectableDef = ɵɵdefineInjectable({ factory: function UtilityService_Factory() { return new UtilityService(ɵɵinject(HttpClient), ɵɵinject(Platform), ɵɵinject(Router), ɵɵinject(ActivatedRoute)); }, token: UtilityService, providedIn: "root" });
1648
- return UtilityService;
1545
+ /** @nocollapse */ LoggerService.ngInjectableDef = ɵɵdefineInjectable({ factory: function LoggerService_Factory() { return new LoggerService(ɵɵinject(ConfigurationsService)); }, token: LoggerService, providedIn: "root" });
1546
+ return LoggerService;
1649
1547
  }());
1650
1548
  if (false) {
1651
- UtilityService.prototype.currentRouteData;
1652
- UtilityService.prototype.http;
1653
- UtilityService.prototype.platform;
1654
- UtilityService.prototype.router;
1655
- UtilityService.prototype.route;
1549
+ LoggerService.prototype.consoleError;
1550
+ LoggerService.prototype.consoleInfo;
1551
+ LoggerService.prototype.consoleLog;
1552
+ LoggerService.prototype.consoleWarn;
1553
+ LoggerService.prototype.noConsole;
1554
+ LoggerService.prototype.configSvc;
1656
1555
  }
1657
1556
 
1658
- var LogoutComponent = (function () {
1659
- function LogoutComponent(dialogRef, configSvc, utilitySvc, router) {
1660
- this.dialogRef = dialogRef;
1661
- this.configSvc = configSvc;
1662
- this.utilitySvc = utilitySvc;
1663
- this.router = router;
1664
- this.disabled = false;
1665
- this.isDownloadableIos = false;
1666
- this.isDownloadableAndroid = false;
1557
+ var msTokenExpiryDuration = 600;
1558
+ var storageKey = 'msLoginRequested';
1559
+ var storage = localStorage;
1560
+ var API_ENDPOINTS = {
1561
+ sharePointToken: '/apis/protected/v8/user/token',
1562
+ };
1563
+ var AuthMicrosoftService = (function () {
1564
+ function AuthMicrosoftService(loggerSvc, http) {
1565
+ this.loggerSvc = loggerSvc;
1566
+ this.http = http;
1567
+ this.msConfig = {
1568
+ clientId: '',
1569
+ tenant: '',
1570
+ defaultEmailId: '',
1571
+ validEmailExtensions: [],
1572
+ isConfigured: false,
1573
+ };
1574
+ this.emailUsed = null;
1575
+ this.code = null;
1576
+ this.msToken = {
1577
+ accessToken: '',
1578
+ expiresOn: '',
1579
+ resource: '',
1580
+ tokenType: '',
1581
+ };
1667
1582
  }
1668
- LogoutComponent.prototype.ngOnInit = function () {
1669
- if (this.configSvc.restrictedFeatures) {
1670
- this.isDownloadableIos = !this.configSvc.restrictedFeatures.has('iosDownload');
1671
- this.isDownloadableAndroid = !this.configSvc.restrictedFeatures.has('androidDownload');
1672
- }
1673
- };
1674
- LogoutComponent.prototype.confirmed = function () {
1675
- this.disabled = true;
1676
- this.dialogRef.close();
1677
- this.router.navigate(['public', 'logout']);
1678
- };
1679
- Object.defineProperty(LogoutComponent.prototype, "isDownloadable", {
1583
+ Object.defineProperty(AuthMicrosoftService.prototype, "isLogoutRequired", {
1680
1584
  get: function () {
1681
- if (this.configSvc.instanceConfig && this.configSvc.instanceConfig.isContentDownloadAvailable &&
1682
- (this.utilitySvc.iOsAppRef || this.utilitySvc.isAndroidApp)) {
1683
- return true;
1585
+ return Boolean(this.msConfig.isConfigured && this.msConfig.clientId && this.emailUsed);
1586
+ },
1587
+ enumerable: true,
1588
+ configurable: true
1589
+ });
1590
+ Object.defineProperty(AuthMicrosoftService.prototype, "loginUrl", {
1591
+ get: function () {
1592
+ if (this.msConfig.isConfigured && this.msConfig.clientId) {
1593
+ var base = 'https://login.windows.net/common/oauth2/authorize';
1594
+ var searchParam = new URLSearchParams({
1595
+ response_type: 'code',
1596
+ client_id: this.msConfig.clientId,
1597
+ redirect_uri: window.location.href,
1598
+ });
1599
+ var fragment = location.search.substring(1);
1600
+ if (fragment) {
1601
+ return base + "?" + searchParam.toString() + "#" + fragment;
1602
+ }
1603
+ return base + "?" + searchParam.toString();
1684
1604
  }
1685
- return false;
1605
+ return null;
1686
1606
  },
1687
1607
  enumerable: true,
1688
1608
  configurable: true
1689
1609
  });
1690
- LogoutComponent.decorators = [
1691
- { type: Component, args: [{
1692
- selector: 'ws-utils-logout',
1693
- template: "<h1 mat-dialog-title i18n>Logout Now</h1>\r\n<div class=\"ws-mat-primary-text text-base pb-2 title-text\" *ngIf=\"isDownloadable\" i18n>\r\n Note: On logging out all the downloaded content will be deleted.\r\n</div>\r\n<div mat-dialog-content class=\"text-base hide-overflow\" i18n>\r\n Are you sure?\r\n</div>\r\n<div mat-dialog-actions class=\"flex-row-reverse\">\r\n <button mat-flat-button color=\"warn\" [disabled]=\"disabled\" (click)=\"confirmed()\" i18n>\r\n Yes\r\n </button>\r\n <button mat-button class=\"margin-right-xs\" [mat-dialog-close] cdkFocusInitial i18n>No</button>\r\n</div>",
1694
- styles: [".hide-overflow{overflow:hidden}"]
1695
- }] }
1610
+ AuthMicrosoftService.prototype.logoutUrl = function (redirectUrl) {
1611
+ if (this.isValidEmail(this.emailUsed || '')) {
1612
+ return "https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=" + redirectUrl;
1613
+ }
1614
+ return redirectUrl;
1615
+ };
1616
+ AuthMicrosoftService.prototype.init = function (config) {
1617
+ return __awaiter(this, void 0, void 0, function () {
1618
+ var queryParams, url;
1619
+ return __generator(this, function (_a) {
1620
+ switch (_a.label) {
1621
+ case 0:
1622
+ if (!config || !config.microsoft || !config.microsoft.isConfigured) {
1623
+ this.loggerSvc.warn('Empty/No Configuration passed, ignoring Microsoft Authentication');
1624
+ }
1625
+ this.msConfig = config.microsoft;
1626
+ queryParams = new URLSearchParams(location.search);
1627
+ if (!(queryParams.has('code') && queryParams.has('session_state'))) return [3, 2];
1628
+ this.code = queryParams.get('code');
1629
+ if (!this.code) {
1630
+ return [2];
1631
+ }
1632
+ url = location.origin + location.pathname;
1633
+ return [4, this.exchangeTokenForCode(this.code, url)];
1634
+ case 1:
1635
+ _a.sent();
1636
+ if (location.hash) {
1637
+ url += location.hash.substring(1);
1638
+ }
1639
+ history.replaceState(null, '', url);
1640
+ _a.label = 2;
1641
+ case 2: return [2];
1642
+ }
1643
+ });
1644
+ });
1645
+ };
1646
+ AuthMicrosoftService.prototype.login = function (email) {
1647
+ return __awaiter(this, void 0, void 0, function () {
1648
+ var loginUrl;
1649
+ return __generator(this, function (_a) {
1650
+ if (!this.isValidEmail(email)) {
1651
+ this.loggerSvc.warn("Microsoft Login is not allowed for your emailId (" + email + ")");
1652
+ return [2];
1653
+ }
1654
+ loginUrl = this.loginUrl;
1655
+ if (loginUrl) {
1656
+ location.assign(loginUrl);
1657
+ }
1658
+ else {
1659
+ this.loggerSvc.warn('Unable to identify Office Login URL, Ignoring login request');
1660
+ }
1661
+ return [2];
1662
+ });
1663
+ });
1664
+ };
1665
+ AuthMicrosoftService.prototype.getToken = function (email) {
1666
+ return __awaiter(this, void 0, void 0, function () {
1667
+ var _a, error_1, _b, error_2;
1668
+ return __generator(this, function (_c) {
1669
+ switch (_c.label) {
1670
+ case 0:
1671
+ if (this.msToken &&
1672
+ this.isValid(this.msToken.accessToken, this.msToken.expiresOn) &&
1673
+ this.msToken.accessToken) {
1674
+ return [2, this.msToken.accessToken];
1675
+ }
1676
+ if (!this.isValidEmail(email)) return [3, 4];
1677
+ _c.label = 1;
1678
+ case 1:
1679
+ _c.trys.push([1, 3, , 4]);
1680
+ _a = this;
1681
+ return [4, this.getTokenForEmail(email)];
1682
+ case 2:
1683
+ _a.msToken = _c.sent();
1684
+ if (this.msToken.accessToken) {
1685
+ this.emailUsed = email;
1686
+ return [2, this.msToken.accessToken];
1687
+ }
1688
+ return [3, 4];
1689
+ case 3:
1690
+ error_1 = _c.sent();
1691
+ if (!this.code) {
1692
+ this.login(email);
1693
+ }
1694
+ return [3, 4];
1695
+ case 4:
1696
+ if (!(this.msConfig.defaultEmailId && this.isValidEmail(this.msConfig.defaultEmailId))) return [3, 8];
1697
+ _c.label = 5;
1698
+ case 5:
1699
+ _c.trys.push([5, 7, , 8]);
1700
+ _b = this;
1701
+ return [4, this.getTokenForEmail(this.msConfig.defaultEmailId)];
1702
+ case 6:
1703
+ _b.msToken = _c.sent();
1704
+ if (this.msToken.accessToken) {
1705
+ this.emailUsed = this.msConfig.defaultEmailId;
1706
+ return [2, this.msToken.accessToken];
1707
+ }
1708
+ return [3, 8];
1709
+ case 7:
1710
+ error_2 = _c.sent();
1711
+ return [3, 8];
1712
+ case 8: throw new Error('UNABLE TO FETCH MS AUTH TOKEN');
1713
+ }
1714
+ });
1715
+ });
1716
+ };
1717
+ AuthMicrosoftService.prototype.loginForSSOEnabledEmbed = function (email) {
1718
+ if (!this.isValidEmail(email)) {
1719
+ this.loggerSvc.warn('SSO Login request Ignored. Invalid Email Id for SSO Enabled Content');
1720
+ }
1721
+ var msPrevTS = 0;
1722
+ try {
1723
+ msPrevTS = parseInt(storage.getItem(storageKey) || '0', 10);
1724
+ }
1725
+ catch (error) { }
1726
+ if (!msPrevTS || (msPrevTS && (Date.now() - msPrevTS) / 1000 > msTokenExpiryDuration)) {
1727
+ this.loggerSvc.info("last login exceeded " + msTokenExpiryDuration + " duration. Redirecting to O365 login");
1728
+ storage.setItem(storageKey, Date.now().toString());
1729
+ this.login(email);
1730
+ }
1731
+ };
1732
+ AuthMicrosoftService.prototype.isValidEmail = function (email) {
1733
+ return this.msConfig.validEmailExtensions.some((function (ext) { return email.endsWith(ext); }));
1734
+ };
1735
+ AuthMicrosoftService.prototype.isValid = function (accessToken, expiresOn) {
1736
+ if (accessToken && expiresOn) {
1737
+ return true;
1738
+ }
1739
+ return false;
1740
+ };
1741
+ AuthMicrosoftService.prototype.exchangeTokenForCode = function (code, redirectUrl) {
1742
+ return __awaiter(this, void 0, void 0, function () {
1743
+ var response;
1744
+ return __generator(this, function (_a) {
1745
+ switch (_a.label) {
1746
+ case 0: return [4, this.http
1747
+ .get(API_ENDPOINTS + "?code=" + code + "&redirectUrl=" + redirectUrl)
1748
+ .toPromise()];
1749
+ case 1:
1750
+ response = _a.sent();
1751
+ return [2, this.getInstanceFromResponse(response)];
1752
+ }
1753
+ });
1754
+ });
1755
+ };
1756
+ AuthMicrosoftService.prototype.getTokenForEmail = function (email) {
1757
+ return __awaiter(this, void 0, void 0, function () {
1758
+ var response;
1759
+ return __generator(this, function (_a) {
1760
+ switch (_a.label) {
1761
+ case 0: return [4, this.http
1762
+ .get(API_ENDPOINTS.sharePointToken + "?email=" + email)
1763
+ .toPromise()];
1764
+ case 1:
1765
+ response = _a.sent();
1766
+ return [2, this.getInstanceFromResponse(response)];
1767
+ }
1768
+ });
1769
+ });
1770
+ };
1771
+ AuthMicrosoftService.prototype.getInstanceFromResponse = function (token) {
1772
+ return {
1773
+ accessToken: token.accessToken,
1774
+ expiresOn: token.expiresOn,
1775
+ resource: token.resource,
1776
+ tokenType: token.tokenType,
1777
+ };
1778
+ };
1779
+ AuthMicrosoftService.decorators = [
1780
+ { type: Injectable, args: [{
1781
+ providedIn: 'root',
1782
+ },] }
1696
1783
  ];
1697
- LogoutComponent.ctorParameters = function () { return [
1698
- { type: MatDialogRef$1 },
1699
- { type: ConfigurationsService },
1700
- { type: UtilityService },
1701
- { type: Router }
1784
+ AuthMicrosoftService.ctorParameters = function () { return [
1785
+ { type: LoggerService },
1786
+ { type: HttpClient }
1702
1787
  ]; };
1703
- return LogoutComponent;
1788
+ /** @nocollapse */ AuthMicrosoftService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthMicrosoftService_Factory() { return new AuthMicrosoftService(ɵɵinject(LoggerService), ɵɵinject(HttpClient)); }, token: AuthMicrosoftService, providedIn: "root" });
1789
+ return AuthMicrosoftService;
1704
1790
  }());
1705
1791
  if (false) {
1706
- LogoutComponent.prototype.disabled;
1707
- LogoutComponent.prototype.isDownloadableIos;
1708
- LogoutComponent.prototype.isDownloadableAndroid;
1709
- LogoutComponent.prototype.dialogRef;
1710
- LogoutComponent.prototype.configSvc;
1711
- LogoutComponent.prototype.utilitySvc;
1712
- LogoutComponent.prototype.router;
1792
+ AuthMicrosoftService.prototype.msConfig;
1793
+ AuthMicrosoftService.prototype.emailUsed;
1794
+ AuthMicrosoftService.prototype.code;
1795
+ AuthMicrosoftService.prototype.msToken;
1796
+ AuthMicrosoftService.prototype.loggerSvc;
1797
+ AuthMicrosoftService.prototype.http;
1713
1798
  }
1714
1799
 
1715
- var LogoutModule = (function () {
1716
- function LogoutModule() {
1717
- }
1718
- LogoutModule.decorators = [
1719
- { type: NgModule, args: [{
1720
- declarations: [LogoutComponent],
1721
- imports: [
1722
- CommonModule,
1723
- MatButtonModule,
1724
- MatDialogModule,
1725
- ],
1726
- entryComponents: [LogoutComponent],
1727
- },] }
1728
- ];
1729
- return LogoutModule;
1730
- }());
1731
-
1732
- function IDateRange() { }
1800
+ function IParsedToken() { }
1733
1801
  if (false) {
1734
- IDateRange.prototype.fromDate;
1735
- IDateRange.prototype.toDate;
1736
- IDateRange.prototype.timeZone;
1802
+ IParsedToken.prototype.email;
1803
+ IParsedToken.prototype.encEmail;
1804
+ IParsedToken.prototype.name;
1805
+ IParsedToken.prototype.preferred_username;
1737
1806
  }
1738
- var PipeConciseDateRangePipe = (function () {
1739
- function PipeConciseDateRangePipe() {
1807
+ var storage$1 = localStorage;
1808
+ var storageKey$1 = 'kc';
1809
+ var AuthKeycloakService = (function () {
1810
+ function AuthKeycloakService(http, configSvc, keycloakSvc, msAuthSvc) {
1811
+ var _this = this;
1812
+ this.http = http;
1813
+ this.configSvc = configSvc;
1814
+ this.keycloakSvc = keycloakSvc;
1815
+ this.msAuthSvc = msAuthSvc;
1816
+ this.loginChangeSubject = new ReplaySubject(1);
1817
+ this.loginChangeSubject.subscribe((function (isLoggedIn) {
1818
+ _this.configSvc.isAuthenticated = isLoggedIn;
1819
+ if (isLoggedIn &&
1820
+ _this.configSvc.instanceConfig &&
1821
+ Boolean(_this.configSvc.instanceConfig.disablePidCheck)) {
1822
+ _this.configSvc.userProfile = {
1823
+ email: _this.userEmail,
1824
+ userName: _this.userName,
1825
+ userId: _this.userId || '',
1826
+ };
1827
+ }
1828
+ }));
1740
1829
  }
1741
- PipeConciseDateRangePipe.prototype.transform = function (dateRange) {
1742
- try {
1743
- var conciseRange = void 0;
1744
- var prefix = void 0;
1745
- var suffix = void 0;
1746
- var fromDate = new Date(dateRange.fromDate);
1747
- var toDate = new Date(dateRange.toDate);
1748
- var fromDateObj = {
1749
- day: fromDate.getDate(),
1750
- month: fromDate.toLocaleString('default', { month: 'short' }),
1751
- year: fromDate.getFullYear(),
1752
- time: fromDate.getTime(),
1753
- };
1754
- var toDateObj = {
1755
- day: toDate.getDate(),
1756
- month: toDate.toLocaleString('default', { month: 'short' }),
1757
- year: toDate.getFullYear(),
1758
- time: toDate.getTime(),
1759
- };
1760
- if (fromDateObj.time === toDateObj.time) {
1761
- conciseRange = fromDateObj.day + " " + fromDateObj.month + " " + fromDateObj.year;
1762
- return conciseRange;
1763
- }
1764
- if (fromDateObj.year !== fromDateObj.year) {
1765
- prefix = fromDateObj.day + " " + fromDateObj.month + " " + fromDateObj.year;
1766
- suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
1767
- conciseRange = prefix + " - " + suffix;
1768
- return conciseRange;
1769
- }
1770
- if (fromDateObj.month === toDateObj.month) {
1771
- prefix = "" + fromDateObj.day;
1772
- suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
1773
- }
1774
- else {
1775
- prefix = fromDateObj.day + " " + fromDateObj.month;
1776
- suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
1777
- }
1778
- conciseRange = prefix + " - " + suffix;
1779
- return conciseRange;
1780
- }
1781
- catch (e) {
1782
- return dateRange.fromDate + " - " + dateRange.toDate;
1783
- }
1784
- };
1785
- PipeConciseDateRangePipe.decorators = [
1786
- { type: Pipe, args: [{
1787
- name: 'pipeConciseDateRange',
1788
- },] }
1789
- ];
1790
- return PipeConciseDateRangePipe;
1791
- }());
1792
-
1793
- var PipeConciseDateRangeModule = (function () {
1794
- function PipeConciseDateRangeModule() {
1795
- }
1796
- PipeConciseDateRangeModule.decorators = [
1797
- { type: NgModule, args: [{
1798
- declarations: [PipeConciseDateRangePipe],
1799
- imports: [CommonModule],
1800
- exports: [PipeConciseDateRangePipe],
1801
- },] }
1802
- ];
1803
- return PipeConciseDateRangeModule;
1804
- }());
1805
-
1806
- var PipeCountTransformPipe = (function () {
1807
- function PipeCountTransformPipe() {
1808
- }
1809
- PipeCountTransformPipe.prototype.transform = function (value) {
1810
- var thousand = 1000;
1811
- var million = 1000000;
1812
- if (value > 0) {
1813
- if (value < thousand) {
1814
- return String(value);
1815
- }
1816
- if (value >= thousand && value < million) {
1817
- var views = (value / thousand).toFixed(1);
1818
- if (views.endsWith('0')) {
1819
- return views.split('.')[0] + "K";
1820
- }
1821
- return views + "K";
1830
+ Object.defineProperty(AuthKeycloakService.prototype, "isLoggedIn$", {
1831
+ get: function () {
1832
+ return this.loginChangeSubject.asObservable();
1833
+ },
1834
+ enumerable: true,
1835
+ configurable: true
1836
+ });
1837
+ Object.defineProperty(AuthKeycloakService.prototype, "isLoggedIn", {
1838
+ get: function () {
1839
+ return this.keycloakSvc.isLoggedIn();
1840
+ },
1841
+ enumerable: true,
1842
+ configurable: true
1843
+ });
1844
+ Object.defineProperty(AuthKeycloakService.prototype, "isAuthenticated", {
1845
+ get: function () {
1846
+ return this.keycloakSvc.getKeycloakInstance().authenticated;
1847
+ },
1848
+ enumerable: true,
1849
+ configurable: true
1850
+ });
1851
+ Object.defineProperty(AuthKeycloakService.prototype, "token", {
1852
+ get: function () {
1853
+ return this.keycloakSvc.getKeycloakInstance().token;
1854
+ },
1855
+ enumerable: true,
1856
+ configurable: true
1857
+ });
1858
+ Object.defineProperty(AuthKeycloakService.prototype, "sessionId", {
1859
+ get: function () {
1860
+ return this.keycloakSvc.getKeycloakInstance().sessionId;
1861
+ },
1862
+ enumerable: true,
1863
+ configurable: true
1864
+ });
1865
+ Object.defineProperty(AuthKeycloakService.prototype, "userId", {
1866
+ get: function () {
1867
+ var kc = this.keycloakSvc.getKeycloakInstance();
1868
+ if (!kc) {
1869
+ return;
1822
1870
  }
1823
- {
1824
- var views = (value / million).toFixed(1);
1825
- if (views.endsWith('0')) {
1826
- return views.split('.')[0] + "M";
1871
+ return (kc.tokenParsed && kc.tokenParsed.sub) || (kc.idTokenParsed && kc.idTokenParsed.sub);
1872
+ },
1873
+ enumerable: true,
1874
+ configurable: true
1875
+ });
1876
+ Object.defineProperty(AuthKeycloakService.prototype, "userEmail", {
1877
+ get: function () {
1878
+ var kc = this.keycloakSvc.getKeycloakInstance();
1879
+ var tokenParsed = ((kc.tokenParsed));
1880
+ var idTokenParsed = ((kc.idTokenParsed));
1881
+ return ((tokenParsed && tokenParsed.email) ||
1882
+ (idTokenParsed && idTokenParsed.email) ||
1883
+ (idTokenParsed && idTokenParsed.encEmail) ||
1884
+ (tokenParsed && tokenParsed.preferred_username) ||
1885
+ (idTokenParsed && idTokenParsed.preferred_username));
1886
+ },
1887
+ enumerable: true,
1888
+ configurable: true
1889
+ });
1890
+ Object.defineProperty(AuthKeycloakService.prototype, "userName", {
1891
+ get: function () {
1892
+ var kc = this.keycloakSvc.getKeycloakInstance();
1893
+ return ((kc.tokenParsed && (((kc.tokenParsed))).name) ||
1894
+ (kc.idTokenParsed && (((kc.idTokenParsed))).name));
1895
+ },
1896
+ enumerable: true,
1897
+ configurable: true
1898
+ });
1899
+ AuthKeycloakService.prototype.initAuth = function () {
1900
+ return __awaiter(this, void 0, void 0, function () {
1901
+ var instanceConfig, err_1;
1902
+ return __generator(this, function (_a) {
1903
+ switch (_a.label) {
1904
+ case 0:
1905
+ if (!this.configSvc.instanceConfig) {
1906
+ return [2, false];
1907
+ }
1908
+ instanceConfig = this.configSvc.instanceConfig;
1909
+ if (instanceConfig.microsoft.isConfigured) {
1910
+ this.msAuthSvc.init({ microsoft: instanceConfig.microsoft });
1911
+ }
1912
+ _a.label = 1;
1913
+ case 1:
1914
+ _a.trys.push([1, 3, , 4]);
1915
+ this.setupGlobalAuthResponder();
1916
+ this.addKeycloakEventListener();
1917
+ return [4, this.keycloakSvc.init({
1918
+ config: {
1919
+ url: instanceConfig.keycloak.url,
1920
+ realm: instanceConfig.keycloak.realm,
1921
+ clientId: instanceConfig.keycloak.clientId,
1922
+ },
1923
+ initOptions: __assign({}, this.getSavedKcConfig(), { onLoad: instanceConfig.keycloak.onLoad || 'check-sso', checkLoginIframe: false }),
1924
+ enableBearerInterceptor: true,
1925
+ loadUserProfileAtStartUp: false,
1926
+ bearerExcludedUrls: instanceConfig.keycloak.bearerExcludedUrls,
1927
+ })];
1928
+ case 2: return [2, _a.sent()];
1929
+ case 3:
1930
+ err_1 = _a.sent();
1931
+ return [2, false];
1932
+ case 4: return [2];
1827
1933
  }
1828
- return views + "M";
1829
- }
1830
- }
1831
- return '0';
1934
+ });
1935
+ });
1832
1936
  };
1833
- PipeCountTransformPipe.decorators = [
1834
- { type: Pipe, args: [{
1835
- name: 'pipeCountTransform',
1836
- },] }
1837
- ];
1838
- return PipeCountTransformPipe;
1839
- }());
1840
-
1841
- var PipeCountTransformModule = (function () {
1842
- function PipeCountTransformModule() {
1843
- }
1844
- PipeCountTransformModule.decorators = [
1845
- { type: NgModule, args: [{
1846
- declarations: [PipeCountTransformPipe],
1847
- imports: [
1848
- CommonModule,
1849
- ],
1850
- exports: [PipeCountTransformPipe],
1851
- },] }
1852
- ];
1853
- return PipeCountTransformModule;
1854
- }());
1855
-
1856
- function ICertificationDate() { }
1857
- if (false) {
1858
- ICertificationDate.prototype.day;
1859
- ICertificationDate.prototype.month;
1860
- ICertificationDate.prototype.year;
1861
- ICertificationDate.prototype.timeZone;
1862
- }
1863
- var PipeDateConcatPipe = (function () {
1864
- function PipeDateConcatPipe() {
1865
- this.months = [
1866
- 'Jan',
1867
- 'Feb',
1868
- 'Mar',
1869
- 'Apr',
1870
- 'May',
1871
- 'Jun',
1872
- 'Jul',
1873
- 'Aug',
1874
- 'Sep',
1875
- 'Oct',
1876
- 'Nov',
1877
- 'Dec',
1878
- ];
1879
- }
1880
- PipeDateConcatPipe.prototype.transform = function (value) {
1881
- var dateStr = value.day + " " + this.months[value.month - 1] + " " + value.year;
1882
- if (value.timeZone) {
1883
- dateStr += " " + value.timeZone;
1884
- }
1885
- return dateStr;
1937
+ AuthKeycloakService.prototype.login = function (idpHint, redirectUrl) {
1938
+ if (idpHint === void 0) { idpHint = 'E'; }
1939
+ if (redirectUrl === void 0) { redirectUrl = this.defaultRedirectUrl; }
1940
+ return this.keycloakSvc.login({
1941
+ idpHint: idpHint,
1942
+ redirectUri: redirectUrl,
1943
+ });
1886
1944
  };
1887
- PipeDateConcatPipe.decorators = [
1888
- { type: Pipe, args: [{
1889
- name: 'pipeDateConcat',
1890
- },] }
1891
- ];
1892
- PipeDateConcatPipe.ctorParameters = function () { return []; };
1893
- return PipeDateConcatPipe;
1894
- }());
1895
- if (false) {
1896
- PipeDateConcatPipe.prototype.months;
1897
- }
1898
-
1899
- var PipeDateConcatModule = (function () {
1900
- function PipeDateConcatModule() {
1901
- }
1902
- PipeDateConcatModule.decorators = [
1903
- { type: NgModule, args: [{
1904
- declarations: [PipeDateConcatPipe],
1905
- imports: [
1906
- CommonModule,
1907
- ],
1908
- exports: [PipeDateConcatPipe],
1909
- },] }
1910
- ];
1911
- return PipeDateConcatModule;
1912
- }());
1913
-
1914
- var PipeDurationTransformPipe = (function () {
1915
- function PipeDurationTransformPipe() {
1916
- }
1917
- PipeDurationTransformPipe.prototype.transform = function (data, type) {
1918
- if (data <= 0) {
1919
- return '';
1920
- }
1921
- var h = Math.floor(data / 3600);
1922
- var m = Math.floor((data % 3600) / 60);
1923
- var s = Math.floor((data % 3600) % 60);
1924
- var duration = '';
1925
- var space = '';
1926
- switch (type) {
1927
- case 'time24':
1928
- return this.defaultDuration(h, m, s);
1929
- case 'hms':
1930
- if (h > 0) {
1931
- duration += type === 'hms' ? h + "h" : h + " hr";
1932
- }
1933
- if (m > 0) {
1934
- if (h > 0) {
1935
- space = ' ';
1936
- }
1937
- duration += type === 'hms' ? "" + space + m + "m" : "" + space + m + " min";
1938
- }
1939
- if (s > 0 && h === 0) {
1940
- if (m > 0) {
1941
- space = ' ';
1942
- }
1943
- duration += type === 'hms' ? "" + space + s + "s" : "" + space + s + " sec";
1944
- }
1945
- return duration;
1946
- case 'hour':
1947
- if (h === 0) {
1948
- duration += 'less than an hour';
1949
- }
1950
- if (h === 1) {
1951
- duration += h + " hour";
1952
- }
1953
- if (h > 1) {
1954
- duration += h + " hours";
1945
+ AuthKeycloakService.prototype.register = function (redirectUrl) {
1946
+ if (redirectUrl === void 0) { redirectUrl = this.defaultRedirectUrl; }
1947
+ return this.keycloakSvc.register({
1948
+ redirectUri: redirectUrl,
1949
+ });
1950
+ };
1951
+ AuthKeycloakService.prototype.logout = function (_redirectUrl) {
1952
+ if (_redirectUrl === void 0) { _redirectUrl = this.defaultRedirectUrl; }
1953
+ return __awaiter(this, void 0, void 0, function () {
1954
+ return __generator(this, function (_a) {
1955
+ window.location.href = _redirectUrl + "apis/reset";
1956
+ return [2];
1957
+ });
1958
+ });
1959
+ };
1960
+ AuthKeycloakService.prototype.force_logout = function () {
1961
+ return __awaiter(this, void 0, void 0, function () {
1962
+ return __generator(this, function (_a) {
1963
+ switch (_a.label) {
1964
+ case 0:
1965
+ if (storage$1.getItem('telemetrySessionId')) {
1966
+ storage$1.removeItem('telemetrySessionId');
1967
+ }
1968
+ try {
1969
+ sessionStorage.clear();
1970
+ localStorage.clear();
1971
+ }
1972
+ catch (_b) {
1973
+ }
1974
+ storage$1.removeItem(storageKey$1);
1975
+ window.location.href = '/public/logout';
1976
+ return [4, this.http.get('/apis/reset').toPromise()];
1977
+ case 1:
1978
+ _a.sent();
1979
+ return [2];
1955
1980
  }
1956
- return duration;
1957
- default:
1958
- return this.defaultDuration(h, m, s);
1959
- }
1981
+ });
1982
+ });
1960
1983
  };
1961
- PipeDurationTransformPipe.prototype.defaultDuration = function (h, m, s) {
1962
- var duration = '';
1963
- duration += h > 0 ? h.toString().padStart(2) + ":" : '';
1964
- duration += m > 0 ? m.toString().padStart(2) + ":" : '00:';
1965
- duration += s > 0 ? s.toString().padStart(2) : '00';
1966
- return duration;
1984
+ AuthKeycloakService.prototype.addKeycloakEventListener = function () {
1985
+ var _this = this;
1986
+ this.keycloakSvc.keycloakEvents$.subscribe((function (event) {
1987
+ switch (event.type) {
1988
+ case KeycloakEventType.OnAuthError:
1989
+ _this.loginChangeSubject.next(false);
1990
+ break;
1991
+ case KeycloakEventType.OnAuthLogout:
1992
+ _this.loginChangeSubject.next(false);
1993
+ storage$1.removeItem(storageKey$1);
1994
+ break;
1995
+ case KeycloakEventType.OnAuthRefreshError:
1996
+ break;
1997
+ case KeycloakEventType.OnAuthRefreshSuccess:
1998
+ break;
1999
+ case KeycloakEventType.OnAuthSuccess:
2000
+ break;
2001
+ case KeycloakEventType.OnReady:
2002
+ _this.loginChangeSubject.next(event.args);
2003
+ if (event.args) {
2004
+ _this.saveKeycloakConfig();
2005
+ }
2006
+ break;
2007
+ case KeycloakEventType.OnTokenExpired:
2008
+ _this.keycloakSvc.updateToken(60);
2009
+ break;
2010
+ }
2011
+ }));
1967
2012
  };
1968
- PipeDurationTransformPipe.decorators = [
1969
- { type: Pipe, args: [{
1970
- name: 'pipeDurationTransform',
1971
- },] }
1972
- ];
1973
- return PipeDurationTransformPipe;
1974
- }());
1975
-
1976
- var PipeDurationTransformModule = (function () {
1977
- function PipeDurationTransformModule() {
1978
- }
1979
- PipeDurationTransformModule.decorators = [
1980
- { type: NgModule, args: [{
1981
- declarations: [PipeDurationTransformPipe],
1982
- imports: [
1983
- CommonModule,
1984
- ],
1985
- exports: [PipeDurationTransformPipe],
1986
- },] }
1987
- ];
1988
- return PipeDurationTransformModule;
1989
- }());
1990
-
1991
- var PipeHtmlTagRemovalPipe = (function () {
1992
- function PipeHtmlTagRemovalPipe() {
1993
- }
1994
- PipeHtmlTagRemovalPipe.prototype.transform = function (htmlString) {
1995
- return htmlString ? String(htmlString).replace(/<[^>]+>/gm, '') : '';
2013
+ AuthKeycloakService.prototype.setupGlobalAuthResponder = function () {
2014
+ var _this = this;
2015
+ fromEvent(window, 'message')
2016
+ .pipe(filter((function (event) {
2017
+ return Boolean(event) &&
2018
+ Boolean(event.data) &&
2019
+ event.data.type === 'AUTH_REQUEST' &&
2020
+ Boolean(event.source && typeof event.source.postMessage === 'function');
2021
+ })))
2022
+ .subscribe((function (event) { return __awaiter(_this, void 0, void 0, function () {
2023
+ var contentWindow, token, response;
2024
+ return __generator(this, function (_a) {
2025
+ switch (_a.label) {
2026
+ case 0:
2027
+ contentWindow = ((event.source));
2028
+ return [4, this.keycloakSvc.getToken()];
2029
+ case 1:
2030
+ token = _a.sent();
2031
+ response = {
2032
+ app: 'WEB_PORTAL',
2033
+ type: 'AUTH_RESPONSE',
2034
+ state: 'NONE',
2035
+ plugin: 'NONE',
2036
+ data: {
2037
+ token: token,
2038
+ id: event.data && event.data.data && event.data.data.id,
2039
+ },
2040
+ };
2041
+ contentWindow.postMessage(response, '*');
2042
+ return [2];
2043
+ }
2044
+ });
2045
+ }); }));
1996
2046
  };
1997
- PipeHtmlTagRemovalPipe.decorators = [
1998
- { type: Pipe, args: [{
1999
- name: 'pipeHtmlTagRemoval',
2000
- },] }
2001
- ];
2002
- return PipeHtmlTagRemovalPipe;
2003
- }());
2004
-
2005
- var PipeHtmlTagRemovalModule = (function () {
2006
- function PipeHtmlTagRemovalModule() {
2007
- }
2008
- PipeHtmlTagRemovalModule.decorators = [
2009
- { type: NgModule, args: [{
2010
- declarations: [PipeHtmlTagRemovalPipe],
2011
- imports: [
2012
- CommonModule,
2013
- ],
2014
- exports: [PipeHtmlTagRemovalPipe],
2015
- },] }
2016
- ];
2017
- return PipeHtmlTagRemovalModule;
2018
- }());
2019
-
2020
- var PipeFilterPipe = (function () {
2021
- function PipeFilterPipe() {
2022
- }
2023
- PipeFilterPipe.prototype.transform = function (value, keys, term) {
2024
- if (!term) {
2025
- return value;
2026
- }
2027
- return (value || []).filter((function (item) { return keys.split(',')
2028
- .some((function (key) { return item.hasOwnProperty(key) && new RegExp("^" + term + "$", 'gi').test(item[key]); })); }));
2047
+ AuthKeycloakService.prototype.saveKeycloakConfig = function () {
2048
+ var kc = this.keycloakSvc.getKeycloakInstance();
2049
+ var kcInitOptions = {
2050
+ idToken: kc.idToken,
2051
+ refreshToken: kc.refreshToken,
2052
+ timeSkew: kc.timeSkew,
2053
+ token: kc.token,
2054
+ };
2055
+ storage$1.setItem(storageKey$1, JSON.stringify(kcInitOptions));
2029
2056
  };
2030
- PipeFilterPipe.decorators = [
2031
- { type: Pipe, args: [{
2032
- name: 'pipeFilter',
2033
- },] }
2034
- ];
2035
- return PipeFilterPipe;
2036
- }());
2037
-
2038
- var PipeFilterModule = (function () {
2039
- function PipeFilterModule() {
2040
- }
2041
- PipeFilterModule.decorators = [
2042
- { type: NgModule, args: [{
2043
- declarations: [PipeFilterPipe],
2044
- imports: [
2045
- CommonModule,
2046
- ],
2047
- exports: [PipeFilterPipe],
2057
+ AuthKeycloakService.prototype.getSavedKcConfig = function () {
2058
+ try {
2059
+ var lastSaved = storage$1.getItem(storageKey$1);
2060
+ if (lastSaved) {
2061
+ var processed = JSON.parse(lastSaved);
2062
+ if ('idToken' in processed &&
2063
+ 'refreshToken' in processed &&
2064
+ 'timeSkew' in processed &&
2065
+ 'token' in processed) {
2066
+ return processed;
2067
+ }
2068
+ }
2069
+ }
2070
+ catch (e) { }
2071
+ return {};
2072
+ };
2073
+ Object.defineProperty(AuthKeycloakService.prototype, "defaultRedirectUrl", {
2074
+ get: function () {
2075
+ try {
2076
+ var baseUrl = document.baseURI;
2077
+ return baseUrl || location.origin;
2078
+ }
2079
+ catch (error) {
2080
+ return location.origin;
2081
+ }
2082
+ },
2083
+ enumerable: true,
2084
+ configurable: true
2085
+ });
2086
+ AuthKeycloakService.decorators = [
2087
+ { type: Injectable, args: [{
2088
+ providedIn: 'root',
2048
2089
  },] }
2049
2090
  ];
2050
- return PipeFilterModule;
2091
+ AuthKeycloakService.ctorParameters = function () { return [
2092
+ { type: HttpClient },
2093
+ { type: ConfigurationsService },
2094
+ { type: KeycloakService },
2095
+ { type: AuthMicrosoftService }
2096
+ ]; };
2097
+ /** @nocollapse */ AuthKeycloakService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthKeycloakService_Factory() { return new AuthKeycloakService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationsService), ɵɵinject(KeycloakService), ɵɵinject(AuthMicrosoftService)); }, token: AuthKeycloakService, providedIn: "root" });
2098
+ return AuthKeycloakService;
2051
2099
  }());
2100
+ if (false) {
2101
+ AuthKeycloakService.prototype.loginChangeSubject;
2102
+ AuthKeycloakService.prototype.http;
2103
+ AuthKeycloakService.prototype.configSvc;
2104
+ AuthKeycloakService.prototype.keycloakSvc;
2105
+ AuthKeycloakService.prototype.msAuthSvc;
2106
+ }
2052
2107
 
2053
- var PipeFilterSearchPipe = (function () {
2054
- function PipeFilterSearchPipe() {
2108
+ function IWindowMobileAppModified() { }
2109
+ if (false) {
2110
+ IWindowMobileAppModified.prototype.appRef;
2111
+ IWindowMobileAppModified.prototype.webkit;
2112
+ }
2113
+ var RANDOM_ID_PER_USER = 0;
2114
+ function IRecursiveData() { }
2115
+ if (false) {
2116
+ IRecursiveData.prototype.identifier;
2117
+ IRecursiveData.prototype.children;
2118
+ }
2119
+ var UtilityService = (function () {
2120
+ function UtilityService(http, platform, router, route) {
2121
+ var _this = this;
2122
+ this.http = http;
2123
+ this.platform = platform;
2124
+ this.router = router;
2125
+ this.route = route;
2126
+ this.currentRouteData = [];
2127
+ this.router.events.subscribe((function (event) {
2128
+ if (event instanceof NavigationEnd) {
2129
+ var snapshot = _this.route.snapshot;
2130
+ var firstChild = snapshot.root.firstChild;
2131
+ _this.getChildRouteData(snapshot, firstChild);
2132
+ }
2133
+ }));
2055
2134
  }
2056
- PipeFilterSearchPipe.prototype.transform = function (items, searchText) {
2057
- var keys = [];
2058
- for (var _i = 2; _i < arguments.length; _i++) {
2059
- keys[_i - 2] = arguments[_i];
2060
- }
2061
- if (!items) {
2062
- return [];
2135
+ UtilityService.prototype.getChildRouteData = function (snapshot, firstChild) {
2136
+ if (firstChild) {
2137
+ if (firstChild.data) {
2138
+ this.currentRouteData.push(firstChild.data);
2139
+ }
2140
+ if (firstChild.firstChild) {
2141
+ this.getChildRouteData(snapshot, firstChild.firstChild);
2142
+ }
2063
2143
  }
2064
- if (!searchText) {
2065
- return items;
2144
+ };
2145
+ Object.defineProperty(UtilityService.prototype, "randomId", {
2146
+ get: function () {
2147
+ return RANDOM_ID_PER_USER + 1;
2148
+ },
2149
+ enumerable: true,
2150
+ configurable: true
2151
+ });
2152
+ UtilityService.prototype.getJson = function (url) {
2153
+ return this.http.get(url);
2154
+ };
2155
+ UtilityService.prototype.getLeafNodes = function (node, nodes) {
2156
+ var _this = this;
2157
+ if ((node.children || []).length === 0) {
2158
+ nodes.push(node);
2066
2159
  }
2067
- var searchTextLowerCase = searchText.toLowerCase();
2068
- if (keys && keys.length) {
2069
- var result = items.filter((function (it) {
2070
- return it['personalDetails'][keys[0]].toLowerCase().includes(searchTextLowerCase);
2071
- }));
2072
- if (result && result.length <= 0) {
2073
- return [-1];
2160
+ else {
2161
+ if (node.children) {
2162
+ node.children.forEach((function (child) {
2163
+ _this.getLeafNodes(child, nodes);
2164
+ }));
2074
2165
  }
2075
- return result;
2076
2166
  }
2077
- return items.filter((function (it) {
2078
- return it.title.toLowerCase().includes(searchTextLowerCase);
2079
- }));
2167
+ return nodes;
2080
2168
  };
2081
- PipeFilterSearchPipe.decorators = [
2082
- { type: Pipe, args: [{
2083
- name: 'pipeFilterSearch',
2084
- },] }
2085
- ];
2086
- return PipeFilterSearchPipe;
2087
- }());
2088
-
2089
- var PipeFilterSearchModule = (function () {
2090
- function PipeFilterSearchModule() {
2091
- }
2092
- PipeFilterSearchModule.decorators = [
2093
- { type: NgModule, args: [{
2094
- declarations: [PipeFilterSearchPipe],
2095
- imports: [
2096
- CommonModule,
2097
- ],
2098
- exports: [PipeFilterSearchPipe],
2099
- },] }
2100
- ];
2101
- return PipeFilterSearchModule;
2102
- }());
2103
-
2104
- var PipeListFilterPipe = (function () {
2105
- function PipeListFilterPipe() {
2106
- }
2107
- PipeListFilterPipe.prototype.transform = function (value, keys, term) {
2108
- if (!term) {
2109
- return value;
2169
+ UtilityService.prototype.getPath = function (node, id) {
2170
+ var path = [];
2171
+ this.hasPath(node, path, id);
2172
+ return path;
2173
+ };
2174
+ UtilityService.prototype.hasPath = function (node, pathArr, id) {
2175
+ var _this = this;
2176
+ if (node == null) {
2177
+ return false;
2110
2178
  }
2111
- return (value || []).filter((function (item) { return keys.split(',')
2112
- .some((function (key) { return item.hasOwnProperty(key)
2113
- && item[key] && (item[key] + " ").toLocaleLowerCase().includes(term.toLocaleLowerCase()); })); }));
2179
+ pathArr.push(node);
2180
+ if (node.identifier === id) {
2181
+ return true;
2182
+ }
2183
+ var children = node.children || [];
2184
+ if (children.some((function (u) { return _this.hasPath(u, pathArr, id); }))) {
2185
+ return true;
2186
+ }
2187
+ pathArr.pop();
2188
+ return false;
2114
2189
  };
2115
- PipeListFilterPipe.decorators = [
2116
- { type: Pipe, args: [{
2117
- name: 'pipeListFilter',
2118
- },] }
2119
- ];
2120
- return PipeListFilterPipe;
2121
- }());
2122
-
2123
- var PipeListFilterModule = (function () {
2124
- function PipeListFilterModule() {
2125
- }
2126
- PipeListFilterModule.decorators = [
2127
- { type: NgModule, args: [{
2128
- declarations: [PipeListFilterPipe],
2129
- imports: [
2130
- CommonModule,
2131
- ],
2132
- exports: [PipeListFilterPipe],
2190
+ Object.defineProperty(UtilityService.prototype, "isMobile", {
2191
+ get: function () {
2192
+ if (this.isIos || this.isAndroid) {
2193
+ return true;
2194
+ }
2195
+ return false;
2196
+ },
2197
+ enumerable: true,
2198
+ configurable: true
2199
+ });
2200
+ Object.defineProperty(UtilityService.prototype, "isIos", {
2201
+ get: function () {
2202
+ return this.platform.IOS;
2203
+ },
2204
+ enumerable: true,
2205
+ configurable: true
2206
+ });
2207
+ Object.defineProperty(UtilityService.prototype, "isAndroid", {
2208
+ get: function () {
2209
+ return this.platform.ANDROID;
2210
+ },
2211
+ enumerable: true,
2212
+ configurable: true
2213
+ });
2214
+ Object.defineProperty(UtilityService.prototype, "isAndroidApp", {
2215
+ get: function () {
2216
+ return Boolean(window.appRef);
2217
+ },
2218
+ enumerable: true,
2219
+ configurable: true
2220
+ });
2221
+ Object.defineProperty(UtilityService.prototype, "iOsAppRef", {
2222
+ get: function () {
2223
+ if (window.webkit &&
2224
+ window.webkit.messageHandlers &&
2225
+ window.webkit.messageHandlers.appRef) {
2226
+ return window.webkit.messageHandlers.appRef;
2227
+ }
2228
+ return null;
2229
+ },
2230
+ enumerable: true,
2231
+ configurable: true
2232
+ });
2233
+ UtilityService.prototype.setRouteData = function (data) {
2234
+ this.currentRouteData = data;
2235
+ };
2236
+ Object.defineProperty(UtilityService.prototype, "routeData", {
2237
+ get: function () {
2238
+ var data = {
2239
+ module: '',
2240
+ pageId: '',
2241
+ };
2242
+ this.currentRouteData.map((function (rd) {
2243
+ if (rd.pageId) {
2244
+ data.pageId = data.pageId + "/" + rd.pageId;
2245
+ }
2246
+ if (rd.module) {
2247
+ data.module = rd.module;
2248
+ }
2249
+ }));
2250
+ return data;
2251
+ },
2252
+ enumerable: true,
2253
+ configurable: true
2254
+ });
2255
+ UtilityService.decorators = [
2256
+ { type: Injectable, args: [{
2257
+ providedIn: 'root',
2133
2258
  },] }
2134
2259
  ];
2135
- return PipeListFilterModule;
2260
+ UtilityService.ctorParameters = function () { return [
2261
+ { type: HttpClient },
2262
+ { type: Platform },
2263
+ { type: Router },
2264
+ { type: ActivatedRoute }
2265
+ ]; };
2266
+ /** @nocollapse */ UtilityService.ngInjectableDef = ɵɵdefineInjectable({ factory: function UtilityService_Factory() { return new UtilityService(ɵɵinject(HttpClient), ɵɵinject(Platform), ɵɵinject(Router), ɵɵinject(ActivatedRoute)); }, token: UtilityService, providedIn: "root" });
2267
+ return UtilityService;
2136
2268
  }());
2269
+ if (false) {
2270
+ UtilityService.prototype.currentRouteData;
2271
+ UtilityService.prototype.http;
2272
+ UtilityService.prototype.platform;
2273
+ UtilityService.prototype.router;
2274
+ UtilityService.prototype.route;
2275
+ }
2137
2276
 
2138
- var PipeRelativeTimePipe = (function () {
2139
- function PipeRelativeTimePipe() {
2277
+ var LogoutComponent = (function () {
2278
+ function LogoutComponent(dialogRef, authSvc, configSvc, utilitySvc) {
2279
+ this.dialogRef = dialogRef;
2280
+ this.authSvc = authSvc;
2281
+ this.configSvc = configSvc;
2282
+ this.utilitySvc = utilitySvc;
2283
+ this.disabled = false;
2284
+ this.isDownloadableIos = false;
2285
+ this.isDownloadableAndroid = false;
2140
2286
  }
2141
- PipeRelativeTimePipe.prototype.transform = function (value) {
2142
- if (value) {
2143
- return moment((new Date(value))).fromNow();
2287
+ LogoutComponent.prototype.ngOnInit = function () {
2288
+ if (this.configSvc.restrictedFeatures) {
2289
+ this.isDownloadableIos = !this.configSvc.restrictedFeatures.has('iosDownload');
2290
+ this.isDownloadableAndroid = !this.configSvc.restrictedFeatures.has('androidDownload');
2144
2291
  }
2145
- return moment().startOf('hour').fromNow();
2146
2292
  };
2147
- PipeRelativeTimePipe.decorators = [
2148
- { type: Pipe, args: [{
2149
- name: 'pipeRelativeTime',
2150
- },] }
2293
+ LogoutComponent.prototype.confirmed = function () {
2294
+ this.disabled = true;
2295
+ this.dialogRef.close();
2296
+ this.authSvc.force_logout();
2297
+ };
2298
+ Object.defineProperty(LogoutComponent.prototype, "isDownloadable", {
2299
+ get: function () {
2300
+ if (this.configSvc.instanceConfig && this.configSvc.instanceConfig.isContentDownloadAvailable &&
2301
+ (this.utilitySvc.iOsAppRef || this.utilitySvc.isAndroidApp)) {
2302
+ return true;
2303
+ }
2304
+ return false;
2305
+ },
2306
+ enumerable: true,
2307
+ configurable: true
2308
+ });
2309
+ LogoutComponent.decorators = [
2310
+ { type: Component, args: [{
2311
+ selector: 'ws-utils-logout',
2312
+ template: "<h1 mat-dialog-title i18n>Logout Now</h1>\r\n<div class=\"ws-mat-primary-text text-base pb-2 title-text\" *ngIf=\"isDownloadable\" i18n>\r\n Note: On logging out all the downloaded content will be deleted.\r\n</div>\r\n<div mat-dialog-content class=\"text-base hide-overflow\" i18n>\r\n Are you sure?\r\n</div>\r\n<div mat-dialog-actions class=\"flex-row-reverse\">\r\n <button mat-flat-button color=\"warn\" [disabled]=\"disabled\" (click)=\"confirmed()\" i18n>\r\n Yes\r\n </button>\r\n <button mat-button class=\"margin-right-xs\" [mat-dialog-close] cdkFocusInitial i18n>No</button>\r\n</div>",
2313
+ styles: [".hide-overflow{overflow:hidden}"]
2314
+ }] }
2151
2315
  ];
2152
- return PipeRelativeTimePipe;
2316
+ LogoutComponent.ctorParameters = function () { return [
2317
+ { type: MatDialogRef$1 },
2318
+ { type: AuthKeycloakService },
2319
+ { type: ConfigurationsService },
2320
+ { type: UtilityService }
2321
+ ]; };
2322
+ return LogoutComponent;
2153
2323
  }());
2324
+ if (false) {
2325
+ LogoutComponent.prototype.disabled;
2326
+ LogoutComponent.prototype.isDownloadableIos;
2327
+ LogoutComponent.prototype.isDownloadableAndroid;
2328
+ LogoutComponent.prototype.dialogRef;
2329
+ LogoutComponent.prototype.authSvc;
2330
+ LogoutComponent.prototype.configSvc;
2331
+ LogoutComponent.prototype.utilitySvc;
2332
+ }
2154
2333
 
2155
- var PipeRelativeTimeModule = (function () {
2156
- function PipeRelativeTimeModule() {
2334
+ var LogoutModule = (function () {
2335
+ function LogoutModule() {
2157
2336
  }
2158
- PipeRelativeTimeModule.decorators = [
2337
+ LogoutModule.decorators = [
2159
2338
  { type: NgModule, args: [{
2160
- declarations: [PipeRelativeTimePipe],
2339
+ declarations: [LogoutComponent],
2161
2340
  imports: [
2162
2341
  CommonModule,
2342
+ MatButtonModule,
2343
+ MatDialogModule,
2163
2344
  ],
2164
- exports: [PipeRelativeTimePipe],
2345
+ entryComponents: [LogoutComponent],
2165
2346
  },] }
2166
2347
  ];
2167
- return PipeRelativeTimeModule;
2348
+ return LogoutModule;
2168
2349
  }());
2169
2350
 
2170
- var OrderByPipe = (function () {
2171
- function OrderByPipe() {
2172
- this.transform = orderBy;
2351
+ function IDateRange() { }
2352
+ if (false) {
2353
+ IDateRange.prototype.fromDate;
2354
+ IDateRange.prototype.toDate;
2355
+ IDateRange.prototype.timeZone;
2356
+ }
2357
+ var PipeConciseDateRangePipe = (function () {
2358
+ function PipeConciseDateRangePipe() {
2173
2359
  }
2174
- OrderByPipe.decorators = [
2360
+ PipeConciseDateRangePipe.prototype.transform = function (dateRange) {
2361
+ try {
2362
+ var conciseRange = void 0;
2363
+ var prefix = void 0;
2364
+ var suffix = void 0;
2365
+ var fromDate = new Date(dateRange.fromDate);
2366
+ var toDate = new Date(dateRange.toDate);
2367
+ var fromDateObj = {
2368
+ day: fromDate.getDate(),
2369
+ month: fromDate.toLocaleString('default', { month: 'short' }),
2370
+ year: fromDate.getFullYear(),
2371
+ time: fromDate.getTime(),
2372
+ };
2373
+ var toDateObj = {
2374
+ day: toDate.getDate(),
2375
+ month: toDate.toLocaleString('default', { month: 'short' }),
2376
+ year: toDate.getFullYear(),
2377
+ time: toDate.getTime(),
2378
+ };
2379
+ if (fromDateObj.time === toDateObj.time) {
2380
+ conciseRange = fromDateObj.day + " " + fromDateObj.month + " " + fromDateObj.year;
2381
+ return conciseRange;
2382
+ }
2383
+ if (fromDateObj.year !== fromDateObj.year) {
2384
+ prefix = fromDateObj.day + " " + fromDateObj.month + " " + fromDateObj.year;
2385
+ suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
2386
+ conciseRange = prefix + " - " + suffix;
2387
+ return conciseRange;
2388
+ }
2389
+ if (fromDateObj.month === toDateObj.month) {
2390
+ prefix = "" + fromDateObj.day;
2391
+ suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
2392
+ }
2393
+ else {
2394
+ prefix = fromDateObj.day + " " + fromDateObj.month;
2395
+ suffix = toDateObj.day + " " + toDateObj.month + " " + toDateObj.year;
2396
+ }
2397
+ conciseRange = prefix + " - " + suffix;
2398
+ return conciseRange;
2399
+ }
2400
+ catch (e) {
2401
+ return dateRange.fromDate + " - " + dateRange.toDate;
2402
+ }
2403
+ };
2404
+ PipeConciseDateRangePipe.decorators = [
2175
2405
  { type: Pipe, args: [{
2176
- name: 'orderBy',
2406
+ name: 'pipeConciseDateRange',
2177
2407
  },] }
2178
2408
  ];
2179
- return OrderByPipe;
2409
+ return PipeConciseDateRangePipe;
2180
2410
  }());
2181
- if (false) {
2182
- OrderByPipe.prototype.transform;
2183
- }
2184
2411
 
2185
- var PipeOrderByModule = (function () {
2186
- function PipeOrderByModule() {
2412
+ var PipeConciseDateRangeModule = (function () {
2413
+ function PipeConciseDateRangeModule() {
2187
2414
  }
2188
- PipeOrderByModule.decorators = [
2415
+ PipeConciseDateRangeModule.decorators = [
2189
2416
  { type: NgModule, args: [{
2190
- declarations: [OrderByPipe],
2191
- imports: [
2192
- CommonModule,
2193
- ],
2194
- exports: [OrderByPipe],
2417
+ declarations: [PipeConciseDateRangePipe],
2418
+ imports: [CommonModule],
2419
+ exports: [PipeConciseDateRangePipe],
2195
2420
  },] }
2196
2421
  ];
2197
- return PipeOrderByModule;
2422
+ return PipeConciseDateRangeModule;
2198
2423
  }());
2199
2424
 
2200
- var PipeLimitToPipe = (function () {
2201
- function PipeLimitToPipe() {
2425
+ var PipeCountTransformPipe = (function () {
2426
+ function PipeCountTransformPipe() {
2202
2427
  }
2203
- PipeLimitToPipe.prototype.transform = function (data, limit) {
2204
- if (limit === void 0) { limit = 5; }
2205
- if (!data || !data.length) {
2206
- return null;
2207
- }
2208
- if (Array.isArray(data)) {
2209
- return data.slice(0, limit);
2210
- }
2211
- if (typeof data === 'string') {
2212
- var slicedString = data.substr(0, limit);
2213
- if (limit < data.length) {
2214
- return slicedString + "...";
2428
+ PipeCountTransformPipe.prototype.transform = function (value) {
2429
+ var thousand = 1000;
2430
+ var million = 1000000;
2431
+ if (value > 0) {
2432
+ if (value < thousand) {
2433
+ return String(value);
2434
+ }
2435
+ if (value >= thousand && value < million) {
2436
+ var views = (value / thousand).toFixed(1);
2437
+ if (views.endsWith('0')) {
2438
+ return views.split('.')[0] + "K";
2439
+ }
2440
+ return views + "K";
2441
+ }
2442
+ {
2443
+ var views = (value / million).toFixed(1);
2444
+ if (views.endsWith('0')) {
2445
+ return views.split('.')[0] + "M";
2446
+ }
2447
+ return views + "M";
2215
2448
  }
2216
- return slicedString;
2217
2449
  }
2218
- return null;
2450
+ return '0';
2219
2451
  };
2220
- PipeLimitToPipe.decorators = [
2452
+ PipeCountTransformPipe.decorators = [
2221
2453
  { type: Pipe, args: [{
2222
- name: 'pipeLimitTo',
2454
+ name: 'pipeCountTransform',
2223
2455
  },] }
2224
2456
  ];
2225
- return PipeLimitToPipe;
2457
+ return PipeCountTransformPipe;
2226
2458
  }());
2227
2459
 
2228
- var PipeLimitToModule = (function () {
2229
- function PipeLimitToModule() {
2460
+ var PipeCountTransformModule = (function () {
2461
+ function PipeCountTransformModule() {
2230
2462
  }
2231
- PipeLimitToModule.decorators = [
2463
+ PipeCountTransformModule.decorators = [
2232
2464
  { type: NgModule, args: [{
2233
- declarations: [PipeLimitToPipe],
2465
+ declarations: [PipeCountTransformPipe],
2234
2466
  imports: [
2235
2467
  CommonModule,
2236
2468
  ],
2237
- exports: [PipeLimitToPipe],
2469
+ exports: [PipeCountTransformPipe],
2238
2470
  },] }
2239
2471
  ];
2240
- return PipeLimitToModule;
2472
+ return PipeCountTransformModule;
2241
2473
  }());
2242
2474
 
2243
- function IUserName() { }
2475
+ function ICertificationDate() { }
2244
2476
  if (false) {
2245
- IUserName.prototype.firstName;
2246
- IUserName.prototype.lastName;
2247
- IUserName.prototype.email;
2477
+ ICertificationDate.prototype.day;
2478
+ ICertificationDate.prototype.month;
2479
+ ICertificationDate.prototype.year;
2480
+ ICertificationDate.prototype.timeZone;
2248
2481
  }
2249
- var PipeNameTransformPipe = (function () {
2250
- function PipeNameTransformPipe() {
2251
- }
2252
- PipeNameTransformPipe.prototype.transform = function (value) {
2253
- var result = '';
2254
- if (value.firstName) {
2255
- result += value.firstName;
2256
- }
2257
- if (value.lastName && value.lastName !== value.firstName) {
2258
- result += " " + value.lastName;
2259
- }
2260
- if (result.trim() !== '') {
2261
- return result;
2262
- }
2263
- if (value.email) {
2264
- return value.email;
2482
+ var PipeDateConcatPipe = (function () {
2483
+ function PipeDateConcatPipe() {
2484
+ this.months = [
2485
+ 'Jan',
2486
+ 'Feb',
2487
+ 'Mar',
2488
+ 'Apr',
2489
+ 'May',
2490
+ 'Jun',
2491
+ 'Jul',
2492
+ 'Aug',
2493
+ 'Sep',
2494
+ 'Oct',
2495
+ 'Nov',
2496
+ 'Dec',
2497
+ ];
2498
+ }
2499
+ PipeDateConcatPipe.prototype.transform = function (value) {
2500
+ var dateStr = value.day + " " + this.months[value.month - 1] + " " + value.year;
2501
+ if (value.timeZone) {
2502
+ dateStr += " " + value.timeZone;
2265
2503
  }
2266
- return 'Anonymous User';
2504
+ return dateStr;
2267
2505
  };
2268
- PipeNameTransformPipe.decorators = [
2506
+ PipeDateConcatPipe.decorators = [
2269
2507
  { type: Pipe, args: [{
2270
- name: 'pipeNameTransform',
2508
+ name: 'pipeDateConcat',
2271
2509
  },] }
2272
2510
  ];
2273
- return PipeNameTransformPipe;
2511
+ PipeDateConcatPipe.ctorParameters = function () { return []; };
2512
+ return PipeDateConcatPipe;
2274
2513
  }());
2514
+ if (false) {
2515
+ PipeDateConcatPipe.prototype.months;
2516
+ }
2275
2517
 
2276
- var PipeNameTransformModule = (function () {
2277
- function PipeNameTransformModule() {
2518
+ var PipeDateConcatModule = (function () {
2519
+ function PipeDateConcatModule() {
2278
2520
  }
2279
- PipeNameTransformModule.decorators = [
2521
+ PipeDateConcatModule.decorators = [
2280
2522
  { type: NgModule, args: [{
2281
- declarations: [PipeNameTransformPipe],
2523
+ declarations: [PipeDateConcatPipe],
2282
2524
  imports: [
2283
2525
  CommonModule,
2284
2526
  ],
2285
- exports: [PipeNameTransformPipe],
2527
+ exports: [PipeDateConcatPipe],
2286
2528
  },] }
2287
2529
  ];
2288
- return PipeNameTransformModule;
2530
+ return PipeDateConcatModule;
2289
2531
  }());
2290
2532
 
2291
- var PipePartialContentPipe = (function () {
2292
- function PipePartialContentPipe() {
2533
+ var PipeDurationTransformPipe = (function () {
2534
+ function PipeDurationTransformPipe() {
2293
2535
  }
2294
- PipePartialContentPipe.prototype.transform = function (value, keys) {
2295
- var e_1, _a;
2296
- var result = {};
2297
- try {
2298
- for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
2299
- var key = keys_1_1.value;
2300
- if (value[key]) {
2301
- result[key] = value[key];
2302
- }
2303
- }
2536
+ PipeDurationTransformPipe.prototype.transform = function (data, type) {
2537
+ if (data <= 0) {
2538
+ return '';
2304
2539
  }
2305
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2306
- finally {
2307
- try {
2308
- if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
2309
- }
2310
- finally { if (e_1) throw e_1.error; }
2540
+ var h = Math.floor(data / 3600);
2541
+ var m = Math.floor((data % 3600) / 60);
2542
+ var s = Math.floor((data % 3600) % 60);
2543
+ var duration = '';
2544
+ var space = '';
2545
+ switch (type) {
2546
+ case 'time24':
2547
+ return this.defaultDuration(h, m, s);
2548
+ case 'hms':
2549
+ if (h > 0) {
2550
+ duration += type === 'hms' ? h + "h" : h + " hr";
2551
+ }
2552
+ if (m > 0) {
2553
+ if (h > 0) {
2554
+ space = ' ';
2555
+ }
2556
+ duration += type === 'hms' ? "" + space + m + "m" : "" + space + m + " min";
2557
+ }
2558
+ if (s > 0 && h === 0) {
2559
+ if (m > 0) {
2560
+ space = ' ';
2561
+ }
2562
+ duration += type === 'hms' ? "" + space + s + "s" : "" + space + s + " sec";
2563
+ }
2564
+ return duration;
2565
+ case 'hour':
2566
+ if (h === 0) {
2567
+ duration += 'less than an hour';
2568
+ }
2569
+ if (h === 1) {
2570
+ duration += h + " hour";
2571
+ }
2572
+ if (h > 1) {
2573
+ duration += h + " hours";
2574
+ }
2575
+ return duration;
2576
+ default:
2577
+ return this.defaultDuration(h, m, s);
2311
2578
  }
2312
- return result;
2313
2579
  };
2314
- PipePartialContentPipe.decorators = [
2580
+ PipeDurationTransformPipe.prototype.defaultDuration = function (h, m, s) {
2581
+ var duration = '';
2582
+ duration += h > 0 ? h.toString().padStart(2) + ":" : '';
2583
+ duration += m > 0 ? m.toString().padStart(2) + ":" : '00:';
2584
+ duration += s > 0 ? s.toString().padStart(2) : '00';
2585
+ return duration;
2586
+ };
2587
+ PipeDurationTransformPipe.decorators = [
2315
2588
  { type: Pipe, args: [{
2316
- name: 'pipePartialContent',
2589
+ name: 'pipeDurationTransform',
2317
2590
  },] }
2318
2591
  ];
2319
- return PipePartialContentPipe;
2592
+ return PipeDurationTransformPipe;
2320
2593
  }());
2321
2594
 
2322
- var PipePartialContentModule = (function () {
2323
- function PipePartialContentModule() {
2595
+ var PipeDurationTransformModule = (function () {
2596
+ function PipeDurationTransformModule() {
2324
2597
  }
2325
- PipePartialContentModule.decorators = [
2598
+ PipeDurationTransformModule.decorators = [
2326
2599
  { type: NgModule, args: [{
2327
- declarations: [PipePartialContentPipe],
2600
+ declarations: [PipeDurationTransformPipe],
2328
2601
  imports: [
2329
2602
  CommonModule,
2330
2603
  ],
2331
- exports: [PipePartialContentPipe],
2604
+ exports: [PipeDurationTransformPipe],
2332
2605
  },] }
2333
2606
  ];
2334
- return PipePartialContentModule;
2607
+ return PipeDurationTransformModule;
2335
2608
  }());
2336
2609
 
2337
- var PipeSafeSanitizerPipe = (function () {
2338
- function PipeSafeSanitizerPipe(sanitizer) {
2339
- this.sanitizer = sanitizer;
2610
+ var PipeHtmlTagRemovalPipe = (function () {
2611
+ function PipeHtmlTagRemovalPipe() {
2340
2612
  }
2341
- PipeSafeSanitizerPipe.prototype.transform = function (value, type) {
2342
- if (type === void 0) { type = 'html'; }
2343
- switch (type) {
2344
- case 'html':
2345
- return this.sanitizer.bypassSecurityTrustHtml(value);
2346
- case 'style':
2347
- return this.sanitizer.bypassSecurityTrustStyle(value);
2348
- case 'script':
2349
- return this.sanitizer.bypassSecurityTrustScript(value);
2350
- case 'url':
2351
- return this.sanitizer.bypassSecurityTrustUrl(value);
2352
- case 'resourceUrl':
2353
- return this.sanitizer.bypassSecurityTrustResourceUrl(value);
2354
- default:
2355
- throw new Error("Invalid safe type specified: " + type);
2356
- }
2613
+ PipeHtmlTagRemovalPipe.prototype.transform = function (htmlString) {
2614
+ return htmlString ? String(htmlString).replace(/<[^>]+>/gm, '') : '';
2357
2615
  };
2358
- PipeSafeSanitizerPipe.decorators = [
2616
+ PipeHtmlTagRemovalPipe.decorators = [
2359
2617
  { type: Pipe, args: [{
2360
- name: 'pipeSafeSanitizer',
2618
+ name: 'pipeHtmlTagRemoval',
2361
2619
  },] }
2362
2620
  ];
2363
- PipeSafeSanitizerPipe.ctorParameters = function () { return [
2364
- { type: DomSanitizer }
2365
- ]; };
2366
- return PipeSafeSanitizerPipe;
2621
+ return PipeHtmlTagRemovalPipe;
2367
2622
  }());
2368
- if (false) {
2369
- PipeSafeSanitizerPipe.prototype.sanitizer;
2370
- }
2371
2623
 
2372
- var PipeSafeSanitizerModule = (function () {
2373
- function PipeSafeSanitizerModule() {
2624
+ var PipeHtmlTagRemovalModule = (function () {
2625
+ function PipeHtmlTagRemovalModule() {
2374
2626
  }
2375
- PipeSafeSanitizerModule.decorators = [
2627
+ PipeHtmlTagRemovalModule.decorators = [
2376
2628
  { type: NgModule, args: [{
2377
- declarations: [PipeSafeSanitizerPipe],
2629
+ declarations: [PipeHtmlTagRemovalPipe],
2378
2630
  imports: [
2379
2631
  CommonModule,
2380
2632
  ],
2381
- exports: [PipeSafeSanitizerPipe],
2382
- },] }
2383
- ];
2384
- return PipeSafeSanitizerModule;
2385
- }());
2386
-
2387
- var ExploreDetailResolve = (function () {
2388
- function ExploreDetailResolve(http, configSvc, utilitySvc) {
2389
- this.http = http;
2390
- this.configSvc = configSvc;
2391
- this.utilitySvc = utilitySvc;
2392
- this.baseUrl = this.configSvc.sitePath;
2393
- this.isIntranetAllowedSettings = false;
2394
- }
2395
- ExploreDetailResolve.prototype.resolve = function (route, _state) {
2396
- var _this = this;
2397
- this.isIntranetAllowedSettings = this.configSvc.isIntranetAllowed;
2398
- var tag = decodeURIComponent(route.params.tags);
2399
- var url = '';
2400
- if (route.data.pageUrl) {
2401
- url = route.data.pageUrl;
2402
- }
2403
- if (route.data.pageType === 'page' && route.data.pageKey) {
2404
- url = this.baseUrl + "/page/" + route.data.pageKey + ".json";
2405
- }
2406
- return this.http.get(url).pipe(map((function (pageData) { return ({ data: _this.transformPageData(pageData, tag), error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
2407
- };
2408
- ExploreDetailResolve.prototype.transformPageData = function (pageData, tag) {
2409
- var _this = this;
2410
- var DELIMITER = '>';
2411
- var path = tag.split(DELIMITER);
2412
- pageData.pageLayout.widgetData.widgets = pageData.pageLayout.widgetData.widgets.map((function (widget) {
2413
- if (pageData.navigationBar && pageData.navigationBar.links) {
2414
- pageData.navigationBar.links = pageData.navigationBar.links
2415
- .filter((function (link) { return link.widgetData.tags === tag; }));
2416
- }
2417
- if (widget.widgetSubType === 'cardBreadcrumb') {
2418
- widget.widgetData.path = [{
2419
- text: pageData.navigationBar.pageTitle,
2420
- clickUrl: pageData.navigationBar.pageBackLink,
2421
- }].concat(path.map((function (edge, idx) { return ({
2422
- text: edge,
2423
- clickUrl: "/page/explore/" + path.slice(0, idx + 1).join(DELIMITER),
2424
- }); })));
2425
- }
2426
- if (widget.widgetSubType === 'contentStripMultiple') {
2427
- widget.widgetData.strips = widget.widgetData.strips.map((function (strip) {
2428
- strip.request.searchV6.filters[0].andFilters.push({ catalogPaths: [tag] });
2429
- if (_this.utilitySvc.isMobile && !_this.isIntranetAllowedSettings) {
2430
- strip.request.searchV6.filters[0].andFilters.push({ isInIntranet: ['false'] });
2431
- }
2432
- return strip;
2433
- }));
2434
- if (widget.widgetData.noDataWidget && widget.widgetData.noDataWidget.widgetData.strips) {
2435
- widget.widgetData.noDataWidget.widgetData.strips = widget.widgetData.noDataWidget.widgetData.strips.map((function (strip) {
2436
- strip.request.searchV6.filters[0].andFilters.push({ catalogPaths: [tag] });
2437
- if (_this.utilitySvc.isMobile && !_this.isIntranetAllowedSettings) {
2438
- strip.request.searchV6.filters[0].andFilters.push({ isInIntranet: ['false'] });
2439
- }
2440
- return strip;
2441
- }));
2442
- }
2443
- }
2444
- return widget;
2445
- }));
2446
- return pageData;
2447
- };
2448
- ExploreDetailResolve.decorators = [
2449
- { type: Injectable, args: [{
2450
- providedIn: 'root',
2633
+ exports: [PipeHtmlTagRemovalPipe],
2451
2634
  },] }
2452
2635
  ];
2453
- ExploreDetailResolve.ctorParameters = function () { return [
2454
- { type: HttpClient },
2455
- { type: ConfigurationsService },
2456
- { type: UtilityService }
2457
- ]; };
2458
- /** @nocollapse */ ExploreDetailResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function ExploreDetailResolve_Factory() { return new ExploreDetailResolve(ɵɵinject(HttpClient), ɵɵinject(ConfigurationsService), ɵɵinject(UtilityService)); }, token: ExploreDetailResolve, providedIn: "root" });
2459
- return ExploreDetailResolve;
2460
- }());
2461
- if (false) {
2462
- ExploreDetailResolve.prototype.baseUrl;
2463
- ExploreDetailResolve.prototype.isIntranetAllowedSettings;
2464
- ExploreDetailResolve.prototype.http;
2465
- ExploreDetailResolve.prototype.configSvc;
2466
- ExploreDetailResolve.prototype.utilitySvc;
2467
- }
2636
+ return PipeHtmlTagRemovalModule;
2637
+ }());
2468
2638
 
2469
- var MarketingOfferingResolve = (function () {
2470
- function MarketingOfferingResolve(http) {
2471
- this.http = http;
2639
+ var PipeFilterPipe = (function () {
2640
+ function PipeFilterPipe() {
2472
2641
  }
2473
- MarketingOfferingResolve.prototype.resolve = function (route, _state) {
2474
- var _this = this;
2475
- var tag = route.params.tag;
2476
- return this.http.get(route.data.pageUrl).pipe(map((function (pageData) { return ({ data: _this.transformPageData(pageData, tag), error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
2477
- };
2478
- MarketingOfferingResolve.prototype.transformPageData = function (pageData, tag) {
2479
- pageData.pageLayout.widgetData.widgets = pageData.pageLayout.widgetData.widgets.map((function (widget) {
2480
- if (widget.widgetSubType === 'contentStripMultiple') {
2481
- widget.widgetData.strips = widget.widgetData.strips.map((function (strip) {
2482
- strip.request.search.filters.catalogPaths = [decodeURIComponent(tag)];
2483
- return strip;
2484
- }));
2485
- }
2486
- return widget;
2487
- }));
2488
- return pageData;
2642
+ PipeFilterPipe.prototype.transform = function (value, keys, term) {
2643
+ if (!term) {
2644
+ return value;
2645
+ }
2646
+ return (value || []).filter((function (item) { return keys.split(',')
2647
+ .some((function (key) { return item.hasOwnProperty(key) && new RegExp("^" + term + "$", 'gi').test(item[key]); })); }));
2489
2648
  };
2490
- MarketingOfferingResolve.decorators = [
2491
- { type: Injectable, args: [{
2492
- providedIn: 'root',
2649
+ PipeFilterPipe.decorators = [
2650
+ { type: Pipe, args: [{
2651
+ name: 'pipeFilter',
2493
2652
  },] }
2494
2653
  ];
2495
- MarketingOfferingResolve.ctorParameters = function () { return [
2496
- { type: HttpClient }
2497
- ]; };
2498
- /** @nocollapse */ MarketingOfferingResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function MarketingOfferingResolve_Factory() { return new MarketingOfferingResolve(ɵɵinject(HttpClient)); }, token: MarketingOfferingResolve, providedIn: "root" });
2499
- return MarketingOfferingResolve;
2654
+ return PipeFilterPipe;
2500
2655
  }());
2501
- if (false) {
2502
- MarketingOfferingResolve.prototype.http;
2503
- }
2504
2656
 
2505
- var NsPage;
2506
- (function (NsPage) {
2507
- function IPage() { }
2508
- NsPage.IPage = IPage;
2509
- if (false) {
2510
- IPage.prototype.contentType;
2511
- IPage.prototype.navigationBar;
2512
- IPage.prototype.pageLayout;
2513
- IPage.prototype.tourGuide;
2514
- }
2515
- function INavBar() { }
2516
- NsPage.INavBar = INavBar;
2517
- if (false) {
2518
- INavBar.prototype.links;
2519
- INavBar.prototype.xsmallNonMenuLinks;
2520
- INavBar.prototype.pageBackLink;
2521
- INavBar.prototype.pageTitle;
2522
- INavBar.prototype.background;
2523
- }
2524
- function INavBackground() { }
2525
- NsPage.INavBackground = INavBackground;
2526
- if (false) {
2527
- INavBackground.prototype.color;
2528
- INavBackground.prototype.styles;
2529
- }
2530
- function INavLink() { }
2531
- NsPage.INavLink = INavLink;
2532
- if (false) {
2533
- INavLink.prototype.config;
2534
- INavLink.prototype.actionBtnId;
2535
- INavLink.prototype.actionBtn;
2536
- INavLink.prototype.actionBtnName;
2537
- }
2538
- function INavLinkConfig() { }
2539
- NsPage.INavLinkConfig = INavLinkConfig;
2540
- if (false) {
2541
- INavLinkConfig.prototype.type;
2542
- INavLinkConfig.prototype.hideIcon;
2543
- INavLinkConfig.prototype.hideTitle;
2544
- INavLinkConfig.prototype.hideStatus;
2545
- INavLinkConfig.prototype.hidePin;
2546
- INavLinkConfig.prototype.iconColor;
2547
- INavLinkConfig.prototype.treatAsCard;
2548
- INavLinkConfig.prototype.useShortName;
2657
+ var PipeFilterModule = (function () {
2658
+ function PipeFilterModule() {
2549
2659
  }
2550
- })(NsPage || (NsPage = {}));
2551
-
2552
- var JSON_MAP = {
2553
- pagename: 'lexid',
2554
- };
2660
+ PipeFilterModule.decorators = [
2661
+ { type: NgModule, args: [{
2662
+ declarations: [PipeFilterPipe],
2663
+ imports: [
2664
+ CommonModule,
2665
+ ],
2666
+ exports: [PipeFilterPipe],
2667
+ },] }
2668
+ ];
2669
+ return PipeFilterModule;
2670
+ }());
2555
2671
 
2556
- var PageResolve = (function () {
2557
- function PageResolve(configSvc, http, locale) {
2558
- this.configSvc = configSvc;
2559
- this.http = http;
2560
- this.locale = locale;
2561
- this.baseUrl = this.configSvc.sitePath;
2672
+ var PipeFilterSearchPipe = (function () {
2673
+ function PipeFilterSearchPipe() {
2562
2674
  }
2563
- PageResolve.prototype.resolve = function (route) {
2564
- if (route.data.pageUrl) {
2565
- return this.getData(route.data.pageUrl);
2566
- }
2567
- if (route.data.pageType === 'feature' && route.data.pageKey) {
2568
- return this.getData(this.baseUrl + "/feature/" + route.data.pageKey);
2569
- }
2570
- if (route.data.pageType === 'page' &&
2571
- route.data.pageKey &&
2572
- route.paramMap.has(route.data.pageKey)) {
2573
- return this.getData(this.baseUrl + "/page/" + route.paramMap.get(route.data.pageKey));
2675
+ PipeFilterSearchPipe.prototype.transform = function (items, searchText) {
2676
+ var keys = [];
2677
+ for (var _i = 2; _i < arguments.length; _i++) {
2678
+ keys[_i - 2] = arguments[_i];
2574
2679
  }
2575
- if (route.data.pageType === 'page' &&
2576
- route.data.pageKey &&
2577
- route.data.pageKey === 'toc') {
2578
- return this.getData(this.baseUrl + "/page/" + route.data.pageKey);
2680
+ if (!items) {
2681
+ return [];
2579
2682
  }
2580
- return {
2581
- data: null,
2582
- error: 'CONFIGURATION_ERROR_PAGE_URL_NOT_FORMED',
2583
- };
2584
- };
2585
- PageResolve.prototype.setS3Cookie = function (contentId) {
2586
- return this.http.post("/apis/protected/v8/content/setCookie", { contentId: contentId }).pipe(catchError((function (_err) { return of(true); })));
2587
- };
2588
- PageResolve.prototype.getContent = function (id) {
2589
- return this.http
2590
- .post("/apis/protected/v8/content/" + id + "?hierarchyType=minimal", ['status', 'artifactUrl']);
2591
- };
2592
- PageResolve.prototype.getData = function (url) {
2593
- var _this = this;
2594
- var id = (((url.split('/').pop()))).split('.')[0] || '';
2595
- var equivalentId = id.startsWith('lex_auth_') ? id : JSON_MAP[id];
2596
- if (equivalentId) {
2597
- return forkJoin([this.setS3Cookie(equivalentId), this.getContent(equivalentId)]).pipe(mergeMap((function (_a) {
2598
- var _b = __read(_a, 2), _ = _b[0], v = _b[1];
2599
- if (v.status === 'Expired' || v.status === 'Deleted' || !v.artifactUrl) {
2600
- return of({ data: null, error: 'NoContent' });
2601
- }
2602
- return _this.http
2603
- .get(v.artifactUrl + "?ts=" + new Date().getTime())
2604
- .pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
2605
- })), catchError((function (err) { return of({ data: null, error: err }); })));
2683
+ if (!searchText) {
2684
+ return items;
2606
2685
  }
2607
- var pageRequest = [
2608
- (equivalentId ? this.setS3Cookie(equivalentId) : of(true)).pipe(mergeMap((function () {
2609
- return _this.http.get(url + ".json").pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
2610
- }))),
2611
- this.locale === 'en' || this.locale === 'en-US' ?
2612
- of({ data: ((undefined)), error: null }) :
2613
- this.http.get(url + "." + this.locale + ".json").pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); }))),
2614
- ];
2615
- return forkJoin(pageRequest).pipe(map((function (_a) {
2616
- var _b = __read(_a, 2), general = _b[0], withLocale = _b[1];
2617
- if (withLocale.data) {
2618
- return withLocale;
2686
+ var searchTextLowerCase = searchText.toLowerCase();
2687
+ if (keys && keys.length) {
2688
+ var result = items.filter((function (it) {
2689
+ return it['personalDetails'][keys[0]].toLowerCase().includes(searchTextLowerCase);
2690
+ }));
2691
+ if (result && result.length <= 0) {
2692
+ return [-1];
2619
2693
  }
2620
- return general;
2621
- })));
2694
+ return result;
2695
+ }
2696
+ return items.filter((function (it) {
2697
+ return it.title.toLowerCase().includes(searchTextLowerCase);
2698
+ }));
2622
2699
  };
2623
- PageResolve.decorators = [
2624
- { type: Injectable, args: [{
2625
- providedIn: 'root',
2700
+ PipeFilterSearchPipe.decorators = [
2701
+ { type: Pipe, args: [{
2702
+ name: 'pipeFilterSearch',
2626
2703
  },] }
2627
2704
  ];
2628
- PageResolve.ctorParameters = function () { return [
2629
- { type: ConfigurationsService },
2630
- { type: HttpClient },
2631
- { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
2632
- ]; };
2633
- /** @nocollapse */ PageResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function PageResolve_Factory() { return new PageResolve(ɵɵinject(ConfigurationsService), ɵɵinject(HttpClient), ɵɵinject(LOCALE_ID)); }, token: PageResolve, providedIn: "root" });
2634
- return PageResolve;
2705
+ return PipeFilterSearchPipe;
2635
2706
  }());
2636
- if (false) {
2637
- PageResolve.prototype.baseUrl;
2638
- PageResolve.prototype.configSvc;
2639
- PageResolve.prototype.http;
2640
- PageResolve.prototype.locale;
2641
- }
2642
2707
 
2643
- function IResolveResponse() { }
2644
- if (false) {
2645
- IResolveResponse.prototype.data;
2646
- IResolveResponse.prototype.error;
2647
- }
2648
-
2649
- var LoggerService = (function () {
2650
- function LoggerService(configSvc) {
2651
- this.configSvc = configSvc;
2652
- this.consoleError = console.error;
2653
- this.consoleInfo = console.info;
2654
- this.consoleLog = console.log;
2655
- this.consoleWarn = console.warn;
2656
- this.noConsole = (function () { });
2708
+ var PipeFilterSearchModule = (function () {
2709
+ function PipeFilterSearchModule() {
2657
2710
  }
2658
- Object.defineProperty(LoggerService.prototype, "error", {
2659
- get: function () {
2660
- return this.consoleError;
2661
- },
2662
- enumerable: true,
2663
- configurable: true
2664
- });
2665
- Object.defineProperty(LoggerService.prototype, "info", {
2666
- get: function () {
2667
- return this.configSvc.isProduction ? this.noConsole : this.consoleInfo;
2668
- },
2669
- enumerable: true,
2670
- configurable: true
2671
- });
2672
- Object.defineProperty(LoggerService.prototype, "log", {
2673
- get: function () {
2674
- return this.configSvc.isProduction ? this.noConsole : this.consoleLog;
2675
- },
2676
- enumerable: true,
2677
- configurable: true
2678
- });
2679
- Object.defineProperty(LoggerService.prototype, "warn", {
2680
- get: function () {
2681
- return this.configSvc.isProduction ? this.noConsole : this.consoleWarn;
2682
- },
2683
- enumerable: true,
2684
- configurable: true
2685
- });
2686
- LoggerService.prototype.removeConsoleAccess = function () {
2687
- if (this.configSvc.isProduction) {
2688
- return;
2711
+ PipeFilterSearchModule.decorators = [
2712
+ { type: NgModule, args: [{
2713
+ declarations: [PipeFilterSearchPipe],
2714
+ imports: [
2715
+ CommonModule,
2716
+ ],
2717
+ exports: [PipeFilterSearchPipe],
2718
+ },] }
2719
+ ];
2720
+ return PipeFilterSearchModule;
2721
+ }());
2722
+
2723
+ var PipeListFilterPipe = (function () {
2724
+ function PipeListFilterPipe() {
2725
+ }
2726
+ PipeListFilterPipe.prototype.transform = function (value, keys, term) {
2727
+ if (!term) {
2728
+ return value;
2689
2729
  }
2690
- var noConsoleWithError = (function () {
2691
- throw new Error('Console Functions Usage Are Not Allowed.');
2692
- });
2693
- console.warn = noConsoleWithError;
2694
- console.info = noConsoleWithError;
2695
- console.error = noConsoleWithError;
2730
+ return (value || []).filter((function (item) { return keys.split(',')
2731
+ .some((function (key) { return item.hasOwnProperty(key)
2732
+ && item[key] && (item[key] + " ").toLocaleLowerCase().includes(term.toLocaleLowerCase()); })); }));
2696
2733
  };
2697
- LoggerService.decorators = [
2698
- { type: Injectable, args: [{
2699
- providedIn: 'root',
2734
+ PipeListFilterPipe.decorators = [
2735
+ { type: Pipe, args: [{
2736
+ name: 'pipeListFilter',
2700
2737
  },] }
2701
2738
  ];
2702
- LoggerService.ctorParameters = function () { return [
2703
- { type: ConfigurationsService }
2704
- ]; };
2705
- /** @nocollapse */ LoggerService.ngInjectableDef = ɵɵdefineInjectable({ factory: function LoggerService_Factory() { return new LoggerService(ɵɵinject(ConfigurationsService)); }, token: LoggerService, providedIn: "root" });
2706
- return LoggerService;
2739
+ return PipeListFilterPipe;
2707
2740
  }());
2708
- if (false) {
2709
- LoggerService.prototype.consoleError;
2710
- LoggerService.prototype.consoleInfo;
2711
- LoggerService.prototype.consoleLog;
2712
- LoggerService.prototype.consoleWarn;
2713
- LoggerService.prototype.noConsole;
2714
- LoggerService.prototype.configSvc;
2715
- }
2716
2741
 
2717
- var msTokenExpiryDuration = 600;
2718
- var storageKey = 'msLoginRequested';
2719
- var storage = localStorage;
2720
- var API_ENDPOINTS = {
2721
- sharePointToken: '/apis/protected/v8/user/token',
2722
- };
2723
- var AuthMicrosoftService = (function () {
2724
- function AuthMicrosoftService(loggerSvc, http) {
2725
- this.loggerSvc = loggerSvc;
2726
- this.http = http;
2727
- this.msConfig = {
2728
- clientId: '',
2729
- tenant: '',
2730
- defaultEmailId: '',
2731
- validEmailExtensions: [],
2732
- isConfigured: false,
2733
- };
2734
- this.emailUsed = null;
2735
- this.code = null;
2736
- this.msToken = {
2737
- accessToken: '',
2738
- expiresOn: '',
2739
- resource: '',
2740
- tokenType: '',
2741
- };
2742
+ var PipeListFilterModule = (function () {
2743
+ function PipeListFilterModule() {
2742
2744
  }
2743
- Object.defineProperty(AuthMicrosoftService.prototype, "isLogoutRequired", {
2744
- get: function () {
2745
- return Boolean(this.msConfig.isConfigured && this.msConfig.clientId && this.emailUsed);
2746
- },
2747
- enumerable: true,
2748
- configurable: true
2749
- });
2750
- Object.defineProperty(AuthMicrosoftService.prototype, "loginUrl", {
2751
- get: function () {
2752
- if (this.msConfig.isConfigured && this.msConfig.clientId) {
2753
- var base = 'https://login.windows.net/common/oauth2/authorize';
2754
- var searchParam = new URLSearchParams({
2755
- response_type: 'code',
2756
- client_id: this.msConfig.clientId,
2757
- redirect_uri: window.location.href,
2758
- });
2759
- var fragment = location.search.substring(1);
2760
- if (fragment) {
2761
- return base + "?" + searchParam.toString() + "#" + fragment;
2762
- }
2763
- return base + "?" + searchParam.toString();
2764
- }
2765
- return null;
2766
- },
2767
- enumerable: true,
2768
- configurable: true
2769
- });
2770
- AuthMicrosoftService.prototype.logoutUrl = function (redirectUrl) {
2771
- if (this.isValidEmail(this.emailUsed || '')) {
2772
- return "https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri=" + redirectUrl;
2745
+ PipeListFilterModule.decorators = [
2746
+ { type: NgModule, args: [{
2747
+ declarations: [PipeListFilterPipe],
2748
+ imports: [
2749
+ CommonModule,
2750
+ ],
2751
+ exports: [PipeListFilterPipe],
2752
+ },] }
2753
+ ];
2754
+ return PipeListFilterModule;
2755
+ }());
2756
+
2757
+ var PipeRelativeTimePipe = (function () {
2758
+ function PipeRelativeTimePipe() {
2759
+ }
2760
+ PipeRelativeTimePipe.prototype.transform = function (value) {
2761
+ if (value) {
2762
+ return moment((new Date(value))).fromNow();
2773
2763
  }
2774
- return redirectUrl;
2775
- };
2776
- AuthMicrosoftService.prototype.init = function (config) {
2777
- return __awaiter(this, void 0, void 0, function () {
2778
- var queryParams, url;
2779
- return __generator(this, function (_a) {
2780
- switch (_a.label) {
2781
- case 0:
2782
- if (!config || !config.microsoft || !config.microsoft.isConfigured) {
2783
- this.loggerSvc.warn('Empty/No Configuration passed, ignoring Microsoft Authentication');
2784
- }
2785
- this.msConfig = config.microsoft;
2786
- queryParams = new URLSearchParams(location.search);
2787
- if (!(queryParams.has('code') && queryParams.has('session_state'))) return [3, 2];
2788
- this.code = queryParams.get('code');
2789
- if (!this.code) {
2790
- return [2];
2791
- }
2792
- url = location.origin + location.pathname;
2793
- return [4, this.exchangeTokenForCode(this.code, url)];
2794
- case 1:
2795
- _a.sent();
2796
- if (location.hash) {
2797
- url += location.hash.substring(1);
2798
- }
2799
- history.replaceState(null, '', url);
2800
- _a.label = 2;
2801
- case 2: return [2];
2802
- }
2803
- });
2804
- });
2805
- };
2806
- AuthMicrosoftService.prototype.login = function (email) {
2807
- return __awaiter(this, void 0, void 0, function () {
2808
- var loginUrl;
2809
- return __generator(this, function (_a) {
2810
- if (!this.isValidEmail(email)) {
2811
- this.loggerSvc.warn("Microsoft Login is not allowed for your emailId (" + email + ")");
2812
- return [2];
2813
- }
2814
- loginUrl = this.loginUrl;
2815
- if (loginUrl) {
2816
- location.assign(loginUrl);
2817
- }
2818
- else {
2819
- this.loggerSvc.warn('Unable to identify Office Login URL, Ignoring login request');
2820
- }
2821
- return [2];
2822
- });
2823
- });
2824
- };
2825
- AuthMicrosoftService.prototype.getToken = function (email) {
2826
- return __awaiter(this, void 0, void 0, function () {
2827
- var _a, error_1, _b, error_2;
2828
- return __generator(this, function (_c) {
2829
- switch (_c.label) {
2830
- case 0:
2831
- if (this.msToken &&
2832
- this.isValid(this.msToken.accessToken, this.msToken.expiresOn) &&
2833
- this.msToken.accessToken) {
2834
- return [2, this.msToken.accessToken];
2835
- }
2836
- if (!this.isValidEmail(email)) return [3, 4];
2837
- _c.label = 1;
2838
- case 1:
2839
- _c.trys.push([1, 3, , 4]);
2840
- _a = this;
2841
- return [4, this.getTokenForEmail(email)];
2842
- case 2:
2843
- _a.msToken = _c.sent();
2844
- if (this.msToken.accessToken) {
2845
- this.emailUsed = email;
2846
- return [2, this.msToken.accessToken];
2847
- }
2848
- return [3, 4];
2849
- case 3:
2850
- error_1 = _c.sent();
2851
- if (!this.code) {
2852
- this.login(email);
2853
- }
2854
- return [3, 4];
2855
- case 4:
2856
- if (!(this.msConfig.defaultEmailId && this.isValidEmail(this.msConfig.defaultEmailId))) return [3, 8];
2857
- _c.label = 5;
2858
- case 5:
2859
- _c.trys.push([5, 7, , 8]);
2860
- _b = this;
2861
- return [4, this.getTokenForEmail(this.msConfig.defaultEmailId)];
2862
- case 6:
2863
- _b.msToken = _c.sent();
2864
- if (this.msToken.accessToken) {
2865
- this.emailUsed = this.msConfig.defaultEmailId;
2866
- return [2, this.msToken.accessToken];
2867
- }
2868
- return [3, 8];
2869
- case 7:
2870
- error_2 = _c.sent();
2871
- return [3, 8];
2872
- case 8: throw new Error('UNABLE TO FETCH MS AUTH TOKEN');
2873
- }
2874
- });
2875
- });
2764
+ return moment().startOf('hour').fromNow();
2876
2765
  };
2877
- AuthMicrosoftService.prototype.loginForSSOEnabledEmbed = function (email) {
2878
- if (!this.isValidEmail(email)) {
2879
- this.loggerSvc.warn('SSO Login request Ignored. Invalid Email Id for SSO Enabled Content');
2766
+ PipeRelativeTimePipe.decorators = [
2767
+ { type: Pipe, args: [{
2768
+ name: 'pipeRelativeTime',
2769
+ },] }
2770
+ ];
2771
+ return PipeRelativeTimePipe;
2772
+ }());
2773
+
2774
+ var PipeRelativeTimeModule = (function () {
2775
+ function PipeRelativeTimeModule() {
2776
+ }
2777
+ PipeRelativeTimeModule.decorators = [
2778
+ { type: NgModule, args: [{
2779
+ declarations: [PipeRelativeTimePipe],
2780
+ imports: [
2781
+ CommonModule,
2782
+ ],
2783
+ exports: [PipeRelativeTimePipe],
2784
+ },] }
2785
+ ];
2786
+ return PipeRelativeTimeModule;
2787
+ }());
2788
+
2789
+ var OrderByPipe = (function () {
2790
+ function OrderByPipe() {
2791
+ this.transform = orderBy;
2792
+ }
2793
+ OrderByPipe.decorators = [
2794
+ { type: Pipe, args: [{
2795
+ name: 'orderBy',
2796
+ },] }
2797
+ ];
2798
+ return OrderByPipe;
2799
+ }());
2800
+ if (false) {
2801
+ OrderByPipe.prototype.transform;
2802
+ }
2803
+
2804
+ var PipeOrderByModule = (function () {
2805
+ function PipeOrderByModule() {
2806
+ }
2807
+ PipeOrderByModule.decorators = [
2808
+ { type: NgModule, args: [{
2809
+ declarations: [OrderByPipe],
2810
+ imports: [
2811
+ CommonModule,
2812
+ ],
2813
+ exports: [OrderByPipe],
2814
+ },] }
2815
+ ];
2816
+ return PipeOrderByModule;
2817
+ }());
2818
+
2819
+ var PipeLimitToPipe = (function () {
2820
+ function PipeLimitToPipe() {
2821
+ }
2822
+ PipeLimitToPipe.prototype.transform = function (data, limit) {
2823
+ if (limit === void 0) { limit = 5; }
2824
+ if (!data || !data.length) {
2825
+ return null;
2880
2826
  }
2881
- var msPrevTS = 0;
2882
- try {
2883
- msPrevTS = parseInt(storage.getItem(storageKey) || '0', 10);
2827
+ if (Array.isArray(data)) {
2828
+ return data.slice(0, limit);
2884
2829
  }
2885
- catch (error) { }
2886
- if (!msPrevTS || (msPrevTS && (Date.now() - msPrevTS) / 1000 > msTokenExpiryDuration)) {
2887
- this.loggerSvc.info("last login exceeded " + msTokenExpiryDuration + " duration. Redirecting to O365 login");
2888
- storage.setItem(storageKey, Date.now().toString());
2889
- this.login(email);
2830
+ if (typeof data === 'string') {
2831
+ var slicedString = data.substr(0, limit);
2832
+ if (limit < data.length) {
2833
+ return slicedString + "...";
2834
+ }
2835
+ return slicedString;
2890
2836
  }
2837
+ return null;
2891
2838
  };
2892
- AuthMicrosoftService.prototype.isValidEmail = function (email) {
2893
- return this.msConfig.validEmailExtensions.some((function (ext) { return email.endsWith(ext); }));
2894
- };
2895
- AuthMicrosoftService.prototype.isValid = function (accessToken, expiresOn) {
2896
- if (accessToken && expiresOn) {
2897
- return true;
2839
+ PipeLimitToPipe.decorators = [
2840
+ { type: Pipe, args: [{
2841
+ name: 'pipeLimitTo',
2842
+ },] }
2843
+ ];
2844
+ return PipeLimitToPipe;
2845
+ }());
2846
+
2847
+ var PipeLimitToModule = (function () {
2848
+ function PipeLimitToModule() {
2849
+ }
2850
+ PipeLimitToModule.decorators = [
2851
+ { type: NgModule, args: [{
2852
+ declarations: [PipeLimitToPipe],
2853
+ imports: [
2854
+ CommonModule,
2855
+ ],
2856
+ exports: [PipeLimitToPipe],
2857
+ },] }
2858
+ ];
2859
+ return PipeLimitToModule;
2860
+ }());
2861
+
2862
+ function IUserName() { }
2863
+ if (false) {
2864
+ IUserName.prototype.firstName;
2865
+ IUserName.prototype.lastName;
2866
+ IUserName.prototype.email;
2867
+ }
2868
+ var PipeNameTransformPipe = (function () {
2869
+ function PipeNameTransformPipe() {
2870
+ }
2871
+ PipeNameTransformPipe.prototype.transform = function (value) {
2872
+ var result = '';
2873
+ if (value.firstName) {
2874
+ result += value.firstName;
2898
2875
  }
2899
- return false;
2900
- };
2901
- AuthMicrosoftService.prototype.exchangeTokenForCode = function (code, redirectUrl) {
2902
- return __awaiter(this, void 0, void 0, function () {
2903
- var response;
2904
- return __generator(this, function (_a) {
2905
- switch (_a.label) {
2906
- case 0: return [4, this.http
2907
- .get(API_ENDPOINTS + "?code=" + code + "&redirectUrl=" + redirectUrl)
2908
- .toPromise()];
2909
- case 1:
2910
- response = _a.sent();
2911
- return [2, this.getInstanceFromResponse(response)];
2912
- }
2913
- });
2914
- });
2876
+ if (value.lastName && value.lastName !== value.firstName) {
2877
+ result += " " + value.lastName;
2878
+ }
2879
+ if (result.trim() !== '') {
2880
+ return result;
2881
+ }
2882
+ if (value.email) {
2883
+ return value.email;
2884
+ }
2885
+ return 'Anonymous User';
2915
2886
  };
2916
- AuthMicrosoftService.prototype.getTokenForEmail = function (email) {
2917
- return __awaiter(this, void 0, void 0, function () {
2918
- var response;
2919
- return __generator(this, function (_a) {
2920
- switch (_a.label) {
2921
- case 0: return [4, this.http
2922
- .get(API_ENDPOINTS.sharePointToken + "?email=" + email)
2923
- .toPromise()];
2924
- case 1:
2925
- response = _a.sent();
2926
- return [2, this.getInstanceFromResponse(response)];
2887
+ PipeNameTransformPipe.decorators = [
2888
+ { type: Pipe, args: [{
2889
+ name: 'pipeNameTransform',
2890
+ },] }
2891
+ ];
2892
+ return PipeNameTransformPipe;
2893
+ }());
2894
+
2895
+ var PipeNameTransformModule = (function () {
2896
+ function PipeNameTransformModule() {
2897
+ }
2898
+ PipeNameTransformModule.decorators = [
2899
+ { type: NgModule, args: [{
2900
+ declarations: [PipeNameTransformPipe],
2901
+ imports: [
2902
+ CommonModule,
2903
+ ],
2904
+ exports: [PipeNameTransformPipe],
2905
+ },] }
2906
+ ];
2907
+ return PipeNameTransformModule;
2908
+ }());
2909
+
2910
+ var PipePartialContentPipe = (function () {
2911
+ function PipePartialContentPipe() {
2912
+ }
2913
+ PipePartialContentPipe.prototype.transform = function (value, keys) {
2914
+ var e_1, _a;
2915
+ var result = {};
2916
+ try {
2917
+ for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
2918
+ var key = keys_1_1.value;
2919
+ if (value[key]) {
2920
+ result[key] = value[key];
2927
2921
  }
2928
- });
2929
- });
2922
+ }
2923
+ }
2924
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2925
+ finally {
2926
+ try {
2927
+ if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
2928
+ }
2929
+ finally { if (e_1) throw e_1.error; }
2930
+ }
2931
+ return result;
2930
2932
  };
2931
- AuthMicrosoftService.prototype.getInstanceFromResponse = function (token) {
2932
- return {
2933
- accessToken: token.accessToken,
2934
- expiresOn: token.expiresOn,
2935
- resource: token.resource,
2936
- tokenType: token.tokenType,
2937
- };
2933
+ PipePartialContentPipe.decorators = [
2934
+ { type: Pipe, args: [{
2935
+ name: 'pipePartialContent',
2936
+ },] }
2937
+ ];
2938
+ return PipePartialContentPipe;
2939
+ }());
2940
+
2941
+ var PipePartialContentModule = (function () {
2942
+ function PipePartialContentModule() {
2943
+ }
2944
+ PipePartialContentModule.decorators = [
2945
+ { type: NgModule, args: [{
2946
+ declarations: [PipePartialContentPipe],
2947
+ imports: [
2948
+ CommonModule,
2949
+ ],
2950
+ exports: [PipePartialContentPipe],
2951
+ },] }
2952
+ ];
2953
+ return PipePartialContentModule;
2954
+ }());
2955
+
2956
+ var PipeSafeSanitizerPipe = (function () {
2957
+ function PipeSafeSanitizerPipe(sanitizer) {
2958
+ this.sanitizer = sanitizer;
2959
+ }
2960
+ PipeSafeSanitizerPipe.prototype.transform = function (value, type) {
2961
+ if (type === void 0) { type = 'html'; }
2962
+ switch (type) {
2963
+ case 'html':
2964
+ return this.sanitizer.bypassSecurityTrustHtml(value);
2965
+ case 'style':
2966
+ return this.sanitizer.bypassSecurityTrustStyle(value);
2967
+ case 'script':
2968
+ return this.sanitizer.bypassSecurityTrustScript(value);
2969
+ case 'url':
2970
+ return this.sanitizer.bypassSecurityTrustUrl(value);
2971
+ case 'resourceUrl':
2972
+ return this.sanitizer.bypassSecurityTrustResourceUrl(value);
2973
+ default:
2974
+ throw new Error("Invalid safe type specified: " + type);
2975
+ }
2938
2976
  };
2939
- AuthMicrosoftService.decorators = [
2940
- { type: Injectable, args: [{
2941
- providedIn: 'root',
2977
+ PipeSafeSanitizerPipe.decorators = [
2978
+ { type: Pipe, args: [{
2979
+ name: 'pipeSafeSanitizer',
2942
2980
  },] }
2943
2981
  ];
2944
- AuthMicrosoftService.ctorParameters = function () { return [
2945
- { type: LoggerService },
2946
- { type: HttpClient }
2982
+ PipeSafeSanitizerPipe.ctorParameters = function () { return [
2983
+ { type: DomSanitizer }
2947
2984
  ]; };
2948
- /** @nocollapse */ AuthMicrosoftService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthMicrosoftService_Factory() { return new AuthMicrosoftService(ɵɵinject(LoggerService), ɵɵinject(HttpClient)); }, token: AuthMicrosoftService, providedIn: "root" });
2949
- return AuthMicrosoftService;
2985
+ return PipeSafeSanitizerPipe;
2950
2986
  }());
2951
2987
  if (false) {
2952
- AuthMicrosoftService.prototype.msConfig;
2953
- AuthMicrosoftService.prototype.emailUsed;
2954
- AuthMicrosoftService.prototype.code;
2955
- AuthMicrosoftService.prototype.msToken;
2956
- AuthMicrosoftService.prototype.loggerSvc;
2957
- AuthMicrosoftService.prototype.http;
2988
+ PipeSafeSanitizerPipe.prototype.sanitizer;
2958
2989
  }
2959
2990
 
2960
- function IParsedToken() { }
2961
- if (false) {
2962
- IParsedToken.prototype.email;
2963
- IParsedToken.prototype.encEmail;
2964
- IParsedToken.prototype.name;
2965
- IParsedToken.prototype.preferred_username;
2966
- }
2967
- var storage$1 = localStorage;
2968
- var storageKey$1 = 'kc';
2969
- var AuthKeycloakService = (function () {
2970
- function AuthKeycloakService(http, configSvc, keycloakSvc, msAuthSvc) {
2971
- var _this = this;
2991
+ var PipeSafeSanitizerModule = (function () {
2992
+ function PipeSafeSanitizerModule() {
2993
+ }
2994
+ PipeSafeSanitizerModule.decorators = [
2995
+ { type: NgModule, args: [{
2996
+ declarations: [PipeSafeSanitizerPipe],
2997
+ imports: [
2998
+ CommonModule,
2999
+ ],
3000
+ exports: [PipeSafeSanitizerPipe],
3001
+ },] }
3002
+ ];
3003
+ return PipeSafeSanitizerModule;
3004
+ }());
3005
+
3006
+ var ExploreDetailResolve = (function () {
3007
+ function ExploreDetailResolve(http, configSvc, utilitySvc) {
2972
3008
  this.http = http;
2973
3009
  this.configSvc = configSvc;
2974
- this.keycloakSvc = keycloakSvc;
2975
- this.msAuthSvc = msAuthSvc;
2976
- this.loginChangeSubject = new ReplaySubject(1);
2977
- this.loginChangeSubject.subscribe((function (isLoggedIn) {
2978
- _this.configSvc.isAuthenticated = isLoggedIn;
2979
- if (isLoggedIn &&
2980
- _this.configSvc.instanceConfig &&
2981
- Boolean(_this.configSvc.instanceConfig.disablePidCheck)) {
2982
- _this.configSvc.userProfile = {
2983
- email: _this.userEmail,
2984
- userName: _this.userName,
2985
- userId: _this.userId || '',
2986
- };
2987
- }
2988
- }));
3010
+ this.utilitySvc = utilitySvc;
3011
+ this.baseUrl = this.configSvc.sitePath;
3012
+ this.isIntranetAllowedSettings = false;
2989
3013
  }
2990
- Object.defineProperty(AuthKeycloakService.prototype, "isLoggedIn$", {
2991
- get: function () {
2992
- return this.loginChangeSubject.asObservable();
2993
- },
2994
- enumerable: true,
2995
- configurable: true
2996
- });
2997
- Object.defineProperty(AuthKeycloakService.prototype, "isLoggedIn", {
2998
- get: function () {
2999
- return this.keycloakSvc.isLoggedIn();
3000
- },
3001
- enumerable: true,
3002
- configurable: true
3003
- });
3004
- Object.defineProperty(AuthKeycloakService.prototype, "isAuthenticated", {
3005
- get: function () {
3006
- return this.keycloakSvc.getKeycloakInstance().authenticated;
3007
- },
3008
- enumerable: true,
3009
- configurable: true
3010
- });
3011
- Object.defineProperty(AuthKeycloakService.prototype, "token", {
3012
- get: function () {
3013
- return this.keycloakSvc.getKeycloakInstance().token;
3014
- },
3015
- enumerable: true,
3016
- configurable: true
3017
- });
3018
- Object.defineProperty(AuthKeycloakService.prototype, "sessionId", {
3019
- get: function () {
3020
- return this.keycloakSvc.getKeycloakInstance().sessionId;
3021
- },
3022
- enumerable: true,
3023
- configurable: true
3024
- });
3025
- Object.defineProperty(AuthKeycloakService.prototype, "userId", {
3026
- get: function () {
3027
- var kc = this.keycloakSvc.getKeycloakInstance();
3028
- if (!kc) {
3029
- return;
3014
+ ExploreDetailResolve.prototype.resolve = function (route, _state) {
3015
+ var _this = this;
3016
+ this.isIntranetAllowedSettings = this.configSvc.isIntranetAllowed;
3017
+ var tag = decodeURIComponent(route.params.tags);
3018
+ var url = '';
3019
+ if (route.data.pageUrl) {
3020
+ url = route.data.pageUrl;
3021
+ }
3022
+ if (route.data.pageType === 'page' && route.data.pageKey) {
3023
+ url = this.baseUrl + "/page/" + route.data.pageKey + ".json";
3024
+ }
3025
+ return this.http.get(url).pipe(map((function (pageData) { return ({ data: _this.transformPageData(pageData, tag), error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
3026
+ };
3027
+ ExploreDetailResolve.prototype.transformPageData = function (pageData, tag) {
3028
+ var _this = this;
3029
+ var DELIMITER = '>';
3030
+ var path = tag.split(DELIMITER);
3031
+ pageData.pageLayout.widgetData.widgets = pageData.pageLayout.widgetData.widgets.map((function (widget) {
3032
+ if (pageData.navigationBar && pageData.navigationBar.links) {
3033
+ pageData.navigationBar.links = pageData.navigationBar.links
3034
+ .filter((function (link) { return link.widgetData.tags === tag; }));
3030
3035
  }
3031
- return (kc.tokenParsed && kc.tokenParsed.sub) || (kc.idTokenParsed && kc.idTokenParsed.sub);
3032
- },
3033
- enumerable: true,
3034
- configurable: true
3035
- });
3036
- Object.defineProperty(AuthKeycloakService.prototype, "userEmail", {
3037
- get: function () {
3038
- var kc = this.keycloakSvc.getKeycloakInstance();
3039
- var tokenParsed = ((kc.tokenParsed));
3040
- var idTokenParsed = ((kc.idTokenParsed));
3041
- return ((tokenParsed && tokenParsed.email) ||
3042
- (idTokenParsed && idTokenParsed.email) ||
3043
- (idTokenParsed && idTokenParsed.encEmail) ||
3044
- (tokenParsed && tokenParsed.preferred_username) ||
3045
- (idTokenParsed && idTokenParsed.preferred_username));
3046
- },
3047
- enumerable: true,
3048
- configurable: true
3049
- });
3050
- Object.defineProperty(AuthKeycloakService.prototype, "userName", {
3051
- get: function () {
3052
- var kc = this.keycloakSvc.getKeycloakInstance();
3053
- return ((kc.tokenParsed && (((kc.tokenParsed))).name) ||
3054
- (kc.idTokenParsed && (((kc.idTokenParsed))).name));
3055
- },
3056
- enumerable: true,
3057
- configurable: true
3058
- });
3059
- AuthKeycloakService.prototype.initAuth = function () {
3060
- return __awaiter(this, void 0, void 0, function () {
3061
- var instanceConfig, err_1;
3062
- return __generator(this, function (_a) {
3063
- switch (_a.label) {
3064
- case 0:
3065
- if (!this.configSvc.instanceConfig) {
3066
- return [2, false];
3067
- }
3068
- instanceConfig = this.configSvc.instanceConfig;
3069
- if (instanceConfig.microsoft.isConfigured) {
3070
- this.msAuthSvc.init({ microsoft: instanceConfig.microsoft });
3036
+ if (widget.widgetSubType === 'cardBreadcrumb') {
3037
+ widget.widgetData.path = [{
3038
+ text: pageData.navigationBar.pageTitle,
3039
+ clickUrl: pageData.navigationBar.pageBackLink,
3040
+ }].concat(path.map((function (edge, idx) { return ({
3041
+ text: edge,
3042
+ clickUrl: "/page/explore/" + path.slice(0, idx + 1).join(DELIMITER),
3043
+ }); })));
3044
+ }
3045
+ if (widget.widgetSubType === 'contentStripMultiple') {
3046
+ widget.widgetData.strips = widget.widgetData.strips.map((function (strip) {
3047
+ strip.request.searchV6.filters[0].andFilters.push({ catalogPaths: [tag] });
3048
+ if (_this.utilitySvc.isMobile && !_this.isIntranetAllowedSettings) {
3049
+ strip.request.searchV6.filters[0].andFilters.push({ isInIntranet: ['false'] });
3050
+ }
3051
+ return strip;
3052
+ }));
3053
+ if (widget.widgetData.noDataWidget && widget.widgetData.noDataWidget.widgetData.strips) {
3054
+ widget.widgetData.noDataWidget.widgetData.strips = widget.widgetData.noDataWidget.widgetData.strips.map((function (strip) {
3055
+ strip.request.searchV6.filters[0].andFilters.push({ catalogPaths: [tag] });
3056
+ if (_this.utilitySvc.isMobile && !_this.isIntranetAllowedSettings) {
3057
+ strip.request.searchV6.filters[0].andFilters.push({ isInIntranet: ['false'] });
3071
3058
  }
3072
- _a.label = 1;
3073
- case 1:
3074
- _a.trys.push([1, 3, , 4]);
3075
- this.setupGlobalAuthResponder();
3076
- this.addKeycloakEventListener();
3077
- return [4, this.keycloakSvc.init({
3078
- config: {
3079
- url: instanceConfig.keycloak.url,
3080
- realm: instanceConfig.keycloak.realm,
3081
- clientId: instanceConfig.keycloak.clientId,
3082
- },
3083
- initOptions: __assign({}, this.getSavedKcConfig(), { onLoad: instanceConfig.keycloak.onLoad || 'check-sso', checkLoginIframe: false }),
3084
- enableBearerInterceptor: true,
3085
- loadUserProfileAtStartUp: false,
3086
- bearerExcludedUrls: instanceConfig.keycloak.bearerExcludedUrls,
3087
- })];
3088
- case 2: return [2, _a.sent()];
3089
- case 3:
3090
- err_1 = _a.sent();
3091
- return [2, false];
3092
- case 4: return [2];
3093
- }
3094
- });
3095
- });
3096
- };
3097
- AuthKeycloakService.prototype.login = function (idpHint, redirectUrl) {
3098
- if (idpHint === void 0) { idpHint = 'E'; }
3099
- if (redirectUrl === void 0) { redirectUrl = this.defaultRedirectUrl; }
3100
- return this.keycloakSvc.login({
3101
- idpHint: idpHint,
3102
- redirectUri: redirectUrl,
3103
- });
3104
- };
3105
- AuthKeycloakService.prototype.register = function (redirectUrl) {
3106
- if (redirectUrl === void 0) { redirectUrl = this.defaultRedirectUrl; }
3107
- return this.keycloakSvc.register({
3108
- redirectUri: redirectUrl,
3109
- });
3110
- };
3111
- AuthKeycloakService.prototype.logout = function (_redirectUrl) {
3112
- if (_redirectUrl === void 0) { _redirectUrl = this.defaultRedirectUrl; }
3113
- return __awaiter(this, void 0, void 0, function () {
3114
- return __generator(this, function (_a) {
3115
- window.location.href = _redirectUrl + "apis/reset";
3116
- return [2];
3117
- });
3118
- });
3119
- };
3120
- AuthKeycloakService.prototype.force_logout = function () {
3121
- return __awaiter(this, void 0, void 0, function () {
3122
- return __generator(this, function (_a) {
3123
- switch (_a.label) {
3124
- case 0: return [4, this.http.get('/apis/reset').toPromise()];
3125
- case 1:
3126
- _a.sent();
3127
- return [2];
3059
+ return strip;
3060
+ }));
3128
3061
  }
3129
- });
3130
- });
3062
+ }
3063
+ return widget;
3064
+ }));
3065
+ return pageData;
3131
3066
  };
3132
- AuthKeycloakService.prototype.addKeycloakEventListener = function () {
3133
- var _this = this;
3134
- this.keycloakSvc.keycloakEvents$.subscribe((function (event) {
3135
- switch (event.type) {
3136
- case KeycloakEventType.OnAuthError:
3137
- _this.loginChangeSubject.next(false);
3138
- break;
3139
- case KeycloakEventType.OnAuthLogout:
3140
- _this.loginChangeSubject.next(false);
3141
- storage$1.removeItem(storageKey$1);
3142
- break;
3143
- case KeycloakEventType.OnAuthRefreshError:
3144
- break;
3145
- case KeycloakEventType.OnAuthRefreshSuccess:
3146
- break;
3147
- case KeycloakEventType.OnAuthSuccess:
3148
- break;
3149
- case KeycloakEventType.OnReady:
3150
- _this.loginChangeSubject.next(event.args);
3151
- if (event.args) {
3152
- _this.saveKeycloakConfig();
3153
- }
3154
- break;
3155
- case KeycloakEventType.OnTokenExpired:
3156
- _this.keycloakSvc.updateToken(60);
3157
- break;
3067
+ ExploreDetailResolve.decorators = [
3068
+ { type: Injectable, args: [{
3069
+ providedIn: 'root',
3070
+ },] }
3071
+ ];
3072
+ ExploreDetailResolve.ctorParameters = function () { return [
3073
+ { type: HttpClient },
3074
+ { type: ConfigurationsService },
3075
+ { type: UtilityService }
3076
+ ]; };
3077
+ /** @nocollapse */ ExploreDetailResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function ExploreDetailResolve_Factory() { return new ExploreDetailResolve(ɵɵinject(HttpClient), ɵɵinject(ConfigurationsService), ɵɵinject(UtilityService)); }, token: ExploreDetailResolve, providedIn: "root" });
3078
+ return ExploreDetailResolve;
3079
+ }());
3080
+ if (false) {
3081
+ ExploreDetailResolve.prototype.baseUrl;
3082
+ ExploreDetailResolve.prototype.isIntranetAllowedSettings;
3083
+ ExploreDetailResolve.prototype.http;
3084
+ ExploreDetailResolve.prototype.configSvc;
3085
+ ExploreDetailResolve.prototype.utilitySvc;
3086
+ }
3087
+
3088
+ var MarketingOfferingResolve = (function () {
3089
+ function MarketingOfferingResolve(http) {
3090
+ this.http = http;
3091
+ }
3092
+ MarketingOfferingResolve.prototype.resolve = function (route, _state) {
3093
+ var _this = this;
3094
+ var tag = route.params.tag;
3095
+ return this.http.get(route.data.pageUrl).pipe(map((function (pageData) { return ({ data: _this.transformPageData(pageData, tag), error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
3096
+ };
3097
+ MarketingOfferingResolve.prototype.transformPageData = function (pageData, tag) {
3098
+ pageData.pageLayout.widgetData.widgets = pageData.pageLayout.widgetData.widgets.map((function (widget) {
3099
+ if (widget.widgetSubType === 'contentStripMultiple') {
3100
+ widget.widgetData.strips = widget.widgetData.strips.map((function (strip) {
3101
+ strip.request.search.filters.catalogPaths = [decodeURIComponent(tag)];
3102
+ return strip;
3103
+ }));
3158
3104
  }
3105
+ return widget;
3159
3106
  }));
3107
+ return pageData;
3160
3108
  };
3161
- AuthKeycloakService.prototype.setupGlobalAuthResponder = function () {
3162
- var _this = this;
3163
- fromEvent(window, 'message')
3164
- .pipe(filter((function (event) {
3165
- return Boolean(event) &&
3166
- Boolean(event.data) &&
3167
- event.data.type === 'AUTH_REQUEST' &&
3168
- Boolean(event.source && typeof event.source.postMessage === 'function');
3169
- })))
3170
- .subscribe((function (event) { return __awaiter(_this, void 0, void 0, function () {
3171
- var contentWindow, token, response;
3172
- return __generator(this, function (_a) {
3173
- switch (_a.label) {
3174
- case 0:
3175
- contentWindow = ((event.source));
3176
- return [4, this.keycloakSvc.getToken()];
3177
- case 1:
3178
- token = _a.sent();
3179
- response = {
3180
- app: 'WEB_PORTAL',
3181
- type: 'AUTH_RESPONSE',
3182
- state: 'NONE',
3183
- plugin: 'NONE',
3184
- data: {
3185
- token: token,
3186
- id: event.data && event.data.data && event.data.data.id,
3187
- },
3188
- };
3189
- contentWindow.postMessage(response, '*');
3190
- return [2];
3191
- }
3192
- });
3193
- }); }));
3194
- };
3195
- AuthKeycloakService.prototype.saveKeycloakConfig = function () {
3196
- var kc = this.keycloakSvc.getKeycloakInstance();
3197
- var kcInitOptions = {
3198
- idToken: kc.idToken,
3199
- refreshToken: kc.refreshToken,
3200
- timeSkew: kc.timeSkew,
3201
- token: kc.token,
3109
+ MarketingOfferingResolve.decorators = [
3110
+ { type: Injectable, args: [{
3111
+ providedIn: 'root',
3112
+ },] }
3113
+ ];
3114
+ MarketingOfferingResolve.ctorParameters = function () { return [
3115
+ { type: HttpClient }
3116
+ ]; };
3117
+ /** @nocollapse */ MarketingOfferingResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function MarketingOfferingResolve_Factory() { return new MarketingOfferingResolve(ɵɵinject(HttpClient)); }, token: MarketingOfferingResolve, providedIn: "root" });
3118
+ return MarketingOfferingResolve;
3119
+ }());
3120
+ if (false) {
3121
+ MarketingOfferingResolve.prototype.http;
3122
+ }
3123
+
3124
+ var NsPage;
3125
+ (function (NsPage) {
3126
+ function IPage() { }
3127
+ NsPage.IPage = IPage;
3128
+ if (false) {
3129
+ IPage.prototype.contentType;
3130
+ IPage.prototype.navigationBar;
3131
+ IPage.prototype.pageLayout;
3132
+ IPage.prototype.tourGuide;
3133
+ }
3134
+ function INavBar() { }
3135
+ NsPage.INavBar = INavBar;
3136
+ if (false) {
3137
+ INavBar.prototype.links;
3138
+ INavBar.prototype.xsmallNonMenuLinks;
3139
+ INavBar.prototype.pageBackLink;
3140
+ INavBar.prototype.pageTitle;
3141
+ INavBar.prototype.background;
3142
+ }
3143
+ function INavBackground() { }
3144
+ NsPage.INavBackground = INavBackground;
3145
+ if (false) {
3146
+ INavBackground.prototype.color;
3147
+ INavBackground.prototype.styles;
3148
+ }
3149
+ function INavLink() { }
3150
+ NsPage.INavLink = INavLink;
3151
+ if (false) {
3152
+ INavLink.prototype.config;
3153
+ INavLink.prototype.actionBtnId;
3154
+ INavLink.prototype.actionBtn;
3155
+ INavLink.prototype.actionBtnName;
3156
+ }
3157
+ function INavLinkConfig() { }
3158
+ NsPage.INavLinkConfig = INavLinkConfig;
3159
+ if (false) {
3160
+ INavLinkConfig.prototype.type;
3161
+ INavLinkConfig.prototype.hideIcon;
3162
+ INavLinkConfig.prototype.hideTitle;
3163
+ INavLinkConfig.prototype.hideStatus;
3164
+ INavLinkConfig.prototype.hidePin;
3165
+ INavLinkConfig.prototype.iconColor;
3166
+ INavLinkConfig.prototype.treatAsCard;
3167
+ INavLinkConfig.prototype.useShortName;
3168
+ }
3169
+ })(NsPage || (NsPage = {}));
3170
+
3171
+ var JSON_MAP = {
3172
+ pagename: 'lexid',
3173
+ };
3174
+
3175
+ var PageResolve = (function () {
3176
+ function PageResolve(configSvc, http, locale) {
3177
+ this.configSvc = configSvc;
3178
+ this.http = http;
3179
+ this.locale = locale;
3180
+ this.baseUrl = this.configSvc.sitePath;
3181
+ }
3182
+ PageResolve.prototype.resolve = function (route) {
3183
+ if (route.data.pageUrl) {
3184
+ return this.getData(route.data.pageUrl);
3185
+ }
3186
+ if (route.data.pageType === 'feature' && route.data.pageKey) {
3187
+ return this.getData(this.baseUrl + "/feature/" + route.data.pageKey);
3188
+ }
3189
+ if (route.data.pageType === 'page' &&
3190
+ route.data.pageKey &&
3191
+ route.paramMap.has(route.data.pageKey)) {
3192
+ return this.getData(this.baseUrl + "/page/" + route.paramMap.get(route.data.pageKey));
3193
+ }
3194
+ if (route.data.pageType === 'page' &&
3195
+ route.data.pageKey &&
3196
+ route.data.pageKey === 'toc') {
3197
+ return this.getData(this.baseUrl + "/page/" + route.data.pageKey);
3198
+ }
3199
+ return {
3200
+ data: null,
3201
+ error: 'CONFIGURATION_ERROR_PAGE_URL_NOT_FORMED',
3202
3202
  };
3203
- storage$1.setItem(storageKey$1, JSON.stringify(kcInitOptions));
3204
3203
  };
3205
- AuthKeycloakService.prototype.getSavedKcConfig = function () {
3206
- try {
3207
- var lastSaved = storage$1.getItem(storageKey$1);
3208
- if (lastSaved) {
3209
- var processed = JSON.parse(lastSaved);
3210
- if ('idToken' in processed &&
3211
- 'refreshToken' in processed &&
3212
- 'timeSkew' in processed &&
3213
- 'token' in processed) {
3214
- return processed;
3204
+ PageResolve.prototype.setS3Cookie = function (contentId) {
3205
+ return this.http.post("/apis/protected/v8/content/setCookie", { contentId: contentId }).pipe(catchError((function (_err) { return of(true); })));
3206
+ };
3207
+ PageResolve.prototype.getContent = function (id) {
3208
+ return this.http
3209
+ .post("/apis/protected/v8/content/" + id + "?hierarchyType=minimal", ['status', 'artifactUrl']);
3210
+ };
3211
+ PageResolve.prototype.getData = function (url) {
3212
+ var _this = this;
3213
+ var id = (((url.split('/').pop()))).split('.')[0] || '';
3214
+ var equivalentId = id.startsWith('lex_auth_') ? id : JSON_MAP[id];
3215
+ if (equivalentId) {
3216
+ return forkJoin([this.setS3Cookie(equivalentId), this.getContent(equivalentId)]).pipe(mergeMap((function (_a) {
3217
+ var _b = __read(_a, 2), _ = _b[0], v = _b[1];
3218
+ if (v.status === 'Expired' || v.status === 'Deleted' || !v.artifactUrl) {
3219
+ return of({ data: null, error: 'NoContent' });
3215
3220
  }
3216
- }
3221
+ return _this.http
3222
+ .get(v.artifactUrl + "?ts=" + new Date().getTime())
3223
+ .pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
3224
+ })), catchError((function (err) { return of({ data: null, error: err }); })));
3217
3225
  }
3218
- catch (e) { }
3219
- return {};
3220
- };
3221
- Object.defineProperty(AuthKeycloakService.prototype, "defaultRedirectUrl", {
3222
- get: function () {
3223
- try {
3224
- var baseUrl = document.baseURI;
3225
- return baseUrl || location.origin;
3226
- }
3227
- catch (error) {
3228
- return location.origin;
3226
+ var pageRequest = [
3227
+ (equivalentId ? this.setS3Cookie(equivalentId) : of(true)).pipe(mergeMap((function () {
3228
+ return _this.http.get(url + ".json").pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); })));
3229
+ }))),
3230
+ this.locale === 'en' || this.locale === 'en-US' ?
3231
+ of({ data: ((undefined)), error: null }) :
3232
+ this.http.get(url + "." + this.locale + ".json").pipe(map((function (data) { return ({ data: data, error: null }); })), catchError((function (err) { return of({ data: null, error: err }); }))),
3233
+ ];
3234
+ return forkJoin(pageRequest).pipe(map((function (_a) {
3235
+ var _b = __read(_a, 2), general = _b[0], withLocale = _b[1];
3236
+ if (withLocale.data) {
3237
+ return withLocale;
3229
3238
  }
3230
- },
3231
- enumerable: true,
3232
- configurable: true
3233
- });
3234
- AuthKeycloakService.decorators = [
3239
+ return general;
3240
+ })));
3241
+ };
3242
+ PageResolve.decorators = [
3235
3243
  { type: Injectable, args: [{
3236
3244
  providedIn: 'root',
3237
3245
  },] }
3238
3246
  ];
3239
- AuthKeycloakService.ctorParameters = function () { return [
3240
- { type: HttpClient },
3247
+ PageResolve.ctorParameters = function () { return [
3241
3248
  { type: ConfigurationsService },
3242
- { type: KeycloakService },
3243
- { type: AuthMicrosoftService }
3249
+ { type: HttpClient },
3250
+ { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
3244
3251
  ]; };
3245
- /** @nocollapse */ AuthKeycloakService.ngInjectableDef = ɵɵdefineInjectable({ factory: function AuthKeycloakService_Factory() { return new AuthKeycloakService(ɵɵinject(HttpClient), ɵɵinject(ConfigurationsService), ɵɵinject(KeycloakService), ɵɵinject(AuthMicrosoftService)); }, token: AuthKeycloakService, providedIn: "root" });
3246
- return AuthKeycloakService;
3252
+ /** @nocollapse */ PageResolve.ngInjectableDef = ɵɵdefineInjectable({ factory: function PageResolve_Factory() { return new PageResolve(ɵɵinject(ConfigurationsService), ɵɵinject(HttpClient), ɵɵinject(LOCALE_ID)); }, token: PageResolve, providedIn: "root" });
3253
+ return PageResolve;
3247
3254
  }());
3248
3255
  if (false) {
3249
- AuthKeycloakService.prototype.loginChangeSubject;
3250
- AuthKeycloakService.prototype.http;
3251
- AuthKeycloakService.prototype.configSvc;
3252
- AuthKeycloakService.prototype.keycloakSvc;
3253
- AuthKeycloakService.prototype.msAuthSvc;
3256
+ PageResolve.prototype.baseUrl;
3257
+ PageResolve.prototype.configSvc;
3258
+ PageResolve.prototype.http;
3259
+ PageResolve.prototype.locale;
3260
+ }
3261
+
3262
+ function IResolveResponse() { }
3263
+ if (false) {
3264
+ IResolveResponse.prototype.data;
3265
+ IResolveResponse.prototype.error;
3254
3266
  }
3255
3267
 
3256
3268
  var NsInstanceConfig;
@@ -3296,17 +3308,6 @@ var NsInstanceConfig;
3296
3308
  IConfig.prototype.forgotPasswordConfig;
3297
3309
  IConfig.prototype.hubs;
3298
3310
  IConfig.prototype.courseContentPath;
3299
- IConfig.prototype.portalUrls;
3300
- }
3301
- function IPortalUrls() { }
3302
- NsInstanceConfig.IPortalUrls = IPortalUrls;
3303
- if (false) {
3304
- IPortalUrls.prototype.igot;
3305
- IPortalUrls.prototype.spv;
3306
- IPortalUrls.prototype.mdo;
3307
- IPortalUrls.prototype.cbc;
3308
- IPortalUrls.prototype.cbp;
3309
- IPortalUrls.prototype.frac;
3310
3311
  }
3311
3312
  function IForgotPassword() { }
3312
3313
  NsInstanceConfig.IForgotPassword = IForgotPassword;