wfw-ngx-adal-observable
Version:
Use Azure AD Library - ADAL in Angular 5
37,023 lines • 1.46 MB
JavaScript
"bundle";
System.registerDynamic("ng2-adal/services.js", ["./services/adal.service", "./services/authHttp.service"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
Object.defineProperty(exports, "__esModule", { value: true });
var adal_service_1 = $__require("./services/adal.service");
exports.AdalService = adal_service_1.AdalService;
var authHttp_service_1 = $__require("./services/authHttp.service");
exports.AuthHttp = authHttp_service_1.AuthHttp;
});
System.registerDynamic("ng2-adal/modules/adal.module.js", ["@angular/core", "./../services/adal.service"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
var __decorate = exports && exports.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = $__require("@angular/core");
var adal_service_1 = $__require("./../services/adal.service");
var AdalModule = function () {
function AdalModule() {}
AdalModule = __decorate([core_1.NgModule({
imports: [],
exports: [],
declarations: [],
providers: [adal_service_1.AdalService]
})], AdalModule);
return AdalModule;
}();
exports.AdalModule = AdalModule;
});
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) : 'function' === 'function' && true ? System.registerDynamic('@angular/common/bundles/common.umd.js', ['@angular/core'], false, function ($__require, $__exports, $__module) {
return factory.call($__exports, $__exports, $__require('@angular/core'));
}) : factory((global.ng = global.ng || {}, global.ng.common = {}), global.ng.core);
})(this, function (exports, _angular_core) {
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* This class should not be used directly by an application developer. Instead, use
* {\@link Location}.
*
* `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
* agnostic.
* This means that we can have different implementation of `PlatformLocation` for the different
* platforms that angular supports. For example, `\@angular/platform-browser` provides an
* implementation specific to the browser environment, while `\@angular/platform-webworker` provides
* one suitable for use with web workers.
*
* The `PlatformLocation` class is used directly by all implementations of {\@link LocationStrategy}
* when they need to interact with the DOM apis like pushState, popState, etc...
*
* {\@link LocationStrategy} in turn is used by the {\@link Location} service which is used directly
* by the {\@link Router} in order to navigate between routes. Since all interactions between {\@link
* Router} /
* {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
* class they are all platform independent.
*
* \@stable
* @abstract
*/
var PlatformLocation = /** @class */function () {
function PlatformLocation() {}
return PlatformLocation;
}();
/**
* \@whatItDoes indicates when a location is initialized
* \@experimental
*/
var LOCATION_INITIALIZED = new _angular_core.InjectionToken('Location Initialized');
/**
* A serializable version of the event from onPopState or onHashChange
*
* \@experimental
* @record
*/
/**
* \@experimental
* @record
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* `LocationStrategy` is responsible for representing and reading route state
* from the browser's URL. Angular provides two strategies:
* {\@link HashLocationStrategy} and {\@link PathLocationStrategy}.
*
* This is used under the hood of the {\@link Location} service.
*
* Applications should use the {\@link Router} or {\@link Location} services to
* interact with application route state.
*
* For instance, {\@link HashLocationStrategy} produces URLs like
* `http://example.com#/foo`, and {\@link PathLocationStrategy} produces
* `http://example.com/foo` as an equivalent URL.
*
* See these two classes for more.
*
* \@stable
* @abstract
*/
var LocationStrategy = /** @class */function () {
function LocationStrategy() {}
return LocationStrategy;
}();
/**
* The `APP_BASE_HREF` token represents the base href to be used with the
* {\@link PathLocationStrategy}.
*
* If you're using {\@link PathLocationStrategy}, you must provide a provider to a string
* representing the URL prefix that should be preserved when generating and recognizing
* URLs.
*
* ### Example
*
* ```typescript
* import {Component, NgModule} from '\@angular/core';
* import {APP_BASE_HREF} from '\@angular/common';
*
* \@NgModule({
* providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
* })
* class AppModule {}
* ```
*
* \@stable
*/
var APP_BASE_HREF = new _angular_core.InjectionToken('appBaseHref');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@experimental
* @record
*/
/**
* \@whatItDoes `Location` is a service that applications can use to interact with a browser's URL.
* \@description
* Depending on which {\@link LocationStrategy} is used, `Location` will either persist
* to the URL's path or the URL's hash segment.
*
* Note: it's better to use {\@link Router#navigate} service to trigger route changes. Use
* `Location` only if you need to interact with or create normalized URLs outside of
* routing.
*
* `Location` is responsible for normalizing the URL against the application's base href.
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
* trailing slash:
* - `/my/app/user/123` is normalized
* - `my/app/user/123` **is not** normalized
* - `/my/app/user/123/` **is not** normalized
*
* ### Example
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
* \@stable
*/
var Location = /** @class */function () {
function Location(platformStrategy) {
var _this = this;
/**
* \@internal
*/
this._subject = new _angular_core.EventEmitter();
this._platformStrategy = platformStrategy;
var /** @type {?} */browserBaseHref = this._platformStrategy.getBaseHref();
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
this._platformStrategy.onPopState(function (ev) {
_this._subject.emit({
'url': _this.path(true),
'pop': true,
'type': ev.type
});
});
}
/**
* Returns the normalized URL path.
*/
// TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is
// removed.
/**
* Returns the normalized URL path.
* @param {?=} includeHash
* @return {?}
*/
Location.prototype.path = /**
* Returns the normalized URL path.
* @param {?=} includeHash
* @return {?}
*/
function (includeHash) {
if (includeHash === void 0) {
includeHash = false;
}
return this.normalize(this._platformStrategy.path(includeHash));
};
/**
* Normalizes the given path and compares to the current normalized path.
*/
/**
* Normalizes the given path and compares to the current normalized path.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.isCurrentPathEqualTo = /**
* Normalizes the given path and compares to the current normalized path.
* @param {?} path
* @param {?=} query
* @return {?}
*/
function (path, query) {
if (query === void 0) {
query = '';
}
return this.path() == this.normalize(path + Location.normalizeQueryParams(query));
};
/**
* Given a string representing a URL, returns the normalized URL path without leading or
* trailing slashes.
*/
/**
* Given a string representing a URL, returns the normalized URL path without leading or
* trailing slashes.
* @param {?} url
* @return {?}
*/
Location.prototype.normalize = /**
* Given a string representing a URL, returns the normalized URL path without leading or
* trailing slashes.
* @param {?} url
* @return {?}
*/
function (url) {
return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
};
/**
* Given a string representing a URL, returns the platform-specific external URL path.
* If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
* before normalizing. This method will also add a hash if `HashLocationStrategy` is
* used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
*/
/**
* Given a string representing a URL, returns the platform-specific external URL path.
* If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
* before normalizing. This method will also add a hash if `HashLocationStrategy` is
* used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
* @param {?} url
* @return {?}
*/
Location.prototype.prepareExternalUrl = /**
* Given a string representing a URL, returns the platform-specific external URL path.
* If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
* before normalizing. This method will also add a hash if `HashLocationStrategy` is
* used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
* @param {?} url
* @return {?}
*/
function (url) {
if (url && url[0] !== '/') {
url = '/' + url;
}
return this._platformStrategy.prepareExternalUrl(url);
};
// TODO: rename this method to pushState
/**
* Changes the browsers URL to the normalized version of the given URL, and pushes a
* new item onto the platform's history.
*/
/**
* Changes the browsers URL to the normalized version of the given URL, and pushes a
* new item onto the platform's history.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.go = /**
* Changes the browsers URL to the normalized version of the given URL, and pushes a
* new item onto the platform's history.
* @param {?} path
* @param {?=} query
* @return {?}
*/
function (path, query) {
if (query === void 0) {
query = '';
}
this._platformStrategy.pushState(null, '', path, query);
};
/**
* Changes the browsers URL to the normalized version of the given URL, and replaces
* the top item on the platform's history stack.
*/
/**
* Changes the browsers URL to the normalized version of the given URL, and replaces
* the top item on the platform's history stack.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.replaceState = /**
* Changes the browsers URL to the normalized version of the given URL, and replaces
* the top item on the platform's history stack.
* @param {?} path
* @param {?=} query
* @return {?}
*/
function (path, query) {
if (query === void 0) {
query = '';
}
this._platformStrategy.replaceState(null, '', path, query);
};
/**
* Navigates forward in the platform's history.
*/
/**
* Navigates forward in the platform's history.
* @return {?}
*/
Location.prototype.forward = /**
* Navigates forward in the platform's history.
* @return {?}
*/
function () {
this._platformStrategy.forward();
};
/**
* Navigates back in the platform's history.
*/
/**
* Navigates back in the platform's history.
* @return {?}
*/
Location.prototype.back = /**
* Navigates back in the platform's history.
* @return {?}
*/
function () {
this._platformStrategy.back();
};
/**
* Subscribe to the platform's `popState` events.
*/
/**
* Subscribe to the platform's `popState` events.
* @param {?} onNext
* @param {?=} onThrow
* @param {?=} onReturn
* @return {?}
*/
Location.prototype.subscribe = /**
* Subscribe to the platform's `popState` events.
* @param {?} onNext
* @param {?=} onThrow
* @param {?=} onReturn
* @return {?}
*/
function (onNext, onThrow, onReturn) {
return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
};
/**
* Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as
* is.
* @param {?} params
* @return {?}
*/
Location.normalizeQueryParams = /**
* Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as
* is.
* @param {?} params
* @return {?}
*/
function (params) {
return params && params[0] !== '?' ? '?' + params : params;
};
/**
* Given 2 parts of a url, join them with a slash if needed.
* @param {?} start
* @param {?} end
* @return {?}
*/
Location.joinWithSlash = /**
* Given 2 parts of a url, join them with a slash if needed.
* @param {?} start
* @param {?} end
* @return {?}
*/
function (start, end) {
if (start.length == 0) {
return end;
}
if (end.length == 0) {
return start;
}
var /** @type {?} */slashes = 0;
if (start.endsWith('/')) {
slashes++;
}
if (end.startsWith('/')) {
slashes++;
}
if (slashes == 2) {
return start + end.substring(1);
}
if (slashes == 1) {
return start + end;
}
return start + '/' + end;
};
/**
* If url has a trailing slash, remove it, otherwise return url as is. This
* method looks for the first occurence of either #, ?, or the end of the
* line as `/` characters after any of these should not be replaced.
* @param {?} url
* @return {?}
*/
Location.stripTrailingSlash = /**
* If url has a trailing slash, remove it, otherwise return url as is. This
* method looks for the first occurence of either #, ?, or the end of the
* line as `/` characters after any of these should not be replaced.
* @param {?} url
* @return {?}
*/
function (url) {
var /** @type {?} */match = url.match(/#|\?|$/);
var /** @type {?} */pathEndIdx = match && match.index || url.length;
var /** @type {?} */droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
};
Location.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
Location.ctorParameters = function () {
return [{ type: LocationStrategy }];
};
return Location;
}();
/**
* @param {?} baseHref
* @param {?} url
* @return {?}
*/
function _stripBaseHref(baseHref, url) {
return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
}
/**
* @param {?} url
* @return {?}
*/
function _stripIndexHtml(url) {
return url.replace(/\/index.html$/, '');
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Use URL hash for storing application location data.
* \@description
* `HashLocationStrategy` is a {\@link LocationStrategy} used to configure the
* {\@link Location} service to represent its state in the
* [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
* of the browser's URL.
*
* For instance, if you call `location.go('/foo')`, the browser's URL will become
* `example.com#/foo`.
*
* ### Example
*
* {\@example common/location/ts/hash_location_component.ts region='LocationComponent'}
*
* \@stable
*/
var HashLocationStrategy = /** @class */function (_super) {
__extends(HashLocationStrategy, _super);
function HashLocationStrategy(_platformLocation, _baseHref) {
var _this = _super.call(this) || this;
_this._platformLocation = _platformLocation;
_this._baseHref = '';
if (_baseHref != null) {
_this._baseHref = _baseHref;
}
return _this;
}
/**
* @param {?} fn
* @return {?}
*/
HashLocationStrategy.prototype.onPopState = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
};
/**
* @return {?}
*/
HashLocationStrategy.prototype.getBaseHref = /**
* @return {?}
*/
function () {
return this._baseHref;
};
/**
* @param {?=} includeHash
* @return {?}
*/
HashLocationStrategy.prototype.path = /**
* @param {?=} includeHash
* @return {?}
*/
function (includeHash) {
if (includeHash === void 0) {
includeHash = false;
}
// the hash value is always prefixed with a `#`
// and if it is empty then it will stay empty
var /** @type {?} */path = this._platformLocation.hash;
if (path == null) path = '#';
return path.length > 0 ? path.substring(1) : path;
};
/**
* @param {?} internal
* @return {?}
*/
HashLocationStrategy.prototype.prepareExternalUrl = /**
* @param {?} internal
* @return {?}
*/
function (internal) {
var /** @type {?} */url = Location.joinWithSlash(this._baseHref, internal);
return url.length > 0 ? '#' + url : url;
};
/**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
HashLocationStrategy.prototype.pushState = /**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
function (state, title, path, queryParams) {
var /** @type {?} */url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
if (url.length == 0) {
url = this._platformLocation.pathname;
}
this._platformLocation.pushState(state, title, url);
};
/**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
HashLocationStrategy.prototype.replaceState = /**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
function (state, title, path, queryParams) {
var /** @type {?} */url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
if (url.length == 0) {
url = this._platformLocation.pathname;
}
this._platformLocation.replaceState(state, title, url);
};
/**
* @return {?}
*/
HashLocationStrategy.prototype.forward = /**
* @return {?}
*/
function () {
this._platformLocation.forward();
};
/**
* @return {?}
*/
HashLocationStrategy.prototype.back = /**
* @return {?}
*/
function () {
this._platformLocation.back();
};
HashLocationStrategy.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
HashLocationStrategy.ctorParameters = function () {
return [{ type: PlatformLocation }, { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [APP_BASE_HREF] }] }];
};
return HashLocationStrategy;
}(LocationStrategy);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Use URL for storing application location data.
* \@description
* `PathLocationStrategy` is a {\@link LocationStrategy} used to configure the
* {\@link Location} service to represent its state in the
* [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
* browser's URL.
*
* If you're using `PathLocationStrategy`, you must provide a {\@link APP_BASE_HREF}
* or add a base element to the document. This URL prefix that will be preserved
* when generating and recognizing URLs.
*
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
* `location.go('/foo')`, the browser's URL will become
* `example.com/my/app/foo`.
*
* Similarly, if you add `<base href='/my/app'/>` to the document and call
* `location.go('/foo')`, the browser's URL will become
* `example.com/my/app/foo`.
*
* ### Example
*
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
*
* \@stable
*/
var PathLocationStrategy = /** @class */function (_super) {
__extends(PathLocationStrategy, _super);
function PathLocationStrategy(_platformLocation, href) {
var _this = _super.call(this) || this;
_this._platformLocation = _platformLocation;
if (href == null) {
href = _this._platformLocation.getBaseHrefFromDOM();
}
if (href == null) {
throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
}
_this._baseHref = href;
return _this;
}
/**
* @param {?} fn
* @return {?}
*/
PathLocationStrategy.prototype.onPopState = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
};
/**
* @return {?}
*/
PathLocationStrategy.prototype.getBaseHref = /**
* @return {?}
*/
function () {
return this._baseHref;
};
/**
* @param {?} internal
* @return {?}
*/
PathLocationStrategy.prototype.prepareExternalUrl = /**
* @param {?} internal
* @return {?}
*/
function (internal) {
return Location.joinWithSlash(this._baseHref, internal);
};
/**
* @param {?=} includeHash
* @return {?}
*/
PathLocationStrategy.prototype.path = /**
* @param {?=} includeHash
* @return {?}
*/
function (includeHash) {
if (includeHash === void 0) {
includeHash = false;
}
var /** @type {?} */pathname = this._platformLocation.pathname + Location.normalizeQueryParams(this._platformLocation.search);
var /** @type {?} */hash = this._platformLocation.hash;
return hash && includeHash ? "" + pathname + hash : pathname;
};
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
PathLocationStrategy.prototype.pushState = /**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
function (state, title, url, queryParams) {
var /** @type {?} */externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
this._platformLocation.pushState(state, title, externalUrl);
};
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
PathLocationStrategy.prototype.replaceState = /**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
function (state, title, url, queryParams) {
var /** @type {?} */externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
this._platformLocation.replaceState(state, title, externalUrl);
};
/**
* @return {?}
*/
PathLocationStrategy.prototype.forward = /**
* @return {?}
*/
function () {
this._platformLocation.forward();
};
/**
* @return {?}
*/
PathLocationStrategy.prototype.back = /**
* @return {?}
*/
function () {
this._platformLocation.back();
};
PathLocationStrategy.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
PathLocationStrategy.ctorParameters = function () {
return [{ type: PlatformLocation }, { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [APP_BASE_HREF] }] }];
};
return PathLocationStrategy;
}(LocationStrategy);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// THIS CODE IS GENERATED - DO NOT MODIFY
// See angular/tools/gulp-tasks/cldr/extract.js
/**
* \@experimental
*/
var CURRENCIES = {
'AOA': [, 'Kz'],
'ARS': [, '$'],
'AUD': ['A$', '$'],
'BAM': [, 'KM'],
'BBD': [, '$'],
'BDT': [, '৳'],
'BMD': [, '$'],
'BND': [, '$'],
'BOB': [, 'Bs'],
'BRL': ['R$'],
'BSD': [, '$'],
'BWP': [, 'P'],
'BYN': [, 'р.'],
'BZD': [, '$'],
'CAD': ['CA$', '$'],
'CLP': [, '$'],
'CNY': ['CN¥', '¥'],
'COP': [, '$'],
'CRC': [, '₡'],
'CUC': [, '$'],
'CUP': [, '$'],
'CZK': [, 'Kč'],
'DKK': [, 'kr'],
'DOP': [, '$'],
'EGP': [, 'E£'],
'ESP': [, '₧'],
'EUR': ['€'],
'FJD': [, '$'],
'FKP': [, '£'],
'GBP': ['£'],
'GEL': [, '₾'],
'GIP': [, '£'],
'GNF': [, 'FG'],
'GTQ': [, 'Q'],
'GYD': [, '$'],
'HKD': ['HK$', '$'],
'HNL': [, 'L'],
'HRK': [, 'kn'],
'HUF': [, 'Ft'],
'IDR': [, 'Rp'],
'ILS': ['₪'],
'INR': ['₹'],
'ISK': [, 'kr'],
'JMD': [, '$'],
'JPY': ['¥'],
'KHR': [, '៛'],
'KMF': [, 'CF'],
'KPW': [, '₩'],
'KRW': ['₩'],
'KYD': [, '$'],
'KZT': [, '₸'],
'LAK': [, '₭'],
'LBP': [, 'L£'],
'LKR': [, 'Rs'],
'LRD': [, '$'],
'LTL': [, 'Lt'],
'LVL': [, 'Ls'],
'MGA': [, 'Ar'],
'MMK': [, 'K'],
'MNT': [, '₮'],
'MUR': [, 'Rs'],
'MXN': ['MX$', '$'],
'MYR': [, 'RM'],
'NAD': [, '$'],
'NGN': [, '₦'],
'NIO': [, 'C$'],
'NOK': [, 'kr'],
'NPR': [, 'Rs'],
'NZD': ['NZ$', '$'],
'PHP': [, '₱'],
'PKR': [, 'Rs'],
'PLN': [, 'zł'],
'PYG': [, '₲'],
'RON': [, 'lei'],
'RUB': [, '₽'],
'RUR': [, 'р.'],
'RWF': [, 'RF'],
'SBD': [, '$'],
'SEK': [, 'kr'],
'SGD': [, '$'],
'SHP': [, '£'],
'SRD': [, '$'],
'SSP': [, '£'],
'STD': [, 'Db'],
'SYP': [, '£'],
'THB': [, '฿'],
'TOP': [, 'T$'],
'TRY': [, '₺'],
'TTD': [, '$'],
'TWD': ['NT$', '$'],
'UAH': [, '₴'],
'USD': ['$'],
'UYU': [, '$'],
'VEF': [, 'Bs'],
'VND': ['₫'],
'XAF': ['FCFA'],
'XCD': ['EC$', '$'],
'XOF': ['CFA'],
'XPF': ['CFPF'],
'ZAR': [, 'R'],
'ZMW': [, 'ZK']
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// THIS CODE IS GENERATED - DO NOT MODIFY
// See angular/tools/gulp-tasks/cldr/extract.js
var localeEn = ['en', [['a', 'p'], ['AM', 'PM']], [['AM', 'PM'],,], [['S', 'M', 'T', 'W', 'T', 'F', 'S'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']],, [['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']],, [['B', 'A'], ['BC', 'AD'], ['Before Christ', 'Anno Domini']], 0, [6, 0], ['M/d/yy', 'MMM d, y', 'MMMM d, y', 'EEEE, MMMM d, y'], ['h:mm a', 'h:mm:ss a', 'h:mm:ss a z', 'h:mm:ss a zzzz'], ['{1}, {0}',, '{1} \'at\' {0}'], ['.', ',', ';', '%', '+', '-', 'E', '×', '‰', '∞', 'NaN', ':'], ['#,##0.###', '#,##0%', '¤#,##0.00', '#E0'], '$', 'US Dollar', function (n) {
var /** @type {?} */i = Math.floor(Math.abs(n)),
/** @type {?} */v = n.toString().replace(/^[^.]*\.?/, '').length;
if (i === 1 && v === 0) return 1;
return 5;
}];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@experimental i18n support is experimental.
*/
var LOCALE_DATA = {};
/**
* Register global data to be used internally by Angular. See the
* {\@linkDocs guide/i18n#i18n-pipes "I18n guide"} to know how to import additional locale data.
*
* \@experimental i18n support is experimental.
* @param {?} data
* @param {?=} localeId
* @param {?=} extraData
* @return {?}
*/
function registerLocaleData(data, localeId, extraData) {
if (typeof localeId !== 'string') {
extraData = localeId;
localeId = data[0 /* LocaleId */];
}
localeId = localeId.toLowerCase().replace(/_/g, '-');
LOCALE_DATA[localeId] = data;
if (extraData) {
LOCALE_DATA[localeId][18 /* ExtraData */] = extraData;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/** @enum {number} */
var NumberFormatStyle = {
Decimal: 0,
Percent: 1,
Currency: 2,
Scientific: 3
};
NumberFormatStyle[NumberFormatStyle.Decimal] = "Decimal";
NumberFormatStyle[NumberFormatStyle.Percent] = "Percent";
NumberFormatStyle[NumberFormatStyle.Currency] = "Currency";
NumberFormatStyle[NumberFormatStyle.Scientific] = "Scientific";
/** @enum {number} */
var Plural = {
Zero: 0,
One: 1,
Two: 2,
Few: 3,
Many: 4,
Other: 5
};
Plural[Plural.Zero] = "Zero";
Plural[Plural.One] = "One";
Plural[Plural.Two] = "Two";
Plural[Plural.Few] = "Few";
Plural[Plural.Many] = "Many";
Plural[Plural.Other] = "Other";
/** @enum {number} */
var FormStyle = {
Format: 0,
Standalone: 1
};
FormStyle[FormStyle.Format] = "Format";
FormStyle[FormStyle.Standalone] = "Standalone";
/** @enum {number} */
var TranslationWidth = {
Narrow: 0,
Abbreviated: 1,
Wide: 2,
Short: 3
};
TranslationWidth[TranslationWidth.Narrow] = "Narrow";
TranslationWidth[TranslationWidth.Abbreviated] = "Abbreviated";
TranslationWidth[TranslationWidth.Wide] = "Wide";
TranslationWidth[TranslationWidth.Short] = "Short";
/** @enum {number} */
var FormatWidth = {
Short: 0,
Medium: 1,
Long: 2,
Full: 3
};
FormatWidth[FormatWidth.Short] = "Short";
FormatWidth[FormatWidth.Medium] = "Medium";
FormatWidth[FormatWidth.Long] = "Long";
FormatWidth[FormatWidth.Full] = "Full";
/** @enum {number} */
var NumberSymbol = {
Decimal: 0,
Group: 1,
List: 2,
PercentSign: 3,
PlusSign: 4,
MinusSign: 5,
Exponential: 6,
SuperscriptingExponent: 7,
PerMille: 8,
Infinity: 9,
NaN: 10,
TimeSeparator: 11,
CurrencyDecimal: 12,
CurrencyGroup: 13
};
NumberSymbol[NumberSymbol.Decimal] = "Decimal";
NumberSymbol[NumberSymbol.Group] = "Group";
NumberSymbol[NumberSymbol.List] = "List";
NumberSymbol[NumberSymbol.PercentSign] = "PercentSign";
NumberSymbol[NumberSymbol.PlusSign] = "PlusSign";
NumberSymbol[NumberSymbol.MinusSign] = "MinusSign";
NumberSymbol[NumberSymbol.Exponential] = "Exponential";
NumberSymbol[NumberSymbol.SuperscriptingExponent] = "SuperscriptingExponent";
NumberSymbol[NumberSymbol.PerMille] = "PerMille";
NumberSymbol[NumberSymbol.Infinity] = "Infinity";
NumberSymbol[NumberSymbol.NaN] = "NaN";
NumberSymbol[NumberSymbol.TimeSeparator] = "TimeSeparator";
NumberSymbol[NumberSymbol.CurrencyDecimal] = "CurrencyDecimal";
NumberSymbol[NumberSymbol.CurrencyGroup] = "CurrencyGroup";
/** @enum {number} */
var WeekDay = {
Sunday: 0,
Monday: 1,
Tuesday: 2,
Wednesday: 3,
Thursday: 4,
Friday: 5,
Saturday: 6
};
WeekDay[WeekDay.Sunday] = "Sunday";
WeekDay[WeekDay.Monday] = "Monday";
WeekDay[WeekDay.Tuesday] = "Tuesday";
WeekDay[WeekDay.Wednesday] = "Wednesday";
WeekDay[WeekDay.Thursday] = "Thursday";
WeekDay[WeekDay.Friday] = "Friday";
WeekDay[WeekDay.Saturday] = "Saturday";
/**
* The locale id for the chosen locale (e.g `en-GB`).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleId(locale) {
return findLocaleData(locale)[0 /* LocaleId */];
}
/**
* Periods of the day (e.g. `[AM, PM]` for en-US).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} formStyle
* @param {?} width
* @return {?}
*/
function getLocaleDayPeriods(locale, formStyle, width) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */amPmData = /** @type {?} */[data[1 /* DayPeriodsFormat */], data[2 /* DayPeriodsStandalone */]];
var /** @type {?} */amPm = getLastDefinedValue(amPmData, formStyle);
return getLastDefinedValue(amPm, width);
}
/**
* Days of the week for the Gregorian calendar (e.g. `[Sunday, Monday, ... Saturday]` for en-US).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} formStyle
* @param {?} width
* @return {?}
*/
function getLocaleDayNames(locale, formStyle, width) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */daysData = /** @type {?} */[data[3 /* DaysFormat */], data[4 /* DaysStandalone */]];
var /** @type {?} */days = getLastDefinedValue(daysData, formStyle);
return getLastDefinedValue(days, width);
}
/**
* Months of the year for the Gregorian calendar (e.g. `[January, February, ...]` for en-US).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} formStyle
* @param {?} width
* @return {?}
*/
function getLocaleMonthNames(locale, formStyle, width) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */monthsData = /** @type {?} */[data[5 /* MonthsFormat */], data[6 /* MonthsStandalone */]];
var /** @type {?} */months = getLastDefinedValue(monthsData, formStyle);
return getLastDefinedValue(months, width);
}
/**
* Eras for the Gregorian calendar (e.g. AD/BC).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} width
* @return {?}
*/
function getLocaleEraNames(locale, width) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */erasData = /** @type {?} */data[7 /* Eras */];
return getLastDefinedValue(erasData, width);
}
/**
* First day of the week for this locale, based on english days (Sunday = 0, Monday = 1, ...).
* For example in french the value would be 1 because the first day of the week is Monday.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleFirstDayOfWeek(locale) {
var /** @type {?} */data = findLocaleData(locale);
return data[8 /* FirstDayOfWeek */];
}
/**
* Range of days in the week that represent the week-end for this locale, based on english days
* (Sunday = 0, Monday = 1, ...).
* For example in english the value would be [6,0] for Saturday to Sunday.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleWeekEndRange(locale) {
var /** @type {?} */data = findLocaleData(locale);
return data[9 /* WeekendRange */];
}
/**
* Date format that depends on the locale.
*
* There are four basic date formats:
* - `full` should contain long-weekday (EEEE), year (y), long-month (MMMM), day (d).
*
* For example, English uses `EEEE, MMMM d, y`, corresponding to a date like
* "Tuesday, September 14, 1999".
*
* - `long` should contain year, long-month, day.
*
* For example, `MMMM d, y`, corresponding to a date like "September 14, 1999".
*
* - `medium` should contain year, abbreviated-month (MMM), day.
*
* For example, `MMM d, y`, corresponding to a date like "Sep 14, 1999".
* For languages that do not use abbreviated months, use the numeric month (MM/M). For example,
* `y/MM/dd`, corresponding to a date like "1999/09/14".
*
* - `short` should contain year, numeric-month (MM/M), and day.
*
* For example, `M/d/yy`, corresponding to a date like "9/14/99".
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} width
* @return {?}
*/
function getLocaleDateFormat(locale, width) {
var /** @type {?} */data = findLocaleData(locale);
return data[10 /* DateFormat */][width];
}
/**
* Time format that depends on the locale.
*
* The standard formats include four basic time formats:
* - `full` should contain hour (h/H), minute (mm), second (ss), and zone (zzzz).
* - `long` should contain hour, minute, second, and zone (z)
* - `medium` should contain hour, minute, second.
* - `short` should contain hour, minute.
*
* Note: The patterns depend on whether the main country using your language uses 12-hour time or
* not:
* - For 12-hour time, use a pattern like `hh:mm a` using h to mean a 12-hour clock cycle running
* 1 through 12 (midnight plus 1 minute is 12:01), or using K to mean a 12-hour clock cycle
* running 0 through 11 (midnight plus 1 minute is 0:01).
* - For 24-hour time, use a pattern like `HH:mm` using H to mean a 24-hour clock cycle running 0
* through 23 (midnight plus 1 minute is 0:01), or using k to mean a 24-hour clock cycle running
* 1 through 24 (midnight plus 1 minute is 24:01).
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} width
* @return {?}
*/
function getLocaleTimeFormat(locale, width) {
var /** @type {?} */data = findLocaleData(locale);
return data[11 /* TimeFormat */][width];
}
/**
* Date-time format that depends on the locale.
*
* The date-time pattern shows how to combine separate patterns for date (represented by {1})
* and time (represented by {0}) into a single pattern. It usually doesn't need to be changed.
* What you want to pay attention to are:
* - possibly removing a space for languages that don't use it, such as many East Asian languages
* - possibly adding a comma, other punctuation, or a combining word
*
* For example:
* - English uses `{1} 'at' {0}` or `{1}, {0}` (depending on date style), while Japanese uses
* `{1}{0}`.
* - An English formatted date-time using the combining pattern `{1}, {0}` could be
* `Dec 10, 2010, 3:59:49 PM`. Notice the comma and space between the date portion and the time
* portion.
*
* There are four formats (`full`, `long`, `medium`, `short`); the determination of which to use
* is normally based on the date style. For example, if the date has a full month and weekday
* name, the full combining pattern will be used to combine that with a time. If the date has
* numeric month, the short version of the combining pattern will be used to combine that with a
* time. English uses `{1} 'at' {0}` for full and long styles, and `{1}, {0}` for medium and short
* styles.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} width
* @return {?}
*/
function getLocaleDateTimeFormat(locale, width) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */dateTimeFormatData = /** @type {?} */data[12 /* DateTimeFormat */];
return getLastDefinedValue(dateTimeFormatData, width);
}
/**
* Number symbol that can be used to replace placeholders in number formats.
* See {\@link NumberSymbol} for more information.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} symbol
* @return {?}
*/
function getLocaleNumberSymbol(locale, symbol) {
var /** @type {?} */data = findLocaleData(locale);
var /** @type {?} */res = data[13 /* NumberSymbols */][symbol];
if (typeof res === 'undefined') {
if (symbol === NumberSymbol.CurrencyDecimal) {
return data[13 /* NumberSymbols */][NumberSymbol.Decimal];
} else if (symbol === NumberSymbol.CurrencyGroup) {
return data[13 /* NumberSymbols */][NumberSymbol.Group];
}
}
return res;
}
/**
* Number format that depends on the locale.
*
* Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
* when used to format the number 12345.678 could result in "12'345,67". That would happen if the
* grouping separator for your language is an apostrophe, and the decimal separator is a comma.
*
* <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders;
* they stand for the decimal separator, and so on, and are NOT real characters.
* You must NOT "translate" the placeholders; for example, don't change `.` to `,` even though in
* your language the decimal point is written with a comma. The symbols should be replaced by the
* local equivalents, using the Number Symbols for your language.
*
* Here are the special characters used in number patterns:
*
* | Symbol | Meaning |
* |--------|---------|
* | . | Replaced automatically by the character used for the decimal point. |
* | , | Replaced by the "grouping" (thousands) separator. |
* | 0 | Replaced by a digit (or zero if there aren't enough digits). |
* | # | Replaced by a digit (or nothing if there aren't enough). |
* | ¤ | This will be replaced by a currency symbol, such as $ or USD. |
* | % | This marks a percent format. The % symbol may change position, but must be retained. |
* | E | This marks a scientific format. The E symbol may change position, but must be retained. |
* | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
*
* You can find more information
* [on the CLDR website](http://cldr.unicode.org/translation/number-patterns)
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} type
* @return {?}
*/
function getLocaleNumberFormat(locale, type) {
var /** @type {?} */data = findLocaleData(locale);
return data[14 /* NumberFormats */][type];
}
/**
* The symbol used to represent the currency for the main country using this locale (e.g. $ for
* the locale en-US).
* The symbol will be `null` if the main country cannot be determined.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleCurrencySymbol(locale) {
var /** @type {?} */data = findLocaleData(locale);
return data[15 /* CurrencySymbol */] || null;
}
/**
* The name of the currency for the main country using this locale (e.g. USD for the locale
* en-US).
* The name will be `null` if the main country cannot be determined.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleCurrencyName(locale) {
var /** @type {?} */data = findLocaleData(locale);
return data[16 /* CurrencyName */] || null;
}
/**
* The locale plural function used by ICU expressions to determine the plural case to use.
* See {\@link NgPlural} for more information.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocalePluralCase(locale) {
var /** @type {?} */data = findLocaleData(locale);
return data[17 /* PluralCase */];
}
/**
* @param {?} data
* @return {?}
*/
function checkFullData(data) {
if (!data[18 /* ExtraData */]) {
throw new Error("Missing extra locale data for the locale \"" + data[0 /* LocaleId */] + "\". Use \"registerLocaleData\" to load new data. See the \"I18n guide\" on angular.io to know more.");
}
}
/**
* Rules used to determine which day period to use (See `dayPeriods` below).
* The rules can either be an array or a single value. If it's an array, consider it as "from"
* and "to". If it's a single value then it means that the period is only valid at this exact
* value.
* There is always the same number of rules as the number of day periods, which means that the
* first rule is applied to the first day period and so on.
* You should fallback to AM/PM when there are no rules available.
*
* Note: this is only available if you load the full locale data.
* See the {\@linkDocs guide/i18n#i18n-pipes "I18n guide"} to know how to import additional locale
* data.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function getLocaleExtraDayPeriodRules(locale) {
var /** @type {?} */data = findLocaleData(locale);
checkFullData(data);
var /** @type {?} */rules = data[18 /* ExtraData */][2 /* ExtraDayPeriodsRules */] || [];
return rules.map(function (rule) {
if (typeof rule === 'string') {
return extractTime(rule);
}
return [extractTime(rule[0]), extractTime(rule[1])];
});
}
/**
* Day Periods indicate roughly how the day is broken up in different languages (e.g. morning,
* noon, afternoon, midnight, ...).
* You should use the function {\@link getLocaleExtraDayPeriodRules} to determine which period to
* use.
* You should fallback to AM/PM when there are no day periods available.
*
* Note: this is only available if you load the full locale data.
* See the {\@linkDocs guide/i18n#i18n-pipes "I18n guide"} to know how to import additional locale
* data.
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @param {?} formStyle
* @param {?} width
* @return {?}
*/
function getLocaleExtraDayPeriods(locale, formStyle, width) {
var /** @type {?} */data = findLocaleData(locale);
checkFullData(data);
var /** @type {?} */dayPeriodsData = /** @type {?} */[data[18 /* ExtraData */][0 /* ExtraDayPeriodFormats */], data[18 /* ExtraData */][1 /* ExtraDayPeriodStandalone */]];
var /** @type {?} */dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
return getLastDefinedValue(dayPeriods, width) || [];
}
/**
* Returns the first value that is defined in an array, going backwards.
*
* To avoid repeating the same data (e.g. when "format" and "standalone" are the same) we only
* add the first one to the locale data arrays, the other ones are only defined when different.
* We use this function to retrieve the first defined value.
*
* \@experimental i18n support is experimental.
* @template T
* @param {?} data
* @param {?} index
* @return {?}
*/
function getLastDefinedValue(data, index) {
for (var /** @type {?} */i = index; i > -1; i--) {
if (typeof data[i] !== 'undefined') {
return data[i];
}
}
throw new Error('Locale data API: locale data undefined');
}
/**
* Extract the hours and minutes from a string like "15:45"
* @param {?} time
* @return {?}
*/
function extractTime(time) {
var _a = time.split(':'),
h = _a[0],
m = _a[1];
return { hours: +h, minutes: +m };
}
/**
* Finds the locale data for a locale id
*
* \@experimental i18n support is experimental.
* @param {?} locale
* @return {?}
*/
function findLocaleData(locale) {
var /** @type {?} */normalizedLocale = locale.toLowerCase().replace(/_/g, '-');
var /** @type {?} */match = LOCALE_DATA[normalizedLocale];
if (match) {
return match;
}
// let's try to find a parent locale
var /** @type {?} */parentLocale = normalizedLocale.split('-')[0];
match = LOCALE_DATA[parentLocale];
if (match) {
return match;
}
if (parentLocale === 'en') {
return localeEn;
}
throw new Error("Missing locale data for the locale \"" + locale + "\".");
}
/**
* Return the currency symbol for a given currency code, or the code if no symbol available
* (e.g.: $, US$, or USD)
*
* \@internal
* @param {?} code
* @param {?} format
* @return {?}
*/
function findCurrencySymbol(code, format) {
var /** @type {?} */currency = CURRENCIES[code] || {};
var /** @type {?} */symbol = currency[0] || code;
return format === 'wide' ? symbol : currency[1] || symbol;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @deprecated from v5
*/
var DEPRECATED_PLURAL_FN = new _angular_core.InjectionToken('UseV4Plurals');
/**
* \@experimental
* @abstract
*/
var NgLocalization = /** @class */function () {
function NgLocalization() {}
return NgLocalization;
}();
/**
* Returns the plural category for a given value.
* - "=value" when the case exists,
* - the plural category otherwise
*
* \@internal
* @param {?} value
* @param {?} cases
* @param {?} ngLocalization
* @param {?=} locale
* @return {?}
*/
function getPluralCategory(value, cases, ngLocalization, locale) {
var /** @type {?} */key = "=" + value;
if (cases.indexOf(key) > -1) {
return key;
}
key = ngLocalization.getPluralCategory(value, locale);
if (cases.indexOf(key) > -1) {
return key;
}
if (cases.indexOf('other') > -1) {
return 'other';
}
throw new Error("No plural message found for value \"" + value + "\"");
}
/**
* Returns the plural case based on the locale
*
* \@experimental
*/
var NgLocaleLocalization = /** @class */function (_super) {
__extends(NgLocaleLocalization, _super);
function NgLocaleLocalization(locale, /** @deprecated from v5 */
deprecatedPluralFn) {
var _this = _super.call(this) || this;
_this.locale = locale;
_this.deprecatedPluralFn = deprecatedPluralFn;
return _this;
}
/**
* @param {?} value
* @param {?=} locale
* @return {?}
*/
NgLocaleLocalization.prototype.getPluralCategory = /**
* @param {?} value
* @param {?=} locale
* @return {?}
*/
function (value, locale) {
var /** @type {?} */plural = this.deprecatedPluralFn ? this.deprecatedPluralFn(locale || this.locale, value) : getLocalePluralCase(locale || this.locale)(value);
switch (plural) {
case Plural.Zero:
return 'zero';
case Plural.One:
return 'one';
case Plural.Two:
return 'two';
case Plural.Few:
return 'few';
case Plural.Many:
return 'many';
default:
return 'other';
}
};
NgLocaleLocalization.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
NgLocaleLocalization.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }, { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [DEPRECATED_PLURAL_FN] }] }];
};
return NgLocaleLocalization;
}(NgLocalization);
/**
* Returns the plural case based on the locale
*
* @deprecated from v5 the plural case function is in locale data files common/locales/*.ts
* \@experimental
* @param {?} locale
* @param {?} nLike
* @return {?}
*/
function getPluralCase(locale, nLike) {
// TODO(vicb): lazy compute
if (typeof nLike === 'string') {
nLike = parseInt( /** @type {?} */nLike, 10);
}
var /** @type {?} */n = /** @type {?} */nLike;
var /** @type {?} */nDecimal = n.toString().replace(/^[^.]*\.?/, '');
var /** @type {?} */i = Math.floor(Math.abs(n));
var /** @type {?} */v = nDecimal.length;
var /** @type {?} */f = parseInt(nDecimal, 10);
var /** @type {?} */t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
var /** @type {?} */lang = locale.split('-')[0].toLowerCase();
switch (lang) {
case 'af':
case 'asa':
case 'az':
case 'bem':
case 'bez':
case 'bg':
case 'brx':
case 'ce':
case 'cgg':
case 'chr':
case 'ckb':
case 'ee':
case 'el':
case 'eo':
case 'es':
case 'eu':
case 'fo':
case 'fur':
case 'gsw':
case 'ha':
case 'haw':
case 'hu':
case 'jgo':
case 'jmc':
case 'ka':
case 'kk':
case 'kkj':
case 'kl':
case 'ks':
case 'ksb':
case 'ky':
case 'lb':
case 'lg':
case 'mas':
case 'mgo':
case 'ml':
case 'mn':
case 'nb':
case 'nd':
case 'ne':
case 'nn':
case 'nnh':
case 'nyn':
case 'om':
case 'or':
case 'os':
case 'ps':
case 'rm':
case 'rof':
case 'rwk':
case 'saq':
case 'seh':
case 'sn':
case 'so':
case 'sq':
case 'ta':
case 'te':
case 'teo':
case 'tk':
case 'tr':
case 'ug':
case 'uz':
case 'vo':
case 'vun':
case 'wae':
case 'xog':
if (n === 1) return Plural.One;
return Plural.Other;
case 'ak':
case 'ln':
case 'mg':
case 'pa':
case 'ti':
if (n === Math.floor(n) && n >= 0 && n <= 1) return Plural.One;
return Plural.Other;
case 'am':
case 'as':
case 'bn':
case 'fa':
case 'gu':
case 'hi':
case 'kn':
case 'mr':
case 'zu':
if (i === 0 || n === 1) return Plural.One;
return Plural.Other;
case 'ar':
if (n === 0) return Plural.Zero;
if (n === 1) return Plural.One;
if (n === 2) return Plural.Two;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10) return Plural.Few;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99) return Plural.Many;
return Plural.Other;
case 'ast':
case 'ca':
case 'de':
case 'en':
case 'et':
case 'fi':
case 'fy':
case 'gl':
case 'it':
case 'nl':
case 'sv':
case 'sw':
case 'ur':
case 'yi':
if (i === 1 && v === 0) return Plural.One;
return Plural.Other;
case 'be':
if (n % 10 === 1 && !(n % 100 === 11)) return Plural.One;
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 && !(n % 100 >= 12 && n % 100 <= 14)) return Plural.Few;
if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14) return Plural.Many;
return Plural.Other;
case 'br':
if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91)) return Plural.One;
if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92)) return Plural.Two;
if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) && !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 || n % 100 >= 90 && n % 100 <= 99)) return Plural.Few;
if (!(n === 0) && n % 1e6 === 0) return Plural.Many;
return Plural.Other;
case 'bs':
case 'hr':
case 'sr':
if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11)) return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14) || f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 && !(f % 100 >= 12 && f % 100 <= 14)) return Plural.Few;
return Plural.Other;
case 'cs':
case 'sk':
if (i === 1 && v === 0) return Plural.One;
if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0) return Plural.Few;
if (!(v === 0)) return Plural.Many;
return Plural.Other;
case 'cy':
if (n === 0) return Plural.Zero;
if (n === 1) return Plural.One;
if (n === 2) return Plural.Two;
if (n === 3) return Plural.Few;
if (n === 6) return Plural.Many;
return Plural.Other;
case 'da':
if (n === 1 || !(t === 0) && (i === 0 || i === 1)) return Plural.One;
return Plural.Other;
case 'dsb':
case 'hsb':
if (v === 0 && i % 100 === 1 || f % 100 === 1) return Plural.One;
if (v === 0 && i % 100 === 2 || f % 100 === 2) return Plural.Two;
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4) return Plural.Few;
return Plural.Other;
case 'ff':
case 'fr':
case 'hy':
case 'kab':
if (i === 0 || i === 1) return Plural.One;
return Plural.Other;
case 'fil':
if (v === 0 && (i === 1 || i === 2 || i === 3) || v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) || !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9)) return Plural.One;
return Plural.Other;
case 'ga':
if (n === 1) return Plural.One;
if (n === 2) return Plural.Two;
if (n === Math.floor(n) && n >= 3 && n <= 6) return Plural.Few;
if (n === Math.floor(n) && n >= 7 && n <= 10) return Plural.Many;
return Plural.Other;
case 'gd':
if (n === 1 || n === 11) return Plural.One;
if (n === 2 || n === 12) return Plural.Two;
if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19)) return Plural.Few;
return Plural.Other;
case 'gv':
if (v === 0 && i % 10 === 1) return Plural.One;
if (v === 0 && i % 10 === 2) return Plural.Two;
if (v === 0 && (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80)) return Plural.Few;
if (!(v === 0)) return Plural.Many;
return Plural.Other;
case 'he':
if (i === 1 && v === 0) return Plural.One;
if (i === 2 && v === 0) return Plural.Two;
if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0) return Plural.Many;
return Plural.Other;
case 'is':
if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0)) return Plural.One;
return Plural.Other;
case 'ksh':
if (n === 0) return Plural.Zero;
if (n === 1) return Plural.One;
return Plural.Other;
case 'kw':
case 'naq':
case 'se':
case 'smn':
if (n === 1) return Plural.One;
if (n === 2) return Plural.Two;
return Plural.Other;
case 'lag':
if (n === 0) return Plural.Zero;
if ((i === 0 || i === 1) && !(n === 0)) return Plural.One;
return Plural.Other;
case 'lt':
if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19)) return Plural.One;
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 && !(n % 100 >= 11 && n % 100 <= 19)) return Plural.Few;
if (!(f === 0)) return Plural.Many;
return Plural.Other;
case 'lv':
case 'prg':
if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 || v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19) return Plural.Zero;
if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) || !(v === 2) && f % 10 === 1) return Plural.One;
return Plural.Other;
case 'mk':
if (v === 0 && i % 10 === 1 || f % 10 === 1) return Plural.One;
return Plural.Other;
case 'mt':
if (n === 1) return Plural.One;
if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10) return Plural.Few;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19) return Plural.Many;
return Plural.Other;
case 'pl':
if (i === 1 && v === 0) return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14)) return Plural.Few;
if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 || v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 || v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14) return Plural.Many;
return Plural.Other;
case 'pt':
if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2)) return Plural.One;
return Plural.Other;
case 'ro':
if (i === 1 && v === 0) return Plural.One;
if (!(v === 0) || n === 0 || !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19) return Plural.Few;
return Plural.Other;
case 'ru':
case 'uk':
if (v === 0 && i % 10 === 1 && !(i % 100 === 11)) return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14)) return Plural.Few;
if (v === 0 && i % 10 === 0 || v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 || v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14) return Plural.Many;
return Plural.Other;
case 'shi':
if (i === 0 || n === 1) return Plural.One;
if (n === Math.floor(n) && n >= 2 && n <= 10) return Plural.Few;
return Plural.Other;
case 'si':
if (n === 0 || n === 1 || i === 0 && f === 1) return Plural.One;
return Plural.Other;
case 'sl':
if (v === 0 && i % 100 === 1) return Plural.One;
if (v === 0 && i % 100 === 2) return Plural.Two;
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0)) return Plural.Few;
return Plural.Other;
case 'tzm':
if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99) return Plural.One;
return Plural.Other;
// When there is no specification, the default is always "other"
// Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
// > other (required—general plural form — also used if the language only has a single form)
default:
return Plural.Other;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} cookieStr
* @param {?} name
* @return {?}
*/
function parseCookieValue(cookieStr, name) {
name = encodeURIComponent(name);
for (var _i = 0, _a = cookieStr.split(';'); _i < _a.length; _i++) {
var cookie = _a[_i];
var /** @type {?} */eqIndex = cookie.indexOf('=');
var _b = eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)],
cookieName = _b[0],
cookieValue = _b[1];
if (cookieName.trim() === name) {
return decodeURIComponent(cookieValue);
}
}
return null;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds and removes CSS classes on an HTML element.
*
* \@howToUse
* ```
* <some-element [ngClass]="'first second'">...</some-element>
*
* <some-element [ngClass]="['first', 'second']">...</some-element>
*
* <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
*
* <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
*
* <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
* ```
*
* \@description
*
* The CSS classes are updated as follows, depending on the type of the expression evaluation:
* - `string` - the CSS classes listed in the string (space delimited) are added,
* - `Array` - the CSS classes declared as Array elements are added,
* - `Object` - keys are CSS classes that get added when the expression given in the value
* evaluates to a truthy value, otherwise they are removed.
*
* \@stable
*/
var NgClass = /** @class */function () {
function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
this._iterableDiffers = _iterableDiffers;
this._keyValueDiffers = _keyValueDiffers;
this._ngEl = _ngEl;
this._renderer = _renderer;
this._initialClasses = [];
}
Object.defineProperty(NgClass.prototype, "klass", {
set: /**
* @param {?} v
* @return {?}
*/
function (v) {
this._applyInitialClasses(true);
this._initialClasses = typeof v === 'string' ? v.split(/\s+/) : [];
this._applyInitialClasses(false);
this._applyClasses(this._rawClass, false);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgClass.prototype, "ngClass", {
set: /**
* @param {?} v
* @return {?}
*/
function (v) {
this._cleanupClasses(this._rawClass);
this._iterableDiffer = null;
this._keyValueDiffer = null;
this._rawClass = typeof v === 'string' ? v.split(/\s+/) : v;
if (this._rawClass) {
if (_angular_core.ɵisListLikeIterable(this._rawClass)) {
this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
} else {
this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
}
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgClass.prototype.ngDoCheck = /**
* @return {?}
*/
function () {
if (this._iterableDiffer) {
var /** @type {?} */iterableChanges = this._iterableDiffer.diff( /** @type {?} */this._rawClass);
if (iterableChanges) {
this._applyIterableChanges(iterableChanges);
}
} else if (this._keyValueDiffer) {
var /** @type {?} */keyValueChanges = this._keyValueDiffer.diff( /** @type {?} */this._rawClass);
if (keyValueChanges) {
this._applyKeyValueChanges(keyValueChanges);
}
}
};
/**
* @param {?} rawClassVal
* @return {?}
*/
NgClass.prototype._cleanupClasses = /**
* @param {?} rawClassVal
* @return {?}
*/
function (rawClassVal) {
this._applyClasses(rawClassVal, true);
this._applyInitialClasses(false);
};
/**
* @param {?} changes
* @return {?}
*/
NgClass.prototype._applyKeyValueChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
changes.forEachAddedItem(function (record) {
return _this._toggleClass(record.key, record.currentValue);
});
changes.forEachChangedItem(function (record) {
return _this._toggleClass(record.key, record.currentValue);
});
changes.forEachRemovedItem(function (record) {
if (record.previousValue) {
_this._toggleClass(record.key, false);
}
});
};
/**
* @param {?} changes
* @return {?}
*/
NgClass.prototype._applyIterableChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
changes.forEachAddedItem(function (record) {
if (typeof record.item === 'string') {
_this._toggleClass(record.item, true);
} else {
throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + _angular_core.ɵstringify(record.item));
}
});
changes.forEachRemovedItem(function (record) {
return _this._toggleClass(record.item, false);
});
};
/**
* @param {?} isCleanup
* @return {?}
*/
NgClass.prototype._applyInitialClasses = /**
* @param {?} isCleanup
* @return {?}
*/
function (isCleanup) {
var _this = this;
this._initialClasses.forEach(function (klass) {
return _this._toggleClass(klass, !isCleanup);
});
};
/**
* @param {?} rawClassVal
* @param {?} isCleanup
* @return {?}
*/
NgClass.prototype._applyClasses = /**
* @param {?} rawClassVal
* @param {?} isCleanup
* @return {?}
*/
function (rawClassVal, isCleanup) {
var _this = this;
if (rawClassVal) {
if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
/** @type {?} */rawClassVal.forEach(function (klass) {
return _this._toggleClass(klass, !isCleanup);
});
} else {
Object.keys(rawClassVal).forEach(function (klass) {
if (rawClassVal[klass] != null) _this._toggleClass(klass, !isCleanup);
});
}
}
};
/**
* @param {?} klass
* @param {?} enabled
* @return {?}
*/
NgClass.prototype._toggleClass = /**
* @param {?} klass
* @param {?} enabled
* @return {?}
*/
function (klass, enabled) {
var _this = this;
klass = klass.trim();
if (klass) {
klass.split(/\s+/g).forEach(function (klass) {
if (enabled) {
_this._renderer.addClass(_this._ngEl.nativeElement, klass);
} else {
_this._renderer.removeClass(_this._ngEl.nativeElement, klass);
}
});
}
};
NgClass.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngClass]' }] }];
/** @nocollapse */
NgClass.ctorParameters = function () {
return [{ type: _angular_core.IterableDiffers }, { type: _angular_core.KeyValueDiffers }, { type: _angular_core.ElementRef }, { type: _angular_core.Renderer2 }];
};
NgClass.propDecorators = {
"klass": [{ type: _angular_core.Input, args: ['class'] }],
"ngClass": [{ type: _angular_core.Input }]
};
return NgClass;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Instantiates a single {\@link Component} type and inserts its Host View into current View.
* `NgComponentOutlet` provides a declarative approach for dynamic component creation.
*
* `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
* any existing component will get destroyed.
*
* ### Fine tune control
*
* You can control the component creation process by using the following optional attributes:
*
* * `ngComponentOutletInjector`: Optional custom {\@link Injector} that will be used as parent for
* the Component. Defaults to the injector of the current view container.
*
* * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
* section of the component, if exists.
*
* * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
* module, then load a component from that module.
*
* ### Syntax
*
* Simple
* ```
* <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
* ```
*
* Customized injector/content
* ```
* <ng-container *ngComponentOutlet="componentTypeExpression;
* injector: injectorExpression;
* content: contentNodesExpression;">
* </ng-container>
* ```
*
* Customized ngModuleFactory
* ```
* <ng-container *ngComponentOutlet="componentTypeExpression;
* ngModuleFactory: moduleFactory;">
* </ng-container>
* ```
* ## Example
*
* {\@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
*
* A more complete example with additional options:
*
* {\@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
* A more complete example with ngModuleFactory:
*
* {\@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'}
*
* \@experimental
*/
var NgComponentOutlet = /** @class */function () {
function NgComponentOutlet(_viewContainerRef) {
this._viewContainerRef = _viewContainerRef;
this._componentRef = null;
this._moduleRef = null;
}
/**
* @param {?} changes
* @return {?}
*/
NgComponentOutlet.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
this._viewContainerRef.clear();
this._componentRef = null;
if (this.ngComponentOutlet) {
var /** @type {?} */elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
if (changes['ngComponentOutletNgModuleFactory']) {
if (this._moduleRef) this._moduleRef.destroy();
if (this.ngComponentOutletNgModuleFactory) {
var /** @type {?} */parentModule = elInjector.get(_angular_core.NgModuleRef);
this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
} else {
this._moduleRef = null;
}
}
var /** @type {?} */componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver : elInjector.get(_angular_core.ComponentFactoryResolver);
var /** @type {?} */componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
}
};
/**
* @return {?}
*/
NgComponentOutlet.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this._moduleRef) this._moduleRef.destroy();
};
NgComponentOutlet.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngComponentOutlet]' }] }];
/** @nocollapse */
NgComponentOutlet.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }];
};
NgComponentOutlet.propDecorators = {
"ngComponentOutlet": [{ type: _angular_core.Input }],
"ngComponentOutletInjector": [{ type: _angular_core.Input }],
"ngComponentOutletContent": [{ type: _angular_core.Input }],
"ngComponentOutletNgModuleFactory": [{ type: _angular_core.Input }]
};
return NgComponentOutlet;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@stable
*/
var NgForOfContext = /** @class */function () {
function NgForOfContext($implicit, ngForOf, index, count) {
this.$implicit = $implicit;
this.ngForOf = ngForOf;
this.index = index;
this.count = count;
}
Object.defineProperty(NgForOfContext.prototype, "first", {
get: /**
* @return {?}
*/
function () {
return this.index === 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "last", {
get: /**
* @return {?}
*/
function () {
return this.index === this.count - 1;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "even", {
get: /**
* @return {?}
*/
function () {
return this.index % 2 === 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "odd", {
get: /**
* @return {?}
*/
function () {
return !this.even;
},
enumerable: true,
configurable: true
});
return NgForOfContext;
}();
/**
* The `NgForOf` directive instantiates a template once per item from an iterable. The context
* for each instantiated template inherits from the outer context with the given loop variable
* set to the current item from the iterable.
*
* ### Local Variables
*
* `NgForOf` provides several exported values that can be aliased to local variables:
*
* - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
* - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
* more complex then a property access, for example when using the async pipe (`userStreams |
* async`).
* - `index: number`: The index of the current item in the iterable.
* - `first: boolean`: True when the item is the first item in the iterable.
* - `last: boolean`: True when the item is the last item in the iterable.
* - `even: boolean`: True when the item has an even index in the iterable.
* - `odd: boolean`: True when the item has an odd index in the iterable.
*
* ```
* <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
* {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
* </li>
* ```
*
* ### Change Propagation
*
* When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
*
* * When an item is added, a new instance of the template is added to the DOM.
* * When an item is removed, its template instance is removed from the DOM.
* * When items are reordered, their respective templates are reordered in the DOM.
* * Otherwise, the DOM element for that item will remain the same.
*
* Angular uses object identity to track insertions and deletions within the iterator and reproduce
* those changes in the DOM. This has important implications for animations and any stateful
* controls (such as `<input>` elements which accept user input) that are present. Inserted rows can
* be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
* such as user input.
*
* It is possible for the identities of elements in the iterator to change while the data does not.
* This can happen, for example, if the iterator produced from an RPC to the server, and that
* RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
* different identities, and Angular will tear down the entire DOM and rebuild it (as if all old
* elements were deleted and all new elements inserted). This is an expensive operation and should
* be avoided if possible.
*
* To customize the default tracking algorithm, `NgForOf` supports `trackBy` option.
* `trackBy` takes a function which has two arguments: `index` and `item`.
* If `trackBy` is given, Angular tracks changes by the return value of the function.
*
* ### Syntax
*
* - `<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>`
*
* With `<ng-template>` element:
*
* ```
* <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
* <li>...</li>
* </ng-template>
* ```
*
* ### Example
*
* See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
* example.
*
* \@stable
*/
var NgForOf = /** @class */function () {
function NgForOf(_viewContainer, _template, _differs) {
this._viewContainer = _viewContainer;
this._template = _template;
this._differs = _differs;
this._differ = null;
}
Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
get: /**
* @return {?}
*/
function () {
return this._trackByFn;
},
set: /**
* @param {?} fn
* @return {?}
*/
function (fn) {
if (_angular_core.isDevMode() && fn != null && typeof fn !== 'function') {
// TODO(vicb): use a log service once there is a public one available
if ( /** @type {?} */console && /** @type {?} */console.warn) {
console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " + "See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
}
}
this._trackByFn = fn;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
// TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
// The current type is too restrictive; a template that just uses index, for example,
// should be acceptable.
if (value) {
this._template = value;
}
},
enumerable: true,
configurable: true
});
/**
* @param {?} changes
* @return {?}
*/
NgForOf.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if ('ngForOf' in changes) {
// React on ngForOf changes only once all inputs have been initialized
var /** @type {?} */value = changes['ngForOf'].currentValue;
if (!this._differ && value) {
try {
this._differ = this._differs.find(value).create(this.ngForTrackBy);
} catch ( /** @type {?} */e) {
throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeNameForDebugging(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
}
}
}
};
/**
* @return {?}
*/
NgForOf.prototype.ngDoCheck = /**
* @return {?}
*/
function () {
if (this._differ) {
var /** @type {?} */changes = this._differ.diff(this.ngForOf);
if (changes) this._applyChanges(changes);
}
};
/**
* @param {?} changes
* @return {?}
*/
NgForOf.prototype._applyChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
var /** @type {?} */insertTuples = [];
changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
if (item.previousIndex == null) {
var /** @type {?} */view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext( /** @type {?} */null, _this.ngForOf, -1, -1), currentIndex);
var /** @type {?} */tuple = new RecordViewTuple(item, view);
insertTuples.push(tuple);
} else if (currentIndex == null) {
_this._viewContainer.remove(adjustedPreviousIndex);
} else {
var /** @type {?} */view = /** @type {?} */_this._viewContainer.get(adjustedPreviousIndex);
_this._viewContainer.move(view, currentIndex);
var /** @type {?} */tuple = new RecordViewTuple(item, /** @type {?} */view);
insertTuples.push(tuple);
}
});
for (var /** @type {?} */i = 0; i < insertTuples.length; i++) {
this._perViewChange(insertTuples[i].view, insertTuples[i].record);
}
for (var /** @type {?} */i = 0, /** @type {?} */ilen = this._viewContainer.length; i < ilen; i++) {
var /** @type {?} */viewRef = /** @type {?} */this._viewContainer.get(i);
viewRef.context.index = i;
viewRef.context.count = ilen;
}
changes.forEachIdentityChange(function (record) {
var /** @type {?} */viewRef = /** @type {?} */_this._viewContainer.get(record.currentIndex);
viewRef.context.$implicit = record.item;
});
};
/**
* @param {?} view
* @param {?} record
* @return {?}
*/
NgForOf.prototype._perViewChange = /**
* @param {?} view
* @param {?} record
* @return {?}
*/
function (view, record) {
view.context.$implicit = record.item;
};
NgForOf.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngFor][ngForOf]' }] }];
/** @nocollapse */
NgForOf.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }, { type: _angular_core.TemplateRef }, { type: _angular_core.IterableDiffers }];
};
NgForOf.propDecorators = {
"ngForOf": [{ type: _angular_core.Input }],
"ngForTrackBy": [{ type: _angular_core.Input }],
"ngForTemplate": [{ type: _angular_core.Input }]
};
return NgForOf;
}();
var RecordViewTuple = /** @class */function () {
function RecordViewTuple(record, view) {
this.record = record;
this.view = view;
}
return RecordViewTuple;
}();
/**
* @param {?} type
* @return {?}
*/
function getTypeNameForDebugging(type) {
return type['name'] || typeof type;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Conditionally includes a template based on the value of an `expression`.
*
* `ngIf` evaluates the `expression` and then renders the `then` or `else` template in its place
* when expression is truthy or falsy respectively. Typically the:
* - `then` template is the inline template of `ngIf` unless bound to a different value.
* - `else` template is blank unless it is bound.
*
* ## Most common usage
*
* The most common usage of the `ngIf` directive is to conditionally show the inline template as
* seen in this example:
* {\@example common/ngIf/ts/module.ts region='NgIfSimple'}
*
* ## Showing an alternative template using `else`
*
* If it is necessary to display a template when the `expression` is falsy use the `else` template
* binding as shown. Note that the `else` binding points to a `<ng-template>` labeled `#elseBlock`.
* The template can be defined anywhere in the component view but is typically placed right after
* `ngIf` for readability.
*
* {\@example common/ngIf/ts/module.ts region='NgIfElse'}
*
* ## Using non-inlined `then` template
*
* Usually the `then` template is the inlined template of the `ngIf`, but it can be changed using
* a binding (just like `else`). Because `then` and `else` are bindings, the template references can
* change at runtime as shown in this example.
*
* {\@example common/ngIf/ts/module.ts region='NgIfThenElse'}
*
* ## Storing conditional result in a variable
*
* A common pattern is that we need to show a set of properties from the same object. If the
* object is undefined, then we have to use the safe-traversal-operator `?.` to guard against
* dereferencing a `null` value. This is especially the case when waiting on async data such as
* when using the `async` pipe as shown in following example:
*
* ```
* Hello {{ (userStream|async)?.last }}, {{ (userStream|async)?.first }}!
* ```
*
* There are several inefficiencies in the above example:
* - We create multiple subscriptions on `userStream`. One for each `async` pipe, or two in the
* example above.
* - We cannot display an alternative screen while waiting for the data to arrive asynchronously.
* - We have to use the safe-traversal-operator `?.` to access properties, which is cumbersome.
* - We have to place the `async` pipe in parenthesis.
*
* A better way to do this is to use `ngIf` and store the result of the condition in a local
* variable as shown in the the example below:
*
* {\@example common/ngIf/ts/module.ts region='NgIfAs'}
*
* Notice that:
* - We use only one `async` pipe and hence only one subscription gets created.
* - `ngIf` stores the result of the `userStream|async` in the local variable `user`.
* - The local `user` can then be bound repeatedly in a more efficient way.
* - No need to use the safe-traversal-operator `?.` to access properties as `ngIf` will only
* display the data if `userStream` returns a value.
* - We can display an alternative template while waiting for the data.
*
* ### Syntax
*
* Simple form:
* - `<div *ngIf="condition">...</div>`
* - `<ng-template [ngIf]="condition"><div>...</div></ng-template>`
*
* Form with an else block:
* ```
* <div *ngIf="condition; else elseBlock">...</div>
* <ng-template #elseBlock>...</ng-template>
* ```
*
* Form with a `then` and `else` block:
* ```
* <div *ngIf="condition; then thenBlock else elseBlock"></div>
* <ng-template #thenBlock>...</ng-template>
* <ng-template #elseBlock>...</ng-template>
* ```
*
* Form with storing the value locally:
* ```
* <div *ngIf="condition as value; else elseBlock">{{value}}</div>
* <ng-template #elseBlock>...</ng-template>
* ```
*
* \@stable
*/
var NgIf = /** @class */function () {
function NgIf(_viewContainer, templateRef) {
this._viewContainer = _viewContainer;
this._context = new NgIfContext();
this._thenTemplateRef = null;
this._elseTemplateRef = null;
this._thenViewRef = null;
this._elseViewRef = null;
this._thenTemplateRef = templateRef;
}
Object.defineProperty(NgIf.prototype, "ngIf", {
set: /**
* @param {?} condition
* @return {?}
*/
function (condition) {
this._context.$implicit = this._context.ngIf = condition;
this._updateView();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgIf.prototype, "ngIfThen", {
set: /**
* @param {?} templateRef
* @return {?}
*/
function (templateRef) {
this._thenTemplateRef = templateRef;
this._thenViewRef = null; // clear previous view if any.
this._updateView();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgIf.prototype, "ngIfElse", {
set: /**
* @param {?} templateRef
* @return {?}
*/
function (templateRef) {
this._elseTemplateRef = templateRef;
this._elseViewRef = null; // clear previous view if any.
this._updateView();
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgIf.prototype._updateView = /**
* @return {?}
*/
function () {
if (this._context.$implicit) {
if (!this._thenViewRef) {
this._viewContainer.clear();
this._elseViewRef = null;
if (this._thenTemplateRef) {
this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
}
}
} else {
if (!this._elseViewRef) {
this._viewContainer.clear();
this._thenViewRef = null;
if (this._elseTemplateRef) {
this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
}
}
}
};
NgIf.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngIf]' }] }];
/** @nocollapse */
NgIf.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }, { type: _angular_core.TemplateRef }];
};
NgIf.propDecorators = {
"ngIf": [{ type: _angular_core.Input }],
"ngIfThen": [{ type: _angular_core.Input }],
"ngIfElse": [{ type: _angular_core.Input }]
};
return NgIf;
}();
/**
* \@stable
*/
var NgIfContext = /** @class */function () {
function NgIfContext() {
this.$implicit = null;
this.ngIf = null;
}
return NgIfContext;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var SwitchView = /** @class */function () {
function SwitchView(_viewContainerRef, _templateRef) {
this._viewContainerRef = _viewContainerRef;
this._templateRef = _templateRef;
this._created = false;
}
/**
* @return {?}
*/
SwitchView.prototype.create = /**
* @return {?}
*/
function () {
this._created = true;
this._viewContainerRef.createEmbeddedView(this._templateRef);
};
/**
* @return {?}
*/
SwitchView.prototype.destroy = /**
* @return {?}
*/
function () {
this._created = false;
this._viewContainerRef.clear();
};
/**
* @param {?} created
* @return {?}
*/
SwitchView.prototype.enforceState = /**
* @param {?} created
* @return {?}
*/
function (created) {
if (created && !this._created) {
this.create();
} else if (!created && this._created) {
this.destroy();
}
};
return SwitchView;
}();
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds / removes DOM sub-trees when the nest match expressions matches the switch
* expression.
*
* \@howToUse
* ```
* <container-element [ngSwitch]="switch_expression">
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
* <some-element *ngSwitchCase="match_expression_2">...</some-element>
* <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
* <ng-container *ngSwitchCase="match_expression_3">
* <!-- use a ng-container to group multiple root nodes -->
* <inner-element></inner-element>
* <inner-other-element></inner-other-element>
* </ng-container>
* <some-element *ngSwitchDefault>...</some-element>
* </container-element>
* ```
* \@description
*
* `NgSwitch` stamps out nested views when their match expression value matches the value of the
* switch expression.
*
* In other words:
* - you define a container element (where you place the directive with a switch expression on the
* `[ngSwitch]="..."` attribute)
* - you define inner views inside the `NgSwitch` and place a `*ngSwitchCase` attribute on the view
* root elements.
*
* Elements within `NgSwitch` but outside of a `NgSwitchCase` or `NgSwitchDefault` directives will
* be preserved at the location.
*
* The `ngSwitchCase` directive informs the parent `NgSwitch` of which view to display when the
* expression is evaluated.
* When no matching expression is found on a `ngSwitchCase` view, the `ngSwitchDefault` view is
* stamped out.
*
* \@stable
*/
var NgSwitch = /** @class */function () {
function NgSwitch() {
this._defaultUsed = false;
this._caseCount = 0;
this._lastCaseCheckIndex = 0;
this._lastCasesMatched = false;
}
Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
set: /**
* @param {?} newValue
* @return {?}
*/
function (newValue) {
this._ngSwitch = newValue;
if (this._caseCount === 0) {
this._updateDefaultCases(true);
}
},
enumerable: true,
configurable: true
});
/** @internal */
/**
* \@internal
* @return {?}
*/
NgSwitch.prototype._addCase = /**
* \@internal
* @return {?}
*/
function () {
return this._caseCount++;
};
/** @internal */
/**
* \@internal
* @param {?} view
* @return {?}
*/
NgSwitch.prototype._addDefault = /**
* \@internal
* @param {?} view
* @return {?}
*/
function (view) {
if (!this._defaultViews) {
this._defaultViews = [];
}
this._defaultViews.push(view);
};
/** @internal */
/**
* \@internal
* @param {?} value
* @return {?}
*/
NgSwitch.prototype._matchCase = /**
* \@internal
* @param {?} value
* @return {?}
*/
function (value) {
var /** @type {?} */matched = value == this._ngSwitch;
this._lastCasesMatched = this._lastCasesMatched || matched;
this._lastCaseCheckIndex++;
if (this._lastCaseCheckIndex === this._caseCount) {
this._updateDefaultCases(!this._lastCasesMatched);
this._lastCaseCheckIndex = 0;
this._lastCasesMatched = false;
}
return matched;
};
/**
* @param {?} useDefault
* @return {?}
*/
NgSwitch.prototype._updateDefaultCases = /**
* @param {?} useDefault
* @return {?}
*/
function (useDefault) {
if (this._defaultViews && useDefault !== this._defaultUsed) {
this._defaultUsed = useDefault;
for (var /** @type {?} */i = 0; i < this._defaultViews.length; i++) {
var /** @type {?} */defaultView = this._defaultViews[i];
defaultView.enforceState(useDefault);
}
}
};
NgSwitch.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngSwitch]' }] }];
/** @nocollapse */
NgSwitch.ctorParameters = function () {
return [];
};
NgSwitch.propDecorators = {
"ngSwitch": [{ type: _angular_core.Input }]
};
return NgSwitch;
}();
/**
* \@ngModule CommonModule
*
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgSwitch} when the
* given expression evaluate to respectively the same/different value as the switch
* expression.
*
* \@howToUse
* ```
* <container-element [ngSwitch]="switch_expression">
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
* </container-element>
* ```
* \@description
*
* Insert the sub-tree when the expression evaluates to the same value as the enclosing switch
* expression.
*
* If multiple match expressions match the switch expression value, all of them are displayed.
*
* See {\@link NgSwitch} for more details and example.
*
* \@stable
*/
var NgSwitchCase = /** @class */function () {
function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
this.ngSwitch = ngSwitch;
ngSwitch._addCase();
this._view = new SwitchView(viewContainer, templateRef);
}
/**
* @return {?}
*/
NgSwitchCase.prototype.ngDoCheck = /**
* @return {?}
*/
function () {
this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase));
};
NgSwitchCase.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngSwitchCase]' }] }];
/** @nocollapse */
NgSwitchCase.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }, { type: _angular_core.TemplateRef }, { type: NgSwitch, decorators: [{ type: _angular_core.Host }] }];
};
NgSwitchCase.propDecorators = {
"ngSwitchCase": [{ type: _angular_core.Input }]
};
return NgSwitchCase;
}();
/**
* \@ngModule CommonModule
* \@whatItDoes Creates a view that is added to the parent {\@link NgSwitch} when no case expressions
* match the
* switch expression.
*
* \@howToUse
* ```
* <container-element [ngSwitch]="switch_expression">
* <some-element *ngSwitchCase="match_expression_1">...</some-element>
* <some-other-element *ngSwitchDefault>...</some-other-element>
* </container-element>
* ```
*
* \@description
*
* Insert the sub-tree when no case expressions evaluate to the same value as the enclosing switch
* expression.
*
* See {\@link NgSwitch} for more details and example.
*
* \@stable
*/
var NgSwitchDefault = /** @class */function () {
function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
}
NgSwitchDefault.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngSwitchDefault]' }] }];
/** @nocollapse */
NgSwitchDefault.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }, { type: _angular_core.TemplateRef }, { type: NgSwitch, decorators: [{ type: _angular_core.Host }] }];
};
return NgSwitchDefault;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
*
* \@howToUse
* ```
* <some-element [ngPlural]="value">
* <ng-template ngPluralCase="=0">there is nothing</ng-template>
* <ng-template ngPluralCase="=1">there is one</ng-template>
* <ng-template ngPluralCase="few">there are a few</ng-template>
* </some-element>
* ```
*
* \@description
*
* Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
* that match the switch expression's pluralization category.
*
* To use this directive you must provide a container element that sets the `[ngPlural]` attribute
* to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
* expression:
* - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
* matches the switch expression exactly,
* - otherwise, the view will be treated as a "category match", and will only display if exact
* value matches aren't found and the value maps to its category for the defined locale.
*
* See http://cldr.unicode.org/index/cldr-spec/plural-rules
*
* \@experimental
*/
var NgPlural = /** @class */function () {
function NgPlural(_localization) {
this._localization = _localization;
this._caseViews = {};
}
Object.defineProperty(NgPlural.prototype, "ngPlural", {
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._switchValue = value;
this._updateView();
},
enumerable: true,
configurable: true
});
/**
* @param {?} value
* @param {?} switchView
* @return {?}
*/
NgPlural.prototype.addCase = /**
* @param {?} value
* @param {?} switchView
* @return {?}
*/
function (value, switchView) {
this._caseViews[value] = switchView;
};
/**
* @return {?}
*/
NgPlural.prototype._updateView = /**
* @return {?}
*/
function () {
this._clearViews();
var /** @type {?} */cases = Object.keys(this._caseViews);
var /** @type {?} */key = getPluralCategory(this._switchValue, cases, this._localization);
this._activateView(this._caseViews[key]);
};
/**
* @return {?}
*/
NgPlural.prototype._clearViews = /**
* @return {?}
*/
function () {
if (this._activeView) this._activeView.destroy();
};
/**
* @param {?} view
* @return {?}
*/
NgPlural.prototype._activateView = /**
* @param {?} view
* @return {?}
*/
function (view) {
if (view) {
this._activeView = view;
this._activeView.create();
}
};
NgPlural.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngPlural]' }] }];
/** @nocollapse */
NgPlural.ctorParameters = function () {
return [{ type: NgLocalization }];
};
NgPlural.propDecorators = {
"ngPlural": [{ type: _angular_core.Input }]
};
return NgPlural;
}();
/**
* \@ngModule CommonModule
*
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgPlural} when the
* given expression matches the plural expression according to CLDR rules.
*
* \@howToUse
* ```
* <some-element [ngPlural]="value">
* <ng-template ngPluralCase="=0">...</ng-template>
* <ng-template ngPluralCase="other">...</ng-template>
* </some-element>
* ```
*
* See {\@link NgPlural} for more details and example.
*
* \@experimental
*/
var NgPluralCase = /** @class */function () {
function NgPluralCase(value, template, viewContainer, ngPlural) {
this.value = value;
var /** @type {?} */isANumber = !isNaN(Number(value));
ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
}
NgPluralCase.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngPluralCase]' }] }];
/** @nocollapse */
NgPluralCase.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Attribute, args: ['ngPluralCase'] }] }, { type: _angular_core.TemplateRef }, { type: _angular_core.ViewContainerRef }, { type: NgPlural, decorators: [{ type: _angular_core.Host }] }];
};
return NgPluralCase;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Update an HTML element styles.
*
* \@howToUse
* ```
* <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
*
* <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
*
* <some-element [ngStyle]="objExp">...</some-element>
* ```
*
* \@description
*
* The styles are updated according to the value of the expression evaluation:
* - keys are style names with an optional `.<unit>` suffix (ie 'top.px', 'font-style.em'),
* - values are the values assigned to those properties (expressed in the given unit).
*
* \@stable
*/
var NgStyle = /** @class */function () {
function NgStyle(_differs, _ngEl, _renderer) {
this._differs = _differs;
this._ngEl = _ngEl;
this._renderer = _renderer;
}
Object.defineProperty(NgStyle.prototype, "ngStyle", {
set: /**
* @param {?} v
* @return {?}
*/
function (v) {
this._ngStyle = v;
if (!this._differ && v) {
this._differ = this._differs.find(v).create();
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgStyle.prototype.ngDoCheck = /**
* @return {?}
*/
function () {
if (this._differ) {
var /** @type {?} */changes = this._differ.diff(this._ngStyle);
if (changes) {
this._applyChanges(changes);
}
}
};
/**
* @param {?} changes
* @return {?}
*/
NgStyle.prototype._applyChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
changes.forEachRemovedItem(function (record) {
return _this._setStyle(record.key, null);
});
changes.forEachAddedItem(function (record) {
return _this._setStyle(record.key, record.currentValue);
});
changes.forEachChangedItem(function (record) {
return _this._setStyle(record.key, record.currentValue);
});
};
/**
* @param {?} nameAndUnit
* @param {?} value
* @return {?}
*/
NgStyle.prototype._setStyle = /**
* @param {?} nameAndUnit
* @param {?} value
* @return {?}
*/
function (nameAndUnit, value) {
var _a = nameAndUnit.split('.'),
name = _a[0],
unit = _a[1];
value = value != null && unit ? "" + value + unit : value;
this._renderer.setStyle(this._ngEl.nativeElement, name, /** @type {?} */value);
};
NgStyle.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngStyle]' }] }];
/** @nocollapse */
NgStyle.ctorParameters = function () {
return [{ type: _angular_core.KeyValueDiffers }, { type: _angular_core.ElementRef }, { type: _angular_core.Renderer2 }];
};
NgStyle.propDecorators = {
"ngStyle": [{ type: _angular_core.Input }]
};
return NgStyle;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Inserts an embedded view from a prepared `TemplateRef`
*
* \@howToUse
* ```
* <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
* ```
*
* \@description
*
* You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
* `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
* by the local template `let` declarations.
*
* Note: using the key `$implicit` in the context object will set it's value as default.
*
* ## Example
*
* {\@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
*
* \@stable
*/
var NgTemplateOutlet = /** @class */function () {
function NgTemplateOutlet(_viewContainerRef) {
this._viewContainerRef = _viewContainerRef;
}
/**
* @param {?} changes
* @return {?}
*/
NgTemplateOutlet.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var /** @type {?} */recreateView = this._shouldRecreateView(changes);
if (recreateView) {
if (this._viewRef) {
this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
}
if (this.ngTemplateOutlet) {
this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
}
} else {
if (this._viewRef && this.ngTemplateOutletContext) {
this._updateExistingContext(this.ngTemplateOutletContext);
}
}
};
/**
* We need to re-create existing embedded view if:
* - templateRef has changed
* - context has changes
*
* We mark context object as changed when the corresponding object
* shape changes (new properties are added or existing properties are removed).
* In other words we consider context with the same properties as "the same" even
* if object reference changes (see https://github.com/angular/angular/issues/13407).
* @param {?} changes
* @return {?}
*/
NgTemplateOutlet.prototype._shouldRecreateView = /**
* We need to re-create existing embedded view if:
* - templateRef has changed
* - context has changes
*
* We mark context object as changed when the corresponding object
* shape changes (new properties are added or existing properties are removed).
* In other words we consider context with the same properties as "the same" even
* if object reference changes (see https://github.com/angular/angular/issues/13407).
* @param {?} changes
* @return {?}
*/
function (changes) {
var /** @type {?} */ctxChange = changes['ngTemplateOutletContext'];
return !!changes['ngTemplateOutlet'] || ctxChange && this._hasContextShapeChanged(ctxChange);
};
/**
* @param {?} ctxChange
* @return {?}
*/
NgTemplateOutlet.prototype._hasContextShapeChanged = /**
* @param {?} ctxChange
* @return {?}
*/
function (ctxChange) {
var /** @type {?} */prevCtxKeys = Object.keys(ctxChange.previousValue || {});
var /** @type {?} */currCtxKeys = Object.keys(ctxChange.currentValue || {});
if (prevCtxKeys.length === currCtxKeys.length) {
for (var _i = 0, currCtxKeys_1 = currCtxKeys; _i < currCtxKeys_1.length; _i++) {
var propName = currCtxKeys_1[_i];
if (prevCtxKeys.indexOf(propName) === -1) {
return true;
}
}
return false;
} else {
return true;
}
};
/**
* @param {?} ctx
* @return {?}
*/
NgTemplateOutlet.prototype._updateExistingContext = /**
* @param {?} ctx
* @return {?}
*/
function (ctx) {
for (var _i = 0, _a = Object.keys(ctx); _i < _a.length; _i++) {
var propName = _a[_i];
/** @type {?} */this._viewRef.context[propName] = /** @type {?} */this.ngTemplateOutletContext[propName];
}
};
NgTemplateOutlet.decorators = [{ type: _angular_core.Directive, args: [{ selector: '[ngTemplateOutlet]' }] }];
/** @nocollapse */
NgTemplateOutlet.ctorParameters = function () {
return [{ type: _angular_core.ViewContainerRef }];
};
NgTemplateOutlet.propDecorators = {
"ngTemplateOutletContext": [{ type: _angular_core.Input }],
"ngTemplateOutlet": [{ type: _angular_core.Input }]
};
return NgTemplateOutlet;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A collection of Angular directives that are likely to be used in each and every Angular
* application.
*/
var COMMON_DIRECTIVES = [NgClass, NgComponentOutlet, NgForOf, NgIf, NgTemplateOutlet, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgPlural, NgPluralCase];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NAMED_FORMATS = {};
var DATE_FORMATS_SPLIT = /((?:[^GyMLwWdEabBhHmsSzZO']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\s\S]*)/;
/** @enum {number} */
var ZoneWidth = {
Short: 0,
ShortGMT: 1,
Long: 2,
Extended: 3
};
ZoneWidth[ZoneWidth.Short] = "Short";
ZoneWidth[ZoneWidth.ShortGMT] = "ShortGMT";
ZoneWidth[ZoneWidth.Long] = "Long";
ZoneWidth[ZoneWidth.Extended] = "Extended";
/** @enum {number} */
var DateType = {
FullYear: 0,
Month: 1,
Date: 2,
Hours: 3,
Minutes: 4,
Seconds: 5,
Milliseconds: 6,
Day: 7
};
DateType[DateType.FullYear] = "FullYear";
DateType[DateType.Month] = "Month";
DateType[DateType.Date] = "Date";
DateType[DateType.Hours] = "Hours";
DateType[DateType.Minutes] = "Minutes";
DateType[DateType.Seconds] = "Seconds";
DateType[DateType.Milliseconds] = "Milliseconds";
DateType[DateType.Day] = "Day";
/** @enum {number} */
var TranslationType = {
DayPeriods: 0,
Days: 1,
Months: 2,
Eras: 3
};
TranslationType[TranslationType.DayPeriods] = "DayPeriods";
TranslationType[TranslationType.Days] = "Days";
TranslationType[TranslationType.Months] = "Months";
TranslationType[TranslationType.Eras] = "Eras";
/**
* Transforms a date to a locale string based on a pattern and a timezone
*
* \@internal
* @param {?} date
* @param {?} format
* @param {?} locale
* @param {?=} timezone
* @return {?}
*/
function formatDate(date, format, locale, timezone) {
var /** @type {?} */namedFormat = getNamedFormat(locale, format);
format = namedFormat || format;
var /** @type {?} */parts = [];
var /** @type {?} */match;
while (format) {
match = DATE_FORMATS_SPLIT.exec(format);
if (match) {
parts = parts.concat(match.slice(1));
var /** @type {?} */part = parts.pop();
if (!part) {
break;
}
format = part;
} else {
parts.push(format);
break;
}
}
var /** @type {?} */dateTimezoneOffset = date.getTimezoneOffset();
if (timezone) {
dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
date = convertTimezoneToLocal(date, timezone, true);
}
var /** @type {?} */text = '';
parts.forEach(function (value) {
var /** @type {?} */dateFormatter = getDateFormatter(value);
text += dateFormatter ? dateFormatter(date, locale, dateTimezoneOffset) : value === '\'\'' ? '\'' : value.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
});
return text;
}
/**
* @param {?} locale
* @param {?} format
* @return {?}
*/
function getNamedFormat(locale, format) {
var /** @type {?} */localeId = getLocaleId(locale);
NAMED_FORMATS[localeId] = NAMED_FORMATS[localeId] || {};
if (NAMED_FORMATS[localeId][format]) {
return NAMED_FORMATS[localeId][format];
}
var /** @type {?} */formatValue = '';
switch (format) {
case 'shortDate':
formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
break;
case 'mediumDate':
formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
break;
case 'longDate':
formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
break;
case 'fullDate':
formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
break;
case 'shortTime':
formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
break;
case 'mediumTime':
formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
break;
case 'longTime':
formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
break;
case 'fullTime':
formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
break;
case 'short':
var /** @type {?} */shortTime = getNamedFormat(locale, 'shortTime');
var /** @type {?} */shortDate = getNamedFormat(locale, 'shortDate');
formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [shortTime, shortDate]);
break;
case 'medium':
var /** @type {?} */mediumTime = getNamedFormat(locale, 'mediumTime');
var /** @type {?} */mediumDate = getNamedFormat(locale, 'mediumDate');
formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [mediumTime, mediumDate]);
break;
case 'long':
var /** @type {?} */longTime = getNamedFormat(locale, 'longTime');
var /** @type {?} */longDate = getNamedFormat(locale, 'longDate');
formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [longTime, longDate]);
break;
case 'full':
var /** @type {?} */fullTime = getNamedFormat(locale, 'fullTime');
var /** @type {?} */fullDate = getNamedFormat(locale, 'fullDate');
formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [fullTime, fullDate]);
break;
}
if (formatValue) {
NAMED_FORMATS[localeId][format] = formatValue;
}
return formatValue;
}
/**
* @param {?} str
* @param {?} opt_values
* @return {?}
*/
function formatDateTime(str, opt_values) {
if (opt_values) {
str = str.replace(/\{([^}]+)}/g, function (match, key) {
return opt_values != null && key in opt_values ? opt_values[key] : match;
});
}
return str;
}
/**
* @param {?} num
* @param {?} digits
* @param {?=} minusSign
* @param {?=} trim
* @param {?=} negWrap
* @return {?}
*/
function padNumber(num, digits, minusSign, trim, negWrap) {
if (minusSign === void 0) {
minusSign = '-';
}
var /** @type {?} */neg = '';
if (num < 0 || negWrap && num <= 0) {
if (negWrap) {
num = -num + 1;
} else {
num = -num;
neg = minusSign;
}
}
var /** @type {?} */strNum = '' + num;
while (strNum.length < digits) strNum = '0' + strNum;
if (trim) {
strNum = strNum.substr(strNum.length - digits);
}
return neg + strNum;
}
/**
* Returns a date formatter that transforms a date into its locale digit representation
* @param {?} name
* @param {?} size
* @param {?=} offset
* @param {?=} trim
* @param {?=} negWrap
* @return {?}
*/
function dateGetter(name, size, offset, trim, negWrap) {
if (offset === void 0) {
offset = 0;
}
if (trim === void 0) {
trim = false;
}
if (negWrap === void 0) {
negWrap = false;
}
return function (date, locale) {
var /** @type {?} */part = getDatePart(name, date, size);
if (offset > 0 || part > -offset) {
part += offset;
}
if (name === DateType.Hours && part === 0 && offset === -12) {
part = 12;
}
return padNumber(part, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign), trim, negWrap);
};
}
/**
* @param {?} name
* @param {?} date
* @param {?} size
* @return {?}
*/
function getDatePart(name, date, size) {
switch (name) {
case DateType.FullYear:
return date.getFullYear();
case DateType.Month:
return date.getMonth();
case DateType.Date:
return date.getDate();
case DateType.Hours:
return date.getHours();
case DateType.Minutes:
return date.getMinutes();
case DateType.Seconds:
return date.getSeconds();
case DateType.Milliseconds:
var /** @type {?} */div = size === 1 ? 100 : size === 2 ? 10 : 1;
return Math.round(date.getMilliseconds() / div);
case DateType.Day:
return date.getDay();
default:
throw new Error("Unknown DateType value \"" + name + "\".");
}
}
/**
* Returns a date formatter that transforms a date into its locale string representation
* @param {?} name
* @param {?} width
* @param {?=} form
* @param {?=} extended
* @return {?}
*/
function dateStrGetter(name, width, form, extended) {
if (form === void 0) {
form = FormStyle.Format;
}
if (extended === void 0) {
extended = false;
}
return function (date, locale) {
return getDateTranslation(date, locale, name, width, form, extended);
};
}
/**
* Returns the locale translation of a date for a given form, type and width
* @param {?} date
* @param {?} locale
* @param {?} name
* @param {?} width
* @param {?} form
* @param {?} extended
* @return {?}
*/
function getDateTranslation(date, locale, name, width, form, extended) {
switch (name) {
case TranslationType.Months:
return getLocaleMonthNames(locale, form, width)[date.getMonth()];
case TranslationType.Days:
return getLocaleDayNames(locale, form, width)[date.getDay()];
case TranslationType.DayPeriods:
var /** @type {?} */currentHours_1 = date.getHours();
var /** @type {?} */currentMinutes_1 = date.getMinutes();
if (extended) {
var /** @type {?} */rules = getLocaleExtraDayPeriodRules(locale);
var /** @type {?} */dayPeriods_1 = getLocaleExtraDayPeriods(locale, form, width);
var /** @type {?} */result_1;
rules.forEach(function (rule, index) {
if (Array.isArray(rule)) {
// morning, afternoon, evening, night
var _a = rule[0],
hoursFrom = _a.hours,
minutesFrom = _a.minutes;
var _b = rule[1],
hoursTo = _b.hours,
minutesTo = _b.minutes;
if (currentHours_1 >= hoursFrom && currentMinutes_1 >= minutesFrom && (currentHours_1 < hoursTo || currentHours_1 === hoursTo && currentMinutes_1 < minutesTo)) {
result_1 = dayPeriods_1[index];
}
} else {
// noon or midnight
var hours = rule.hours,
minutes = rule.minutes;
if (hours === currentHours_1 && minutes === currentMinutes_1) {
result_1 = dayPeriods_1[index];
}
}
});
if (result_1) {
return result_1;
}
}
// if no rules for the day periods, we use am/pm by default
return getLocaleDayPeriods(locale, form, /** @type {?} */width)[currentHours_1 < 12 ? 0 : 1];
case TranslationType.Eras:
return getLocaleEraNames(locale, /** @type {?} */width)[date.getFullYear() <= 0 ? 0 : 1];
}
}
/**
* Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
* GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
* extended = +04:30)
* @param {?} width
* @return {?}
*/
function timeZoneGetter(width) {
return function (date, locale, offset) {
var /** @type {?} */zone = -1 * offset;
var /** @type {?} */minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
var /** @type {?} */hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
switch (width) {
case ZoneWidth.Short:
return (zone >= 0 ? '+' : '') + padNumber(hours, 2, minusSign) + padNumber(Math.abs(zone % 60), 2, minusSign);
case ZoneWidth.ShortGMT:
return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 1, minusSign);
case ZoneWidth.Long:
return 'GMT' + (zone >= 0 ? '+' : '') + padNumber(hours, 2, minusSign) + ':' + padNumber(Math.abs(zone % 60), 2, minusSign);
case ZoneWidth.Extended:
if (offset === 0) {
return 'Z';
} else {
return (zone >= 0 ? '+' : '') + padNumber(hours, 2, minusSign) + ':' + padNumber(Math.abs(zone % 60), 2, minusSign);
}
default:
throw new Error("Unknown zone width \"" + width + "\"");
}
};
}
var JANUARY = 0;
var THURSDAY = 4;
/**
* @param {?} year
* @return {?}
*/
function getFirstThursdayOfYear(year) {
var /** @type {?} */firstDayOfYear = new Date(year, JANUARY, 1).getDay();
return new Date(year, 0, 1 + (firstDayOfYear <= THURSDAY ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
}
/**
* @param {?} datetime
* @return {?}
*/
function getThursdayThisWeek(datetime) {
return new Date(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + (THURSDAY - datetime.getDay()));
}
/**
* @param {?} size
* @param {?=} monthBased
* @return {?}
*/
function weekGetter(size, monthBased) {
if (monthBased === void 0) {
monthBased = false;
}
return function (date, locale) {
var /** @type {?} */result;
if (monthBased) {
var /** @type {?} */nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
var /** @type {?} */today = date.getDate();
result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
} else {
var /** @type {?} */firstThurs = getFirstThursdayOfYear(date.getFullYear());
var /** @type {?} */thisThurs = getThursdayThisWeek(date);
var /** @type {?} */diff = thisThurs.getTime() - firstThurs.getTime();
result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
}
return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
};
}
var DATE_FORMATS = {};
/**
* @param {?} format
* @return {?}
*/
function getDateFormatter(format) {
if (DATE_FORMATS[format]) {
return DATE_FORMATS[format];
}
var /** @type {?} */formatter;
switch (format) {
// Era name (AD/BC)
case 'G':
case 'GG':
case 'GGG':
formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated);
break;
case 'GGGG':
formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide);
break;
case 'GGGGG':
formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow);
break;
// 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
case 'y':
formatter = dateGetter(DateType.FullYear, 1, 0, false, true);
break;
// 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
case 'yy':
formatter = dateGetter(DateType.FullYear, 2, 0, true, true);
break;
// 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
case 'yyy':
formatter = dateGetter(DateType.FullYear, 3, 0, false, true);
break;
// 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
case 'yyyy':
formatter = dateGetter(DateType.FullYear, 4, 0, false, true);
break;
// Month of the year (1-12), numeric
case 'M':
case 'L':
formatter = dateGetter(DateType.Month, 1, 1);
break;
case 'MM':
case 'LL':
formatter = dateGetter(DateType.Month, 2, 1);
break;
// Month of the year (January, ...), string, format
case 'MMM':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated);
break;
case 'MMMM':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide);
break;
case 'MMMMM':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow);
break;
// Month of the year (January, ...), string, standalone
case 'LLL':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone);
break;
case 'LLLL':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone);
break;
case 'LLLLL':
formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone);
break;
// Week of the year (1, ... 52)
case 'w':
formatter = weekGetter(1);
break;
case 'ww':
formatter = weekGetter(2);
break;
// Week of the month (1, ...)
case 'W':
formatter = weekGetter(1, true);
break;
// Day of the month (1-31)
case 'd':
formatter = dateGetter(DateType.Date, 1);
break;
case 'dd':
formatter = dateGetter(DateType.Date, 2);
break;
// Day of the Week
case 'E':
case 'EE':
case 'EEE':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated);
break;
case 'EEEE':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide);
break;
case 'EEEEE':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow);
break;
case 'EEEEEE':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short);
break;
// Generic period of the day (am-pm)
case 'a':
case 'aa':
case 'aaa':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated);
break;
case 'aaaa':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide);
break;
case 'aaaaa':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow);
break;
// Extended period of the day (midnight, at night, ...), standalone
case 'b':
case 'bb':
case 'bbb':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
break;
case 'bbbb':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true);
break;
case 'bbbbb':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true);
break;
// Extended period of the day (midnight, night, ...), standalone
case 'B':
case 'BB':
case 'BBB':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true);
break;
case 'BBBB':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true);
break;
case 'BBBBB':
formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true);
break;
// Hour in AM/PM, (1-12)
case 'h':
formatter = dateGetter(DateType.Hours, 1, -12);
break;
case 'hh':
formatter = dateGetter(DateType.Hours, 2, -12);
break;
// Hour of the day (0-23)
case 'H':
formatter = dateGetter(DateType.Hours, 1);
break;
// Hour in day, padded (00-23)
case 'HH':
formatter = dateGetter(DateType.Hours, 2);
break;
// Minute of the hour (0-59)
case 'm':
formatter = dateGetter(DateType.Minutes, 1);
break;
case 'mm':
formatter = dateGetter(DateType.Minutes, 2);
break;
// Second of the minute (0-59)
case 's':
formatter = dateGetter(DateType.Seconds, 1);
break;
case 'ss':
formatter = dateGetter(DateType.Seconds, 2);
break;
// Fractional second padded (0-9)
case 'S':
formatter = dateGetter(DateType.Milliseconds, 1);
break;
case 'SS':
formatter = dateGetter(DateType.Milliseconds, 2);
break;
// = millisecond
case 'SSS':
formatter = dateGetter(DateType.Milliseconds, 3);
break;
// Timezone ISO8601 short format (-0430)
case 'Z':
case 'ZZ':
case 'ZZZ':
formatter = timeZoneGetter(ZoneWidth.Short);
break;
// Timezone ISO8601 extended format (-04:30)
case 'ZZZZZ':
formatter = timeZoneGetter(ZoneWidth.Extended);
break;
// Timezone GMT short format (GMT+4)
case 'O':
case 'OO':
case 'OOO':
// Should be location, but fallback to format O instead because we don't have the data yet
case 'z':
case 'zz':
case 'zzz':
formatter = timeZoneGetter(ZoneWidth.ShortGMT);
break;
// Timezone GMT long format (GMT+0430)
case 'OOOO':
case 'ZZZZ':
// Should be location, but fallback to format O instead because we don't have the data yet
case 'zzzz':
formatter = timeZoneGetter(ZoneWidth.Long);
break;
default:
return null;
}
DATE_FORMATS[format] = formatter;
return formatter;
}
/**
* @param {?} timezone
* @param {?} fallback
* @return {?}
*/
function timezoneToOffset(timezone, fallback) {
// Support: IE 9-11 only, Edge 13-15+
// IE/Edge do not "understand" colon (`:`) in timezone
timezone = timezone.replace(/:/g, '');
var /** @type {?} */requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
}
/**
* @param {?} date
* @param {?} minutes
* @return {?}
*/
function addDateMinutes(date, minutes) {
date = new Date(date.getTime());
date.setMinutes(date.getMinutes() + minutes);
return date;
}
/**
* @param {?} date
* @param {?} timezone
* @param {?} reverse
* @return {?}
*/
function convertTimezoneToLocal(date, timezone, reverse) {
var /** @type {?} */reverseValue = reverse ? -1 : 1;
var /** @type {?} */dateTimezoneOffset = date.getTimezoneOffset();
var /** @type {?} */timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} type
* @param {?} value
* @return {?}
*/
function invalidPipeArgumentError(type, value) {
return Error("InvalidPipeArgument: '" + value + "' for pipe '" + _angular_core.ɵstringify(type) + "'");
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a date according to locale rules.
* \@howToUse `date_expression | date[:format[:timezone[:locale]]]`
* \@description
*
* Where:
* - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
* (https://www.w3.org/TR/NOTE-datetime).
* - `format` indicates which date/time components to include. The format can be predefined as
* shown below (all examples are given for `en-US`) or custom as shown in the table.
* - `'short'`: equivalent to `'M/d/yy, h:mm a'` (e.g. `6/15/15, 9:03 AM`)
* - `'medium'`: equivalent to `'MMM d, y, h:mm:ss a'` (e.g. `Jun 15, 2015, 9:03:01 AM`)
* - `'long'`: equivalent to `'MMMM d, y, h:mm:ss a z'` (e.g. `June 15, 2015 at 9:03:01 AM GMT+1`)
* - `'full'`: equivalent to `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (e.g. `Monday, June 15, 2015 at
* 9:03:01 AM GMT+01:00`)
* - `'shortDate'`: equivalent to `'M/d/yy'` (e.g. `6/15/15`)
* - `'mediumDate'`: equivalent to `'MMM d, y'` (e.g. `Jun 15, 2015`)
* - `'longDate'`: equivalent to `'MMMM d, y'` (e.g. `June 15, 2015`)
* - `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` (e.g. `Monday, June 15, 2015`)
* - `'shortTime'`: equivalent to `'h:mm a'` (e.g. `9:03 AM`)
* - `'mediumTime'`: equivalent to `'h:mm:ss a'` (e.g. `9:03:01 AM`)
* - `'longTime'`: equivalent to `'h:mm:ss a z'` (e.g. `9:03:01 AM GMT+1`)
* - `'fullTime'`: equivalent to `'h:mm:ss a zzzz'` (e.g. `9:03:01 AM GMT+01:00`)
* - `timezone` to be used for formatting. It understands UTC/GMT and the continental US time zone
* abbreviations, but for general use, use a time zone offset, for example,
* `'+0430'` (4 hours, 30 minutes east of the Greenwich meridian)
* If not specified, the local system timezone of the end-user's browser will be used.
* - `locale` is a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
* default)
*
*
* | Field Type | Format | Description | Example Value |
* |--------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
* | Era | G, GG & GGG | Abbreviated | AD |
* | | GGGG | Wide | Anno Domini |
* | | GGGGG | Narrow | A |
* | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
* | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
* | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
* | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
* | Month | M | Numeric: 1 digit | 9, 12 |
* | | MM | Numeric: 2 digits + zero padded | 09, 12 |
* | | MMM | Abbreviated | Sep |
* | | MMMM | Wide | September |
* | | MMMMM | Narrow | S |
* | Month standalone | L | Numeric: 1 digit | 9, 12 |
* | | LL | Numeric: 2 digits + zero padded | 09, 12 |
* | | LLL | Abbreviated | Sep |
* | | LLLL | Wide | September |
* | | LLLLL | Narrow | S |
* | Week of year | w | Numeric: minimum digits | 1... 53 |
* | | ww | Numeric: 2 digits + zero padded | 01... 53 |
* | Week of month | W | Numeric: 1 digit | 1... 5 |
* | Day of month | d | Numeric: minimum digits | 1 |
* | | dd | Numeric: 2 digits + zero padded | 01 |
* | Week day | E, EE & EEE | Abbreviated | Tue |
* | | EEEE | Wide | Tuesday |
* | | EEEEE | Narrow | T |
* | | EEEEEE | Short | Tu |
* | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
* | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
* | | aaaaa | Narrow | a/p |
* | Period* | B, BB & BBB | Abbreviated | mid. |
* | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
* | | BBBBB | Narrow | md |
* | Period standalone* | b, bb & bbb | Abbreviated | mid. |
* | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
* | | bbbbb | Narrow | md |
* | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
* | | hh | Numeric: 2 digits + zero padded | 01, 12 |
* | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
* | | HH | Numeric: 2 digits + zero padded | 00, 23 |
* | Minute | m | Numeric: minimum digits | 8, 59 |
* | | mm | Numeric: 2 digits + zero padded | 08, 59 |
* | Second | s | Numeric: minimum digits | 0... 59 |
* | | ss | Numeric: 2 digits + zero padded | 00... 59 |
* | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
* | | SS | Numeric: 2 digits + zero padded | 00... 99 |
* | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
* | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
* | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
* | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
* | | ZZZZ | Long localized GMT format | GMT-8:00 |
* | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
* | | O, OO & OOO | Short localized GMT format | GMT-8 |
* | | OOOO | Long localized GMT format | GMT-08:00 |
*
*
* When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
* applied and the formatted text will have the same day, month and year of the expression.
*
* WARNINGS:
* - this pipe has only access to en-US locale data by default. If you want to localize the dates
* in another language, you will have to import data for other locales.
* See the {\@linkDocs guide/i18n#i18n-pipes "I18n guide"} to know how to import additional locale
* data.
* - Fields suffixed with * are only available in the extra dataset.
* See the {\@linkDocs guide/i18n#i18n-pipes "I18n guide"} to know how to import extra locale
* data.
* - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
* Instead users should treat the date as an immutable object and change the reference when the
* pipe needs to re-run (this is to avoid reformatting the date on every change detection run
* which would be an expensive operation).
*
* ### Examples
*
* Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
* in the _local_ time and locale is 'en-US':
*
* {\@example common/pipes/ts/date_pipe.ts region='DatePipe'}
*
* \@stable
*/
var DatePipe = /** @class */function () {
function DatePipe(locale) {
this.locale = locale;
}
/**
* @param {?} value
* @param {?=} format
* @param {?=} timezone
* @param {?=} locale
* @return {?}
*/
DatePipe.prototype.transform = /**
* @param {?} value
* @param {?=} format
* @param {?=} timezone
* @param {?=} locale
* @return {?}
*/
function (value, format, timezone, locale) {
if (format === void 0) {
format = 'mediumDate';
}
if (value == null || value === '' || value !== value) return null;
if (typeof value === 'string') {
value = value.trim();
}
var /** @type {?} */date;
if (isDate$1(value)) {
date = value;
} else if (!isNaN(value - parseFloat(value))) {
date = new Date(parseFloat(value));
} else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
/**
* For ISO Strings without time the day, month and year must be extracted from the ISO String
* before Date creation to avoid time offset and errors in the new Date.
* If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
* date, some browsers (e.g. IE 9) will throw an invalid Date error
* If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
* is applied
* Note: ISO months are 0 for January, 1 for February, ...
*/
var _a = value.split('-').map(function (val) {
return +val;
}),
y = _a[0],
m = _a[1],
d = _a[2];
date = new Date(y, m - 1, d);
} else {
date = new Date(value);
}
if (!isDate$1(date)) {
var /** @type {?} */match = void 0;
if (typeof value === 'string' && (match = value.match(ISO8601_DATE_REGEX))) {
date = isoStringToDate(match);
} else {
throw invalidPipeArgumentError(DatePipe, value);
}
}
return formatDate(date, format, locale || this.locale, timezone);
};
DatePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'date', pure: true }] }];
/** @nocollapse */
DatePipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DatePipe;
}();
/**
* \@internal
* @param {?} match
* @return {?}
*/
function isoStringToDate(match) {
var /** @type {?} */date = new Date(0);
var /** @type {?} */tzHour = 0;
var /** @type {?} */tzMin = 0;
var /** @type {?} */dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
var /** @type {?} */timeSetter = match[8] ? date.setUTCHours : date.setHours;
if (match[9]) {
tzHour = +(match[9] + match[10]);
tzMin = +(match[9] + match[11]);
}
dateSetter.call(date, +match[1], +match[2] - 1, +match[3]);
var /** @type {?} */h = +(match[4] || '0') - tzHour;
var /** @type {?} */m = +(match[5] || '0') - tzMin;
var /** @type {?} */s = +(match[6] || '0');
var /** @type {?} */ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
timeSetter.call(date, h, m, s, ms);
return date;
}
/**
* @param {?} value
* @return {?}
*/
function isDate$1(value) {
return value instanceof Date && !isNaN(value.valueOf());
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NumberFormatter = /** @class */function () {
function NumberFormatter() {}
/**
* @param {?} num
* @param {?} locale
* @param {?} style
* @param {?=} opts
* @return {?}
*/
NumberFormatter.format = /**
* @param {?} num
* @param {?} locale
* @param {?} style
* @param {?=} opts
* @return {?}
*/
function (num, locale, style, opts) {
if (opts === void 0) {
opts = {};
}
var minimumIntegerDigits = opts.minimumIntegerDigits,
minimumFractionDigits = opts.minimumFractionDigits,
maximumFractionDigits = opts.maximumFractionDigits,
currency = opts.currency,
_a = opts.currencyAsSymbol,
currencyAsSymbol = _a === void 0 ? false : _a;
var /** @type {?} */options = {
minimumIntegerDigits: minimumIntegerDigits,
minimumFractionDigits: minimumFractionDigits,
maximumFractionDigits: maximumFractionDigits,
style: NumberFormatStyle[style].toLowerCase()
};
if (style == NumberFormatStyle.Currency) {
options.currency = typeof currency == 'string' ? currency : undefined;
options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
}
return new Intl.NumberFormat(locale, options).format(num);
};
return NumberFormatter;
}();
var DATE_FORMATS_SPLIT$1 = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
var PATTERN_ALIASES = {
// Keys are quoted so they do not get renamed during closure compilation.
'yMMMdjms': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1), digitCondition('hour', 1), digitCondition('minute', 1), digitCondition('second', 1)])),
'yMdjm': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1), digitCondition('hour', 1), digitCondition('minute', 1)])),
'yMMMMEEEEd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4), digitCondition('day', 1)])),
'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
};
var DATE_FORMATS$1 = {
// Keys are quoted so they do not get renamed.
'yyyy': datePartGetterFactory(digitCondition('year', 4)),
'yy': datePartGetterFactory(digitCondition('year', 2)),
'y': datePartGetterFactory(digitCondition('year', 1)),
'MMMM': datePartGetterFactory(nameCondition('month', 4)),
'MMM': datePartGetterFactory(nameCondition('month', 3)),
'MM': datePartGetterFactory(digitCondition('month', 2)),
'M': datePartGetterFactory(digitCondition('month', 1)),
'LLLL': datePartGetterFactory(nameCondition('month', 4)),
'L': datePartGetterFactory(nameCondition('month', 1)),
'dd': datePartGetterFactory(digitCondition('day', 2)),
'd': datePartGetterFactory(digitCondition('day', 1)),
'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
'jj': datePartGetterFactory(digitCondition('hour', 2)),
'j': datePartGetterFactory(digitCondition('hour', 1)),
'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
'm': datePartGetterFactory(digitCondition('minute', 1)),
'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
's': datePartGetterFactory(digitCondition('second', 1)),
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
// we can be just safely rely on using `sss` since we currently don't support single or two digit
// fractions
'sss': datePartGetterFactory(digitCondition('second', 3)),
'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
'EE': datePartGetterFactory(nameCondition('weekday', 2)),
'E': datePartGetterFactory(nameCondition('weekday', 1)),
'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
'Z': timeZoneGetter$1('short'),
'z': timeZoneGetter$1('long'),
'ww': datePartGetterFactory({}),
// Week of year, padded (00-53). Week 01 is the week with the
// first Thursday of the year. not support ?
'w': datePartGetterFactory({}),
// Week of year (0-53). Week 1 is the week with the first Thursday
// of the year not support ?
'G': datePartGetterFactory(nameCondition('era', 1)),
'GG': datePartGetterFactory(nameCondition('era', 2)),
'GGG': datePartGetterFactory(nameCondition('era', 3)),
'GGGG': datePartGetterFactory(nameCondition('era', 4))
};
/**
* @param {?} inner
* @return {?}
*/
function digitModifier(inner) {
return function (date, locale) {
var /** @type {?} */result = inner(date, locale);
return result.length == 1 ? '0' + result : result;
};
}
/**
* @param {?} inner
* @return {?}
*/
function hourClockExtractor(inner) {
return function (date, locale) {
return inner(date, locale).split(' ')[1];
};
}
/**
* @param {?} inner
* @return {?}
*/
function hourExtractor(inner) {
return function (date, locale) {
return inner(date, locale).split(' ')[0];
};
}
/**
* @param {?} date
* @param {?} locale
* @param {?} options
* @return {?}
*/
function intlDateFormat(date, locale, options) {
return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
}
/**
* @param {?} timezone
* @return {?}
*/
function timeZoneGetter$1(timezone) {
// To workaround `Intl` API restriction for single timezone let format with 24 hours
var /** @type {?} */options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
return function (date, locale) {
var /** @type {?} */result = intlDateFormat(date, locale, options);
// Then extract first 3 letters that related to hours
return result ? result.substring(3) : '';
};
}
/**
* @param {?} options
* @param {?} value
* @return {?}
*/
function hour12Modify(options, value) {
options.hour12 = value;
return options;
}
/**
* @param {?} prop
* @param {?} len
* @return {?}
*/
function digitCondition(prop, len) {
var /** @type {?} */result = {};
result[prop] = len === 2 ? '2-digit' : 'numeric';
return result;
}
/**
* @param {?} prop
* @param {?} len
* @return {?}
*/
function nameCondition(prop, len) {
var /** @type {?} */result = {};
if (len < 4) {
result[prop] = len > 1 ? 'short' : 'narrow';
} else {
result[prop] = 'long';
}
return result;
}
/**
* @param {?} options
* @return {?}
*/
function combine(options) {
return options.reduce(function (merged, opt) {
return __assign({}, merged, opt);
}, {});
}
/**
* @param {?} ret
* @return {?}
*/
function datePartGetterFactory(ret) {
return function (date, locale) {
return intlDateFormat(date, locale, ret);
};
}
var DATE_FORMATTER_CACHE = new Map();
/**
* @param {?} format
* @param {?} date
* @param {?} locale
* @return {?}
*/
function dateFormatter(format, date, locale) {
var /** @type {?} */fn = PATTERN_ALIASES[format];
if (fn) return fn(date, locale);
var /** @type {?} */cacheKey = format;
var /** @type {?} */parts = DATE_FORMATTER_CACHE.get(cacheKey);
if (!parts) {
parts = [];
var /** @type {?} */match = void 0;
DATE_FORMATS_SPLIT$1.exec(format);
var /** @type {?} */_format = format;
while (_format) {
match = DATE_FORMATS_SPLIT$1.exec(_format);
if (match) {
parts = parts.concat(match.slice(1));
_format = /** @type {?} */parts.pop();
} else {
parts.push(_format);
_format = null;
}
}
DATE_FORMATTER_CACHE.set(cacheKey, parts);
}
return parts.reduce(function (text, part) {
var /** @type {?} */fn = DATE_FORMATS$1[part];
return text + (fn ? fn(date, locale) : partToTime(part));
}, '');
}
/**
* @param {?} part
* @return {?}
*/
function partToTime(part) {
return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
}
var DateFormatter = /** @class */function () {
function DateFormatter() {}
/**
* @param {?} date
* @param {?} locale
* @param {?} pattern
* @return {?}
*/
DateFormatter.format = /**
* @param {?} date
* @param {?} locale
* @param {?} pattern
* @return {?}
*/
function (date, locale, pattern) {
return dateFormatter(pattern, date, locale);
};
return DateFormatter;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a date according to locale rules.
* \@howToUse `date_expression | date[:format]`
* \@description
*
* Where:
* - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
* (https://www.w3.org/TR/NOTE-datetime).
* - `format` indicates which date/time components to include. The format can be predefined as
* shown below or custom as shown in the table.
* - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
* - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
* - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
* - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
* - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
* - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
* - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
* - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
*
*
* | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
* |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
* | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
* | year | y | - | - | - | y (2015) | yy (15) |
* | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
* | day | d | - | - | - | d (3) | dd (03) |
* | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
* | hour | j | - | - | - | j (13) | jj (13) |
* | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)|
* | hour24 | H | - | - | - | H (13) | HH (13) |
* | minute | m | - | - | - | m (5) | mm (05) |
* | second | s | - | - | - | s (9) | ss (09) |
* | timezone | z | - | - | z (Pacific Standard Time)| - | - |
* | timezone | Z | - | Z (GMT-8:00) | - | - | - |
* | timezone | a | - | a (PM) | - | - | - |
*
* In javascript, only the components specified will be respected (not the ordering,
* punctuations, ...) and details of the formatting will be dependent on the locale.
*
* Timezone of the formatted text will be the local system timezone of the end-user's machine.
*
* When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
* applied and the formatted text will have the same day, month and year of the expression.
*
* WARNINGS:
* - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
* Instead users should treat the date as an immutable object and change the reference when the
* pipe needs to re-run (this is to avoid reformatting the date on every change detection run
* which would be an expensive operation).
* - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
* browsers.
*
* ### Examples
*
* Assuming `dateObj` is (year: 2010, month: 9, day: 3, hour: 12 PM, minute: 05, second: 08)
* in the _local_ time and locale is 'en-US':
*
* {\@example common/pipes/ts/date_pipe.ts region='DeprecatedDatePipe'}
*
* \@stable
*/
var DeprecatedDatePipe = /** @class */function () {
function DeprecatedDatePipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} pattern
* @return {?}
*/
DeprecatedDatePipe.prototype.transform = /**
* @param {?} value
* @param {?=} pattern
* @return {?}
*/
function (value, pattern) {
if (pattern === void 0) {
pattern = 'mediumDate';
}
if (value == null || value === '' || value !== value) return null;
var /** @type {?} */date;
if (typeof value === 'string') {
value = value.trim();
}
if (isDate(value)) {
date = value;
} else if (!isNaN(value - parseFloat(value))) {
date = new Date(parseFloat(value));
} else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
/**
* For ISO Strings without time the day, month and year must be extracted from the ISO String
* before Date creation to avoid time offset and errors in the new Date.
* If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
* date, some browsers (e.g. IE 9) will throw an invalid Date error
* If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the
* timeoffset
* is applied
* Note: ISO months are 0 for January, 1 for February, ...
*/
var _a = value.split('-').map(function (val) {
return parseInt(val, 10);
}),
y = _a[0],
m = _a[1],
d = _a[2];
date = new Date(y, m - 1, d);
} else {
date = new Date(value);
}
if (!isDate(date)) {
var /** @type {?} */match = void 0;
if (typeof value === 'string' && (match = value.match(ISO8601_DATE_REGEX))) {
date = isoStringToDate(match);
} else {
throw invalidPipeArgumentError(DeprecatedDatePipe, value);
}
}
return DateFormatter.format(date, this._locale, DeprecatedDatePipe._ALIASES[pattern] || pattern);
};
/**
* \@internal
*/
DeprecatedDatePipe._ALIASES = {
'medium': 'yMMMdjms',
'short': 'yMdjm',
'fullDate': 'yMMMMEEEEd',
'longDate': 'yMMMMd',
'mediumDate': 'yMMMd',
'shortDate': 'yMd',
'mediumTime': 'jms',
'shortTime': 'jm'
};
DeprecatedDatePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'date', pure: true }] }];
/** @nocollapse */
DeprecatedDatePipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DeprecatedDatePipe;
}();
/**
* @param {?} value
* @return {?}
*/
function isDate(value) {
return value instanceof Date && !isNaN(value.valueOf());
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
var MAX_DIGITS = 22;
var DECIMAL_SEP = '.';
var ZERO_CHAR = '0';
var PATTERN_SEP = ';';
var GROUP_SEP = ',';
var DIGIT_CHAR = '#';
var CURRENCY_CHAR = '¤';
var PERCENT_CHAR = '%';
/**
* Transform a number to a locale string based on a style and a format
*
* \@internal
* @param {?} value
* @param {?} locale
* @param {?} style
* @param {?=} digitsInfo
* @param {?=} currency
* @return {?}
*/
function formatNumber$1(value, locale, style, digitsInfo, currency) {
if (currency === void 0) {
currency = null;
}
var /** @type {?} */res = { str: null };
var /** @type {?} */format = getLocaleNumberFormat(locale, style);
var /** @type {?} */num;
// Convert strings to numbers
if (typeof value === 'string' && !isNaN(+value - parseFloat(value))) {
num = +value;
} else if (typeof value !== 'number') {
res.error = value + " is not a number";
return res;
} else {
num = value;
}
if (style === NumberFormatStyle.Percent) {
num = num * 100;
}
var /** @type {?} */numStr = Math.abs(num) + '';
var /** @type {?} */pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
var /** @type {?} */formattedText = '';
var /** @type {?} */isZero = false;
if (!isFinite(num)) {
formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
} else {
var /** @type {?} */parsedNumber = parseNumber(numStr);
var /** @type {?} */minInt = pattern.minInt;
var /** @type {?} */minFraction = pattern.minFrac;
var /** @type {?} */maxFraction = pattern.maxFrac;
if (digitsInfo) {
var /** @type {?} */parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
if (parts === null) {
res.error = digitsInfo + " is not a valid digit info";
return res;
}
var /** @type {?} */minIntPart = parts[1];
var /** @type {?} */minFractionPart = parts[3];
var /** @type {?} */maxFractionPart = parts[5];
if (minIntPart != null) {
minInt = parseIntAutoRadix(minIntPart);
}
if (minFractionPart != null) {
minFraction = parseIntAutoRadix(minFractionPart);
}
if (maxFractionPart != null) {
maxFraction = parseIntAutoRadix(maxFractionPart);
} else if (minFractionPart != null && minFraction > maxFraction) {
maxFraction = minFraction;
}
}
roundNumber(parsedNumber, minFraction, maxFraction);
var /** @type {?} */digits = parsedNumber.digits;
var /** @type {?} */integerLen = parsedNumber.integerLen;
var /** @type {?} */exponent = parsedNumber.exponent;
var /** @type {?} */decimals = [];
isZero = digits.every(function (d) {
return !d;
});
// pad zeros for small numbers
for (; integerLen < minInt; integerLen++) {
digits.unshift(0);
}
// pad zeros for small numbers
for (; integerLen < 0; integerLen++) {
digits.unshift(0);
}
// extract decimals digits
if (integerLen > 0) {
decimals = digits.splice(integerLen, digits.length);
} else {
decimals = digits;
digits = [0];
}
// format the integer digits with grouping separators
var /** @type {?} */groups = [];
if (digits.length >= pattern.lgSize) {
groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
}
while (digits.length > pattern.gSize) {
groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
}
if (digits.length) {
groups.unshift(digits.join(''));
}
var /** @type {?} */groupSymbol = currency ? NumberSymbol.CurrencyGroup : NumberSymbol.Group;
formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
// append the decimal digits
if (decimals.length) {
var /** @type {?} */decimalSymbol = currency ? NumberSymbol.CurrencyDecimal : NumberSymbol.Decimal;
formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
}
if (exponent) {
formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
}
}
if (num < 0 && !isZero) {
formattedText = pattern.negPre + formattedText + pattern.negSuf;
} else {
formattedText = pattern.posPre + formattedText + pattern.posSuf;
}
if (style === NumberFormatStyle.Currency && currency !== null) {
res.str = formattedText.replace(CURRENCY_CHAR, currency).replace(CURRENCY_CHAR, '');
return res;
}
if (style === NumberFormatStyle.Percent) {
res.str = formattedText.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
return res;
}
res.str = formattedText;
return res;
}
/**
* @param {?} format
* @param {?=} minusSign
* @return {?}
*/
function parseNumberFormat(format, minusSign) {
if (minusSign === void 0) {
minusSign = '-';
}
var /** @type {?} */p = {
minInt: 1,
minFrac: 0,
maxFrac: 0,
posPre: '',
posSuf: '',
negPre: '',
negSuf: '',
gSize: 0,
lgSize: 0
};
var /** @type {?} */patternParts = format.split(PATTERN_SEP);
var /** @type {?} */positive = patternParts[0];
var /** @type {?} */negative = patternParts[1];
var /** @type {?} */positiveParts = positive.indexOf(DECIMAL_SEP) !== -1 ? positive.split(DECIMAL_SEP) : [positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1), positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1)],
/** @type {?} */
integer = positiveParts[0],
/** @type {?} */fraction = positiveParts[1] || '';
p.posPre = integer.substr(0, integer.indexOf(DIGIT_CHAR));
for (var /** @type {?} */i = 0; i < fraction.length; i++) {
var /** @type {?} */ch = fraction.charAt(i);
if (ch === ZERO_CHAR) {
p.minFrac = p.maxFrac = i + 1;
} else if (ch === DIGIT_CHAR) {
p.maxFrac = i + 1;
} else {
p.posSuf += ch;
}
}
var /** @type {?} */groups = integer.split(GROUP_SEP);
p.gSize = groups[1] ? groups[1].length : 0;
p.lgSize = groups[2] || groups[1] ? (groups[2] || groups[1]).length : 0;
if (negative) {
var /** @type {?} */trunkLen = positive.length - p.posPre.length - p.posSuf.length,
/** @type {?} */
pos = negative.indexOf(DIGIT_CHAR);
p.negPre = negative.substr(0, pos).replace(/'/g, '');
p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, '');
} else {
p.negPre = minusSign + p.posPre;
p.negSuf = p.posSuf;
}
return p;
}
/**
* Parse a number (as a string)
* Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
* @param {?} numStr
* @return {?}
*/
function parseNumber(numStr) {
var /** @type {?} */exponent = 0,
/** @type {?} */digits,
/** @type {?} */integerLen;
var /** @type {?} */i, /** @type {?} */j, /** @type {?} */zeros;
// Decimal point?
if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
numStr = numStr.replace(DECIMAL_SEP, '');
}
// Exponential form?
if ((i = numStr.search(/e/i)) > 0) {
// Work out the exponent.
if (integerLen < 0) integerLen = i;
integerLen += +numStr.slice(i + 1);
numStr = numStr.substring(0, i);
} else if (integerLen < 0) {
// There was no decimal point or exponent so it is an integer.
integerLen = numStr.length;
}
// Count the number of leading zeros.
for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) {
/* empty */
}
if (i === (zeros = numStr.length)) {
// The digits are all zero.
digits = [0];
integerLen = 1;
} else {
// Count the number of trailing zeros
zeros--;
while (numStr.charAt(zeros) === ZERO_CHAR) zeros--;
// Trailing zeros are insignificant so ignore them
integerLen -= i;
digits = [];
// Convert string to array of digits without leading/trailing zeros.
for (j = 0; i <= zeros; i++, j++) {
digits[j] = +numStr.charAt(i);
}
}
// If the number overflows the maximum allowed digits then use an exponent.
if (integerLen > MAX_DIGITS) {
digits = digits.splice(0, MAX_DIGITS - 1);
exponent = integerLen - 1;
integerLen = 1;
}
return { digits: digits, exponent: exponent, integerLen: integerLen };
}
/**
* Round the parsed number to the specified number of decimal places
* This function changes the parsedNumber in-place
* @param {?} parsedNumber
* @param {?} minFrac
* @param {?} maxFrac
* @return {?}
*/
function roundNumber(parsedNumber, minFrac, maxFrac) {
if (minFrac > maxFrac) {
throw new Error("The minimum number of digits after fraction (" + minFrac + ") is higher than the maximum (" + maxFrac + ").");
}
var /** @type {?} */digits = parsedNumber.digits;
var /** @type {?} */fractionLen = digits.length - parsedNumber.integerLen;
var /** @type {?} */fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
// The index of the digit to where rounding is to occur
var /** @type {?} */roundAt = fractionSize + parsedNumber.integerLen;
var /** @type {?} */digit = digits[roundAt];
if (roundAt > 0) {
// Drop fractional digits beyond `roundAt`
digits.splice(Math.max(parsedNumber.integerLen, roundAt));
// Set non-fractional digits beyond `roundAt` to 0
for (var /** @type {?} */j = roundAt; j < digits.length; j++) {
digits[j] = 0;
}
} else {
// We rounded to zero so reset the parsedNumber
fractionLen = Math.max(0, fractionLen);
parsedNumber.integerLen = 1;
digits.length = Math.max(1, roundAt = fractionSize + 1);
digits[0] = 0;
for (var /** @type {?} */i = 1; i < roundAt; i++) digits[i] = 0;
}
if (digit >= 5) {
if (roundAt - 1 < 0) {
for (var /** @type {?} */k = 0; k > roundAt; k--) {
digits.unshift(0);
parsedNumber.integerLen++;
}
digits.unshift(1);
parsedNumber.integerLen++;
} else {
digits[roundAt - 1]++;
}
}
// Pad out with zeros to get the required fraction length
for (; fractionLen < Math.max(0, fractionSize); fractionLen++) digits.push(0);
// Do any carrying, e.g. a digit was rounded up to 10
var /** @type {?} */carry = digits.reduceRight(function (carry, d, i, digits) {
d = d + carry;
digits[i] = d % 10;
return Math.floor(d / 10);
}, 0);
if (carry) {
digits.unshift(carry);
parsedNumber.integerLen++;
}
}
/**
* \@internal
* @param {?} text
* @return {?}
*/
function parseIntAutoRadix(text) {
var /** @type {?} */result = parseInt(text);
if (isNaN(result)) {
throw new Error('Invalid integer literal when parsing ' + text);
}
return result;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} pipe
* @param {?} locale
* @param {?} value
* @param {?} style
* @param {?=} digits
* @param {?=} currency
* @param {?=} currencyAsSymbol
* @return {?}
*/
function formatNumber(pipe, locale, value, style, digits, currency, currencyAsSymbol) {
if (currency === void 0) {
currency = null;
}
if (currencyAsSymbol === void 0) {
currencyAsSymbol = false;
}
if (value == null) return null;
// Convert strings to numbers
value = typeof value === 'string' && !isNaN(+value - parseFloat(value)) ? +value : value;
if (typeof value !== 'number') {
throw invalidPipeArgumentError(pipe, value);
}
var /** @type {?} */minInt;
var /** @type {?} */minFraction;
var /** @type {?} */maxFraction;
if (style !== NumberFormatStyle.Currency) {
// rely on Intl default for currency
minInt = 1;
minFraction = 0;
maxFraction = 3;
}
if (digits) {
var /** @type {?} */parts = digits.match(NUMBER_FORMAT_REGEXP);
if (parts === null) {
throw new Error(digits + " is not a valid digit info for number pipes");
}
if (parts[1] != null) {
// min integer digits
minInt = parseIntAutoRadix(parts[1]);
}
if (parts[3] != null) {
// min fraction digits
minFraction = parseIntAutoRadix(parts[3]);
}
if (parts[5] != null) {
// max fraction digits
maxFraction = parseIntAutoRadix(parts[5]);
}
}
return NumberFormatter.format( /** @type {?} */value, locale, style, {
minimumIntegerDigits: minInt,
minimumFractionDigits: minFraction,
maximumFractionDigits: maxFraction,
currency: currency,
currencyAsSymbol: currencyAsSymbol
});
}
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number according to locale rules.
* \@howToUse `number_expression | number[:digitInfo]`
*
* Formats a number as text. Group sizing and separator and other locale-specific
* configurations are based on the active locale.
*
* where `expression` is a number:
* - `digitInfo` is a `string` which has a following format: <br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
* - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
* - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
* - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
*
* For more information on the acceptable range for each of these numbers and other
* details see your native internationalization library.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
*
* ### Example
*
* {\@example common/pipes/ts/number_pipe.ts region='DeprecatedNumberPipe'}
*
* \@stable
*/
var DeprecatedDecimalPipe = /** @class */function () {
function DeprecatedDecimalPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
DeprecatedDecimalPipe.prototype.transform = /**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
function (value, digits) {
return formatNumber(DeprecatedDecimalPipe, this._locale, value, NumberFormatStyle.Decimal, digits);
};
DeprecatedDecimalPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'number' }] }];
/** @nocollapse */
DeprecatedDecimalPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DeprecatedDecimalPipe;
}();
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as a percentage according to locale rules.
* \@howToUse `number_expression | percent[:digitInfo]`
*
* \@description
*
* Formats a number as percentage.
*
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
*
* ### Example
*
* {\@example common/pipes/ts/percent_pipe.ts region='DeprecatedPercentPipe'}
*
* \@stable
*/
var DeprecatedPercentPipe = /** @class */function () {
function DeprecatedPercentPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
DeprecatedPercentPipe.prototype.transform = /**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
function (value, digits) {
return formatNumber(DeprecatedPercentPipe, this._locale, value, NumberFormatStyle.Percent, digits);
};
DeprecatedPercentPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'percent' }] }];
/** @nocollapse */
DeprecatedPercentPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DeprecatedPercentPipe;
}();
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as currency using locale rules.
* \@howToUse `number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]`
* \@description
*
* Use `currency` to format a number as currency.
*
* - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
* as `USD` for the US dollar and `EUR` for the euro.
* - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
* - `true`: use symbol (e.g. `$`).
* - `false`(default): use code (e.g. `USD`).
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See [Browser Support](guide/browser-support) for details.
*
* ### Example
*
* {\@example common/pipes/ts/currency_pipe.ts region='DeprecatedCurrencyPipe'}
*
* \@stable
*/
var DeprecatedCurrencyPipe = /** @class */function () {
function DeprecatedCurrencyPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} currencyCode
* @param {?=} symbolDisplay
* @param {?=} digits
* @return {?}
*/
DeprecatedCurrencyPipe.prototype.transform = /**
* @param {?} value
* @param {?=} currencyCode
* @param {?=} symbolDisplay
* @param {?=} digits
* @return {?}
*/
function (value, currencyCode, symbolDisplay, digits) {
if (currencyCode === void 0) {
currencyCode = 'USD';
}
if (symbolDisplay === void 0) {
symbolDisplay = false;
}
return formatNumber(DeprecatedCurrencyPipe, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
};
DeprecatedCurrencyPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'currency' }] }];
/** @nocollapse */
DeprecatedCurrencyPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DeprecatedCurrencyPipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A collection of deprecated i18n pipes that require intl api
*
* @deprecated from v5
*/
var COMMON_DEPRECATED_I18N_PIPES = [DeprecatedDecimalPipe, DeprecatedPercentPipe, DeprecatedCurrencyPipe, DeprecatedDatePipe];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ObservableStrategy = /** @class */function () {
function ObservableStrategy() {}
/**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
ObservableStrategy.prototype.createSubscription = /**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
function (async, updateLatestValue) {
return async.subscribe({ next: updateLatestValue, error: function (e) {
throw e;
} });
};
/**
* @param {?} subscription
* @return {?}
*/
ObservableStrategy.prototype.dispose = /**
* @param {?} subscription
* @return {?}
*/
function (subscription) {
subscription.unsubscribe();
};
/**
* @param {?} subscription
* @return {?}
*/
ObservableStrategy.prototype.onDestroy = /**
* @param {?} subscription
* @return {?}
*/
function (subscription) {
subscription.unsubscribe();
};
return ObservableStrategy;
}();
var PromiseStrategy = /** @class */function () {
function PromiseStrategy() {}
/**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
PromiseStrategy.prototype.createSubscription = /**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
function (async, updateLatestValue) {
return async.then(updateLatestValue, function (e) {
throw e;
});
};
/**
* @param {?} subscription
* @return {?}
*/
PromiseStrategy.prototype.dispose = /**
* @param {?} subscription
* @return {?}
*/
function (subscription) {};
/**
* @param {?} subscription
* @return {?}
*/
PromiseStrategy.prototype.onDestroy = /**
* @param {?} subscription
* @return {?}
*/
function (subscription) {};
return PromiseStrategy;
}();
var _promiseStrategy = new PromiseStrategy();
var _observableStrategy = new ObservableStrategy();
/**
* \@ngModule CommonModule
* \@whatItDoes Unwraps a value from an asynchronous primitive.
* \@howToUse `observable_or_promise_expression | async`
* \@description
* The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
* emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
* changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
* potential memory leaks.
*
*
* ## Examples
*
* This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
* promise.
*
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
*
* It's also possible to use `async` with Observables. The example below binds the `time` Observable
* to the view. The Observable continuously updates the view with the current time.
*
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
*
* \@stable
*/
var AsyncPipe = /** @class */function () {
function AsyncPipe(_ref) {
this._ref = _ref;
this._latestValue = null;
this._latestReturnedValue = null;
this._subscription = null;
this._obj = null;
this._strategy = /** @type {?} */null;
}
/**
* @return {?}
*/
AsyncPipe.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this._subscription) {
this._dispose();
}
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype.transform = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
if (!this._obj) {
if (obj) {
this._subscribe(obj);
}
this._latestReturnedValue = this._latestValue;
return this._latestValue;
}
if (obj !== this._obj) {
this._dispose();
return this.transform( /** @type {?} */obj);
}
if (this._latestValue === this._latestReturnedValue) {
return this._latestReturnedValue;
}
this._latestReturnedValue = this._latestValue;
return _angular_core.WrappedValue.wrap(this._latestValue);
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype._subscribe = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
var _this = this;
this._obj = obj;
this._strategy = this._selectStrategy(obj);
this._subscription = this._strategy.createSubscription(obj, function (value) {
return _this._updateLatestValue(obj, value);
});
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype._selectStrategy = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
if (_angular_core.ɵisPromise(obj)) {
return _promiseStrategy;
}
if (_angular_core.ɵisObservable(obj)) {
return _observableStrategy;
}
throw invalidPipeArgumentError(AsyncPipe, obj);
};
/**
* @return {?}
*/
AsyncPipe.prototype._dispose = /**
* @return {?}
*/
function () {
this._strategy.dispose( /** @type {?} */this._subscription);
this._latestValue = null;
this._latestReturnedValue = null;
this._subscription = null;
this._obj = null;
};
/**
* @param {?} async
* @param {?} value
* @return {?}
*/
AsyncPipe.prototype._updateLatestValue = /**
* @param {?} async
* @param {?} value
* @return {?}
*/
function (async, value) {
if (async === this._obj) {
this._latestValue = value;
this._ref.markForCheck();
}
};
AsyncPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'async', pure: false }] }];
/** @nocollapse */
AsyncPipe.ctorParameters = function () {
return [{ type: _angular_core.ChangeDetectorRef }];
};
return AsyncPipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Transforms text to lowercase.
*
* {\@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe' }
*
* \@stable
*/
var LowerCasePipe = /** @class */function () {
function LowerCasePipe() {}
/**
* @param {?} value
* @return {?}
*/
LowerCasePipe.prototype.transform = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (!value) return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(LowerCasePipe, value);
}
return value.toLowerCase();
};
LowerCasePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'lowercase' }] }];
/** @nocollapse */
LowerCasePipe.ctorParameters = function () {
return [];
};
return LowerCasePipe;
}();
/**
* Helper method to transform a single word to titlecase.
*
* \@stable
* @param {?} word
* @return {?}
*/
function titleCaseWord(word) {
if (!word) return word;
return word[0].toUpperCase() + word.substr(1).toLowerCase();
}
/**
* Transforms text to titlecase.
*
* \@stable
*/
var TitleCasePipe = /** @class */function () {
function TitleCasePipe() {}
/**
* @param {?} value
* @return {?}
*/
TitleCasePipe.prototype.transform = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (!value) return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(TitleCasePipe, value);
}
return value.split(/\b/g).map(function (word) {
return titleCaseWord(word);
}).join('');
};
TitleCasePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'titlecase' }] }];
/** @nocollapse */
TitleCasePipe.ctorParameters = function () {
return [];
};
return TitleCasePipe;
}();
/**
* Transforms text to uppercase.
*
* \@stable
*/
var UpperCasePipe = /** @class */function () {
function UpperCasePipe() {}
/**
* @param {?} value
* @return {?}
*/
UpperCasePipe.prototype.transform = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (!value) return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(UpperCasePipe, value);
}
return value.toUpperCase();
};
UpperCasePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'uppercase' }] }];
/** @nocollapse */
UpperCasePipe.ctorParameters = function () {
return [];
};
return UpperCasePipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _INTERPOLATION_REGEXP = /#/g;
/**
* \@ngModule CommonModule
* \@whatItDoes Maps a value to a string that pluralizes the value according to locale rules.
* \@howToUse `expression | i18nPlural:mapping[:locale]`
* \@description
*
* Where:
* - `expression` is a number.
* - `mapping` is an object that mimics the ICU format, see
* http://userguide.icu-project.org/formatparse/messages
* - `locale` is a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
* default)
*
* ## Example
*
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
*
* \@experimental
*/
var I18nPluralPipe = /** @class */function () {
function I18nPluralPipe(_localization) {
this._localization = _localization;
}
/**
* @param {?} value
* @param {?} pluralMap
* @param {?=} locale
* @return {?}
*/
I18nPluralPipe.prototype.transform = /**
* @param {?} value
* @param {?} pluralMap
* @param {?=} locale
* @return {?}
*/
function (value, pluralMap, locale) {
if (value == null) return '';
if (typeof pluralMap !== 'object' || pluralMap === null) {
throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
}
var /** @type {?} */key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
};
I18nPluralPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'i18nPlural', pure: true }] }];
/** @nocollapse */
I18nPluralPipe.ctorParameters = function () {
return [{ type: NgLocalization }];
};
return I18nPluralPipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Generic selector that displays the string that matches the current value.
* \@howToUse `expression | i18nSelect:mapping`
* \@description
*
* Where `mapping` is an object that indicates the text that should be displayed
* for different values of the provided `expression`.
* If none of the keys of the mapping match the value of the `expression`, then the content
* of the `other` key is returned when present, otherwise an empty string is returned.
*
* ## Example
*
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
*
* \@experimental
*/
var I18nSelectPipe = /** @class */function () {
function I18nSelectPipe() {}
/**
* @param {?} value
* @param {?} mapping
* @return {?}
*/
I18nSelectPipe.prototype.transform = /**
* @param {?} value
* @param {?} mapping
* @return {?}
*/
function (value, mapping) {
if (value == null) return '';
if (typeof mapping !== 'object' || typeof value !== 'string') {
throw invalidPipeArgumentError(I18nSelectPipe, mapping);
}
if (mapping.hasOwnProperty(value)) {
return mapping[value];
}
if (mapping.hasOwnProperty('other')) {
return mapping['other'];
}
return '';
};
I18nSelectPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'i18nSelect', pure: true }] }];
/** @nocollapse */
I18nSelectPipe.ctorParameters = function () {
return [];
};
return I18nSelectPipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Converts value into JSON string.
* \@howToUse `expression | json`
* \@description
*
* Converts value into string using `JSON.stringify`. Useful for debugging.
*
* ### Example
* {\@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
*
* \@stable
*/
var JsonPipe = /** @class */function () {
function JsonPipe() {}
/**
* @param {?} value
* @return {?}
*/
JsonPipe.prototype.transform = /**
* @param {?} value
* @return {?}
*/
function (value) {
return JSON.stringify(value, null, 2);
};
JsonPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'json', pure: false }] }];
/** @nocollapse */
JsonPipe.ctorParameters = function () {
return [];
};
return JsonPipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number according to locale rules.
* \@howToUse `number_expression | number[:digitInfo[:locale]]`
*
* Formats a number as text. Group sizing and separator and other locale-specific
* configurations are based on the active locale.
*
* where `expression` is a number:
* - `digitInfo` is a `string` which has a following format: <br>
* <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
* - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
* - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
* - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
* - `locale` is a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
* default)
*
* For more information on the acceptable range for each of these numbers and other
* details see your native internationalization library.
*
* ### Example
*
* {\@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
*
* \@stable
*/
var DecimalPipe = /** @class */function () {
function DecimalPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
DecimalPipe.prototype.transform = /**
* @param {?} value
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
function (value, digits, locale) {
if (isEmpty(value)) return null;
locale = locale || this._locale;
var _a = formatNumber$1(value, locale, NumberFormatStyle.Decimal, digits),
str = _a.str,
error = _a.error;
if (error) {
throw invalidPipeArgumentError(DecimalPipe, error);
}
return str;
};
DecimalPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'number' }] }];
/** @nocollapse */
DecimalPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return DecimalPipe;
}();
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as a percentage according to locale rules.
* \@howToUse `number_expression | percent[:digitInfo[:locale]]`
*
* \@description
*
* Formats a number as percentage.
*
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
* - `locale` is a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
* default)
*
* ### Example
*
* {\@example common/pipes/ts/percent_pipe.ts region='PercentPipe'}
*
* \@stable
*/
var PercentPipe = /** @class */function () {
function PercentPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
PercentPipe.prototype.transform = /**
* @param {?} value
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
function (value, digits, locale) {
if (isEmpty(value)) return null;
locale = locale || this._locale;
var _a = formatNumber$1(value, locale, NumberFormatStyle.Percent, digits),
str = _a.str,
error = _a.error;
if (error) {
throw invalidPipeArgumentError(PercentPipe, error);
}
return str;
};
PercentPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'percent' }] }];
/** @nocollapse */
PercentPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return PercentPipe;
}();
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as currency using locale rules.
* \@howToUse `number_expression | currency[:currencyCode[:display[:digitInfo[:locale]]]]`
* \@description
*
* Use `currency` to format a number as currency.
*
* - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
* as `USD` for the US dollar and `EUR` for the euro.
* - `display` indicates whether to show the currency symbol or the code.
* - `code`: use code (e.g. `USD`).
* - `symbol`(default): use symbol (e.g. `$`).
* - `symbol-narrow`: some countries have two symbols for their currency, one regular and one
* narrow (e.g. the canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`).
* - boolean (deprecated from v5): `true` for symbol and false for `code`
* If there is no narrow symbol for the chosen currency, the regular symbol will be used.
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
* - `locale` is a `string` defining the locale to use (uses the current {\@link LOCALE_ID} by
* default)
*
* ### Example
*
* {\@example common/pipes/ts/currency_pipe.ts region='CurrencyPipe'}
*
* \@stable
*/
var CurrencyPipe = /** @class */function () {
function CurrencyPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} currencyCode
* @param {?=} display
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
CurrencyPipe.prototype.transform = /**
* @param {?} value
* @param {?=} currencyCode
* @param {?=} display
* @param {?=} digits
* @param {?=} locale
* @return {?}
*/
function (value, currencyCode, display, digits, locale) {
if (display === void 0) {
display = 'symbol';
}
if (isEmpty(value)) return null;
locale = locale || this._locale;
if (typeof display === 'boolean') {
if ( /** @type {?} */console && /** @type {?} */console.warn) {
console.warn("Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are \"code\", \"symbol\" or \"symbol-narrow\".");
}
display = display ? 'symbol' : 'code';
}
var /** @type {?} */currency = currencyCode || 'USD';
if (display !== 'code') {
currency = findCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow');
}
var _a = formatNumber$1(value, locale, NumberFormatStyle.Currency, digits, currency),
str = _a.str,
error = _a.error;
if (error) {
throw invalidPipeArgumentError(CurrencyPipe, error);
}
return str;
};
CurrencyPipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'currency' }] }];
/** @nocollapse */
CurrencyPipe.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.LOCALE_ID] }] }];
};
return CurrencyPipe;
}();
/**
* @param {?} value
* @return {?}
*/
function isEmpty(value) {
return value == null || value === '' || value !== value;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Creates a new List or String containing a subset (slice) of the elements.
* \@howToUse `array_or_string_expression | slice:start[:end]`
* \@description
*
* Where the input expression is a `List` or `String`, and:
* - `start`: The starting index of the subset to return.
* - **a positive integer**: return the item at `start` index and all items after
* in the list or string expression.
* - **a negative integer**: return the item at `start` index from the end and all items after
* in the list or string expression.
* - **if positive and greater than the size of the expression**: return an empty list or string.
* - **if negative and greater than the size of the expression**: return entire list or string.
* - `end`: The ending index of the subset to return.
* - **omitted**: return all items until the end.
* - **if positive**: return all items before `end` index of the list or string.
* - **if negative**: return all items before `end` index from the end of the list or string.
*
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
* and `String.prototype.slice()`.
*
* When operating on a [List], the returned list is always a copy even when all
* the elements are being returned.
*
* When operating on a blank value, the pipe returns the blank value.
*
* ## List Example
*
* This `ngFor` example:
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
*
* produces the following:
*
* <li>b</li>
* <li>c</li>
*
* ## String Examples
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
*
* \@stable
*/
var SlicePipe = /** @class */function () {
function SlicePipe() {}
/**
* @param {?} value
* @param {?} start
* @param {?=} end
* @return {?}
*/
SlicePipe.prototype.transform = /**
* @param {?} value
* @param {?} start
* @param {?=} end
* @return {?}
*/
function (value, start, end) {
if (value == null) return value;
if (!this.supports(value)) {
throw invalidPipeArgumentError(SlicePipe, value);
}
return value.slice(start, end);
};
/**
* @param {?} obj
* @return {?}
*/
SlicePipe.prototype.supports = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
return typeof obj === 'string' || Array.isArray(obj);
};
SlicePipe.decorators = [{ type: _angular_core.Pipe, args: [{ name: 'slice', pure: false }] }];
/** @nocollapse */
SlicePipe.ctorParameters = function () {
return [];
};
return SlicePipe;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* This module provides a set of common Pipes.
*/
/**
* A collection of Angular pipes that are likely to be used in each and every application.
*/
var COMMON_PIPES = [AsyncPipe, UpperCasePipe, LowerCasePipe, JsonPipe, SlicePipe, DecimalPipe, PercentPipe, TitleCasePipe, CurrencyPipe, DatePipe, I18nPluralPipe, I18nSelectPipe];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* The module that includes all the basic Angular directives like {\@link NgIf}, {\@link NgForOf}, ...
*
* \@stable
*/
var CommonModule = /** @class */function () {
function CommonModule() {}
CommonModule.decorators = [{ type: _angular_core.NgModule, args: [{
declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
exports: [COMMON_DIRECTIVES, COMMON_PIPES],
providers: [{ provide: NgLocalization, useClass: NgLocaleLocalization }]
}] }];
/** @nocollapse */
CommonModule.ctorParameters = function () {
return [];
};
return CommonModule;
}();
var ɵ0 = getPluralCase;
/**
* A module that contains the deprecated i18n pipes.
*
* @deprecated from v5
*/
var DeprecatedI18NPipesModule = /** @class */function () {
function DeprecatedI18NPipesModule() {}
DeprecatedI18NPipesModule.decorators = [{ type: _angular_core.NgModule, args: [{
declarations: [COMMON_DEPRECATED_I18N_PIPES],
exports: [COMMON_DEPRECATED_I18N_PIPES],
providers: [{ provide: DEPRECATED_PLURAL_FN, useValue: ɵ0 }]
}] }];
/** @nocollapse */
DeprecatedI18NPipesModule.ctorParameters = function () {
return [];
};
return DeprecatedI18NPipesModule;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A DI Token representing the main rendering context. In a browser this is the DOM Document.
*
* Note: Document might not be available in the Application Context when Application and Rendering
* Contexts are not the same (e.g. when running the application into a Web Worker).
*
* \@stable
*/
var DOCUMENT = new _angular_core.InjectionToken('DocumentToken');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var PLATFORM_BROWSER_ID = 'browser';
var PLATFORM_SERVER_ID = 'server';
var PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
var PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
/**
* Returns whether a platform id represents a browser platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformBrowser(platformId) {
return platformId === PLATFORM_BROWSER_ID;
}
/**
* Returns whether a platform id represents a server platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformServer(platformId) {
return platformId === PLATFORM_SERVER_ID;
}
/**
* Returns whether a platform id represents a web worker app platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformWorkerApp(platformId) {
return platformId === PLATFORM_WORKER_APP_ID;
}
/**
* Returns whether a platform id represents a web worker UI platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformWorkerUi(platformId) {
return platformId === PLATFORM_WORKER_UI_ID;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* \@stable
*/
var VERSION = new _angular_core.Version('5.1.0');
exports.NgLocaleLocalization = NgLocaleLocalization;
exports.NgLocalization = NgLocalization;
exports.registerLocaleData = registerLocaleData;
exports.Plural = Plural;
exports.NumberFormatStyle = NumberFormatStyle;
exports.FormStyle = FormStyle;
exports.TranslationWidth = TranslationWidth;
exports.FormatWidth = FormatWidth;
exports.NumberSymbol = NumberSymbol;
exports.WeekDay = WeekDay;
exports.getLocaleDayPeriods = getLocaleDayPeriods;
exports.getLocaleDayNames = getLocaleDayNames;
exports.getLocaleMonthNames = getLocaleMonthNames;
exports.getLocaleId = getLocaleId;
exports.getLocaleEraNames = getLocaleEraNames;
exports.getLocaleWeekEndRange = getLocaleWeekEndRange;
exports.getLocaleFirstDayOfWeek = getLocaleFirstDayOfWeek;
exports.getLocaleDateFormat = getLocaleDateFormat;
exports.getLocaleDateTimeFormat = getLocaleDateTimeFormat;
exports.getLocaleExtraDayPeriodRules = getLocaleExtraDayPeriodRules;
exports.getLocaleExtraDayPeriods = getLocaleExtraDayPeriods;
exports.getLocalePluralCase = getLocalePluralCase;
exports.getLocaleTimeFormat = getLocaleTimeFormat;
exports.getLocaleNumberSymbol = getLocaleNumberSymbol;
exports.getLocaleNumberFormat = getLocaleNumberFormat;
exports.getLocaleCurrencyName = getLocaleCurrencyName;
exports.getLocaleCurrencySymbol = getLocaleCurrencySymbol;
exports.CURRENCIES = CURRENCIES;
exports.ɵparseCookieValue = parseCookieValue;
exports.CommonModule = CommonModule;
exports.DeprecatedI18NPipesModule = DeprecatedI18NPipesModule;
exports.NgClass = NgClass;
exports.NgForOf = NgForOf;
exports.NgForOfContext = NgForOfContext;
exports.NgIf = NgIf;
exports.NgIfContext = NgIfContext;
exports.NgPlural = NgPlural;
exports.NgPluralCase = NgPluralCase;
exports.NgStyle = NgStyle;
exports.NgSwitch = NgSwitch;
exports.NgSwitchCase = NgSwitchCase;
exports.NgSwitchDefault = NgSwitchDefault;
exports.NgTemplateOutlet = NgTemplateOutlet;
exports.NgComponentOutlet = NgComponentOutlet;
exports.DOCUMENT = DOCUMENT;
exports.AsyncPipe = AsyncPipe;
exports.DatePipe = DatePipe;
exports.I18nPluralPipe = I18nPluralPipe;
exports.I18nSelectPipe = I18nSelectPipe;
exports.JsonPipe = JsonPipe;
exports.LowerCasePipe = LowerCasePipe;
exports.CurrencyPipe = CurrencyPipe;
exports.DecimalPipe = DecimalPipe;
exports.PercentPipe = PercentPipe;
exports.SlicePipe = SlicePipe;
exports.UpperCasePipe = UpperCasePipe;
exports.TitleCasePipe = TitleCasePipe;
exports.DeprecatedDatePipe = DeprecatedDatePipe;
exports.DeprecatedCurrencyPipe = DeprecatedCurrencyPipe;
exports.DeprecatedDecimalPipe = DeprecatedDecimalPipe;
exports.DeprecatedPercentPipe = DeprecatedPercentPipe;
exports.ɵPLATFORM_BROWSER_ID = PLATFORM_BROWSER_ID;
exports.ɵPLATFORM_SERVER_ID = PLATFORM_SERVER_ID;
exports.ɵPLATFORM_WORKER_APP_ID = PLATFORM_WORKER_APP_ID;
exports.ɵPLATFORM_WORKER_UI_ID = PLATFORM_WORKER_UI_ID;
exports.isPlatformBrowser = isPlatformBrowser;
exports.isPlatformServer = isPlatformServer;
exports.isPlatformWorkerApp = isPlatformWorkerApp;
exports.isPlatformWorkerUi = isPlatformWorkerUi;
exports.VERSION = VERSION;
exports.PlatformLocation = PlatformLocation;
exports.LOCATION_INITIALIZED = LOCATION_INITIALIZED;
exports.LocationStrategy = LocationStrategy;
exports.APP_BASE_HREF = APP_BASE_HREF;
exports.HashLocationStrategy = HashLocationStrategy;
exports.PathLocationStrategy = PathLocationStrategy;
exports.Location = Location;
exports.ɵe = COMMON_DIRECTIVES;
exports.ɵd = findLocaleData;
exports.ɵa = DEPRECATED_PLURAL_FN;
exports.ɵb = getPluralCase;
exports.ɵg = COMMON_DEPRECATED_I18N_PIPES;
exports.ɵf = COMMON_PIPES;
Object.defineProperty(exports, '__esModule', { value: true });
});
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) : 'function' === 'function' && true ? System.registerDynamic('@angular/platform-browser/bundles/platform-browser.umd.js', ['@angular/common', '@angular/core'], false, function ($__require, $__exports, $__module) {
return factory.call($__exports, $__exports, $__require('@angular/common'), $__require('@angular/core'));
}) : factory((global.ng = global.ng || {}, global.ng.platformBrowser = {}), global.ng.common, global.ng.core);
})(this, function (exports, _angular_common, _angular_core) {
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _DOM = /** @type {?} */null;
/**
* @return {?}
*/
function getDOM() {
return _DOM;
}
/**
* @param {?} adapter
* @return {?}
*/
/**
* @param {?} adapter
* @return {?}
*/
function setRootDomAdapter(adapter) {
if (!_DOM) {
_DOM = adapter;
}
}
/**
* Provides DOM operations in an environment-agnostic way.
*
* \@security Tread carefully! Interacting with the DOM directly is dangerous and
* can introduce XSS risks.
* @abstract
*/
var DomAdapter = /** @class */function () {
function DomAdapter() {
this.resourceLoaderType = /** @type {?} */null;
}
Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
/**
* Maps attribute names to their corresponding property names for cases
* where attribute name doesn't match property name.
*/
get: /**
* Maps attribute names to their corresponding property names for cases
* where attribute name doesn't match property name.
* @return {?}
*/
function () {
return this._attrToPropMap;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this._attrToPropMap = value;
},
enumerable: true,
configurable: true
});
return DomAdapter;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Provides DOM operations in any browser environment.
*
* \@security Tread carefully! Interacting with the DOM directly is dangerous and
* can introduce XSS risks.
* @abstract
*/
var GenericBrowserDomAdapter = /** @class */function (_super) {
__extends(GenericBrowserDomAdapter, _super);
function GenericBrowserDomAdapter() {
var _this = _super.call(this) || this;
_this._animationPrefix = null;
_this._transitionEnd = null;
try {
var /** @type {?} */element_1 = _this.createElement('div', document);
if (_this.getStyle(element_1, 'animationName') != null) {
_this._animationPrefix = '';
} else {
var /** @type {?} */domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
for (var /** @type {?} */i = 0; i < domPrefixes.length; i++) {
if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
_this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
break;
}
}
}
var /** @type {?} */transEndEventNames_1 = {
WebkitTransition: 'webkitTransitionEnd',
MozTransition: 'transitionend',
OTransition: 'oTransitionEnd otransitionend',
transition: 'transitionend'
};
Object.keys(transEndEventNames_1).forEach(function (key) {
if (_this.getStyle(element_1, key) != null) {
_this._transitionEnd = transEndEventNames_1[key];
}
});
} catch ( /** @type {?} */e) {
_this._animationPrefix = null;
_this._transitionEnd = null;
}
return _this;
}
/**
* @param {?} el
* @return {?}
*/
GenericBrowserDomAdapter.prototype.getDistributedNodes = /**
* @param {?} el
* @return {?}
*/
function (el) {
return (/** @type {?} */el.getDistributedNodes()
);
};
/**
* @param {?} el
* @param {?} baseUrl
* @param {?} href
* @return {?}
*/
GenericBrowserDomAdapter.prototype.resolveAndSetHref = /**
* @param {?} el
* @param {?} baseUrl
* @param {?} href
* @return {?}
*/
function (el, baseUrl, href) {
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
};
/**
* @return {?}
*/
GenericBrowserDomAdapter.prototype.supportsDOMEvents = /**
* @return {?}
*/
function () {
return true;
};
/**
* @return {?}
*/
GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = /**
* @return {?}
*/
function () {
return typeof /** @type {?} */document.body.createShadowRoot === 'function';
};
/**
* @return {?}
*/
GenericBrowserDomAdapter.prototype.getAnimationPrefix = /**
* @return {?}
*/
function () {
return this._animationPrefix ? this._animationPrefix : '';
};
/**
* @return {?}
*/
GenericBrowserDomAdapter.prototype.getTransitionEnd = /**
* @return {?}
*/
function () {
return this._transitionEnd ? this._transitionEnd : '';
};
/**
* @return {?}
*/
GenericBrowserDomAdapter.prototype.supportsAnimation = /**
* @return {?}
*/
function () {
return this._animationPrefix != null && this._transitionEnd != null;
};
return GenericBrowserDomAdapter;
}(DomAdapter);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _attrToPropMap = {
'class': 'className',
'innerHtml': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex'
};
var DOM_KEY_LOCATION_NUMPAD = 3;
// Map to convert some key or keyIdentifier values to what will be returned by getEventKey
var _keyMap = {
// The following values are here for cross-browser compatibility and to match the W3C standard
// cf http://www.w3.org/TR/DOM-Level-3-Events-key/
'\b': 'Backspace',
'\t': 'Tab',
'\x7F': 'Delete',
'\x1B': 'Escape',
'Del': 'Delete',
'Esc': 'Escape',
'Left': 'ArrowLeft',
'Right': 'ArrowRight',
'Up': 'ArrowUp',
'Down': 'ArrowDown',
'Menu': 'ContextMenu',
'Scroll': 'ScrollLock',
'Win': 'OS'
};
// There is a bug in Chrome for numeric keypad keys:
// https://code.google.com/p/chromium/issues/detail?id=155654
// 1, 2, 3 ... are reported as A, B, C ...
var _chromeNumKeyPadMap = {
'A': '1',
'B': '2',
'C': '3',
'D': '4',
'E': '5',
'F': '6',
'G': '7',
'H': '8',
'I': '9',
'J': '*',
'K': '+',
'M': '-',
'N': '.',
'O': '/',
'\x60': '0',
'\x90': 'NumLock'
};
var nodeContains;
if (_angular_core.ɵglobal['Node']) {
nodeContains = _angular_core.ɵglobal['Node'].prototype.contains || function (node) {
return !!(this.compareDocumentPosition(node) & 16);
};
}
/**
* A `DomAdapter` powered by full browser DOM APIs.
*
* \@security Tread carefully! Interacting with the DOM directly is dangerous and
* can introduce XSS risks.
*/
var BrowserDomAdapter = /** @class */function (_super) {
__extends(BrowserDomAdapter, _super);
function BrowserDomAdapter() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} templateHtml
* @return {?}
*/
BrowserDomAdapter.prototype.parse = /**
* @param {?} templateHtml
* @return {?}
*/
function (templateHtml) {
throw new Error('parse not implemented');
};
/**
* @return {?}
*/
BrowserDomAdapter.makeCurrent = /**
* @return {?}
*/
function () {
setRootDomAdapter(new BrowserDomAdapter());
};
/**
* @param {?} element
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.hasProperty = /**
* @param {?} element
* @param {?} name
* @return {?}
*/
function (element, name) {
return name in element;
};
/**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setProperty = /**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
function (el, name, value) {
/** @type {?} */el[name] = value;
};
/**
* @param {?} el
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getProperty = /**
* @param {?} el
* @param {?} name
* @return {?}
*/
function (el, name) {
return (/** @type {?} */el[name]
);
};
/**
* @param {?} el
* @param {?} methodName
* @param {?} args
* @return {?}
*/
BrowserDomAdapter.prototype.invoke = /**
* @param {?} el
* @param {?} methodName
* @param {?} args
* @return {?}
*/
function (el, methodName, args) {
(_a = /** @type {?} */el)[methodName].apply(_a, args);
var _a;
};
// TODO(tbosch): move this into a separate environment class once we have it
/**
* @param {?} error
* @return {?}
*/
BrowserDomAdapter.prototype.logError = /**
* @param {?} error
* @return {?}
*/
function (error) {
if (window.console) {
if (console.error) {
console.error(error);
} else {
console.log(error);
}
}
};
/**
* @param {?} error
* @return {?}
*/
BrowserDomAdapter.prototype.log = /**
* @param {?} error
* @return {?}
*/
function (error) {
if (window.console) {
window.console.log && window.console.log(error);
}
};
/**
* @param {?} error
* @return {?}
*/
BrowserDomAdapter.prototype.logGroup = /**
* @param {?} error
* @return {?}
*/
function (error) {
if (window.console) {
window.console.group && window.console.group(error);
}
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.logGroupEnd = /**
* @return {?}
*/
function () {
if (window.console) {
window.console.groupEnd && window.console.groupEnd();
}
};
Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
get: /**
* @return {?}
*/
function () {
return _attrToPropMap;
},
enumerable: true,
configurable: true
});
/**
* @param {?} nodeA
* @param {?} nodeB
* @return {?}
*/
BrowserDomAdapter.prototype.contains = /**
* @param {?} nodeA
* @param {?} nodeB
* @return {?}
*/
function (nodeA, nodeB) {
return nodeContains.call(nodeA, nodeB);
};
/**
* @param {?} el
* @param {?} selector
* @return {?}
*/
BrowserDomAdapter.prototype.querySelector = /**
* @param {?} el
* @param {?} selector
* @return {?}
*/
function (el, selector) {
return el.querySelector(selector);
};
/**
* @param {?} el
* @param {?} selector
* @return {?}
*/
BrowserDomAdapter.prototype.querySelectorAll = /**
* @param {?} el
* @param {?} selector
* @return {?}
*/
function (el, selector) {
return el.querySelectorAll(selector);
};
/**
* @param {?} el
* @param {?} evt
* @param {?} listener
* @return {?}
*/
BrowserDomAdapter.prototype.on = /**
* @param {?} el
* @param {?} evt
* @param {?} listener
* @return {?}
*/
function (el, evt, listener) {
el.addEventListener(evt, listener, false);
};
/**
* @param {?} el
* @param {?} evt
* @param {?} listener
* @return {?}
*/
BrowserDomAdapter.prototype.onAndCancel = /**
* @param {?} el
* @param {?} evt
* @param {?} listener
* @return {?}
*/
function (el, evt, listener) {
el.addEventListener(evt, listener, false);
// Needed to follow Dart's subscription semantic, until fix of
// https://code.google.com/p/dart/issues/detail?id=17406
return function () {
el.removeEventListener(evt, listener, false);
};
};
/**
* @param {?} el
* @param {?} evt
* @return {?}
*/
BrowserDomAdapter.prototype.dispatchEvent = /**
* @param {?} el
* @param {?} evt
* @return {?}
*/
function (el, evt) {
el.dispatchEvent(evt);
};
/**
* @param {?} eventType
* @return {?}
*/
BrowserDomAdapter.prototype.createMouseEvent = /**
* @param {?} eventType
* @return {?}
*/
function (eventType) {
var /** @type {?} */evt = this.getDefaultDocument().createEvent('MouseEvent');
evt.initEvent(eventType, true, true);
return evt;
};
/**
* @param {?} eventType
* @return {?}
*/
BrowserDomAdapter.prototype.createEvent = /**
* @param {?} eventType
* @return {?}
*/
function (eventType) {
var /** @type {?} */evt = this.getDefaultDocument().createEvent('Event');
evt.initEvent(eventType, true, true);
return evt;
};
/**
* @param {?} evt
* @return {?}
*/
BrowserDomAdapter.prototype.preventDefault = /**
* @param {?} evt
* @return {?}
*/
function (evt) {
evt.preventDefault();
evt.returnValue = false;
};
/**
* @param {?} evt
* @return {?}
*/
BrowserDomAdapter.prototype.isPrevented = /**
* @param {?} evt
* @return {?}
*/
function (evt) {
return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getInnerHTML = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.innerHTML;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getTemplateContent = /**
* @param {?} el
* @return {?}
*/
function (el) {
return 'content' in el && this.isTemplateElement(el) ? /** @type {?} */el.content : null;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getOuterHTML = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.outerHTML;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.nodeName = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nodeName;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.nodeValue = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nodeValue;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.type = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.type;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.content = /**
* @param {?} node
* @return {?}
*/
function (node) {
if (this.hasProperty(node, 'content')) {
return (/** @type {?} */node.content
);
} else {
return node;
}
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.firstChild = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.firstChild;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.nextSibling = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.nextSibling;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.parentElement = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.parentNode;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.childNodes = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.childNodes;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.childNodesAsList = /**
* @param {?} el
* @return {?}
*/
function (el) {
var /** @type {?} */childNodes = el.childNodes;
var /** @type {?} */res = new Array(childNodes.length);
for (var /** @type {?} */i = 0; i < childNodes.length; i++) {
res[i] = childNodes[i];
}
return res;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.clearNodes = /**
* @param {?} el
* @return {?}
*/
function (el) {
while (el.firstChild) {
el.removeChild(el.firstChild);
}
};
/**
* @param {?} el
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.appendChild = /**
* @param {?} el
* @param {?} node
* @return {?}
*/
function (el, node) {
el.appendChild(node);
};
/**
* @param {?} el
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.removeChild = /**
* @param {?} el
* @param {?} node
* @return {?}
*/
function (el, node) {
el.removeChild(node);
};
/**
* @param {?} el
* @param {?} newChild
* @param {?} oldChild
* @return {?}
*/
BrowserDomAdapter.prototype.replaceChild = /**
* @param {?} el
* @param {?} newChild
* @param {?} oldChild
* @return {?}
*/
function (el, newChild, oldChild) {
el.replaceChild(newChild, oldChild);
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.remove = /**
* @param {?} node
* @return {?}
*/
function (node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
return node;
};
/**
* @param {?} parent
* @param {?} ref
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.insertBefore = /**
* @param {?} parent
* @param {?} ref
* @param {?} node
* @return {?}
*/
function (parent, ref, node) {
parent.insertBefore(node, ref);
};
/**
* @param {?} parent
* @param {?} ref
* @param {?} nodes
* @return {?}
*/
BrowserDomAdapter.prototype.insertAllBefore = /**
* @param {?} parent
* @param {?} ref
* @param {?} nodes
* @return {?}
*/
function (parent, ref, nodes) {
nodes.forEach(function (n) {
return parent.insertBefore(n, ref);
});
};
/**
* @param {?} parent
* @param {?} ref
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.insertAfter = /**
* @param {?} parent
* @param {?} ref
* @param {?} node
* @return {?}
*/
function (parent, ref, node) {
parent.insertBefore(node, ref.nextSibling);
};
/**
* @param {?} el
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setInnerHTML = /**
* @param {?} el
* @param {?} value
* @return {?}
*/
function (el, value) {
el.innerHTML = value;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getText = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.textContent;
};
/**
* @param {?} el
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setText = /**
* @param {?} el
* @param {?} value
* @return {?}
*/
function (el, value) {
el.textContent = value;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getValue = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.value;
};
/**
* @param {?} el
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setValue = /**
* @param {?} el
* @param {?} value
* @return {?}
*/
function (el, value) {
el.value = value;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getChecked = /**
* @param {?} el
* @return {?}
*/
function (el) {
return el.checked;
};
/**
* @param {?} el
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setChecked = /**
* @param {?} el
* @param {?} value
* @return {?}
*/
function (el, value) {
el.checked = value;
};
/**
* @param {?} text
* @return {?}
*/
BrowserDomAdapter.prototype.createComment = /**
* @param {?} text
* @return {?}
*/
function (text) {
return this.getDefaultDocument().createComment(text);
};
/**
* @param {?} html
* @return {?}
*/
BrowserDomAdapter.prototype.createTemplate = /**
* @param {?} html
* @return {?}
*/
function (html) {
var /** @type {?} */t = this.getDefaultDocument().createElement('template');
t.innerHTML = html;
return t;
};
/**
* @param {?} tagName
* @param {?=} doc
* @return {?}
*/
BrowserDomAdapter.prototype.createElement = /**
* @param {?} tagName
* @param {?=} doc
* @return {?}
*/
function (tagName, doc) {
doc = doc || this.getDefaultDocument();
return doc.createElement(tagName);
};
/**
* @param {?} ns
* @param {?} tagName
* @param {?=} doc
* @return {?}
*/
BrowserDomAdapter.prototype.createElementNS = /**
* @param {?} ns
* @param {?} tagName
* @param {?=} doc
* @return {?}
*/
function (ns, tagName, doc) {
doc = doc || this.getDefaultDocument();
return doc.createElementNS(ns, tagName);
};
/**
* @param {?} text
* @param {?=} doc
* @return {?}
*/
BrowserDomAdapter.prototype.createTextNode = /**
* @param {?} text
* @param {?=} doc
* @return {?}
*/
function (text, doc) {
doc = doc || this.getDefaultDocument();
return doc.createTextNode(text);
};
/**
* @param {?} attrName
* @param {?} attrValue
* @param {?=} doc
* @return {?}
*/
BrowserDomAdapter.prototype.createScriptTag = /**
* @param {?} attrName
* @param {?} attrValue
* @param {?=} doc
* @return {?}
*/
function (attrName, attrValue, doc) {
doc = doc || this.getDefaultDocument();
var /** @type {?} */el = /** @type {?} */doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
};
/**
* @param {?} css
* @param {?=} doc
* @return {?}
*/
BrowserDomAdapter.prototype.createStyleElement = /**
* @param {?} css
* @param {?=} doc
* @return {?}
*/
function (css, doc) {
doc = doc || this.getDefaultDocument();
var /** @type {?} */style = /** @type {?} */doc.createElement('style');
this.appendChild(style, this.createTextNode(css, doc));
return style;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.createShadowRoot = /**
* @param {?} el
* @return {?}
*/
function (el) {
return (/** @type {?} */el.createShadowRoot()
);
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getShadowRoot = /**
* @param {?} el
* @return {?}
*/
function (el) {
return (/** @type {?} */el.shadowRoot
);
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getHost = /**
* @param {?} el
* @return {?}
*/
function (el) {
return (/** @type {?} */el.host
);
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.clone = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.cloneNode(true);
};
/**
* @param {?} element
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getElementsByClassName = /**
* @param {?} element
* @param {?} name
* @return {?}
*/
function (element, name) {
return element.getElementsByClassName(name);
};
/**
* @param {?} element
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getElementsByTagName = /**
* @param {?} element
* @param {?} name
* @return {?}
*/
function (element, name) {
return element.getElementsByTagName(name);
};
/**
* @param {?} element
* @return {?}
*/
BrowserDomAdapter.prototype.classList = /**
* @param {?} element
* @return {?}
*/
function (element) {
return Array.prototype.slice.call(element.classList, 0);
};
/**
* @param {?} element
* @param {?} className
* @return {?}
*/
BrowserDomAdapter.prototype.addClass = /**
* @param {?} element
* @param {?} className
* @return {?}
*/
function (element, className) {
element.classList.add(className);
};
/**
* @param {?} element
* @param {?} className
* @return {?}
*/
BrowserDomAdapter.prototype.removeClass = /**
* @param {?} element
* @param {?} className
* @return {?}
*/
function (element, className) {
element.classList.remove(className);
};
/**
* @param {?} element
* @param {?} className
* @return {?}
*/
BrowserDomAdapter.prototype.hasClass = /**
* @param {?} element
* @param {?} className
* @return {?}
*/
function (element, className) {
return element.classList.contains(className);
};
/**
* @param {?} element
* @param {?} styleName
* @param {?} styleValue
* @return {?}
*/
BrowserDomAdapter.prototype.setStyle = /**
* @param {?} element
* @param {?} styleName
* @param {?} styleValue
* @return {?}
*/
function (element, styleName, styleValue) {
element.style[styleName] = styleValue;
};
/**
* @param {?} element
* @param {?} stylename
* @return {?}
*/
BrowserDomAdapter.prototype.removeStyle = /**
* @param {?} element
* @param {?} stylename
* @return {?}
*/
function (element, stylename) {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
element.style[stylename] = '';
};
/**
* @param {?} element
* @param {?} stylename
* @return {?}
*/
BrowserDomAdapter.prototype.getStyle = /**
* @param {?} element
* @param {?} stylename
* @return {?}
*/
function (element, stylename) {
return element.style[stylename];
};
/**
* @param {?} element
* @param {?} styleName
* @param {?=} styleValue
* @return {?}
*/
BrowserDomAdapter.prototype.hasStyle = /**
* @param {?} element
* @param {?} styleName
* @param {?=} styleValue
* @return {?}
*/
function (element, styleName, styleValue) {
var /** @type {?} */value = this.getStyle(element, styleName) || '';
return styleValue ? value == styleValue : value.length > 0;
};
/**
* @param {?} element
* @return {?}
*/
BrowserDomAdapter.prototype.tagName = /**
* @param {?} element
* @return {?}
*/
function (element) {
return element.tagName;
};
/**
* @param {?} element
* @return {?}
*/
BrowserDomAdapter.prototype.attributeMap = /**
* @param {?} element
* @return {?}
*/
function (element) {
var /** @type {?} */res = new Map();
var /** @type {?} */elAttrs = element.attributes;
for (var /** @type {?} */i = 0; i < elAttrs.length; i++) {
var /** @type {?} */attrib = elAttrs.item(i);
res.set(attrib.name, attrib.value);
}
return res;
};
/**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
BrowserDomAdapter.prototype.hasAttribute = /**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
function (element, attribute) {
return element.hasAttribute(attribute);
};
/**
* @param {?} element
* @param {?} ns
* @param {?} attribute
* @return {?}
*/
BrowserDomAdapter.prototype.hasAttributeNS = /**
* @param {?} element
* @param {?} ns
* @param {?} attribute
* @return {?}
*/
function (element, ns, attribute) {
return element.hasAttributeNS(ns, attribute);
};
/**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
BrowserDomAdapter.prototype.getAttribute = /**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
function (element, attribute) {
return element.getAttribute(attribute);
};
/**
* @param {?} element
* @param {?} ns
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getAttributeNS = /**
* @param {?} element
* @param {?} ns
* @param {?} name
* @return {?}
*/
function (element, ns, name) {
return element.getAttributeNS(ns, name);
};
/**
* @param {?} element
* @param {?} name
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setAttribute = /**
* @param {?} element
* @param {?} name
* @param {?} value
* @return {?}
*/
function (element, name, value) {
element.setAttribute(name, value);
};
/**
* @param {?} element
* @param {?} ns
* @param {?} name
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setAttributeNS = /**
* @param {?} element
* @param {?} ns
* @param {?} name
* @param {?} value
* @return {?}
*/
function (element, ns, name, value) {
element.setAttributeNS(ns, name, value);
};
/**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
BrowserDomAdapter.prototype.removeAttribute = /**
* @param {?} element
* @param {?} attribute
* @return {?}
*/
function (element, attribute) {
element.removeAttribute(attribute);
};
/**
* @param {?} element
* @param {?} ns
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.removeAttributeNS = /**
* @param {?} element
* @param {?} ns
* @param {?} name
* @return {?}
*/
function (element, ns, name) {
element.removeAttributeNS(ns, name);
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.templateAwareRoot = /**
* @param {?} el
* @return {?}
*/
function (el) {
return this.isTemplateElement(el) ? this.content(el) : el;
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.createHtmlDocument = /**
* @return {?}
*/
function () {
return document.implementation.createHTMLDocument('fakeTitle');
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.getDefaultDocument = /**
* @return {?}
*/
function () {
return document;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getBoundingClientRect = /**
* @param {?} el
* @return {?}
*/
function (el) {
try {
return el.getBoundingClientRect();
} catch ( /** @type {?} */e) {
return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
}
};
/**
* @param {?} doc
* @return {?}
*/
BrowserDomAdapter.prototype.getTitle = /**
* @param {?} doc
* @return {?}
*/
function (doc) {
return doc.title;
};
/**
* @param {?} doc
* @param {?} newTitle
* @return {?}
*/
BrowserDomAdapter.prototype.setTitle = /**
* @param {?} doc
* @param {?} newTitle
* @return {?}
*/
function (doc, newTitle) {
doc.title = newTitle || '';
};
/**
* @param {?} n
* @param {?} selector
* @return {?}
*/
BrowserDomAdapter.prototype.elementMatches = /**
* @param {?} n
* @param {?} selector
* @return {?}
*/
function (n, selector) {
if (this.isElementNode(n)) {
return n.matches && n.matches(selector) || n.msMatchesSelector && n.msMatchesSelector(selector) || n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
}
return false;
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.isTemplateElement = /**
* @param {?} el
* @return {?}
*/
function (el) {
return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.isTextNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nodeType === Node.TEXT_NODE;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.isCommentNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nodeType === Node.COMMENT_NODE;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.isElementNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nodeType === Node.ELEMENT_NODE;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.hasShadowRoot = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.shadowRoot != null && node instanceof HTMLElement;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.isShadowRoot = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node instanceof DocumentFragment;
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.importIntoDoc = /**
* @param {?} node
* @return {?}
*/
function (node) {
return document.importNode(this.templateAwareRoot(node), true);
};
/**
* @param {?} node
* @return {?}
*/
BrowserDomAdapter.prototype.adoptNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return document.adoptNode(node);
};
/**
* @param {?} el
* @return {?}
*/
BrowserDomAdapter.prototype.getHref = /**
* @param {?} el
* @return {?}
*/
function (el) {
return (/** @type {?} */el.getAttribute('href')
);
};
/**
* @param {?} event
* @return {?}
*/
BrowserDomAdapter.prototype.getEventKey = /**
* @param {?} event
* @return {?}
*/
function (event) {
var /** @type {?} */key = event.key;
if (key == null) {
key = event.keyIdentifier;
// keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
// Safari cf
// http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
if (key == null) {
return 'Unidentified';
}
if (key.startsWith('U+')) {
key = String.fromCharCode(parseInt(key.substring(2), 16));
if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
// There is a bug in Chrome for numeric keypad keys:
// https://code.google.com/p/chromium/issues/detail?id=155654
// 1, 2, 3 ... are reported as A, B, C ...
key = /** @type {?} */_chromeNumKeyPadMap[key];
}
}
}
return _keyMap[key] || key;
};
/**
* @param {?} doc
* @param {?} target
* @return {?}
*/
BrowserDomAdapter.prototype.getGlobalEventTarget = /**
* @param {?} doc
* @param {?} target
* @return {?}
*/
function (doc, target) {
if (target === 'window') {
return window;
}
if (target === 'document') {
return doc;
}
if (target === 'body') {
return doc.body;
}
return null;
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.getHistory = /**
* @return {?}
*/
function () {
return window.history;
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.getLocation = /**
* @return {?}
*/
function () {
return window.location;
};
/**
* @param {?} doc
* @return {?}
*/
BrowserDomAdapter.prototype.getBaseHref = /**
* @param {?} doc
* @return {?}
*/
function (doc) {
var /** @type {?} */href = getBaseElementHref();
return href == null ? null : relativePath(href);
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.resetBaseElement = /**
* @return {?}
*/
function () {
baseElement = null;
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.getUserAgent = /**
* @return {?}
*/
function () {
return window.navigator.userAgent;
};
/**
* @param {?} element
* @param {?} name
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setData = /**
* @param {?} element
* @param {?} name
* @param {?} value
* @return {?}
*/
function (element, name, value) {
this.setAttribute(element, 'data-' + name, value);
};
/**
* @param {?} element
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getData = /**
* @param {?} element
* @param {?} name
* @return {?}
*/
function (element, name) {
return this.getAttribute(element, 'data-' + name);
};
/**
* @param {?} element
* @return {?}
*/
BrowserDomAdapter.prototype.getComputedStyle = /**
* @param {?} element
* @return {?}
*/
function (element) {
return getComputedStyle(element);
};
// TODO(tbosch): move this into a separate environment class once we have it
/**
* @return {?}
*/
BrowserDomAdapter.prototype.supportsWebAnimation = /**
* @return {?}
*/
function () {
return typeof /** @type {?} */Element.prototype['animate'] === 'function';
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.performanceNow = /**
* @return {?}
*/
function () {
// performance.now() is not available in all browsers, see
// http://caniuse.com/#search=performance.now
return window.performance && window.performance.now ? window.performance.now() : new Date().getTime();
};
/**
* @return {?}
*/
BrowserDomAdapter.prototype.supportsCookies = /**
* @return {?}
*/
function () {
return true;
};
/**
* @param {?} name
* @return {?}
*/
BrowserDomAdapter.prototype.getCookie = /**
* @param {?} name
* @return {?}
*/
function (name) {
return _angular_common.ɵparseCookieValue(document.cookie, name);
};
/**
* @param {?} name
* @param {?} value
* @return {?}
*/
BrowserDomAdapter.prototype.setCookie = /**
* @param {?} name
* @param {?} value
* @return {?}
*/
function (name, value) {
// document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
// not clear other cookies.
document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
};
return BrowserDomAdapter;
}(GenericBrowserDomAdapter);
var baseElement = null;
/**
* @return {?}
*/
function getBaseElementHref() {
if (!baseElement) {
baseElement = /** @type {?} */document.querySelector('base');
if (!baseElement) {
return null;
}
}
return baseElement.getAttribute('href');
}
// based on urlUtils.js in AngularJS 1
var urlParsingNode;
/**
* @param {?} url
* @return {?}
*/
function relativePath(url) {
if (!urlParsingNode) {
urlParsingNode = document.createElement('a');
}
urlParsingNode.setAttribute('href', url);
return urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A DI Token representing the main rendering context. In a browser this is the DOM Document.
*
* Note: Document might not be available in the Application Context when Application and Rendering
* Contexts are not the same (e.g. when running the application into a Web Worker).
*
* @deprecated import from `\@angular/common` instead.
*/
var DOCUMENT$1 = _angular_common.DOCUMENT;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @return {?}
*/
function supportsState() {
return !!window.history.pushState;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* `PlatformLocation` encapsulates all of the direct calls to platform APIs.
* This class should not be used directly by an application developer. Instead, use
* {\@link Location}.
*/
var BrowserPlatformLocation = /** @class */function (_super) {
__extends(BrowserPlatformLocation, _super);
function BrowserPlatformLocation(_doc) {
var _this = _super.call(this) || this;
_this._doc = _doc;
_this._init();
return _this;
}
// This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
/** @internal */
/**
* \@internal
* @return {?}
*/
BrowserPlatformLocation.prototype._init = /**
* \@internal
* @return {?}
*/
function () {
/** @type {?} */this.location = getDOM().getLocation();
this._history = getDOM().getHistory();
};
/**
* @return {?}
*/
BrowserPlatformLocation.prototype.getBaseHrefFromDOM = /**
* @return {?}
*/
function () {
return (/** @type {?} */getDOM().getBaseHref(this._doc)
);
};
/**
* @param {?} fn
* @return {?}
*/
BrowserPlatformLocation.prototype.onPopState = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
};
/**
* @param {?} fn
* @return {?}
*/
BrowserPlatformLocation.prototype.onHashChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
};
Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
get: /**
* @return {?}
*/
function () {
return this.location.pathname;
},
set: /**
* @param {?} newPath
* @return {?}
*/
function (newPath) {
this.location.pathname = newPath;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
get: /**
* @return {?}
*/
function () {
return this.location.search;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
get: /**
* @return {?}
*/
function () {
return this.location.hash;
},
enumerable: true,
configurable: true
});
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
BrowserPlatformLocation.prototype.pushState = /**
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
function (state, title, url) {
if (supportsState()) {
this._history.pushState(state, title, url);
} else {
this.location.hash = url;
}
};
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
BrowserPlatformLocation.prototype.replaceState = /**
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
function (state, title, url) {
if (supportsState()) {
this._history.replaceState(state, title, url);
} else {
this.location.hash = url;
}
};
/**
* @return {?}
*/
BrowserPlatformLocation.prototype.forward = /**
* @return {?}
*/
function () {
this._history.forward();
};
/**
* @return {?}
*/
BrowserPlatformLocation.prototype.back = /**
* @return {?}
*/
function () {
this._history.back();
};
BrowserPlatformLocation.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
BrowserPlatformLocation.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return BrowserPlatformLocation;
}(_angular_common.PlatformLocation);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A service that can be used to get and add meta tags.
*
* \@experimental
*/
var Meta = /** @class */function () {
function Meta(_doc) {
this._doc = _doc;
this._dom = getDOM();
}
/**
* @param {?} tag
* @param {?=} forceCreation
* @return {?}
*/
Meta.prototype.addTag = /**
* @param {?} tag
* @param {?=} forceCreation
* @return {?}
*/
function (tag, forceCreation) {
if (forceCreation === void 0) {
forceCreation = false;
}
if (!tag) return null;
return this._getOrCreateElement(tag, forceCreation);
};
/**
* @param {?} tags
* @param {?=} forceCreation
* @return {?}
*/
Meta.prototype.addTags = /**
* @param {?} tags
* @param {?=} forceCreation
* @return {?}
*/
function (tags, forceCreation) {
var _this = this;
if (forceCreation === void 0) {
forceCreation = false;
}
if (!tags) return [];
return tags.reduce(function (result, tag) {
if (tag) {
result.push(_this._getOrCreateElement(tag, forceCreation));
}
return result;
}, []);
};
/**
* @param {?} attrSelector
* @return {?}
*/
Meta.prototype.getTag = /**
* @param {?} attrSelector
* @return {?}
*/
function (attrSelector) {
if (!attrSelector) return null;
return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]") || null;
};
/**
* @param {?} attrSelector
* @return {?}
*/
Meta.prototype.getTags = /**
* @param {?} attrSelector
* @return {?}
*/
function (attrSelector) {
if (!attrSelector) return [];
var /** @type {?} */list = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
return list ? [].slice.call(list) : [];
};
/**
* @param {?} tag
* @param {?=} selector
* @return {?}
*/
Meta.prototype.updateTag = /**
* @param {?} tag
* @param {?=} selector
* @return {?}
*/
function (tag, selector) {
if (!tag) return null;
selector = selector || this._parseSelector(tag);
var /** @type {?} */meta = /** @type {?} */this.getTag(selector);
if (meta) {
return this._setMetaElementAttributes(tag, meta);
}
return this._getOrCreateElement(tag, true);
};
/**
* @param {?} attrSelector
* @return {?}
*/
Meta.prototype.removeTag = /**
* @param {?} attrSelector
* @return {?}
*/
function (attrSelector) {
this.removeTagElement( /** @type {?} */this.getTag(attrSelector));
};
/**
* @param {?} meta
* @return {?}
*/
Meta.prototype.removeTagElement = /**
* @param {?} meta
* @return {?}
*/
function (meta) {
if (meta) {
this._dom.remove(meta);
}
};
/**
* @param {?} meta
* @param {?=} forceCreation
* @return {?}
*/
Meta.prototype._getOrCreateElement = /**
* @param {?} meta
* @param {?=} forceCreation
* @return {?}
*/
function (meta, forceCreation) {
if (forceCreation === void 0) {
forceCreation = false;
}
if (!forceCreation) {
var /** @type {?} */selector = this._parseSelector(meta);
var /** @type {?} */elem = /** @type {?} */this.getTag(selector);
// It's allowed to have multiple elements with the same name so it's not enough to
// just check that element with the same name already present on the page. We also need to
// check if element has tag attributes
if (elem && this._containsAttributes(meta, elem)) return elem;
}
var /** @type {?} */element = /** @type {?} */this._dom.createElement('meta');
this._setMetaElementAttributes(meta, element);
var /** @type {?} */head = this._dom.getElementsByTagName(this._doc, 'head')[0];
this._dom.appendChild(head, element);
return element;
};
/**
* @param {?} tag
* @param {?} el
* @return {?}
*/
Meta.prototype._setMetaElementAttributes = /**
* @param {?} tag
* @param {?} el
* @return {?}
*/
function (tag, el) {
var _this = this;
Object.keys(tag).forEach(function (prop) {
return _this._dom.setAttribute(el, prop, tag[prop]);
});
return el;
};
/**
* @param {?} tag
* @return {?}
*/
Meta.prototype._parseSelector = /**
* @param {?} tag
* @return {?}
*/
function (tag) {
var /** @type {?} */attr = tag.name ? 'name' : 'property';
return attr + "=\"" + tag[attr] + "\"";
};
/**
* @param {?} tag
* @param {?} elem
* @return {?}
*/
Meta.prototype._containsAttributes = /**
* @param {?} tag
* @param {?} elem
* @return {?}
*/
function (tag, elem) {
var _this = this;
return Object.keys(tag).every(function (key) {
return _this._dom.getAttribute(elem, key) === tag[key];
});
};
Meta.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
Meta.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return Meta;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An id that identifies a particular application being bootstrapped, that should
* match across the client/server boundary.
*/
var TRANSITION_ID = new _angular_core.InjectionToken('TRANSITION_ID');
/**
* @param {?} transitionId
* @param {?} document
* @param {?} injector
* @return {?}
*/
function appInitializerFactory(transitionId, document, injector) {
return function () {
// Wait for all application initializers to be completed before removing the styles set by
// the server.
injector.get(_angular_core.ApplicationInitStatus).donePromise.then(function () {
var /** @type {?} */dom = getDOM();
var /** @type {?} */styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
styles.filter(function (el) {
return dom.getAttribute(el, 'ng-transition') === transitionId;
}).forEach(function (el) {
return dom.remove(el);
});
});
};
}
var SERVER_TRANSITION_PROVIDERS = [{
provide: _angular_core.APP_INITIALIZER,
useFactory: appInitializerFactory,
deps: [TRANSITION_ID, DOCUMENT$1, _angular_core.Injector],
multi: true
}];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var BrowserGetTestability = /** @class */function () {
function BrowserGetTestability() {}
/**
* @return {?}
*/
BrowserGetTestability.init = /**
* @return {?}
*/
function () {
_angular_core.setTestabilityGetter(new BrowserGetTestability());
};
/**
* @param {?} registry
* @return {?}
*/
BrowserGetTestability.prototype.addToWindow = /**
* @param {?} registry
* @return {?}
*/
function (registry) {
_angular_core.ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
if (findInAncestors === void 0) {
findInAncestors = true;
}
var /** @type {?} */testability = registry.findTestabilityInTree(elem, findInAncestors);
if (testability == null) {
throw new Error('Could not find testability for element.');
}
return testability;
};
_angular_core.ɵglobal['getAllAngularTestabilities'] = function () {
return registry.getAllTestabilities();
};
_angular_core.ɵglobal['getAllAngularRootElements'] = function () {
return registry.getAllRootElements();
};
var /** @type {?} */whenAllStable = function (callback /** TODO #9100 */) {
var /** @type {?} */testabilities = _angular_core.ɵglobal['getAllAngularTestabilities']();
var /** @type {?} */count = testabilities.length;
var /** @type {?} */didWork = false;
var /** @type {?} */decrement = function (didWork_ /** TODO #9100 */) {
didWork = didWork || didWork_;
count--;
if (count == 0) {
callback(didWork);
}
};
testabilities.forEach(function (testability /** TODO #9100 */) {
testability.whenStable(decrement);
});
};
if (!_angular_core.ɵglobal['frameworkStabilizers']) {
_angular_core.ɵglobal['frameworkStabilizers'] = [];
}
_angular_core.ɵglobal['frameworkStabilizers'].push(whenAllStable);
};
/**
* @param {?} registry
* @param {?} elem
* @param {?} findInAncestors
* @return {?}
*/
BrowserGetTestability.prototype.findTestabilityInTree = /**
* @param {?} registry
* @param {?} elem
* @param {?} findInAncestors
* @return {?}
*/
function (registry, elem, findInAncestors) {
if (elem == null) {
return null;
}
var /** @type {?} */t = registry.getTestability(elem);
if (t != null) {
return t;
} else if (!findInAncestors) {
return null;
}
if (getDOM().isShadowRoot(elem)) {
return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
}
return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
};
return BrowserGetTestability;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A service that can be used to get and set the title of a current HTML document.
*
* Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
* it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
* (representing the `<title>` tag). Instead, this service can be used to set and get the current
* title value.
*
* \@experimental
*/
var Title = /** @class */function () {
function Title(_doc) {
this._doc = _doc;
}
/**
* Get the title of the current HTML document.
*/
/**
* Get the title of the current HTML document.
* @return {?}
*/
Title.prototype.getTitle = /**
* Get the title of the current HTML document.
* @return {?}
*/
function () {
return getDOM().getTitle(this._doc);
};
/**
* Set the title of the current HTML document.
* @param newTitle
*/
/**
* Set the title of the current HTML document.
* @param {?} newTitle
* @return {?}
*/
Title.prototype.setTitle = /**
* Set the title of the current HTML document.
* @param {?} newTitle
* @return {?}
*/
function (newTitle) {
getDOM().setTitle(this._doc, newTitle);
};
Title.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
Title.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return Title;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} input
* @return {?}
*/
/**
* @param {?} input
* @return {?}
*/
/**
* Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
* `name` is `'probe'`.
* @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
* global `ng` object.
* @param {?} value The value to export.
* @return {?}
*/
function exportNgVar(name, value) {
if (typeof COMPILED === 'undefined' || !COMPILED) {
// Note: we can't export `ng` when using closure enhanced optimization as:
// - closure declares globals itself for minified names, which sometimes clobber our `ng` global
// - we can't declare a closure extern as the namespace `ng` is already used within Google
// for typings for angularJS (via `goog.provide('ng....')`).
var /** @type {?} */ng = _angular_core.ɵglobal['ng'] = /** @type {?} */_angular_core.ɵglobal['ng'] || {};
ng[name] = value;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var CORE_TOKENS = {
'ApplicationRef': _angular_core.ApplicationRef,
'NgZone': _angular_core.NgZone
};
var INSPECT_GLOBAL_NAME = 'probe';
var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
/**
* Returns a {\@link DebugElement} for the given native DOM element, or
* null if the given native element does not have an Angular view associated
* with it.
* @param {?} element
* @return {?}
*/
function inspectNativeElement(element) {
return _angular_core.getDebugNode(element);
}
/**
* @param {?} coreTokens
* @return {?}
*/
function _createNgProbe(coreTokens) {
exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
return function () {
return inspectNativeElement;
};
}
/**
* @param {?} tokens
* @return {?}
*/
function _ngProbeTokensToMap(tokens) {
return tokens.reduce(function (prev, t) {
return prev[t.name] = t.token, prev;
}, {});
}
/**
* Providers which support debugging Angular applications (e.g. via `ng.probe`).
*/
var ELEMENT_PROBE_PROVIDERS = [{
provide: _angular_core.APP_INITIALIZER,
useFactory: _createNgProbe,
deps: [[_angular_core.NgProbeToken, new _angular_core.Optional()]],
multi: true
}];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@stable
*/
var EVENT_MANAGER_PLUGINS = new _angular_core.InjectionToken('EventManagerPlugins');
/**
* \@stable
*/
var EventManager = /** @class */function () {
function EventManager(plugins, _zone) {
var _this = this;
this._zone = _zone;
this._eventNameToPlugin = new Map();
plugins.forEach(function (p) {
return p.manager = _this;
});
this._plugins = plugins.slice().reverse();
}
/**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
EventManager.prototype.addEventListener = /**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (element, eventName, handler) {
var /** @type {?} */plugin = this._findPluginFor(eventName);
return plugin.addEventListener(element, eventName, handler);
};
/**
* @param {?} target
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
EventManager.prototype.addGlobalEventListener = /**
* @param {?} target
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (target, eventName, handler) {
var /** @type {?} */plugin = this._findPluginFor(eventName);
return plugin.addGlobalEventListener(target, eventName, handler);
};
/**
* @return {?}
*/
EventManager.prototype.getZone = /**
* @return {?}
*/
function () {
return this._zone;
};
/** @internal */
/**
* \@internal
* @param {?} eventName
* @return {?}
*/
EventManager.prototype._findPluginFor = /**
* \@internal
* @param {?} eventName
* @return {?}
*/
function (eventName) {
var /** @type {?} */plugin = this._eventNameToPlugin.get(eventName);
if (plugin) {
return plugin;
}
var /** @type {?} */plugins = this._plugins;
for (var /** @type {?} */i = 0; i < plugins.length; i++) {
var /** @type {?} */plugin_1 = plugins[i];
if (plugin_1.supports(eventName)) {
this._eventNameToPlugin.set(eventName, plugin_1);
return plugin_1;
}
}
throw new Error("No event manager plugin found for event " + eventName);
};
EventManager.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
EventManager.ctorParameters = function () {
return [{ type: Array, decorators: [{ type: _angular_core.Inject, args: [EVENT_MANAGER_PLUGINS] }] }, { type: _angular_core.NgZone }];
};
return EventManager;
}();
/**
* @abstract
*/
var EventManagerPlugin = /** @class */function () {
function EventManagerPlugin(_doc) {
this._doc = _doc;
}
/**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
EventManagerPlugin.prototype.addGlobalEventListener = /**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (element, eventName, handler) {
var /** @type {?} */target = getDOM().getGlobalEventTarget(this._doc, element);
if (!target) {
throw new Error("Unsupported event target " + target + " for event " + eventName);
}
return this.addEventListener(target, eventName, handler);
};
return EventManagerPlugin;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var SharedStylesHost = /** @class */function () {
function SharedStylesHost() {
/**
* \@internal
*/
this._stylesSet = new Set();
}
/**
* @param {?} styles
* @return {?}
*/
SharedStylesHost.prototype.addStyles = /**
* @param {?} styles
* @return {?}
*/
function (styles) {
var _this = this;
var /** @type {?} */additions = new Set();
styles.forEach(function (style) {
if (!_this._stylesSet.has(style)) {
_this._stylesSet.add(style);
additions.add(style);
}
});
this.onStylesAdded(additions);
};
/**
* @param {?} additions
* @return {?}
*/
SharedStylesHost.prototype.onStylesAdded = /**
* @param {?} additions
* @return {?}
*/
function (additions) {};
/**
* @return {?}
*/
SharedStylesHost.prototype.getAllStyles = /**
* @return {?}
*/
function () {
return Array.from(this._stylesSet);
};
SharedStylesHost.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
SharedStylesHost.ctorParameters = function () {
return [];
};
return SharedStylesHost;
}();
var DomSharedStylesHost = /** @class */function (_super) {
__extends(DomSharedStylesHost, _super);
function DomSharedStylesHost(_doc) {
var _this = _super.call(this) || this;
_this._doc = _doc;
_this._hostNodes = new Set();
_this._styleNodes = new Set();
_this._hostNodes.add(_doc.head);
return _this;
}
/**
* @param {?} styles
* @param {?} host
* @return {?}
*/
DomSharedStylesHost.prototype._addStylesToHost = /**
* @param {?} styles
* @param {?} host
* @return {?}
*/
function (styles, host) {
var _this = this;
styles.forEach(function (style) {
var /** @type {?} */styleEl = _this._doc.createElement('style');
styleEl.textContent = style;
_this._styleNodes.add(host.appendChild(styleEl));
});
};
/**
* @param {?} hostNode
* @return {?}
*/
DomSharedStylesHost.prototype.addHost = /**
* @param {?} hostNode
* @return {?}
*/
function (hostNode) {
this._addStylesToHost(this._stylesSet, hostNode);
this._hostNodes.add(hostNode);
};
/**
* @param {?} hostNode
* @return {?}
*/
DomSharedStylesHost.prototype.removeHost = /**
* @param {?} hostNode
* @return {?}
*/
function (hostNode) {
this._hostNodes.delete(hostNode);
};
/**
* @param {?} additions
* @return {?}
*/
DomSharedStylesHost.prototype.onStylesAdded = /**
* @param {?} additions
* @return {?}
*/
function (additions) {
var _this = this;
this._hostNodes.forEach(function (hostNode) {
return _this._addStylesToHost(additions, hostNode);
});
};
/**
* @return {?}
*/
DomSharedStylesHost.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this._styleNodes.forEach(function (styleNode) {
return getDOM().remove(styleNode);
});
};
DomSharedStylesHost.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
DomSharedStylesHost.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return DomSharedStylesHost;
}(SharedStylesHost);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NAMESPACE_URIS = {
'svg': 'http://www.w3.org/2000/svg',
'xhtml': 'http://www.w3.org/1999/xhtml',
'xlink': 'http://www.w3.org/1999/xlink',
'xml': 'http://www.w3.org/XML/1998/namespace',
'xmlns': 'http://www.w3.org/2000/xmlns/'
};
var COMPONENT_REGEX = /%COMP%/g;
var COMPONENT_VARIABLE = '%COMP%';
var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
/**
* @param {?} componentShortId
* @return {?}
*/
function shimContentAttribute(componentShortId) {
return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
}
/**
* @param {?} componentShortId
* @return {?}
*/
function shimHostAttribute(componentShortId) {
return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
}
/**
* @param {?} compId
* @param {?} styles
* @param {?} target
* @return {?}
*/
function flattenStyles(compId, styles, target) {
for (var /** @type {?} */i = 0; i < styles.length; i++) {
var /** @type {?} */style = styles[i];
if (Array.isArray(style)) {
flattenStyles(compId, style, target);
} else {
style = style.replace(COMPONENT_REGEX, compId);
target.push(style);
}
}
return target;
}
/**
* @param {?} eventHandler
* @return {?}
*/
function decoratePreventDefault(eventHandler) {
return function (event) {
var /** @type {?} */allowDefaultBehavior = eventHandler(event);
if (allowDefaultBehavior === false) {
// TODO(tbosch): move preventDefault into event plugins...
event.preventDefault();
event.returnValue = false;
}
};
}
var DomRendererFactory2 = /** @class */function () {
function DomRendererFactory2(eventManager, sharedStylesHost) {
this.eventManager = eventManager;
this.sharedStylesHost = sharedStylesHost;
this.rendererByCompId = new Map();
this.defaultRenderer = new DefaultDomRenderer2(eventManager);
}
/**
* @param {?} element
* @param {?} type
* @return {?}
*/
DomRendererFactory2.prototype.createRenderer = /**
* @param {?} element
* @param {?} type
* @return {?}
*/
function (element, type) {
if (!element || !type) {
return this.defaultRenderer;
}
switch (type.encapsulation) {
case _angular_core.ViewEncapsulation.Emulated:
{
var /** @type {?} */renderer = this.rendererByCompId.get(type.id);
if (!renderer) {
renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type);
this.rendererByCompId.set(type.id, renderer);
}
/** @type {?} */renderer.applyToHost(element);
return renderer;
}
case _angular_core.ViewEncapsulation.Native:
return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
default:
{
if (!this.rendererByCompId.has(type.id)) {
var /** @type {?} */styles = flattenStyles(type.id, type.styles, []);
this.sharedStylesHost.addStyles(styles);
this.rendererByCompId.set(type.id, this.defaultRenderer);
}
return this.defaultRenderer;
}
}
};
/**
* @return {?}
*/
DomRendererFactory2.prototype.begin = /**
* @return {?}
*/
function () {};
/**
* @return {?}
*/
DomRendererFactory2.prototype.end = /**
* @return {?}
*/
function () {};
DomRendererFactory2.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
DomRendererFactory2.ctorParameters = function () {
return [{ type: EventManager }, { type: DomSharedStylesHost }];
};
return DomRendererFactory2;
}();
var DefaultDomRenderer2 = /** @class */function () {
function DefaultDomRenderer2(eventManager) {
this.eventManager = eventManager;
this.data = Object.create(null);
}
/**
* @return {?}
*/
DefaultDomRenderer2.prototype.destroy = /**
* @return {?}
*/
function () {};
/**
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
DefaultDomRenderer2.prototype.createElement = /**
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
function (name, namespace) {
if (namespace) {
return document.createElementNS(NAMESPACE_URIS[namespace], name);
}
return document.createElement(name);
};
/**
* @param {?} value
* @return {?}
*/
DefaultDomRenderer2.prototype.createComment = /**
* @param {?} value
* @return {?}
*/
function (value) {
return document.createComment(value);
};
/**
* @param {?} value
* @return {?}
*/
DefaultDomRenderer2.prototype.createText = /**
* @param {?} value
* @return {?}
*/
function (value) {
return document.createTextNode(value);
};
/**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
DefaultDomRenderer2.prototype.appendChild = /**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
function (parent, newChild) {
parent.appendChild(newChild);
};
/**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
DefaultDomRenderer2.prototype.insertBefore = /**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
function (parent, newChild, refChild) {
if (parent) {
parent.insertBefore(newChild, refChild);
}
};
/**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
DefaultDomRenderer2.prototype.removeChild = /**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
function (parent, oldChild) {
if (parent) {
parent.removeChild(oldChild);
}
};
/**
* @param {?} selectorOrNode
* @return {?}
*/
DefaultDomRenderer2.prototype.selectRootElement = /**
* @param {?} selectorOrNode
* @return {?}
*/
function (selectorOrNode) {
var /** @type {?} */el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) : selectorOrNode;
if (!el) {
throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
}
el.textContent = '';
return el;
};
/**
* @param {?} node
* @return {?}
*/
DefaultDomRenderer2.prototype.parentNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.parentNode;
};
/**
* @param {?} node
* @return {?}
*/
DefaultDomRenderer2.prototype.nextSibling = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node.nextSibling;
};
/**
* @param {?} el
* @param {?} name
* @param {?} value
* @param {?=} namespace
* @return {?}
*/
DefaultDomRenderer2.prototype.setAttribute = /**
* @param {?} el
* @param {?} name
* @param {?} value
* @param {?=} namespace
* @return {?}
*/
function (el, name, value, namespace) {
if (namespace) {
name = namespace + ":" + name;
var /** @type {?} */namespaceUri = NAMESPACE_URIS[namespace];
if (namespaceUri) {
el.setAttributeNS(namespaceUri, name, value);
} else {
el.setAttribute(name, value);
}
} else {
el.setAttribute(name, value);
}
};
/**
* @param {?} el
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
DefaultDomRenderer2.prototype.removeAttribute = /**
* @param {?} el
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
function (el, name, namespace) {
if (namespace) {
var /** @type {?} */namespaceUri = NAMESPACE_URIS[namespace];
if (namespaceUri) {
el.removeAttributeNS(namespaceUri, name);
} else {
el.removeAttribute(namespace + ":" + name);
}
} else {
el.removeAttribute(name);
}
};
/**
* @param {?} el
* @param {?} name
* @return {?}
*/
DefaultDomRenderer2.prototype.addClass = /**
* @param {?} el
* @param {?} name
* @return {?}
*/
function (el, name) {
el.classList.add(name);
};
/**
* @param {?} el
* @param {?} name
* @return {?}
*/
DefaultDomRenderer2.prototype.removeClass = /**
* @param {?} el
* @param {?} name
* @return {?}
*/
function (el, name) {
el.classList.remove(name);
};
/**
* @param {?} el
* @param {?} style
* @param {?} value
* @param {?} flags
* @return {?}
*/
DefaultDomRenderer2.prototype.setStyle = /**
* @param {?} el
* @param {?} style
* @param {?} value
* @param {?} flags
* @return {?}
*/
function (el, style, value, flags) {
if (flags & _angular_core.RendererStyleFlags2.DashCase) {
el.style.setProperty(style, value, !!(flags & _angular_core.RendererStyleFlags2.Important) ? 'important' : '');
} else {
el.style[style] = value;
}
};
/**
* @param {?} el
* @param {?} style
* @param {?} flags
* @return {?}
*/
DefaultDomRenderer2.prototype.removeStyle = /**
* @param {?} el
* @param {?} style
* @param {?} flags
* @return {?}
*/
function (el, style, flags) {
if (flags & _angular_core.RendererStyleFlags2.DashCase) {
el.style.removeProperty(style);
} else {
// IE requires '' instead of null
// see https://github.com/angular/angular/issues/7916
el.style[style] = '';
}
};
/**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
DefaultDomRenderer2.prototype.setProperty = /**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
function (el, name, value) {
checkNoSyntheticProp(name, 'property');
el[name] = value;
};
/**
* @param {?} node
* @param {?} value
* @return {?}
*/
DefaultDomRenderer2.prototype.setValue = /**
* @param {?} node
* @param {?} value
* @return {?}
*/
function (node, value) {
node.nodeValue = value;
};
/**
* @param {?} target
* @param {?} event
* @param {?} callback
* @return {?}
*/
DefaultDomRenderer2.prototype.listen = /**
* @param {?} target
* @param {?} event
* @param {?} callback
* @return {?}
*/
function (target, event, callback) {
checkNoSyntheticProp(event, 'listener');
if (typeof target === 'string') {
return (/** @type {?} */this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback))
);
}
return (/** @type {?} */this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))
);
};
return DefaultDomRenderer2;
}();
var AT_CHARCODE = '@'.charCodeAt(0);
/**
* @param {?} name
* @param {?} nameKind
* @return {?}
*/
function checkNoSyntheticProp(name, nameKind) {
if (name.charCodeAt(0) === AT_CHARCODE) {
throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
}
}
var EmulatedEncapsulationDomRenderer2 = /** @class */function (_super) {
__extends(EmulatedEncapsulationDomRenderer2, _super);
function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component) {
var _this = _super.call(this, eventManager) || this;
_this.component = component;
var /** @type {?} */styles = flattenStyles(component.id, component.styles, []);
sharedStylesHost.addStyles(styles);
_this.contentAttr = shimContentAttribute(component.id);
_this.hostAttr = shimHostAttribute(component.id);
return _this;
}
/**
* @param {?} element
* @return {?}
*/
EmulatedEncapsulationDomRenderer2.prototype.applyToHost = /**
* @param {?} element
* @return {?}
*/
function (element) {
_super.prototype.setAttribute.call(this, element, this.hostAttr, '');
};
/**
* @param {?} parent
* @param {?} name
* @return {?}
*/
EmulatedEncapsulationDomRenderer2.prototype.createElement = /**
* @param {?} parent
* @param {?} name
* @return {?}
*/
function (parent, name) {
var /** @type {?} */el = _super.prototype.createElement.call(this, parent, name);
_super.prototype.setAttribute.call(this, el, this.contentAttr, '');
return el;
};
return EmulatedEncapsulationDomRenderer2;
}(DefaultDomRenderer2);
var ShadowDomRenderer = /** @class */function (_super) {
__extends(ShadowDomRenderer, _super);
function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
var _this = _super.call(this, eventManager) || this;
_this.sharedStylesHost = sharedStylesHost;
_this.hostEl = hostEl;
_this.component = component;
_this.shadowRoot = /** @type {?} */hostEl.createShadowRoot();
_this.sharedStylesHost.addHost(_this.shadowRoot);
var /** @type {?} */styles = flattenStyles(component.id, component.styles, []);
for (var /** @type {?} */i = 0; i < styles.length; i++) {
var /** @type {?} */styleEl = document.createElement('style');
styleEl.textContent = styles[i];
_this.shadowRoot.appendChild(styleEl);
}
return _this;
}
/**
* @param {?} node
* @return {?}
*/
ShadowDomRenderer.prototype.nodeOrShadowRoot = /**
* @param {?} node
* @return {?}
*/
function (node) {
return node === this.hostEl ? this.shadowRoot : node;
};
/**
* @return {?}
*/
ShadowDomRenderer.prototype.destroy = /**
* @return {?}
*/
function () {
this.sharedStylesHost.removeHost(this.shadowRoot);
};
/**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
ShadowDomRenderer.prototype.appendChild = /**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
function (parent, newChild) {
return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
};
/**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
ShadowDomRenderer.prototype.insertBefore = /**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
function (parent, newChild, refChild) {
return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
};
/**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
ShadowDomRenderer.prototype.removeChild = /**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
function (parent, oldChild) {
return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
};
/**
* @param {?} node
* @return {?}
*/
ShadowDomRenderer.prototype.parentNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
};
return ShadowDomRenderer;
}(DefaultDomRenderer2);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ɵ0 = function (v) {
return '__zone_symbol__' + v;
};
/**
* Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
* since Angular can do much more
* efficient bookkeeping than Zone can, because we have additional information. This speeds up
* addEventListener by 3x.
*/
var __symbol__ = typeof Zone !== 'undefined' && /** @type {?} */Zone['__symbol__'] || ɵ0;
var ADD_EVENT_LISTENER = __symbol__('addEventListener');
var REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
var symbolNames = {};
var FALSE = 'FALSE';
var ANGULAR = 'ANGULAR';
var NATIVE_ADD_LISTENER = 'addEventListener';
var NATIVE_REMOVE_LISTENER = 'removeEventListener';
// use the same symbol string which is used in zone.js
var stopSymbol = '__zone_symbol__propagationStopped';
var stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
var blackListedEvents = typeof Zone !== 'undefined' && /** @type {?} */Zone[__symbol__('BLACK_LISTED_EVENTS')];
var blackListedMap;
if (blackListedEvents) {
blackListedMap = {};
blackListedEvents.forEach(function (eventName) {
blackListedMap[eventName] = eventName;
});
}
var isBlackListedEvent = function (eventName) {
if (!blackListedMap) {
return false;
}
return blackListedMap.hasOwnProperty(eventName);
};
// a global listener to handle all dom event,
// so we do not need to create a closure everytime
var globalListener = function (event) {
var /** @type {?} */symbolName = symbolNames[event.type];
if (!symbolName) {
return;
}
var /** @type {?} */taskDatas = this[symbolName];
if (!taskDatas) {
return;
}
var /** @type {?} */args = [event];
if (taskDatas.length === 1) {
// if taskDatas only have one element, just invoke it
var /** @type {?} */taskData = taskDatas[0];
if (taskData.zone !== Zone.current) {
// only use Zone.run when Zone.current not equals to stored zone
return taskData.zone.run(taskData.handler, this, args);
} else {
return taskData.handler.apply(this, args);
}
} else {
// copy tasks as a snapshot to avoid event handlers remove
// itself or others
var /** @type {?} */copiedTasks = taskDatas.slice();
for (var /** @type {?} */i = 0; i < copiedTasks.length; i++) {
// if other listener call event.stopImmediatePropagation
// just break
if ( /** @type {?} */event[stopSymbol] === true) {
break;
}
var /** @type {?} */taskData = copiedTasks[i];
if (taskData.zone !== Zone.current) {
// only use Zone.run when Zone.current not equals to stored zone
taskData.zone.run(taskData.handler, this, args);
} else {
taskData.handler.apply(this, args);
}
}
}
};
var DomEventsPlugin = /** @class */function (_super) {
__extends(DomEventsPlugin, _super);
function DomEventsPlugin(doc, ngZone) {
var _this = _super.call(this, doc) || this;
_this.ngZone = ngZone;
_this.patchEvent();
return _this;
}
/**
* @return {?}
*/
DomEventsPlugin.prototype.patchEvent = /**
* @return {?}
*/
function () {
if (!Event || !Event.prototype) {
return;
}
if ( /** @type {?} */Event.prototype[stopMethodSymbol]) {
// already patched by zone.js
return;
}
var /** @type {?} */delegate = /** @type {?} */Event.prototype[stopMethodSymbol] = Event.prototype.stopImmediatePropagation;
Event.prototype.stopImmediatePropagation = function () {
if (this) {
this[stopSymbol] = true;
}
// should call native delegate in case
// in some enviroment part of the application
// will not use the patched Event
delegate && delegate.apply(this, arguments);
};
};
// This plugin should come last in the list of plugins, because it accepts all
// events.
/**
* @param {?} eventName
* @return {?}
*/
DomEventsPlugin.prototype.supports = /**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
return true;
};
/**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
DomEventsPlugin.prototype.addEventListener = /**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (element, eventName, handler) {
var _this = this;
/**
* This code is about to add a listener to the DOM. If Zone.js is present, than
* `addEventListener` has been patched. The patched code adds overhead in both
* memory and speed (3x slower) than native. For this reason if we detect that
* Zone.js is present we use a simple version of zone aware addEventListener instead.
* The result is faster registration and the zone will be restored.
* But ZoneSpec.onScheduleTask, ZoneSpec.onInvokeTask, ZoneSpec.onCancelTask
* will not be invoked
* We also do manual zone restoration in element.ts renderEventHandlerClosure method.
*
* NOTE: it is possible that the element is from different iframe, and so we
* have to check before we execute the method.
*/
var /** @type {?} */self = this;
var /** @type {?} */zoneJsLoaded = element[ADD_EVENT_LISTENER];
var /** @type {?} */callback = /** @type {?} */handler;
// if zonejs is loaded and current zone is not ngZone
// we keep Zone.current on target for later restoration.
if (zoneJsLoaded && (!_angular_core.NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
var /** @type {?} */symbolName = symbolNames[eventName];
if (!symbolName) {
symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
}
var /** @type {?} */taskDatas = /** @type {?} */element[symbolName];
var /** @type {?} */globalListenerRegistered = taskDatas && taskDatas.length > 0;
if (!taskDatas) {
taskDatas = /** @type {?} */element[symbolName] = [];
}
var /** @type {?} */zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
if (taskDatas.length === 0) {
taskDatas.push({ zone: zone, handler: callback });
} else {
var /** @type {?} */callbackRegistered = false;
for (var /** @type {?} */i = 0; i < taskDatas.length; i++) {
if (taskDatas[i].handler === callback) {
callbackRegistered = true;
break;
}
}
if (!callbackRegistered) {
taskDatas.push({ zone: zone, handler: callback });
}
}
if (!globalListenerRegistered) {
element[ADD_EVENT_LISTENER](eventName, globalListener, false);
}
} else {
element[NATIVE_ADD_LISTENER](eventName, callback, false);
}
return function () {
return _this.removeEventListener(element, eventName, callback);
};
};
/**
* @param {?} target
* @param {?} eventName
* @param {?} callback
* @return {?}
*/
DomEventsPlugin.prototype.removeEventListener = /**
* @param {?} target
* @param {?} eventName
* @param {?} callback
* @return {?}
*/
function (target, eventName, callback) {
var /** @type {?} */underlyingRemove = target[REMOVE_EVENT_LISTENER];
// zone.js not loaded, use native removeEventListener
if (!underlyingRemove) {
return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
}
var /** @type {?} */symbolName = symbolNames[eventName];
var /** @type {?} */taskDatas = symbolName && target[symbolName];
if (!taskDatas) {
// addEventListener not using patched version
// just call native removeEventListener
return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
}
// fix issue 20532, should be able to remove
// listener which was added inside of ngZone
var /** @type {?} */found = false;
for (var /** @type {?} */i = 0; i < taskDatas.length; i++) {
// remove listener from taskDatas if the callback equals
if (taskDatas[i].handler === callback) {
found = true;
taskDatas.splice(i, 1);
break;
}
}
if (found) {
if (taskDatas.length === 0) {
// all listeners are removed, we can remove the globalListener from target
underlyingRemove.apply(target, [eventName, globalListener, false]);
}
} else {
// not found in taskDatas, the callback may be added inside of ngZone
// use native remove listener to remove the calback
target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
}
};
DomEventsPlugin.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
DomEventsPlugin.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }, { type: _angular_core.NgZone }];
};
return DomEventsPlugin;
}(EventManagerPlugin);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var EVENT_NAMES = {
// pan
'pan': true,
'panstart': true,
'panmove': true,
'panend': true,
'pancancel': true,
'panleft': true,
'panright': true,
'panup': true,
'pandown': true,
// pinch
'pinch': true,
'pinchstart': true,
'pinchmove': true,
'pinchend': true,
'pinchcancel': true,
'pinchin': true,
'pinchout': true,
// press
'press': true,
'pressup': true,
// rotate
'rotate': true,
'rotatestart': true,
'rotatemove': true,
'rotateend': true,
'rotatecancel': true,
// swipe
'swipe': true,
'swipeleft': true,
'swiperight': true,
'swipeup': true,
'swipedown': true,
// tap
'tap': true
};
/**
* A DI token that you can use to provide{\@link HammerGestureConfig} to Angular. Use it to configure
* Hammer gestures.
*
* \@experimental
*/
var HAMMER_GESTURE_CONFIG = new _angular_core.InjectionToken('HammerGestureConfig');
/**
* @record
*/
/**
* \@experimental
*/
var HammerGestureConfig = /** @class */function () {
function HammerGestureConfig() {
this.events = [];
this.overrides = {};
}
/**
* @param {?} element
* @return {?}
*/
HammerGestureConfig.prototype.buildHammer = /**
* @param {?} element
* @return {?}
*/
function (element) {
var /** @type {?} */mc = new Hammer(element);
mc.get('pinch').set({ enable: true });
mc.get('rotate').set({ enable: true });
for (var /** @type {?} */eventName in this.overrides) {
mc.get(eventName).set(this.overrides[eventName]);
}
return mc;
};
HammerGestureConfig.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
HammerGestureConfig.ctorParameters = function () {
return [];
};
return HammerGestureConfig;
}();
var HammerGesturesPlugin = /** @class */function (_super) {
__extends(HammerGesturesPlugin, _super);
function HammerGesturesPlugin(doc, _config) {
var _this = _super.call(this, doc) || this;
_this._config = _config;
return _this;
}
/**
* @param {?} eventName
* @return {?}
*/
HammerGesturesPlugin.prototype.supports = /**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
return false;
}
if (! /** @type {?} */window.Hammer) {
throw new Error("Hammer.js is not loaded, can not bind " + eventName + " event");
}
return true;
};
/**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
HammerGesturesPlugin.prototype.addEventListener = /**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (element, eventName, handler) {
var _this = this;
var /** @type {?} */zone = this.manager.getZone();
eventName = eventName.toLowerCase();
return zone.runOutsideAngular(function () {
// Creating the manager bind events, must be done outside of angular
var /** @type {?} */mc = _this._config.buildHammer(element);
var /** @type {?} */callback = function (eventObj) {
zone.runGuarded(function () {
handler(eventObj);
});
};
mc.on(eventName, callback);
return function () {
return mc.off(eventName, callback);
};
});
};
/**
* @param {?} eventName
* @return {?}
*/
HammerGesturesPlugin.prototype.isCustomEvent = /**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
return this._config.events.indexOf(eventName) > -1;
};
HammerGesturesPlugin.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
HammerGesturesPlugin.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }, { type: HammerGestureConfig, decorators: [{ type: _angular_core.Inject, args: [HAMMER_GESTURE_CONFIG] }] }];
};
return HammerGesturesPlugin;
}(EventManagerPlugin);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
var ɵ0$1 = function (event) {
return event.altKey;
};
var ɵ1$1 = function (event) {
return event.ctrlKey;
};
var ɵ2$1 = function (event) {
return event.metaKey;
};
var ɵ3 = function (event) {
return event.shiftKey;
};
var MODIFIER_KEY_GETTERS = {
'alt': ɵ0$1,
'control': ɵ1$1,
'meta': ɵ2$1,
'shift': ɵ3
};
/**
* \@experimental
*/
var KeyEventsPlugin = /** @class */function (_super) {
__extends(KeyEventsPlugin, _super);
function KeyEventsPlugin(doc) {
return _super.call(this, doc) || this;
}
/**
* @param {?} eventName
* @return {?}
*/
KeyEventsPlugin.prototype.supports = /**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
return KeyEventsPlugin.parseEventName(eventName) != null;
};
/**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
KeyEventsPlugin.prototype.addEventListener = /**
* @param {?} element
* @param {?} eventName
* @param {?} handler
* @return {?}
*/
function (element, eventName, handler) {
var /** @type {?} */parsedEvent = /** @type {?} */KeyEventsPlugin.parseEventName(eventName);
var /** @type {?} */outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
return this.manager.getZone().runOutsideAngular(function () {
return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
});
};
/**
* @param {?} eventName
* @return {?}
*/
KeyEventsPlugin.parseEventName = /**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
var /** @type {?} */parts = eventName.toLowerCase().split('.');
var /** @type {?} */domEventName = parts.shift();
if (parts.length === 0 || !(domEventName === 'keydown' || domEventName === 'keyup')) {
return null;
}
var /** @type {?} */key = KeyEventsPlugin._normalizeKey( /** @type {?} */parts.pop());
var /** @type {?} */fullKey = '';
MODIFIER_KEYS.forEach(function (modifierName) {
var /** @type {?} */index = parts.indexOf(modifierName);
if (index > -1) {
parts.splice(index, 1);
fullKey += modifierName + '.';
}
});
fullKey += key;
if (parts.length != 0 || key.length === 0) {
// returning null instead of throwing to let another plugin process the event
return null;
}
var /** @type {?} */result = {};
result['domEventName'] = domEventName;
result['fullKey'] = fullKey;
return result;
};
/**
* @param {?} event
* @return {?}
*/
KeyEventsPlugin.getEventFullKey = /**
* @param {?} event
* @return {?}
*/
function (event) {
var /** @type {?} */fullKey = '';
var /** @type {?} */key = getDOM().getEventKey(event);
key = key.toLowerCase();
if (key === ' ') {
key = 'space'; // for readability
} else if (key === '.') {
key = 'dot'; // because '.' is used as a separator in event names
}
MODIFIER_KEYS.forEach(function (modifierName) {
if (modifierName != key) {
var /** @type {?} */modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
if (modifierGetter(event)) {
fullKey += modifierName + '.';
}
}
});
fullKey += key;
return fullKey;
};
/**
* @param {?} fullKey
* @param {?} handler
* @param {?} zone
* @return {?}
*/
KeyEventsPlugin.eventCallback = /**
* @param {?} fullKey
* @param {?} handler
* @param {?} zone
* @return {?}
*/
function (fullKey, handler, zone) {
return function (event /** TODO #9100 */) {
if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
zone.runGuarded(function () {
return handler(event);
});
}
};
};
/** @internal */
/**
* \@internal
* @param {?} keyName
* @return {?}
*/
KeyEventsPlugin._normalizeKey = /**
* \@internal
* @param {?} keyName
* @return {?}
*/
function (keyName) {
// TODO: switch to a Map if the mapping grows too much
switch (keyName) {
case 'esc':
return 'escape';
default:
return keyName;
}
};
KeyEventsPlugin.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
KeyEventsPlugin.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return KeyEventsPlugin;
}(EventManagerPlugin);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A pattern that recognizes a commonly useful subset of URLs that are safe.
*
* This regular expression matches a subset of URLs that will not cause script
* execution if used in URL context within a HTML document. Specifically, this
* regular expression matches if (comment from here on and regex copied from
* Soy's EscapingConventions):
* (1) Either a protocol in a whitelist (http, https, mailto or ftp).
* (2) or no protocol. A protocol must be followed by a colon. The below
* allows that by allowing colons only after one of the characters [/?#].
* A colon after a hash (#) must be in the fragment.
* Otherwise, a colon after a (?) must be in a query.
* Otherwise, a colon after a single solidus (/) must be in a path.
* Otherwise, a colon after a double solidus (//) must be in the authority
* (before port).
*
* The pattern disallows &, used in HTML entity declarations before
* one of the characters in [/?#]. This disallows HTML entities used in the
* protocol name, which should never happen, e.g. "http" for "http".
* It also disallows HTML entities in the first path part of a relative path,
* e.g. "foo<bar/baz". Our existing escaping functions should not produce
* that. More importantly, it disallows masking of a colon,
* e.g. "javascript:...".
*
* This regular expression was taken from the Closure sanitization library.
*/
var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio types.
*/
var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\/]+=*$/i;
/**
* @param {?} url
* @return {?}
*/
function sanitizeUrl(url) {
url = String(url);
if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) return url;
if (_angular_core.isDevMode()) {
getDOM().log("WARNING: sanitizing unsafe URL value " + url + " (see http://g.co/ng/security#xss)");
}
return 'unsafe:' + url;
}
/**
* @param {?} srcset
* @return {?}
*/
function sanitizeSrcset(srcset) {
srcset = String(srcset);
return srcset.split(',').map(function (srcset) {
return sanitizeUrl(srcset.trim());
}).join(', ');
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
*/
var inertElement = null;
/**
* Lazily initialized to make sure the DOM adapter gets set before use.
*/
var DOM = /** @type {?} */null;
/**
* Returns an HTML element that is guaranteed to not execute code when creating elements in it.
* @return {?}
*/
function getInertElement() {
if (inertElement) return inertElement;
DOM = getDOM();
// Prefer using <template> element if supported.
var /** @type {?} */templateEl = DOM.createElement('template');
if ('content' in templateEl) return templateEl;
var /** @type {?} */doc = DOM.createHtmlDocument();
inertElement = DOM.querySelector(doc, 'body');
if (inertElement == null) {
// usually there should be only one body element in the document, but IE doesn't have any, so we
// need to create one.
var /** @type {?} */html = DOM.createElement('html', doc);
inertElement = DOM.createElement('body', doc);
DOM.appendChild(html, inertElement);
DOM.appendChild(doc, html);
}
return inertElement;
}
/**
* @param {?} tags
* @return {?}
*/
function tagSet(tags) {
var /** @type {?} */res = {};
for (var _i = 0, _a = tags.split(','); _i < _a.length; _i++) {
var t = _a[_i];
res[t] = true;
}
return res;
}
/**
* @param {...?} sets
* @return {?}
*/
function merge() {
var sets = [];
for (var _i = 0; _i < arguments.length; _i++) {
sets[_i] = arguments[_i];
}
var /** @type {?} */res = {};
for (var _a = 0, sets_1 = sets; _a < sets_1.length; _a++) {
var s = sets_1[_a];
for (var /** @type {?} */v in s) {
if (s.hasOwnProperty(v)) res[v] = true;
}
}
return res;
}
// Good source of info about elements and attributes
// http://dev.w3.org/html5/spec/Overview.html#semantics
// http://simon.html5.org/html-elements
// Safe Void Elements - HTML5
// http://dev.w3.org/html5/spec/Overview.html#void-elements
var VOID_ELEMENTS = tagSet('area,br,col,hr,img,wbr');
// Elements that you can, intentionally, leave open (and which close themselves)
// http://dev.w3.org/html5/spec/Overview.html#optional-tags
var OPTIONAL_END_TAG_BLOCK_ELEMENTS = tagSet('colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr');
var OPTIONAL_END_TAG_INLINE_ELEMENTS = tagSet('rp,rt');
var OPTIONAL_END_TAG_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, OPTIONAL_END_TAG_BLOCK_ELEMENTS);
// Safe Block Elements - HTML5
var BLOCK_ELEMENTS = merge(OPTIONAL_END_TAG_BLOCK_ELEMENTS, tagSet('address,article,' + 'aside,blockquote,caption,center,del,details,dialog,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,' + 'h6,header,hgroup,hr,ins,main,map,menu,nav,ol,pre,section,summary,table,ul'));
// Inline Elements - HTML5
var INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,acronym,audio,b,' + 'bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,picture,q,ruby,rp,rt,s,' + 'samp,small,source,span,strike,strong,sub,sup,time,track,tt,u,var,video'));
var VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
// Attributes that have href and hence need to be sanitized
var URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
// Attributes that have special href set hence need to be sanitized
var SRCSET_ATTRS = tagSet('srcset');
var HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' + 'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' + 'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' + 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' + 'valign,value,vspace,width');
// NB: This currently consciously doesn't support SVG. SVG sanitization has had several security
// issues in the past, so it seems safer to leave it out if possible. If support for binding SVG via
// innerHTML is required, SVG attributes should be added here.
// NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
// can be sanitized, but they increase security surface area without a legitimate use case, so they
// are left out here.
var VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS);
/**
* SanitizingHtmlSerializer serializes a DOM fragment, stripping out any unsafe elements and unsafe
* attributes.
*/
var SanitizingHtmlSerializer = /** @class */function () {
function SanitizingHtmlSerializer() {
this.sanitizedSomething = false;
this.buf = [];
}
/**
* @param {?} el
* @return {?}
*/
SanitizingHtmlSerializer.prototype.sanitizeChildren = /**
* @param {?} el
* @return {?}
*/
function (el) {
// This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
// However this code never accesses properties off of `document` before deleting its contents
// again, so it shouldn't be vulnerable to DOM clobbering.
var /** @type {?} */current = /** @type {?} */el.firstChild;
while (current) {
if (DOM.isElementNode(current)) {
this.startElement( /** @type {?} */current);
} else if (DOM.isTextNode(current)) {
this.chars( /** @type {?} */DOM.nodeValue(current));
} else {
// Strip non-element, non-text nodes.
this.sanitizedSomething = true;
}
if (DOM.firstChild(current)) {
current = /** @type {?} */DOM.firstChild(current);
continue;
}
while (current) {
// Leaving the element. Walk up and to the right, closing tags as we go.
if (DOM.isElementNode(current)) {
this.endElement( /** @type {?} */current);
}
var /** @type {?} */next = checkClobberedElement(current, /** @type {?} */DOM.nextSibling(current));
if (next) {
current = next;
break;
}
current = checkClobberedElement(current, /** @type {?} */DOM.parentElement(current));
}
}
return this.buf.join('');
};
/**
* @param {?} element
* @return {?}
*/
SanitizingHtmlSerializer.prototype.startElement = /**
* @param {?} element
* @return {?}
*/
function (element) {
var _this = this;
var /** @type {?} */tagName = DOM.nodeName(element).toLowerCase();
if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
this.sanitizedSomething = true;
return;
}
this.buf.push('<');
this.buf.push(tagName);
DOM.attributeMap(element).forEach(function (value, attrName) {
var /** @type {?} */lower = attrName.toLowerCase();
if (!VALID_ATTRS.hasOwnProperty(lower)) {
_this.sanitizedSomething = true;
return;
}
// TODO(martinprobst): Special case image URIs for data:image/...
if (URI_ATTRS[lower]) value = sanitizeUrl(value);
if (SRCSET_ATTRS[lower]) value = sanitizeSrcset(value);
_this.buf.push(' ');
_this.buf.push(attrName);
_this.buf.push('="');
_this.buf.push(encodeEntities(value));
_this.buf.push('"');
});
this.buf.push('>');
};
/**
* @param {?} current
* @return {?}
*/
SanitizingHtmlSerializer.prototype.endElement = /**
* @param {?} current
* @return {?}
*/
function (current) {
var /** @type {?} */tagName = DOM.nodeName(current).toLowerCase();
if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
this.buf.push('</');
this.buf.push(tagName);
this.buf.push('>');
}
};
/**
* @param {?} chars
* @return {?}
*/
SanitizingHtmlSerializer.prototype.chars = /**
* @param {?} chars
* @return {?}
*/
function (chars) {
this.buf.push(encodeEntities(chars));
};
return SanitizingHtmlSerializer;
}();
/**
* @param {?} node
* @param {?} nextNode
* @return {?}
*/
function checkClobberedElement(node, nextNode) {
if (nextNode && DOM.contains(node, nextNode)) {
throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
}
return nextNode;
}
// Regular Expressions for parsing tags and attributes
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
// ! to ~ is the ASCII range.
var NON_ALPHANUMERIC_REGEXP = /([^\#-~ |!])/g;
/**
* Escapes all potentially dangerous characters, so that the
* resulting string can be safely inserted into attribute or
* element text.
* @param {?} value
* @return {?}
*/
function encodeEntities(value) {
return value.replace(/&/g, '&').replace(SURROGATE_PAIR_REGEXP, function (match) {
var /** @type {?} */hi = match.charCodeAt(0);
var /** @type {?} */low = match.charCodeAt(1);
return '&#' + ((hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) + ';';
}).replace(NON_ALPHANUMERIC_REGEXP, function (match) {
return '&#' + match.charCodeAt(0) + ';';
}).replace(/</g, '<').replace(/>/g, '>');
}
/**
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
*
* This is undesirable since we don't want to allow any of these custom attributes. This method
* strips them all.
* @param {?} el
* @return {?}
*/
function stripCustomNsAttrs(el) {
DOM.attributeMap(el).forEach(function (_, attrName) {
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
DOM.removeAttribute(el, attrName);
}
});
for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
var n = _a[_i];
if (DOM.isElementNode(n)) stripCustomNsAttrs( /** @type {?} */n);
}
}
/**
* Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
* the DOM in a browser environment.
* @param {?} defaultDoc
* @param {?} unsafeHtmlInput
* @return {?}
*/
function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
try {
var /** @type {?} */containerEl = getInertElement();
// Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
var /** @type {?} */unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
// mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
// trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
var /** @type {?} */mXSSAttempts = 5;
var /** @type {?} */parsedHtml = unsafeHtml;
do {
if (mXSSAttempts === 0) {
throw new Error('Failed to sanitize html because the input is unstable');
}
mXSSAttempts--;
unsafeHtml = parsedHtml;
DOM.setInnerHTML(containerEl, unsafeHtml);
if (defaultDoc.documentMode) {
// strip custom-namespaced attributes on IE<=11
stripCustomNsAttrs(containerEl);
}
parsedHtml = DOM.getInnerHTML(containerEl);
} while (unsafeHtml !== parsedHtml);
var /** @type {?} */sanitizer = new SanitizingHtmlSerializer();
var /** @type {?} */safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(containerEl) || containerEl);
// Clear out the body element.
var /** @type {?} */parent_1 = DOM.getTemplateContent(containerEl) || containerEl;
for (var _i = 0, _a = DOM.childNodesAsList(parent_1); _i < _a.length; _i++) {
var child = _a[_i];
DOM.removeChild(parent_1, child);
}
if (_angular_core.isDevMode() && sanitizer.sanitizedSomething) {
DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
}
return safeHtml;
} catch ( /** @type {?} */e) {
// In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
inertElement = null;
throw e;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Regular expression for safe style values.
*
* Quotes (" and ') are allowed, but a check must be done elsewhere to ensure they're balanced.
*
* ',' allows multiple values to be assigned to the same property (e.g. background-attachment or
* font-family) and hence could allow multiple values to get injected, but that should pose no risk
* of XSS.
*
* The function expression checks only for XSS safety, not for CSS validity.
*
* This regular expression was taken from the Closure sanitization library, and augmented for
* transformation values.
*/
var VALUES = '[-,."\'%_!# a-zA-Z0-9]+';
var TRANSFORMATION_FNS = '(?:matrix|translate|scale|rotate|skew|perspective)(?:X|Y|3d)?';
var COLOR_FNS = '(?:rgb|hsl)a?';
var GRADIENTS = '(?:repeating-)?(?:linear|radial)-gradient';
var CSS3_FNS = '(?:calc|attr)';
var FN_ARGS = '\\([-0-9.%, #a-zA-Z]+\\)';
var SAFE_STYLE_VALUE = new RegExp("^(" + VALUES + "|" + ("(?:" + TRANSFORMATION_FNS + "|" + COLOR_FNS + "|" + GRADIENTS + "|" + CSS3_FNS + ")") + (FN_ARGS + ")$"), 'g');
/**
* Matches a `url(...)` value with an arbitrary argument as long as it does
* not contain parentheses.
*
* The URL value still needs to be sanitized separately.
*
* `url(...)` values are a very common use case, e.g. for `background-image`. With carefully crafted
* CSS style rules, it is possible to construct an information leak with `url` values in CSS, e.g.
* by observing whether scroll bars are displayed, or character ranges used by a font face
* definition.
*
* Angular only allows binding CSS values (as opposed to entire CSS rules), so it is unlikely that
* binding a URL value without further cooperation from the page will cause an information leak, and
* if so, it is just a leak, not a full blown XSS vulnerability.
*
* Given the common use case, low likelihood of attack vector, and low impact of an attack, this
* code is permissive and allows URLs that sanitize otherwise.
*/
var URL_RE = /^url\(([^)]+)\)$/;
/**
* Checks that quotes (" and ') are properly balanced inside a string. Assumes
* that neither escape (\) nor any other character that could result in
* breaking out of a string parsing context are allowed;
* see http://www.w3.org/TR/css3-syntax/#string-token-diagram.
*
* This code was taken from the Closure sanitization library.
* @param {?} value
* @return {?}
*/
function hasBalancedQuotes(value) {
var /** @type {?} */outsideSingle = true;
var /** @type {?} */outsideDouble = true;
for (var /** @type {?} */i = 0; i < value.length; i++) {
var /** @type {?} */c = value.charAt(i);
if (c === '\'' && outsideDouble) {
outsideSingle = !outsideSingle;
} else if (c === '"' && outsideSingle) {
outsideDouble = !outsideDouble;
}
}
return outsideSingle && outsideDouble;
}
/**
* Sanitizes the given untrusted CSS style property value (i.e. not an entire object, just a single
* value) and returns a value that is safe to use in a browser environment.
* @param {?} value
* @return {?}
*/
function sanitizeStyle(value) {
value = String(value).trim(); // Make sure it's actually a string.
if (!value) return '';
// Single url(...) values are supported, but only for URLs that sanitize cleanly. See above for
// reasoning behind this.
var /** @type {?} */urlMatch = value.match(URL_RE);
if (urlMatch && sanitizeUrl(urlMatch[1]) === urlMatch[1] || value.match(SAFE_STYLE_VALUE) && hasBalancedQuotes(value)) {
return value; // Safe style values.
}
if (_angular_core.isDevMode()) {
getDOM().log("WARNING: sanitizing unsafe style value " + value + " (see http://g.co/ng/security#xss).");
}
return 'unsafe';
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Marker interface for a value that's safe to use in a particular context.
*
* \@stable
* @record
*/
/**
* Marker interface for a value that's safe to use as HTML.
*
* \@stable
* @record
*/
/**
* Marker interface for a value that's safe to use as style (CSS).
*
* \@stable
* @record
*/
/**
* Marker interface for a value that's safe to use as JavaScript.
*
* \@stable
* @record
*/
/**
* Marker interface for a value that's safe to use as a URL linking to a document.
*
* \@stable
* @record
*/
/**
* Marker interface for a value that's safe to use as a URL to load executable code from.
*
* \@stable
* @record
*/
/**
* DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
* values to be safe to use in the different DOM contexts.
*
* For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
* sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
* the website.
*
* In specific situations, it might be necessary to disable sanitization, for example if the
* application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
* Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
* methods, and then binding to that value from the template.
*
* These situations should be very rare, and extraordinary care must be taken to avoid creating a
* Cross Site Scripting (XSS) security bug!
*
* When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
* close as possible to the source of the value, to make it easy to verify no security bug is
* created by its use.
*
* It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
* does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
* code. The sanitizer leaves safe values intact.
*
* \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
* sanitization for the value passed in. Carefully check and audit all values and code paths going
* into this call. Make sure any user data is appropriately escaped for this security context.
* For more detail, see the [Security Guide](http://g.co/ng/security).
*
* \@stable
* @abstract
*/
var DomSanitizer = /** @class */function () {
function DomSanitizer() {}
return DomSanitizer;
}();
var DomSanitizerImpl = /** @class */function (_super) {
__extends(DomSanitizerImpl, _super);
function DomSanitizerImpl(_doc) {
var _this = _super.call(this) || this;
_this._doc = _doc;
return _this;
}
/**
* @param {?} ctx
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.sanitize = /**
* @param {?} ctx
* @param {?} value
* @return {?}
*/
function (ctx, value) {
if (value == null) return null;
switch (ctx) {
case _angular_core.SecurityContext.NONE:
return (/** @type {?} */value
);
case _angular_core.SecurityContext.HTML:
if (value instanceof SafeHtmlImpl) return value.changingThisBreaksApplicationSecurity;
this.checkNotSafeValue(value, 'HTML');
return sanitizeHtml(this._doc, String(value));
case _angular_core.SecurityContext.STYLE:
if (value instanceof SafeStyleImpl) return value.changingThisBreaksApplicationSecurity;
this.checkNotSafeValue(value, 'Style');
return sanitizeStyle( /** @type {?} */value);
case _angular_core.SecurityContext.SCRIPT:
if (value instanceof SafeScriptImpl) return value.changingThisBreaksApplicationSecurity;
this.checkNotSafeValue(value, 'Script');
throw new Error('unsafe value used in a script context');
case _angular_core.SecurityContext.URL:
if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
// Allow resource URLs in URL contexts, they are strictly more trusted.
return value.changingThisBreaksApplicationSecurity;
}
this.checkNotSafeValue(value, 'URL');
return sanitizeUrl(String(value));
case _angular_core.SecurityContext.RESOURCE_URL:
if (value instanceof SafeResourceUrlImpl) {
return value.changingThisBreaksApplicationSecurity;
}
this.checkNotSafeValue(value, 'ResourceURL');
throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
default:
throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
}
};
/**
* @param {?} value
* @param {?} expectedType
* @return {?}
*/
DomSanitizerImpl.prototype.checkNotSafeValue = /**
* @param {?} value
* @param {?} expectedType
* @return {?}
*/
function (value, expectedType) {
if (value instanceof SafeValueImpl) {
throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " + "(see http://g.co/ng/security#xss)");
}
};
/**
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.bypassSecurityTrustHtml = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new SafeHtmlImpl(value);
};
/**
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.bypassSecurityTrustStyle = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new SafeStyleImpl(value);
};
/**
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.bypassSecurityTrustScript = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new SafeScriptImpl(value);
};
/**
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.bypassSecurityTrustUrl = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new SafeUrlImpl(value);
};
/**
* @param {?} value
* @return {?}
*/
DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new SafeResourceUrlImpl(value);
};
DomSanitizerImpl.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
DomSanitizerImpl.ctorParameters = function () {
return [{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1] }] }];
};
return DomSanitizerImpl;
}(DomSanitizer);
/**
* @abstract
*/
var SafeValueImpl = /** @class */function () {
function SafeValueImpl(changingThisBreaksApplicationSecurity) {
// empty
this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
}
/**
* @return {?}
*/
SafeValueImpl.prototype.toString = /**
* @return {?}
*/
function () {
return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity + " (see http://g.co/ng/security#xss)";
};
return SafeValueImpl;
}();
var SafeHtmlImpl = /** @class */function (_super) {
__extends(SafeHtmlImpl, _super);
function SafeHtmlImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
SafeHtmlImpl.prototype.getTypeName = /**
* @return {?}
*/
function () {
return 'HTML';
};
return SafeHtmlImpl;
}(SafeValueImpl);
var SafeStyleImpl = /** @class */function (_super) {
__extends(SafeStyleImpl, _super);
function SafeStyleImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
SafeStyleImpl.prototype.getTypeName = /**
* @return {?}
*/
function () {
return 'Style';
};
return SafeStyleImpl;
}(SafeValueImpl);
var SafeScriptImpl = /** @class */function (_super) {
__extends(SafeScriptImpl, _super);
function SafeScriptImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
SafeScriptImpl.prototype.getTypeName = /**
* @return {?}
*/
function () {
return 'Script';
};
return SafeScriptImpl;
}(SafeValueImpl);
var SafeUrlImpl = /** @class */function (_super) {
__extends(SafeUrlImpl, _super);
function SafeUrlImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
SafeUrlImpl.prototype.getTypeName = /**
* @return {?}
*/
function () {
return 'URL';
};
return SafeUrlImpl;
}(SafeValueImpl);
var SafeResourceUrlImpl = /** @class */function (_super) {
__extends(SafeResourceUrlImpl, _super);
function SafeResourceUrlImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
SafeResourceUrlImpl.prototype.getTypeName = /**
* @return {?}
*/
function () {
return 'ResourceURL';
};
return SafeResourceUrlImpl;
}(SafeValueImpl);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [{ provide: _angular_core.PLATFORM_ID, useValue: _angular_common.ɵPLATFORM_BROWSER_ID }, { provide: _angular_core.PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true }, { provide: _angular_common.PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT$1] }, { provide: DOCUMENT$1, useFactory: _document, deps: [] }];
/**
* \@security Replacing built-in sanitization providers exposes the application to XSS risks.
* Attacker-controlled data introduced by an unsanitized provider could expose your
* application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
* \@experimental
*/
var BROWSER_SANITIZATION_PROVIDERS = [{ provide: _angular_core.Sanitizer, useExisting: DomSanitizer }, { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT$1] }];
/**
* \@stable
*/
var platformBrowser = _angular_core.createPlatformFactory(_angular_core.platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
/**
* @return {?}
*/
function initDomAdapter() {
BrowserDomAdapter.makeCurrent();
BrowserGetTestability.init();
}
/**
* @return {?}
*/
function errorHandler() {
return new _angular_core.ErrorHandler();
}
/**
* @return {?}
*/
function _document() {
return document;
}
/**
* The ng module for the browser.
*
* \@stable
*/
var BrowserModule = /** @class */function () {
function BrowserModule(parentModule) {
if (parentModule) {
throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.");
}
}
/**
* Configures a browser-based application to transition from a server-rendered app, if
* one is present on the page. The specified parameters must include an application id,
* which must match between the client and server applications.
*
* @experimental
*/
/**
* Configures a browser-based application to transition from a server-rendered app, if
* one is present on the page. The specified parameters must include an application id,
* which must match between the client and server applications.
*
* \@experimental
* @param {?} params
* @return {?}
*/
BrowserModule.withServerTransition = /**
* Configures a browser-based application to transition from a server-rendered app, if
* one is present on the page. The specified parameters must include an application id,
* which must match between the client and server applications.
*
* \@experimental
* @param {?} params
* @return {?}
*/
function (params) {
return {
ngModule: BrowserModule,
providers: [{ provide: _angular_core.APP_ID, useValue: params.appId }, { provide: TRANSITION_ID, useExisting: _angular_core.APP_ID }, SERVER_TRANSITION_PROVIDERS]
};
};
BrowserModule.decorators = [{ type: _angular_core.NgModule, args: [{
providers: [BROWSER_SANITIZATION_PROVIDERS, { provide: _angular_core.ErrorHandler, useFactory: errorHandler, deps: [] }, { provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true }, { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true }, { provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true }, { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig }, DomRendererFactory2, { provide: _angular_core.RendererFactory2, useExisting: DomRendererFactory2 }, { provide: SharedStylesHost, useExisting: DomSharedStylesHost }, DomSharedStylesHost, _angular_core.Testability, EventManager, ELEMENT_PROBE_PROVIDERS, Meta, Title],
exports: [_angular_common.CommonModule, _angular_core.ApplicationModule]
}] }];
/** @nocollapse */
BrowserModule.ctorParameters = function () {
return [{ type: BrowserModule, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.SkipSelf }] }];
};
return BrowserModule;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var win = typeof window !== 'undefined' && window || /** @type {?} */{};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ChangeDetectionPerfRecord = /** @class */function () {
function ChangeDetectionPerfRecord(msPerTick, numTicks) {
this.msPerTick = msPerTick;
this.numTicks = numTicks;
}
return ChangeDetectionPerfRecord;
}();
/**
* Entry point for all Angular profiling-related debug tools. This object
* corresponds to the `ng.profiler` in the dev console.
*/
var AngularProfiler = /** @class */function () {
function AngularProfiler(ref) {
this.appRef = ref.injector.get(_angular_core.ApplicationRef);
}
// tslint:disable:no-console
/**
* Exercises change detection in a loop and then prints the average amount of
* time in milliseconds how long a single round of change detection takes for
* the current state of the UI. It runs a minimum of 5 rounds for a minimum
* of 500 milliseconds.
*
* Optionally, a user may pass a `config` parameter containing a map of
* options. Supported options are:
*
* `record` (boolean) - causes the profiler to record a CPU profile while
* it exercises the change detector. Example:
*
* ```
* ng.profiler.timeChangeDetection({record: true})
* ```
*/
/**
* Exercises change detection in a loop and then prints the average amount of
* time in milliseconds how long a single round of change detection takes for
* the current state of the UI. It runs a minimum of 5 rounds for a minimum
* of 500 milliseconds.
*
* Optionally, a user may pass a `config` parameter containing a map of
* options. Supported options are:
*
* `record` (boolean) - causes the profiler to record a CPU profile while
* it exercises the change detector. Example:
*
* ```
* ng.profiler.timeChangeDetection({record: true})
* ```
* @param {?} config
* @return {?}
*/
AngularProfiler.prototype.timeChangeDetection = /**
* Exercises change detection in a loop and then prints the average amount of
* time in milliseconds how long a single round of change detection takes for
* the current state of the UI. It runs a minimum of 5 rounds for a minimum
* of 500 milliseconds.
*
* Optionally, a user may pass a `config` parameter containing a map of
* options. Supported options are:
*
* `record` (boolean) - causes the profiler to record a CPU profile while
* it exercises the change detector. Example:
*
* ```
* ng.profiler.timeChangeDetection({record: true})
* ```
* @param {?} config
* @return {?}
*/
function (config) {
var /** @type {?} */record = config && config['record'];
var /** @type {?} */profileName = 'Change Detection';
// Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
var /** @type {?} */isProfilerAvailable = win.console.profile != null;
if (record && isProfilerAvailable) {
win.console.profile(profileName);
}
var /** @type {?} */start = getDOM().performanceNow();
var /** @type {?} */numTicks = 0;
while (numTicks < 5 || getDOM().performanceNow() - start < 500) {
this.appRef.tick();
numTicks++;
}
var /** @type {?} */end = getDOM().performanceNow();
if (record && isProfilerAvailable) {
// need to cast to <any> because type checker thinks there's no argument
// while in fact there is:
//
// https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
/** @type {?} */win.console.profileEnd(profileName);
}
var /** @type {?} */msPerTick = (end - start) / numTicks;
win.console.log("ran " + numTicks + " change detection cycles");
win.console.log(msPerTick.toFixed(2) + " ms per check");
return new ChangeDetectionPerfRecord(msPerTick, numTicks);
};
return AngularProfiler;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var PROFILER_GLOBAL_NAME = 'profiler';
/**
* Enabled Angular debug tools that are accessible via your browser's
* developer console.
*
* Usage:
*
* 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
* 1. Type `ng.` (usually the console will show auto-complete suggestion)
* 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
* then hit Enter.
*
* \@experimental All debugging apis are currently experimental.
* @template T
* @param {?} ref
* @return {?}
*/
function enableDebugTools(ref) {
exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
return ref;
}
/**
* Disables Angular tools.
*
* \@experimental All debugging apis are currently experimental.
* @return {?}
*/
function disableDebugTools() {
exportNgVar(PROFILER_GLOBAL_NAME, null);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} text
* @return {?}
*/
function escapeHtml(text) {
var /** @type {?} */escapedText = {
'&': '&a;',
'"': '&q;',
'\'': '&s;',
'<': '&l;',
'>': '&g;'
};
return text.replace(/[&"'<>]/g, function (s) {
return escapedText[s];
});
}
/**
* @param {?} text
* @return {?}
*/
function unescapeHtml(text) {
var /** @type {?} */unescapedText = {
'&a;': '&',
'&q;': '"',
'&s;': '\'',
'&l;': '<',
'&g;': '>'
};
return text.replace(/&[^;]+;/g, function (s) {
return unescapedText[s];
});
}
/**
* Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
*
* Example:
*
* ```
* const COUNTER_KEY = makeStateKey<number>('counter');
* let value = 10;
*
* transferState.set(COUNTER_KEY, value);
* ```
*
* \@experimental
* @template T
* @param {?} key
* @return {?}
*/
function makeStateKey(key) {
return (/** @type {?} */key
);
}
/**
* A key value store that is transferred from the application on the server side to the application
* on the client side.
*
* `TransferState` will be available as an injectable token. To use it import
* `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
*
* The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
* boolean, number, string, null and non-class objects will be serialized and deserialzied in a
* non-lossy manner.
*
* \@experimental
*/
var TransferState = /** @class */function () {
function TransferState() {
this.store = {};
this.onSerializeCallbacks = {};
}
/** @internal */
/**
* \@internal
* @param {?} initState
* @return {?}
*/
TransferState.init = /**
* \@internal
* @param {?} initState
* @return {?}
*/
function (initState) {
var /** @type {?} */transferState = new TransferState();
transferState.store = initState;
return transferState;
};
/**
* Get the value corresponding to a key. Return `defaultValue` if key is not found.
*/
/**
* Get the value corresponding to a key. Return `defaultValue` if key is not found.
* @template T
* @param {?} key
* @param {?} defaultValue
* @return {?}
*/
TransferState.prototype.get = /**
* Get the value corresponding to a key. Return `defaultValue` if key is not found.
* @template T
* @param {?} key
* @param {?} defaultValue
* @return {?}
*/
function (key, defaultValue) {
return (/** @type {?} */this.store[key] || defaultValue
);
};
/**
* Set the value corresponding to a key.
*/
/**
* Set the value corresponding to a key.
* @template T
* @param {?} key
* @param {?} value
* @return {?}
*/
TransferState.prototype.set = /**
* Set the value corresponding to a key.
* @template T
* @param {?} key
* @param {?} value
* @return {?}
*/
function (key, value) {
this.store[key] = value;
};
/**
* Remove a key from the store.
*/
/**
* Remove a key from the store.
* @template T
* @param {?} key
* @return {?}
*/
TransferState.prototype.remove = /**
* Remove a key from the store.
* @template T
* @param {?} key
* @return {?}
*/
function (key) {
delete this.store[key];
};
/**
* Test whether a key exists in the store.
*/
/**
* Test whether a key exists in the store.
* @template T
* @param {?} key
* @return {?}
*/
TransferState.prototype.hasKey = /**
* Test whether a key exists in the store.
* @template T
* @param {?} key
* @return {?}
*/
function (key) {
return this.store.hasOwnProperty(key);
};
/**
* Register a callback to provide the value for a key when `toJson` is called.
*/
/**
* Register a callback to provide the value for a key when `toJson` is called.
* @template T
* @param {?} key
* @param {?} callback
* @return {?}
*/
TransferState.prototype.onSerialize = /**
* Register a callback to provide the value for a key when `toJson` is called.
* @template T
* @param {?} key
* @param {?} callback
* @return {?}
*/
function (key, callback) {
this.onSerializeCallbacks[key] = callback;
};
/**
* Serialize the current state of the store to JSON.
*/
/**
* Serialize the current state of the store to JSON.
* @return {?}
*/
TransferState.prototype.toJson = /**
* Serialize the current state of the store to JSON.
* @return {?}
*/
function () {
// Call the onSerialize callbacks and put those values into the store.
for (var /** @type {?} */key in this.onSerializeCallbacks) {
if (this.onSerializeCallbacks.hasOwnProperty(key)) {
try {
this.store[key] = this.onSerializeCallbacks[key]();
} catch ( /** @type {?} */e) {
console.warn('Exception in onSerialize callback: ', e);
}
}
}
return JSON.stringify(this.store);
};
TransferState.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
TransferState.ctorParameters = function () {
return [];
};
return TransferState;
}();
/**
* @param {?} doc
* @param {?} appId
* @return {?}
*/
function initTransferState(doc, appId) {
// Locate the script tag with the JSON data transferred from the server.
// The id of the script tag is set to the Angular appId + 'state'.
var /** @type {?} */script = doc.getElementById(appId + '-state');
var /** @type {?} */initialState = {};
if (script && script.textContent) {
try {
initialState = JSON.parse(unescapeHtml(script.textContent));
} catch ( /** @type {?} */e) {
console.warn('Exception while restoring TransferState for app ' + appId, e);
}
}
return TransferState.init(initialState);
}
/**
* NgModule to install on the client side while using the `TransferState` to transfer state from
* server to client.
*
* \@experimental
*/
var BrowserTransferStateModule = /** @class */function () {
function BrowserTransferStateModule() {}
BrowserTransferStateModule.decorators = [{ type: _angular_core.NgModule, args: [{
providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT$1, _angular_core.APP_ID] }]
}] }];
/** @nocollapse */
BrowserTransferStateModule.ctorParameters = function () {
return [];
};
return BrowserTransferStateModule;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Predicates for use with {\@link DebugElement}'s query functions.
*
* \@experimental All debugging apis are currently experimental.
*/
var By = /** @class */function () {
function By() {}
/**
* Match all elements.
*
* ## Example
*
* {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
*/
/**
* Match all elements.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
* @return {?}
*/
By.all = /**
* Match all elements.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
* @return {?}
*/
function () {
return function (debugElement) {
return true;
};
};
/**
* Match elements by the given CSS selector.
*
* ## Example
*
* {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
*/
/**
* Match elements by the given CSS selector.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
* @param {?} selector
* @return {?}
*/
By.css = /**
* Match elements by the given CSS selector.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
* @param {?} selector
* @return {?}
*/
function (selector) {
return function (debugElement) {
return debugElement.nativeElement != null ? getDOM().elementMatches(debugElement.nativeElement, selector) : false;
};
};
/**
* Match elements that have the given directive present.
*
* ## Example
*
* {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
*/
/**
* Match elements that have the given directive present.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
* @param {?} type
* @return {?}
*/
By.directive = /**
* Match elements that have the given directive present.
*
* ## Example
*
* {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
* @param {?} type
* @return {?}
*/
function (type) {
return function (debugElement) {
return debugElement.providerTokens.indexOf(type) !== -1;
};
};
return By;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* \@stable
*/
var VERSION = new _angular_core.Version('5.1.0');
exports.BrowserModule = BrowserModule;
exports.platformBrowser = platformBrowser;
exports.Meta = Meta;
exports.Title = Title;
exports.disableDebugTools = disableDebugTools;
exports.enableDebugTools = enableDebugTools;
exports.BrowserTransferStateModule = BrowserTransferStateModule;
exports.TransferState = TransferState;
exports.makeStateKey = makeStateKey;
exports.By = By;
exports.DOCUMENT = DOCUMENT$1;
exports.EVENT_MANAGER_PLUGINS = EVENT_MANAGER_PLUGINS;
exports.EventManager = EventManager;
exports.HAMMER_GESTURE_CONFIG = HAMMER_GESTURE_CONFIG;
exports.HammerGestureConfig = HammerGestureConfig;
exports.DomSanitizer = DomSanitizer;
exports.VERSION = VERSION;
exports.ɵBROWSER_SANITIZATION_PROVIDERS = BROWSER_SANITIZATION_PROVIDERS;
exports.ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS = INTERNAL_BROWSER_PLATFORM_PROVIDERS;
exports.ɵinitDomAdapter = initDomAdapter;
exports.ɵBrowserDomAdapter = BrowserDomAdapter;
exports.ɵBrowserPlatformLocation = BrowserPlatformLocation;
exports.ɵTRANSITION_ID = TRANSITION_ID;
exports.ɵBrowserGetTestability = BrowserGetTestability;
exports.ɵescapeHtml = escapeHtml;
exports.ɵELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS;
exports.ɵDomAdapter = DomAdapter;
exports.ɵgetDOM = getDOM;
exports.ɵsetRootDomAdapter = setRootDomAdapter;
exports.ɵDomRendererFactory2 = DomRendererFactory2;
exports.ɵNAMESPACE_URIS = NAMESPACE_URIS;
exports.ɵflattenStyles = flattenStyles;
exports.ɵshimContentAttribute = shimContentAttribute;
exports.ɵshimHostAttribute = shimHostAttribute;
exports.ɵDomEventsPlugin = DomEventsPlugin;
exports.ɵHammerGesturesPlugin = HammerGesturesPlugin;
exports.ɵKeyEventsPlugin = KeyEventsPlugin;
exports.ɵDomSharedStylesHost = DomSharedStylesHost;
exports.ɵSharedStylesHost = SharedStylesHost;
exports.ɵb = _document;
exports.ɵa = errorHandler;
exports.ɵi = GenericBrowserDomAdapter;
exports.ɵg = SERVER_TRANSITION_PROVIDERS;
exports.ɵf = appInitializerFactory;
exports.ɵc = initTransferState;
exports.ɵh = _createNgProbe;
exports.ɵd = EventManagerPlugin;
exports.ɵe = DomSanitizerImpl;
Object.defineProperty(exports, '__esModule', { value: true });
});
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Observable'), require('@angular/platform-browser')) : 'function' === 'function' && true ? System.registerDynamic('@angular/http/bundles/http.umd.js', ['@angular/core', 'rxjs/Observable', '@angular/platform-browser'], false, function ($__require, $__exports, $__module) {
return factory.call($__exports, $__exports, $__require('@angular/core'), $__require('rxjs/Observable'), $__require('@angular/platform-browser'));
}) : factory((global.ng = global.ng || {}, global.ng.http = {}), global.ng.core, global.Rx, global.ng.platformBrowser);
})(this, function (exports, _angular_core, rxjs_Observable, _angular_platformBrowser) {
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A backend for http that uses the `XMLHttpRequest` browser API.
*
* Take care not to evaluate this in non-browser contexts.
*
* @deprecated use \@angular/common/http instead
*/
var BrowserXhr = /** @class */function () {
function BrowserXhr() {}
/**
* @return {?}
*/
BrowserXhr.prototype.build = /**
* @return {?}
*/
function () {
return (/** @type {?} */new XMLHttpRequest()
);
};
BrowserXhr.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
BrowserXhr.ctorParameters = function () {
return [];
};
return BrowserXhr;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/** @enum {number} */
var RequestMethod = {
Get: 0,
Post: 1,
Put: 2,
Delete: 3,
Options: 4,
Head: 5,
Patch: 6
};
RequestMethod[RequestMethod.Get] = "Get";
RequestMethod[RequestMethod.Post] = "Post";
RequestMethod[RequestMethod.Put] = "Put";
RequestMethod[RequestMethod.Delete] = "Delete";
RequestMethod[RequestMethod.Options] = "Options";
RequestMethod[RequestMethod.Head] = "Head";
RequestMethod[RequestMethod.Patch] = "Patch";
/** @enum {number} */
var ReadyState = {
Unsent: 0,
Open: 1,
HeadersReceived: 2,
Loading: 3,
Done: 4,
Cancelled: 5
};
ReadyState[ReadyState.Unsent] = "Unsent";
ReadyState[ReadyState.Open] = "Open";
ReadyState[ReadyState.HeadersReceived] = "HeadersReceived";
ReadyState[ReadyState.Loading] = "Loading";
ReadyState[ReadyState.Done] = "Done";
ReadyState[ReadyState.Cancelled] = "Cancelled";
/** @enum {number} */
var ResponseType = {
Basic: 0,
Cors: 1,
Default: 2,
Error: 3,
Opaque: 4
};
ResponseType[ResponseType.Basic] = "Basic";
ResponseType[ResponseType.Cors] = "Cors";
ResponseType[ResponseType.Default] = "Default";
ResponseType[ResponseType.Error] = "Error";
ResponseType[ResponseType.Opaque] = "Opaque";
/** @enum {number} */
var ContentType = {
NONE: 0,
JSON: 1,
FORM: 2,
FORM_DATA: 3,
TEXT: 4,
BLOB: 5,
ARRAY_BUFFER: 6
};
ContentType[ContentType.NONE] = "NONE";
ContentType[ContentType.JSON] = "JSON";
ContentType[ContentType.FORM] = "FORM";
ContentType[ContentType.FORM_DATA] = "FORM_DATA";
ContentType[ContentType.TEXT] = "TEXT";
ContentType[ContentType.BLOB] = "BLOB";
ContentType[ContentType.ARRAY_BUFFER] = "ARRAY_BUFFER";
/** @enum {number} */
var ResponseContentType = {
Text: 0,
Json: 1,
ArrayBuffer: 2,
Blob: 3
};
ResponseContentType[ResponseContentType.Text] = "Text";
ResponseContentType[ResponseContentType.Json] = "Json";
ResponseContentType[ResponseContentType.ArrayBuffer] = "ArrayBuffer";
ResponseContentType[ResponseContentType.Blob] = "Blob";
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Polyfill for [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers), as
* specified in the [Fetch Spec](https://fetch.spec.whatwg.org/#headers-class).
*
* The only known difference between this `Headers` implementation and the spec is the
* lack of an `entries` method.
*
* ### Example
*
* ```
* import {Headers} from '\@angular/http';
*
* var firstHeaders = new Headers();
* firstHeaders.append('Content-Type', 'image/jpeg');
* console.log(firstHeaders.get('Content-Type')) //'image/jpeg'
*
* // Create headers from Plain Old JavaScript Object
* var secondHeaders = new Headers({
* 'X-My-Custom-Header': 'Angular'
* });
* console.log(secondHeaders.get('X-My-Custom-Header')); //'Angular'
*
* var thirdHeaders = new Headers(secondHeaders);
* console.log(thirdHeaders.get('X-My-Custom-Header')); //'Angular'
* ```
*
* @deprecated use \@angular/common/http instead
*/
var Headers = /** @class */function () {
// TODO(vicb): any -> string|string[]
function Headers(headers) {
var _this = this;
/**
* \@internal header names are lower case
*/
this._headers = new Map();
/**
* \@internal map lower case names to actual names
*/
this._normalizedNames = new Map();
if (!headers) {
return;
}
if (headers instanceof Headers) {
headers.forEach(function (values, name) {
values.forEach(function (value) {
return _this.append(name, value);
});
});
return;
}
Object.keys(headers).forEach(function (name) {
var /** @type {?} */values = Array.isArray(headers[name]) ? headers[name] : [headers[name]];
_this.delete(name);
values.forEach(function (value) {
return _this.append(name, value);
});
});
}
/**
* Returns a new Headers instance from the given DOMString of Response Headers
*/
/**
* Returns a new Headers instance from the given DOMString of Response Headers
* @param {?} headersString
* @return {?}
*/
Headers.fromResponseHeaderString = /**
* Returns a new Headers instance from the given DOMString of Response Headers
* @param {?} headersString
* @return {?}
*/
function (headersString) {
var /** @type {?} */headers = new Headers();
headersString.split('\n').forEach(function (line) {
var /** @type {?} */index = line.indexOf(':');
if (index > 0) {
var /** @type {?} */name_1 = line.slice(0, index);
var /** @type {?} */value = line.slice(index + 1).trim();
headers.set(name_1, value);
}
});
return headers;
};
/**
* Appends a header to existing list of header values for a given header name.
*/
/**
* Appends a header to existing list of header values for a given header name.
* @param {?} name
* @param {?} value
* @return {?}
*/
Headers.prototype.append = /**
* Appends a header to existing list of header values for a given header name.
* @param {?} name
* @param {?} value
* @return {?}
*/
function (name, value) {
var /** @type {?} */values = this.getAll(name);
if (values === null) {
this.set(name, value);
} else {
values.push(value);
}
};
/**
* Deletes all header values for the given name.
*/
/**
* Deletes all header values for the given name.
* @param {?} name
* @return {?}
*/
Headers.prototype.delete = /**
* Deletes all header values for the given name.
* @param {?} name
* @return {?}
*/
function (name) {
var /** @type {?} */lcName = name.toLowerCase();
this._normalizedNames.delete(lcName);
this._headers.delete(lcName);
};
/**
* @param {?} fn
* @return {?}
*/
Headers.prototype.forEach = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var _this = this;
this._headers.forEach(function (values, lcName) {
return fn(values, _this._normalizedNames.get(lcName), _this._headers);
});
};
/**
* Returns first header that matches given name.
*/
/**
* Returns first header that matches given name.
* @param {?} name
* @return {?}
*/
Headers.prototype.get = /**
* Returns first header that matches given name.
* @param {?} name
* @return {?}
*/
function (name) {
var /** @type {?} */values = this.getAll(name);
if (values === null) {
return null;
}
return values.length > 0 ? values[0] : null;
};
/**
* Checks for existence of header by given name.
*/
/**
* Checks for existence of header by given name.
* @param {?} name
* @return {?}
*/
Headers.prototype.has = /**
* Checks for existence of header by given name.
* @param {?} name
* @return {?}
*/
function (name) {
return this._headers.has(name.toLowerCase());
};
/**
* Returns the names of the headers
*/
/**
* Returns the names of the headers
* @return {?}
*/
Headers.prototype.keys = /**
* Returns the names of the headers
* @return {?}
*/
function () {
return Array.from(this._normalizedNames.values());
};
/**
* Sets or overrides header value for given name.
*/
/**
* Sets or overrides header value for given name.
* @param {?} name
* @param {?} value
* @return {?}
*/
Headers.prototype.set = /**
* Sets or overrides header value for given name.
* @param {?} name
* @param {?} value
* @return {?}
*/
function (name, value) {
if (Array.isArray(value)) {
if (value.length) {
this._headers.set(name.toLowerCase(), [value.join(',')]);
}
} else {
this._headers.set(name.toLowerCase(), [value]);
}
this.mayBeSetNormalizedName(name);
};
/**
* Returns values of all headers.
*/
/**
* Returns values of all headers.
* @return {?}
*/
Headers.prototype.values = /**
* Returns values of all headers.
* @return {?}
*/
function () {
return Array.from(this._headers.values());
};
/**
* Returns string of all headers.
*/
// TODO(vicb): returns {[name: string]: string[]}
/**
* Returns string of all headers.
* @return {?}
*/
Headers.prototype.toJSON = /**
* Returns string of all headers.
* @return {?}
*/
function () {
var _this = this;
var /** @type {?} */serialized = {};
this._headers.forEach(function (values, name) {
var /** @type {?} */split = [];
values.forEach(function (v) {
return split.push.apply(split, v.split(','));
});
serialized[/** @type {?} */_this._normalizedNames.get(name)] = split;
});
return serialized;
};
/**
* Returns list of header values for a given name.
*/
/**
* Returns list of header values for a given name.
* @param {?} name
* @return {?}
*/
Headers.prototype.getAll = /**
* Returns list of header values for a given name.
* @param {?} name
* @return {?}
*/
function (name) {
return this.has(name) ? this._headers.get(name.toLowerCase()) || null : null;
};
/**
* This method is not implemented.
*/
/**
* This method is not implemented.
* @return {?}
*/
Headers.prototype.entries = /**
* This method is not implemented.
* @return {?}
*/
function () {
throw new Error('"entries" method is not implemented on Headers class');
};
/**
* @param {?} name
* @return {?}
*/
Headers.prototype.mayBeSetNormalizedName = /**
* @param {?} name
* @return {?}
*/
function (name) {
var /** @type {?} */lcName = name.toLowerCase();
if (!this._normalizedNames.has(lcName)) {
this._normalizedNames.set(lcName, name);
}
};
return Headers;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Creates a response options object to be optionally provided when instantiating a
* {\@link Response}.
*
* This class is based on the `ResponseInit` description in the [Fetch
* Spec](https://fetch.spec.whatwg.org/#responseinit).
*
* All values are null by default. Typical defaults can be found in the
* {\@link BaseResponseOptions} class, which sub-classes `ResponseOptions`.
*
* This class may be used in tests to build {\@link Response Responses} for
* mock responses (see {\@link MockBackend}).
*
* ### Example ([live demo](http://plnkr.co/edit/P9Jkk8e8cz6NVzbcxEsD?p=preview))
*
* ```typescript
* import {ResponseOptions, Response} from '\@angular/http';
*
* var options = new ResponseOptions({
* body: '{"name":"Jeff"}'
* });
* var res = new Response(options);
*
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
* ```
*
* @deprecated use \@angular/common/http instead
*/
var ResponseOptions = /** @class */function () {
function ResponseOptions(opts) {
if (opts === void 0) {
opts = {};
}
var body = opts.body,
status = opts.status,
headers = opts.headers,
statusText = opts.statusText,
type = opts.type,
url = opts.url;
this.body = body != null ? body : null;
this.status = status != null ? status : null;
this.headers = headers != null ? headers : null;
this.statusText = statusText != null ? statusText : null;
this.type = type != null ? type : null;
this.url = url != null ? url : null;
}
/**
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to
* override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* This may be useful when sharing a base `ResponseOptions` object inside tests,
* where certain properties may change from test to test.
*
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
*
* ```typescript
* import {ResponseOptions, Response} from '@angular/http';
*
* var options = new ResponseOptions({
* body: {name: 'Jeff'}
* });
* var res = new Response(options.merge({
* url: 'https://google.com'
* }));
* console.log('options.url:', options.url); // null
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
* console.log('res.url:', res.url); // https://google.com
* ```
*/
/**
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to
* override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* This may be useful when sharing a base `ResponseOptions` object inside tests,
* where certain properties may change from test to test.
*
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
*
* ```typescript
* import {ResponseOptions, Response} from '\@angular/http';
*
* var options = new ResponseOptions({
* body: {name: 'Jeff'}
* });
* var res = new Response(options.merge({
* url: 'https://google.com'
* }));
* console.log('options.url:', options.url); // null
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
* console.log('res.url:', res.url); // https://google.com
* ```
* @param {?=} options
* @return {?}
*/
ResponseOptions.prototype.merge = /**
* Creates a copy of the `ResponseOptions` instance, using the optional input as values to
* override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* This may be useful when sharing a base `ResponseOptions` object inside tests,
* where certain properties may change from test to test.
*
* ### Example ([live demo](http://plnkr.co/edit/1lXquqFfgduTFBWjNoRE?p=preview))
*
* ```typescript
* import {ResponseOptions, Response} from '\@angular/http';
*
* var options = new ResponseOptions({
* body: {name: 'Jeff'}
* });
* var res = new Response(options.merge({
* url: 'https://google.com'
* }));
* console.log('options.url:', options.url); // null
* console.log('res.json():', res.json()); // Object {name: "Jeff"}
* console.log('res.url:', res.url); // https://google.com
* ```
* @param {?=} options
* @return {?}
*/
function (options) {
return new ResponseOptions({
body: options && options.body != null ? options.body : this.body,
status: options && options.status != null ? options.status : this.status,
headers: options && options.headers != null ? options.headers : this.headers,
statusText: options && options.statusText != null ? options.statusText : this.statusText,
type: options && options.type != null ? options.type : this.type,
url: options && options.url != null ? options.url : this.url
});
};
return ResponseOptions;
}();
/**
* Subclass of {\@link ResponseOptions}, with default values.
*
* Default values:
* * status: 200
* * headers: empty {\@link Headers} object
*
* This class could be extended and bound to the {\@link ResponseOptions} class
* when configuring an {\@link Injector}, in order to override the default options
* used by {\@link Http} to create {\@link Response Responses}.
*
* ### Example ([live demo](http://plnkr.co/edit/qv8DLT?p=preview))
*
* ```typescript
* import {provide} from '\@angular/core';
* import {bootstrap} from '\@angular/platform-browser/browser';
* import {HTTP_PROVIDERS, Headers, Http, BaseResponseOptions, ResponseOptions} from
* '\@angular/http';
* import {App} from './myapp';
*
* class MyOptions extends BaseResponseOptions {
* headers:Headers = new Headers({network: 'github'});
* }
*
* bootstrap(App, [HTTP_PROVIDERS, {provide: ResponseOptions, useClass: MyOptions}]);
* ```
*
* The options could also be extended when manually creating a {\@link Response}
* object.
*
* ### Example ([live demo](http://plnkr.co/edit/VngosOWiaExEtbstDoix?p=preview))
*
* ```
* import {BaseResponseOptions, Response} from '\@angular/http';
*
* var options = new BaseResponseOptions();
* var res = new Response(options.merge({
* body: 'Angular',
* headers: new Headers({framework: 'angular'})
* }));
* console.log('res.headers.get("framework"):', res.headers.get('framework')); // angular
* console.log('res.text():', res.text()); // Angular;
* ```
*
* @deprecated use \@angular/common/http instead
*/
var BaseResponseOptions = /** @class */function (_super) {
__extends(BaseResponseOptions, _super);
function BaseResponseOptions() {
return _super.call(this, { status: 200, statusText: 'Ok', type: ResponseType.Default, headers: new Headers() }) || this;
}
BaseResponseOptions.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
BaseResponseOptions.ctorParameters = function () {
return [];
};
return BaseResponseOptions;
}(ResponseOptions);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Abstract class from which real backends are derived.
*
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
* {\@link Request}.
*
* @deprecated use \@angular/common/http instead
* @abstract
*/
var ConnectionBackend = /** @class */function () {
function ConnectionBackend() {}
return ConnectionBackend;
}();
/**
* Abstract class from which real connections are derived.
*
* @deprecated use \@angular/common/http instead
* @abstract
*/
var Connection = /** @class */function () {
function Connection() {}
return Connection;
}();
/**
* An XSRFStrategy configures XSRF protection (e.g. via headers) on an HTTP request.
*
* @deprecated use \@angular/common/http instead
* @abstract
*/
var XSRFStrategy = /** @class */function () {
function XSRFStrategy() {}
return XSRFStrategy;
}();
/**
* Interface for options to construct a RequestOptions, based on
* [RequestInit](https://fetch.spec.whatwg.org/#requestinit) from the Fetch spec.
*
* @deprecated use \@angular/common/http instead
* @record
*/
/**
* Required structure when constructing new Request();
* @record
*/
/**
* Interface for options to construct a Response, based on
* [ResponseInit](https://fetch.spec.whatwg.org/#responseinit) from the Fetch spec.
*
* @deprecated use \@angular/common/http instead
* @record
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} method
* @return {?}
*/
function normalizeMethodName(method) {
if (typeof method !== 'string') return method;
switch (method.toUpperCase()) {
case 'GET':
return RequestMethod.Get;
case 'POST':
return RequestMethod.Post;
case 'PUT':
return RequestMethod.Put;
case 'DELETE':
return RequestMethod.Delete;
case 'OPTIONS':
return RequestMethod.Options;
case 'HEAD':
return RequestMethod.Head;
case 'PATCH':
return RequestMethod.Patch;
}
throw new Error("Invalid request method. The method \"" + method + "\" is not supported.");
}
var isSuccess = function (status) {
return status >= 200 && status < 300;
};
/**
* @param {?} xhr
* @return {?}
*/
function getResponseURL(xhr) {
if ('responseURL' in xhr) {
return xhr.responseURL;
}
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-Request-URL');
}
return null;
}
/**
* @param {?} input
* @return {?}
*/
/**
* @param {?} input
* @return {?}
*/
function stringToArrayBuffer(input) {
var /** @type {?} */view = new Uint16Array(input.length);
for (var /** @type {?} */i = 0, /** @type {?} */strLen = input.length; i < strLen; i++) {
view[i] = input.charCodeAt(i);
}
return view.buffer;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?=} rawParams
* @return {?}
*/
function paramParser(rawParams) {
if (rawParams === void 0) {
rawParams = '';
}
var /** @type {?} */map = new Map();
if (rawParams.length > 0) {
var /** @type {?} */params = rawParams.split('&');
params.forEach(function (param) {
var /** @type {?} */eqIdx = param.indexOf('=');
var _a = eqIdx == -1 ? [param, ''] : [param.slice(0, eqIdx), param.slice(eqIdx + 1)],
key = _a[0],
val = _a[1];
var /** @type {?} */list = map.get(key) || [];
list.push(val);
map.set(key, list);
});
}
return map;
}
/**
* @deprecated use \@angular/common/http instead
*
*/
var QueryEncoder = /** @class */function () {
function QueryEncoder() {}
/**
* @param {?} k
* @return {?}
*/
QueryEncoder.prototype.encodeKey = /**
* @param {?} k
* @return {?}
*/
function (k) {
return standardEncoding(k);
};
/**
* @param {?} v
* @return {?}
*/
QueryEncoder.prototype.encodeValue = /**
* @param {?} v
* @return {?}
*/
function (v) {
return standardEncoding(v);
};
return QueryEncoder;
}();
/**
* @param {?} v
* @return {?}
*/
function standardEncoding(v) {
return encodeURIComponent(v).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/gi, '$').replace(/%2C/gi, ',').replace(/%3B/gi, ';').replace(/%2B/gi, '+').replace(/%3D/gi, '=').replace(/%3F/gi, '?').replace(/%2F/gi, '/');
}
/**
* Map-like representation of url search parameters, based on
* [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
* with several extensions for merging URLSearchParams objects:
* - setAll()
* - appendAll()
* - replaceAll()
*
* This class accepts an optional second parameter of ${\@link QueryEncoder},
* which is used to serialize parameters before making a request. By default,
* `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`,
* and then un-encodes certain characters that are allowed to be part of the query
* according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
*
* These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /`
*
* If the set of allowed query characters is not acceptable for a particular backend,
* `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams.
*
* ```
* import {URLSearchParams, QueryEncoder} from '\@angular/http';
* class MyQueryEncoder extends QueryEncoder {
* encodeKey(k: string): string {
* return myEncodingFunction(k);
* }
*
* encodeValue(v: string): string {
* return myEncodingFunction(v);
* }
* }
*
* let params = new URLSearchParams('', new MyQueryEncoder());
* ```
* @deprecated use \@angular/common/http instead
*/
var URLSearchParams = /** @class */function () {
function URLSearchParams(rawParams, queryEncoder) {
if (rawParams === void 0) {
rawParams = '';
}
if (queryEncoder === void 0) {
queryEncoder = new QueryEncoder();
}
this.rawParams = rawParams;
this.queryEncoder = queryEncoder;
this.paramsMap = paramParser(rawParams);
}
/**
* @return {?}
*/
URLSearchParams.prototype.clone = /**
* @return {?}
*/
function () {
var /** @type {?} */clone = new URLSearchParams('', this.queryEncoder);
clone.appendAll(this);
return clone;
};
/**
* @param {?} param
* @return {?}
*/
URLSearchParams.prototype.has = /**
* @param {?} param
* @return {?}
*/
function (param) {
return this.paramsMap.has(param);
};
/**
* @param {?} param
* @return {?}
*/
URLSearchParams.prototype.get = /**
* @param {?} param
* @return {?}
*/
function (param) {
var /** @type {?} */storedParam = this.paramsMap.get(param);
return Array.isArray(storedParam) ? storedParam[0] : null;
};
/**
* @param {?} param
* @return {?}
*/
URLSearchParams.prototype.getAll = /**
* @param {?} param
* @return {?}
*/
function (param) {
return this.paramsMap.get(param) || [];
};
/**
* @param {?} param
* @param {?} val
* @return {?}
*/
URLSearchParams.prototype.set = /**
* @param {?} param
* @param {?} val
* @return {?}
*/
function (param, val) {
if (val === void 0 || val === null) {
this.delete(param);
return;
}
var /** @type {?} */list = this.paramsMap.get(param) || [];
list.length = 0;
list.push(val);
this.paramsMap.set(param, list);
};
// A merge operation
// For each name-values pair in `searchParams`, perform `set(name, values[0])`
//
// E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4], c=[8], b=[7]"
//
// TODO(@caitp): document this better
/**
* @param {?} searchParams
* @return {?}
*/
URLSearchParams.prototype.setAll = /**
* @param {?} searchParams
* @return {?}
*/
function (searchParams) {
var _this = this;
searchParams.paramsMap.forEach(function (value, param) {
var /** @type {?} */list = _this.paramsMap.get(param) || [];
list.length = 0;
list.push(value[0]);
_this.paramsMap.set(param, list);
});
};
/**
* @param {?} param
* @param {?} val
* @return {?}
*/
URLSearchParams.prototype.append = /**
* @param {?} param
* @param {?} val
* @return {?}
*/
function (param, val) {
if (val === void 0 || val === null) return;
var /** @type {?} */list = this.paramsMap.get(param) || [];
list.push(val);
this.paramsMap.set(param, list);
};
// A merge operation
// For each name-values pair in `searchParams`, perform `append(name, value)`
// for each value in `values`.
//
// E.g: "a=[1,2], c=[8]" + "a=[3,4], b=[7]" = "a=[1,2,3,4], c=[8], b=[7]"
//
// TODO(@caitp): document this better
/**
* @param {?} searchParams
* @return {?}
*/
URLSearchParams.prototype.appendAll = /**
* @param {?} searchParams
* @return {?}
*/
function (searchParams) {
var _this = this;
searchParams.paramsMap.forEach(function (value, param) {
var /** @type {?} */list = _this.paramsMap.get(param) || [];
for (var /** @type {?} */i = 0; i < value.length; ++i) {
list.push(value[i]);
}
_this.paramsMap.set(param, list);
});
};
// A merge operation
// For each name-values pair in `searchParams`, perform `delete(name)`,
// followed by `set(name, values)`
//
// E.g: "a=[1,2,3], c=[8]" + "a=[4,5,6], b=[7]" = "a=[4,5,6], c=[8], b=[7]"
//
// TODO(@caitp): document this better
/**
* @param {?} searchParams
* @return {?}
*/
URLSearchParams.prototype.replaceAll = /**
* @param {?} searchParams
* @return {?}
*/
function (searchParams) {
var _this = this;
searchParams.paramsMap.forEach(function (value, param) {
var /** @type {?} */list = _this.paramsMap.get(param) || [];
list.length = 0;
for (var /** @type {?} */i = 0; i < value.length; ++i) {
list.push(value[i]);
}
_this.paramsMap.set(param, list);
});
};
/**
* @return {?}
*/
URLSearchParams.prototype.toString = /**
* @return {?}
*/
function () {
var _this = this;
var /** @type {?} */paramsList = [];
this.paramsMap.forEach(function (values, k) {
values.forEach(function (v) {
return paramsList.push(_this.queryEncoder.encodeKey(k) + '=' + _this.queryEncoder.encodeValue(v));
});
});
return paramsList.join('&');
};
/**
* @param {?} param
* @return {?}
*/
URLSearchParams.prototype.delete = /**
* @param {?} param
* @return {?}
*/
function (param) {
this.paramsMap.delete(param);
};
return URLSearchParams;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* HTTP request body used by both {\@link Request} and {\@link Response}
* https://fetch.spec.whatwg.org/#body
* @abstract
*/
var Body = /** @class */function () {
function Body() {}
/**
* Attempts to return body as parsed `JSON` object, or raises an exception.
*/
/**
* Attempts to return body as parsed `JSON` object, or raises an exception.
* @return {?}
*/
Body.prototype.json = /**
* Attempts to return body as parsed `JSON` object, or raises an exception.
* @return {?}
*/
function () {
if (typeof this._body === 'string') {
return JSON.parse( /** @type {?} */this._body);
}
if (this._body instanceof ArrayBuffer) {
return JSON.parse(this.text());
}
return this._body;
};
/**
* Returns the body as a string, presuming `toString()` can be called on the response body.
*
* When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
* bytes in the buffer will be interpreted. Valid values are:
*
* - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
* in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
* In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
* into consideration. This is the default behavior to avoid breaking apps, but should be
* considered deprecated.
*
* - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
*/
/**
* Returns the body as a string, presuming `toString()` can be called on the response body.
*
* When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
* bytes in the buffer will be interpreted. Valid values are:
*
* - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
* in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
* In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
* into consideration. This is the default behavior to avoid breaking apps, but should be
* considered deprecated.
*
* - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
* @param {?=} encodingHint
* @return {?}
*/
Body.prototype.text = /**
* Returns the body as a string, presuming `toString()` can be called on the response body.
*
* When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
* bytes in the buffer will be interpreted. Valid values are:
*
* - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
* in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
* In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
* into consideration. This is the default behavior to avoid breaking apps, but should be
* considered deprecated.
*
* - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
* @param {?=} encodingHint
* @return {?}
*/
function (encodingHint) {
if (encodingHint === void 0) {
encodingHint = 'legacy';
}
if (this._body instanceof URLSearchParams) {
return this._body.toString();
}
if (this._body instanceof ArrayBuffer) {
switch (encodingHint) {
case 'legacy':
return String.fromCharCode.apply(null, new Uint16Array( /** @type {?} */this._body));
case 'iso-8859':
return String.fromCharCode.apply(null, new Uint8Array( /** @type {?} */this._body));
default:
throw new Error("Invalid value for encodingHint: " + encodingHint);
}
}
if (this._body == null) {
return '';
}
if (typeof this._body === 'object') {
return JSON.stringify(this._body, null, 2);
}
return this._body.toString();
};
/**
* Return the body as an ArrayBuffer
*/
/**
* Return the body as an ArrayBuffer
* @return {?}
*/
Body.prototype.arrayBuffer = /**
* Return the body as an ArrayBuffer
* @return {?}
*/
function () {
if (this._body instanceof ArrayBuffer) {
return (/** @type {?} */this._body
);
}
return stringToArrayBuffer(this.text());
};
/**
* Returns the request's body as a Blob, assuming that body exists.
*/
/**
* Returns the request's body as a Blob, assuming that body exists.
* @return {?}
*/
Body.prototype.blob = /**
* Returns the request's body as a Blob, assuming that body exists.
* @return {?}
*/
function () {
if (this._body instanceof Blob) {
return (/** @type {?} */this._body
);
}
if (this._body instanceof ArrayBuffer) {
return new Blob([this._body]);
}
throw new Error('The request body isn\'t either a blob or an array buffer');
};
return Body;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Creates `Response` instances from provided values.
*
* Though this object isn't
* usually instantiated by end-users, it is the primary object interacted with when it comes time to
* add data to a view.
*
* ### Example
*
* ```
* http.request('my-friends.txt').subscribe(response => this.friends = response.text());
* ```
*
* The Response's interface is inspired by the Response constructor defined in the [Fetch
* Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
* can be accessed many times. There are other differences in the implementation, but this is the
* most significant.
*
* @deprecated use \@angular/common/http instead
*/
var Response = /** @class */function (_super) {
__extends(Response, _super);
function Response(responseOptions) {
var _this = _super.call(this) || this;
_this._body = responseOptions.body;
_this.status = /** @type {?} */responseOptions.status;
_this.ok = _this.status >= 200 && _this.status <= 299;
_this.statusText = responseOptions.statusText;
_this.headers = responseOptions.headers;
_this.type = /** @type {?} */responseOptions.type;
_this.url = /** @type {?} */responseOptions.url;
return _this;
}
/**
* @return {?}
*/
Response.prototype.toString = /**
* @return {?}
*/
function () {
return "Response with status: " + this.status + " " + this.statusText + " for URL: " + this.url;
};
return Response;
}(Body);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _nextRequestId = 0;
var JSONP_HOME = '__ng_jsonp__';
var _jsonpConnections = null;
/**
* @return {?}
*/
function _getJsonpConnections() {
var /** @type {?} */w = typeof window == 'object' ? window : {};
if (_jsonpConnections === null) {
_jsonpConnections = w[JSONP_HOME] = {};
}
return _jsonpConnections;
}
var BrowserJsonp = /** @class */function () {
function BrowserJsonp() {}
// Construct a <script> element with the specified URL
/**
* @param {?} url
* @return {?}
*/
BrowserJsonp.prototype.build = /**
* @param {?} url
* @return {?}
*/
function (url) {
var /** @type {?} */node = document.createElement('script');
node.src = url;
return node;
};
/**
* @return {?}
*/
BrowserJsonp.prototype.nextRequestID = /**
* @return {?}
*/
function () {
return "__req" + _nextRequestId++;
};
/**
* @param {?} id
* @return {?}
*/
BrowserJsonp.prototype.requestCallback = /**
* @param {?} id
* @return {?}
*/
function (id) {
return JSONP_HOME + "." + id + ".finished";
};
/**
* @param {?} id
* @param {?} connection
* @return {?}
*/
BrowserJsonp.prototype.exposeConnection = /**
* @param {?} id
* @param {?} connection
* @return {?}
*/
function (id, connection) {
var /** @type {?} */connections = _getJsonpConnections();
connections[id] = connection;
};
/**
* @param {?} id
* @return {?}
*/
BrowserJsonp.prototype.removeConnection = /**
* @param {?} id
* @return {?}
*/
function (id) {
var /** @type {?} */connections = _getJsonpConnections();
connections[id] = null;
};
// Attach the <script> element to the DOM
/**
* @param {?} node
* @return {?}
*/
BrowserJsonp.prototype.send = /**
* @param {?} node
* @return {?}
*/
function (node) {
document.body.appendChild( /** @type {?} */node);
};
// Remove <script> element from the DOM
/**
* @param {?} node
* @return {?}
*/
BrowserJsonp.prototype.cleanup = /**
* @param {?} node
* @return {?}
*/
function (node) {
if (node.parentNode) {
node.parentNode.removeChild( /** @type {?} */node);
}
};
BrowserJsonp.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
BrowserJsonp.ctorParameters = function () {
return [];
};
return BrowserJsonp;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
/**
* Base class for an in-flight JSONP request.
*
* @deprecated use \@angular/common/http instead
*/
var JSONPConnection = /** @class */function () {
/** @internal */
function JSONPConnection(req, _dom, baseResponseOptions) {
var _this = this;
this._dom = _dom;
this.baseResponseOptions = baseResponseOptions;
this._finished = false;
if (req.method !== RequestMethod.Get) {
throw new TypeError(JSONP_ERR_WRONG_METHOD);
}
this.request = req;
this.response = new rxjs_Observable.Observable(function (responseObserver) {
_this.readyState = ReadyState.Loading;
var /** @type {?} */id = _this._id = _dom.nextRequestID();
_dom.exposeConnection(id, _this);
// Workaround Dart
// url = url.replace(/=JSONP_CALLBACK(&|$)/, `generated method`);
var /** @type {?} */callback = _dom.requestCallback(_this._id);
var /** @type {?} */url = req.url;
if (url.indexOf('=JSONP_CALLBACK&') > -1) {
url = url.replace('=JSONP_CALLBACK&', "=" + callback + "&");
} else if (url.lastIndexOf('=JSONP_CALLBACK') === url.length - '=JSONP_CALLBACK'.length) {
url = url.substring(0, url.length - '=JSONP_CALLBACK'.length) + ("=" + callback);
}
var /** @type {?} */script = _this._script = _dom.build(url);
var /** @type {?} */onLoad = function (event) {
if (_this.readyState === ReadyState.Cancelled) return;
_this.readyState = ReadyState.Done;
_dom.cleanup(script);
if (!_this._finished) {
var /** @type {?} */responseOptions_1 = new ResponseOptions({ body: JSONP_ERR_NO_CALLBACK, type: ResponseType.Error, url: url });
if (baseResponseOptions) {
responseOptions_1 = baseResponseOptions.merge(responseOptions_1);
}
responseObserver.error(new Response(responseOptions_1));
return;
}
var /** @type {?} */responseOptions = new ResponseOptions({ body: _this._responseData, url: url });
if (_this.baseResponseOptions) {
responseOptions = _this.baseResponseOptions.merge(responseOptions);
}
responseObserver.next(new Response(responseOptions));
responseObserver.complete();
};
var /** @type {?} */onError = function (error) {
if (_this.readyState === ReadyState.Cancelled) return;
_this.readyState = ReadyState.Done;
_dom.cleanup(script);
var /** @type {?} */responseOptions = new ResponseOptions({ body: error.message, type: ResponseType.Error });
if (baseResponseOptions) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
responseObserver.error(new Response(responseOptions));
};
script.addEventListener('load', onLoad);
script.addEventListener('error', onError);
_dom.send(script);
return function () {
_this.readyState = ReadyState.Cancelled;
script.removeEventListener('load', onLoad);
script.removeEventListener('error', onError);
_this._dom.cleanup(script);
};
});
}
/**
* Callback called when the JSONP request completes, to notify the application
* of the new data.
*/
/**
* Callback called when the JSONP request completes, to notify the application
* of the new data.
* @param {?=} data
* @return {?}
*/
JSONPConnection.prototype.finished = /**
* Callback called when the JSONP request completes, to notify the application
* of the new data.
* @param {?=} data
* @return {?}
*/
function (data) {
// Don't leak connections
this._finished = true;
this._dom.removeConnection(this._id);
if (this.readyState === ReadyState.Cancelled) return;
this._responseData = data;
};
return JSONPConnection;
}();
/**
* A {\@link ConnectionBackend} that uses the JSONP strategy of making requests.
*
* @deprecated use \@angular/common/http instead
*/
var JSONPBackend = /** @class */function (_super) {
__extends(JSONPBackend, _super);
/** @internal */
function JSONPBackend(_browserJSONP, _baseResponseOptions) {
var _this = _super.call(this) || this;
_this._browserJSONP = _browserJSONP;
_this._baseResponseOptions = _baseResponseOptions;
return _this;
}
/**
* @param {?} request
* @return {?}
*/
JSONPBackend.prototype.createConnection = /**
* @param {?} request
* @return {?}
*/
function (request) {
return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);
};
JSONPBackend.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
JSONPBackend.ctorParameters = function () {
return [{ type: BrowserJsonp }, { type: ResponseOptions }];
};
return JSONPBackend;
}(ConnectionBackend);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var XSSI_PREFIX = /^\)\]\}',?\n/;
/**
* Creates connections using `XMLHttpRequest`. Given a fully-qualified
* request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
* request.
*
* This class would typically not be created or interacted with directly inside applications, though
* the {\@link MockConnection} may be interacted with in tests.
*
* @deprecated use \@angular/common/http instead
*/
var XHRConnection = /** @class */function () {
function XHRConnection(req, browserXHR, baseResponseOptions) {
var _this = this;
this.request = req;
this.response = new rxjs_Observable.Observable(function (responseObserver) {
var /** @type {?} */_xhr = browserXHR.build();
_xhr.open(RequestMethod[req.method].toUpperCase(), req.url);
if (req.withCredentials != null) {
_xhr.withCredentials = req.withCredentials;
}
// load event handler
var /** @type {?} */onLoad = function () {
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
var /** @type {?} */status = _xhr.status === 1223 ? 204 : _xhr.status;
var /** @type {?} */body = null;
// HTTP 204 means no content
if (status !== 204) {
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response/responseType properties were introduced in ResourceLoader Level2 spec
// (supported by IE10)
body = typeof _xhr.response === 'undefined' ? _xhr.responseText : _xhr.response;
// Implicitly strip a potential XSSI prefix.
if (typeof body === 'string') {
body = body.replace(XSSI_PREFIX, '');
}
}
// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = body ? 200 : 0;
}
var /** @type {?} */headers = Headers.fromResponseHeaderString(_xhr.getAllResponseHeaders());
// IE 9 does not provide the way to get URL of response
var /** @type {?} */url = getResponseURL(_xhr) || req.url;
var /** @type {?} */statusText = _xhr.statusText || 'OK';
var /** @type {?} */responseOptions = new ResponseOptions({ body: body, status: status, headers: headers, statusText: statusText, url: url });
if (baseResponseOptions != null) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
var /** @type {?} */response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
responseObserver.error(response);
};
// error event handler
var /** @type {?} */onError = function (err) {
var /** @type {?} */responseOptions = new ResponseOptions({
body: err,
type: ResponseType.Error,
status: _xhr.status,
statusText: _xhr.statusText
});
if (baseResponseOptions != null) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
responseObserver.error(new Response(responseOptions));
};
_this.setDetectedContentType(req, _xhr);
if (req.headers == null) {
req.headers = new Headers();
}
if (!req.headers.has('Accept')) {
req.headers.append('Accept', 'application/json, text/plain, */*');
}
req.headers.forEach(function (values, name) {
return _xhr.setRequestHeader( /** @type {?} */name, values.join(','));
});
// Select the correct buffer type to store the response
if (req.responseType != null && _xhr.responseType != null) {
switch (req.responseType) {
case ResponseContentType.ArrayBuffer:
_xhr.responseType = 'arraybuffer';
break;
case ResponseContentType.Json:
_xhr.responseType = 'json';
break;
case ResponseContentType.Text:
_xhr.responseType = 'text';
break;
case ResponseContentType.Blob:
_xhr.responseType = 'blob';
break;
default:
throw new Error('The selected responseType is not supported');
}
}
_xhr.addEventListener('load', onLoad);
_xhr.addEventListener('error', onError);
_xhr.send(_this.request.getBody());
return function () {
_xhr.removeEventListener('load', onLoad);
_xhr.removeEventListener('error', onError);
_xhr.abort();
};
});
}
/**
* @param {?} req
* @param {?} _xhr
* @return {?}
*/
XHRConnection.prototype.setDetectedContentType = /**
* @param {?} req
* @param {?} _xhr
* @return {?}
*/
function (req /** TODO Request */, _xhr /** XMLHttpRequest */) {
// Skip if a custom Content-Type header is provided
if (req.headers != null && req.headers.get('Content-Type') != null) {
return;
}
// Set the detected content type
switch (req.contentType) {
case ContentType.NONE:
break;
case ContentType.JSON:
_xhr.setRequestHeader('content-type', 'application/json');
break;
case ContentType.FORM:
_xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
break;
case ContentType.TEXT:
_xhr.setRequestHeader('content-type', 'text/plain');
break;
case ContentType.BLOB:
var /** @type {?} */blob = req.blob();
if (blob.type) {
_xhr.setRequestHeader('content-type', blob.type);
}
break;
}
};
return XHRConnection;
}();
/**
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
* for more information on XSRF.
*
* Applications can configure custom cookie and header names by binding an instance of this class
* with different `cookieName` and `headerName` values. See the main HTTP documentation for more
* details.
*
* @deprecated use \@angular/common/http instead
*/
var CookieXSRFStrategy = /** @class */function () {
function CookieXSRFStrategy(_cookieName, _headerName) {
if (_cookieName === void 0) {
_cookieName = 'XSRF-TOKEN';
}
if (_headerName === void 0) {
_headerName = 'X-XSRF-TOKEN';
}
this._cookieName = _cookieName;
this._headerName = _headerName;
}
/**
* @param {?} req
* @return {?}
*/
CookieXSRFStrategy.prototype.configureRequest = /**
* @param {?} req
* @return {?}
*/
function (req) {
var /** @type {?} */xsrfToken = _angular_platformBrowser.ɵgetDOM().getCookie(this._cookieName);
if (xsrfToken) {
req.headers.set(this._headerName, xsrfToken);
}
};
return CookieXSRFStrategy;
}();
/**
* Creates {\@link XHRConnection} instances.
*
* This class would typically not be used by end users, but could be
* overridden if a different backend implementation should be used,
* such as in a node backend.
*
* ### Example
*
* ```
* import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '\@angular/http';
* \@Component({
* viewProviders: [
* HTTP_PROVIDERS,
* {provide: Http, useFactory: (backend, options) => {
* return new Http(backend, options);
* }, deps: [MyNodeBackend, BaseRequestOptions]}]
* })
* class MyComponent {
* constructor(http:Http) {
* http.request('people.json').subscribe(res => this.people = res.json());
* }
* }
* ```
* @deprecated use \@angular/common/http instead
*/
var XHRBackend = /** @class */function () {
function XHRBackend(_browserXHR, _baseResponseOptions, _xsrfStrategy) {
this._browserXHR = _browserXHR;
this._baseResponseOptions = _baseResponseOptions;
this._xsrfStrategy = _xsrfStrategy;
}
/**
* @param {?} request
* @return {?}
*/
XHRBackend.prototype.createConnection = /**
* @param {?} request
* @return {?}
*/
function (request) {
this._xsrfStrategy.configureRequest(request);
return new XHRConnection(request, this._browserXHR, this._baseResponseOptions);
};
XHRBackend.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
XHRBackend.ctorParameters = function () {
return [{ type: BrowserXhr }, { type: ResponseOptions }, { type: XSRFStrategy }];
};
return XHRBackend;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Creates a request options object to be optionally provided when instantiating a
* {\@link Request}.
*
* This class is based on the `RequestInit` description in the [Fetch
* Spec](https://fetch.spec.whatwg.org/#requestinit).
*
* All values are null by default. Typical defaults can be found in the {\@link BaseRequestOptions}
* class, which sub-classes `RequestOptions`.
*
* ```typescript
* import {RequestOptions, Request, RequestMethod} from '\@angular/http';
*
* const options = new RequestOptions({
* method: RequestMethod.Post,
* url: 'https://google.com'
* });
* const req = new Request(options);
* console.log('req.method:', RequestMethod[req.method]); // Post
* console.log('options.url:', options.url); // https://google.com
* ```
*
* @deprecated use \@angular/common/http instead
*/
var RequestOptions = /** @class */function () {
// TODO(Dzmitry): remove search when this.search is removed
function RequestOptions(opts) {
if (opts === void 0) {
opts = {};
}
var method = opts.method,
headers = opts.headers,
body = opts.body,
url = opts.url,
search = opts.search,
params = opts.params,
withCredentials = opts.withCredentials,
responseType = opts.responseType;
this.method = method != null ? normalizeMethodName(method) : null;
this.headers = headers != null ? headers : null;
this.body = body != null ? body : null;
this.url = url != null ? url : null;
this.params = this._mergeSearchParams(params || search);
this.withCredentials = withCredentials != null ? withCredentials : null;
this.responseType = responseType != null ? responseType : null;
}
Object.defineProperty(RequestOptions.prototype, "search", {
/**
* @deprecated from 4.0.0. Use params instead.
*/
get: /**
* @deprecated from 4.0.0. Use params instead.
* @return {?}
*/
function () {
return this.params;
},
/**
* @deprecated from 4.0.0. Use params instead.
*/
set: /**
* @deprecated from 4.0.0. Use params instead.
* @param {?} params
* @return {?}
*/
function (params) {
this.params = params;
},
enumerable: true,
configurable: true
});
/**
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* Note that `headers` and `search` will override existing values completely if present in
* the `options` object. If these values should be merged, it should be done prior to calling
* `merge` on the `RequestOptions` instance.
*
* ```typescript
* import {RequestOptions, Request, RequestMethod} from '@angular/http';
*
* const options = new RequestOptions({
* method: RequestMethod.Post
* });
* const req = new Request(options.merge({
* url: 'https://google.com'
* }));
* console.log('req.method:', RequestMethod[req.method]); // Post
* console.log('options.url:', options.url); // null
* console.log('req.url:', req.url); // https://google.com
* ```
*/
/**
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* Note that `headers` and `search` will override existing values completely if present in
* the `options` object. If these values should be merged, it should be done prior to calling
* `merge` on the `RequestOptions` instance.
*
* ```typescript
* import {RequestOptions, Request, RequestMethod} from '\@angular/http';
*
* const options = new RequestOptions({
* method: RequestMethod.Post
* });
* const req = new Request(options.merge({
* url: 'https://google.com'
* }));
* console.log('req.method:', RequestMethod[req.method]); // Post
* console.log('options.url:', options.url); // null
* console.log('req.url:', req.url); // https://google.com
* ```
* @param {?=} options
* @return {?}
*/
RequestOptions.prototype.merge = /**
* Creates a copy of the `RequestOptions` instance, using the optional input as values to override
* existing values. This method will not change the values of the instance on which it is being
* called.
*
* Note that `headers` and `search` will override existing values completely if present in
* the `options` object. If these values should be merged, it should be done prior to calling
* `merge` on the `RequestOptions` instance.
*
* ```typescript
* import {RequestOptions, Request, RequestMethod} from '\@angular/http';
*
* const options = new RequestOptions({
* method: RequestMethod.Post
* });
* const req = new Request(options.merge({
* url: 'https://google.com'
* }));
* console.log('req.method:', RequestMethod[req.method]); // Post
* console.log('options.url:', options.url); // null
* console.log('req.url:', req.url); // https://google.com
* ```
* @param {?=} options
* @return {?}
*/
function (options) {
return new RequestOptions({
method: options && options.method != null ? options.method : this.method,
headers: options && options.headers != null ? options.headers : new Headers(this.headers),
body: options && options.body != null ? options.body : this.body,
url: options && options.url != null ? options.url : this.url,
params: options && this._mergeSearchParams(options.params || options.search),
withCredentials: options && options.withCredentials != null ? options.withCredentials : this.withCredentials,
responseType: options && options.responseType != null ? options.responseType : this.responseType
});
};
/**
* @param {?=} params
* @return {?}
*/
RequestOptions.prototype._mergeSearchParams = /**
* @param {?=} params
* @return {?}
*/
function (params) {
if (!params) return this.params;
if (params instanceof URLSearchParams) {
return params.clone();
}
if (typeof params === 'string') {
return new URLSearchParams(params);
}
return this._parseParams(params);
};
/**
* @param {?=} objParams
* @return {?}
*/
RequestOptions.prototype._parseParams = /**
* @param {?=} objParams
* @return {?}
*/
function (objParams) {
var _this = this;
if (objParams === void 0) {
objParams = {};
}
var /** @type {?} */params = new URLSearchParams();
Object.keys(objParams).forEach(function (key) {
var /** @type {?} */value = objParams[key];
if (Array.isArray(value)) {
value.forEach(function (item) {
return _this._appendParam(key, item, params);
});
} else {
_this._appendParam(key, value, params);
}
});
return params;
};
/**
* @param {?} key
* @param {?} value
* @param {?} params
* @return {?}
*/
RequestOptions.prototype._appendParam = /**
* @param {?} key
* @param {?} value
* @param {?} params
* @return {?}
*/
function (key, value, params) {
if (typeof value !== 'string') {
value = JSON.stringify(value);
}
params.append(key, value);
};
return RequestOptions;
}();
/**
* Subclass of {\@link RequestOptions}, with default values.
*
* Default values:
* * method: {\@link RequestMethod RequestMethod.Get}
* * headers: empty {\@link Headers} object
*
* This class could be extended and bound to the {\@link RequestOptions} class
* when configuring an {\@link Injector}, in order to override the default options
* used by {\@link Http} to create and send {\@link Request Requests}.
*
* ```typescript
* import {BaseRequestOptions, RequestOptions} from '\@angular/http';
*
* class MyOptions extends BaseRequestOptions {
* search: string = 'coreTeam=true';
* }
*
* {provide: RequestOptions, useClass: MyOptions};
* ```
*
* The options could also be extended when manually creating a {\@link Request}
* object.
*
* ```
* import {BaseRequestOptions, Request, RequestMethod} from '\@angular/http';
*
* const options = new BaseRequestOptions();
* const req = new Request(options.merge({
* method: RequestMethod.Post,
* url: 'https://google.com'
* }));
* console.log('req.method:', RequestMethod[req.method]); // Post
* console.log('options.url:', options.url); // null
* console.log('req.url:', req.url); // https://google.com
* ```
*
* @deprecated use \@angular/common/http instead
*/
var BaseRequestOptions = /** @class */function (_super) {
__extends(BaseRequestOptions, _super);
function BaseRequestOptions() {
return _super.call(this, { method: RequestMethod.Get, headers: new Headers() }) || this;
}
BaseRequestOptions.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
BaseRequestOptions.ctorParameters = function () {
return [];
};
return BaseRequestOptions;
}(RequestOptions);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Creates `Request` instances from provided values.
*
* The Request's interface is inspired by the Request constructor defined in the [Fetch
* Spec](https://fetch.spec.whatwg.org/#request-class),
* but is considered a static value whose body can be accessed many times. There are other
* differences in the implementation, but this is the most significant.
*
* `Request` instances are typically created by higher-level classes, like {\@link Http} and
* {\@link Jsonp}, but it may occasionally be useful to explicitly create `Request` instances.
* One such example is when creating services that wrap higher-level services, like {\@link Http},
* where it may be useful to generate a `Request` with arbitrary headers and search params.
*
* ```typescript
* import {Injectable, Injector} from '\@angular/core';
* import {HTTP_PROVIDERS, Http, Request, RequestMethod} from '\@angular/http';
*
* \@Injectable()
* class AutoAuthenticator {
* constructor(public http:Http) {}
* request(url:string) {
* return this.http.request(new Request({
* method: RequestMethod.Get,
* url: url,
* search: 'password=123'
* }));
* }
* }
*
* var injector = Injector.resolveAndCreate([HTTP_PROVIDERS, AutoAuthenticator]);
* var authenticator = injector.get(AutoAuthenticator);
* authenticator.request('people.json').subscribe(res => {
* //URL should have included '?password=123'
* console.log('people', res.json());
* });
* ```
*
* @deprecated use \@angular/common/http instead
*/
var Request = /** @class */function (_super) {
__extends(Request, _super);
function Request(requestOptions) {
var _this = _super.call(this) || this;
// TODO: assert that url is present
var /** @type {?} */url = requestOptions.url;
_this.url = /** @type {?} */requestOptions.url;
var /** @type {?} */paramsArg = requestOptions.params || requestOptions.search;
if (paramsArg) {
var /** @type {?} */params = void 0;
if (typeof paramsArg === 'object' && !(paramsArg instanceof URLSearchParams)) {
params = urlEncodeParams(paramsArg).toString();
} else {
params = paramsArg.toString();
}
if (params.length > 0) {
var /** @type {?} */prefix = '?';
if (_this.url.indexOf('?') != -1) {
prefix = _this.url[_this.url.length - 1] == '&' ? '' : '&';
}
// TODO: just delete search-query-looking string in url?
// TODO: just delete search-query-looking string in url?
_this.url = url + prefix + params;
}
}
_this._body = requestOptions.body;
_this.method = normalizeMethodName( /** @type {?} */requestOptions.method);
// TODO(jeffbcross): implement behavior
// Defaults to 'omit', consistent with browser
// TODO(jeffbcross): implement behavior
// Defaults to 'omit', consistent with browser
_this.headers = new Headers(requestOptions.headers);
_this.contentType = _this.detectContentType();
_this.withCredentials = /** @type {?} */requestOptions.withCredentials;
_this.responseType = /** @type {?} */requestOptions.responseType;
return _this;
}
/**
* Returns the content type enum based on header options.
*/
/**
* Returns the content type enum based on header options.
* @return {?}
*/
Request.prototype.detectContentType = /**
* Returns the content type enum based on header options.
* @return {?}
*/
function () {
switch (this.headers.get('content-type')) {
case 'application/json':
return ContentType.JSON;
case 'application/x-www-form-urlencoded':
return ContentType.FORM;
case 'multipart/form-data':
return ContentType.FORM_DATA;
case 'text/plain':
case 'text/html':
return ContentType.TEXT;
case 'application/octet-stream':
return this._body instanceof ArrayBuffer$1 ? ContentType.ARRAY_BUFFER : ContentType.BLOB;
default:
return this.detectContentTypeFromBody();
}
};
/**
* Returns the content type of request's body based on its type.
*/
/**
* Returns the content type of request's body based on its type.
* @return {?}
*/
Request.prototype.detectContentTypeFromBody = /**
* Returns the content type of request's body based on its type.
* @return {?}
*/
function () {
if (this._body == null) {
return ContentType.NONE;
} else if (this._body instanceof URLSearchParams) {
return ContentType.FORM;
} else if (this._body instanceof FormData) {
return ContentType.FORM_DATA;
} else if (this._body instanceof Blob$1) {
return ContentType.BLOB;
} else if (this._body instanceof ArrayBuffer$1) {
return ContentType.ARRAY_BUFFER;
} else if (this._body && typeof this._body === 'object') {
return ContentType.JSON;
} else {
return ContentType.TEXT;
}
};
/**
* Returns the request's body according to its type. If body is undefined, return
* null.
*/
/**
* Returns the request's body according to its type. If body is undefined, return
* null.
* @return {?}
*/
Request.prototype.getBody = /**
* Returns the request's body according to its type. If body is undefined, return
* null.
* @return {?}
*/
function () {
switch (this.contentType) {
case ContentType.JSON:
return this.text();
case ContentType.FORM:
return this.text();
case ContentType.FORM_DATA:
return this._body;
case ContentType.TEXT:
return this.text();
case ContentType.BLOB:
return this.blob();
case ContentType.ARRAY_BUFFER:
return this.arrayBuffer();
default:
return null;
}
};
return Request;
}(Body);
/**
* @param {?} params
* @return {?}
*/
function urlEncodeParams(params) {
var /** @type {?} */searchParams = new URLSearchParams();
Object.keys(params).forEach(function (key) {
var /** @type {?} */value = params[key];
if (value && Array.isArray(value)) {
value.forEach(function (element) {
return searchParams.append(key, element.toString());
});
} else {
searchParams.append(key, value.toString());
}
});
return searchParams;
}
var noop = function () {};
var w = typeof window == 'object' ? window : noop;
var FormData = /** @type {?} */w /** TODO #9100 */[/** TODO #9100 */'FormData'] || noop;
var Blob$1 = /** @type {?} */w /** TODO #9100 */[/** TODO #9100 */'Blob'] || noop;
var ArrayBuffer$1 = /** @type {?} */w /** TODO #9100 */[/** TODO #9100 */'ArrayBuffer'] || noop;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} backend
* @param {?} request
* @return {?}
*/
function httpRequest(backend, request) {
return backend.createConnection(request).response;
}
/**
* @param {?} defaultOpts
* @param {?} providedOpts
* @param {?} method
* @param {?} url
* @return {?}
*/
function mergeOptions(defaultOpts, providedOpts, method, url) {
var /** @type {?} */newOptions = defaultOpts;
if (providedOpts) {
// Hack so Dart can used named parameters
return (/** @type {?} */newOptions.merge(new RequestOptions({
method: providedOpts.method || method,
url: providedOpts.url || url,
search: providedOpts.search,
params: providedOpts.params,
headers: providedOpts.headers,
body: providedOpts.body,
withCredentials: providedOpts.withCredentials,
responseType: providedOpts.responseType
}))
);
}
return (/** @type {?} */newOptions.merge(new RequestOptions({ method: method, url: url }))
);
}
/**
* Performs http requests using `XMLHttpRequest` as the default backend.
*
* `Http` is available as an injectable class, with methods to perform http requests. Calling
* `request` returns an `Observable` which will emit a single {\@link Response} when a
* response is received.
*
* ### Example
*
* ```typescript
* import {Http, HTTP_PROVIDERS} from '\@angular/http';
* import 'rxjs/add/operator/map'
* \@Component({
* selector: 'http-app',
* viewProviders: [HTTP_PROVIDERS],
* templateUrl: 'people.html'
* })
* class PeopleComponent {
* constructor(http: Http) {
* http.get('people.json')
* // Call map on the response observable to get the parsed people object
* .map(res => res.json())
* // Subscribe to the observable to get the parsed people object and attach it to the
* // component
* .subscribe(people => this.people = people);
* }
* }
* ```
*
*
* ### Example
*
* ```
* http.get('people.json').subscribe((res:Response) => this.people = res.json());
* ```
*
* The default construct used to perform requests, `XMLHttpRequest`, is abstracted as a "Backend" (
* {\@link XHRBackend} in this case), which could be mocked with dependency injection by replacing
* the {\@link XHRBackend} provider, as in the following example:
*
* ### Example
*
* ```typescript
* import {BaseRequestOptions, Http} from '\@angular/http';
* import {MockBackend} from '\@angular/http/testing';
* var injector = Injector.resolveAndCreate([
* BaseRequestOptions,
* MockBackend,
* {provide: Http, useFactory:
* function(backend, defaultOptions) {
* return new Http(backend, defaultOptions);
* },
* deps: [MockBackend, BaseRequestOptions]}
* ]);
* var http = injector.get(Http);
* http.get('request-from-mock-backend.json').subscribe((res:Response) => doSomething(res));
* ```
*
* @deprecated use \@angular/common/http instead
*/
var Http = /** @class */function () {
function Http(_backend, _defaultOptions) {
this._backend = _backend;
this._defaultOptions = _defaultOptions;
}
/**
* Performs any type of http request. First argument is required, and can either be a url or
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {@link BaseRequestOptions} before performing the request.
*/
/**
* Performs any type of http request. First argument is required, and can either be a url or
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {\@link BaseRequestOptions} before performing the request.
* @param {?} url
* @param {?=} options
* @return {?}
*/
Http.prototype.request = /**
* Performs any type of http request. First argument is required, and can either be a url or
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {\@link BaseRequestOptions} before performing the request.
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
var /** @type {?} */responseObservable;
if (typeof url === 'string') {
responseObservable = httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */url)));
} else if (url instanceof Request) {
responseObservable = httpRequest(this._backend, url);
} else {
throw new Error('First argument must be a url string or Request instance.');
}
return responseObservable;
};
/**
* Performs a request with `get` http method.
*/
/**
* Performs a request with `get` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
Http.prototype.get = /**
* Performs a request with `get` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, url)));
};
/**
* Performs a request with `post` http method.
*/
/**
* Performs a request with `post` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
Http.prototype.post = /**
* Performs a request with `post` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
function (url, body, options) {
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Post, url)));
};
/**
* Performs a request with `put` http method.
*/
/**
* Performs a request with `put` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
Http.prototype.put = /**
* Performs a request with `put` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
function (url, body, options) {
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Put, url)));
};
/**
* Performs a request with `delete` http method.
*/
/**
* Performs a request with `delete` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
Http.prototype.delete = /**
* Performs a request with `delete` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Delete, url)));
};
/**
* Performs a request with `patch` http method.
*/
/**
* Performs a request with `patch` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
Http.prototype.patch = /**
* Performs a request with `patch` http method.
* @param {?} url
* @param {?} body
* @param {?=} options
* @return {?}
*/
function (url, body, options) {
return this.request(new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({ body: body })), options, RequestMethod.Patch, url)));
};
/**
* Performs a request with `head` http method.
*/
/**
* Performs a request with `head` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
Http.prototype.head = /**
* Performs a request with `head` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Head, url)));
};
/**
* Performs a request with `options` http method.
*/
/**
* Performs a request with `options` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
Http.prototype.options = /**
* Performs a request with `options` http method.
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
return this.request(new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Options, url)));
};
Http.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
Http.ctorParameters = function () {
return [{ type: ConnectionBackend }, { type: RequestOptions }];
};
return Http;
}();
/**
* @deprecated use \@angular/common/http instead
*/
var Jsonp = /** @class */function (_super) {
__extends(Jsonp, _super);
function Jsonp(backend, defaultOptions) {
return _super.call(this, backend, defaultOptions) || this;
}
/**
* Performs any type of http request. First argument is required, and can either be a url or
* a {@link Request} instance. If the first argument is a url, an optional {@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {@link BaseRequestOptions} before performing the request.
*
* @security Regular XHR is the safest alternative to JSONP for most applications, and is
* supported by all current browsers. Because JSONP creates a `<script>` element with
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
* source could expose your application to XSS risks. Data exposed by JSONP may also be
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for
* future security issues (e.g. content sniffing). For more detail, see the
* [Security Guide](http://g.co/ng/security).
*/
/**
* Performs any type of http request. First argument is required, and can either be a url or
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {\@link BaseRequestOptions} before performing the request.
*
* \@security Regular XHR is the safest alternative to JSONP for most applications, and is
* supported by all current browsers. Because JSONP creates a `<script>` element with
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
* source could expose your application to XSS risks. Data exposed by JSONP may also be
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for
* future security issues (e.g. content sniffing). For more detail, see the
* [Security Guide](http://g.co/ng/security).
* @param {?} url
* @param {?=} options
* @return {?}
*/
Jsonp.prototype.request = /**
* Performs any type of http request. First argument is required, and can either be a url or
* a {\@link Request} instance. If the first argument is a url, an optional {\@link RequestOptions}
* object can be provided as the 2nd argument. The options object will be merged with the values
* of {\@link BaseRequestOptions} before performing the request.
*
* \@security Regular XHR is the safest alternative to JSONP for most applications, and is
* supported by all current browsers. Because JSONP creates a `<script>` element with
* contents retrieved from a remote source, attacker-controlled data introduced by an untrusted
* source could expose your application to XSS risks. Data exposed by JSONP may also be
* readable by malicious third-party websites. In addition, JSONP introduces potential risk for
* future security issues (e.g. content sniffing). For more detail, see the
* [Security Guide](http://g.co/ng/security).
* @param {?} url
* @param {?=} options
* @return {?}
*/
function (url, options) {
var /** @type {?} */responseObservable;
if (typeof url === 'string') {
url = new Request(mergeOptions(this._defaultOptions, options, RequestMethod.Get, /** @type {?} */url));
}
if (url instanceof Request) {
if (url.method !== RequestMethod.Get) {
throw new Error('JSONP requests must use GET request method.');
}
responseObservable = httpRequest(this._backend, url);
} else {
throw new Error('First argument must be a url string or Request instance.');
}
return responseObservable;
};
Jsonp.decorators = [{ type: _angular_core.Injectable }];
/** @nocollapse */
Jsonp.ctorParameters = function () {
return [{ type: ConnectionBackend }, { type: RequestOptions }];
};
return Jsonp;
}(Http);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* The http module provides services to perform http requests. To get started, see the {@link Http}
* class.
*/
/**
* @return {?}
*/
function _createDefaultCookieXSRFStrategy() {
return new CookieXSRFStrategy();
}
/**
* @param {?} xhrBackend
* @param {?} requestOptions
* @return {?}
*/
function httpFactory(xhrBackend, requestOptions) {
return new Http(xhrBackend, requestOptions);
}
/**
* @param {?} jsonpBackend
* @param {?} requestOptions
* @return {?}
*/
function jsonpFactory(jsonpBackend, requestOptions) {
return new Jsonp(jsonpBackend, requestOptions);
}
/**
* The module that includes http's providers
*
* @deprecated use \@angular/common/http instead
*/
var HttpModule = /** @class */function () {
function HttpModule() {}
HttpModule.decorators = [{ type: _angular_core.NgModule, args: [{
providers: [
// TODO(pascal): use factory type annotations once supported in DI
// issue: https://github.com/angular/angular/issues/3183
{ provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions] }, BrowserXhr, { provide: RequestOptions, useClass: BaseRequestOptions }, { provide: ResponseOptions, useClass: BaseResponseOptions }, XHRBackend, { provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy }]
}] }];
/** @nocollapse */
HttpModule.ctorParameters = function () {
return [];
};
return HttpModule;
}();
/**
* The module that includes jsonp's providers
*
* @deprecated use \@angular/common/http instead
*/
var JsonpModule = /** @class */function () {
function JsonpModule() {}
JsonpModule.decorators = [{ type: _angular_core.NgModule, args: [{
providers: [
// TODO(pascal): use factory type annotations once supported in DI
// issue: https://github.com/angular/angular/issues/3183
{ provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions] }, BrowserJsonp, { provide: RequestOptions, useClass: BaseRequestOptions }, { provide: ResponseOptions, useClass: BaseResponseOptions }, JSONPBackend]
}] }];
/** @nocollapse */
JsonpModule.ctorParameters = function () {
return [];
};
return JsonpModule;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* @deprecated use \@angular/common/http instead
*/
var VERSION = new _angular_core.Version('5.1.0');
exports.BrowserXhr = BrowserXhr;
exports.JSONPBackend = JSONPBackend;
exports.JSONPConnection = JSONPConnection;
exports.CookieXSRFStrategy = CookieXSRFStrategy;
exports.XHRBackend = XHRBackend;
exports.XHRConnection = XHRConnection;
exports.BaseRequestOptions = BaseRequestOptions;
exports.RequestOptions = RequestOptions;
exports.BaseResponseOptions = BaseResponseOptions;
exports.ResponseOptions = ResponseOptions;
exports.ReadyState = ReadyState;
exports.RequestMethod = RequestMethod;
exports.ResponseContentType = ResponseContentType;
exports.ResponseType = ResponseType;
exports.Headers = Headers;
exports.Http = Http;
exports.Jsonp = Jsonp;
exports.HttpModule = HttpModule;
exports.JsonpModule = JsonpModule;
exports.Connection = Connection;
exports.ConnectionBackend = ConnectionBackend;
exports.XSRFStrategy = XSRFStrategy;
exports.Request = Request;
exports.Response = Response;
exports.QueryEncoder = QueryEncoder;
exports.URLSearchParams = URLSearchParams;
exports.VERSION = VERSION;
exports.ɵe = BrowserJsonp;
exports.ɵf = Body;
exports.ɵa = _createDefaultCookieXSRFStrategy;
exports.ɵb = httpFactory;
exports.ɵc = jsonpFactory;
Object.defineProperty(exports, '__esModule', { value: true });
});
System.registerDynamic("rxjs/observable/ScalarObservable.js", ["../Observable"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = $__require('../Observable');
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ScalarObservable = function (_super) {
__extends(ScalarObservable, _super);
function ScalarObservable(value, scheduler) {
_super.call(this);
this.value = value;
this.scheduler = scheduler;
this._isScalar = true;
if (scheduler) {
this._isScalar = false;
}
}
ScalarObservable.create = function (value, scheduler) {
return new ScalarObservable(value, scheduler);
};
ScalarObservable.dispatch = function (state) {
var done = state.done,
value = state.value,
subscriber = state.subscriber;
if (done) {
subscriber.complete();
return;
}
subscriber.next(value);
if (subscriber.closed) {
return;
}
state.done = true;
this.schedule(state);
};
ScalarObservable.prototype._subscribe = function (subscriber) {
var value = this.value;
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ScalarObservable.dispatch, 0, {
done: false, value: value, subscriber: subscriber
});
} else {
subscriber.next(value);
if (!subscriber.closed) {
subscriber.complete();
}
}
};
return ScalarObservable;
}(Observable_1.Observable);
exports.ScalarObservable = ScalarObservable;
});
System.registerDynamic("rxjs/observable/EmptyObservable.js", ["../Observable"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = $__require('../Observable');
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var EmptyObservable = function (_super) {
__extends(EmptyObservable, _super);
function EmptyObservable(scheduler) {
_super.call(this);
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits a complete notification.
*
* <span class="informal">Just emits 'complete', and nothing else.
* </span>
*
* <img src="./img/empty.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the complete notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example <caption>Emit the number 7, then complete.</caption>
* var result = Rx.Observable.empty().startWith(7);
* result.subscribe(x => console.log(x));
*
* @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following to the console:
* // x is equal to the count on the interval eg(0,1,2,3,...)
* // x will occur every 1000ms
* // if x % 2 is equal to 1 print abc
* // if x % 2 is not equal to 1 nothing will be output
*
* @see {@link create}
* @see {@link never}
* @see {@link of}
* @see {@link throw}
*
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the complete notification.
* @return {Observable} An "empty" Observable: emits only the complete
* notification.
* @static true
* @name empty
* @owner Observable
*/
EmptyObservable.create = function (scheduler) {
return new EmptyObservable(scheduler);
};
EmptyObservable.dispatch = function (arg) {
var subscriber = arg.subscriber;
subscriber.complete();
};
EmptyObservable.prototype._subscribe = function (subscriber) {
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
} else {
subscriber.complete();
}
};
return EmptyObservable;
}(Observable_1.Observable);
exports.EmptyObservable = EmptyObservable;
});
System.registerDynamic('rxjs/observable/ArrayObservable.js', ['../Observable', './ScalarObservable', './EmptyObservable', '../util/isScheduler'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = $__require('../Observable');
var ScalarObservable_1 = $__require('./ScalarObservable');
var EmptyObservable_1 = $__require('./EmptyObservable');
var isScheduler_1 = $__require('../util/isScheduler');
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ArrayObservable = function (_super) {
__extends(ArrayObservable, _super);
function ArrayObservable(array, scheduler) {
_super.call(this);
this.array = array;
this.scheduler = scheduler;
if (!scheduler && array.length === 1) {
this._isScalar = true;
this.value = array[0];
}
}
ArrayObservable.create = function (array, scheduler) {
return new ArrayObservable(array, scheduler);
};
/**
* Creates an Observable that emits some values you specify as arguments,
* immediately one after the other, and then emits a complete notification.
*
* <span class="informal">Emits the arguments you provide, then completes.
* </span>
*
* <img src="./img/of.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the arguments given, and the complete notification thereafter. It can
* be used for composing with other Observables, such as with {@link concat}.
* By default, it uses a `null` IScheduler, which means the `next`
* notifications are sent synchronously, although with a different IScheduler
* it is possible to determine when those notifications will be delivered.
*
* @example <caption>Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.</caption>
* var numbers = Rx.Observable.of(10, 20, 30);
* var letters = Rx.Observable.of('a', 'b', 'c');
* var interval = Rx.Observable.interval(1000);
* var result = numbers.concat(letters).concat(interval);
* result.subscribe(x => console.log(x));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link throw}
*
* @param {...T} values Arguments that represent `next` values to be emitted.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emissions of the `next` notifications.
* @return {Observable<T>} An Observable that emits each given input value.
* @static true
* @name of
* @owner Observable
*/
ArrayObservable.of = function () {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i - 0] = arguments[_i];
}
var scheduler = array[array.length - 1];
if (isScheduler_1.isScheduler(scheduler)) {
array.pop();
} else {
scheduler = null;
}
var len = array.length;
if (len > 1) {
return new ArrayObservable(array, scheduler);
} else if (len === 1) {
return new ScalarObservable_1.ScalarObservable(array[0], scheduler);
} else {
return new EmptyObservable_1.EmptyObservable(scheduler);
}
};
ArrayObservable.dispatch = function (state) {
var array = state.array,
index = state.index,
count = state.count,
subscriber = state.subscriber;
if (index >= count) {
subscriber.complete();
return;
}
subscriber.next(array[index]);
if (subscriber.closed) {
return;
}
state.index = index + 1;
this.schedule(state);
};
ArrayObservable.prototype._subscribe = function (subscriber) {
var index = 0;
var array = this.array;
var count = array.length;
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ArrayObservable.dispatch, 0, {
array: array, index: index, count: count, subscriber: subscriber
});
} else {
for (var i = 0; i < count && !subscriber.closed; i++) {
subscriber.next(array[i]);
}
subscriber.complete();
}
};
return ArrayObservable;
}(Observable_1.Observable);
exports.ArrayObservable = ArrayObservable;
});
System.registerDynamic("rxjs/util/identity.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
function identity(x) {
return x;
}
exports.identity = identity;
});
System.registerDynamic('rxjs/operators/mergeAll.js', ['./mergeMap', '../util/identity'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var mergeMap_1 = $__require('./mergeMap');
var identity_1 = $__require('../util/identity');
/**
* Converts a higher-order Observable into a first-order Observable which
* concurrently delivers all values that are emitted on the inner Observables.
*
* <span class="informal">Flattens an Observable-of-Observables.</span>
*
* <img src="./img/mergeAll.png" width="100%">
*
* `mergeAll` subscribes to an Observable that emits Observables, also known as
* a higher-order Observable. Each time it observes one of these emitted inner
* Observables, it subscribes to that and delivers all the values from the
* inner Observable on the output Observable. The output Observable only
* completes once all inner Observables have completed. Any error delivered by
* a inner Observable will be immediately emitted on the output Observable.
*
* @example <caption>Spawn a new interval Observable for each click event, and blend their outputs as one Observable</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
* var firstOrder = higherOrder.mergeAll();
* firstOrder.subscribe(x => console.log(x));
*
* @example <caption>Count from 0 to 9 every second for each click, but only allow 2 concurrent timers</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
* var firstOrder = higherOrder.mergeAll(2);
* firstOrder.subscribe(x => console.log(x));
*
* @see {@link combineAll}
* @see {@link concatAll}
* @see {@link exhaust}
* @see {@link merge}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
* @see {@link switch}
* @see {@link zipAll}
*
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
* Observables being subscribed to concurrently.
* @return {Observable} An Observable that emits values coming from all the
* inner Observables emitted by the source Observable.
* @method mergeAll
* @owner Observable
*/
function mergeAll(concurrent) {
if (concurrent === void 0) {
concurrent = Number.POSITIVE_INFINITY;
}
return mergeMap_1.mergeMap(identity_1.identity, null, concurrent);
}
exports.mergeAll = mergeAll;
});
System.registerDynamic("rxjs/util/isScheduler.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
function isScheduler(value) {
return value && typeof value.schedule === 'function';
}
exports.isScheduler = isScheduler;
});
System.registerDynamic('rxjs/operators/merge.js', ['../Observable', '../observable/ArrayObservable', './mergeAll', '../util/isScheduler'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Observable_1 = $__require('../Observable');
var ArrayObservable_1 = $__require('../observable/ArrayObservable');
var mergeAll_1 = $__require('./mergeAll');
var isScheduler_1 = $__require('../util/isScheduler');
/* tslint:enable:max-line-length */
function merge() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
return function (source) {
return source.lift.call(mergeStatic.apply(void 0, [source].concat(observables)));
};
}
exports.merge = merge;
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which concurrently emits all values from every
* given input Observable.
*
* <span class="informal">Flattens multiple Observables together by blending
* their values into one Observable.</span>
*
* <img src="./img/merge.png" width="100%">
*
* `merge` subscribes to each given input Observable (as arguments), and simply
* forwards (without doing any transformation) all the values from all the input
* Observables to the output Observable. The output Observable only completes
* once all input Observables have completed. Any error delivered by an input
* Observable will be immediately emitted on the output Observable.
*
* @example <caption>Merge together two Observables: 1s interval and clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var timer = Rx.Observable.interval(1000);
* var clicksOrTimer = Rx.Observable.merge(clicks, timer);
* clicksOrTimer.subscribe(x => console.log(x));
*
* // Results in the following:
* // timer will emit ascending values, one every second(1000ms) to console
* // clicks logs MouseEvents to console everytime the "document" is clicked
* // Since the two streams are merged you see these happening
* // as they occur.
*
* @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var concurrent = 2; // the argument
* var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
* merged.subscribe(x => console.log(x));
*
* // Results in the following:
* // - First timer1 and timer2 will run concurrently
* // - timer1 will emit a value every 1000ms for 10 iterations
* // - timer2 will emit a value every 2000ms for 6 iterations
* // - after timer1 hits it's max iteration, timer2 will
* // continue, and timer3 will start to run concurrently with timer2
* // - when timer2 hits it's max iteration it terminates, and
* // timer3 will continue to emit a value every 500ms until it is complete
*
* @see {@link mergeAll}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
*
* @param {...ObservableInput} observables Input Observables to merge together.
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
* concurrency of input Observables.
* @return {Observable} an Observable that emits items that are the result of
* every input Observable.
* @static true
* @name merge
* @owner Observable
*/
function mergeStatic() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
var concurrent = Number.POSITIVE_INFINITY;
var scheduler = null;
var last = observables[observables.length - 1];
if (isScheduler_1.isScheduler(last)) {
scheduler = observables.pop();
if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
concurrent = observables.pop();
}
} else if (typeof last === 'number') {
concurrent = observables.pop();
}
if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
return observables[0];
}
return mergeAll_1.mergeAll(concurrent)(new ArrayObservable_1.ArrayObservable(observables, scheduler));
}
exports.mergeStatic = mergeStatic;
});
System.registerDynamic('rxjs/operator/merge.js', ['../operators/merge'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var merge_1 = $__require('../operators/merge');
var merge_2 = $__require('../operators/merge');
exports.mergeStatic = merge_2.mergeStatic;
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which concurrently emits all values from every
* given input Observable.
*
* <span class="informal">Flattens multiple Observables together by blending
* their values into one Observable.</span>
*
* <img src="./img/merge.png" width="100%">
*
* `merge` subscribes to each given input Observable (either the source or an
* Observable given as argument), and simply forwards (without doing any
* transformation) all the values from all the input Observables to the output
* Observable. The output Observable only completes once all input Observables
* have completed. Any error delivered by an input Observable will be immediately
* emitted on the output Observable.
*
* @example <caption>Merge together two Observables: 1s interval and clicks</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var timer = Rx.Observable.interval(1000);
* var clicksOrTimer = clicks.merge(timer);
* clicksOrTimer.subscribe(x => console.log(x));
*
* @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var concurrent = 2; // the argument
* var merged = timer1.merge(timer2, timer3, concurrent);
* merged.subscribe(x => console.log(x));
*
* @see {@link mergeAll}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
*
* @param {ObservableInput} other An input Observable to merge with the source
* Observable. More than one input Observables may be given as argument.
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
* concurrency of input Observables.
* @return {Observable} An Observable that emits items that are the result of
* every input Observable.
* @method merge
* @owner Observable
*/
function merge() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
return merge_1.merge.apply(void 0, observables)(this);
}
exports.merge = merge;
});
System.registerDynamic("rxjs/observable/merge.js", ["../operator/merge"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var merge_1 = $__require('../operator/merge');
exports.merge = merge_1.mergeStatic;
});
System.registerDynamic('rxjs/observable/ConnectableObservable.js', ['../Subject', '../Observable', '../Subscriber', '../Subscription', '../operators/refCount'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subject_1 = $__require('../Subject');
var Observable_1 = $__require('../Observable');
var Subscriber_1 = $__require('../Subscriber');
var Subscription_1 = $__require('../Subscription');
var refCount_1 = $__require('../operators/refCount');
/**
* @class ConnectableObservable<T>
*/
var ConnectableObservable = function (_super) {
__extends(ConnectableObservable, _super);
function ConnectableObservable(source, subjectFactory) {
_super.call(this);
this.source = source;
this.subjectFactory = subjectFactory;
this._refCount = 0;
this._isComplete = false;
}
ConnectableObservable.prototype._subscribe = function (subscriber) {
return this.getSubject().subscribe(subscriber);
};
ConnectableObservable.prototype.getSubject = function () {
var subject = this._subject;
if (!subject || subject.isStopped) {
this._subject = this.subjectFactory();
}
return this._subject;
};
ConnectableObservable.prototype.connect = function () {
var connection = this._connection;
if (!connection) {
this._isComplete = false;
connection = this._connection = new Subscription_1.Subscription();
connection.add(this.source.subscribe(new ConnectableSubscriber(this.getSubject(), this)));
if (connection.closed) {
this._connection = null;
connection = Subscription_1.Subscription.EMPTY;
} else {
this._connection = connection;
}
}
return connection;
};
ConnectableObservable.prototype.refCount = function () {
return refCount_1.refCount()(this);
};
return ConnectableObservable;
}(Observable_1.Observable);
exports.ConnectableObservable = ConnectableObservable;
var connectableProto = ConnectableObservable.prototype;
exports.connectableObservableDescriptor = {
operator: { value: null },
_refCount: { value: 0, writable: true },
_subject: { value: null, writable: true },
_connection: { value: null, writable: true },
_subscribe: { value: connectableProto._subscribe },
_isComplete: { value: connectableProto._isComplete, writable: true },
getSubject: { value: connectableProto.getSubject },
connect: { value: connectableProto.connect },
refCount: { value: connectableProto.refCount }
};
var ConnectableSubscriber = function (_super) {
__extends(ConnectableSubscriber, _super);
function ConnectableSubscriber(destination, connectable) {
_super.call(this, destination);
this.connectable = connectable;
}
ConnectableSubscriber.prototype._error = function (err) {
this._unsubscribe();
_super.prototype._error.call(this, err);
};
ConnectableSubscriber.prototype._complete = function () {
this.connectable._isComplete = true;
this._unsubscribe();
_super.prototype._complete.call(this);
};
ConnectableSubscriber.prototype._unsubscribe = function () {
var connectable = this.connectable;
if (connectable) {
this.connectable = null;
var connection = connectable._connection;
connectable._refCount = 0;
connectable._subject = null;
connectable._connection = null;
if (connection) {
connection.unsubscribe();
}
}
};
return ConnectableSubscriber;
}(Subject_1.SubjectSubscriber);
var RefCountOperator = function () {
function RefCountOperator(connectable) {
this.connectable = connectable;
}
RefCountOperator.prototype.call = function (subscriber, source) {
var connectable = this.connectable;
connectable._refCount++;
var refCounter = new RefCountSubscriber(subscriber, connectable);
var subscription = source.subscribe(refCounter);
if (!refCounter.closed) {
refCounter.connection = connectable.connect();
}
return subscription;
};
return RefCountOperator;
}();
var RefCountSubscriber = function (_super) {
__extends(RefCountSubscriber, _super);
function RefCountSubscriber(destination, connectable) {
_super.call(this, destination);
this.connectable = connectable;
}
RefCountSubscriber.prototype._unsubscribe = function () {
var connectable = this.connectable;
if (!connectable) {
this.connection = null;
return;
}
this.connectable = null;
var refCount = connectable._refCount;
if (refCount <= 0) {
this.connection = null;
return;
}
connectable._refCount = refCount - 1;
if (refCount > 1) {
this.connection = null;
return;
}
///
// Compare the local RefCountSubscriber's connection Subscription to the
// connection Subscription on the shared ConnectableObservable. In cases
// where the ConnectableObservable source synchronously emits values, and
// the RefCountSubscriber's downstream Observers synchronously unsubscribe,
// execution continues to here before the RefCountOperator has a chance to
// supply the RefCountSubscriber with the shared connection Subscription.
// For example:
// ```
// Observable.range(0, 10)
// .publish()
// .refCount()
// .take(5)
// .subscribe();
// ```
// In order to account for this case, RefCountSubscriber should only dispose
// the ConnectableObservable's shared connection Subscription if the
// connection Subscription exists, *and* either:
// a. RefCountSubscriber doesn't have a reference to the shared connection
// Subscription yet, or,
// b. RefCountSubscriber's connection Subscription reference is identical
// to the shared connection Subscription
///
var connection = this.connection;
var sharedConnection = connectable._connection;
this.connection = null;
if (sharedConnection && (!connection || sharedConnection === connection)) {
sharedConnection.unsubscribe();
}
};
return RefCountSubscriber;
}(Subscriber_1.Subscriber);
});
System.registerDynamic('rxjs/operators/multicast.js', ['../observable/ConnectableObservable'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var ConnectableObservable_1 = $__require('../observable/ConnectableObservable');
/* tslint:enable:max-line-length */
/**
* Returns an Observable that emits the results of invoking a specified selector on items
* emitted by a ConnectableObservable that shares a single subscription to the underlying stream.
*
* <img src="./img/multicast.png" width="100%">
*
* @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through
* which the source sequence's elements will be multicast to the selector function
* or Subject to push source elements into.
* @param {Function} [selector] - Optional selector function that can use the multicasted source stream
* as many times as needed, without causing multiple subscriptions to the source stream.
* Subscribers to the given source will receive all notifications of the source from the
* time of the subscription forward.
* @return {Observable} An Observable that emits the results of invoking the selector
* on the items emitted by a `ConnectableObservable` that shares a single subscription to
* the underlying stream.
* @method multicast
* @owner Observable
*/
function multicast(subjectOrSubjectFactory, selector) {
return function multicastOperatorFunction(source) {
var subjectFactory;
if (typeof subjectOrSubjectFactory === 'function') {
subjectFactory = subjectOrSubjectFactory;
} else {
subjectFactory = function subjectFactory() {
return subjectOrSubjectFactory;
};
}
if (typeof selector === 'function') {
return source.lift(new MulticastOperator(subjectFactory, selector));
}
var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
connectable.source = source;
connectable.subjectFactory = subjectFactory;
return connectable;
};
}
exports.multicast = multicast;
var MulticastOperator = function () {
function MulticastOperator(subjectFactory, selector) {
this.subjectFactory = subjectFactory;
this.selector = selector;
}
MulticastOperator.prototype.call = function (subscriber, source) {
var selector = this.selector;
var subject = this.subjectFactory();
var subscription = selector(subject).subscribe(subscriber);
subscription.add(source.subscribe(subject));
return subscription;
};
return MulticastOperator;
}();
exports.MulticastOperator = MulticastOperator;
});
System.registerDynamic("rxjs/operators/refCount.js", ["../Subscriber"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = $__require('../Subscriber');
function refCount() {
return function refCountOperatorFunction(source) {
return source.lift(new RefCountOperator(source));
};
}
exports.refCount = refCount;
var RefCountOperator = function () {
function RefCountOperator(connectable) {
this.connectable = connectable;
}
RefCountOperator.prototype.call = function (subscriber, source) {
var connectable = this.connectable;
connectable._refCount++;
var refCounter = new RefCountSubscriber(subscriber, connectable);
var subscription = source.subscribe(refCounter);
if (!refCounter.closed) {
refCounter.connection = connectable.connect();
}
return subscription;
};
return RefCountOperator;
}();
var RefCountSubscriber = function (_super) {
__extends(RefCountSubscriber, _super);
function RefCountSubscriber(destination, connectable) {
_super.call(this, destination);
this.connectable = connectable;
}
RefCountSubscriber.prototype._unsubscribe = function () {
var connectable = this.connectable;
if (!connectable) {
this.connection = null;
return;
}
this.connectable = null;
var refCount = connectable._refCount;
if (refCount <= 0) {
this.connection = null;
return;
}
connectable._refCount = refCount - 1;
if (refCount > 1) {
this.connection = null;
return;
}
///
// Compare the local RefCountSubscriber's connection Subscription to the
// connection Subscription on the shared ConnectableObservable. In cases
// where the ConnectableObservable source synchronously emits values, and
// the RefCountSubscriber's downstream Observers synchronously unsubscribe,
// execution continues to here before the RefCountOperator has a chance to
// supply the RefCountSubscriber with the shared connection Subscription.
// For example:
// ```
// Observable.range(0, 10)
// .publish()
// .refCount()
// .take(5)
// .subscribe();
// ```
// In order to account for this case, RefCountSubscriber should only dispose
// the ConnectableObservable's shared connection Subscription if the
// connection Subscription exists, *and* either:
// a. RefCountSubscriber doesn't have a reference to the shared connection
// Subscription yet, or,
// b. RefCountSubscriber's connection Subscription reference is identical
// to the shared connection Subscription
///
var connection = this.connection;
var sharedConnection = connectable._connection;
this.connection = null;
if (sharedConnection && (!connection || sharedConnection === connection)) {
sharedConnection.unsubscribe();
}
};
return RefCountSubscriber;
}(Subscriber_1.Subscriber);
});
System.registerDynamic('rxjs/operators/share.js', ['./multicast', './refCount', '../Subject'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var multicast_1 = $__require('./multicast');
var refCount_1 = $__require('./refCount');
var Subject_1 = $__require('../Subject');
function shareSubjectFactory() {
return new Subject_1.Subject();
}
/**
* Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
* Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
* This is an alias for .multicast(() => new Subject()).refCount().
*
* <img src="./img/share.png" width="100%">
*
* @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
* @method share
* @owner Observable
*/
function share() {
return function (source) {
return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source));
};
}
exports.share = share;
;
});
System.registerDynamic("rxjs/operator/share.js", ["../operators/share"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var share_1 = $__require('../operators/share');
/**
* Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
* Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
*
* This behaves similarly to .publish().refCount(), with a behavior difference when the source observable emits complete.
* .publish().refCount() will not resubscribe to the original source, however .share() will resubscribe to the original source.
* Observable.of("test").publish().refCount() will not re-emit "test" on new subscriptions, Observable.of("test").share() will
* re-emit "test" to new subscriptions.
*
* <img src="./img/share.png" width="100%">
*
* @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
* @method share
* @owner Observable
*/
function share() {
return share_1.share()(this);
}
exports.share = share;
;
});
System.registerDynamic('rxjs/util/ObjectUnsubscribedError.js', [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when an action is invalid because the object has been
* unsubscribed.
*
* @see {@link Subject}
* @see {@link BehaviorSubject}
*
* @class ObjectUnsubscribedError
*/
var ObjectUnsubscribedError = function (_super) {
__extends(ObjectUnsubscribedError, _super);
function ObjectUnsubscribedError() {
var err = _super.call(this, 'object unsubscribed');
this.name = err.name = 'ObjectUnsubscribedError';
this.stack = err.stack;
this.message = err.message;
}
return ObjectUnsubscribedError;
}(Error);
exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
});
System.registerDynamic("rxjs/SubjectSubscription.js", ["./Subscription"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscription_1 = $__require('./Subscription');
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var SubjectSubscription = function (_super) {
__extends(SubjectSubscription, _super);
function SubjectSubscription(subject, subscriber) {
_super.call(this);
this.subject = subject;
this.subscriber = subscriber;
this.closed = false;
}
SubjectSubscription.prototype.unsubscribe = function () {
if (this.closed) {
return;
}
this.closed = true;
var subject = this.subject;
var observers = subject.observers;
this.subject = null;
if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
return;
}
var subscriberIndex = observers.indexOf(this.subscriber);
if (subscriberIndex !== -1) {
observers.splice(subscriberIndex, 1);
}
};
return SubjectSubscription;
}(Subscription_1.Subscription);
exports.SubjectSubscription = SubjectSubscription;
});
System.registerDynamic('rxjs/Subject.js', ['./Observable', './Subscriber', './Subscription', './util/ObjectUnsubscribedError', './SubjectSubscription', './symbol/rxSubscriber'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = $__require('./Observable');
var Subscriber_1 = $__require('./Subscriber');
var Subscription_1 = $__require('./Subscription');
var ObjectUnsubscribedError_1 = $__require('./util/ObjectUnsubscribedError');
var SubjectSubscription_1 = $__require('./SubjectSubscription');
var rxSubscriber_1 = $__require('./symbol/rxSubscriber');
/**
* @class SubjectSubscriber<T>
*/
var SubjectSubscriber = function (_super) {
__extends(SubjectSubscriber, _super);
function SubjectSubscriber(destination) {
_super.call(this, destination);
this.destination = destination;
}
return SubjectSubscriber;
}(Subscriber_1.Subscriber);
exports.SubjectSubscriber = SubjectSubscriber;
/**
* @class Subject<T>
*/
var Subject = function (_super) {
__extends(Subject, _super);
function Subject() {
_super.call(this);
this.observers = [];
this.closed = false;
this.isStopped = false;
this.hasError = false;
this.thrownError = null;
}
Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
return new SubjectSubscriber(this);
};
Subject.prototype.lift = function (operator) {
var subject = new AnonymousSubject(this, this);
subject.operator = operator;
return subject;
};
Subject.prototype.next = function (value) {
if (this.closed) {
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
}
if (!this.isStopped) {
var observers = this.observers;
var len = observers.length;
var copy = observers.slice();
for (var i = 0; i < len; i++) {
copy[i].next(value);
}
}
};
Subject.prototype.error = function (err) {
if (this.closed) {
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
}
this.hasError = true;
this.thrownError = err;
this.isStopped = true;
var observers = this.observers;
var len = observers.length;
var copy = observers.slice();
for (var i = 0; i < len; i++) {
copy[i].error(err);
}
this.observers.length = 0;
};
Subject.prototype.complete = function () {
if (this.closed) {
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
}
this.isStopped = true;
var observers = this.observers;
var len = observers.length;
var copy = observers.slice();
for (var i = 0; i < len; i++) {
copy[i].complete();
}
this.observers.length = 0;
};
Subject.prototype.unsubscribe = function () {
this.isStopped = true;
this.closed = true;
this.observers = null;
};
Subject.prototype._trySubscribe = function (subscriber) {
if (this.closed) {
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
} else {
return _super.prototype._trySubscribe.call(this, subscriber);
}
};
Subject.prototype._subscribe = function (subscriber) {
if (this.closed) {
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
} else if (this.hasError) {
subscriber.error(this.thrownError);
return Subscription_1.Subscription.EMPTY;
} else if (this.isStopped) {
subscriber.complete();
return Subscription_1.Subscription.EMPTY;
} else {
this.observers.push(subscriber);
return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
}
};
Subject.prototype.asObservable = function () {
var observable = new Observable_1.Observable();
observable.source = this;
return observable;
};
Subject.create = function (destination, source) {
return new AnonymousSubject(destination, source);
};
return Subject;
}(Observable_1.Observable);
exports.Subject = Subject;
/**
* @class AnonymousSubject<T>
*/
var AnonymousSubject = function (_super) {
__extends(AnonymousSubject, _super);
function AnonymousSubject(destination, source) {
_super.call(this);
this.destination = destination;
this.source = source;
}
AnonymousSubject.prototype.next = function (value) {
var destination = this.destination;
if (destination && destination.next) {
destination.next(value);
}
};
AnonymousSubject.prototype.error = function (err) {
var destination = this.destination;
if (destination && destination.error) {
this.destination.error(err);
}
};
AnonymousSubject.prototype.complete = function () {
var destination = this.destination;
if (destination && destination.complete) {
this.destination.complete();
}
};
AnonymousSubject.prototype._subscribe = function (subscriber) {
var source = this.source;
if (source) {
return this.source.subscribe(subscriber);
} else {
return Subscription_1.Subscription.EMPTY;
}
};
return AnonymousSubject;
}(Subject);
exports.AnonymousSubject = AnonymousSubject;
});
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/Observable'), require('rxjs/observable/merge'), require('rxjs/operator/share'), require('rxjs/Subject')) : 'function' === 'function' && true ? System.registerDynamic('@angular/core/bundles/core.umd.js', ['rxjs/Observable', 'rxjs/observable/merge', 'rxjs/operator/share', 'rxjs/Subject'], false, function ($__require, $__exports, $__module) {
return factory.call($__exports, $__exports, $__require('rxjs/Observable'), $__require('rxjs/observable/merge'), $__require('rxjs/operator/share'), $__require('rxjs/Subject'));
}) : factory((global.ng = global.ng || {}, global.ng.core = {}), global.Rx, global.Rx.Observable, global.Rx.Observable.prototype, global.Rx);
})(this, function (exports, rxjs_Observable, rxjs_observable_merge, rxjs_operator_share, rxjs_Subject) {
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
};
function __extends(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
/**
* @license Angular v5.1.0
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Creates a token that can be used in a DI Provider.
*
* Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
* runtime representation) such as when injecting an interface, callable type, array or
* parametrized type.
*
* `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
* the `Injector`. This provides additional level of type safety.
*
* ```
* interface MyInterface {...}
* var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
* // myInterface is inferred to be MyInterface.
* ```
*
* ### Example
*
* {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
*
* \@stable
*/
var InjectionToken = /** @class */function () {
function InjectionToken(_desc) {
this._desc = _desc;
/**
* \@internal
*/
this.ngMetadataName = 'InjectionToken';
}
/**
* @return {?}
*/
InjectionToken.prototype.toString = /**
* @return {?}
*/
function () {
return "InjectionToken " + this._desc;
};
return InjectionToken;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An interface implemented by all Angular type decorators, which allows them to be used as ES7
* decorators as well as
* Angular DSL syntax.
*
* ES7 syntax:
*
* ```
* \@ng.Component({...})
* class MyClass {...}
* ```
* \@stable
* @record
*/
var ANNOTATIONS = '__annotations__';
var PARAMETERS = '__paramaters__';
var PROP_METADATA = '__prop__metadata__';
/**
* @suppress {globalThis}
* @param {?} name
* @param {?=} props
* @param {?=} parentClass
* @param {?=} chainFn
* @return {?}
*/
function makeDecorator(name, props, parentClass, chainFn) {
var /** @type {?} */metaCtor = makeMetadataCtor(props);
/**
* @param {?} objOrType
* @return {?}
*/
function DecoratorFactory(objOrType) {
if (this instanceof DecoratorFactory) {
metaCtor.call(this, objOrType);
return this;
}
var /** @type {?} */annotationInstance = new /** @type {?} */DecoratorFactory(objOrType);
var /** @type {?} */TypeDecorator = /** @type {?} */function TypeDecorator(cls) {
// Use of Object.defineProperty is important since it creates non-enumerable property which
// prevents the property is copied during subclassing.
var /** @type {?} */annotations = cls.hasOwnProperty(ANNOTATIONS) ? /** @type {?} */cls[ANNOTATIONS] : Object.defineProperty(cls, ANNOTATIONS, { value: [] })[ANNOTATIONS];
annotations.push(annotationInstance);
return cls;
};
if (chainFn) chainFn(TypeDecorator);
return TypeDecorator;
}
if (parentClass) {
DecoratorFactory.prototype = Object.create(parentClass.prototype);
}
DecoratorFactory.prototype.ngMetadataName = name;
/** @type {?} */DecoratorFactory.annotationCls = DecoratorFactory;
return (/** @type {?} */DecoratorFactory
);
}
/**
* @param {?=} props
* @return {?}
*/
function makeMetadataCtor(props) {
return function ctor() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (props) {
var /** @type {?} */values = props.apply(void 0, args);
for (var /** @type {?} */propName in values) {
this[propName] = values[propName];
}
}
};
}
/**
* @param {?} name
* @param {?=} props
* @param {?=} parentClass
* @return {?}
*/
function makeParamDecorator(name, props, parentClass) {
var /** @type {?} */metaCtor = makeMetadataCtor(props);
/**
* @param {...?} args
* @return {?}
*/
function ParamDecoratorFactory() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this instanceof ParamDecoratorFactory) {
metaCtor.apply(this, args);
return this;
}
var /** @type {?} */annotationInstance = new ((_a = /** @type {?} */ParamDecoratorFactory).bind.apply(_a, [void 0].concat(args)))();
/** @type {?} */ParamDecorator.annotation = annotationInstance;
return ParamDecorator;
/**
* @param {?} cls
* @param {?} unusedKey
* @param {?} index
* @return {?}
*/
function ParamDecorator(cls, unusedKey, index) {
// Use of Object.defineProperty is important since it creates non-enumerable property which
// prevents the property is copied during subclassing.
var /** @type {?} */parameters = cls.hasOwnProperty(PARAMETERS) ? /** @type {?} */cls[PARAMETERS] : Object.defineProperty(cls, PARAMETERS, { value: [] })[PARAMETERS];
// there might be gaps if some in between parameters do not have annotations.
// we pad with nulls.
while (parameters.length <= index) {
parameters.push(null);
}
(parameters[index] = parameters[index] || []).push(annotationInstance);
return cls;
}
var _a;
}
if (parentClass) {
ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
}
ParamDecoratorFactory.prototype.ngMetadataName = name;
/** @type {?} */ParamDecoratorFactory.annotationCls = ParamDecoratorFactory;
return ParamDecoratorFactory;
}
/**
* @param {?} name
* @param {?=} props
* @param {?=} parentClass
* @return {?}
*/
function makePropDecorator(name, props, parentClass) {
var /** @type {?} */metaCtor = makeMetadataCtor(props);
/**
* @param {...?} args
* @return {?}
*/
function PropDecoratorFactory() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this instanceof PropDecoratorFactory) {
metaCtor.apply(this, args);
return this;
}
var /** @type {?} */decoratorInstance = new ((_a = /** @type {?} */PropDecoratorFactory).bind.apply(_a, [void 0].concat(args)))();
return function PropDecorator(target, name) {
var /** @type {?} */constructor = target.constructor;
// Use of Object.defineProperty is important since it creates non-enumerable property which
// prevents the property is copied during subclassing.
var /** @type {?} */meta = constructor.hasOwnProperty(PROP_METADATA) ? /** @type {?} */constructor[PROP_METADATA] : Object.defineProperty(constructor, PROP_METADATA, { value: {} })[PROP_METADATA];
meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
meta[name].unshift(decoratorInstance);
};
var _a;
}
if (parentClass) {
PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
}
PropDecoratorFactory.prototype.ngMetadataName = name;
/** @type {?} */PropDecoratorFactory.annotationCls = PropDecoratorFactory;
return PropDecoratorFactory;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* This token can be used to create a virtual provider that will populate the
* `entryComponents` fields of components and ng modules based on its `useValue`.
* All components that are referenced in the `useValue` value (either directly
* or in a nested array or map) will be added to the `entryComponents` property.
*
* ### Example
* The following example shows how the router can populate the `entryComponents`
* field of an NgModule based on the router configuration which refers
* to components.
*
* ```typescript
* // helper function inside the router
* function provideRoutes(routes) {
* return [
* {provide: ROUTES, useValue: routes},
* {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
* ];
* }
*
* // user code
* let routes = [
* {path: '/root', component: RootComp},
* {path: '/teams', component: TeamsComp}
* ];
*
* \@NgModule({
* providers: [provideRoutes(routes)]
* })
* class ModuleWithRoutes {}
* ```
*
* \@experimental
*/
var ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
/**
* Type of the Attribute decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Attribute decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Attribute = makeParamDecorator('Attribute', function (attributeName) {
return { attributeName: attributeName };
});
/**
* Base class for query metadata.
*
* See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
* more information.
*
* \@stable
* @abstract
*/
var Query = /** @class */function () {
function Query() {}
return Query;
}();
/**
* Type of the ContentChildren decorator / constructor function.
*
* See {\@link ContentChildren}.
*
* \@stable
* @record
*/
/**
* ContentChildren decorator and metadata.
*
* \@stable
* \@Annotation
*/
var ContentChildren = makePropDecorator('ContentChildren', function (selector, data) {
if (data === void 0) {
data = {};
}
return __assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data);
}, Query);
/**
* Type of the ContentChild decorator / constructor function.
*
*
* \@stable
* @record
*/
/**
* ContentChild decorator and metadata.
*
* \@stable
* \@Annotation
*/
var ContentChild = makePropDecorator('ContentChild', function (selector, data) {
if (data === void 0) {
data = {};
}
return __assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data);
}, Query);
/**
* Type of the ViewChildren decorator / constructor function.
*
* See {\@link ViewChildren}.
*
* \@stable
* @record
*/
/**
* ViewChildren decorator and metadata.
*
* \@stable
* \@Annotation
*/
var ViewChildren = makePropDecorator('ViewChildren', function (selector, data) {
if (data === void 0) {
data = {};
}
return __assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data);
}, Query);
/**
* Type of the ViewChild decorator / constructor function.
*
* See {\@link ViewChild}
*
* \@stable
* @record
*/
/**
* ViewChild decorator and metadata.
*
* \@stable
* \@Annotation
*/
var ViewChild = makePropDecorator('ViewChild', function (selector, data) {
return __assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data);
}, Query);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/** @enum {number} */
var ChangeDetectionStrategy = {
/**
* `OnPush` means that the change detector's mode will be initially set to `CheckOnce`.
*/
OnPush: 0,
/**
* `Default` means that the change detector's mode will be initially set to `CheckAlways`.
*/
Default: 1
};
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
/** @enum {number} */
var ChangeDetectorStatus = {
/**
* `CheckOnce` means that after calling detectChanges the mode of the change detector
* will become `Checked`.
*/
CheckOnce: 0,
/**
* `Checked` means that the change detector should be skipped until its mode changes to
* `CheckOnce`.
*/
Checked: 1,
/**
* `CheckAlways` means that after calling detectChanges the mode of the change detector
* will remain `CheckAlways`.
*/
CheckAlways: 2,
/**
* `Detached` means that the change detector sub tree is not a part of the main tree and
* should be skipped.
*/
Detached: 3,
/**
* `Errored` means that the change detector encountered an error checking a binding
* or calling a directive lifecycle method and is now in an inconsistent state. Change
* detectors in this state will no longer detect changes.
*/
Errored: 4,
/**
* `Destroyed` means that the change detector is destroyed.
*/
Destroyed: 5
};
ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
/**
* @param {?} changeDetectionStrategy
* @return {?}
*/
function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
return changeDetectionStrategy == null || changeDetectionStrategy === ChangeDetectionStrategy.Default;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Type of the Directive decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Directive decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Directive = makeDecorator('Directive', function (dir) {
if (dir === void 0) {
dir = {};
}
return dir;
});
/**
* Type of the Component decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Component decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Component = makeDecorator('Component', function (c) {
if (c === void 0) {
c = {};
}
return __assign({ changeDetection: ChangeDetectionStrategy.Default }, c);
}, Directive);
/**
* Type of the Pipe decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Pipe decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Pipe = makeDecorator('Pipe', function (p) {
return __assign({ pure: true }, p);
});
/**
* Type of the Input decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Input decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Input = makePropDecorator('Input', function (bindingPropertyName) {
return { bindingPropertyName: bindingPropertyName };
});
/**
* Type of the Output decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Output decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Output = makePropDecorator('Output', function (bindingPropertyName) {
return { bindingPropertyName: bindingPropertyName };
});
/**
* Type of the HostBinding decorator / constructor function.
*
* \@stable
* @record
*/
/**
* HostBinding decorator and metadata.
*
* \@stable
* \@Annotation
*/
var HostBinding = makePropDecorator('HostBinding', function (hostPropertyName) {
return { hostPropertyName: hostPropertyName };
});
/**
* Type of the HostListener decorator / constructor function.
*
* \@stable
* @record
*/
/**
* HostListener decorator and metadata.
*
* \@stable
* \@Annotation
*/
var HostListener = makePropDecorator('HostListener', function (eventName, args) {
return { eventName: eventName, args: args };
});
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A wrapper around a module that also includes the providers.
*
* \@stable
* @record
*/
/**
* Interface for schema definitions in \@NgModules.
*
* \@experimental
* @record
*/
/**
* Defines a schema that will allow:
* - any non-Angular elements with a `-` in their name,
* - any properties on elements with a `-` in their name which is the common rule for custom
* elements.
*
* \@stable
*/
var CUSTOM_ELEMENTS_SCHEMA = {
name: 'custom-elements'
};
/**
* Defines a schema that will allow any property on any element.
*
* \@experimental
*/
var NO_ERRORS_SCHEMA = {
name: 'no-errors-schema'
};
/**
* Type of the NgModule decorator / constructor function.
*
* \@stable
* @record
*/
/**
* NgModule decorator and metadata.
*
* \@stable
* \@Annotation
*/
var NgModule = makeDecorator('NgModule', function (ngModule) {
return ngModule;
});
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/** @enum {number} */
var ViewEncapsulation = {
/**
* Emulate `Native` scoping of styles by adding an attribute containing surrogate id to the Host
* Element and pre-processing the style rules provided via {@link Component#styles styles} or
* {@link Component#styleUrls styleUrls}, and adding the new Host Element attribute to all
* selectors.
*
* This is the default option.
*/
Emulated: 0,
/**
* Use the native encapsulation mechanism of the renderer.
*
* For the DOM this means using [Shadow DOM](https://w3c.github.io/webcomponents/spec/shadow/) and
* creating a ShadowRoot for Component's Host Element.
*/
Native: 1,
/**
* Don't provide any template or style encapsulation.
*/
None: 2
};
ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
ViewEncapsulation[ViewEncapsulation.Native] = "Native";
ViewEncapsulation[ViewEncapsulation.None] = "None";
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Represents the version of Angular
*
* \@stable
*/
var Version = /** @class */function () {
function Version(full) {
this.full = full;
this.major = full.split('.')[0];
this.minor = full.split('.')[1];
this.patch = full.split('.').slice(2).join('.');
}
return Version;
}();
/**
* \@stable
*/
var VERSION = new Version('5.1.0');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Type of the Inject decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Inject decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Inject = makeParamDecorator('Inject', function (token) {
return { token: token };
});
/**
* Type of the Optional decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Optional decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Optional = makeParamDecorator('Optional');
/**
* Type of the Injectable decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Injectable decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Injectable = makeDecorator('Injectable');
/**
* Type of the Self decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Self decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Self = makeParamDecorator('Self');
/**
* Type of the SkipSelf decorator / constructor function.
*
* \@stable
* @record
*/
/**
* SkipSelf decorator and metadata.
*
* \@stable
* \@Annotation
*/
var SkipSelf = makeParamDecorator('SkipSelf');
/**
* Type of the Host decorator / constructor function.
*
* \@stable
* @record
*/
/**
* Host decorator and metadata.
*
* \@stable
* \@Annotation
*/
var Host = makeParamDecorator('Host');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self;
var __global = typeof global !== 'undefined' && global;
var _global = __window || __global || __self;
var _symbolIterator = null;
/**
* @return {?}
*/
function getSymbolIterator() {
if (!_symbolIterator) {
var /** @type {?} */Symbol_1 = _global['Symbol'];
if (Symbol_1 && Symbol_1.iterator) {
_symbolIterator = Symbol_1.iterator;
} else {
// es6-shim specific logic
var /** @type {?} */keys = Object.getOwnPropertyNames(Map.prototype);
for (var /** @type {?} */i = 0; i < keys.length; ++i) {
var /** @type {?} */key = keys[i];
if (key !== 'entries' && key !== 'size' && /** @type {?} */Map.prototype[key] === Map.prototype['entries']) {
_symbolIterator = key;
}
}
}
}
return _symbolIterator;
}
/**
* @param {?} fn
* @return {?}
*/
function scheduleMicroTask(fn) {
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
}
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function looseIdentical(a, b) {
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
}
/**
* @param {?} token
* @return {?}
*/
function stringify(token) {
if (typeof token === 'string') {
return token;
}
if (token instanceof Array) {
return '[' + token.map(stringify).join(', ') + ']';
}
if (token == null) {
return '' + token;
}
if (token.overriddenName) {
return "" + token.overriddenName;
}
if (token.name) {
return "" + token.name;
}
var /** @type {?} */res = token.toString();
if (res == null) {
return '' + res;
}
var /** @type {?} */newLineIndex = res.indexOf('\n');
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An interface that a function passed into {\@link forwardRef} has to implement.
*
* ### Example
*
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref_fn'}
* \@experimental
* @record
*/
/**
* Allows to refer to references which are not yet defined.
*
* For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
* DI is declared,
* but not yet defined. It is also used when the `token` which we use when creating a query is not
* yet defined.
*
* ### Example
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
* \@experimental
* @param {?} forwardRefFn
* @return {?}
*/
function forwardRef(forwardRefFn) {
/** @type {?} */forwardRefFn.__forward_ref__ = forwardRef;
/** @type {?} */forwardRefFn.toString = function () {
return stringify(this());
};
return (/** @type {?} */ /** @type {?} */forwardRefFn
);
}
/**
* Lazily retrieves the reference value from a forwardRef.
*
* Acts as the identity function when given a non-forward-ref value.
*
* ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
*
* {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
*
* See: {\@link forwardRef}
* \@experimental
* @param {?} type
* @return {?}
*/
function resolveForwardRef(type) {
if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') && type.__forward_ref__ === forwardRef) {
return (/** @type {?} */type()
);
} else {
return type;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _THROW_IF_NOT_FOUND = new Object();
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
var _NullInjector = /** @class */function () {
function _NullInjector() {}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
_NullInjector.prototype.get = /**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
function (token, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = _THROW_IF_NOT_FOUND;
}
if (notFoundValue === _THROW_IF_NOT_FOUND) {
throw new Error("NullInjectorError: No provider for " + stringify(token) + "!");
}
return notFoundValue;
};
return _NullInjector;
}();
/**
* \@whatItDoes Injector interface
* \@howToUse
* ```
* const injector: Injector = ...;
* injector.get(...);
* ```
*
* \@description
* For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
*
* ### Example
*
* {\@example core/di/ts/injector_spec.ts region='Injector'}
*
* `Injector` returns itself when given `Injector` as a token:
* {\@example core/di/ts/injector_spec.ts region='injectInjector'}
*
* \@stable
* @abstract
*/
var Injector = /** @class */function () {
function Injector() {}
/**
* Create a new Injector which is configure using `StaticProvider`s.
*
* ### Example
*
* {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
*/
/**
* Create a new Injector which is configure using `StaticProvider`s.
*
* ### Example
*
* {\@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
Injector.create = /**
* Create a new Injector which is configure using `StaticProvider`s.
*
* ### Example
*
* {\@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
function (providers, parent) {
return new StaticInjector(providers, parent);
};
Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
Injector.NULL = new _NullInjector();
return Injector;
}();
var IDENT = function (value) {
return value;
};
var EMPTY = /** @type {?} */[];
var CIRCULAR = IDENT;
var MULTI_PROVIDER_FN = function () {
return Array.prototype.slice.call(arguments);
};
var GET_PROPERTY_NAME = /** @type {?} */{};
var ɵ2 = GET_PROPERTY_NAME;
var USE_VALUE = getClosureSafeProperty({ provide: String, useValue: ɵ2 });
var NG_TOKEN_PATH = 'ngTokenPath';
var NG_TEMP_TOKEN_PATH = 'ngTempTokenPath';
var NULL_INJECTOR = Injector.NULL;
var NEW_LINE = /\n/gm;
var NO_NEW_LINE = 'ɵ';
var StaticInjector = /** @class */function () {
function StaticInjector(providers, parent) {
if (parent === void 0) {
parent = NULL_INJECTOR;
}
this.parent = parent;
var /** @type {?} */records = this._records = new Map();
records.set(Injector, /** @type {?} */{ token: Injector, fn: IDENT, deps: EMPTY, value: this, useNew: false });
recursivelyProcessProviders(records, providers);
}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
StaticInjector.prototype.get = /**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
function (token, notFoundValue) {
var /** @type {?} */record = this._records.get(token);
try {
return tryResolveToken(token, record, this._records, this.parent, notFoundValue);
} catch ( /** @type {?} */e) {
var /** @type {?} */tokenPath = e[NG_TEMP_TOKEN_PATH];
e.message = formatError('\n' + e.message, tokenPath);
e[NG_TOKEN_PATH] = tokenPath;
e[NG_TEMP_TOKEN_PATH] = null;
throw e;
}
};
/**
* @return {?}
*/
StaticInjector.prototype.toString = /**
* @return {?}
*/
function () {
var /** @type {?} */tokens = /** @type {?} */[],
/** @type {?} */records = this._records;
records.forEach(function (v, token) {
return tokens.push(stringify(token));
});
return "StaticInjector[" + tokens.join(', ') + "]";
};
return StaticInjector;
}();
/**
* @param {?} provider
* @return {?}
*/
function resolveProvider(provider) {
var /** @type {?} */deps = computeDeps(provider);
var /** @type {?} */fn = IDENT;
var /** @type {?} */value = EMPTY;
var /** @type {?} */useNew = false;
var /** @type {?} */provide = resolveForwardRef(provider.provide);
if (USE_VALUE in provider) {
// We need to use USE_VALUE in provider since provider.useValue could be defined as undefined.
value = /** @type {?} */provider.useValue;
} else if ( /** @type {?} */provider.useFactory) {
fn = /** @type {?} */provider.useFactory;
} else if ( /** @type {?} */provider.useExisting) {
// Just use IDENT
} else if ( /** @type {?} */provider.useClass) {
useNew = true;
fn = resolveForwardRef( /** @type {?} */provider.useClass);
} else if (typeof provide == 'function') {
useNew = true;
fn = provide;
} else {
throw staticError('StaticProvider does not have [useValue|useFactory|useExisting|useClass] or [provide] is not newable', provider);
}
return { deps: deps, fn: fn, useNew: useNew, value: value };
}
/**
* @param {?} token
* @return {?}
*/
function multiProviderMixError(token) {
return staticError('Cannot mix multi providers and regular providers', token);
}
/**
* @param {?} records
* @param {?} provider
* @return {?}
*/
function recursivelyProcessProviders(records, provider) {
if (provider) {
provider = resolveForwardRef(provider);
if (provider instanceof Array) {
// if we have an array recurse into the array
for (var /** @type {?} */i = 0; i < provider.length; i++) {
recursivelyProcessProviders(records, provider[i]);
}
} else if (typeof provider === 'function') {
// Functions were supported in ReflectiveInjector, but are not here. For safety give useful
// error messages
throw staticError('Function/Class not supported', provider);
} else if (provider && typeof provider === 'object' && provider.provide) {
// At this point we have what looks like a provider: {provide: ?, ....}
var /** @type {?} */token = resolveForwardRef(provider.provide);
var /** @type {?} */resolvedProvider = resolveProvider(provider);
if (provider.multi === true) {
// This is a multi provider.
var /** @type {?} */multiProvider = records.get(token);
if (multiProvider) {
if (multiProvider.fn !== MULTI_PROVIDER_FN) {
throw multiProviderMixError(token);
}
} else {
// Create a placeholder factory which will look up the constituents of the multi provider.
records.set(token, multiProvider = /** @type {?} */{
token: provider.provide,
deps: [],
useNew: false,
fn: MULTI_PROVIDER_FN,
value: EMPTY
});
}
// Treat the provider as the token.
token = provider;
multiProvider.deps.push({ token: token, options: 6 /* Default */ });
}
var /** @type {?} */record = records.get(token);
if (record && record.fn == MULTI_PROVIDER_FN) {
throw multiProviderMixError(token);
}
records.set(token, resolvedProvider);
} else {
throw staticError('Unexpected provider', provider);
}
}
}
/**
* @param {?} token
* @param {?} record
* @param {?} records
* @param {?} parent
* @param {?} notFoundValue
* @return {?}
*/
function tryResolveToken(token, record, records, parent, notFoundValue) {
try {
return resolveToken(token, record, records, parent, notFoundValue);
} catch ( /** @type {?} */e) {
// ensure that 'e' is of type Error.
if (!(e instanceof Error)) {
e = new Error(e);
}
var /** @type {?} */path = e[NG_TEMP_TOKEN_PATH] = e[NG_TEMP_TOKEN_PATH] || [];
path.unshift(token);
if (record && record.value == CIRCULAR) {
// Reset the Circular flag.
record.value = EMPTY;
}
throw e;
}
}
/**
* @param {?} token
* @param {?} record
* @param {?} records
* @param {?} parent
* @param {?} notFoundValue
* @return {?}
*/
function resolveToken(token, record, records, parent, notFoundValue) {
var /** @type {?} */value;
if (record) {
// If we don't have a record, this implies that we don't own the provider hence don't know how
// to resolve it.
value = record.value;
if (value == CIRCULAR) {
throw Error(NO_NEW_LINE + 'Circular dependency');
} else if (value === EMPTY) {
record.value = CIRCULAR;
var /** @type {?} */obj = undefined;
var /** @type {?} */useNew = record.useNew;
var /** @type {?} */fn = record.fn;
var /** @type {?} */depRecords = record.deps;
var /** @type {?} */deps = EMPTY;
if (depRecords.length) {
deps = [];
for (var /** @type {?} */i = 0; i < depRecords.length; i++) {
var /** @type {?} */depRecord = depRecords[i];
var /** @type {?} */options = depRecord.options;
var /** @type {?} */childRecord = options & 2 /* CheckSelf */ ? records.get(depRecord.token) : undefined;
deps.push(tryResolveToken(
// Current Token to resolve
depRecord.token, childRecord, records,
// If we don't know how to resolve dependency and we should not check parent for it,
// than pass in Null injector.
!childRecord && !(options & 4 /* CheckParent */) ? NULL_INJECTOR : parent, options & 1 /* Optional */ ? null : Injector.THROW_IF_NOT_FOUND));
}
}
record.value = value = useNew ? new ((_a = /** @type {?} */fn).bind.apply(_a, [void 0].concat(deps)))() : fn.apply(obj, deps);
}
} else {
value = parent.get(token, notFoundValue);
}
return value;
var _a;
}
/**
* @param {?} provider
* @return {?}
*/
function computeDeps(provider) {
var /** @type {?} */deps = EMPTY;
var /** @type {?} */providerDeps = /** @type {?} */provider.deps;
if (providerDeps && providerDeps.length) {
deps = [];
for (var /** @type {?} */i = 0; i < providerDeps.length; i++) {
var /** @type {?} */options = 6;
var /** @type {?} */token = resolveForwardRef(providerDeps[i]);
if (token instanceof Array) {
for (var /** @type {?} */j = 0, /** @type {?} */annotations = token; j < annotations.length; j++) {
var /** @type {?} */annotation = annotations[j];
if (annotation instanceof Optional || annotation == Optional) {
options = options | 1 /* Optional */;
} else if (annotation instanceof SkipSelf || annotation == SkipSelf) {
options = options & ~2 /* CheckSelf */;
} else if (annotation instanceof Self || annotation == Self) {
options = options & ~4 /* CheckParent */;
} else if (annotation instanceof Inject) {
token = /** @type {?} */annotation.token;
} else {
token = resolveForwardRef(annotation);
}
}
}
deps.push({ token: token, options: options });
}
} else if ( /** @type {?} */provider.useExisting) {
var /** @type {?} */token = resolveForwardRef( /** @type {?} */provider.useExisting);
deps = [{ token: token, options: 6 /* Default */ }];
} else if (!providerDeps && !(USE_VALUE in provider)) {
// useValue & useExisting are the only ones which are exempt from deps all others need it.
throw staticError('\'deps\' required', provider);
}
return deps;
}
/**
* @param {?} text
* @param {?} obj
* @return {?}
*/
function formatError(text, obj) {
text = text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text;
var /** @type {?} */context = stringify(obj);
if (obj instanceof Array) {
context = obj.map(stringify).join(' -> ');
} else if (typeof obj === 'object') {
var /** @type {?} */parts = /** @type {?} */[];
for (var /** @type {?} */key in obj) {
if (obj.hasOwnProperty(key)) {
var /** @type {?} */value = obj[key];
parts.push(key + ':' + (typeof value === 'string' ? JSON.stringify(value) : stringify(value)));
}
}
context = "{" + parts.join(', ') + "}";
}
return "StaticInjectorError[" + context + "]: " + text.replace(NEW_LINE, '\n ');
}
/**
* @param {?} text
* @param {?} obj
* @return {?}
*/
function staticError(text, obj) {
return new Error(formatError(text, obj));
}
/**
* @template T
* @param {?} objWithPropertyToExtract
* @return {?}
*/
function getClosureSafeProperty(objWithPropertyToExtract) {
for (var /** @type {?} */key in objWithPropertyToExtract) {
if (objWithPropertyToExtract[key] === GET_PROPERTY_NAME) {
return key;
}
}
throw Error('!prop');
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
var ERROR_LOGGER = 'ngErrorLogger';
/**
* @param {?} error
* @return {?}
*/
/**
* @param {?} error
* @return {?}
*/
function getDebugContext(error) {
return (/** @type {?} */error[ERROR_DEBUG_CONTEXT]
);
}
/**
* @param {?} error
* @return {?}
*/
function getOriginalError(error) {
return (/** @type {?} */error[ERROR_ORIGINAL_ERROR]
);
}
/**
* @param {?} error
* @return {?}
*/
function getErrorLogger(error) {
return (/** @type {?} */error[ERROR_LOGGER] || defaultErrorLogger
);
}
/**
* @param {?} console
* @param {...?} values
* @return {?}
*/
function defaultErrorLogger(console) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
console.error.apply(console, values);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Provides a hook for centralized exception handling.
*
* \@description
*
* The default implementation of `ErrorHandler` prints error messages to the `console`. To
* intercept error handling, write a custom exception handler that replaces this default as
* appropriate for your app.
*
* ### Example
*
* ```
* class MyErrorHandler implements ErrorHandler {
* handleError(error) {
* // do something with the exception
* }
* }
*
* \@NgModule({
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
* })
* class MyModule {}
* ```
*
* \@stable
*/
var ErrorHandler = /** @class */function () {
function ErrorHandler() {
/**
* \@internal
*/
this._console = console;
}
/**
* @param {?} error
* @return {?}
*/
ErrorHandler.prototype.handleError = /**
* @param {?} error
* @return {?}
*/
function (error) {
var /** @type {?} */originalError = this._findOriginalError(error);
var /** @type {?} */context = this._findContext(error);
// Note: Browser consoles show the place from where console.error was called.
// We can use this to give users additional information about the error.
var /** @type {?} */errorLogger = getErrorLogger(error);
errorLogger(this._console, "ERROR", error);
if (originalError) {
errorLogger(this._console, "ORIGINAL ERROR", originalError);
}
if (context) {
errorLogger(this._console, 'ERROR CONTEXT', context);
}
};
/** @internal */
/**
* \@internal
* @param {?} error
* @return {?}
*/
ErrorHandler.prototype._findContext = /**
* \@internal
* @param {?} error
* @return {?}
*/
function (error) {
if (error) {
return getDebugContext(error) ? getDebugContext(error) : this._findContext(getOriginalError(error));
}
return null;
};
/** @internal */
/**
* \@internal
* @param {?} error
* @return {?}
*/
ErrorHandler.prototype._findOriginalError = /**
* \@internal
* @param {?} error
* @return {?}
*/
function (error) {
var /** @type {?} */e = getOriginalError(error);
while (e && getOriginalError(e)) {
e = getOriginalError(e);
}
return e;
};
return ErrorHandler;
}();
/**
* @param {?} message
* @param {?} originalError
* @return {?}
*/
function wrappedError(message, originalError) {
var /** @type {?} */msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
var /** @type {?} */error = Error(msg);
/** @type {?} */error[ERROR_ORIGINAL_ERROR] = originalError;
return error;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} keys
* @return {?}
*/
function findFirstClosedCycle(keys) {
var /** @type {?} */res = [];
for (var /** @type {?} */i = 0; i < keys.length; ++i) {
if (res.indexOf(keys[i]) > -1) {
res.push(keys[i]);
return res;
}
res.push(keys[i]);
}
return res;
}
/**
* @param {?} keys
* @return {?}
*/
function constructResolvingPath(keys) {
if (keys.length > 1) {
var /** @type {?} */reversed = findFirstClosedCycle(keys.slice().reverse());
var /** @type {?} */tokenStrs = reversed.map(function (k) {
return stringify(k.token);
});
return ' (' + tokenStrs.join(' -> ') + ')';
}
return '';
}
/**
* @record
*/
/**
* @param {?} injector
* @param {?} key
* @param {?} constructResolvingMessage
* @param {?=} originalError
* @return {?}
*/
function injectionError(injector, key, constructResolvingMessage, originalError) {
var /** @type {?} */keys = [key];
var /** @type {?} */errMsg = constructResolvingMessage(keys);
var /** @type {?} */error = /** @type {?} */originalError ? wrappedError(errMsg, originalError) : Error(errMsg);
error.addKey = addKey;
error.keys = keys;
error.injectors = [injector];
error.constructResolvingMessage = constructResolvingMessage;
/** @type {?} */error[ERROR_ORIGINAL_ERROR] = originalError;
return error;
}
/**
* @this {?}
* @param {?} injector
* @param {?} key
* @return {?}
*/
function addKey(injector, key) {
this.injectors.push(injector);
this.keys.push(key);
// Note: This updated message won't be reflected in the `.stack` property
this.message = this.constructResolvingMessage(this.keys);
}
/**
* Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
* {\@link Injector} does not have a {\@link Provider} for the given key.
*
* ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
*
* ```typescript
* class A {
* constructor(b:B) {}
* }
*
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
* ```
* @param {?} injector
* @param {?} key
* @return {?}
*/
function noProviderError(injector, key) {
return injectionError(injector, key, function (keys) {
var /** @type {?} */first = stringify(keys[0].token);
return "No provider for " + first + "!" + constructResolvingPath(keys);
});
}
/**
* Thrown when dependencies form a cycle.
*
* ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
*
* ```typescript
* var injector = Injector.resolveAndCreate([
* {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
* {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
* ]);
*
* expect(() => injector.get("one")).toThrowError();
* ```
*
* Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
* @param {?} injector
* @param {?} key
* @return {?}
*/
function cyclicDependencyError(injector, key) {
return injectionError(injector, key, function (keys) {
return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
});
}
/**
* Thrown when a constructing type returns with an Error.
*
* The `InstantiationError` class contains the original error plus the dependency graph which caused
* this object to be instantiated.
*
* ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
*
* ```typescript
* class A {
* constructor() {
* throw new Error('message');
* }
* }
*
* var injector = Injector.resolveAndCreate([A]);
* try {
* injector.get(A);
* } catch (e) {
* expect(e instanceof InstantiationError).toBe(true);
* expect(e.originalException.message).toEqual("message");
* expect(e.originalStack).toBeDefined();
* }
* ```
* @param {?} injector
* @param {?} originalException
* @param {?} originalStack
* @param {?} key
* @return {?}
*/
function instantiationError(injector, originalException, originalStack, key) {
return injectionError(injector, key, function (keys) {
var /** @type {?} */first = stringify(keys[0].token);
return originalException.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(keys) + ".";
}, originalException);
}
/**
* Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
* creation.
*
* ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
*
* ```typescript
* expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
* ```
* @param {?} provider
* @return {?}
*/
function invalidProviderError(provider) {
return Error("Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
}
/**
* Thrown when the class has no annotation information.
*
* Lack of annotation information prevents the {\@link Injector} from determining which dependencies
* need to be injected into the constructor.
*
* ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
*
* ```typescript
* class A {
* constructor(b) {}
* }
*
* expect(() => Injector.resolveAndCreate([A])).toThrowError();
* ```
*
* This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
*
* ```typescript
* class B {}
*
* class A {
* constructor(b:B) {} // no information about the parameter types of A is available at runtime.
* }
*
* expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
* ```
* \@stable
* @param {?} typeOrFunc
* @param {?} params
* @return {?}
*/
function noAnnotationError(typeOrFunc, params) {
var /** @type {?} */signature = [];
for (var /** @type {?} */i = 0, /** @type {?} */ii = params.length; i < ii; i++) {
var /** @type {?} */parameter = params[i];
if (!parameter || parameter.length == 0) {
signature.push('?');
} else {
signature.push(parameter.map(stringify).join(' '));
}
}
return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' + signature.join(', ') + '). ' + 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' + stringify(typeOrFunc) + '\' is decorated with Injectable.');
}
/**
* Thrown when getting an object by index.
*
* ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
*
* ```typescript
* class A {}
*
* var injector = Injector.resolveAndCreate([A]);
*
* expect(() => injector.getAt(100)).toThrowError();
* ```
* \@stable
* @param {?} index
* @return {?}
*/
function outOfBoundsError(index) {
return Error("Index " + index + " is out-of-bounds.");
}
/**
* Thrown when a multi provider and a regular provider are bound to the same token.
*
* ### Example
*
* ```typescript
* expect(() => Injector.resolveAndCreate([
* { provide: "Strings", useValue: "string1", multi: true},
* { provide: "Strings", useValue: "string2", multi: false}
* ])).toThrowError();
* ```
* @param {?} provider1
* @param {?} provider2
* @return {?}
*/
function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
return Error("Cannot mix multi providers and regular providers, got: " + provider1 + " " + provider2);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A unique object used for retrieving items from the {\@link ReflectiveInjector}.
*
* Keys have:
* - a system-wide unique `id`.
* - a `token`.
*
* `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
* the
* injector to store created objects in a more efficient way.
*
* `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
* resolving
* providers.
* @deprecated No replacement
*/
var ReflectiveKey = /** @class */function () {
/**
* Private
*/
function ReflectiveKey(token, id) {
this.token = token;
this.id = id;
if (!token) {
throw new Error('Token must be defined!');
}
this.displayName = stringify(this.token);
}
/**
* Retrieves a `Key` for a token.
*/
/**
* Retrieves a `Key` for a token.
* @param {?} token
* @return {?}
*/
ReflectiveKey.get = /**
* Retrieves a `Key` for a token.
* @param {?} token
* @return {?}
*/
function (token) {
return _globalKeyRegistry.get(resolveForwardRef(token));
};
Object.defineProperty(ReflectiveKey, "numberOfKeys", {
/**
* @returns the number of keys registered in the system.
*/
get: /**
* @return {?} the number of keys registered in the system.
*/
function () {
return _globalKeyRegistry.numberOfKeys;
},
enumerable: true,
configurable: true
});
return ReflectiveKey;
}();
/**
* \@internal
*/
var KeyRegistry = /** @class */function () {
function KeyRegistry() {
this._allKeys = new Map();
}
/**
* @param {?} token
* @return {?}
*/
KeyRegistry.prototype.get = /**
* @param {?} token
* @return {?}
*/
function (token) {
if (token instanceof ReflectiveKey) return token;
if (this._allKeys.has(token)) {
return (/** @type {?} */this._allKeys.get(token)
);
}
var /** @type {?} */newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
this._allKeys.set(token, newKey);
return newKey;
};
Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
get: /**
* @return {?}
*/
function () {
return this._allKeys.size;
},
enumerable: true,
configurable: true
});
return KeyRegistry;
}();
var _globalKeyRegistry = new KeyRegistry();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Represents a type that a Component or other object is instances of.
*
* \@description
*
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
* the `MyCustomComponent` constructor function.
*
* \@stable
*/
var Type = Function;
/**
* @param {?} v
* @return {?}
*/
function isType(v) {
return typeof v === 'function';
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Attention: This regex has to hold even if the code is minified!
*/
var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
var ReflectionCapabilities = /** @class */function () {
function ReflectionCapabilities(reflect) {
this._reflect = reflect || _global['Reflect'];
}
/**
* @return {?}
*/
ReflectionCapabilities.prototype.isReflectionEnabled = /**
* @return {?}
*/
function () {
return true;
};
/**
* @template T
* @param {?} t
* @return {?}
*/
ReflectionCapabilities.prototype.factory = /**
* @template T
* @param {?} t
* @return {?}
*/
function (t) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new (t.bind.apply(t, [void 0].concat(args)))();
};
};
/** @internal */
/**
* \@internal
* @param {?} paramTypes
* @param {?} paramAnnotations
* @return {?}
*/
ReflectionCapabilities.prototype._zipTypesAndAnnotations = /**
* \@internal
* @param {?} paramTypes
* @param {?} paramAnnotations
* @return {?}
*/
function (paramTypes, paramAnnotations) {
var /** @type {?} */result;
if (typeof paramTypes === 'undefined') {
result = new Array(paramAnnotations.length);
} else {
result = new Array(paramTypes.length);
}
for (var /** @type {?} */i = 0; i < result.length; i++) {
// TS outputs Object for parameters without types, while Traceur omits
// the annotations. For now we preserve the Traceur behavior to aid
// migration, but this can be revisited.
if (typeof paramTypes === 'undefined') {
result[i] = [];
} else if (paramTypes[i] != Object) {
result[i] = [paramTypes[i]];
} else {
result[i] = [];
}
if (paramAnnotations && paramAnnotations[i] != null) {
result[i] = result[i].concat(paramAnnotations[i]);
}
}
return result;
};
/**
* @param {?} type
* @param {?} parentCtor
* @return {?}
*/
ReflectionCapabilities.prototype._ownParameters = /**
* @param {?} type
* @param {?} parentCtor
* @return {?}
*/
function (type, parentCtor) {
// If we have no decorators, we only have function.length as metadata.
// In that case, to detect whether a child class declared an own constructor or not,
// we need to look inside of that constructor to check whether it is
// just calling the parent.
// This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
// that sets 'design:paramtypes' to []
// if a class inherits from another class but has no ctor declared itself.
if (DELEGATE_CTOR.exec(type.toString())) {
return null;
}
// Prefer the direct API.
if ( /** @type {?} */type.parameters && /** @type {?} */type.parameters !== parentCtor.parameters) {
return (/** @type {?} */type.parameters
);
}
// API of tsickle for lowering decorators to properties on the class.
var /** @type {?} */tsickleCtorParams = /** @type {?} */type.ctorParameters;
if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
// Newer tsickle uses a function closure
// Retain the non-function case for compatibility with older tsickle
var /** @type {?} */ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
var /** @type {?} */paramTypes_1 = ctorParameters.map(function (ctorParam) {
return ctorParam && ctorParam.type;
});
var /** @type {?} */paramAnnotations_1 = ctorParameters.map(function (ctorParam) {
return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators);
});
return this._zipTypesAndAnnotations(paramTypes_1, paramAnnotations_1);
}
// API for metadata created by invoking the decorators.
var /** @type {?} */paramAnnotations = type.hasOwnProperty(PARAMETERS) && /** @type {?} */type[PARAMETERS];
var /** @type {?} */paramTypes = this._reflect && this._reflect.getOwnMetadata && this._reflect.getOwnMetadata('design:paramtypes', type);
if (paramTypes || paramAnnotations) {
return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
}
// If a class has no decorators, at least create metadata
// based on function.length.
// Note: We know that this is a real constructor as we checked
// the content of the constructor above.
return new Array( /** @type {?} */type.length).fill(undefined);
};
/**
* @param {?} type
* @return {?}
*/
ReflectionCapabilities.prototype.parameters = /**
* @param {?} type
* @return {?}
*/
function (type) {
// Note: only report metadata if we have at least one class decorator
// to stay in sync with the static reflector.
if (!isType(type)) {
return [];
}
var /** @type {?} */parentCtor = getParentCtor(type);
var /** @type {?} */parameters = this._ownParameters(type, parentCtor);
if (!parameters && parentCtor !== Object) {
parameters = this.parameters(parentCtor);
}
return parameters || [];
};
/**
* @param {?} typeOrFunc
* @param {?} parentCtor
* @return {?}
*/
ReflectionCapabilities.prototype._ownAnnotations = /**
* @param {?} typeOrFunc
* @param {?} parentCtor
* @return {?}
*/
function (typeOrFunc, parentCtor) {
// Prefer the direct API.
if ( /** @type {?} */typeOrFunc.annotations && /** @type {?} */typeOrFunc.annotations !== parentCtor.annotations) {
var /** @type {?} */annotations = /** @type {?} */typeOrFunc.annotations;
if (typeof annotations === 'function' && annotations.annotations) {
annotations = annotations.annotations;
}
return annotations;
}
// API of tsickle for lowering decorators to properties on the class.
if ( /** @type {?} */typeOrFunc.decorators && /** @type {?} */typeOrFunc.decorators !== parentCtor.decorators) {
return convertTsickleDecoratorIntoMetadata( /** @type {?} */typeOrFunc.decorators);
}
// API for metadata created by invoking the decorators.
if (typeOrFunc.hasOwnProperty(ANNOTATIONS)) {
return (/** @type {?} */typeOrFunc[ANNOTATIONS]
);
}
return null;
};
/**
* @param {?} typeOrFunc
* @return {?}
*/
ReflectionCapabilities.prototype.annotations = /**
* @param {?} typeOrFunc
* @return {?}
*/
function (typeOrFunc) {
if (!isType(typeOrFunc)) {
return [];
}
var /** @type {?} */parentCtor = getParentCtor(typeOrFunc);
var /** @type {?} */ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
var /** @type {?} */parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
return parentAnnotations.concat(ownAnnotations);
};
/**
* @param {?} typeOrFunc
* @param {?} parentCtor
* @return {?}
*/
ReflectionCapabilities.prototype._ownPropMetadata = /**
* @param {?} typeOrFunc
* @param {?} parentCtor
* @return {?}
*/
function (typeOrFunc, parentCtor) {
// Prefer the direct API.
if ( /** @type {?} */typeOrFunc.propMetadata && /** @type {?} */typeOrFunc.propMetadata !== parentCtor.propMetadata) {
var /** @type {?} */propMetadata = /** @type {?} */typeOrFunc.propMetadata;
if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
propMetadata = propMetadata.propMetadata;
}
return propMetadata;
}
// API of tsickle for lowering decorators to properties on the class.
if ( /** @type {?} */typeOrFunc.propDecorators && /** @type {?} */typeOrFunc.propDecorators !== parentCtor.propDecorators) {
var /** @type {?} */propDecorators_1 = /** @type {?} */typeOrFunc.propDecorators;
var /** @type {?} */propMetadata_1 = /** @type {?} */{};
Object.keys(propDecorators_1).forEach(function (prop) {
propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]);
});
return propMetadata_1;
}
// API for metadata created by invoking the decorators.
if (typeOrFunc.hasOwnProperty(PROP_METADATA)) {
return (/** @type {?} */typeOrFunc[PROP_METADATA]
);
}
return null;
};
/**
* @param {?} typeOrFunc
* @return {?}
*/
ReflectionCapabilities.prototype.propMetadata = /**
* @param {?} typeOrFunc
* @return {?}
*/
function (typeOrFunc) {
if (!isType(typeOrFunc)) {
return {};
}
var /** @type {?} */parentCtor = getParentCtor(typeOrFunc);
var /** @type {?} */propMetadata = {};
if (parentCtor !== Object) {
var /** @type {?} */parentPropMetadata_1 = this.propMetadata(parentCtor);
Object.keys(parentPropMetadata_1).forEach(function (propName) {
propMetadata[propName] = parentPropMetadata_1[propName];
});
}
var /** @type {?} */ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
if (ownPropMetadata) {
Object.keys(ownPropMetadata).forEach(function (propName) {
var /** @type {?} */decorators = [];
if (propMetadata.hasOwnProperty(propName)) {
decorators.push.apply(decorators, propMetadata[propName]);
}
decorators.push.apply(decorators, ownPropMetadata[propName]);
propMetadata[propName] = decorators;
});
}
return propMetadata;
};
/**
* @param {?} type
* @param {?} lcProperty
* @return {?}
*/
ReflectionCapabilities.prototype.hasLifecycleHook = /**
* @param {?} type
* @param {?} lcProperty
* @return {?}
*/
function (type, lcProperty) {
return type instanceof Type && lcProperty in type.prototype;
};
/**
* @param {?} name
* @return {?}
*/
ReflectionCapabilities.prototype.getter = /**
* @param {?} name
* @return {?}
*/
function (name) {
return (/** @type {?} */new Function('o', 'return o.' + name + ';')
);
};
/**
* @param {?} name
* @return {?}
*/
ReflectionCapabilities.prototype.setter = /**
* @param {?} name
* @return {?}
*/
function (name) {
return (/** @type {?} */new Function('o', 'v', 'return o.' + name + ' = v;')
);
};
/**
* @param {?} name
* @return {?}
*/
ReflectionCapabilities.prototype.method = /**
* @param {?} name
* @return {?}
*/
function (name) {
var /** @type {?} */functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
return (/** @type {?} */new Function('o', 'args', functionBody)
);
};
// There is not a concept of import uri in Js, but this is useful in developing Dart applications.
/**
* @param {?} type
* @return {?}
*/
ReflectionCapabilities.prototype.importUri = /**
* @param {?} type
* @return {?}
*/
function (type) {
// StaticSymbol
if (typeof type === 'object' && type['filePath']) {
return type['filePath'];
}
// Runtime type
return "./" + stringify(type);
};
/**
* @param {?} type
* @return {?}
*/
ReflectionCapabilities.prototype.resourceUri = /**
* @param {?} type
* @return {?}
*/
function (type) {
return "./" + stringify(type);
};
/**
* @param {?} name
* @param {?} moduleUrl
* @param {?} members
* @param {?} runtime
* @return {?}
*/
ReflectionCapabilities.prototype.resolveIdentifier = /**
* @param {?} name
* @param {?} moduleUrl
* @param {?} members
* @param {?} runtime
* @return {?}
*/
function (name, moduleUrl, members, runtime) {
return runtime;
};
/**
* @param {?} enumIdentifier
* @param {?} name
* @return {?}
*/
ReflectionCapabilities.prototype.resolveEnum = /**
* @param {?} enumIdentifier
* @param {?} name
* @return {?}
*/
function (enumIdentifier, name) {
return enumIdentifier[name];
};
return ReflectionCapabilities;
}();
/**
* @param {?} decoratorInvocations
* @return {?}
*/
function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
if (!decoratorInvocations) {
return [];
}
return decoratorInvocations.map(function (decoratorInvocation) {
var /** @type {?} */decoratorType = decoratorInvocation.type;
var /** @type {?} */annotationCls = decoratorType.annotationCls;
var /** @type {?} */annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
return new (annotationCls.bind.apply(annotationCls, [void 0].concat(annotationArgs)))();
});
}
/**
* @param {?} ctor
* @return {?}
*/
function getParentCtor(ctor) {
var /** @type {?} */parentProto = Object.getPrototypeOf(ctor.prototype);
var /** @type {?} */parentCtor = parentProto ? parentProto.constructor : null;
// Note: We always use `Object` as the null value
// to simplify checking later on.
return parentCtor || Object;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Provides access to reflection data about symbols. Used internally by Angular
* to power dependency injection and compilation.
*/
var Reflector = /** @class */function () {
function Reflector(reflectionCapabilities) {
this.reflectionCapabilities = reflectionCapabilities;
}
/**
* @param {?} caps
* @return {?}
*/
Reflector.prototype.updateCapabilities = /**
* @param {?} caps
* @return {?}
*/
function (caps) {
this.reflectionCapabilities = caps;
};
/**
* @param {?} type
* @return {?}
*/
Reflector.prototype.factory = /**
* @param {?} type
* @return {?}
*/
function (type) {
return this.reflectionCapabilities.factory(type);
};
/**
* @param {?} typeOrFunc
* @return {?}
*/
Reflector.prototype.parameters = /**
* @param {?} typeOrFunc
* @return {?}
*/
function (typeOrFunc) {
return this.reflectionCapabilities.parameters(typeOrFunc);
};
/**
* @param {?} typeOrFunc
* @return {?}
*/
Reflector.prototype.annotations = /**
* @param {?} typeOrFunc
* @return {?}
*/
function (typeOrFunc) {
return this.reflectionCapabilities.annotations(typeOrFunc);
};
/**
* @param {?} typeOrFunc
* @return {?}
*/
Reflector.prototype.propMetadata = /**
* @param {?} typeOrFunc
* @return {?}
*/
function (typeOrFunc) {
return this.reflectionCapabilities.propMetadata(typeOrFunc);
};
/**
* @param {?} type
* @param {?} lcProperty
* @return {?}
*/
Reflector.prototype.hasLifecycleHook = /**
* @param {?} type
* @param {?} lcProperty
* @return {?}
*/
function (type, lcProperty) {
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
};
/**
* @param {?} name
* @return {?}
*/
Reflector.prototype.getter = /**
* @param {?} name
* @return {?}
*/
function (name) {
return this.reflectionCapabilities.getter(name);
};
/**
* @param {?} name
* @return {?}
*/
Reflector.prototype.setter = /**
* @param {?} name
* @return {?}
*/
function (name) {
return this.reflectionCapabilities.setter(name);
};
/**
* @param {?} name
* @return {?}
*/
Reflector.prototype.method = /**
* @param {?} name
* @return {?}
*/
function (name) {
return this.reflectionCapabilities.method(name);
};
/**
* @param {?} type
* @return {?}
*/
Reflector.prototype.importUri = /**
* @param {?} type
* @return {?}
*/
function (type) {
return this.reflectionCapabilities.importUri(type);
};
/**
* @param {?} type
* @return {?}
*/
Reflector.prototype.resourceUri = /**
* @param {?} type
* @return {?}
*/
function (type) {
return this.reflectionCapabilities.resourceUri(type);
};
/**
* @param {?} name
* @param {?} moduleUrl
* @param {?} members
* @param {?} runtime
* @return {?}
*/
Reflector.prototype.resolveIdentifier = /**
* @param {?} name
* @param {?} moduleUrl
* @param {?} members
* @param {?} runtime
* @return {?}
*/
function (name, moduleUrl, members, runtime) {
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
};
/**
* @param {?} identifier
* @param {?} name
* @return {?}
*/
Reflector.prototype.resolveEnum = /**
* @param {?} identifier
* @param {?} name
* @return {?}
*/
function (identifier, name) {
return this.reflectionCapabilities.resolveEnum(identifier, name);
};
return Reflector;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* The {\@link Reflector} used internally in Angular to access metadata
* about symbols.
*/
var reflector = new Reflector(new ReflectionCapabilities());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* `Dependency` is used by the framework to extend DI.
* This is internal to Angular and should not be used directly.
*/
var ReflectiveDependency = /** @class */function () {
function ReflectiveDependency(key, optional, visibility) {
this.key = key;
this.optional = optional;
this.visibility = visibility;
}
/**
* @param {?} key
* @return {?}
*/
ReflectiveDependency.fromKey = /**
* @param {?} key
* @return {?}
*/
function (key) {
return new ReflectiveDependency(key, false, null);
};
return ReflectiveDependency;
}();
var _EMPTY_LIST = [];
/**
* An internal resolved representation of a {\@link Provider} used by the {\@link Injector}.
*
* It is usually created automatically by `Injector.resolveAndCreate`.
*
* It can be created manually, as follows:
*
* ### Example ([live demo](http://plnkr.co/edit/RfEnhh8kUEI0G3qsnIeT?p%3Dpreview&p=preview))
*
* ```typescript
* var resolvedProviders = Injector.resolve([{ provide: 'message', useValue: 'Hello' }]);
* var injector = Injector.fromResolvedProviders(resolvedProviders);
*
* expect(injector.get('message')).toEqual('Hello');
* ```
*
* \@experimental
* @record
*/
var ResolvedReflectiveProvider_ = /** @class */function () {
function ResolvedReflectiveProvider_(key, resolvedFactories, multiProvider) {
this.key = key;
this.resolvedFactories = resolvedFactories;
this.multiProvider = multiProvider;
}
Object.defineProperty(ResolvedReflectiveProvider_.prototype, "resolvedFactory", {
get: /**
* @return {?}
*/
function () {
return this.resolvedFactories[0];
},
enumerable: true,
configurable: true
});
return ResolvedReflectiveProvider_;
}();
/**
* An internal resolved representation of a factory function created by resolving {\@link
* Provider}.
* \@experimental
*/
var ResolvedReflectiveFactory = /** @class */function () {
function ResolvedReflectiveFactory(factory, dependencies) {
this.factory = factory;
this.dependencies = dependencies;
}
return ResolvedReflectiveFactory;
}();
/**
* Resolve a single provider.
* @param {?} provider
* @return {?}
*/
function resolveReflectiveFactory(provider) {
var /** @type {?} */factoryFn;
var /** @type {?} */resolvedDeps;
if (provider.useClass) {
var /** @type {?} */useClass = resolveForwardRef(provider.useClass);
factoryFn = reflector.factory(useClass);
resolvedDeps = _dependenciesFor(useClass);
} else if (provider.useExisting) {
factoryFn = function (aliasInstance) {
return aliasInstance;
};
resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
} else if (provider.useFactory) {
factoryFn = provider.useFactory;
resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
} else {
factoryFn = function () {
return provider.useValue;
};
resolvedDeps = _EMPTY_LIST;
}
return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
}
/**
* Converts the {\@link Provider} into {\@link ResolvedProvider}.
*
* {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
* convenience provider syntax.
* @param {?} provider
* @return {?}
*/
function resolveReflectiveProvider(provider) {
return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
}
/**
* Resolve a list of Providers.
* @param {?} providers
* @return {?}
*/
function resolveReflectiveProviders(providers) {
var /** @type {?} */normalized = _normalizeProviders(providers, []);
var /** @type {?} */resolved = normalized.map(resolveReflectiveProvider);
var /** @type {?} */resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
return Array.from(resolvedProviderMap.values());
}
/**
* Merges a list of ResolvedProviders into a list where
* each key is contained exactly once and multi providers
* have been merged.
* @param {?} providers
* @param {?} normalizedProvidersMap
* @return {?}
*/
function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
for (var /** @type {?} */i = 0; i < providers.length; i++) {
var /** @type {?} */provider = providers[i];
var /** @type {?} */existing = normalizedProvidersMap.get(provider.key.id);
if (existing) {
if (provider.multiProvider !== existing.multiProvider) {
throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
}
if (provider.multiProvider) {
for (var /** @type {?} */j = 0; j < provider.resolvedFactories.length; j++) {
existing.resolvedFactories.push(provider.resolvedFactories[j]);
}
} else {
normalizedProvidersMap.set(provider.key.id, provider);
}
} else {
var /** @type {?} */resolvedProvider = void 0;
if (provider.multiProvider) {
resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
} else {
resolvedProvider = provider;
}
normalizedProvidersMap.set(provider.key.id, resolvedProvider);
}
}
return normalizedProvidersMap;
}
/**
* @param {?} providers
* @param {?} res
* @return {?}
*/
function _normalizeProviders(providers, res) {
providers.forEach(function (b) {
if (b instanceof Type) {
res.push({ provide: b, useClass: b });
} else if (b && typeof b == 'object' && /** @type {?} */b.provide !== undefined) {
res.push( /** @type {?} */b);
} else if (b instanceof Array) {
_normalizeProviders(b, res);
} else {
throw invalidProviderError(b);
}
});
return res;
}
/**
* @param {?} typeOrFunc
* @param {?=} dependencies
* @return {?}
*/
function constructDependencies(typeOrFunc, dependencies) {
if (!dependencies) {
return _dependenciesFor(typeOrFunc);
} else {
var /** @type {?} */params_1 = dependencies.map(function (t) {
return [t];
});
return dependencies.map(function (t) {
return _extractToken(typeOrFunc, t, params_1);
});
}
}
/**
* @param {?} typeOrFunc
* @return {?}
*/
function _dependenciesFor(typeOrFunc) {
var /** @type {?} */params = reflector.parameters(typeOrFunc);
if (!params) return [];
if (params.some(function (p) {
return p == null;
})) {
throw noAnnotationError(typeOrFunc, params);
}
return params.map(function (p) {
return _extractToken(typeOrFunc, p, params);
});
}
/**
* @param {?} typeOrFunc
* @param {?} metadata
* @param {?} params
* @return {?}
*/
function _extractToken(typeOrFunc, metadata, params) {
var /** @type {?} */token = null;
var /** @type {?} */optional = false;
if (!Array.isArray(metadata)) {
if (metadata instanceof Inject) {
return _createDependency(metadata.token, optional, null);
} else {
return _createDependency(metadata, optional, null);
}
}
var /** @type {?} */visibility = null;
for (var /** @type {?} */i = 0; i < metadata.length; ++i) {
var /** @type {?} */paramMetadata = metadata[i];
if (paramMetadata instanceof Type) {
token = paramMetadata;
} else if (paramMetadata instanceof Inject) {
token = paramMetadata.token;
} else if (paramMetadata instanceof Optional) {
optional = true;
} else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
visibility = paramMetadata;
} else if (paramMetadata instanceof InjectionToken) {
token = paramMetadata;
}
}
token = resolveForwardRef(token);
if (token != null) {
return _createDependency(token, optional, visibility);
} else {
throw noAnnotationError(typeOrFunc, params);
}
}
/**
* @param {?} token
* @param {?} optional
* @param {?} visibility
* @return {?}
*/
function _createDependency(token, optional, visibility) {
return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Threshold for the dynamic version
var UNDEFINED = new Object();
/**
* A ReflectiveDependency injection container used for instantiating objects and resolving
* dependencies.
*
* An `Injector` is a replacement for a `new` operator, which can automatically resolve the
* constructor dependencies.
*
* In typical use, application code asks for the dependencies in the constructor and they are
* resolved by the `Injector`.
*
* ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
*
* The following example creates an `Injector` configured to create `Engine` and `Car`.
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
* var car = injector.get(Car);
* expect(car instanceof Car).toBe(true);
* expect(car.engine instanceof Engine).toBe(true);
* ```
*
* Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
* resolve all of the object's dependencies automatically.
*
* @deprecated from v5 - slow and brings in a lot of code, Use `Injector.create` instead.
* @abstract
*/
var ReflectiveInjector = /** @class */function () {
function ReflectiveInjector() {}
/**
* Turns an array of provider definitions into an array of resolved providers.
*
* A resolution is a process of flattening multiple nested arrays and converting individual
* providers into an array of {@link ResolvedReflectiveProvider}s.
*
* ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
*
* ```typescript
* @Injectable()
* class Engine {
* }
*
* @Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
*
* expect(providers.length).toEqual(2);
*
* expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
* expect(providers[0].key.displayName).toBe("Car");
* expect(providers[0].dependencies.length).toEqual(1);
* expect(providers[0].factory).toBeDefined();
*
* expect(providers[1].key.displayName).toBe("Engine");
* });
* ```
*
* See {@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders} for more info.
*/
/**
* Turns an array of provider definitions into an array of resolved providers.
*
* A resolution is a process of flattening multiple nested arrays and converting individual
* providers into an array of {\@link ResolvedReflectiveProvider}s.
*
* ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
*
* expect(providers.length).toEqual(2);
*
* expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
* expect(providers[0].key.displayName).toBe("Car");
* expect(providers[0].dependencies.length).toEqual(1);
* expect(providers[0].factory).toBeDefined();
*
* expect(providers[1].key.displayName).toBe("Engine");
* });
* ```
*
* See {\@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders} for more info.
* @param {?} providers
* @return {?}
*/
ReflectiveInjector.resolve = /**
* Turns an array of provider definitions into an array of resolved providers.
*
* A resolution is a process of flattening multiple nested arrays and converting individual
* providers into an array of {\@link ResolvedReflectiveProvider}s.
*
* ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
*
* expect(providers.length).toEqual(2);
*
* expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
* expect(providers[0].key.displayName).toBe("Car");
* expect(providers[0].dependencies.length).toEqual(1);
* expect(providers[0].factory).toBeDefined();
*
* expect(providers[1].key.displayName).toBe("Engine");
* });
* ```
*
* See {\@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders} for more info.
* @param {?} providers
* @return {?}
*/
function (providers) {
return resolveReflectiveProviders(providers);
};
/**
* Resolves an array of providers and creates an injector from those providers.
*
* The passed-in providers can be an array of `Type`, {@link Provider},
* or a recursive array of more providers.
*
* ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
*
* ```typescript
* @Injectable()
* class Engine {
* }
*
* @Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
*
* This function is slower than the corresponding `fromResolvedProviders`
* because it needs to resolve the passed-in providers first.
* See {@link ReflectiveInjector#resolve resolve} and
* {@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders}.
*/
/**
* Resolves an array of providers and creates an injector from those providers.
*
* The passed-in providers can be an array of `Type`, {\@link Provider},
* or a recursive array of more providers.
*
* ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
*
* This function is slower than the corresponding `fromResolvedProviders`
* because it needs to resolve the passed-in providers first.
* See {\@link ReflectiveInjector#resolve resolve} and
* {\@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders}.
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
ReflectiveInjector.resolveAndCreate = /**
* Resolves an array of providers and creates an injector from those providers.
*
* The passed-in providers can be an array of `Type`, {\@link Provider},
* or a recursive array of more providers.
*
* ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
*
* This function is slower than the corresponding `fromResolvedProviders`
* because it needs to resolve the passed-in providers first.
* See {\@link ReflectiveInjector#resolve resolve} and
* {\@link ReflectiveInjector#fromResolvedProviders fromResolvedProviders}.
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
function (providers, parent) {
var /** @type {?} */ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
};
/**
* Creates an injector from previously resolved providers.
*
* This API is the recommended way to construct injectors in performance-sensitive parts.
*
* ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
*
* ```typescript
* @Injectable()
* class Engine {
* }
*
* @Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, Engine]);
* var injector = ReflectiveInjector.fromResolvedProviders(providers);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
* @experimental
*/
/**
* Creates an injector from previously resolved providers.
*
* This API is the recommended way to construct injectors in performance-sensitive parts.
*
* ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, Engine]);
* var injector = ReflectiveInjector.fromResolvedProviders(providers);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
* \@experimental
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
ReflectiveInjector.fromResolvedProviders = /**
* Creates an injector from previously resolved providers.
*
* This API is the recommended way to construct injectors in performance-sensitive parts.
*
* ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
*
* ```typescript
* \@Injectable()
* class Engine {
* }
*
* \@Injectable()
* class Car {
* constructor(public engine:Engine) {}
* }
*
* var providers = ReflectiveInjector.resolve([Car, Engine]);
* var injector = ReflectiveInjector.fromResolvedProviders(providers);
* expect(injector.get(Car) instanceof Car).toBe(true);
* ```
* \@experimental
* @param {?} providers
* @param {?=} parent
* @return {?}
*/
function (providers, parent) {
return new ReflectiveInjector_(providers, parent);
};
return ReflectiveInjector;
}();
var ReflectiveInjector_ = /** @class */function () {
/**
* Private
*/
function ReflectiveInjector_(_providers, _parent) {
/**
* \@internal
*/
this._constructionCounter = 0;
this._providers = _providers;
this.parent = _parent || null;
var /** @type {?} */len = _providers.length;
this.keyIds = new Array(len);
this.objs = new Array(len);
for (var /** @type {?} */i = 0; i < len; i++) {
this.keyIds[i] = _providers[i].key.id;
this.objs[i] = UNDEFINED;
}
}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
ReflectiveInjector_.prototype.get = /**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
function (token, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = THROW_IF_NOT_FOUND;
}
return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
};
/**
* @param {?} providers
* @return {?}
*/
ReflectiveInjector_.prototype.resolveAndCreateChild = /**
* @param {?} providers
* @return {?}
*/
function (providers) {
var /** @type {?} */ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
return this.createChildFromResolved(ResolvedReflectiveProviders);
};
/**
* @param {?} providers
* @return {?}
*/
ReflectiveInjector_.prototype.createChildFromResolved = /**
* @param {?} providers
* @return {?}
*/
function (providers) {
var /** @type {?} */inj = new ReflectiveInjector_(providers);
/** @type {?} */inj.parent = this;
return inj;
};
/**
* @param {?} provider
* @return {?}
*/
ReflectiveInjector_.prototype.resolveAndInstantiate = /**
* @param {?} provider
* @return {?}
*/
function (provider) {
return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
};
/**
* @param {?} provider
* @return {?}
*/
ReflectiveInjector_.prototype.instantiateResolved = /**
* @param {?} provider
* @return {?}
*/
function (provider) {
return this._instantiateProvider(provider);
};
/**
* @param {?} index
* @return {?}
*/
ReflectiveInjector_.prototype.getProviderAtIndex = /**
* @param {?} index
* @return {?}
*/
function (index) {
if (index < 0 || index >= this._providers.length) {
throw outOfBoundsError(index);
}
return this._providers[index];
};
/** @internal */
/**
* \@internal
* @param {?} provider
* @return {?}
*/
ReflectiveInjector_.prototype._new = /**
* \@internal
* @param {?} provider
* @return {?}
*/
function (provider) {
if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
throw cyclicDependencyError(this, provider.key);
}
return this._instantiateProvider(provider);
};
/**
* @return {?}
*/
ReflectiveInjector_.prototype._getMaxNumberOfObjects = /**
* @return {?}
*/
function () {
return this.objs.length;
};
/**
* @param {?} provider
* @return {?}
*/
ReflectiveInjector_.prototype._instantiateProvider = /**
* @param {?} provider
* @return {?}
*/
function (provider) {
if (provider.multiProvider) {
var /** @type {?} */res = new Array(provider.resolvedFactories.length);
for (var /** @type {?} */i = 0; i < provider.resolvedFactories.length; ++i) {
res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
}
return res;
} else {
return this._instantiate(provider, provider.resolvedFactories[0]);
}
};
/**
* @param {?} provider
* @param {?} ResolvedReflectiveFactory
* @return {?}
*/
ReflectiveInjector_.prototype._instantiate = /**
* @param {?} provider
* @param {?} ResolvedReflectiveFactory
* @return {?}
*/
function (provider, ResolvedReflectiveFactory$$1) {
var _this = this;
var /** @type {?} */factory = ResolvedReflectiveFactory$$1.factory;
var /** @type {?} */deps;
try {
deps = ResolvedReflectiveFactory$$1.dependencies.map(function (dep) {
return _this._getByReflectiveDependency(dep);
});
} catch ( /** @type {?} */e) {
if (e.addKey) {
e.addKey(this, provider.key);
}
throw e;
}
var /** @type {?} */obj;
try {
obj = factory.apply(void 0, deps);
} catch ( /** @type {?} */e) {
throw instantiationError(this, e, e.stack, provider.key);
}
return obj;
};
/**
* @param {?} dep
* @return {?}
*/
ReflectiveInjector_.prototype._getByReflectiveDependency = /**
* @param {?} dep
* @return {?}
*/
function (dep) {
return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
};
/**
* @param {?} key
* @param {?} visibility
* @param {?} notFoundValue
* @return {?}
*/
ReflectiveInjector_.prototype._getByKey = /**
* @param {?} key
* @param {?} visibility
* @param {?} notFoundValue
* @return {?}
*/
function (key, visibility, notFoundValue) {
if (key === ReflectiveInjector_.INJECTOR_KEY) {
return this;
}
if (visibility instanceof Self) {
return this._getByKeySelf(key, notFoundValue);
} else {
return this._getByKeyDefault(key, notFoundValue, visibility);
}
};
/**
* @param {?} keyId
* @return {?}
*/
ReflectiveInjector_.prototype._getObjByKeyId = /**
* @param {?} keyId
* @return {?}
*/
function (keyId) {
for (var /** @type {?} */i = 0; i < this.keyIds.length; i++) {
if (this.keyIds[i] === keyId) {
if (this.objs[i] === UNDEFINED) {
this.objs[i] = this._new(this._providers[i]);
}
return this.objs[i];
}
}
return UNDEFINED;
};
/** @internal */
/**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @return {?}
*/
ReflectiveInjector_.prototype._throwOrNull = /**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @return {?}
*/
function (key, notFoundValue) {
if (notFoundValue !== THROW_IF_NOT_FOUND) {
return notFoundValue;
} else {
throw noProviderError(this, key);
}
};
/** @internal */
/**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @return {?}
*/
ReflectiveInjector_.prototype._getByKeySelf = /**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @return {?}
*/
function (key, notFoundValue) {
var /** @type {?} */obj = this._getObjByKeyId(key.id);
return obj !== UNDEFINED ? obj : this._throwOrNull(key, notFoundValue);
};
/** @internal */
/**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @param {?} visibility
* @return {?}
*/
ReflectiveInjector_.prototype._getByKeyDefault = /**
* \@internal
* @param {?} key
* @param {?} notFoundValue
* @param {?} visibility
* @return {?}
*/
function (key, notFoundValue, visibility) {
var /** @type {?} */inj;
if (visibility instanceof SkipSelf) {
inj = this.parent;
} else {
inj = this;
}
while (inj instanceof ReflectiveInjector_) {
var /** @type {?} */inj_ = /** @type {?} */inj;
var /** @type {?} */obj = inj_._getObjByKeyId(key.id);
if (obj !== UNDEFINED) return obj;
inj = inj_.parent;
}
if (inj !== null) {
return inj.get(key.token, notFoundValue);
} else {
return this._throwOrNull(key, notFoundValue);
}
};
Object.defineProperty(ReflectiveInjector_.prototype, "displayName", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */providers = _mapProviders(this, function (b) {
return ' "' + b.key.displayName + '" ';
}).join(', ');
return "ReflectiveInjector(providers: [" + providers + "])";
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
ReflectiveInjector_.prototype.toString = /**
* @return {?}
*/
function () {
return this.displayName;
};
ReflectiveInjector_.INJECTOR_KEY = ReflectiveKey.get(Injector);
return ReflectiveInjector_;
}();
/**
* @param {?} injector
* @param {?} fn
* @return {?}
*/
function _mapProviders(injector, fn) {
var /** @type {?} */res = new Array(injector._providers.length);
for (var /** @type {?} */i = 0; i < injector._providers.length; ++i) {
res[i] = fn(injector.getProviderAtIndex(i));
}
return res;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* The `di` module provides dependency injection container services.
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Determine if the argument is shaped like a Promise
* @param {?} obj
* @return {?}
*/
function isPromise(obj) {
// allow any Promise/A+ compliant thenable.
// It's up to the caller to ensure that obj.then conforms to the spec
return !!obj && typeof obj.then === 'function';
}
/**
* Determine if the argument is an Observable
* @param {?} obj
* @return {?}
*/
function isObservable(obj) {
// TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
return !!obj && typeof obj.subscribe === 'function';
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A function that will be executed when an application is initialized.
* \@experimental
*/
var APP_INITIALIZER = new InjectionToken('Application Initializer');
/**
* A class that reflects the state of running {\@link APP_INITIALIZER}s.
*
* \@experimental
*/
var ApplicationInitStatus = /** @class */function () {
function ApplicationInitStatus(appInits) {
var _this = this;
this.appInits = appInits;
this.initialized = false;
this.done = false;
this.donePromise = new Promise(function (res, rej) {
_this.resolve = res;
_this.reject = rej;
});
}
/** @internal */
/**
* \@internal
* @return {?}
*/
ApplicationInitStatus.prototype.runInitializers = /**
* \@internal
* @return {?}
*/
function () {
var _this = this;
if (this.initialized) {
return;
}
var /** @type {?} */asyncInitPromises = [];
var /** @type {?} */complete = function () {
/** @type {?} */_this.done = true;
_this.resolve();
};
if (this.appInits) {
for (var /** @type {?} */i = 0; i < this.appInits.length; i++) {
var /** @type {?} */initResult = this.appInits[i]();
if (isPromise(initResult)) {
asyncInitPromises.push(initResult);
}
}
}
Promise.all(asyncInitPromises).then(function () {
complete();
}).catch(function (e) {
_this.reject(e);
});
if (asyncInitPromises.length === 0) {
complete();
}
this.initialized = true;
};
ApplicationInitStatus.decorators = [{ type: Injectable }];
/** @nocollapse */
ApplicationInitStatus.ctorParameters = function () {
return [{ type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER] }, { type: Optional }] }];
};
return ApplicationInitStatus;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A DI Token representing a unique string id assigned to the application by Angular and used
* primarily for prefixing application attributes and CSS styles when
* {\@link ViewEncapsulation#Emulated ViewEncapsulation.Emulated} is being used.
*
* If you need to avoid randomly generated value to be used as an application id, you can provide
* a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
* using this token.
* \@experimental
*/
var APP_ID = new InjectionToken('AppId');
/**
* @return {?}
*/
function _appIdRandomProviderFactory() {
return "" + _randomChar() + _randomChar() + _randomChar();
}
/**
* Providers that will generate a random APP_ID_TOKEN.
* \@experimental
*/
var APP_ID_RANDOM_PROVIDER = {
provide: APP_ID,
useFactory: _appIdRandomProviderFactory,
deps: /** @type {?} */[]
};
/**
* @return {?}
*/
function _randomChar() {
return String.fromCharCode(97 + Math.floor(Math.random() * 25));
}
/**
* A function that will be executed when a platform is initialized.
* \@experimental
*/
var PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
/**
* A token that indicates an opaque platform id.
* \@experimental
*/
var PLATFORM_ID = new InjectionToken('Platform ID');
/**
* All callbacks provided via this token will be called for every component that is bootstrapped.
* Signature of the callback:
*
* `(componentRef: ComponentRef) => void`.
*
* \@experimental
*/
var APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
/**
* A token which indicates the root directory of the application
* \@experimental
*/
var PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var Console = /** @class */function () {
function Console() {}
/**
* @param {?} message
* @return {?}
*/
Console.prototype.log = /**
* @param {?} message
* @return {?}
*/
function (message) {
// tslint:disable-next-line:no-console
console.log(message);
};
// Note: for reporting errors use `DOM.logError()` as it is platform specific
/**
* @param {?} message
* @return {?}
*/
Console.prototype.warn = /**
* @param {?} message
* @return {?}
*/
function (message) {
// tslint:disable-next-line:no-console
console.warn(message);
};
Console.decorators = [{ type: Injectable }];
/** @nocollapse */
Console.ctorParameters = function () {
return [];
};
return Console;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Combination of NgModuleFactory and ComponentFactorys.
*
* \@experimental
*/
var ModuleWithComponentFactories = /** @class */function () {
function ModuleWithComponentFactories(ngModuleFactory, componentFactories) {
this.ngModuleFactory = ngModuleFactory;
this.componentFactories = componentFactories;
}
return ModuleWithComponentFactories;
}();
/**
* @return {?}
*/
function _throwError() {
throw new Error("Runtime compiler is not loaded");
}
/**
* Low-level service for running the angular compiler during runtime
* to create {\@link ComponentFactory}s, which
* can later be used to create and render a Component instance.
*
* Each `\@NgModule` provides an own `Compiler` to its injector,
* that will use the directives/pipes of the ng module for compilation
* of components.
* \@stable
*/
var Compiler = /** @class */function () {
function Compiler() {}
/**
* Compiles the given NgModule and all of its components. All templates of the components listed
* in `entryComponents` have to be inlined.
*/
/**
* Compiles the given NgModule and all of its components. All templates of the components listed
* in `entryComponents` have to be inlined.
* @template T
* @param {?} moduleType
* @return {?}
*/
Compiler.prototype.compileModuleSync = /**
* Compiles the given NgModule and all of its components. All templates of the components listed
* in `entryComponents` have to be inlined.
* @template T
* @param {?} moduleType
* @return {?}
*/
function (moduleType) {
throw _throwError();
};
/**
* Compiles the given NgModule and all of its components
*/
/**
* Compiles the given NgModule and all of its components
* @template T
* @param {?} moduleType
* @return {?}
*/
Compiler.prototype.compileModuleAsync = /**
* Compiles the given NgModule and all of its components
* @template T
* @param {?} moduleType
* @return {?}
*/
function (moduleType) {
throw _throwError();
};
/**
* Same as {@link #compileModuleSync} but also creates ComponentFactories for all components.
*/
/**
* Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
* @template T
* @param {?} moduleType
* @return {?}
*/
Compiler.prototype.compileModuleAndAllComponentsSync = /**
* Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
* @template T
* @param {?} moduleType
* @return {?}
*/
function (moduleType) {
throw _throwError();
};
/**
* Same as {@link #compileModuleAsync} but also creates ComponentFactories for all components.
*/
/**
* Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
* @template T
* @param {?} moduleType
* @return {?}
*/
Compiler.prototype.compileModuleAndAllComponentsAsync = /**
* Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
* @template T
* @param {?} moduleType
* @return {?}
*/
function (moduleType) {
throw _throwError();
};
/**
* Clears all caches.
*/
/**
* Clears all caches.
* @return {?}
*/
Compiler.prototype.clearCache = /**
* Clears all caches.
* @return {?}
*/
function () {};
/**
* Clears the cache for the given component/ngModule.
*/
/**
* Clears the cache for the given component/ngModule.
* @param {?} type
* @return {?}
*/
Compiler.prototype.clearCacheFor = /**
* Clears the cache for the given component/ngModule.
* @param {?} type
* @return {?}
*/
function (type) {};
Compiler.decorators = [{ type: Injectable }];
/** @nocollapse */
Compiler.ctorParameters = function () {
return [];
};
return Compiler;
}();
/**
* Token to provide CompilerOptions in the platform injector.
*
* \@experimental
*/
var COMPILER_OPTIONS = new InjectionToken('compilerOptions');
/**
* A factory for creating a Compiler
*
* \@experimental
* @abstract
*/
var CompilerFactory = /** @class */function () {
function CompilerFactory() {}
return CompilerFactory;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Represents an instance of a Component created via a {\@link ComponentFactory}.
*
* `ComponentRef` provides access to the Component Instance as well other objects related to this
* Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
* method.
* \@stable
* @abstract
*/
var ComponentRef = /** @class */function () {
function ComponentRef() {}
return ComponentRef;
}();
/**
* \@stable
* @abstract
*/
var ComponentFactory = /** @class */function () {
function ComponentFactory() {}
return ComponentFactory;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} component
* @return {?}
*/
function noComponentFactoryError(component) {
var /** @type {?} */error = Error("No component factory found for " + stringify(component) + ". Did you add it to @NgModule.entryComponents?");
/** @type {?} */error[ERROR_COMPONENT] = component;
return error;
}
var ERROR_COMPONENT = 'ngComponent';
/**
* @param {?} error
* @return {?}
*/
var _NullComponentFactoryResolver = /** @class */function () {
function _NullComponentFactoryResolver() {}
/**
* @template T
* @param {?} component
* @return {?}
*/
_NullComponentFactoryResolver.prototype.resolveComponentFactory = /**
* @template T
* @param {?} component
* @return {?}
*/
function (component) {
throw noComponentFactoryError(component);
};
return _NullComponentFactoryResolver;
}();
/**
* \@stable
* @abstract
*/
var ComponentFactoryResolver = /** @class */function () {
function ComponentFactoryResolver() {}
ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
return ComponentFactoryResolver;
}();
var CodegenComponentFactoryResolver = /** @class */function () {
function CodegenComponentFactoryResolver(factories, _parent, _ngModule) {
this._parent = _parent;
this._ngModule = _ngModule;
this._factories = new Map();
for (var /** @type {?} */i = 0; i < factories.length; i++) {
var /** @type {?} */factory = factories[i];
this._factories.set(factory.componentType, factory);
}
}
/**
* @template T
* @param {?} component
* @return {?}
*/
CodegenComponentFactoryResolver.prototype.resolveComponentFactory = /**
* @template T
* @param {?} component
* @return {?}
*/
function (component) {
var /** @type {?} */factory = this._factories.get(component);
if (!factory && this._parent) {
factory = this._parent.resolveComponentFactory(component);
}
if (!factory) {
throw noComponentFactoryError(component);
}
return new ComponentFactoryBoundToModule(factory, this._ngModule);
};
return CodegenComponentFactoryResolver;
}();
var ComponentFactoryBoundToModule = /** @class */function (_super) {
__extends(ComponentFactoryBoundToModule, _super);
function ComponentFactoryBoundToModule(factory, ngModule) {
var _this = _super.call(this) || this;
_this.factory = factory;
_this.ngModule = ngModule;
return _this;
}
Object.defineProperty(ComponentFactoryBoundToModule.prototype, "selector", {
get: /**
* @return {?}
*/
function () {
return this.factory.selector;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentFactoryBoundToModule.prototype, "componentType", {
get: /**
* @return {?}
*/
function () {
return this.factory.componentType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentFactoryBoundToModule.prototype, "ngContentSelectors", {
get: /**
* @return {?}
*/
function () {
return this.factory.ngContentSelectors;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentFactoryBoundToModule.prototype, "inputs", {
get: /**
* @return {?}
*/
function () {
return this.factory.inputs;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentFactoryBoundToModule.prototype, "outputs", {
get: /**
* @return {?}
*/
function () {
return this.factory.outputs;
},
enumerable: true,
configurable: true
});
/**
* @param {?} injector
* @param {?=} projectableNodes
* @param {?=} rootSelectorOrNode
* @param {?=} ngModule
* @return {?}
*/
ComponentFactoryBoundToModule.prototype.create = /**
* @param {?} injector
* @param {?=} projectableNodes
* @param {?=} rootSelectorOrNode
* @param {?=} ngModule
* @return {?}
*/
function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
};
return ComponentFactoryBoundToModule;
}(ComponentFactory);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
*
* `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
* NgModule Instance.
*
* \@stable
* @abstract
*/
var NgModuleRef = /** @class */function () {
function NgModuleRef() {}
return NgModuleRef;
}();
/**
* @record
*/
/**
* \@experimental
* @abstract
*/
var NgModuleFactory = /** @class */function () {
function NgModuleFactory() {}
return NgModuleFactory;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A scope function for the Web Tracing Framework (WTF).
*
* \@experimental
* @record
*/
/**
* @record
*/
/**
* @record
*/
var trace;
var events;
/**
* @return {?}
*/
function detectWTF() {
var /** @type {?} */wtf = /** @type {?} */_global /** TODO #9100 */[/** TODO #9100 */'wtf'];
if (wtf) {
trace = wtf['trace'];
if (trace) {
events = trace['events'];
return true;
}
}
return false;
}
/**
* @param {?} signature
* @param {?=} flags
* @return {?}
*/
function createScope(signature, flags) {
if (flags === void 0) {
flags = null;
}
return events.createScope(signature, flags);
}
/**
* @template T
* @param {?} scope
* @param {?=} returnValue
* @return {?}
*/
function leave(scope, returnValue) {
trace.leaveScope(scope, returnValue);
return returnValue;
}
/**
* @param {?} rangeType
* @param {?} action
* @return {?}
*/
function startTimeRange(rangeType, action) {
return trace.beginTimeRange(rangeType, action);
}
/**
* @param {?} range
* @return {?}
*/
function endTimeRange(range) {
trace.endTimeRange(range);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* True if WTF is enabled.
*/
var wtfEnabled = detectWTF();
/**
* @param {?=} arg0
* @param {?=} arg1
* @return {?}
*/
function noopScope(arg0, arg1) {
return null;
}
/**
* Create trace scope.
*
* Scopes must be strictly nested and are analogous to stack frames, but
* do not have to follow the stack frames. Instead it is recommended that they follow logical
* nesting. You may want to use
* [Event
* Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
* as they are defined in WTF.
*
* Used to mark scope entry. The return value is used to leave the scope.
*
* var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
*
* someMethod() {
* var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
* // DO SOME WORK HERE
* return wtfLeave(s, 123); // Return value 123
* }
*
* Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
* negatively impact the performance of your application. For this reason we recommend that
* you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
* so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
* exception, will produce incorrect trace, but presence of exception signifies logic error which
* needs to be fixed before the app should be profiled. Add try-finally only when you expect that
* an exception is expected during normal execution while profiling.
*
* \@experimental
*/
var wtfCreateScope = wtfEnabled ? createScope : function (signature, flags) {
return noopScope;
};
/**
* Used to mark end of Scope.
*
* - `scope` to end.
* - `returnValue` (optional) to be passed to the WTF.
*
* Returns the `returnValue for easy chaining.
* \@experimental
*/
var wtfLeave = wtfEnabled ? leave : function (s, r) {
return r;
};
/**
* Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
* The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
* enabled.
*
* someMethod() {
* var s = wtfStartTimeRange('HTTP:GET', 'some.url');
* var future = new Future.delay(5).then((_) {
* wtfEndTimeRange(s);
* });
* }
* \@experimental
*/
var wtfStartTimeRange = wtfEnabled ? startTimeRange : function (rangeType, action) {
return null;
};
/**
* Ends a async time range operation.
* [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
* enabled.
* \@experimental
*/
var wtfEndTimeRange = wtfEnabled ? endTimeRange : function (r) {
return null;
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Use by directives and components to emit custom Events.
*
* ### Examples
*
* In the following example, `Zippy` alternatively emits `open` and `close` events when its
* title gets clicked:
*
* ```
* \@Component({
* selector: 'zippy',
* template: `
* <div class="zippy">
* <div (click)="toggle()">Toggle</div>
* <div [hidden]="!visible">
* <ng-content></ng-content>
* </div>
* </div>`})
* export class Zippy {
* visible: boolean = true;
* \@Output() open: EventEmitter<any> = new EventEmitter();
* \@Output() close: EventEmitter<any> = new EventEmitter();
*
* toggle() {
* this.visible = !this.visible;
* if (this.visible) {
* this.open.emit(null);
* } else {
* this.close.emit(null);
* }
* }
* }
* ```
*
* The events payload can be accessed by the parameter `$event` on the components output event
* handler:
*
* ```
* <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
* ```
*
* Uses Rx.Observable but provides an adapter to make it work as specified here:
* https://github.com/jhusain/observable-spec
*
* Once a reference implementation of the spec is available, switch to it.
* \@stable
*/
var EventEmitter = /** @class */function (_super) {
__extends(EventEmitter, _super);
/**
* Creates an instance of {@link EventEmitter}, which depending on `isAsync`,
* delivers events synchronously or asynchronously.
*
* @param isAsync By default, events are delivered synchronously (default value: `false`).
* Set to `true` for asynchronous event delivery.
*/
function EventEmitter(isAsync) {
if (isAsync === void 0) {
isAsync = false;
}
var _this = _super.call(this) || this;
_this.__isAsync = isAsync;
return _this;
}
/**
* @param {?=} value
* @return {?}
*/
EventEmitter.prototype.emit = /**
* @param {?=} value
* @return {?}
*/
function (value) {
_super.prototype.next.call(this, value);
};
/**
* @param {?=} generatorOrNext
* @param {?=} error
* @param {?=} complete
* @return {?}
*/
EventEmitter.prototype.subscribe = /**
* @param {?=} generatorOrNext
* @param {?=} error
* @param {?=} complete
* @return {?}
*/
function (generatorOrNext, error, complete) {
var /** @type {?} */schedulerFn;
var /** @type {?} */errorFn = function (err) {
return null;
};
var /** @type {?} */completeFn = function () {
return null;
};
if (generatorOrNext && typeof generatorOrNext === 'object') {
schedulerFn = this.__isAsync ? function (value) {
setTimeout(function () {
return generatorOrNext.next(value);
});
} : function (value) {
generatorOrNext.next(value);
};
if (generatorOrNext.error) {
errorFn = this.__isAsync ? function (err) {
setTimeout(function () {
return generatorOrNext.error(err);
});
} : function (err) {
generatorOrNext.error(err);
};
}
if (generatorOrNext.complete) {
completeFn = this.__isAsync ? function () {
setTimeout(function () {
return generatorOrNext.complete();
});
} : function () {
generatorOrNext.complete();
};
}
} else {
schedulerFn = this.__isAsync ? function (value) {
setTimeout(function () {
return generatorOrNext(value);
});
} : function (value) {
generatorOrNext(value);
};
if (error) {
errorFn = this.__isAsync ? function (err) {
setTimeout(function () {
return error(err);
});
} : function (err) {
error(err);
};
}
if (complete) {
completeFn = this.__isAsync ? function () {
setTimeout(function () {
return complete();
});
} : function () {
complete();
};
}
}
return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
};
return EventEmitter;
}(rxjs_Subject.Subject);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An injectable service for executing work inside or outside of the Angular zone.
*
* The most common use of this service is to optimize performance when starting a work consisting of
* one or more asynchronous tasks that don't require UI updates or error handling to be handled by
* Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
* can reenter the Angular zone via {\@link #run}.
*
* <!-- TODO: add/fix links to:
* - docs explaining zones and the use of zones in Angular and change-detection
* - link to runOutsideAngular/run (throughout this file!)
* -->
*
* ### Example
*
* ```
* import {Component, NgZone} from '\@angular/core';
* import {NgIf} from '\@angular/common';
*
* \@Component({
* selector: 'ng-zone-demo',
* template: `
* <h2>Demo: NgZone</h2>
*
* <p>Progress: {{progress}}%</p>
* <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
*
* <button (click)="processWithinAngularZone()">Process within Angular zone</button>
* <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
* `,
* })
* export class NgZoneDemo {
* progress: number = 0;
* label: string;
*
* constructor(private _ngZone: NgZone) {}
*
* // Loop inside the Angular zone
* // so the UI DOES refresh after each setTimeout cycle
* processWithinAngularZone() {
* this.label = 'inside';
* this.progress = 0;
* this._increaseProgress(() => console.log('Inside Done!'));
* }
*
* // Loop outside of the Angular zone
* // so the UI DOES NOT refresh after each setTimeout cycle
* processOutsideOfAngularZone() {
* this.label = 'outside';
* this.progress = 0;
* this._ngZone.runOutsideAngular(() => {
* this._increaseProgress(() => {
* // reenter the Angular zone and display done
* this._ngZone.run(() => { console.log('Outside Done!'); });
* });
* });
* }
*
* _increaseProgress(doneCallback: () => void) {
* this.progress += 1;
* console.log(`Current progress: ${this.progress}%`);
*
* if (this.progress < 100) {
* window.setTimeout(() => this._increaseProgress(doneCallback), 10);
* } else {
* doneCallback();
* }
* }
* }
* ```
*
* \@experimental
*/
var NgZone = /** @class */function () {
function NgZone(_a) {
var _b = _a.enableLongStackTrace,
enableLongStackTrace = _b === void 0 ? false : _b;
this.hasPendingMicrotasks = false;
this.hasPendingMacrotasks = false;
/**
* Whether there are no outstanding microtasks or macrotasks.
*/
this.isStable = true;
/**
* Notifies when code enters Angular Zone. This gets fired first on VM Turn.
*/
this.onUnstable = new EventEmitter(false);
/**
* Notifies when there is no more microtasks enqueued in the current VM Turn.
* This is a hint for Angular to do change detection, which may enqueue more microtasks.
* For this reason this event can fire multiple times per VM Turn.
*/
this.onMicrotaskEmpty = new EventEmitter(false);
/**
* Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
* implies we are about to relinquish VM turn.
* This event gets called just once.
*/
this.onStable = new EventEmitter(false);
/**
* Notifies that an error has been delivered.
*/
this.onError = new EventEmitter(false);
if (typeof Zone == 'undefined') {
throw new Error("In this configuration Angular requires Zone.js");
}
Zone.assertZonePatched();
var /** @type {?} */self = /** @type {?} */this;
self._nesting = 0;
self._outer = self._inner = Zone.current;
if ( /** @type {?} */Zone['wtfZoneSpec']) {
self._inner = self._inner.fork( /** @type {?} */Zone['wtfZoneSpec']);
}
if (enableLongStackTrace && /** @type {?} */Zone['longStackTraceZoneSpec']) {
self._inner = self._inner.fork( /** @type {?} */Zone['longStackTraceZoneSpec']);
}
forkInnerZoneWithAngularBehavior(self);
}
/**
* @return {?}
*/
NgZone.isInAngularZone = /**
* @return {?}
*/
function () {
return Zone.current.get('isAngularZone') === true;
};
/**
* @return {?}
*/
NgZone.assertInAngularZone = /**
* @return {?}
*/
function () {
if (!NgZone.isInAngularZone()) {
throw new Error('Expected to be in Angular Zone, but it is not!');
}
};
/**
* @return {?}
*/
NgZone.assertNotInAngularZone = /**
* @return {?}
*/
function () {
if (NgZone.isInAngularZone()) {
throw new Error('Expected to not be in Angular Zone, but it is!');
}
};
/**
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
* the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
*/
/**
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
* the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @return {?}
*/
NgZone.prototype.run = /**
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
* the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @return {?}
*/
function (fn, applyThis, applyArgs) {
return (/** @type {?} */ /** @type {?} */this._inner.run(fn, applyThis, applyArgs)
);
};
/**
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
* returned by the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
*/
/**
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
* returned by the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @param {?=} name
* @return {?}
*/
NgZone.prototype.runTask = /**
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
* returned by the function.
*
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
* outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* within the Angular zone.
*
* If a synchronous error happens it will be rethrown and not reported via `onError`.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @param {?=} name
* @return {?}
*/
function (fn, applyThis, applyArgs, name) {
var /** @type {?} */zone = /** @type {?} */this._inner;
var /** @type {?} */task = zone.scheduleEventTask('NgZoneEvent: ' + name, fn, EMPTY_PAYLOAD, noop, noop);
try {
return (/** @type {?} */zone.runTask(task, applyThis, applyArgs)
);
} finally {
zone.cancelTask(task);
}
};
/**
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
* rethrown.
*/
/**
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
* rethrown.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @return {?}
*/
NgZone.prototype.runGuarded = /**
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
* rethrown.
* @template T
* @param {?} fn
* @param {?=} applyThis
* @param {?=} applyArgs
* @return {?}
*/
function (fn, applyThis, applyArgs) {
return (/** @type {?} */ /** @type {?} */this._inner.runGuarded(fn, applyThis, applyArgs)
);
};
/**
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
* the function.
*
* Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
* work that
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* outside of the Angular zone.
*
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
*/
/**
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
* the function.
*
* Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
* work that
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* outside of the Angular zone.
*
* Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
* @template T
* @param {?} fn
* @return {?}
*/
NgZone.prototype.runOutsideAngular = /**
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
* the function.
*
* Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
* work that
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
*
* Any future tasks or microtasks scheduled from within this function will continue executing from
* outside of the Angular zone.
*
* Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
* @template T
* @param {?} fn
* @return {?}
*/
function (fn) {
return (/** @type {?} */ /** @type {?} */this._outer.run(fn)
);
};
return NgZone;
}();
/**
* @return {?}
*/
function noop() {}
var EMPTY_PAYLOAD = {};
/**
* @param {?} zone
* @return {?}
*/
function checkStable(zone) {
if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
try {
zone._nesting++;
zone.onMicrotaskEmpty.emit(null);
} finally {
zone._nesting--;
if (!zone.hasPendingMicrotasks) {
try {
zone.runOutsideAngular(function () {
return zone.onStable.emit(null);
});
} finally {
zone.isStable = true;
}
}
}
}
}
/**
* @param {?} zone
* @return {?}
*/
function forkInnerZoneWithAngularBehavior(zone) {
zone._inner = zone._inner.fork({
name: 'angular',
properties: /** @type {?} */{ 'isAngularZone': true },
onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
try {
onEnter(zone);
return delegate.invokeTask(target, task, applyThis, applyArgs);
} finally {
onLeave(zone);
}
},
onInvoke: function (delegate, current, target, callback, applyThis, applyArgs, source) {
try {
onEnter(zone);
return delegate.invoke(target, callback, applyThis, applyArgs, source);
} finally {
onLeave(zone);
}
},
onHasTask: function (delegate, current, target, hasTaskState) {
delegate.hasTask(target, hasTaskState);
if (current === target) {
// We are only interested in hasTask events which originate from our zone
// (A child hasTask event is not interesting to us)
if (hasTaskState.change == 'microTask') {
zone.hasPendingMicrotasks = hasTaskState.microTask;
checkStable(zone);
} else if (hasTaskState.change == 'macroTask') {
zone.hasPendingMacrotasks = hasTaskState.macroTask;
}
}
},
onHandleError: function (delegate, current, target, error) {
delegate.handleError(target, error);
zone.runOutsideAngular(function () {
return zone.onError.emit(error);
});
return false;
}
});
}
/**
* @param {?} zone
* @return {?}
*/
function onEnter(zone) {
zone._nesting++;
if (zone.isStable) {
zone.isStable = false;
zone.onUnstable.emit(null);
}
}
/**
* @param {?} zone
* @return {?}
*/
function onLeave(zone) {
zone._nesting--;
checkStable(zone);
}
/**
* Provides a noop implementation of `NgZone` which does nothing. This zone requires explicit calls
* to framework to perform rendering.
*
* \@internal
*/
var NoopNgZone = /** @class */function () {
function NoopNgZone() {
this.hasPendingMicrotasks = false;
this.hasPendingMacrotasks = false;
this.isStable = true;
this.onUnstable = new EventEmitter();
this.onMicrotaskEmpty = new EventEmitter();
this.onStable = new EventEmitter();
this.onError = new EventEmitter();
}
/**
* @param {?} fn
* @return {?}
*/
NoopNgZone.prototype.run = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
return fn();
};
/**
* @param {?} fn
* @return {?}
*/
NoopNgZone.prototype.runGuarded = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
return fn();
};
/**
* @param {?} fn
* @return {?}
*/
NoopNgZone.prototype.runOutsideAngular = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
return fn();
};
/**
* @template T
* @param {?} fn
* @return {?}
*/
NoopNgZone.prototype.runTask = /**
* @template T
* @param {?} fn
* @return {?}
*/
function (fn) {
return fn();
};
return NoopNgZone;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* The Testability service provides testing hooks that can be accessed from
* the browser and by services such as Protractor. Each bootstrapped Angular
* application on the page will have an instance of Testability.
* \@experimental
*/
var Testability = /** @class */function () {
function Testability(_ngZone) {
this._ngZone = _ngZone;
/**
* \@internal
*/
this._pendingCount = 0;
/**
* \@internal
*/
this._isZoneStable = true;
/**
* Whether any work was done since the last 'whenStable' callback. This is
* useful to detect if this could have potentially destabilized another
* component while it is stabilizing.
* \@internal
*/
this._didWork = false;
/**
* \@internal
*/
this._callbacks = [];
this._watchAngularEvents();
}
/** @internal */
/**
* \@internal
* @return {?}
*/
Testability.prototype._watchAngularEvents = /**
* \@internal
* @return {?}
*/
function () {
var _this = this;
this._ngZone.onUnstable.subscribe({
next: function () {
_this._didWork = true;
_this._isZoneStable = false;
}
});
this._ngZone.runOutsideAngular(function () {
_this._ngZone.onStable.subscribe({
next: function () {
NgZone.assertNotInAngularZone();
scheduleMicroTask(function () {
_this._isZoneStable = true;
_this._runCallbacksIfReady();
});
}
});
});
};
/**
* Increases the number of pending request
*/
/**
* Increases the number of pending request
* @return {?}
*/
Testability.prototype.increasePendingRequestCount = /**
* Increases the number of pending request
* @return {?}
*/
function () {
this._pendingCount += 1;
this._didWork = true;
return this._pendingCount;
};
/**
* Decreases the number of pending request
*/
/**
* Decreases the number of pending request
* @return {?}
*/
Testability.prototype.decreasePendingRequestCount = /**
* Decreases the number of pending request
* @return {?}
*/
function () {
this._pendingCount -= 1;
if (this._pendingCount < 0) {
throw new Error('pending async requests below zero');
}
this._runCallbacksIfReady();
return this._pendingCount;
};
/**
* Whether an associated application is stable
*/
/**
* Whether an associated application is stable
* @return {?}
*/
Testability.prototype.isStable = /**
* Whether an associated application is stable
* @return {?}
*/
function () {
return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
};
/** @internal */
/**
* \@internal
* @return {?}
*/
Testability.prototype._runCallbacksIfReady = /**
* \@internal
* @return {?}
*/
function () {
var _this = this;
if (this.isStable()) {
// Schedules the call backs in a new frame so that it is always async.
scheduleMicroTask(function () {
while (_this._callbacks.length !== 0) {
/** @type {?} */_this._callbacks.pop()(_this._didWork);
}
_this._didWork = false;
});
} else {
// Not Ready
this._didWork = true;
}
};
/**
* Run callback when the application is stable
* @param callback function to be called after the application is stable
*/
/**
* Run callback when the application is stable
* @param {?} callback function to be called after the application is stable
* @return {?}
*/
Testability.prototype.whenStable = /**
* Run callback when the application is stable
* @param {?} callback function to be called after the application is stable
* @return {?}
*/
function (callback) {
this._callbacks.push(callback);
this._runCallbacksIfReady();
};
/**
* Get the number of pending requests
*/
/**
* Get the number of pending requests
* @return {?}
*/
Testability.prototype.getPendingRequestCount = /**
* Get the number of pending requests
* @return {?}
*/
function () {
return this._pendingCount;
};
/**
* Find providers by name
* @param using The root element to search from
* @param provider The name of binding variable
* @param exactMatch Whether using exactMatch
*/
/**
* Find providers by name
* @param {?} using The root element to search from
* @param {?} provider The name of binding variable
* @param {?} exactMatch Whether using exactMatch
* @return {?}
*/
Testability.prototype.findProviders = /**
* Find providers by name
* @param {?} using The root element to search from
* @param {?} provider The name of binding variable
* @param {?} exactMatch Whether using exactMatch
* @return {?}
*/
function (using, provider, exactMatch) {
// TODO(juliemr): implement.
return [];
};
Testability.decorators = [{ type: Injectable }];
/** @nocollapse */
Testability.ctorParameters = function () {
return [{ type: NgZone }];
};
return Testability;
}();
/**
* A global registry of {\@link Testability} instances for specific elements.
* \@experimental
*/
var TestabilityRegistry = /** @class */function () {
function TestabilityRegistry() {
/**
* \@internal
*/
this._applications = new Map();
_testabilityGetter.addToWindow(this);
}
/**
* Registers an application with a testability hook so that it can be tracked
* @param token token of application, root element
* @param testability Testability hook
*/
/**
* Registers an application with a testability hook so that it can be tracked
* @param {?} token token of application, root element
* @param {?} testability Testability hook
* @return {?}
*/
TestabilityRegistry.prototype.registerApplication = /**
* Registers an application with a testability hook so that it can be tracked
* @param {?} token token of application, root element
* @param {?} testability Testability hook
* @return {?}
*/
function (token, testability) {
this._applications.set(token, testability);
};
/**
* Unregisters an application.
* @param token token of application, root element
*/
/**
* Unregisters an application.
* @param {?} token token of application, root element
* @return {?}
*/
TestabilityRegistry.prototype.unregisterApplication = /**
* Unregisters an application.
* @param {?} token token of application, root element
* @return {?}
*/
function (token) {
this._applications.delete(token);
};
/**
* Unregisters all applications
*/
/**
* Unregisters all applications
* @return {?}
*/
TestabilityRegistry.prototype.unregisterAllApplications = /**
* Unregisters all applications
* @return {?}
*/
function () {
this._applications.clear();
};
/**
* Get a testability hook associated with the application
* @param elem root element
*/
/**
* Get a testability hook associated with the application
* @param {?} elem root element
* @return {?}
*/
TestabilityRegistry.prototype.getTestability = /**
* Get a testability hook associated with the application
* @param {?} elem root element
* @return {?}
*/
function (elem) {
return this._applications.get(elem) || null;
};
/**
* Get all registered testabilities
*/
/**
* Get all registered testabilities
* @return {?}
*/
TestabilityRegistry.prototype.getAllTestabilities = /**
* Get all registered testabilities
* @return {?}
*/
function () {
return Array.from(this._applications.values());
};
/**
* Get all registered applications(root elements)
*/
/**
* Get all registered applications(root elements)
* @return {?}
*/
TestabilityRegistry.prototype.getAllRootElements = /**
* Get all registered applications(root elements)
* @return {?}
*/
function () {
return Array.from(this._applications.keys());
};
/**
* Find testability of a node in the Tree
* @param elem node
* @param findInAncestors whether finding testability in ancestors if testability was not found in
* current node
*/
/**
* Find testability of a node in the Tree
* @param {?} elem node
* @param {?=} findInAncestors whether finding testability in ancestors if testability was not found in
* current node
* @return {?}
*/
TestabilityRegistry.prototype.findTestabilityInTree = /**
* Find testability of a node in the Tree
* @param {?} elem node
* @param {?=} findInAncestors whether finding testability in ancestors if testability was not found in
* current node
* @return {?}
*/
function (elem, findInAncestors) {
if (findInAncestors === void 0) {
findInAncestors = true;
}
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
};
TestabilityRegistry.decorators = [{ type: Injectable }];
/** @nocollapse */
TestabilityRegistry.ctorParameters = function () {
return [];
};
return TestabilityRegistry;
}();
/**
* Adapter interface for retrieving the `Testability` service associated for a
* particular context.
*
* \@experimental Testability apis are primarily intended to be used by e2e test tool vendors like
* the Protractor team.
* @record
*/
var _NoopGetTestability = /** @class */function () {
function _NoopGetTestability() {}
/**
* @param {?} registry
* @return {?}
*/
_NoopGetTestability.prototype.addToWindow = /**
* @param {?} registry
* @return {?}
*/
function (registry) {};
/**
* @param {?} registry
* @param {?} elem
* @param {?} findInAncestors
* @return {?}
*/
_NoopGetTestability.prototype.findTestabilityInTree = /**
* @param {?} registry
* @param {?} elem
* @param {?} findInAncestors
* @return {?}
*/
function (registry, elem, findInAncestors) {
return null;
};
return _NoopGetTestability;
}();
/**
* Set the {\@link GetTestability} implementation used by the Angular testing framework.
* \@experimental
* @param {?} getter
* @return {?}
*/
function setTestabilityGetter(getter) {
_testabilityGetter = getter;
}
var _testabilityGetter = new _NoopGetTestability();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _devMode = true;
var _runModeLocked = false;
var _platform;
var ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
/**
* Disable Angular's development mode, which turns off assertions and other
* checks within the framework.
*
* One important assertion this disables verifies that a change detection pass
* does not result in additional changes to any bindings (also known as
* unidirectional data flow).
*
* \@stable
* @return {?}
*/
function enableProdMode() {
if (_runModeLocked) {
throw new Error('Cannot enable prod mode after platform setup.');
}
_devMode = false;
}
/**
* Returns whether Angular is in development mode. After called once,
* the value is locked and won't change any more.
*
* By default, this is true, unless a user calls `enableProdMode` before calling this.
*
* \@experimental APIs related to application bootstrap are currently under review.
* @return {?}
*/
function isDevMode() {
_runModeLocked = true;
return _devMode;
}
/**
* A token for third-party components that can register themselves with NgProbe.
*
* \@experimental
*/
var NgProbeToken = /** @class */function () {
function NgProbeToken(name, token) {
this.name = name;
this.token = token;
}
return NgProbeToken;
}();
/**
* Creates a platform.
* Platforms have to be eagerly created via this function.
*
* \@experimental APIs related to application bootstrap are currently under review.
* @param {?} injector
* @return {?}
*/
function createPlatform(injector) {
if (_platform && !_platform.destroyed && !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
}
_platform = injector.get(PlatformRef);
var /** @type {?} */inits = injector.get(PLATFORM_INITIALIZER, null);
if (inits) inits.forEach(function (init) {
return init();
});
return _platform;
}
/**
* Creates a factory for a platform
*
* \@experimental APIs related to application bootstrap are currently under review.
* @param {?} parentPlatformFactory
* @param {?} name
* @param {?=} providers
* @return {?}
*/
function createPlatformFactory(parentPlatformFactory, name, providers) {
if (providers === void 0) {
providers = [];
}
var /** @type {?} */marker = new InjectionToken("Platform: " + name);
return function (extraProviders) {
if (extraProviders === void 0) {
extraProviders = [];
}
var /** @type {?} */platform = getPlatform();
if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
if (parentPlatformFactory) {
parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
} else {
createPlatform(Injector.create(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
}
}
return assertPlatform(marker);
};
}
/**
* Checks that there currently is a platform which contains the given token as a provider.
*
* \@experimental APIs related to application bootstrap are currently under review.
* @param {?} requiredToken
* @return {?}
*/
function assertPlatform(requiredToken) {
var /** @type {?} */platform = getPlatform();
if (!platform) {
throw new Error('No platform exists!');
}
if (!platform.injector.get(requiredToken, null)) {
throw new Error('A platform with a different configuration has been created. Please destroy it first.');
}
return platform;
}
/**
* Destroy the existing platform.
*
* \@experimental APIs related to application bootstrap are currently under review.
* @return {?}
*/
function destroyPlatform() {
if (_platform && !_platform.destroyed) {
_platform.destroy();
}
}
/**
* Returns the current platform.
*
* \@experimental APIs related to application bootstrap are currently under review.
* @return {?}
*/
function getPlatform() {
return _platform && !_platform.destroyed ? _platform : null;
}
/**
* Provides additional options to the bootstraping process.
*
* \@stable
* @record
*/
/**
* The Angular platform is the entry point for Angular on a web page. Each page
* has exactly one platform, and services (such as reflection) which are common
* to every Angular application running on the page are bound in its scope.
*
* A page's platform is initialized implicitly when a platform is created via a platform factory
* (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
*
* \@stable
*/
var PlatformRef = /** @class */function () {
/** @internal */
function PlatformRef(_injector) {
this._injector = _injector;
this._modules = [];
this._destroyListeners = [];
this._destroyed = false;
}
/**
* Creates an instance of an `@NgModule` for the given platform
* for offline compilation.
*
* ## Simple Example
*
* ```typescript
* my_module.ts:
*
* @NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* main.ts:
* import {MyModuleNgFactory} from './my_module.ngfactory';
* import {platformBrowser} from '@angular/platform-browser';
*
* let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
* ```
*
* @experimental APIs related to application bootstrap are currently under review.
*/
/**
* Creates an instance of an `\@NgModule` for the given platform
* for offline compilation.
*
* ## Simple Example
*
* ```typescript
* my_module.ts:
*
* \@NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* main.ts:
* import {MyModuleNgFactory} from './my_module.ngfactory';
* import {platformBrowser} from '\@angular/platform-browser';
*
* let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
* ```
*
* \@experimental APIs related to application bootstrap are currently under review.
* @template M
* @param {?} moduleFactory
* @param {?=} options
* @return {?}
*/
PlatformRef.prototype.bootstrapModuleFactory = /**
* Creates an instance of an `\@NgModule` for the given platform
* for offline compilation.
*
* ## Simple Example
*
* ```typescript
* my_module.ts:
*
* \@NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* main.ts:
* import {MyModuleNgFactory} from './my_module.ngfactory';
* import {platformBrowser} from '\@angular/platform-browser';
*
* let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
* ```
*
* \@experimental APIs related to application bootstrap are currently under review.
* @template M
* @param {?} moduleFactory
* @param {?=} options
* @return {?}
*/
function (moduleFactory, options) {
var _this = this;
// Note: We need to create the NgZone _before_ we instantiate the module,
// as instantiating the module creates some providers eagerly.
// So we create a mini parent injector that just contains the new NgZone and
// pass that as parent to the NgModuleFactory.
var /** @type {?} */ngZoneOption = options ? options.ngZone : undefined;
var /** @type {?} */ngZone = getNgZone(ngZoneOption);
// Attention: Don't use ApplicationRef.run here,
// as we want to be sure that all possible constructor calls are inside `ngZone.run`!
return ngZone.run(function () {
var /** @type {?} */ngZoneInjector = Injector.create([{ provide: NgZone, useValue: ngZone }], _this.injector);
var /** @type {?} */moduleRef = /** @type {?} */moduleFactory.create(ngZoneInjector);
var /** @type {?} */exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
if (!exceptionHandler) {
throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
}
moduleRef.onDestroy(function () {
return remove(_this._modules, moduleRef);
}); /** @type {?} */
ngZone.runOutsideAngular(function () {
return ngZone.onError.subscribe({ next: function (error) {
exceptionHandler.handleError(error);
} });
});
return _callAndReportToErrorHandler(exceptionHandler, /** @type {?} */ngZone, function () {
var /** @type {?} */initStatus = moduleRef.injector.get(ApplicationInitStatus);
initStatus.runInitializers();
return initStatus.donePromise.then(function () {
_this._moduleDoBootstrap(moduleRef);
return moduleRef;
});
});
});
};
/**
* Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
*
* ## Simple Example
*
* ```typescript
* @NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* let moduleRef = platformBrowser().bootstrapModule(MyModule);
* ```
* @stable
*/
/**
* Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
*
* ## Simple Example
*
* ```typescript
* \@NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* let moduleRef = platformBrowser().bootstrapModule(MyModule);
* ```
* \@stable
* @template M
* @param {?} moduleType
* @param {?=} compilerOptions
* @return {?}
*/
PlatformRef.prototype.bootstrapModule = /**
* Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
*
* ## Simple Example
*
* ```typescript
* \@NgModule({
* imports: [BrowserModule]
* })
* class MyModule {}
*
* let moduleRef = platformBrowser().bootstrapModule(MyModule);
* ```
* \@stable
* @template M
* @param {?} moduleType
* @param {?=} compilerOptions
* @return {?}
*/
function (moduleType, compilerOptions) {
var _this = this;
if (compilerOptions === void 0) {
compilerOptions = [];
}
var /** @type {?} */compilerFactory = this.injector.get(CompilerFactory);
var /** @type {?} */options = optionsReducer({}, compilerOptions);
var /** @type {?} */compiler = compilerFactory.createCompiler([options]);
return compiler.compileModuleAsync(moduleType).then(function (moduleFactory) {
return _this.bootstrapModuleFactory(moduleFactory, options);
});
};
/**
* @param {?} moduleRef
* @return {?}
*/
PlatformRef.prototype._moduleDoBootstrap = /**
* @param {?} moduleRef
* @return {?}
*/
function (moduleRef) {
var /** @type {?} */appRef = /** @type {?} */moduleRef.injector.get(ApplicationRef);
if (moduleRef._bootstrapComponents.length > 0) {
moduleRef._bootstrapComponents.forEach(function (f) {
return appRef.bootstrap(f);
});
} else if (moduleRef.instance.ngDoBootstrap) {
moduleRef.instance.ngDoBootstrap(appRef);
} else {
throw new Error("The module " + stringify(moduleRef.instance.constructor) + " was bootstrapped, but it does not declare \"@NgModule.bootstrap\" components nor a \"ngDoBootstrap\" method. " + "Please define one of these.");
}
this._modules.push(moduleRef);
};
/**
* Register a listener to be called when the platform is disposed.
*/
/**
* Register a listener to be called when the platform is disposed.
* @param {?} callback
* @return {?}
*/
PlatformRef.prototype.onDestroy = /**
* Register a listener to be called when the platform is disposed.
* @param {?} callback
* @return {?}
*/
function (callback) {
this._destroyListeners.push(callback);
};
Object.defineProperty(PlatformRef.prototype, "injector", {
/**
* Retrieve the platform {@link Injector}, which is the parent injector for
* every Angular application on the page and provides singleton providers.
*/
get: /**
* Retrieve the platform {\@link Injector}, which is the parent injector for
* every Angular application on the page and provides singleton providers.
* @return {?}
*/
function () {
return this._injector;
},
enumerable: true,
configurable: true
});
/**
* Destroy the Angular platform and all Angular applications on the page.
*/
/**
* Destroy the Angular platform and all Angular applications on the page.
* @return {?}
*/
PlatformRef.prototype.destroy = /**
* Destroy the Angular platform and all Angular applications on the page.
* @return {?}
*/
function () {
if (this._destroyed) {
throw new Error('The platform has already been destroyed!');
}
this._modules.slice().forEach(function (module) {
return module.destroy();
});
this._destroyListeners.forEach(function (listener) {
return listener();
});
this._destroyed = true;
};
Object.defineProperty(PlatformRef.prototype, "destroyed", {
get: /**
* @return {?}
*/
function () {
return this._destroyed;
},
enumerable: true,
configurable: true
});
PlatformRef.decorators = [{ type: Injectable }];
/** @nocollapse */
PlatformRef.ctorParameters = function () {
return [{ type: Injector }];
};
return PlatformRef;
}();
/**
* @param {?=} ngZoneOption
* @return {?}
*/
function getNgZone(ngZoneOption) {
var /** @type {?} */ngZone;
if (ngZoneOption === 'noop') {
ngZone = new NoopNgZone();
} else {
ngZone = (ngZoneOption === 'zone.js' ? undefined : ngZoneOption) || new NgZone({ enableLongStackTrace: isDevMode() });
}
return ngZone;
}
/**
* @param {?} errorHandler
* @param {?} ngZone
* @param {?} callback
* @return {?}
*/
function _callAndReportToErrorHandler(errorHandler, ngZone, callback) {
try {
var /** @type {?} */result = callback();
if (isPromise(result)) {
return result.catch(function (e) {
ngZone.runOutsideAngular(function () {
return errorHandler.handleError(e);
});
// rethrow as the exception handler might not do it
throw e;
});
}
return result;
} catch ( /** @type {?} */e) {
ngZone.runOutsideAngular(function () {
return errorHandler.handleError(e);
});
// rethrow as the exception handler might not do it
throw e;
}
}
/**
* @template T
* @param {?} dst
* @param {?} objs
* @return {?}
*/
function optionsReducer(dst, objs) {
if (Array.isArray(objs)) {
dst = objs.reduce(optionsReducer, dst);
} else {
dst = __assign({}, dst, /** @type {?} */objs);
}
return dst;
}
/**
* A reference to an Angular application running on a page.
*
* \@stable
*/
var ApplicationRef = /** @class */function () {
/** @internal */
function ApplicationRef(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
var _this = this;
this._zone = _zone;
this._console = _console;
this._injector = _injector;
this._exceptionHandler = _exceptionHandler;
this._componentFactoryResolver = _componentFactoryResolver;
this._initStatus = _initStatus;
this._bootstrapListeners = [];
this._views = [];
this._runningTick = false;
this._enforceNoNewChanges = false;
this._stable = true;
/**
* Get a list of component types registered to this application.
* This list is populated even before the component is created.
*/
this.componentTypes = [];
/**
* Get a list of components registered to this application.
*/
this.components = [];
this._enforceNoNewChanges = isDevMode();
this._zone.onMicrotaskEmpty.subscribe({ next: function () {
_this._zone.run(function () {
_this.tick();
});
} });
var /** @type {?} */isCurrentlyStable = new rxjs_Observable.Observable(function (observer) {
_this._stable = _this._zone.isStable && !_this._zone.hasPendingMacrotasks && !_this._zone.hasPendingMicrotasks;
_this._zone.runOutsideAngular(function () {
observer.next(_this._stable);
observer.complete();
});
});
var /** @type {?} */isStable = new rxjs_Observable.Observable(function (observer) {
// Create the subscription to onStable outside the Angular Zone so that
// the callback is run outside the Angular Zone.
var /** @type {?} */stableSub;
_this._zone.runOutsideAngular(function () {
stableSub = _this._zone.onStable.subscribe(function () {
NgZone.assertNotInAngularZone();
// Check whether there are no pending macro/micro tasks in the next tick
// to allow for NgZone to update the state.
scheduleMicroTask(function () {
if (!_this._stable && !_this._zone.hasPendingMacrotasks && !_this._zone.hasPendingMicrotasks) {
_this._stable = true;
observer.next(true);
}
});
});
});
var /** @type {?} */unstableSub = _this._zone.onUnstable.subscribe(function () {
NgZone.assertInAngularZone();
if (_this._stable) {
_this._stable = false;
_this._zone.runOutsideAngular(function () {
observer.next(false);
});
}
});
return function () {
stableSub.unsubscribe();
unstableSub.unsubscribe();
};
});
/** @type {?} */this.isStable = rxjs_observable_merge.merge(isCurrentlyStable, rxjs_operator_share.share.call(isStable));
}
/**
* Bootstrap a new component at the root level of the application.
*
* ### Bootstrap process
*
* When bootstrapping a new root component into an application, Angular mounts the
* specified application component onto DOM elements identified by the [componentType]'s
* selector and kicks off automatic change detection to finish initializing the component.
*
* Optionally, a component can be mounted onto a DOM element that does not match the
* [componentType]'s selector.
*
* ### Example
* {@example core/ts/platform/platform.ts region='longform'}
*/
/**
* Bootstrap a new component at the root level of the application.
*
* ### Bootstrap process
*
* When bootstrapping a new root component into an application, Angular mounts the
* specified application component onto DOM elements identified by the [componentType]'s
* selector and kicks off automatic change detection to finish initializing the component.
*
* Optionally, a component can be mounted onto a DOM element that does not match the
* [componentType]'s selector.
*
* ### Example
* {\@example core/ts/platform/platform.ts region='longform'}
* @template C
* @param {?} componentOrFactory
* @param {?=} rootSelectorOrNode
* @return {?}
*/
ApplicationRef.prototype.bootstrap = /**
* Bootstrap a new component at the root level of the application.
*
* ### Bootstrap process
*
* When bootstrapping a new root component into an application, Angular mounts the
* specified application component onto DOM elements identified by the [componentType]'s
* selector and kicks off automatic change detection to finish initializing the component.
*
* Optionally, a component can be mounted onto a DOM element that does not match the
* [componentType]'s selector.
*
* ### Example
* {\@example core/ts/platform/platform.ts region='longform'}
* @template C
* @param {?} componentOrFactory
* @param {?=} rootSelectorOrNode
* @return {?}
*/
function (componentOrFactory, rootSelectorOrNode) {
var _this = this;
if (!this._initStatus.done) {
throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
}
var /** @type {?} */componentFactory;
if (componentOrFactory instanceof ComponentFactory) {
componentFactory = componentOrFactory;
} else {
componentFactory =
/** @type {?} */this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
}
this.componentTypes.push(componentFactory.componentType);
// Create a factory associated with the current module if it's not bound to some other
var /** @type {?} */ngModule = componentFactory instanceof ComponentFactoryBoundToModule ? null : this._injector.get(NgModuleRef);
var /** @type {?} */selectorOrNode = rootSelectorOrNode || componentFactory.selector;
var /** @type {?} */compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
compRef.onDestroy(function () {
_this._unloadComponent(compRef);
});
var /** @type {?} */testability = compRef.injector.get(Testability, null);
if (testability) {
compRef.injector.get(TestabilityRegistry).registerApplication(compRef.location.nativeElement, testability);
}
this._loadComponent(compRef);
if (isDevMode()) {
this._console.log("Angular is running in the development mode. Call enableProdMode() to enable the production mode.");
}
return compRef;
};
/**
* Invoke this method to explicitly process change detection and its side-effects.
*
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
* further changes are detected. If additional changes are picked up during this second cycle,
* bindings in the app have side-effects that cannot be resolved in a single change detection
* pass.
* In this case, Angular throws an error, since an Angular application can only have one change
* detection pass during which all change detection must complete.
*/
/**
* Invoke this method to explicitly process change detection and its side-effects.
*
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
* further changes are detected. If additional changes are picked up during this second cycle,
* bindings in the app have side-effects that cannot be resolved in a single change detection
* pass.
* In this case, Angular throws an error, since an Angular application can only have one change
* detection pass during which all change detection must complete.
* @return {?}
*/
ApplicationRef.prototype.tick = /**
* Invoke this method to explicitly process change detection and its side-effects.
*
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
* further changes are detected. If additional changes are picked up during this second cycle,
* bindings in the app have side-effects that cannot be resolved in a single change detection
* pass.
* In this case, Angular throws an error, since an Angular application can only have one change
* detection pass during which all change detection must complete.
* @return {?}
*/
function () {
var _this = this;
if (this._runningTick) {
throw new Error('ApplicationRef.tick is called recursively');
}
var /** @type {?} */scope = ApplicationRef._tickScope();
try {
this._runningTick = true;
this._views.forEach(function (view) {
return view.detectChanges();
});
if (this._enforceNoNewChanges) {
this._views.forEach(function (view) {
return view.checkNoChanges();
});
}
} catch ( /** @type {?} */e) {
// Attention: Don't rethrow as it could cancel subscriptions to Observables!
this._zone.runOutsideAngular(function () {
return _this._exceptionHandler.handleError(e);
});
} finally {
this._runningTick = false;
wtfLeave(scope);
}
};
/**
* Attaches a view so that it will be dirty checked.
* The view will be automatically detached when it is destroyed.
* This will throw if the view is already attached to a ViewContainer.
*/
/**
* Attaches a view so that it will be dirty checked.
* The view will be automatically detached when it is destroyed.
* This will throw if the view is already attached to a ViewContainer.
* @param {?} viewRef
* @return {?}
*/
ApplicationRef.prototype.attachView = /**
* Attaches a view so that it will be dirty checked.
* The view will be automatically detached when it is destroyed.
* This will throw if the view is already attached to a ViewContainer.
* @param {?} viewRef
* @return {?}
*/
function (viewRef) {
var /** @type {?} */view = /** @type {?} */viewRef;
this._views.push(view);
view.attachToAppRef(this);
};
/**
* Detaches a view from dirty checking again.
*/
/**
* Detaches a view from dirty checking again.
* @param {?} viewRef
* @return {?}
*/
ApplicationRef.prototype.detachView = /**
* Detaches a view from dirty checking again.
* @param {?} viewRef
* @return {?}
*/
function (viewRef) {
var /** @type {?} */view = /** @type {?} */viewRef;
remove(this._views, view);
view.detachFromAppRef();
};
/**
* @param {?} componentRef
* @return {?}
*/
ApplicationRef.prototype._loadComponent = /**
* @param {?} componentRef
* @return {?}
*/
function (componentRef) {
this.attachView(componentRef.hostView);
this.tick();
this.components.push(componentRef);
// Get the listeners lazily to prevent DI cycles.
var /** @type {?} */listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
listeners.forEach(function (listener) {
return listener(componentRef);
});
};
/**
* @param {?} componentRef
* @return {?}
*/
ApplicationRef.prototype._unloadComponent = /**
* @param {?} componentRef
* @return {?}
*/
function (componentRef) {
this.detachView(componentRef.hostView);
remove(this.components, componentRef);
};
/** @internal */
/**
* \@internal
* @return {?}
*/
ApplicationRef.prototype.ngOnDestroy = /**
* \@internal
* @return {?}
*/
function () {
// TODO(alxhub): Dispose of the NgZone.
this._views.slice().forEach(function (view) {
return view.destroy();
});
};
Object.defineProperty(ApplicationRef.prototype, "viewCount", {
/**
* Returns the number of attached views.
*/
get: /**
* Returns the number of attached views.
* @return {?}
*/
function () {
return this._views.length;
},
enumerable: true,
configurable: true
});
/**
* \@internal
*/
ApplicationRef._tickScope = wtfCreateScope('ApplicationRef#tick()');
ApplicationRef.decorators = [{ type: Injectable }];
/** @nocollapse */
ApplicationRef.ctorParameters = function () {
return [{ type: NgZone }, { type: Console }, { type: Injector }, { type: ErrorHandler }, { type: ComponentFactoryResolver }, { type: ApplicationInitStatus }];
};
return ApplicationRef;
}();
/**
* @template T
* @param {?} list
* @param {?} el
* @return {?}
*/
function remove(list, el) {
var /** @type {?} */index = list.indexOf(el);
if (index > -1) {
list.splice(index, 1);
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Public API for Zone
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @deprecated Use `RendererType2` (and `Renderer2`) instead.
*/
var RenderComponentType = /** @class */function () {
function RenderComponentType(id, templateUrl, slotCount, encapsulation, styles, animations) {
this.id = id;
this.templateUrl = templateUrl;
this.slotCount = slotCount;
this.encapsulation = encapsulation;
this.styles = styles;
this.animations = animations;
}
return RenderComponentType;
}();
/**
* @deprecated Debug info is handeled internally in the view engine now.
* @abstract
*/
var RenderDebugInfo = /** @class */function () {
function RenderDebugInfo() {}
return RenderDebugInfo;
}();
/**
* @deprecated Use the `Renderer2` instead.
* @record
*/
/**
* @deprecated Use the `Renderer2` instead.
* @abstract
*/
var Renderer = /** @class */function () {
function Renderer() {}
return Renderer;
}();
var Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
/**
* Injectable service that provides a low-level interface for modifying the UI.
*
* Use this service to bypass Angular's templating and make custom UI changes that can't be
* expressed declaratively. For example if you need to set a property or an attribute whose name is
* not statically known, use {\@link Renderer#setElementProperty setElementProperty} or
* {\@link Renderer#setElementAttribute setElementAttribute} respectively.
*
* If you are implementing a custom renderer, you must implement this interface.
*
* The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
*
* @deprecated Use `RendererFactory2` instead.
* @abstract
*/
var RootRenderer = /** @class */function () {
function RootRenderer() {}
return RootRenderer;
}();
/**
* \@experimental
* @record
*/
/**
* \@experimental
* @abstract
*/
var RendererFactory2 = /** @class */function () {
function RendererFactory2() {}
return RendererFactory2;
}();
/** @enum {number} */
var RendererStyleFlags2 = {
Important: 1,
DashCase: 2
};
RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
/**
* \@experimental
* @abstract
*/
var Renderer2 = /** @class */function () {
function Renderer2() {}
return Renderer2;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Public API for render
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A wrapper around a native element inside of a View.
*
* An `ElementRef` is backed by a render-specific element. In the browser, this is usually a DOM
* element.
*
* \@security Permitting direct access to the DOM can make your application more vulnerable to
* XSS attacks. Carefully review any use of `ElementRef` in your code. For more detail, see the
* [Security Guide](http://g.co/ng/security).
*
* \@stable
*/
var ElementRef = /** @class */function () {
function ElementRef(nativeElement) {
this.nativeElement = nativeElement;
}
return ElementRef;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Used to load ng module factories.
* \@stable
* @abstract
*/
var NgModuleFactoryLoader = /** @class */function () {
function NgModuleFactoryLoader() {}
return NgModuleFactoryLoader;
}();
var moduleFactories = new Map();
/**
* Registers a loaded module. Should only be called from generated NgModuleFactory code.
* \@experimental
* @param {?} id
* @param {?} factory
* @return {?}
*/
function registerModuleFactory(id, factory) {
var /** @type {?} */existing = moduleFactories.get(id);
if (existing) {
throw new Error("Duplicate module registered for " + id + " - " + existing.moduleType.name + " vs " + factory.moduleType.name);
}
moduleFactories.set(id, factory);
}
/**
* @return {?}
*/
/**
* Returns the NgModuleFactory with the given id, if it exists and has been loaded.
* Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
* cannot be found.
* \@experimental
* @param {?} id
* @return {?}
*/
function getModuleFactory(id) {
var /** @type {?} */factory = moduleFactories.get(id);
if (!factory) throw new Error("No module with ID " + id + " loaded");
return factory;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An unmodifiable list of items that Angular keeps up to date when the state
* of the application changes.
*
* The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
* provide.
*
* Implements an iterable interface, therefore it can be used in both ES6
* javascript `for (var i of items)` loops as well as in Angular templates with
* `*ngFor="let i of myList"`.
*
* Changes can be observed by subscribing to the changes `Observable`.
*
* NOTE: In the future this class will implement an `Observable` interface.
*
* ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
* ```typescript
* \@Component({...})
* class Container {
* \@ViewChildren(Item) items:QueryList<Item>;
* }
* ```
* \@stable
*/
var QueryList = /** @class */function () {
function QueryList() {
this.dirty = true;
this._results = [];
this.changes = new EventEmitter();
}
Object.defineProperty(QueryList.prototype, "length", {
get: /**
* @return {?}
*/
function () {
return this._results.length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(QueryList.prototype, "first", {
get: /**
* @return {?}
*/
function () {
return this._results[0];
},
enumerable: true,
configurable: true
});
Object.defineProperty(QueryList.prototype, "last", {
get: /**
* @return {?}
*/
function () {
return this._results[this.length - 1];
},
enumerable: true,
configurable: true
});
/**
* See
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
*/
/**
* See
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
* @template U
* @param {?} fn
* @return {?}
*/
QueryList.prototype.map = /**
* See
* [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
* @template U
* @param {?} fn
* @return {?}
*/
function (fn) {
return this._results.map(fn);
};
/**
* See
* [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
*/
/**
* See
* [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
* @param {?} fn
* @return {?}
*/
QueryList.prototype.filter = /**
* See
* [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
* @param {?} fn
* @return {?}
*/
function (fn) {
return this._results.filter(fn);
};
/**
* See
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
*/
/**
* See
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
* @param {?} fn
* @return {?}
*/
QueryList.prototype.find = /**
* See
* [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
* @param {?} fn
* @return {?}
*/
function (fn) {
return this._results.find(fn);
};
/**
* See
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
*/
/**
* See
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
* @template U
* @param {?} fn
* @param {?} init
* @return {?}
*/
QueryList.prototype.reduce = /**
* See
* [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
* @template U
* @param {?} fn
* @param {?} init
* @return {?}
*/
function (fn, init) {
return this._results.reduce(fn, init);
};
/**
* See
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
*/
/**
* See
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
* @param {?} fn
* @return {?}
*/
QueryList.prototype.forEach = /**
* See
* [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
* @param {?} fn
* @return {?}
*/
function (fn) {
this._results.forEach(fn);
};
/**
* See
* [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
*/
/**
* See
* [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
* @param {?} fn
* @return {?}
*/
QueryList.prototype.some = /**
* See
* [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
* @param {?} fn
* @return {?}
*/
function (fn) {
return this._results.some(fn);
};
/**
* @return {?}
*/
QueryList.prototype.toArray = /**
* @return {?}
*/
function () {
return this._results.slice();
};
/**
* @return {?}
*/
QueryList.prototype[getSymbolIterator()] = /**
* @return {?}
*/
function () {
return (/** @type {?} */this._results[getSymbolIterator()]()
);
};
/**
* @return {?}
*/
QueryList.prototype.toString = /**
* @return {?}
*/
function () {
return this._results.toString();
};
/**
* @param {?} res
* @return {?}
*/
QueryList.prototype.reset = /**
* @param {?} res
* @return {?}
*/
function (res) {
this._results = flatten(res);
/** @type {?} */this.dirty = false;
};
/**
* @return {?}
*/
QueryList.prototype.notifyOnChanges = /**
* @return {?}
*/
function () {
/** @type {?} */this.changes.emit(this);
};
/** internal */
/**
* internal
* @return {?}
*/
QueryList.prototype.setDirty = /**
* internal
* @return {?}
*/
function () {
/** @type {?} */this.dirty = true;
};
/** internal */
/**
* internal
* @return {?}
*/
QueryList.prototype.destroy = /**
* internal
* @return {?}
*/
function () {
/** @type {?} */this.changes.complete();
/** @type {?} */this.changes.unsubscribe();
};
return QueryList;
}();
/**
* @template T
* @param {?} list
* @return {?}
*/
function flatten(list) {
return list.reduce(function (flat, item) {
var /** @type {?} */flatItem = Array.isArray(item) ? flatten(item) : item;
return (/** @type {?} */flat.concat(flatItem)
);
}, []);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _SEPARATOR = '#';
var FACTORY_CLASS_SUFFIX = 'NgFactory';
/**
* Configuration for SystemJsNgModuleLoader.
* token.
*
* \@experimental
* @abstract
*/
var SystemJsNgModuleLoaderConfig = /** @class */function () {
function SystemJsNgModuleLoaderConfig() {}
return SystemJsNgModuleLoaderConfig;
}();
var DEFAULT_CONFIG = {
factoryPathPrefix: '',
factoryPathSuffix: '.ngfactory'
};
/**
* NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
* \@experimental
*/
var SystemJsNgModuleLoader = /** @class */function () {
function SystemJsNgModuleLoader(_compiler, config) {
this._compiler = _compiler;
this._config = config || DEFAULT_CONFIG;
}
/**
* @param {?} path
* @return {?}
*/
SystemJsNgModuleLoader.prototype.load = /**
* @param {?} path
* @return {?}
*/
function (path) {
var /** @type {?} */offlineMode = this._compiler instanceof Compiler;
return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
};
/**
* @param {?} path
* @return {?}
*/
SystemJsNgModuleLoader.prototype.loadAndCompile = /**
* @param {?} path
* @return {?}
*/
function (path) {
var _this = this;
var _a = path.split(_SEPARATOR),
module = _a[0],
exportName = _a[1];
if (exportName === undefined) {
exportName = 'default';
}
return System.import(module).then(function (module) {
return module[exportName];
}).then(function (type) {
return checkNotEmpty(type, module, exportName);
}).then(function (type) {
return _this._compiler.compileModuleAsync(type);
});
};
/**
* @param {?} path
* @return {?}
*/
SystemJsNgModuleLoader.prototype.loadFactory = /**
* @param {?} path
* @return {?}
*/
function (path) {
var _a = path.split(_SEPARATOR),
module = _a[0],
exportName = _a[1];
var /** @type {?} */factoryClassSuffix = FACTORY_CLASS_SUFFIX;
if (exportName === undefined) {
exportName = 'default';
factoryClassSuffix = '';
}
return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix).then(function (module) {
return module[exportName + factoryClassSuffix];
}).then(function (factory) {
return checkNotEmpty(factory, module, exportName);
});
};
SystemJsNgModuleLoader.decorators = [{ type: Injectable }];
/** @nocollapse */
SystemJsNgModuleLoader.ctorParameters = function () {
return [{ type: Compiler }, { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional }] }];
};
return SystemJsNgModuleLoader;
}();
/**
* @param {?} value
* @param {?} modulePath
* @param {?} exportName
* @return {?}
*/
function checkNotEmpty(value, modulePath, exportName) {
if (!value) {
throw new Error("Cannot find '" + exportName + "' in '" + modulePath + "'");
}
return value;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Represents an Embedded Template that can be used to instantiate Embedded Views.
*
* You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
* (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
* the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
* the `TemplateRef` from a Component or a Directive via {\@link Query}.
*
* To instantiate Embedded Views based on a Template, use {\@link ViewContainerRef#
* createEmbeddedView}, which will create the View and attach it to the View Container.
* \@stable
* @abstract
*/
var TemplateRef = /** @class */function () {
function TemplateRef() {}
return TemplateRef;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Represents a container where one or more Views can be attached.
*
* The container can contain two kinds of Views. Host Views, created by instantiating a
* {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
* {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
*
* The location of the View Container within the containing View is specified by the Anchor
* `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
* have a single View Container.
*
* Root elements of Views attached to this container become siblings of the Anchor Element in
* the Rendered View.
*
* To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
* with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
* \@stable
* @abstract
*/
var ViewContainerRef = /** @class */function () {
function ViewContainerRef() {}
return ViewContainerRef;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@stable
* @abstract
*/
var ChangeDetectorRef = /** @class */function () {
function ChangeDetectorRef() {}
return ChangeDetectorRef;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@stable
* @abstract
*/
var ViewRef = /** @class */function (_super) {
__extends(ViewRef, _super);
function ViewRef() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ViewRef;
}(ChangeDetectorRef);
/**
* Represents an Angular View.
*
* <!-- TODO: move the next two paragraphs to the dev guide -->
* A View is a fundamental building block of the application UI. It is the smallest grouping of
* Elements which are created and destroyed together.
*
* Properties of elements in a View can change, but the structure (number and order) of elements in
* a View cannot. Changing the structure of Elements can only be done by inserting, moving or
* removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
* <!-- /TODO -->
*
* ### Example
*
* Given this template...
*
* ```
* Count: {{items.length}}
* <ul>
* <li *ngFor="let item of items">{{item}}</li>
* </ul>
* ```
*
* We have two {\@link TemplateRef}s:
*
* Outer {\@link TemplateRef}:
* ```
* Count: {{items.length}}
* <ul>
* <ng-template ngFor let-item [ngForOf]="items"></ng-template>
* </ul>
* ```
*
* Inner {\@link TemplateRef}:
* ```
* <li>{{item}}</li>
* ```
*
* Notice that the original template is broken down into two separate {\@link TemplateRef}s.
*
* The outer/inner {\@link TemplateRef}s are then assembled into views like so:
*
* ```
* <!-- ViewRef: outer-0 -->
* Count: 2
* <ul>
* <ng-template view-container-ref></ng-template>
* <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
* <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
* </ul>
* <!-- /ViewRef: outer-0 -->
* ```
* \@experimental
* @abstract
*/
var EmbeddedViewRef = /** @class */function (_super) {
__extends(EmbeddedViewRef, _super);
function EmbeddedViewRef() {
return _super !== null && _super.apply(this, arguments) || this;
}
return EmbeddedViewRef;
}(ViewRef);
/**
* @record
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Public API for compiler
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var EventListener = /** @class */function () {
function EventListener(name, callback) {
this.name = name;
this.callback = callback;
}
return EventListener;
}();
/**
* \@experimental All debugging apis are currently experimental.
*/
var DebugNode = /** @class */function () {
function DebugNode(nativeNode, parent, _debugContext) {
this._debugContext = _debugContext;
this.nativeNode = nativeNode;
if (parent && parent instanceof DebugElement) {
parent.addChild(this);
} else {
this.parent = null;
}
this.listeners = [];
}
Object.defineProperty(DebugNode.prototype, "injector", {
get: /**
* @return {?}
*/
function () {
return this._debugContext.injector;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugNode.prototype, "componentInstance", {
get: /**
* @return {?}
*/
function () {
return this._debugContext.component;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugNode.prototype, "context", {
get: /**
* @return {?}
*/
function () {
return this._debugContext.context;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugNode.prototype, "references", {
get: /**
* @return {?}
*/
function () {
return this._debugContext.references;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugNode.prototype, "providerTokens", {
get: /**
* @return {?}
*/
function () {
return this._debugContext.providerTokens;
},
enumerable: true,
configurable: true
});
return DebugNode;
}();
/**
* \@experimental All debugging apis are currently experimental.
*/
var DebugElement = /** @class */function (_super) {
__extends(DebugElement, _super);
function DebugElement(nativeNode, parent, _debugContext) {
var _this = _super.call(this, nativeNode, parent, _debugContext) || this;
_this.properties = {};
_this.attributes = {};
_this.classes = {};
_this.styles = {};
_this.childNodes = [];
_this.nativeElement = nativeNode;
return _this;
}
/**
* @param {?} child
* @return {?}
*/
DebugElement.prototype.addChild = /**
* @param {?} child
* @return {?}
*/
function (child) {
if (child) {
this.childNodes.push(child);
child.parent = this;
}
};
/**
* @param {?} child
* @return {?}
*/
DebugElement.prototype.removeChild = /**
* @param {?} child
* @return {?}
*/
function (child) {
var /** @type {?} */childIndex = this.childNodes.indexOf(child);
if (childIndex !== -1) {
child.parent = null;
this.childNodes.splice(childIndex, 1);
}
};
/**
* @param {?} child
* @param {?} newChildren
* @return {?}
*/
DebugElement.prototype.insertChildrenAfter = /**
* @param {?} child
* @param {?} newChildren
* @return {?}
*/
function (child, newChildren) {
var _this = this;
var /** @type {?} */siblingIndex = this.childNodes.indexOf(child);
if (siblingIndex !== -1) {
(_a = this.childNodes).splice.apply(_a, [siblingIndex + 1, 0].concat(newChildren));
newChildren.forEach(function (c) {
if (c.parent) {
c.parent.removeChild(c);
}
c.parent = _this;
});
}
var _a;
};
/**
* @param {?} refChild
* @param {?} newChild
* @return {?}
*/
DebugElement.prototype.insertBefore = /**
* @param {?} refChild
* @param {?} newChild
* @return {?}
*/
function (refChild, newChild) {
var /** @type {?} */refIndex = this.childNodes.indexOf(refChild);
if (refIndex === -1) {
this.addChild(newChild);
} else {
if (newChild.parent) {
newChild.parent.removeChild(newChild);
}
newChild.parent = this;
this.childNodes.splice(refIndex, 0, newChild);
}
};
/**
* @param {?} predicate
* @return {?}
*/
DebugElement.prototype.query = /**
* @param {?} predicate
* @return {?}
*/
function (predicate) {
var /** @type {?} */results = this.queryAll(predicate);
return results[0] || null;
};
/**
* @param {?} predicate
* @return {?}
*/
DebugElement.prototype.queryAll = /**
* @param {?} predicate
* @return {?}
*/
function (predicate) {
var /** @type {?} */matches = [];
_queryElementChildren(this, predicate, matches);
return matches;
};
/**
* @param {?} predicate
* @return {?}
*/
DebugElement.prototype.queryAllNodes = /**
* @param {?} predicate
* @return {?}
*/
function (predicate) {
var /** @type {?} */matches = [];
_queryNodeChildren(this, predicate, matches);
return matches;
};
Object.defineProperty(DebugElement.prototype, "children", {
get: /**
* @return {?}
*/
function () {
return (/** @type {?} */this.childNodes.filter(function (node) {
return node instanceof DebugElement;
})
);
},
enumerable: true,
configurable: true
});
/**
* @param {?} eventName
* @param {?} eventObj
* @return {?}
*/
DebugElement.prototype.triggerEventHandler = /**
* @param {?} eventName
* @param {?} eventObj
* @return {?}
*/
function (eventName, eventObj) {
this.listeners.forEach(function (listener) {
if (listener.name == eventName) {
listener.callback(eventObj);
}
});
};
return DebugElement;
}(DebugNode);
/**
* \@experimental
* @param {?} debugEls
* @return {?}
*/
function asNativeElements(debugEls) {
return debugEls.map(function (el) {
return el.nativeElement;
});
}
/**
* @param {?} element
* @param {?} predicate
* @param {?} matches
* @return {?}
*/
function _queryElementChildren(element, predicate, matches) {
element.childNodes.forEach(function (node) {
if (node instanceof DebugElement) {
if (predicate(node)) {
matches.push(node);
}
_queryElementChildren(node, predicate, matches);
}
});
}
/**
* @param {?} parentNode
* @param {?} predicate
* @param {?} matches
* @return {?}
*/
function _queryNodeChildren(parentNode, predicate, matches) {
if (parentNode instanceof DebugElement) {
parentNode.childNodes.forEach(function (node) {
if (predicate(node)) {
matches.push(node);
}
if (node instanceof DebugElement) {
_queryNodeChildren(node, predicate, matches);
}
});
}
}
// Need to keep the nodes in a global Map so that multiple angular apps are supported.
var _nativeNodeToDebugNode = new Map();
/**
* \@experimental
* @param {?} nativeNode
* @return {?}
*/
function getDebugNode(nativeNode) {
return _nativeNodeToDebugNode.get(nativeNode) || null;
}
/**
* @return {?}
*/
/**
* @param {?} node
* @return {?}
*/
function indexDebugNode(node) {
_nativeNodeToDebugNode.set(node.nativeNode, node);
}
/**
* @param {?} node
* @return {?}
*/
function removeDebugNodeFromIndex(node) {
_nativeNodeToDebugNode.delete(node.nativeNode);
}
/**
* A boolean-valued function over a value, possibly including context information
* regarding that value's position in an array.
*
* \@experimental All debugging apis are currently experimental.
* @record
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function devModeEqual(a, b) {
var /** @type {?} */isListLikeIterableA = isListLikeIterable(a);
var /** @type {?} */isListLikeIterableB = isListLikeIterable(b);
if (isListLikeIterableA && isListLikeIterableB) {
return areIterablesEqual(a, b, devModeEqual);
} else {
var /** @type {?} */isAObject = a && (typeof a === 'object' || typeof a === 'function');
var /** @type {?} */isBObject = b && (typeof b === 'object' || typeof b === 'function');
if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
return true;
} else {
return looseIdentical(a, b);
}
}
}
/**
* Indicates that the result of a {\@link Pipe} transformation has changed even though the
* reference
* has not changed.
*
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
*
* Example:
*
* ```
* if (this._latestValue === this._latestReturnedValue) {
* return this._latestReturnedValue;
* } else {
* this._latestReturnedValue = this._latestValue;
* return WrappedValue.wrap(this._latestValue); // this will force update
* }
* ```
* \@stable
*/
var WrappedValue = /** @class */function () {
function WrappedValue(wrapped) {
this.wrapped = wrapped;
}
/**
* @param {?} value
* @return {?}
*/
WrappedValue.wrap = /**
* @param {?} value
* @return {?}
*/
function (value) {
return new WrappedValue(value);
};
return WrappedValue;
}();
/**
* Helper class for unwrapping WrappedValue s
*/
var ValueUnwrapper = /** @class */function () {
function ValueUnwrapper() {
this.hasWrappedValue = false;
}
/**
* @param {?} value
* @return {?}
*/
ValueUnwrapper.prototype.unwrap = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value instanceof WrappedValue) {
this.hasWrappedValue = true;
return value.wrapped;
}
return value;
};
/**
* @return {?}
*/
ValueUnwrapper.prototype.reset = /**
* @return {?}
*/
function () {
this.hasWrappedValue = false;
};
return ValueUnwrapper;
}();
/**
* Represents a basic change from a previous to a new value.
* \@stable
*/
var SimpleChange = /** @class */function () {
function SimpleChange(previousValue, currentValue, firstChange) {
this.previousValue = previousValue;
this.currentValue = currentValue;
this.firstChange = firstChange;
}
/**
* Check whether the new value is the first value assigned.
*/
/**
* Check whether the new value is the first value assigned.
* @return {?}
*/
SimpleChange.prototype.isFirstChange = /**
* Check whether the new value is the first value assigned.
* @return {?}
*/
function () {
return this.firstChange;
};
return SimpleChange;
}();
/**
* @param {?} obj
* @return {?}
*/
function isListLikeIterable(obj) {
if (!isJsObject(obj)) return false;
return Array.isArray(obj) || !(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
// JS Map are iterables but return entries as [k, v]
getSymbolIterator() in obj; // JS Iterable have a Symbol.iterator prop
}
/**
* @param {?} a
* @param {?} b
* @param {?} comparator
* @return {?}
*/
function areIterablesEqual(a, b, comparator) {
var /** @type {?} */iterator1 = a[getSymbolIterator()]();
var /** @type {?} */iterator2 = b[getSymbolIterator()]();
while (true) {
var /** @type {?} */item1 = iterator1.next();
var /** @type {?} */item2 = iterator2.next();
if (item1.done && item2.done) return true;
if (item1.done || item2.done) return false;
if (!comparator(item1.value, item2.value)) return false;
}
}
/**
* @param {?} obj
* @param {?} fn
* @return {?}
*/
function iterateListLike(obj, fn) {
if (Array.isArray(obj)) {
for (var /** @type {?} */i = 0; i < obj.length; i++) {
fn(obj[i]);
}
} else {
var /** @type {?} */iterator = obj[getSymbolIterator()]();
var /** @type {?} */item = void 0;
while (!(item = iterator.next()).done) {
fn(item.value);
}
}
}
/**
* @param {?} o
* @return {?}
*/
function isJsObject(o) {
return o !== null && (typeof o === 'function' || typeof o === 'object');
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var DefaultIterableDifferFactory = /** @class */function () {
function DefaultIterableDifferFactory() {}
/**
* @param {?} obj
* @return {?}
*/
DefaultIterableDifferFactory.prototype.supports = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
return isListLikeIterable(obj);
};
/**
* @template V
* @param {?=} trackByFn
* @return {?}
*/
DefaultIterableDifferFactory.prototype.create = /**
* @template V
* @param {?=} trackByFn
* @return {?}
*/
function (trackByFn) {
return new DefaultIterableDiffer(trackByFn);
};
return DefaultIterableDifferFactory;
}();
var trackByIdentity = function (index, item) {
return item;
};
/**
* @deprecated v4.0.0 - Should not be part of public API.
*/
var DefaultIterableDiffer = /** @class */function () {
function DefaultIterableDiffer(trackByFn) {
this.length = 0;
this._linkedRecords = null;
this._unlinkedRecords = null;
this._previousItHead = null;
this._itHead = null;
this._itTail = null;
this._additionsHead = null;
this._additionsTail = null;
this._movesHead = null;
this._movesTail = null;
this._removalsHead = null;
this._removalsTail = null;
this._identityChangesHead = null;
this._identityChangesTail = null;
this._trackByFn = trackByFn || trackByIdentity;
}
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._itHead; record !== null; record = record._next) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachOperation = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */nextIt = this._itHead;
var /** @type {?} */nextRemove = this._removalsHead;
var /** @type {?} */addRemoveOffset = 0;
var /** @type {?} */moveOffsets = null;
while (nextIt || nextRemove) {
// Figure out which is the next record to process
// Order: remove, add, move
var /** @type {?} */record = !nextRemove || nextIt && /** @type {?} */nextIt.currentIndex < getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? /** @type {?} */
nextIt : nextRemove;
var /** @type {?} */adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
var /** @type {?} */currentIndex = record.currentIndex;
// consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
if (record === nextRemove) {
addRemoveOffset--;
nextRemove = nextRemove._nextRemoved;
} else {
nextIt = /** @type {?} */nextIt._next;
if (record.previousIndex == null) {
addRemoveOffset++;
} else {
// INVARIANT: currentIndex < previousIndex
if (!moveOffsets) moveOffsets = [];
var /** @type {?} */localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
var /** @type {?} */localCurrentIndex = /** @type {?} */currentIndex - addRemoveOffset;
if (localMovePreviousIndex != localCurrentIndex) {
for (var /** @type {?} */i = 0; i < localMovePreviousIndex; i++) {
var /** @type {?} */offset = i < moveOffsets.length ? moveOffsets[i] : moveOffsets[i] = 0;
var /** @type {?} */index = offset + i;
if (localCurrentIndex <= index && index < localMovePreviousIndex) {
moveOffsets[i] = offset + 1;
}
}
var /** @type {?} */previousIndex = record.previousIndex;
moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
}
}
}
if (adjPreviousIndex !== currentIndex) {
fn(record, adjPreviousIndex, currentIndex);
}
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachPreviousItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachAddedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachMovedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._movesHead; record !== null; record = record._nextMoved) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachRemovedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultIterableDiffer.prototype.forEachIdentityChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
fn(record);
}
};
/**
* @param {?} collection
* @return {?}
*/
DefaultIterableDiffer.prototype.diff = /**
* @param {?} collection
* @return {?}
*/
function (collection) {
if (collection == null) collection = [];
if (!isListLikeIterable(collection)) {
throw new Error("Error trying to diff '" + stringify(collection) + "'. Only arrays and iterables are allowed");
}
if (this.check(collection)) {
return this;
} else {
return null;
}
};
/**
* @return {?}
*/
DefaultIterableDiffer.prototype.onDestroy = /**
* @return {?}
*/
function () {};
/**
* @param {?} collection
* @return {?}
*/
DefaultIterableDiffer.prototype.check = /**
* @param {?} collection
* @return {?}
*/
function (collection) {
var _this = this;
this._reset();
var /** @type {?} */record = this._itHead;
var /** @type {?} */mayBeDirty = false;
var /** @type {?} */index;
var /** @type {?} */item;
var /** @type {?} */itemTrackBy;
if (Array.isArray(collection)) {
/** @type {?} */this.length = collection.length;
for (var /** @type {?} */index_1 = 0; index_1 < this.length; index_1++) {
item = collection[index_1];
itemTrackBy = this._trackByFn(index_1, item);
if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
record = this._mismatch(record, item, itemTrackBy, index_1);
mayBeDirty = true;
} else {
if (mayBeDirty) {
// TODO(misko): can we limit this to duplicates only?
record = this._verifyReinsertion(record, item, itemTrackBy, index_1);
}
if (!looseIdentical(record.item, item)) this._addIdentityChange(record, item);
}
record = record._next;
}
} else {
index = 0;
iterateListLike(collection, function (item) {
itemTrackBy = _this._trackByFn(index, item);
if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
record = _this._mismatch(record, item, itemTrackBy, index);
mayBeDirty = true;
} else {
if (mayBeDirty) {
// TODO(misko): can we limit this to duplicates only?
record = _this._verifyReinsertion(record, item, itemTrackBy, index);
}
if (!looseIdentical(record.item, item)) _this._addIdentityChange(record, item);
}
record = record._next;
index++;
});
/** @type {?} */this.length = index;
}
this._truncate(record);
/** @type {?} */this.collection = collection;
return this.isDirty;
};
Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
/* CollectionChanges is considered dirty if it has any additions, moves, removals, or identity
* changes.
*/
get: /**
* @return {?}
*/
function () {
return this._additionsHead !== null || this._movesHead !== null || this._removalsHead !== null || this._identityChangesHead !== null;
},
enumerable: true,
configurable: true
});
/**
* Reset the state of the change objects to show no changes. This means set previousKey to
* currentKey, and clear all of the queues (additions, moves, removals).
* Set the previousIndexes of moved and added items to their currentIndexes
* Reset the list of additions, moves and removals
*
* @internal
*/
/**
* Reset the state of the change objects to show no changes. This means set previousKey to
* currentKey, and clear all of the queues (additions, moves, removals).
* Set the previousIndexes of moved and added items to their currentIndexes
* Reset the list of additions, moves and removals
*
* \@internal
* @return {?}
*/
DefaultIterableDiffer.prototype._reset = /**
* Reset the state of the change objects to show no changes. This means set previousKey to
* currentKey, and clear all of the queues (additions, moves, removals).
* Set the previousIndexes of moved and added items to their currentIndexes
* Reset the list of additions, moves and removals
*
* \@internal
* @return {?}
*/
function () {
if (this.isDirty) {
var /** @type {?} */record = void 0;
var /** @type {?} */nextRecord = void 0;
for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
record._nextPrevious = record._next;
}
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
record.previousIndex = record.currentIndex;
}
this._additionsHead = this._additionsTail = null;
for (record = this._movesHead; record !== null; record = nextRecord) {
record.previousIndex = record.currentIndex;
nextRecord = record._nextMoved;
}
this._movesHead = this._movesTail = null;
this._removalsHead = this._removalsTail = null;
this._identityChangesHead = this._identityChangesTail = null;
// todo(vicb) when assert gets supported
// assert(!this.isDirty);
}
};
/**
* This is the core function which handles differences between collections.
*
* - `record` is the record which we saw at this position last time. If null then it is a new
* item.
* - `item` is the current item in the collection
* - `index` is the position of the item in the collection
*
* @internal
*/
/**
* This is the core function which handles differences between collections.
*
* - `record` is the record which we saw at this position last time. If null then it is a new
* item.
* - `item` is the current item in the collection
* - `index` is the position of the item in the collection
*
* \@internal
* @param {?} record
* @param {?} item
* @param {?} itemTrackBy
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._mismatch = /**
* This is the core function which handles differences between collections.
*
* - `record` is the record which we saw at this position last time. If null then it is a new
* item.
* - `item` is the current item in the collection
* - `index` is the position of the item in the collection
*
* \@internal
* @param {?} record
* @param {?} item
* @param {?} itemTrackBy
* @param {?} index
* @return {?}
*/
function (record, item, itemTrackBy, index) {
// The previous record after which we will append the current one.
var /** @type {?} */previousRecord;
if (record === null) {
previousRecord = this._itTail;
} else {
previousRecord = record._prev;
// Remove the record from the collection since we know it does not match the item.
this._remove(record);
}
// Attempt to see if we have seen the item before.
record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
if (record !== null) {
// We have seen this before, we need to move it forward in the collection.
// But first we need to check if identity changed, so we can update in view if necessary
if (!looseIdentical(record.item, item)) this._addIdentityChange(record, item);
this._moveAfter(record, previousRecord, index);
} else {
// Never seen it, check evicted list.
record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
if (record !== null) {
// It is an item which we have evicted earlier: reinsert it back into the list.
// But first we need to check if identity changed, so we can update in view if necessary
if (!looseIdentical(record.item, item)) this._addIdentityChange(record, item);
this._reinsertAfter(record, previousRecord, index);
} else {
// It is a new item: add it.
record = this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
}
}
return record;
};
/**
* This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
*
* Use case: `[a, a]` => `[b, a, a]`
*
* If we did not have this check then the insertion of `b` would:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) leave `a` at index `1` as is. <-- this is wrong!
* 3) reinsert `a` at index 2. <-- this is wrong!
*
* The correct behavior is:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) reinsert `a` at index 1.
* 3) move `a` at from `1` to `2`.
*
*
* Double check that we have not evicted a duplicate item. We need to check if the item type may
* have already been removed:
* The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
* at the end.
*
* @internal
*/
/**
* This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
*
* Use case: `[a, a]` => `[b, a, a]`
*
* If we did not have this check then the insertion of `b` would:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) leave `a` at index `1` as is. <-- this is wrong!
* 3) reinsert `a` at index 2. <-- this is wrong!
*
* The correct behavior is:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) reinsert `a` at index 1.
* 3) move `a` at from `1` to `2`.
*
*
* Double check that we have not evicted a duplicate item. We need to check if the item type may
* have already been removed:
* The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
* at the end.
*
* \@internal
* @param {?} record
* @param {?} item
* @param {?} itemTrackBy
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._verifyReinsertion = /**
* This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
*
* Use case: `[a, a]` => `[b, a, a]`
*
* If we did not have this check then the insertion of `b` would:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) leave `a` at index `1` as is. <-- this is wrong!
* 3) reinsert `a` at index 2. <-- this is wrong!
*
* The correct behavior is:
* 1) evict first `a`
* 2) insert `b` at `0` index.
* 3) reinsert `a` at index 1.
* 3) move `a` at from `1` to `2`.
*
*
* Double check that we have not evicted a duplicate item. We need to check if the item type may
* have already been removed:
* The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
* at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
* better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
* at the end.
*
* \@internal
* @param {?} record
* @param {?} item
* @param {?} itemTrackBy
* @param {?} index
* @return {?}
*/
function (record, item, itemTrackBy, index) {
var /** @type {?} */reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
if (reinsertRecord !== null) {
record = this._reinsertAfter(reinsertRecord, /** @type {?} */record._prev, index);
} else if (record.currentIndex != index) {
record.currentIndex = index;
this._addToMoves(record, index);
}
return record;
};
/**
* Get rid of any excess {@link IterableChangeRecord_}s from the previous collection
*
* - `record` The first excess {@link IterableChangeRecord_}.
*
* @internal
*/
/**
* Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
*
* - `record` The first excess {\@link IterableChangeRecord_}.
*
* \@internal
* @param {?} record
* @return {?}
*/
DefaultIterableDiffer.prototype._truncate = /**
* Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
*
* - `record` The first excess {\@link IterableChangeRecord_}.
*
* \@internal
* @param {?} record
* @return {?}
*/
function (record) {
// Anything after that needs to be removed;
while (record !== null) {
var /** @type {?} */nextRecord = record._next;
this._addToRemovals(this._unlink(record));
record = nextRecord;
}
if (this._unlinkedRecords !== null) {
this._unlinkedRecords.clear();
}
if (this._additionsTail !== null) {
this._additionsTail._nextAdded = null;
}
if (this._movesTail !== null) {
this._movesTail._nextMoved = null;
}
if (this._itTail !== null) {
this._itTail._next = null;
}
if (this._removalsTail !== null) {
this._removalsTail._nextRemoved = null;
}
if (this._identityChangesTail !== null) {
this._identityChangesTail._nextIdentityChange = null;
}
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._reinsertAfter = /**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
function (record, prevRecord, index) {
if (this._unlinkedRecords !== null) {
this._unlinkedRecords.remove(record);
}
var /** @type {?} */prev = record._prevRemoved;
var /** @type {?} */next = record._nextRemoved;
if (prev === null) {
this._removalsHead = next;
} else {
prev._nextRemoved = next;
}
if (next === null) {
this._removalsTail = prev;
} else {
next._prevRemoved = prev;
}
this._insertAfter(record, prevRecord, index);
this._addToMoves(record, index);
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._moveAfter = /**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
function (record, prevRecord, index) {
this._unlink(record);
this._insertAfter(record, prevRecord, index);
this._addToMoves(record, index);
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._addAfter = /**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
function (record, prevRecord, index) {
this._insertAfter(record, prevRecord, index);
if (this._additionsTail === null) {
// todo(vicb)
// assert(this._additionsHead === null);
this._additionsTail = this._additionsHead = record;
} else {
// todo(vicb)
// assert(_additionsTail._nextAdded === null);
// assert(record._nextAdded === null);
this._additionsTail = this._additionsTail._nextAdded = record;
}
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
DefaultIterableDiffer.prototype._insertAfter = /**
* \@internal
* @param {?} record
* @param {?} prevRecord
* @param {?} index
* @return {?}
*/
function (record, prevRecord, index) {
// todo(vicb)
// assert(record != prevRecord);
// assert(record._next === null);
// assert(record._prev === null);
var /** @type {?} */next = prevRecord === null ? this._itHead : prevRecord._next;
// todo(vicb)
// assert(next != record);
// assert(prevRecord != record);
record._next = next;
record._prev = prevRecord;
if (next === null) {
this._itTail = record;
} else {
next._prev = record;
}
if (prevRecord === null) {
this._itHead = record;
} else {
prevRecord._next = record;
}
if (this._linkedRecords === null) {
this._linkedRecords = new _DuplicateMap();
}
this._linkedRecords.put(record);
record.currentIndex = index;
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @return {?}
*/
DefaultIterableDiffer.prototype._remove = /**
* \@internal
* @param {?} record
* @return {?}
*/
function (record) {
return this._addToRemovals(this._unlink(record));
};
/** @internal */
/**
* \@internal
* @param {?} record
* @return {?}
*/
DefaultIterableDiffer.prototype._unlink = /**
* \@internal
* @param {?} record
* @return {?}
*/
function (record) {
if (this._linkedRecords !== null) {
this._linkedRecords.remove(record);
}
var /** @type {?} */prev = record._prev;
var /** @type {?} */next = record._next;
// todo(vicb)
// assert((record._prev = null) === null);
// assert((record._next = null) === null);
if (prev === null) {
this._itHead = next;
} else {
prev._next = next;
}
if (next === null) {
this._itTail = prev;
} else {
next._prev = prev;
}
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} toIndex
* @return {?}
*/
DefaultIterableDiffer.prototype._addToMoves = /**
* \@internal
* @param {?} record
* @param {?} toIndex
* @return {?}
*/
function (record, toIndex) {
// todo(vicb)
// assert(record._nextMoved === null);
if (record.previousIndex === toIndex) {
return record;
}
if (this._movesTail === null) {
// todo(vicb)
// assert(_movesHead === null);
this._movesTail = this._movesHead = record;
} else {
// todo(vicb)
// assert(_movesTail._nextMoved === null);
this._movesTail = this._movesTail._nextMoved = record;
}
return record;
};
/**
* @param {?} record
* @return {?}
*/
DefaultIterableDiffer.prototype._addToRemovals = /**
* @param {?} record
* @return {?}
*/
function (record) {
if (this._unlinkedRecords === null) {
this._unlinkedRecords = new _DuplicateMap();
}
this._unlinkedRecords.put(record);
record.currentIndex = null;
record._nextRemoved = null;
if (this._removalsTail === null) {
// todo(vicb)
// assert(_removalsHead === null);
this._removalsTail = this._removalsHead = record;
record._prevRemoved = null;
} else {
// todo(vicb)
// assert(_removalsTail._nextRemoved === null);
// assert(record._nextRemoved === null);
record._prevRemoved = this._removalsTail;
this._removalsTail = this._removalsTail._nextRemoved = record;
}
return record;
};
/** @internal */
/**
* \@internal
* @param {?} record
* @param {?} item
* @return {?}
*/
DefaultIterableDiffer.prototype._addIdentityChange = /**
* \@internal
* @param {?} record
* @param {?} item
* @return {?}
*/
function (record, item) {
record.item = item;
if (this._identityChangesTail === null) {
this._identityChangesTail = this._identityChangesHead = record;
} else {
this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
}
return record;
};
return DefaultIterableDiffer;
}();
/**
* \@stable
*/
var IterableChangeRecord_ = /** @class */function () {
function IterableChangeRecord_(item, trackById) {
this.item = item;
this.trackById = trackById;
this.currentIndex = null;
this.previousIndex = null;
/**
* \@internal
*/
this._nextPrevious = null;
/**
* \@internal
*/
this._prev = null;
/**
* \@internal
*/
this._next = null;
/**
* \@internal
*/
this._prevDup = null;
/**
* \@internal
*/
this._nextDup = null;
/**
* \@internal
*/
this._prevRemoved = null;
/**
* \@internal
*/
this._nextRemoved = null;
/**
* \@internal
*/
this._nextAdded = null;
/**
* \@internal
*/
this._nextMoved = null;
/**
* \@internal
*/
this._nextIdentityChange = null;
}
return IterableChangeRecord_;
}();
var _DuplicateItemRecordList = /** @class */function () {
function _DuplicateItemRecordList() {
/**
* \@internal
*/
this._head = null;
/**
* \@internal
*/
this._tail = null;
}
/**
* Append the record to the list of duplicates.
*
* Note: by design all records in the list of duplicates hold the same value in record.item.
*/
/**
* Append the record to the list of duplicates.
*
* Note: by design all records in the list of duplicates hold the same value in record.item.
* @param {?} record
* @return {?}
*/
_DuplicateItemRecordList.prototype.add = /**
* Append the record to the list of duplicates.
*
* Note: by design all records in the list of duplicates hold the same value in record.item.
* @param {?} record
* @return {?}
*/
function (record) {
if (this._head === null) {
this._head = this._tail = record;
record._nextDup = null;
record._prevDup = null;
} else {
/** @type {?} */
// todo(vicb)
// assert(record.item == _head.item ||
// record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
this._tail._nextDup = record;
record._prevDup = this._tail;
record._nextDup = null;
this._tail = record;
}
};
// Returns a IterableChangeRecord_ having IterableChangeRecord_.trackById == trackById and
// IterableChangeRecord_.currentIndex >= atOrAfterIndex
/**
* @param {?} trackById
* @param {?} atOrAfterIndex
* @return {?}
*/
_DuplicateItemRecordList.prototype.get = /**
* @param {?} trackById
* @param {?} atOrAfterIndex
* @return {?}
*/
function (trackById, atOrAfterIndex) {
var /** @type {?} */record;
for (record = this._head; record !== null; record = record._nextDup) {
if ((atOrAfterIndex === null || atOrAfterIndex <= /** @type {?} */record.currentIndex) && looseIdentical(record.trackById, trackById)) {
return record;
}
}
return null;
};
/**
* Remove one {@link IterableChangeRecord_} from the list of duplicates.
*
* Returns whether the list of duplicates is empty.
*/
/**
* Remove one {\@link IterableChangeRecord_} from the list of duplicates.
*
* Returns whether the list of duplicates is empty.
* @param {?} record
* @return {?}
*/
_DuplicateItemRecordList.prototype.remove = /**
* Remove one {\@link IterableChangeRecord_} from the list of duplicates.
*
* Returns whether the list of duplicates is empty.
* @param {?} record
* @return {?}
*/
function (record) {
// todo(vicb)
// assert(() {
// // verify that the record being removed is in the list.
// for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
// if (identical(cursor, record)) return true;
// }
// return false;
//});
var /** @type {?} */prev = record._prevDup;
var /** @type {?} */next = record._nextDup;
if (prev === null) {
this._head = next;
} else {
prev._nextDup = next;
}
if (next === null) {
this._tail = prev;
} else {
next._prevDup = prev;
}
return this._head === null;
};
return _DuplicateItemRecordList;
}();
var _DuplicateMap = /** @class */function () {
function _DuplicateMap() {
this.map = new Map();
}
/**
* @param {?} record
* @return {?}
*/
_DuplicateMap.prototype.put = /**
* @param {?} record
* @return {?}
*/
function (record) {
var /** @type {?} */key = record.trackById;
var /** @type {?} */duplicates = this.map.get(key);
if (!duplicates) {
duplicates = new _DuplicateItemRecordList();
this.map.set(key, duplicates);
}
duplicates.add(record);
};
/**
* Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
* have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
*
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
* have any more `a`s needs to return the second `a`.
*/
/**
* Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
* have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
*
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
* have any more `a`s needs to return the second `a`.
* @param {?} trackById
* @param {?} atOrAfterIndex
* @return {?}
*/
_DuplicateMap.prototype.get = /**
* Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
* have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
*
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
* have any more `a`s needs to return the second `a`.
* @param {?} trackById
* @param {?} atOrAfterIndex
* @return {?}
*/
function (trackById, atOrAfterIndex) {
var /** @type {?} */key = trackById;
var /** @type {?} */recordList = this.map.get(key);
return recordList ? recordList.get(trackById, atOrAfterIndex) : null;
};
/**
* Removes a {@link IterableChangeRecord_} from the list of duplicates.
*
* The list of duplicates also is removed from the map if it gets empty.
*/
/**
* Removes a {\@link IterableChangeRecord_} from the list of duplicates.
*
* The list of duplicates also is removed from the map if it gets empty.
* @param {?} record
* @return {?}
*/
_DuplicateMap.prototype.remove = /**
* Removes a {\@link IterableChangeRecord_} from the list of duplicates.
*
* The list of duplicates also is removed from the map if it gets empty.
* @param {?} record
* @return {?}
*/
function (record) {
var /** @type {?} */key = record.trackById;
var /** @type {?} */recordList = /** @type {?} */this.map.get(key);
// Remove the list of duplicates when it gets empty
if (recordList.remove(record)) {
this.map.delete(key);
}
return record;
};
Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
get: /**
* @return {?}
*/
function () {
return this.map.size === 0;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
_DuplicateMap.prototype.clear = /**
* @return {?}
*/
function () {
this.map.clear();
};
return _DuplicateMap;
}();
/**
* @param {?} item
* @param {?} addRemoveOffset
* @param {?} moveOffsets
* @return {?}
*/
function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
var /** @type {?} */previousIndex = item.previousIndex;
if (previousIndex === null) return previousIndex;
var /** @type {?} */moveOffset = 0;
if (moveOffsets && previousIndex < moveOffsets.length) {
moveOffset = moveOffsets[previousIndex];
}
return previousIndex + addRemoveOffset + moveOffset;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var DefaultKeyValueDifferFactory = /** @class */function () {
function DefaultKeyValueDifferFactory() {}
/**
* @param {?} obj
* @return {?}
*/
DefaultKeyValueDifferFactory.prototype.supports = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
return obj instanceof Map || isJsObject(obj);
};
/**
* @template K, V
* @return {?}
*/
DefaultKeyValueDifferFactory.prototype.create = /**
* @template K, V
* @return {?}
*/
function () {
return new DefaultKeyValueDiffer();
};
return DefaultKeyValueDifferFactory;
}();
var DefaultKeyValueDiffer = /** @class */function () {
function DefaultKeyValueDiffer() {
this._records = new Map();
this._mapHead = null;
this._appendAfter = null;
this._previousMapHead = null;
this._changesHead = null;
this._changesTail = null;
this._additionsHead = null;
this._additionsTail = null;
this._removalsHead = null;
this._removalsTail = null;
}
Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
get: /**
* @return {?}
*/
function () {
return this._additionsHead !== null || this._changesHead !== null || this._removalsHead !== null;
},
enumerable: true,
configurable: true
});
/**
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype.forEachItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._mapHead; record !== null; record = record._next) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype.forEachPreviousItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype.forEachChangedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._changesHead; record !== null; record = record._nextChanged) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype.forEachAddedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
fn(record);
}
};
/**
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype.forEachRemovedItem = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
var /** @type {?} */record;
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
fn(record);
}
};
/**
* @param {?=} map
* @return {?}
*/
DefaultKeyValueDiffer.prototype.diff = /**
* @param {?=} map
* @return {?}
*/
function (map) {
if (!map) {
map = new Map();
} else if (!(map instanceof Map || isJsObject(map))) {
throw new Error("Error trying to diff '" + stringify(map) + "'. Only maps and objects are allowed");
}
return this.check(map) ? this : null;
};
/**
* @return {?}
*/
DefaultKeyValueDiffer.prototype.onDestroy = /**
* @return {?}
*/
function () {};
/**
* Check the current state of the map vs the previous.
* The algorithm is optimised for when the keys do no change.
*/
/**
* Check the current state of the map vs the previous.
* The algorithm is optimised for when the keys do no change.
* @param {?} map
* @return {?}
*/
DefaultKeyValueDiffer.prototype.check = /**
* Check the current state of the map vs the previous.
* The algorithm is optimised for when the keys do no change.
* @param {?} map
* @return {?}
*/
function (map) {
var _this = this;
this._reset();
var /** @type {?} */insertBefore = this._mapHead;
this._appendAfter = null;
this._forEach(map, function (value, key) {
if (insertBefore && insertBefore.key === key) {
_this._maybeAddToChanges(insertBefore, value);
_this._appendAfter = insertBefore;
insertBefore = insertBefore._next;
} else {
var /** @type {?} */record = _this._getOrCreateRecordForKey(key, value);
insertBefore = _this._insertBeforeOrAppend(insertBefore, record);
}
});
// Items remaining at the end of the list have been deleted
if (insertBefore) {
if (insertBefore._prev) {
insertBefore._prev._next = null;
}
this._removalsHead = insertBefore;
for (var /** @type {?} */record = insertBefore; record !== null; record = record._nextRemoved) {
if (record === this._mapHead) {
this._mapHead = null;
}
this._records.delete(record.key);
record._nextRemoved = record._next;
record.previousValue = record.currentValue;
record.currentValue = null;
record._prev = null;
record._next = null;
}
}
// Make sure tails have no next records from previous runs
if (this._changesTail) this._changesTail._nextChanged = null;
if (this._additionsTail) this._additionsTail._nextAdded = null;
return this.isDirty;
};
/**
* Inserts a record before `before` or append at the end of the list when `before` is null.
*
* Notes:
* - This method appends at `this._appendAfter`,
* - This method updates `this._appendAfter`,
* - The return value is the new value for the insertion pointer.
* @param {?} before
* @param {?} record
* @return {?}
*/
DefaultKeyValueDiffer.prototype._insertBeforeOrAppend = /**
* Inserts a record before `before` or append at the end of the list when `before` is null.
*
* Notes:
* - This method appends at `this._appendAfter`,
* - This method updates `this._appendAfter`,
* - The return value is the new value for the insertion pointer.
* @param {?} before
* @param {?} record
* @return {?}
*/
function (before, record) {
if (before) {
var /** @type {?} */prev = before._prev;
record._next = before;
record._prev = prev;
before._prev = record;
if (prev) {
prev._next = record;
}
if (before === this._mapHead) {
this._mapHead = record;
}
this._appendAfter = before;
return before;
}
if (this._appendAfter) {
this._appendAfter._next = record;
record._prev = this._appendAfter;
} else {
this._mapHead = record;
}
this._appendAfter = record;
return null;
};
/**
* @param {?} key
* @param {?} value
* @return {?}
*/
DefaultKeyValueDiffer.prototype._getOrCreateRecordForKey = /**
* @param {?} key
* @param {?} value
* @return {?}
*/
function (key, value) {
if (this._records.has(key)) {
var /** @type {?} */record_1 = /** @type {?} */this._records.get(key);
this._maybeAddToChanges(record_1, value);
var /** @type {?} */prev = record_1._prev;
var /** @type {?} */next = record_1._next;
if (prev) {
prev._next = next;
}
if (next) {
next._prev = prev;
}
record_1._next = null;
record_1._prev = null;
return record_1;
}
var /** @type {?} */record = new KeyValueChangeRecord_(key);
this._records.set(key, record);
record.currentValue = value;
this._addToAdditions(record);
return record;
};
/** @internal */
/**
* \@internal
* @return {?}
*/
DefaultKeyValueDiffer.prototype._reset = /**
* \@internal
* @return {?}
*/
function () {
if (this.isDirty) {
var /** @type {?} */record = void 0;
// let `_previousMapHead` contain the state of the map before the changes
this._previousMapHead = this._mapHead;
for (record = this._previousMapHead; record !== null; record = record._next) {
record._nextPrevious = record._next;
}
// Update `record.previousValue` with the value of the item before the changes
// We need to update all changed items (that's those which have been added and changed)
for (record = this._changesHead; record !== null; record = record._nextChanged) {
record.previousValue = record.currentValue;
}
for (record = this._additionsHead; record != null; record = record._nextAdded) {
record.previousValue = record.currentValue;
}
this._changesHead = this._changesTail = null;
this._additionsHead = this._additionsTail = null;
this._removalsHead = null;
}
};
/**
* @param {?} record
* @param {?} newValue
* @return {?}
*/
DefaultKeyValueDiffer.prototype._maybeAddToChanges = /**
* @param {?} record
* @param {?} newValue
* @return {?}
*/
function (record, newValue) {
if (!looseIdentical(newValue, record.currentValue)) {
record.previousValue = record.currentValue;
record.currentValue = newValue;
this._addToChanges(record);
}
};
/**
* @param {?} record
* @return {?}
*/
DefaultKeyValueDiffer.prototype._addToAdditions = /**
* @param {?} record
* @return {?}
*/
function (record) {
if (this._additionsHead === null) {
this._additionsHead = this._additionsTail = record;
} else {
/** @type {?} */this._additionsTail._nextAdded = record;
this._additionsTail = record;
}
};
/**
* @param {?} record
* @return {?}
*/
DefaultKeyValueDiffer.prototype._addToChanges = /**
* @param {?} record
* @return {?}
*/
function (record) {
if (this._changesHead === null) {
this._changesHead = this._changesTail = record;
} else {
/** @type {?} */this._changesTail._nextChanged = record;
this._changesTail = record;
}
};
/**
* \@internal
* @template K, V
* @param {?} obj
* @param {?} fn
* @return {?}
*/
DefaultKeyValueDiffer.prototype._forEach = /**
* \@internal
* @template K, V
* @param {?} obj
* @param {?} fn
* @return {?}
*/
function (obj, fn) {
if (obj instanceof Map) {
obj.forEach(fn);
} else {
Object.keys(obj).forEach(function (k) {
return fn(obj[k], k);
});
}
};
return DefaultKeyValueDiffer;
}();
/**
* \@stable
*/
var KeyValueChangeRecord_ = /** @class */function () {
function KeyValueChangeRecord_(key) {
this.key = key;
this.previousValue = null;
this.currentValue = null;
/**
* \@internal
*/
this._nextPrevious = null;
/**
* \@internal
*/
this._next = null;
/**
* \@internal
*/
this._prev = null;
/**
* \@internal
*/
this._nextAdded = null;
/**
* \@internal
*/
this._nextRemoved = null;
/**
* \@internal
*/
this._nextChanged = null;
}
return KeyValueChangeRecord_;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A strategy for tracking changes over time to an iterable. Used by {\@link NgForOf} to
* respond to changes in an iterable by effecting equivalent changes in the DOM.
*
* \@stable
* @record
*/
/**
* An object describing the changes in the `Iterable` collection since last time
* `IterableDiffer#diff()` was invoked.
*
* \@stable
* @record
*/
/**
* Record representing the item change information.
*
* \@stable
* @record
*/
/**
* @deprecated v4.0.0 - Use IterableChangeRecord instead.
* @record
*/
/**
* An optional function passed into {\@link NgForOf} that defines how to track
* items in an iterable (e.g. fby index or id)
*
* \@stable
* @record
*/
/**
* Provides a factory for {\@link IterableDiffer}.
*
* \@stable
* @record
*/
/**
* A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
* \@stable
*/
var IterableDiffers = /** @class */function () {
function IterableDiffers(factories) {
this.factories = factories;
}
/**
* @param {?} factories
* @param {?=} parent
* @return {?}
*/
IterableDiffers.create = /**
* @param {?} factories
* @param {?=} parent
* @return {?}
*/
function (factories, parent) {
if (parent != null) {
var /** @type {?} */copied = parent.factories.slice();
factories = factories.concat(copied);
return new IterableDiffers(factories);
} else {
return new IterableDiffers(factories);
}
};
/**
* Takes an array of {@link IterableDifferFactory} and returns a provider used to extend the
* inherited {@link IterableDiffers} instance with the provided factories and return a new
* {@link IterableDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {@link IterableDiffer} available.
*
* ### Example
*
* ```
* @Component({
* viewProviders: [
* IterableDiffers.extend([new ImmutableListDiffer()])
* ]
* })
* ```
*/
/**
* Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
* inherited {\@link IterableDiffers} instance with the provided factories and return a new
* {\@link IterableDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {\@link IterableDiffer} available.
*
* ### Example
*
* ```
* \@Component({
* viewProviders: [
* IterableDiffers.extend([new ImmutableListDiffer()])
* ]
* })
* ```
* @param {?} factories
* @return {?}
*/
IterableDiffers.extend = /**
* Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
* inherited {\@link IterableDiffers} instance with the provided factories and return a new
* {\@link IterableDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {\@link IterableDiffer} available.
*
* ### Example
*
* ```
* \@Component({
* viewProviders: [
* IterableDiffers.extend([new ImmutableListDiffer()])
* ]
* })
* ```
* @param {?} factories
* @return {?}
*/
function (factories) {
return {
provide: IterableDiffers,
useFactory: function (parent) {
if (!parent) {
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed
// to
// bootstrap(), which would override default pipes instead of extending them.
throw new Error('Cannot extend IterableDiffers without a parent injector');
}
return IterableDiffers.create(factories, parent);
},
// Dependency technically isn't optional, but we can provide a better error message this way.
deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
};
};
/**
* @param {?} iterable
* @return {?}
*/
IterableDiffers.prototype.find = /**
* @param {?} iterable
* @return {?}
*/
function (iterable) {
var /** @type {?} */factory = this.factories.find(function (f) {
return f.supports(iterable);
});
if (factory != null) {
return factory;
} else {
throw new Error("Cannot find a differ supporting object '" + iterable + "' of type '" + getTypeNameForDebugging(iterable) + "'");
}
};
return IterableDiffers;
}();
/**
* @param {?} type
* @return {?}
*/
function getTypeNameForDebugging(type) {
return type['name'] || typeof type;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A differ that tracks changes made to an object over time.
*
* \@stable
* @record
*/
/**
* An object describing the changes in the `Map` or `{[k:string]: string}` since last time
* `KeyValueDiffer#diff()` was invoked.
*
* \@stable
* @record
*/
/**
* Record representing the item change information.
*
* \@stable
* @record
*/
/**
* Provides a factory for {\@link KeyValueDiffer}.
*
* \@stable
* @record
*/
/**
* A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
* \@stable
*/
var KeyValueDiffers = /** @class */function () {
function KeyValueDiffers(factories) {
this.factories = factories;
}
/**
* @template S
* @param {?} factories
* @param {?=} parent
* @return {?}
*/
KeyValueDiffers.create = /**
* @template S
* @param {?} factories
* @param {?=} parent
* @return {?}
*/
function (factories, parent) {
if (parent) {
var /** @type {?} */copied = parent.factories.slice();
factories = factories.concat(copied);
}
return new KeyValueDiffers(factories);
};
/**
* Takes an array of {@link KeyValueDifferFactory} and returns a provider used to extend the
* inherited {@link KeyValueDiffers} instance with the provided factories and return a new
* {@link KeyValueDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {@link KeyValueDiffer} available.
*
* ### Example
*
* ```
* @Component({
* viewProviders: [
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
* ]
* })
* ```
*/
/**
* Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
* inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
* {\@link KeyValueDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {\@link KeyValueDiffer} available.
*
* ### Example
*
* ```
* \@Component({
* viewProviders: [
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
* ]
* })
* ```
* @template S
* @param {?} factories
* @return {?}
*/
KeyValueDiffers.extend = /**
* Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
* inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
* {\@link KeyValueDiffers} instance.
*
* The following example shows how to extend an existing list of factories,
* which will only be applied to the injector for this component and its children.
* This step is all that's required to make a new {\@link KeyValueDiffer} available.
*
* ### Example
*
* ```
* \@Component({
* viewProviders: [
* KeyValueDiffers.extend([new ImmutableMapDiffer()])
* ]
* })
* ```
* @template S
* @param {?} factories
* @return {?}
*/
function (factories) {
return {
provide: KeyValueDiffers,
useFactory: function (parent) {
if (!parent) {
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
// to bootstrap(), which would override default pipes instead of extending them.
throw new Error('Cannot extend KeyValueDiffers without a parent injector');
}
return KeyValueDiffers.create(factories, parent);
},
// Dependency technically isn't optional, but we can provide a better error message this way.
deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
};
};
/**
* @param {?} kv
* @return {?}
*/
KeyValueDiffers.prototype.find = /**
* @param {?} kv
* @return {?}
*/
function (kv) {
var /** @type {?} */factory = this.factories.find(function (f) {
return f.supports(kv);
});
if (factory) {
return factory;
}
throw new Error("Cannot find a differ supporting object '" + kv + "'");
};
return KeyValueDiffers;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Structural diffing for `Object`s and `Map`s.
*/
var keyValDiff = [new DefaultKeyValueDifferFactory()];
/**
* Structural diffing for `Iterable` types such as `Array`s.
*/
var iterableDiff = [new DefaultIterableDifferFactory()];
var defaultIterableDiffers = new IterableDiffers(iterableDiff);
var defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Change detection enables data binding in Angular.
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _CORE_PLATFORM_PROVIDERS = [
// Set a default platform name for platforms that don't set it explicitly.
{ provide: PLATFORM_ID, useValue: 'unknown' }, { provide: PlatformRef, deps: [Injector] }, { provide: TestabilityRegistry, deps: [] }, { provide: Console, deps: [] }];
/**
* This platform has to be included in any other platform
*
* \@experimental
*/
var platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Provide this token to set the locale of your application.
* It is used for i18n extraction, by i18n pipes (DatePipe, I18nPluralPipe, CurrencyPipe,
* DecimalPipe and PercentPipe) and by ICU expressions.
*
* See the {\@linkDocs guide/i18n#setting-up-locale i18n guide} for more information.
*
* ### Example
*
* ```typescript
* import { LOCALE_ID } from '\@angular/core';
* import { platformBrowserDynamic } from '\@angular/platform-browser-dynamic';
* import { AppModule } from './app/app.module';
*
* platformBrowserDynamic().bootstrapModule(AppModule, {
* providers: [{provide: LOCALE_ID, useValue: 'en-US' }]
* });
* ```
*
* \@experimental i18n support is experimental.
*/
var LOCALE_ID = new InjectionToken('LocaleId');
/**
* Use this token at bootstrap to provide the content of your translation file (`xtb`,
* `xlf` or `xlf2`) when you want to translate your application in another language.
*
* See the {\@linkDocs guide/i18n#merge i18n guide} for more information.
*
* ### Example
*
* ```typescript
* import { TRANSLATIONS } from '\@angular/core';
* import { platformBrowserDynamic } from '\@angular/platform-browser-dynamic';
* import { AppModule } from './app/app.module';
*
* // content of your translation file
* const translations = '....';
*
* platformBrowserDynamic().bootstrapModule(AppModule, {
* providers: [{provide: TRANSLATIONS, useValue: translations }]
* });
* ```
*
* \@experimental i18n support is experimental.
*/
var TRANSLATIONS = new InjectionToken('Translations');
/**
* Provide this token at bootstrap to set the format of your {\@link TRANSLATIONS}: `xtb`,
* `xlf` or `xlf2`.
*
* See the {\@linkDocs guide/i18n#merge i18n guide} for more information.
*
* ### Example
*
* ```typescript
* import { TRANSLATIONS_FORMAT } from '\@angular/core';
* import { platformBrowserDynamic } from '\@angular/platform-browser-dynamic';
* import { AppModule } from './app/app.module';
*
* platformBrowserDynamic().bootstrapModule(AppModule, {
* providers: [{provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }]
* });
* ```
*
* \@experimental i18n support is experimental.
*/
var TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
/** @enum {number} */
var MissingTranslationStrategy = {
Error: 0,
Warning: 1,
Ignore: 2
};
MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @return {?}
*/
function _iterableDiffersFactory() {
return defaultIterableDiffers;
}
/**
* @return {?}
*/
function _keyValueDiffersFactory() {
return defaultKeyValueDiffers;
}
/**
* @param {?=} locale
* @return {?}
*/
function _localeFactory(locale) {
return locale || 'en-US';
}
/**
* This module includes the providers of \@angular/core that are needed
* to bootstrap components via `ApplicationRef`.
*
* \@experimental
*/
var ApplicationModule = /** @class */function () {
// Inject ApplicationRef to make it eager...
function ApplicationModule(appRef) {}
ApplicationModule.decorators = [{ type: NgModule, args: [{
providers: [ApplicationRef, ApplicationInitStatus, Compiler, APP_ID_RANDOM_PROVIDER, { provide: IterableDiffers, useFactory: _iterableDiffersFactory }, { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory }, {
provide: LOCALE_ID,
useFactory: _localeFactory,
deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
}]
}] }];
/** @nocollapse */
ApplicationModule.ctorParameters = function () {
return [{ type: ApplicationRef }];
};
return ApplicationModule;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/** @enum {number} */
var SecurityContext = {
NONE: 0,
HTML: 1,
STYLE: 2,
SCRIPT: 3,
URL: 4,
RESOURCE_URL: 5
};
SecurityContext[SecurityContext.NONE] = "NONE";
SecurityContext[SecurityContext.HTML] = "HTML";
SecurityContext[SecurityContext.STYLE] = "STYLE";
SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
SecurityContext[SecurityContext.URL] = "URL";
SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
/**
* Sanitizer is used by the views to sanitize potentially dangerous values.
*
* \@stable
* @abstract
*/
var Sanitizer = /** @class */function () {
function Sanitizer() {}
return Sanitizer;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Factory for ViewDefinitions/NgModuleDefinitions.
* We use a function so we can reexeute it in case an error happens and use the given logger
* function to log the error from the definition of the node, which is shown in all browser
* logs.
* @record
*/
/**
* Function to call console.error at the right source location. This is an indirection
* via another function as browser will log the location that actually called
* `console.error`.
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* A node definition in the view.
*
* Note: We use one type for all nodes so that loops that loop over all nodes
* of a ViewDefinition stay monomorphic!
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* View instance data.
* Attention: Adding fields to this is performance sensitive!
* @record
*/
/**
* @param {?} view
* @param {?} priorInitState
* @param {?} newInitState
* @return {?}
*/
function shiftInitState(view, priorInitState, newInitState) {
// Only update the InitState if we are currently in the prior state.
// For example, only move into CallingInit if we are in BeforeInit. Only
// move into CallingContentInit if we are in CallingInit. Normally this will
// always be true because of how checkCycle is called in checkAndUpdateView.
// However, if checkAndUpdateView is called recursively or if an exception is
// thrown while checkAndUpdateView is running, checkAndUpdateView starts over
// from the beginning. This ensures the state is monotonically increasing,
// terminating in the AfterInit state, which ensures the Init methods are called
// at least once and only once.
var /** @type {?} */state = view.state;
var /** @type {?} */initState = state & 1792;
if (initState === priorInitState) {
view.state = state & ~1792 /* InitState_Mask */ | newInitState;
view.initIndex = -1;
return true;
}
return initState === newInitState;
}
/**
* @param {?} view
* @param {?} initState
* @param {?} index
* @return {?}
*/
function shouldCallLifecycleInitHook(view, initState, index) {
if ((view.state & 1792 /* InitState_Mask */) === initState && view.initIndex <= index) {
view.initIndex = index + 1;
return true;
}
return false;
}
/**
* @record
*/
/**
* Data for an instantiated NodeType.Text.
*
* Attention: Adding fields to this is performance sensitive!
* @record
*/
/**
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
* @param {?} view
* @param {?} index
* @return {?}
*/
function asTextData(view, index) {
return (/** @type {?} */view.nodes[index]
);
}
/**
* Data for an instantiated NodeType.Element.
*
* Attention: Adding fields to this is performance sensitive!
* @record
*/
/**
* @record
*/
/**
* @record
*/
/**
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
* @param {?} view
* @param {?} index
* @return {?}
*/
function asElementData(view, index) {
return (/** @type {?} */view.nodes[index]
);
}
/**
* Data for an instantiated NodeType.Provider.
*
* Attention: Adding fields to this is performance sensitive!
* @record
*/
/**
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
* @param {?} view
* @param {?} index
* @return {?}
*/
function asProviderData(view, index) {
return (/** @type {?} */view.nodes[index]
);
}
/**
* Data for an instantiated NodeType.PureExpression.
*
* Attention: Adding fields to this is performance sensitive!
* @record
*/
/**
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
* @param {?} view
* @param {?} index
* @return {?}
*/
function asPureExpressionData(view, index) {
return (/** @type {?} */view.nodes[index]
);
}
/**
* Accessor for view.nodes, enforcing that every usage site stays monomorphic.
* @param {?} view
* @param {?} index
* @return {?}
*/
function asQueryList(view, index) {
return (/** @type {?} */view.nodes[index]
);
}
/**
* @record
*/
/**
* @abstract
*/
var DebugContext = /** @class */function () {
function DebugContext() {}
return DebugContext;
}();
/**
* @record
*/
/**
* This object is used to prevent cycles in the source files and to have a place where
* debug mode can hook it. It is lazily filled when `isDevMode` is known.
*/
var Services = {
setCurrentNode: /** @type {?} */undefined,
createRootView: /** @type {?} */undefined,
createEmbeddedView: /** @type {?} */undefined,
createComponentView: /** @type {?} */undefined,
createNgModuleRef: /** @type {?} */undefined,
overrideProvider: /** @type {?} */undefined,
overrideComponentView: /** @type {?} */undefined,
clearOverrides: /** @type {?} */undefined,
checkAndUpdateView: /** @type {?} */undefined,
checkNoChangesView: /** @type {?} */undefined,
destroyView: /** @type {?} */undefined,
resolveDep: /** @type {?} */undefined,
createDebugContext: /** @type {?} */undefined,
handleEvent: /** @type {?} */undefined,
updateDirectives: /** @type {?} */undefined,
updateRenderer: /** @type {?} */undefined,
dirtyParentQueries: /** @type {?} */undefined
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} context
* @param {?} oldValue
* @param {?} currValue
* @param {?} isFirstCheck
* @return {?}
*/
function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
var /** @type {?} */msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'.";
if (isFirstCheck) {
msg += " It seems like the view has been created after its parent and its children have been dirty checked." + " Has it been created in a change detection hook ?";
}
return viewDebugError(msg, context);
}
/**
* @param {?} err
* @param {?} context
* @return {?}
*/
function viewWrappedDebugError(err, context) {
if (!(err instanceof Error)) {
// errors that are not Error instances don't have a stack,
// so it is ok to wrap them into a new Error object...
err = new Error(err.toString());
}
_addDebugContext(err, context);
return err;
}
/**
* @param {?} msg
* @param {?} context
* @return {?}
*/
function viewDebugError(msg, context) {
var /** @type {?} */err = new Error(msg);
_addDebugContext(err, context);
return err;
}
/**
* @param {?} err
* @param {?} context
* @return {?}
*/
function _addDebugContext(err, context) {
/** @type {?} */err[ERROR_DEBUG_CONTEXT] = context;
/** @type {?} */err[ERROR_LOGGER] = context.logError.bind(context);
}
/**
* @param {?} err
* @return {?}
*/
function isViewDebugError(err) {
return !!getDebugContext(err);
}
/**
* @param {?} action
* @return {?}
*/
function viewDestroyedError(action) {
return new Error("ViewDestroyedError: Attempt to use a destroyed view: " + action);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NOOP = function () {};
var _tokenKeyCache = new Map();
/**
* @param {?} token
* @return {?}
*/
function tokenKey(token) {
var /** @type {?} */key = _tokenKeyCache.get(token);
if (!key) {
key = stringify(token) + '_' + _tokenKeyCache.size;
_tokenKeyCache.set(token, key);
}
return key;
}
/**
* @param {?} view
* @param {?} nodeIdx
* @param {?} bindingIdx
* @param {?} value
* @return {?}
*/
function unwrapValue(view, nodeIdx, bindingIdx, value) {
if (value instanceof WrappedValue) {
value = value.wrapped;
var /** @type {?} */globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
var /** @type {?} */oldValue = view.oldValues[globalBindingIdx];
if (oldValue instanceof WrappedValue) {
oldValue = oldValue.wrapped;
}
view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
}
return value;
}
var UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
var EMPTY_RENDERER_TYPE_ID = '$$empty';
/**
* @param {?} values
* @return {?}
*/
function createRendererType2(values) {
return {
id: UNDEFINED_RENDERER_TYPE_ID,
styles: values.styles,
encapsulation: values.encapsulation,
data: values.data
};
}
var _renderCompCount = 0;
/**
* @param {?=} type
* @return {?}
*/
function resolveRendererType2(type) {
if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
// first time we see this RendererType2. Initialize it...
var /** @type {?} */isFilled = type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None || type.styles.length || Object.keys(type.data).length;
if (isFilled) {
type.id = "c" + _renderCompCount++;
} else {
type.id = EMPTY_RENDERER_TYPE_ID;
}
}
if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
type = null;
}
return type || null;
}
/**
* @param {?} view
* @param {?} def
* @param {?} bindingIdx
* @param {?} value
* @return {?}
*/
function checkBinding(view, def, bindingIdx, value) {
var /** @type {?} */oldValues = view.oldValues;
if (view.state & 2 /* FirstCheck */ || !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
return true;
}
return false;
}
/**
* @param {?} view
* @param {?} def
* @param {?} bindingIdx
* @param {?} value
* @return {?}
*/
function checkAndUpdateBinding(view, def, bindingIdx, value) {
if (checkBinding(view, def, bindingIdx, value)) {
view.oldValues[def.bindingIndex + bindingIdx] = value;
return true;
}
return false;
}
/**
* @param {?} view
* @param {?} def
* @param {?} bindingIdx
* @param {?} value
* @return {?}
*/
function checkBindingNoChanges(view, def, bindingIdx, value) {
var /** @type {?} */oldValue = view.oldValues[def.bindingIndex + bindingIdx];
if (view.state & 1 /* BeforeFirstCheck */ || !devModeEqual(oldValue, value)) {
throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.nodeIndex), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
}
}
/**
* @param {?} view
* @return {?}
*/
function markParentViewsForCheck(view) {
var /** @type {?} */currView = view;
while (currView) {
if (currView.def.flags & 2 /* OnPush */) {
currView.state |= 8 /* ChecksEnabled */;
}
currView = currView.viewContainerParent || currView.parent;
}
}
/**
* @param {?} view
* @param {?} endView
* @return {?}
*/
function markParentViewsForCheckProjectedViews(view, endView) {
var /** @type {?} */currView = view;
while (currView && currView !== endView) {
currView.state |= 64 /* CheckProjectedViews */;
currView = currView.viewContainerParent || currView.parent;
}
}
/**
* @param {?} view
* @param {?} nodeIndex
* @param {?} eventName
* @param {?} event
* @return {?}
*/
function dispatchEvent(view, nodeIndex, eventName, event) {
try {
var /** @type {?} */nodeDef = view.def.nodes[nodeIndex];
var /** @type {?} */startView = nodeDef.flags & 33554432 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
markParentViewsForCheck(startView);
return Services.handleEvent(view, nodeIndex, eventName, event);
} catch ( /** @type {?} */e) {
// Attention: Don't rethrow, as it would cancel Observable subscriptions!
view.root.errorHandler.handleError(e);
}
}
/**
* @param {?} view
* @return {?}
*/
function declaredViewContainer(view) {
if (view.parent) {
var /** @type {?} */parentView = view.parent;
return asElementData(parentView, /** @type {?} */view.parentNodeDef.nodeIndex);
}
return null;
}
/**
* for component views, this is the host element.
* for embedded views, this is the index of the parent node
* that contains the view container.
* @param {?} view
* @return {?}
*/
function viewParentEl(view) {
var /** @type {?} */parentView = view.parent;
if (parentView) {
return (/** @type {?} */view.parentNodeDef.parent
);
} else {
return null;
}
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function renderNode(view, def) {
switch (def.flags & 201347067 /* Types */) {case 1 /* TypeElement */:
return asElementData(view, def.nodeIndex).renderElement;
case 2 /* TypeText */:
return asTextData(view, def.nodeIndex).renderText;
}
}
/**
* @param {?} target
* @param {?} name
* @return {?}
*/
function elementEventFullName(target, name) {
return target ? target + ":" + name : name;
}
/**
* @param {?} view
* @return {?}
*/
function isComponentView(view) {
return !!view.parent && !!( /** @type {?} */view.parentNodeDef.flags & 32768 /* Component */);
}
/**
* @param {?} view
* @return {?}
*/
function isEmbeddedView(view) {
return !!view.parent && !( /** @type {?} */view.parentNodeDef.flags & 32768 /* Component */);
}
/**
* @param {?} queryId
* @return {?}
*/
function filterQueryId(queryId) {
return 1 << queryId % 32;
}
/**
* @param {?} matchedQueriesDsl
* @return {?}
*/
function splitMatchedQueriesDsl(matchedQueriesDsl) {
var /** @type {?} */matchedQueries = {};
var /** @type {?} */matchedQueryIds = 0;
var /** @type {?} */references = {};
if (matchedQueriesDsl) {
matchedQueriesDsl.forEach(function (_a) {
var queryId = _a[0],
valueType = _a[1];
if (typeof queryId === 'number') {
matchedQueries[queryId] = valueType;
matchedQueryIds |= filterQueryId(queryId);
} else {
references[queryId] = valueType;
}
});
}
return { matchedQueries: matchedQueries, references: references, matchedQueryIds: matchedQueryIds };
}
/**
* @param {?} deps
* @return {?}
*/
function splitDepsDsl(deps) {
return deps.map(function (value) {
var /** @type {?} */token;
var /** @type {?} */flags;
if (Array.isArray(value)) {
flags = value[0], token = value[1];
} else {
flags = 0 /* None */;
token = value;
}
return { flags: flags, token: token, tokenKey: tokenKey(token) };
});
}
/**
* @param {?} view
* @param {?} renderHost
* @param {?} def
* @return {?}
*/
function getParentRenderElement(view, renderHost, def) {
var /** @type {?} */renderParent = def.renderParent;
if (renderParent) {
if ((renderParent.flags & 1 /* TypeElement */) === 0 || (renderParent.flags & 33554432 /* ComponentView */) === 0 || /** @type {?} */renderParent.element.componentRendererType && /** @type {?} */ /** @type {?} */renderParent.element.componentRendererType.encapsulation === ViewEncapsulation.Native) {
// only children of non components, or children of components with native encapsulation should
// be attached.
return asElementData(view, /** @type {?} */def.renderParent.nodeIndex).renderElement;
}
} else {
return renderHost;
}
}
var DEFINITION_CACHE = new WeakMap();
/**
* @template D
* @param {?} factory
* @return {?}
*/
function resolveDefinition(factory) {
var /** @type {?} */value = /** @type {?} */DEFINITION_CACHE.get(factory);
if (!value) {
value = factory(function () {
return NOOP;
});
value.factory = factory;
DEFINITION_CACHE.set(factory, value);
}
return value;
}
/**
* @param {?} view
* @return {?}
*/
function rootRenderNodes(view) {
var /** @type {?} */renderNodes = [];
visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
return renderNodes;
}
/**
* @param {?} view
* @param {?} action
* @param {?} parentNode
* @param {?} nextSibling
* @param {?=} target
* @return {?}
*/
function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
// We need to re-compute the parent node in case the nodes have been moved around manually
if (action === 3 /* RemoveChild */) {
parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */view.def.lastRenderRootNode));
}
visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
}
/**
* @param {?} view
* @param {?} action
* @param {?} startIndex
* @param {?} endIndex
* @param {?} parentNode
* @param {?} nextSibling
* @param {?=} target
* @return {?}
*/
function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
for (var /** @type {?} */i = startIndex; i <= endIndex; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 8 /* TypeNgContent */)) {
visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
}
// jump to next sibling
i += nodeDef.childCount;
}
}
/**
* @param {?} view
* @param {?} ngContentIndex
* @param {?} action
* @param {?} parentNode
* @param {?} nextSibling
* @param {?=} target
* @return {?}
*/
function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
var /** @type {?} */compView = view;
while (compView && !isComponentView(compView)) {
compView = compView.parent;
}
var /** @type {?} */hostView = /** @type {?} */compView.parent;
var /** @type {?} */hostElDef = viewParentEl( /** @type {?} */compView);
var /** @type {?} */startIndex = /** @type {?} */hostElDef.nodeIndex + 1;
var /** @type {?} */endIndex = /** @type {?} */hostElDef.nodeIndex + /** @type {?} */hostElDef.childCount;
for (var /** @type {?} */i = startIndex; i <= endIndex; i++) {
var /** @type {?} */nodeDef = /** @type {?} */hostView.def.nodes[i];
if (nodeDef.ngContentIndex === ngContentIndex) {
visitRenderNode( /** @type {?} */hostView, nodeDef, action, parentNode, nextSibling, target);
}
// jump to next sibling
i += nodeDef.childCount;
}
if (! /** @type {?} */hostView.parent) {
// a root view
var /** @type {?} */projectedNodes = view.root.projectableNodes[ngContentIndex];
if (projectedNodes) {
for (var /** @type {?} */i = 0; i < projectedNodes.length; i++) {
execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
}
}
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} action
* @param {?} parentNode
* @param {?} nextSibling
* @param {?=} target
* @return {?}
*/
function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
if (nodeDef.flags & 8 /* TypeNgContent */) {
visitProjectedRenderNodes(view, /** @type {?} */nodeDef.ngContent.index, action, parentNode, nextSibling, target);
} else {
var /** @type {?} */rn = renderNode(view, nodeDef);
if (action === 3 /* RemoveChild */ && nodeDef.flags & 33554432 /* ComponentView */ && nodeDef.bindingFlags & 48 /* CatSyntheticProperty */) {
// Note: we might need to do both actions.
if (nodeDef.bindingFlags & 16 /* SyntheticProperty */) {
execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
}
if (nodeDef.bindingFlags & 32 /* SyntheticHostProperty */) {
var /** @type {?} */compView = asElementData(view, nodeDef.nodeIndex).componentView;
execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
}
} else {
execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
}
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
var /** @type {?} */embeddedViews = /** @type {?} */asElementData(view, nodeDef.nodeIndex).viewContainer._embeddedViews;
for (var /** @type {?} */k = 0; k < embeddedViews.length; k++) {
visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
}
}
if (nodeDef.flags & 1 /* TypeElement */ && ! /** @type {?} */nodeDef.element.name) {
visitSiblingRenderNodes(view, action, nodeDef.nodeIndex + 1, nodeDef.nodeIndex + nodeDef.childCount, parentNode, nextSibling, target);
}
}
}
/**
* @param {?} view
* @param {?} renderNode
* @param {?} action
* @param {?} parentNode
* @param {?} nextSibling
* @param {?=} target
* @return {?}
*/
function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
var /** @type {?} */renderer = view.renderer;
switch (action) {
case 1 /* AppendChild */:
renderer.appendChild(parentNode, renderNode);
break;
case 2 /* InsertBefore */:
renderer.insertBefore(parentNode, renderNode, nextSibling);
break;
case 3 /* RemoveChild */:
renderer.removeChild(parentNode, renderNode);
break;
case 0 /* Collect */:
/** @type {?} */target.push(renderNode);
break;
}
}
var NS_PREFIX_RE = /^:([^:]+):(.+)$/;
/**
* @param {?} name
* @return {?}
*/
function splitNamespace(name) {
if (name[0] === ':') {
var /** @type {?} */match = /** @type {?} */name.match(NS_PREFIX_RE);
return [match[1], match[2]];
}
return ['', name];
}
/**
* @param {?} bindings
* @return {?}
*/
function calcBindingFlags(bindings) {
var /** @type {?} */flags = 0;
for (var /** @type {?} */i = 0; i < bindings.length; i++) {
flags |= bindings[i].flags;
}
return flags;
}
/**
* @param {?} valueCount
* @param {?} constAndInterp
* @return {?}
*/
function interpolate(valueCount, constAndInterp) {
var /** @type {?} */result = '';
for (var /** @type {?} */i = 0; i < valueCount * 2; i = i + 2) {
result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
}
return result + constAndInterp[valueCount * 2];
}
/**
* @param {?} valueCount
* @param {?} c0
* @param {?} a1
* @param {?} c1
* @param {?=} a2
* @param {?=} c2
* @param {?=} a3
* @param {?=} c3
* @param {?=} a4
* @param {?=} c4
* @param {?=} a5
* @param {?=} c5
* @param {?=} a6
* @param {?=} c6
* @param {?=} a7
* @param {?=} c7
* @param {?=} a8
* @param {?=} c8
* @param {?=} a9
* @param {?=} c9
* @return {?}
*/
function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
switch (valueCount) {
case 1:
return c0 + _toStringWithNull(a1) + c1;
case 2:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
case 3:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3;
case 4:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4;
case 5:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
case 6:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
case 7:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6 + _toStringWithNull(a7) + c7;
case 8:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
case 9:
return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) + c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
default:
throw new Error("Does not support more than 9 expressions");
}
}
/**
* @param {?} v
* @return {?}
*/
function _toStringWithNull(v) {
return v != null ? v.toString() : '';
}
var EMPTY_ARRAY = [];
var EMPTY_MAP = {};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} flags
* @param {?} matchedQueriesDsl
* @param {?} ngContentIndex
* @param {?} childCount
* @param {?=} handleEvent
* @param {?=} templateFactory
* @return {?}
*/
function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
flags |= 1 /* TypeElement */;
var _a = splitMatchedQueriesDsl(matchedQueriesDsl),
matchedQueries = _a.matchedQueries,
references = _a.references,
matchedQueryIds = _a.matchedQueryIds;
var /** @type {?} */template = templateFactory ? resolveDefinition(templateFactory) : null;
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
flags: flags,
checkIndex: -1,
childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
bindings: [],
bindingFlags: 0,
outputs: [],
element: {
ns: null,
name: null,
attrs: null, template: template,
componentProvider: null,
componentView: null,
componentRendererType: null,
publicProviders: null,
allProviders: null,
handleEvent: handleEvent || NOOP
},
provider: null,
text: null,
query: null,
ngContent: null
};
}
/**
* @param {?} checkIndex
* @param {?} flags
* @param {?} matchedQueriesDsl
* @param {?} ngContentIndex
* @param {?} childCount
* @param {?} namespaceAndName
* @param {?=} fixedAttrs
* @param {?=} bindings
* @param {?=} outputs
* @param {?=} handleEvent
* @param {?=} componentView
* @param {?=} componentRendererType
* @return {?}
*/
function elementDef(checkIndex, flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs, bindings, outputs, handleEvent, componentView, componentRendererType) {
if (fixedAttrs === void 0) {
fixedAttrs = [];
}
if (!handleEvent) {
handleEvent = NOOP;
}
var _a = splitMatchedQueriesDsl(matchedQueriesDsl),
matchedQueries = _a.matchedQueries,
references = _a.references,
matchedQueryIds = _a.matchedQueryIds;
var /** @type {?} */ns = /** @type {?} */null;
var /** @type {?} */name = /** @type {?} */null;
if (namespaceAndName) {
_b = splitNamespace(namespaceAndName), ns = _b[0], name = _b[1];
}
bindings = bindings || [];
var /** @type {?} */bindingDefs = new Array(bindings.length);
for (var /** @type {?} */i = 0; i < bindings.length; i++) {
var _c = bindings[i],
bindingFlags = _c[0],
namespaceAndName_1 = _c[1],
suffixOrSecurityContext = _c[2];
var _d = splitNamespace(namespaceAndName_1),
ns_1 = _d[0],
name_1 = _d[1];
var /** @type {?} */securityContext = /** @type {?} */undefined;
var /** @type {?} */suffix = /** @type {?} */undefined;
switch (bindingFlags & 15 /* Types */) {case 4 /* TypeElementStyle */:
suffix = /** @type {?} */suffixOrSecurityContext;
break;
case 1 /* TypeElementAttribute */:
case 8 /* TypeProperty */:
securityContext = /** @type {?} */suffixOrSecurityContext;
break;
}
bindingDefs[i] = { flags: bindingFlags, ns: ns_1, name: name_1, nonMinifiedName: name_1, securityContext: securityContext, suffix: suffix };
}
outputs = outputs || [];
var /** @type {?} */outputDefs = new Array(outputs.length);
for (var /** @type {?} */i = 0; i < outputs.length; i++) {
var _e = outputs[i],
target = _e[0],
eventName = _e[1];
outputDefs[i] = {
type: 0 /* ElementOutput */
, target: /** @type {?} */target, eventName: eventName,
propName: null
};
}
fixedAttrs = fixedAttrs || [];
var /** @type {?} */attrs = /** @type {?} */fixedAttrs.map(function (_a) {
var namespaceAndName = _a[0],
value = _a[1];
var _b = splitNamespace(namespaceAndName),
ns = _b[0],
name = _b[1];
return [ns, name, value];
});
componentRendererType = resolveRendererType2(componentRendererType);
if (componentView) {
flags |= 33554432 /* ComponentView */;
}
flags |= 1 /* TypeElement */;
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
checkIndex: checkIndex,
flags: flags,
childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
bindings: bindingDefs,
bindingFlags: calcBindingFlags(bindingDefs),
outputs: outputDefs,
element: {
ns: ns,
name: name,
attrs: attrs,
template: null,
// will bet set by the view definition
componentProvider: null,
componentView: componentView || null,
componentRendererType: componentRendererType,
publicProviders: null,
allProviders: null,
handleEvent: handleEvent || NOOP
},
provider: null,
text: null,
query: null,
ngContent: null
};
var _b;
}
/**
* @param {?} view
* @param {?} renderHost
* @param {?} def
* @return {?}
*/
function createElement(view, renderHost, def) {
var /** @type {?} */elDef = /** @type {?} */def.element;
var /** @type {?} */rootSelectorOrNode = view.root.selectorOrNode;
var /** @type {?} */renderer = view.renderer;
var /** @type {?} */el;
if (view.parent || !rootSelectorOrNode) {
if (elDef.name) {
el = renderer.createElement(elDef.name, elDef.ns);
} else {
el = renderer.createComment('');
}
var /** @type {?} */parentEl = getParentRenderElement(view, renderHost, def);
if (parentEl) {
renderer.appendChild(parentEl, el);
}
} else {
el = renderer.selectRootElement(rootSelectorOrNode);
}
if (elDef.attrs) {
for (var /** @type {?} */i = 0; i < elDef.attrs.length; i++) {
var _a = elDef.attrs[i],
ns = _a[0],
name_2 = _a[1],
value = _a[2];
renderer.setAttribute(el, name_2, value, ns);
}
}
return el;
}
/**
* @param {?} view
* @param {?} compView
* @param {?} def
* @param {?} el
* @return {?}
*/
function listenToElementOutputs(view, compView, def, el) {
for (var /** @type {?} */i = 0; i < def.outputs.length; i++) {
var /** @type {?} */output = def.outputs[i];
var /** @type {?} */handleEventClosure = renderEventHandlerClosure(view, def.nodeIndex, elementEventFullName(output.target, output.eventName));
var /** @type {?} */listenTarget = output.target;
var /** @type {?} */listenerView = view;
if (output.target === 'component') {
listenTarget = null;
listenerView = compView;
}
var /** @type {?} */disposable = /** @type {?} */listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure); /** @type {?} */
view.disposables[def.outputIndex + i] = disposable;
}
}
/**
* @param {?} view
* @param {?} index
* @param {?} eventName
* @return {?}
*/
function renderEventHandlerClosure(view, index, eventName) {
return function (event) {
return dispatchEvent(view, index, eventName, event);
};
}
/**
* @param {?} view
* @param {?} def
* @param {?} v0
* @param {?} v1
* @param {?} v2
* @param {?} v3
* @param {?} v4
* @param {?} v5
* @param {?} v6
* @param {?} v7
* @param {?} v8
* @param {?} v9
* @return {?}
*/
function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */bindLen = def.bindings.length;
var /** @type {?} */changed = false;
if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0)) changed = true;
if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1)) changed = true;
if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2)) changed = true;
if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3)) changed = true;
if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4)) changed = true;
if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5)) changed = true;
if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6)) changed = true;
if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7)) changed = true;
if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8)) changed = true;
if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9)) changed = true;
return changed;
}
/**
* @param {?} view
* @param {?} def
* @param {?} values
* @return {?}
*/
function checkAndUpdateElementDynamic(view, def, values) {
var /** @type {?} */changed = false;
for (var /** @type {?} */i = 0; i < values.length; i++) {
if (checkAndUpdateElementValue(view, def, i, values[i])) changed = true;
}
return changed;
}
/**
* @param {?} view
* @param {?} def
* @param {?} bindingIdx
* @param {?} value
* @return {?}
*/
function checkAndUpdateElementValue(view, def, bindingIdx, value) {
if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
return false;
}
var /** @type {?} */binding = def.bindings[bindingIdx];
var /** @type {?} */elData = asElementData(view, def.nodeIndex);
var /** @type {?} */renderNode$$1 = elData.renderElement;
var /** @type {?} */name = /** @type {?} */binding.name;
switch (binding.flags & 15 /* Types */) {case 1 /* TypeElementAttribute */:
setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
break;
case 2 /* TypeElementClass */:
setElementClass(view, renderNode$$1, name, value);
break;
case 4 /* TypeElementStyle */:
setElementStyle(view, binding, renderNode$$1, name, value);
break;
case 8 /* TypeProperty */:
var /** @type {?} */bindView = def.flags & 33554432 /* ComponentView */ && binding.flags & 32 /* SyntheticHostProperty */ ? elData.componentView : view;
setElementProperty(bindView, binding, renderNode$$1, name, value);
break;
}
return true;
}
/**
* @param {?} view
* @param {?} binding
* @param {?} renderNode
* @param {?} ns
* @param {?} name
* @param {?} value
* @return {?}
*/
function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
var /** @type {?} */securityContext = binding.securityContext;
var /** @type {?} */renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
renderValue = renderValue != null ? renderValue.toString() : null;
var /** @type {?} */renderer = view.renderer;
if (value != null) {
renderer.setAttribute(renderNode$$1, name, renderValue, ns);
} else {
renderer.removeAttribute(renderNode$$1, name, ns);
}
}
/**
* @param {?} view
* @param {?} renderNode
* @param {?} name
* @param {?} value
* @return {?}
*/
function setElementClass(view, renderNode$$1, name, value) {
var /** @type {?} */renderer = view.renderer;
if (value) {
renderer.addClass(renderNode$$1, name);
} else {
renderer.removeClass(renderNode$$1, name);
}
}
/**
* @param {?} view
* @param {?} binding
* @param {?} renderNode
* @param {?} name
* @param {?} value
* @return {?}
*/
function setElementStyle(view, binding, renderNode$$1, name, value) {
var /** @type {?} */renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */value);
if (renderValue != null) {
renderValue = renderValue.toString();
var /** @type {?} */unit = binding.suffix;
if (unit != null) {
renderValue = renderValue + unit;
}
} else {
renderValue = null;
}
var /** @type {?} */renderer = view.renderer;
if (renderValue != null) {
renderer.setStyle(renderNode$$1, name, renderValue);
} else {
renderer.removeStyle(renderNode$$1, name);
}
}
/**
* @param {?} view
* @param {?} binding
* @param {?} renderNode
* @param {?} name
* @param {?} value
* @return {?}
*/
function setElementProperty(view, binding, renderNode$$1, name, value) {
var /** @type {?} */securityContext = binding.securityContext;
var /** @type {?} */renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
view.renderer.setProperty(renderNode$$1, name, renderValue);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var UNDEFINED_VALUE = new Object();
var InjectorRefTokenKey$1 = tokenKey(Injector);
var NgModuleRefTokenKey = tokenKey(NgModuleRef);
/**
* @param {?} flags
* @param {?} token
* @param {?} value
* @param {?} deps
* @return {?}
*/
function moduleProvideDef(flags, token, value, deps) {
// Need to resolve forwardRefs as e.g. for `useValue` we
// lowered the expression and then stopped evaluating it,
// i.e. also didn't unwrap it.
value = resolveForwardRef(value);
var /** @type {?} */depDefs = splitDepsDsl(deps);
return {
// will bet set by the module definition
index: -1,
deps: depDefs, flags: flags, token: token, value: value
};
}
/**
* @param {?} providers
* @return {?}
*/
function moduleDef(providers) {
var /** @type {?} */providersByKey = {};
for (var /** @type {?} */i = 0; i < providers.length; i++) {
var /** @type {?} */provider = providers[i];
provider.index = i;
providersByKey[tokenKey(provider.token)] = provider;
}
return {
// Will be filled later...
factory: null,
providersByKey: providersByKey,
providers: providers
};
}
/**
* @param {?} data
* @return {?}
*/
function initNgModule(data) {
var /** @type {?} */def = data._def;
var /** @type {?} */providers = data._providers = new Array(def.providers.length);
for (var /** @type {?} */i = 0; i < def.providers.length; i++) {
var /** @type {?} */provDef = def.providers[i];
if (!(provDef.flags & 4096 /* LazyProvider */)) {
providers[i] = _createProviderInstance$1(data, provDef);
}
}
}
/**
* @param {?} data
* @param {?} depDef
* @param {?=} notFoundValue
* @return {?}
*/
function resolveNgModuleDep(data, depDef, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = Injector.THROW_IF_NOT_FOUND;
}
if (depDef.flags & 8 /* Value */) {
return depDef.token;
}
if (depDef.flags & 2 /* Optional */) {
notFoundValue = null;
}
if (depDef.flags & 1 /* SkipSelf */) {
return data._parent.get(depDef.token, notFoundValue);
}
var /** @type {?} */tokenKey$$1 = depDef.tokenKey;
switch (tokenKey$$1) {
case InjectorRefTokenKey$1:
case NgModuleRefTokenKey:
return data;
}
var /** @type {?} */providerDef = data._def.providersByKey[tokenKey$$1];
if (providerDef) {
var /** @type {?} */providerInstance = data._providers[providerDef.index];
if (providerInstance === undefined) {
providerInstance = data._providers[providerDef.index] = _createProviderInstance$1(data, providerDef);
}
return providerInstance === UNDEFINED_VALUE ? undefined : providerInstance;
}
return data._parent.get(depDef.token, notFoundValue);
}
/**
* @param {?} ngModule
* @param {?} providerDef
* @return {?}
*/
function _createProviderInstance$1(ngModule, providerDef) {
var /** @type {?} */injectable;
switch (providerDef.flags & 201347067 /* Types */) {case 512 /* TypeClassProvider */:
injectable = _createClass(ngModule, providerDef.value, providerDef.deps);
break;
case 1024 /* TypeFactoryProvider */:
injectable = _callFactory(ngModule, providerDef.value, providerDef.deps);
break;
case 2048 /* TypeUseExistingProvider */:
injectable = resolveNgModuleDep(ngModule, providerDef.deps[0]);
break;
case 256 /* TypeValueProvider */:
injectable = providerDef.value;
break;
}
return injectable === undefined ? UNDEFINED_VALUE : injectable;
}
/**
* @param {?} ngModule
* @param {?} ctor
* @param {?} deps
* @return {?}
*/
function _createClass(ngModule, ctor, deps) {
var /** @type {?} */len = deps.length;
switch (len) {
case 0:
return new ctor();
case 1:
return new ctor(resolveNgModuleDep(ngModule, deps[0]));
case 2:
return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
case 3:
return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
default:
var /** @type {?} */depValues = new Array(len);
for (var /** @type {?} */i = 0; i < len; i++) {
depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
}
return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
}
}
/**
* @param {?} ngModule
* @param {?} factory
* @param {?} deps
* @return {?}
*/
function _callFactory(ngModule, factory, deps) {
var /** @type {?} */len = deps.length;
switch (len) {
case 0:
return factory();
case 1:
return factory(resolveNgModuleDep(ngModule, deps[0]));
case 2:
return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
case 3:
return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
default:
var /** @type {?} */depValues = Array(len);
for (var /** @type {?} */i = 0; i < len; i++) {
depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
}
return factory.apply(void 0, depValues);
}
}
/**
* @param {?} ngModule
* @param {?} lifecycles
* @return {?}
*/
function callNgModuleLifecycle(ngModule, lifecycles) {
var /** @type {?} */def = ngModule._def;
for (var /** @type {?} */i = 0; i < def.providers.length; i++) {
var /** @type {?} */provDef = def.providers[i];
if (provDef.flags & 131072 /* OnDestroy */) {
var /** @type {?} */instance = ngModule._providers[i];
if (instance && instance !== UNDEFINED_VALUE) {
instance.ngOnDestroy();
}
}
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} parentView
* @param {?} elementData
* @param {?} viewIndex
* @param {?} view
* @return {?}
*/
function attachEmbeddedView(parentView, elementData, viewIndex, view) {
var /** @type {?} */embeddedViews = /** @type {?} */elementData.viewContainer._embeddedViews;
if (viewIndex === null || viewIndex === undefined) {
viewIndex = embeddedViews.length;
}
view.viewContainerParent = parentView;
addToArray(embeddedViews, /** @type {?} */viewIndex, view);
attachProjectedView(elementData, view);
Services.dirtyParentQueries(view);
var /** @type {?} */prevView = /** @type {?} */viewIndex > 0 ? embeddedViews[/** @type {?} */viewIndex - 1] : null;
renderAttachEmbeddedView(elementData, prevView, view);
}
/**
* @param {?} vcElementData
* @param {?} view
* @return {?}
*/
function attachProjectedView(vcElementData, view) {
var /** @type {?} */dvcElementData = declaredViewContainer(view);
if (!dvcElementData || dvcElementData === vcElementData || view.state & 16 /* IsProjectedView */) {
return;
}
// Note: For performance reasons, we
// - add a view to template._projectedViews only 1x throughout its lifetime,
// and remove it not until the view is destroyed.
// (hard, as when a parent view is attached/detached we would need to attach/detach all
// nested projected views as well, even accross component boundaries).
// - don't track the insertion order of views in the projected views array
// (hard, as when the views of the same template are inserted different view containers)
view.state |= 16 /* IsProjectedView */;
var /** @type {?} */projectedViews = dvcElementData.template._projectedViews;
if (!projectedViews) {
projectedViews = dvcElementData.template._projectedViews = [];
}
projectedViews.push(view);
// Note: we are changing the NodeDef here as we cannot calculate
// the fact whether a template is used for projection during compilation.
markNodeAsProjectedTemplate( /** @type {?} */view.parent.def, /** @type {?} */view.parentNodeDef);
}
/**
* @param {?} viewDef
* @param {?} nodeDef
* @return {?}
*/
function markNodeAsProjectedTemplate(viewDef, nodeDef) {
if (nodeDef.flags & 4 /* ProjectedTemplate */) {
return;
}
viewDef.nodeFlags |= 4 /* ProjectedTemplate */;
nodeDef.flags |= 4 /* ProjectedTemplate */;
var /** @type {?} */parentNodeDef = nodeDef.parent;
while (parentNodeDef) {
parentNodeDef.childFlags |= 4 /* ProjectedTemplate */;
parentNodeDef = parentNodeDef.parent;
}
}
/**
* @param {?} elementData
* @param {?=} viewIndex
* @return {?}
*/
function detachEmbeddedView(elementData, viewIndex) {
var /** @type {?} */embeddedViews = /** @type {?} */elementData.viewContainer._embeddedViews;
if (viewIndex == null || viewIndex >= embeddedViews.length) {
viewIndex = embeddedViews.length - 1;
}
if (viewIndex < 0) {
return null;
}
var /** @type {?} */view = embeddedViews[viewIndex];
view.viewContainerParent = null;
removeFromArray(embeddedViews, viewIndex);
// See attachProjectedView for why we don't update projectedViews here.
Services.dirtyParentQueries(view);
renderDetachView(view);
return view;
}
/**
* @param {?} view
* @return {?}
*/
function detachProjectedView(view) {
if (!(view.state & 16 /* IsProjectedView */)) {
return;
}
var /** @type {?} */dvcElementData = declaredViewContainer(view);
if (dvcElementData) {
var /** @type {?} */projectedViews = dvcElementData.template._projectedViews;
if (projectedViews) {
removeFromArray(projectedViews, projectedViews.indexOf(view));
Services.dirtyParentQueries(view);
}
}
}
/**
* @param {?} elementData
* @param {?} oldViewIndex
* @param {?} newViewIndex
* @return {?}
*/
function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
var /** @type {?} */embeddedViews = /** @type {?} */elementData.viewContainer._embeddedViews;
var /** @type {?} */view = embeddedViews[oldViewIndex];
removeFromArray(embeddedViews, oldViewIndex);
if (newViewIndex == null) {
newViewIndex = embeddedViews.length;
}
addToArray(embeddedViews, newViewIndex, view);
// Note: Don't need to change projectedViews as the order in there
// as always invalid...
Services.dirtyParentQueries(view);
renderDetachView(view);
var /** @type {?} */prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
renderAttachEmbeddedView(elementData, prevView, view);
return view;
}
/**
* @param {?} elementData
* @param {?} prevView
* @param {?} view
* @return {?}
*/
function renderAttachEmbeddedView(elementData, prevView, view) {
var /** @type {?} */prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */prevView.def.lastRenderRootNode) : elementData.renderElement;
var /** @type {?} */parentNode = view.renderer.parentNode(prevRenderNode);
var /** @type {?} */nextSibling = view.renderer.nextSibling(prevRenderNode);
// Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
// However, browsers automatically do `appendChild` when there is no `nextSibling`.
visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
}
/**
* @param {?} view
* @return {?}
*/
function renderDetachView(view) {
visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
}
/**
* @param {?} arr
* @param {?} index
* @param {?} value
* @return {?}
*/
function addToArray(arr, index, value) {
// perf: array.push is faster than array.splice!
if (index >= arr.length) {
arr.push(value);
} else {
arr.splice(index, 0, value);
}
}
/**
* @param {?} arr
* @param {?} index
* @return {?}
*/
function removeFromArray(arr, index) {
// perf: array.pop is faster than array.splice!
if (index >= arr.length - 1) {
arr.pop();
} else {
arr.splice(index, 1);
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var EMPTY_CONTEXT = new Object();
/**
* @param {?} selector
* @param {?} componentType
* @param {?} viewDefFactory
* @param {?} inputs
* @param {?} outputs
* @param {?} ngContentSelectors
* @return {?}
*/
function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
}
/**
* @param {?} componentFactory
* @return {?}
*/
function getComponentViewDefinitionFactory(componentFactory) {
return (/** @type {?} */componentFactory.viewDefFactory
);
}
var ComponentFactory_ = /** @class */function (_super) {
__extends(ComponentFactory_, _super);
function ComponentFactory_(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
var _this =
// Attention: this ctor is called as top level function.
// Putting any logic in here will destroy closure tree shaking!
_super.call(this) || this;
_this.selector = selector;
_this.componentType = componentType;
_this._inputs = _inputs;
_this._outputs = _outputs;
_this.ngContentSelectors = ngContentSelectors;
_this.viewDefFactory = viewDefFactory;
return _this;
}
Object.defineProperty(ComponentFactory_.prototype, "inputs", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */inputsArr = [];
var /** @type {?} */inputs = /** @type {?} */this._inputs;
for (var /** @type {?} */propName in inputs) {
var /** @type {?} */templateName = inputs[propName];
inputsArr.push({ propName: propName, templateName: templateName });
}
return inputsArr;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentFactory_.prototype, "outputs", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */outputsArr = [];
for (var /** @type {?} */propName in this._outputs) {
var /** @type {?} */templateName = this._outputs[propName];
outputsArr.push({ propName: propName, templateName: templateName });
}
return outputsArr;
},
enumerable: true,
configurable: true
});
/**
* Creates a new component.
*/
/**
* Creates a new component.
* @param {?} injector
* @param {?=} projectableNodes
* @param {?=} rootSelectorOrNode
* @param {?=} ngModule
* @return {?}
*/
ComponentFactory_.prototype.create = /**
* Creates a new component.
* @param {?} injector
* @param {?=} projectableNodes
* @param {?=} rootSelectorOrNode
* @param {?=} ngModule
* @return {?}
*/
function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
if (!ngModule) {
throw new Error('ngModule should be provided');
}
var /** @type {?} */viewDef = resolveDefinition(this.viewDefFactory);
var /** @type {?} */componentNodeIndex = /** @type {?} */ /** @type {?} */viewDef.nodes[0].element.componentProvider.nodeIndex;
var /** @type {?} */view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
var /** @type {?} */component = asProviderData(view, componentNodeIndex).instance;
if (rootSelectorOrNode) {
view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
}
return new ComponentRef_(view, new ViewRef_(view), component);
};
return ComponentFactory_;
}(ComponentFactory);
var ComponentRef_ = /** @class */function (_super) {
__extends(ComponentRef_, _super);
function ComponentRef_(_view, _viewRef, _component) {
var _this = _super.call(this) || this;
_this._view = _view;
_this._viewRef = _viewRef;
_this._component = _component;
_this._elDef = _this._view.def.nodes[0];
_this.hostView = _viewRef;
_this.changeDetectorRef = _viewRef;
_this.instance = _component;
return _this;
}
Object.defineProperty(ComponentRef_.prototype, "location", {
get: /**
* @return {?}
*/
function () {
return new ElementRef(asElementData(this._view, this._elDef.nodeIndex).renderElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentRef_.prototype, "injector", {
get: /**
* @return {?}
*/
function () {
return new Injector_(this._view, this._elDef);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ComponentRef_.prototype, "componentType", {
get: /**
* @return {?}
*/
function () {
return (/** @type {?} */this._component.constructor
);
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
ComponentRef_.prototype.destroy = /**
* @return {?}
*/
function () {
this._viewRef.destroy();
};
/**
* @param {?} callback
* @return {?}
*/
ComponentRef_.prototype.onDestroy = /**
* @param {?} callback
* @return {?}
*/
function (callback) {
this._viewRef.onDestroy(callback);
};
return ComponentRef_;
}(ComponentRef);
/**
* @param {?} view
* @param {?} elDef
* @param {?} elData
* @return {?}
*/
function createViewContainerData(view, elDef, elData) {
return new ViewContainerRef_(view, elDef, elData);
}
var ViewContainerRef_ = /** @class */function () {
function ViewContainerRef_(_view, _elDef, _data) {
this._view = _view;
this._elDef = _elDef;
this._data = _data;
/**
* \@internal
*/
this._embeddedViews = [];
}
Object.defineProperty(ViewContainerRef_.prototype, "element", {
get: /**
* @return {?}
*/
function () {
return new ElementRef(this._data.renderElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ViewContainerRef_.prototype, "injector", {
get: /**
* @return {?}
*/
function () {
return new Injector_(this._view, this._elDef);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ViewContainerRef_.prototype, "parentInjector", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */view = this._view;
var /** @type {?} */elDef = this._elDef.parent;
while (!elDef && view) {
elDef = viewParentEl(view);
view = /** @type {?} */view.parent;
}
return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
ViewContainerRef_.prototype.clear = /**
* @return {?}
*/
function () {
var /** @type {?} */len = this._embeddedViews.length;
for (var /** @type {?} */i = len - 1; i >= 0; i--) {
var /** @type {?} */view = /** @type {?} */detachEmbeddedView(this._data, i);
Services.destroyView(view);
}
};
/**
* @param {?} index
* @return {?}
*/
ViewContainerRef_.prototype.get = /**
* @param {?} index
* @return {?}
*/
function (index) {
var /** @type {?} */view = this._embeddedViews[index];
if (view) {
var /** @type {?} */ref = new ViewRef_(view);
ref.attachToViewContainerRef(this);
return ref;
}
return null;
};
Object.defineProperty(ViewContainerRef_.prototype, "length", {
get: /**
* @return {?}
*/
function () {
return this._embeddedViews.length;
},
enumerable: true,
configurable: true
});
/**
* @template C
* @param {?} templateRef
* @param {?=} context
* @param {?=} index
* @return {?}
*/
ViewContainerRef_.prototype.createEmbeddedView = /**
* @template C
* @param {?} templateRef
* @param {?=} context
* @param {?=} index
* @return {?}
*/
function (templateRef, context, index) {
var /** @type {?} */viewRef = templateRef.createEmbeddedView(context || /** @type {?} */{});
this.insert(viewRef, index);
return viewRef;
};
/**
* @template C
* @param {?} componentFactory
* @param {?=} index
* @param {?=} injector
* @param {?=} projectableNodes
* @param {?=} ngModuleRef
* @return {?}
*/
ViewContainerRef_.prototype.createComponent = /**
* @template C
* @param {?} componentFactory
* @param {?=} index
* @param {?=} injector
* @param {?=} projectableNodes
* @param {?=} ngModuleRef
* @return {?}
*/
function (componentFactory, index, injector, projectableNodes, ngModuleRef) {
var /** @type {?} */contextInjector = injector || this.parentInjector;
if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
ngModuleRef = contextInjector.get(NgModuleRef);
}
var /** @type {?} */componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
this.insert(componentRef.hostView, index);
return componentRef;
};
/**
* @param {?} viewRef
* @param {?=} index
* @return {?}
*/
ViewContainerRef_.prototype.insert = /**
* @param {?} viewRef
* @param {?=} index
* @return {?}
*/
function (viewRef, index) {
if (viewRef.destroyed) {
throw new Error('Cannot insert a destroyed View in a ViewContainer!');
}
var /** @type {?} */viewRef_ = /** @type {?} */viewRef;
var /** @type {?} */viewData = viewRef_._view;
attachEmbeddedView(this._view, this._data, index, viewData);
viewRef_.attachToViewContainerRef(this);
return viewRef;
};
/**
* @param {?} viewRef
* @param {?} currentIndex
* @return {?}
*/
ViewContainerRef_.prototype.move = /**
* @param {?} viewRef
* @param {?} currentIndex
* @return {?}
*/
function (viewRef, currentIndex) {
if (viewRef.destroyed) {
throw new Error('Cannot move a destroyed View in a ViewContainer!');
}
var /** @type {?} */previousIndex = this._embeddedViews.indexOf(viewRef._view);
moveEmbeddedView(this._data, previousIndex, currentIndex);
return viewRef;
};
/**
* @param {?} viewRef
* @return {?}
*/
ViewContainerRef_.prototype.indexOf = /**
* @param {?} viewRef
* @return {?}
*/
function (viewRef) {
return this._embeddedViews.indexOf( /** @type {?} */viewRef._view);
};
/**
* @param {?=} index
* @return {?}
*/
ViewContainerRef_.prototype.remove = /**
* @param {?=} index
* @return {?}
*/
function (index) {
var /** @type {?} */viewData = detachEmbeddedView(this._data, index);
if (viewData) {
Services.destroyView(viewData);
}
};
/**
* @param {?=} index
* @return {?}
*/
ViewContainerRef_.prototype.detach = /**
* @param {?=} index
* @return {?}
*/
function (index) {
var /** @type {?} */view = detachEmbeddedView(this._data, index);
return view ? new ViewRef_(view) : null;
};
return ViewContainerRef_;
}();
/**
* @param {?} view
* @return {?}
*/
function createChangeDetectorRef(view) {
return new ViewRef_(view);
}
var ViewRef_ = /** @class */function () {
function ViewRef_(_view) {
this._view = _view;
this._viewContainerRef = null;
this._appRef = null;
}
Object.defineProperty(ViewRef_.prototype, "rootNodes", {
get: /**
* @return {?}
*/
function () {
return rootRenderNodes(this._view);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ViewRef_.prototype, "context", {
get: /**
* @return {?}
*/
function () {
return this._view.context;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ViewRef_.prototype, "destroyed", {
get: /**
* @return {?}
*/
function () {
return (this._view.state & 128 /* Destroyed */) !== 0;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
ViewRef_.prototype.markForCheck = /**
* @return {?}
*/
function () {
markParentViewsForCheck(this._view);
};
/**
* @return {?}
*/
ViewRef_.prototype.detach = /**
* @return {?}
*/
function () {
this._view.state &= ~4 /* Attached */;
};
/**
* @return {?}
*/
ViewRef_.prototype.detectChanges = /**
* @return {?}
*/
function () {
var /** @type {?} */fs = this._view.root.rendererFactory;
if (fs.begin) {
fs.begin();
}
Services.checkAndUpdateView(this._view);
if (fs.end) {
fs.end();
}
};
/**
* @return {?}
*/
ViewRef_.prototype.checkNoChanges = /**
* @return {?}
*/
function () {
Services.checkNoChangesView(this._view);
};
/**
* @return {?}
*/
ViewRef_.prototype.reattach = /**
* @return {?}
*/
function () {
this._view.state |= 4 /* Attached */;
};
/**
* @param {?} callback
* @return {?}
*/
ViewRef_.prototype.onDestroy = /**
* @param {?} callback
* @return {?}
*/
function (callback) {
if (!this._view.disposables) {
this._view.disposables = [];
}
this._view.disposables.push( /** @type {?} */callback);
};
/**
* @return {?}
*/
ViewRef_.prototype.destroy = /**
* @return {?}
*/
function () {
if (this._appRef) {
this._appRef.detachView(this);
} else if (this._viewContainerRef) {
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
}
Services.destroyView(this._view);
};
/**
* @return {?}
*/
ViewRef_.prototype.detachFromAppRef = /**
* @return {?}
*/
function () {
this._appRef = null;
renderDetachView(this._view);
Services.dirtyParentQueries(this._view);
};
/**
* @param {?} appRef
* @return {?}
*/
ViewRef_.prototype.attachToAppRef = /**
* @param {?} appRef
* @return {?}
*/
function (appRef) {
if (this._viewContainerRef) {
throw new Error('This view is already attached to a ViewContainer!');
}
this._appRef = appRef;
};
/**
* @param {?} vcRef
* @return {?}
*/
ViewRef_.prototype.attachToViewContainerRef = /**
* @param {?} vcRef
* @return {?}
*/
function (vcRef) {
if (this._appRef) {
throw new Error('This view is already attached directly to the ApplicationRef!');
}
this._viewContainerRef = vcRef;
};
return ViewRef_;
}();
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function createTemplateData(view, def) {
return new TemplateRef_(view, def);
}
var TemplateRef_ = /** @class */function (_super) {
__extends(TemplateRef_, _super);
function TemplateRef_(_parentView, _def) {
var _this = _super.call(this) || this;
_this._parentView = _parentView;
_this._def = _def;
return _this;
}
/**
* @param {?} context
* @return {?}
*/
TemplateRef_.prototype.createEmbeddedView = /**
* @param {?} context
* @return {?}
*/
function (context) {
return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, /** @type {?} */ /** @type {?} */this._def.element.template, context));
};
Object.defineProperty(TemplateRef_.prototype, "elementRef", {
get: /**
* @return {?}
*/
function () {
return new ElementRef(asElementData(this._parentView, this._def.nodeIndex).renderElement);
},
enumerable: true,
configurable: true
});
return TemplateRef_;
}(TemplateRef);
/**
* @param {?} view
* @param {?} elDef
* @return {?}
*/
function createInjector(view, elDef) {
return new Injector_(view, elDef);
}
var Injector_ = /** @class */function () {
function Injector_(view, elDef) {
this.view = view;
this.elDef = elDef;
}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
Injector_.prototype.get = /**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
function (token, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = Injector.THROW_IF_NOT_FOUND;
}
var /** @type {?} */allowPrivateServices = this.elDef ? (this.elDef.flags & 33554432 /* ComponentView */) !== 0 : false;
return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token: token, tokenKey: tokenKey(token) }, notFoundValue);
};
return Injector_;
}();
/**
* @param {?} view
* @param {?} index
* @return {?}
*/
function nodeValue(view, index) {
var /** @type {?} */def = view.def.nodes[index];
if (def.flags & 1 /* TypeElement */) {
var /** @type {?} */elData = asElementData(view, def.nodeIndex);
return (/** @type {?} */def.element.template ? elData.template : elData.renderElement
);
} else if (def.flags & 2 /* TypeText */) {
return asTextData(view, def.nodeIndex).renderText;
} else if (def.flags & (20224 /* CatProvider */ | 16 /* TypePipe */)) {
return asProviderData(view, def.nodeIndex).instance;
}
throw new Error("Illegal state: read nodeValue for node index " + index);
}
/**
* @param {?} view
* @return {?}
*/
function createRendererV1(view) {
return new RendererAdapter(view.renderer);
}
var RendererAdapter = /** @class */function () {
function RendererAdapter(delegate) {
this.delegate = delegate;
}
/**
* @param {?} selectorOrNode
* @return {?}
*/
RendererAdapter.prototype.selectRootElement = /**
* @param {?} selectorOrNode
* @return {?}
*/
function (selectorOrNode) {
return this.delegate.selectRootElement(selectorOrNode);
};
/**
* @param {?} parent
* @param {?} namespaceAndName
* @return {?}
*/
RendererAdapter.prototype.createElement = /**
* @param {?} parent
* @param {?} namespaceAndName
* @return {?}
*/
function (parent, namespaceAndName) {
var _a = splitNamespace(namespaceAndName),
ns = _a[0],
name = _a[1];
var /** @type {?} */el = this.delegate.createElement(name, ns);
if (parent) {
this.delegate.appendChild(parent, el);
}
return el;
};
/**
* @param {?} hostElement
* @return {?}
*/
RendererAdapter.prototype.createViewRoot = /**
* @param {?} hostElement
* @return {?}
*/
function (hostElement) {
return hostElement;
};
/**
* @param {?} parentElement
* @return {?}
*/
RendererAdapter.prototype.createTemplateAnchor = /**
* @param {?} parentElement
* @return {?}
*/
function (parentElement) {
var /** @type {?} */comment = this.delegate.createComment('');
if (parentElement) {
this.delegate.appendChild(parentElement, comment);
}
return comment;
};
/**
* @param {?} parentElement
* @param {?} value
* @return {?}
*/
RendererAdapter.prototype.createText = /**
* @param {?} parentElement
* @param {?} value
* @return {?}
*/
function (parentElement, value) {
var /** @type {?} */node = this.delegate.createText(value);
if (parentElement) {
this.delegate.appendChild(parentElement, node);
}
return node;
};
/**
* @param {?} parentElement
* @param {?} nodes
* @return {?}
*/
RendererAdapter.prototype.projectNodes = /**
* @param {?} parentElement
* @param {?} nodes
* @return {?}
*/
function (parentElement, nodes) {
for (var /** @type {?} */i = 0; i < nodes.length; i++) {
this.delegate.appendChild(parentElement, nodes[i]);
}
};
/**
* @param {?} node
* @param {?} viewRootNodes
* @return {?}
*/
RendererAdapter.prototype.attachViewAfter = /**
* @param {?} node
* @param {?} viewRootNodes
* @return {?}
*/
function (node, viewRootNodes) {
var /** @type {?} */parentElement = this.delegate.parentNode(node);
var /** @type {?} */nextSibling = this.delegate.nextSibling(node);
for (var /** @type {?} */i = 0; i < viewRootNodes.length; i++) {
this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
}
};
/**
* @param {?} viewRootNodes
* @return {?}
*/
RendererAdapter.prototype.detachView = /**
* @param {?} viewRootNodes
* @return {?}
*/
function (viewRootNodes) {
for (var /** @type {?} */i = 0; i < viewRootNodes.length; i++) {
var /** @type {?} */node = viewRootNodes[i];
var /** @type {?} */parentElement = this.delegate.parentNode(node);
this.delegate.removeChild(parentElement, node);
}
};
/**
* @param {?} hostElement
* @param {?} viewAllNodes
* @return {?}
*/
RendererAdapter.prototype.destroyView = /**
* @param {?} hostElement
* @param {?} viewAllNodes
* @return {?}
*/
function (hostElement, viewAllNodes) {
for (var /** @type {?} */i = 0; i < viewAllNodes.length; i++) {
/** @type {?} */this.delegate.destroyNode(viewAllNodes[i]);
}
};
/**
* @param {?} renderElement
* @param {?} name
* @param {?} callback
* @return {?}
*/
RendererAdapter.prototype.listen = /**
* @param {?} renderElement
* @param {?} name
* @param {?} callback
* @return {?}
*/
function (renderElement, name, callback) {
return this.delegate.listen(renderElement, name, /** @type {?} */callback);
};
/**
* @param {?} target
* @param {?} name
* @param {?} callback
* @return {?}
*/
RendererAdapter.prototype.listenGlobal = /**
* @param {?} target
* @param {?} name
* @param {?} callback
* @return {?}
*/
function (target, name, callback) {
return this.delegate.listen(target, name, /** @type {?} */callback);
};
/**
* @param {?} renderElement
* @param {?} propertyName
* @param {?} propertyValue
* @return {?}
*/
RendererAdapter.prototype.setElementProperty = /**
* @param {?} renderElement
* @param {?} propertyName
* @param {?} propertyValue
* @return {?}
*/
function (renderElement, propertyName, propertyValue) {
this.delegate.setProperty(renderElement, propertyName, propertyValue);
};
/**
* @param {?} renderElement
* @param {?} namespaceAndName
* @param {?} attributeValue
* @return {?}
*/
RendererAdapter.prototype.setElementAttribute = /**
* @param {?} renderElement
* @param {?} namespaceAndName
* @param {?} attributeValue
* @return {?}
*/
function (renderElement, namespaceAndName, attributeValue) {
var _a = splitNamespace(namespaceAndName),
ns = _a[0],
name = _a[1];
if (attributeValue != null) {
this.delegate.setAttribute(renderElement, name, attributeValue, ns);
} else {
this.delegate.removeAttribute(renderElement, name, ns);
}
};
/**
* @param {?} renderElement
* @param {?} propertyName
* @param {?} propertyValue
* @return {?}
*/
RendererAdapter.prototype.setBindingDebugInfo = /**
* @param {?} renderElement
* @param {?} propertyName
* @param {?} propertyValue
* @return {?}
*/
function (renderElement, propertyName, propertyValue) {};
/**
* @param {?} renderElement
* @param {?} className
* @param {?} isAdd
* @return {?}
*/
RendererAdapter.prototype.setElementClass = /**
* @param {?} renderElement
* @param {?} className
* @param {?} isAdd
* @return {?}
*/
function (renderElement, className, isAdd) {
if (isAdd) {
this.delegate.addClass(renderElement, className);
} else {
this.delegate.removeClass(renderElement, className);
}
};
/**
* @param {?} renderElement
* @param {?} styleName
* @param {?} styleValue
* @return {?}
*/
RendererAdapter.prototype.setElementStyle = /**
* @param {?} renderElement
* @param {?} styleName
* @param {?} styleValue
* @return {?}
*/
function (renderElement, styleName, styleValue) {
if (styleValue != null) {
this.delegate.setStyle(renderElement, styleName, styleValue);
} else {
this.delegate.removeStyle(renderElement, styleName);
}
};
/**
* @param {?} renderElement
* @param {?} methodName
* @param {?} args
* @return {?}
*/
RendererAdapter.prototype.invokeElementMethod = /**
* @param {?} renderElement
* @param {?} methodName
* @param {?} args
* @return {?}
*/
function (renderElement, methodName, args) {
/** @type {?} */renderElement[methodName].apply(renderElement, args);
};
/**
* @param {?} renderNode
* @param {?} text
* @return {?}
*/
RendererAdapter.prototype.setText = /**
* @param {?} renderNode
* @param {?} text
* @return {?}
*/
function (renderNode$$1, text) {
this.delegate.setValue(renderNode$$1, text);
};
/**
* @return {?}
*/
RendererAdapter.prototype.animate = /**
* @return {?}
*/
function () {
throw new Error('Renderer.animate is no longer supported!');
};
return RendererAdapter;
}();
/**
* @param {?} moduleType
* @param {?} parent
* @param {?} bootstrapComponents
* @param {?} def
* @return {?}
*/
function createNgModuleRef(moduleType, parent, bootstrapComponents, def) {
return new NgModuleRef_(moduleType, parent, bootstrapComponents, def);
}
var NgModuleRef_ = /** @class */function () {
function NgModuleRef_(_moduleType, _parent, _bootstrapComponents, _def) {
this._moduleType = _moduleType;
this._parent = _parent;
this._bootstrapComponents = _bootstrapComponents;
this._def = _def;
this._destroyListeners = [];
this._destroyed = false;
initNgModule(this);
}
/**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
NgModuleRef_.prototype.get = /**
* @param {?} token
* @param {?=} notFoundValue
* @return {?}
*/
function (token, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = Injector.THROW_IF_NOT_FOUND;
}
return resolveNgModuleDep(this, { token: token, tokenKey: tokenKey(token), flags: 0 /* None */ }, notFoundValue);
};
Object.defineProperty(NgModuleRef_.prototype, "instance", {
get: /**
* @return {?}
*/
function () {
return this.get(this._moduleType);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgModuleRef_.prototype, "componentFactoryResolver", {
get: /**
* @return {?}
*/
function () {
return this.get(ComponentFactoryResolver);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgModuleRef_.prototype, "injector", {
get: /**
* @return {?}
*/
function () {
return this;
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgModuleRef_.prototype.destroy = /**
* @return {?}
*/
function () {
if (this._destroyed) {
throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
}
this._destroyed = true;
callNgModuleLifecycle(this, 131072 /* OnDestroy */);
this._destroyListeners.forEach(function (listener) {
return listener();
});
};
/**
* @param {?} callback
* @return {?}
*/
NgModuleRef_.prototype.onDestroy = /**
* @param {?} callback
* @return {?}
*/
function (callback) {
this._destroyListeners.push(callback);
};
return NgModuleRef_;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var RendererV1TokenKey = tokenKey(Renderer);
var Renderer2TokenKey = tokenKey(Renderer2);
var ElementRefTokenKey = tokenKey(ElementRef);
var ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
var TemplateRefTokenKey = tokenKey(TemplateRef);
var ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
var InjectorRefTokenKey = tokenKey(Injector);
/**
* @param {?} checkIndex
* @param {?} flags
* @param {?} matchedQueries
* @param {?} childCount
* @param {?} ctor
* @param {?} deps
* @param {?=} props
* @param {?=} outputs
* @return {?}
*/
function directiveDef(checkIndex, flags, matchedQueries, childCount, ctor, deps, props, outputs) {
var /** @type {?} */bindings = [];
if (props) {
for (var /** @type {?} */prop in props) {
var _a = props[prop],
bindingIndex = _a[0],
nonMinifiedName = _a[1];
bindings[bindingIndex] = {
flags: 8 /* TypeProperty */
, name: prop, nonMinifiedName: nonMinifiedName,
ns: null,
securityContext: null,
suffix: null
};
}
}
var /** @type {?} */outputDefs = [];
if (outputs) {
for (var /** @type {?} */propName in outputs) {
outputDefs.push({ type: 1 /* DirectiveOutput */, propName: propName, target: null, eventName: outputs[propName] });
}
}
flags |= 16384 /* TypeDirective */;
return _def(checkIndex, flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
}
/**
* @param {?} flags
* @param {?} ctor
* @param {?} deps
* @return {?}
*/
function pipeDef(flags, ctor, deps) {
flags |= 16 /* TypePipe */;
return _def(-1, flags, null, 0, ctor, ctor, deps);
}
/**
* @param {?} flags
* @param {?} matchedQueries
* @param {?} token
* @param {?} value
* @param {?} deps
* @return {?}
*/
function providerDef(flags, matchedQueries, token, value, deps) {
return _def(-1, flags, matchedQueries, 0, token, value, deps);
}
/**
* @param {?} checkIndex
* @param {?} flags
* @param {?} matchedQueriesDsl
* @param {?} childCount
* @param {?} token
* @param {?} value
* @param {?} deps
* @param {?=} bindings
* @param {?=} outputs
* @return {?}
*/
function _def(checkIndex, flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
var _a = splitMatchedQueriesDsl(matchedQueriesDsl),
matchedQueries = _a.matchedQueries,
references = _a.references,
matchedQueryIds = _a.matchedQueryIds;
if (!outputs) {
outputs = [];
}
if (!bindings) {
bindings = [];
}
// Need to resolve forwardRefs as e.g. for `useValue` we
// lowered the expression and then stopped evaluating it,
// i.e. also didn't unwrap it.
value = resolveForwardRef(value);
var /** @type {?} */depDefs = splitDepsDsl(deps);
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
checkIndex: checkIndex,
flags: flags,
childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references,
ngContentIndex: -1, childCount: childCount, bindings: bindings,
bindingFlags: calcBindingFlags(bindings), outputs: outputs,
element: null,
provider: { token: token, value: value, deps: depDefs },
text: null,
query: null,
ngContent: null
};
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function createProviderInstance(view, def) {
return _createProviderInstance(view, def);
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function createPipeInstance(view, def) {
// deps are looked up from component.
var /** @type {?} */compView = view;
while (compView.parent && !isComponentView(compView)) {
compView = compView.parent;
}
// pipes can see the private services of the component
var /** @type {?} */allowPrivateServices = true;
// pipes are always eager and classes!
return createClass( /** @type {?} */compView.parent, /** @type {?} */viewParentEl(compView), allowPrivateServices, /** @type {?} */def.provider.value, /** @type {?} */def.provider.deps);
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function createDirectiveInstance(view, def) {
// components can see other private services, other directives can't.
var /** @type {?} */allowPrivateServices = (def.flags & 32768 /* Component */) > 0;
// directives are always eager and classes!
var /** @type {?} */instance = createClass(view, /** @type {?} */def.parent, allowPrivateServices, /** @type {?} */def.provider.value, /** @type {?} */def.provider.deps);
if (def.outputs.length) {
for (var /** @type {?} */i = 0; i < def.outputs.length; i++) {
var /** @type {?} */output = def.outputs[i];
var /** @type {?} */subscription = instance[/** @type {?} */output.propName].subscribe(eventHandlerClosure(view, /** @type {?} */def.parent.nodeIndex, output.eventName)); /** @type {?} */
view.disposables[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
}
}
return instance;
}
/**
* @param {?} view
* @param {?} index
* @param {?} eventName
* @return {?}
*/
function eventHandlerClosure(view, index, eventName) {
return function (event) {
return dispatchEvent(view, index, eventName, event);
};
}
/**
* @param {?} view
* @param {?} def
* @param {?} v0
* @param {?} v1
* @param {?} v2
* @param {?} v3
* @param {?} v4
* @param {?} v5
* @param {?} v6
* @param {?} v7
* @param {?} v8
* @param {?} v9
* @return {?}
*/
function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */providerData = asProviderData(view, def.nodeIndex);
var /** @type {?} */directive = providerData.instance;
var /** @type {?} */changed = false;
var /** @type {?} */changes = /** @type {?} */undefined;
var /** @type {?} */bindLen = def.bindings.length;
if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
changed = true;
changes = updateProp(view, providerData, def, 0, v0, changes);
}
if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
changed = true;
changes = updateProp(view, providerData, def, 1, v1, changes);
}
if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
changed = true;
changes = updateProp(view, providerData, def, 2, v2, changes);
}
if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
changed = true;
changes = updateProp(view, providerData, def, 3, v3, changes);
}
if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
changed = true;
changes = updateProp(view, providerData, def, 4, v4, changes);
}
if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
changed = true;
changes = updateProp(view, providerData, def, 5, v5, changes);
}
if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
changed = true;
changes = updateProp(view, providerData, def, 6, v6, changes);
}
if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
changed = true;
changes = updateProp(view, providerData, def, 7, v7, changes);
}
if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
changed = true;
changes = updateProp(view, providerData, def, 8, v8, changes);
}
if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
changed = true;
changes = updateProp(view, providerData, def, 9, v9, changes);
}
if (changes) {
directive.ngOnChanges(changes);
}
if (def.flags & 65536 /* OnInit */ && shouldCallLifecycleInitHook(view, 256 /* InitState_CallingOnInit */, def.nodeIndex)) {
directive.ngOnInit();
}
if (def.flags & 262144 /* DoCheck */) {
directive.ngDoCheck();
}
return changed;
}
/**
* @param {?} view
* @param {?} def
* @param {?} values
* @return {?}
*/
function checkAndUpdateDirectiveDynamic(view, def, values) {
var /** @type {?} */providerData = asProviderData(view, def.nodeIndex);
var /** @type {?} */directive = providerData.instance;
var /** @type {?} */changed = false;
var /** @type {?} */changes = /** @type {?} */undefined;
for (var /** @type {?} */i = 0; i < values.length; i++) {
if (checkBinding(view, def, i, values[i])) {
changed = true;
changes = updateProp(view, providerData, def, i, values[i], changes);
}
}
if (changes) {
directive.ngOnChanges(changes);
}
if (def.flags & 65536 /* OnInit */ && shouldCallLifecycleInitHook(view, 256 /* InitState_CallingOnInit */, def.nodeIndex)) {
directive.ngOnInit();
}
if (def.flags & 262144 /* DoCheck */) {
directive.ngDoCheck();
}
return changed;
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function _createProviderInstance(view, def) {
// private services can see other private services
var /** @type {?} */allowPrivateServices = (def.flags & 8192 /* PrivateProvider */) > 0;
var /** @type {?} */providerDef = def.provider;
switch (def.flags & 201347067 /* Types */) {case 512 /* TypeClassProvider */:
return createClass(view, /** @type {?} */def.parent, allowPrivateServices, /** @type {?} */providerDef.value, /** @type {?} */providerDef.deps);
case 1024 /* TypeFactoryProvider */:
return callFactory(view, /** @type {?} */def.parent, allowPrivateServices, /** @type {?} */providerDef.value, /** @type {?} */providerDef.deps);
case 2048 /* TypeUseExistingProvider */:
return resolveDep(view, /** @type {?} */def.parent, allowPrivateServices, /** @type {?} */providerDef.deps[0]);
case 256 /* TypeValueProvider */:
return (/** @type {?} */providerDef.value
);
}
}
/**
* @param {?} view
* @param {?} elDef
* @param {?} allowPrivateServices
* @param {?} ctor
* @param {?} deps
* @return {?}
*/
function createClass(view, elDef, allowPrivateServices, ctor, deps) {
var /** @type {?} */len = deps.length;
switch (len) {
case 0:
return new ctor();
case 1:
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
case 2:
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
case 3:
return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
default:
var /** @type {?} */depValues = new Array(len);
for (var /** @type {?} */i = 0; i < len; i++) {
depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
}
return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
}
}
/**
* @param {?} view
* @param {?} elDef
* @param {?} allowPrivateServices
* @param {?} factory
* @param {?} deps
* @return {?}
*/
function callFactory(view, elDef, allowPrivateServices, factory, deps) {
var /** @type {?} */len = deps.length;
switch (len) {
case 0:
return factory();
case 1:
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
case 2:
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
case 3:
return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
default:
var /** @type {?} */depValues = Array(len);
for (var /** @type {?} */i = 0; i < len; i++) {
depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
}
return factory.apply(void 0, depValues);
}
}
// This default value is when checking the hierarchy for a token.
//
// It means both:
// - the token is not provided by the current injector,
// - only the element injectors should be checked (ie do not check module injectors
//
// mod1
// /
// el1 mod2
// \ /
// el2
//
// When requesting el2.injector.get(token), we should check in the following order and return the
// first found value:
// - el2.injector.get(token, default)
// - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
// - mod2.injector.get(token, default)
var NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
/**
* @param {?} view
* @param {?} elDef
* @param {?} allowPrivateServices
* @param {?} depDef
* @param {?=} notFoundValue
* @return {?}
*/
function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue) {
if (notFoundValue === void 0) {
notFoundValue = Injector.THROW_IF_NOT_FOUND;
}
if (depDef.flags & 8 /* Value */) {
return depDef.token;
}
var /** @type {?} */startView = view;
if (depDef.flags & 2 /* Optional */) {
notFoundValue = null;
}
var /** @type {?} */tokenKey$$1 = depDef.tokenKey;
if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
// directives on the same element as a component should be able to control the change detector
// of that component as well.
allowPrivateServices = !!(elDef && /** @type {?} */elDef.element.componentView);
}
if (elDef && depDef.flags & 1 /* SkipSelf */) {
allowPrivateServices = false;
elDef = /** @type {?} */elDef.parent;
}
while (view) {
if (elDef) {
switch (tokenKey$$1) {
case RendererV1TokenKey:
{
var /** @type {?} */compView = findCompView(view, elDef, allowPrivateServices);
return createRendererV1(compView);
}
case Renderer2TokenKey:
{
var /** @type {?} */compView = findCompView(view, elDef, allowPrivateServices);
return compView.renderer;
}
case ElementRefTokenKey:
return new ElementRef(asElementData(view, elDef.nodeIndex).renderElement);
case ViewContainerRefTokenKey:
return asElementData(view, elDef.nodeIndex).viewContainer;
case TemplateRefTokenKey:
{
if ( /** @type {?} */elDef.element.template) {
return asElementData(view, elDef.nodeIndex).template;
}
break;
}
case ChangeDetectorRefTokenKey:
{
var /** @type {?} */cdView = findCompView(view, elDef, allowPrivateServices);
return createChangeDetectorRef(cdView);
}
case InjectorRefTokenKey:
return createInjector(view, elDef);
default:
var /** @type {?} */providerDef_1 = /** @type {?} */(allowPrivateServices ? /** @type {?} */elDef.element.allProviders : /** @type {?} */elDef.element.publicProviders)[tokenKey$$1];
if (providerDef_1) {
var /** @type {?} */providerData = asProviderData(view, providerDef_1.nodeIndex);
if (!providerData) {
providerData = { instance: _createProviderInstance(view, providerDef_1) };
view.nodes[providerDef_1.nodeIndex] = /** @type {?} */providerData;
}
return providerData.instance;
}
}
}
allowPrivateServices = isComponentView(view);
elDef = /** @type {?} */viewParentEl(view);
view = /** @type {?} */view.parent;
}
var /** @type {?} */value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR || notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
// Return the value from the root element injector when
// - it provides it
// (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
// - the module injector should not be checked
// (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
return value;
}
return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
}
/**
* @param {?} view
* @param {?} elDef
* @param {?} allowPrivateServices
* @return {?}
*/
function findCompView(view, elDef, allowPrivateServices) {
var /** @type {?} */compView;
if (allowPrivateServices) {
compView = asElementData(view, elDef.nodeIndex).componentView;
} else {
compView = view;
while (compView.parent && !isComponentView(compView)) {
compView = compView.parent;
}
}
return compView;
}
/**
* @param {?} view
* @param {?} providerData
* @param {?} def
* @param {?} bindingIdx
* @param {?} value
* @param {?} changes
* @return {?}
*/
function updateProp(view, providerData, def, bindingIdx, value, changes) {
if (def.flags & 32768 /* Component */) {
var /** @type {?} */compView = asElementData(view, /** @type {?} */def.parent.nodeIndex).componentView;
if (compView.def.flags & 2 /* OnPush */) {
compView.state |= 8 /* ChecksEnabled */;
}
}
var /** @type {?} */binding = def.bindings[bindingIdx];
var /** @type {?} */propName = /** @type {?} */binding.name;
// Note: This is still safe with Closure Compiler as
// the user passed in the property name as an object has to `providerDef`,
// so Closure Compiler will have renamed the property correctly already.
providerData.instance[propName] = value;
if (def.flags & 524288 /* OnChanges */) {
changes = changes || {};
var /** @type {?} */oldValue = view.oldValues[def.bindingIndex + bindingIdx];
if (oldValue instanceof WrappedValue) {
oldValue = oldValue.wrapped;
}
var /** @type {?} */binding_1 = def.bindings[bindingIdx];
changes[/** @type {?} */binding_1.nonMinifiedName] = new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
}
view.oldValues[def.bindingIndex + bindingIdx] = value;
return changes;
}
/**
* @param {?} view
* @param {?} lifecycles
* @return {?}
*/
function callLifecycleHooksChildrenFirst(view, lifecycles) {
if (!(view.def.nodeFlags & lifecycles)) {
return;
}
var /** @type {?} */nodes = view.def.nodes;
var /** @type {?} */initIndex = 0;
for (var /** @type {?} */i = 0; i < nodes.length; i++) {
var /** @type {?} */nodeDef = nodes[i];
var /** @type {?} */parent_1 = nodeDef.parent;
if (!parent_1 && nodeDef.flags & lifecycles) {
// matching root node (e.g. a pipe)
callProviderLifecycles(view, i, nodeDef.flags & lifecycles, initIndex++);
}
if ((nodeDef.childFlags & lifecycles) === 0) {
// no child matches one of the lifecycles
i += nodeDef.childCount;
}
while (parent_1 && parent_1.flags & 1 /* TypeElement */ && i === parent_1.nodeIndex + parent_1.childCount) {
// last child of an element
if (parent_1.directChildFlags & lifecycles) {
initIndex = callElementProvidersLifecycles(view, parent_1, lifecycles, initIndex);
}
parent_1 = parent_1.parent;
}
}
}
/**
* @param {?} view
* @param {?} elDef
* @param {?} lifecycles
* @param {?} initIndex
* @return {?}
*/
function callElementProvidersLifecycles(view, elDef, lifecycles, initIndex) {
for (var /** @type {?} */i = elDef.nodeIndex + 1; i <= elDef.nodeIndex + elDef.childCount; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & lifecycles) {
callProviderLifecycles(view, i, nodeDef.flags & lifecycles, initIndex++);
}
// only visit direct children
i += nodeDef.childCount;
}
return initIndex;
}
/**
* @param {?} view
* @param {?} index
* @param {?} lifecycles
* @param {?} initIndex
* @return {?}
*/
function callProviderLifecycles(view, index, lifecycles, initIndex) {
var /** @type {?} */providerData = asProviderData(view, index);
if (!providerData) {
return;
}
var /** @type {?} */provider = providerData.instance;
if (!provider) {
return;
}
Services.setCurrentNode(view, index);
if (lifecycles & 1048576 /* AfterContentInit */ && shouldCallLifecycleInitHook(view, 512 /* InitState_CallingAfterContentInit */, initIndex)) {
provider.ngAfterContentInit();
}
if (lifecycles & 2097152 /* AfterContentChecked */) {
provider.ngAfterContentChecked();
}
if (lifecycles & 4194304 /* AfterViewInit */ && shouldCallLifecycleInitHook(view, 768 /* InitState_CallingAfterViewInit */, initIndex)) {
provider.ngAfterViewInit();
}
if (lifecycles & 8388608 /* AfterViewChecked */) {
provider.ngAfterViewChecked();
}
if (lifecycles & 131072 /* OnDestroy */) {
provider.ngOnDestroy();
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} flags
* @param {?} id
* @param {?} bindings
* @return {?}
*/
function queryDef(flags, id, bindings) {
var /** @type {?} */bindingDefs = [];
for (var /** @type {?} */propName in bindings) {
var /** @type {?} */bindingType = bindings[propName];
bindingDefs.push({ propName: propName, bindingType: bindingType });
}
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
// TODO(vicb): check
checkIndex: -1, flags: flags,
childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0,
ngContentIndex: -1,
matchedQueries: {},
matchedQueryIds: 0,
references: {},
childCount: 0,
bindings: [],
bindingFlags: 0,
outputs: [],
element: null,
provider: null,
text: null,
query: { id: id, filterId: filterQueryId(id), bindings: bindingDefs },
ngContent: null
};
}
/**
* @return {?}
*/
function createQuery() {
return new QueryList();
}
/**
* @param {?} view
* @return {?}
*/
function dirtyParentQueries(view) {
var /** @type {?} */queryIds = view.def.nodeMatchedQueries;
while (view.parent && isEmbeddedView(view)) {
var /** @type {?} */tplDef = /** @type {?} */view.parentNodeDef;
view = view.parent;
// content queries
var /** @type {?} */end = tplDef.nodeIndex + tplDef.childCount;
for (var /** @type {?} */i = 0; i <= end; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & 67108864 /* TypeContentQuery */ && nodeDef.flags & 536870912 /* DynamicQuery */ && ( /** @type {?} */nodeDef.query.filterId & queryIds) === /** @type {?} */nodeDef.query.filterId) {
asQueryList(view, i).setDirty();
}
if (nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.nodeIndex || !(nodeDef.childFlags & 67108864 /* TypeContentQuery */) || !(nodeDef.childFlags & 536870912 /* DynamicQuery */)) {
// skip elements that don't contain the template element or no query.
i += nodeDef.childCount;
}
}
}
// view queries
if (view.def.nodeFlags & 134217728 /* TypeViewQuery */) {
for (var /** @type {?} */i = 0; i < view.def.nodes.length; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & 134217728 /* TypeViewQuery */ && nodeDef.flags & 536870912 /* DynamicQuery */) {
asQueryList(view, i).setDirty();
}
// only visit the root nodes
i += nodeDef.childCount;
}
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @return {?}
*/
function checkAndUpdateQuery(view, nodeDef) {
var /** @type {?} */queryList = asQueryList(view, nodeDef.nodeIndex);
if (!queryList.dirty) {
return;
}
var /** @type {?} */directiveInstance;
var /** @type {?} */newValues = /** @type {?} */undefined;
if (nodeDef.flags & 67108864 /* TypeContentQuery */) {
var /** @type {?} */elementDef = /** @type {?} */ /** @type {?} */nodeDef.parent.parent;
newValues = calcQueryValues(view, elementDef.nodeIndex, elementDef.nodeIndex + elementDef.childCount, /** @type {?} */nodeDef.query, []);
directiveInstance = asProviderData(view, /** @type {?} */nodeDef.parent.nodeIndex).instance;
} else if (nodeDef.flags & 134217728 /* TypeViewQuery */) {
newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */nodeDef.query, []);
directiveInstance = view.component;
}
queryList.reset(newValues);
var /** @type {?} */bindings = /** @type {?} */nodeDef.query.bindings;
var /** @type {?} */notify = false;
for (var /** @type {?} */i = 0; i < bindings.length; i++) {
var /** @type {?} */binding = bindings[i];
var /** @type {?} */boundValue = void 0;
switch (binding.bindingType) {
case 0 /* First */:
boundValue = queryList.first;
break;
case 1 /* All */:
boundValue = queryList;
notify = true;
break;
}
directiveInstance[binding.propName] = boundValue;
}
if (notify) {
queryList.notifyOnChanges();
}
}
/**
* @param {?} view
* @param {?} startIndex
* @param {?} endIndex
* @param {?} queryDef
* @param {?} values
* @return {?}
*/
function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
for (var /** @type {?} */i = startIndex; i <= endIndex; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
var /** @type {?} */valueType = nodeDef.matchedQueries[queryDef.id];
if (valueType != null) {
values.push(getQueryValue(view, nodeDef, valueType));
}
if (nodeDef.flags & 1 /* TypeElement */ && /** @type {?} */nodeDef.element.template && ( /** @type {?} */ /** @type {?} */nodeDef.element.template.nodeMatchedQueries & queryDef.filterId) === queryDef.filterId) {
var /** @type {?} */elementData = asElementData(view, i);
// check embedded views that were attached at the place of their template,
// but process child nodes first if some match the query (see issue #16568)
if ((nodeDef.childMatchedQueries & queryDef.filterId) === queryDef.filterId) {
calcQueryValues(view, i + 1, i + nodeDef.childCount, queryDef, values);
i += nodeDef.childCount;
}
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
var /** @type {?} */embeddedViews = /** @type {?} */elementData.viewContainer._embeddedViews;
for (var /** @type {?} */k = 0; k < embeddedViews.length; k++) {
var /** @type {?} */embeddedView = embeddedViews[k];
var /** @type {?} */dvc = declaredViewContainer(embeddedView);
if (dvc && dvc === elementData) {
calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
}
}
}
var /** @type {?} */projectedViews = elementData.template._projectedViews;
if (projectedViews) {
for (var /** @type {?} */k = 0; k < projectedViews.length; k++) {
var /** @type {?} */projectedView = projectedViews[k];
calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
}
}
}
if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
// if no child matches the query, skip the children.
i += nodeDef.childCount;
}
}
return values;
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} queryValueType
* @return {?}
*/
function getQueryValue(view, nodeDef, queryValueType) {
if (queryValueType != null) {
// a match
switch (queryValueType) {
case 1 /* RenderElement */:
return asElementData(view, nodeDef.nodeIndex).renderElement;
case 0 /* ElementRef */:
return new ElementRef(asElementData(view, nodeDef.nodeIndex).renderElement);
case 2 /* TemplateRef */:
return asElementData(view, nodeDef.nodeIndex).template;
case 3 /* ViewContainerRef */:
return asElementData(view, nodeDef.nodeIndex).viewContainer;
case 4 /* Provider */:
return asProviderData(view, nodeDef.nodeIndex).instance;
}
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} ngContentIndex
* @param {?} index
* @return {?}
*/
function ngContentDef(ngContentIndex, index) {
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
checkIndex: -1,
flags: 8 /* TypeNgContent */
, childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0,
matchedQueries: {},
matchedQueryIds: 0,
references: {}, ngContentIndex: ngContentIndex,
childCount: 0,
bindings: [],
bindingFlags: 0,
outputs: [],
element: null,
provider: null,
text: null,
query: null,
ngContent: { index: index }
};
}
/**
* @param {?} view
* @param {?} renderHost
* @param {?} def
* @return {?}
*/
function appendNgContent(view, renderHost, def) {
var /** @type {?} */parentEl = getParentRenderElement(view, renderHost, def);
if (!parentEl) {
// Nothing to do if there is no parent element.
return;
}
var /** @type {?} */ngContentIndex = /** @type {?} */def.ngContent.index;
visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} checkIndex
* @param {?} argCount
* @return {?}
*/
function purePipeDef(checkIndex, argCount) {
// argCount + 1 to include the pipe as first arg
return _pureExpressionDef(128 /* TypePurePipe */, checkIndex, new Array(argCount + 1));
}
/**
* @param {?} checkIndex
* @param {?} argCount
* @return {?}
*/
function pureArrayDef(checkIndex, argCount) {
return _pureExpressionDef(32 /* TypePureArray */, checkIndex, new Array(argCount));
}
/**
* @param {?} checkIndex
* @param {?} propToIndex
* @return {?}
*/
function pureObjectDef(checkIndex, propToIndex) {
var /** @type {?} */keys = Object.keys(propToIndex);
var /** @type {?} */nbKeys = keys.length;
var /** @type {?} */propertyNames = new Array(nbKeys);
for (var /** @type {?} */i = 0; i < nbKeys; i++) {
var /** @type {?} */key = keys[i];
var /** @type {?} */index = propToIndex[key];
propertyNames[index] = key;
}
return _pureExpressionDef(64 /* TypePureObject */, checkIndex, propertyNames);
}
/**
* @param {?} flags
* @param {?} checkIndex
* @param {?} propertyNames
* @return {?}
*/
function _pureExpressionDef(flags, checkIndex, propertyNames) {
var /** @type {?} */bindings = new Array(propertyNames.length);
for (var /** @type {?} */i = 0; i < propertyNames.length; i++) {
var /** @type {?} */prop = propertyNames[i];
bindings[i] = {
flags: 8 /* TypeProperty */
, name: prop,
ns: null,
nonMinifiedName: prop,
securityContext: null,
suffix: null
};
}
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
checkIndex: checkIndex,
flags: flags,
childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0,
matchedQueries: {},
matchedQueryIds: 0,
references: {},
ngContentIndex: -1,
childCount: 0, bindings: bindings,
bindingFlags: calcBindingFlags(bindings),
outputs: [],
element: null,
provider: null,
text: null,
query: null,
ngContent: null
};
}
/**
* @param {?} view
* @param {?} def
* @return {?}
*/
function createPureExpression(view, def) {
return { value: undefined };
}
/**
* @param {?} view
* @param {?} def
* @param {?} v0
* @param {?} v1
* @param {?} v2
* @param {?} v3
* @param {?} v4
* @param {?} v5
* @param {?} v6
* @param {?} v7
* @param {?} v8
* @param {?} v9
* @return {?}
*/
function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */bindings = def.bindings;
var /** @type {?} */changed = false;
var /** @type {?} */bindLen = bindings.length;
if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0)) changed = true;
if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1)) changed = true;
if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2)) changed = true;
if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3)) changed = true;
if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4)) changed = true;
if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5)) changed = true;
if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6)) changed = true;
if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7)) changed = true;
if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8)) changed = true;
if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9)) changed = true;
if (changed) {
var /** @type {?} */data = asPureExpressionData(view, def.nodeIndex);
var /** @type {?} */value = void 0;
switch (def.flags & 201347067 /* Types */) {case 32 /* TypePureArray */:
value = new Array(bindings.length);
if (bindLen > 0) value[0] = v0;
if (bindLen > 1) value[1] = v1;
if (bindLen > 2) value[2] = v2;
if (bindLen > 3) value[3] = v3;
if (bindLen > 4) value[4] = v4;
if (bindLen > 5) value[5] = v5;
if (bindLen > 6) value[6] = v6;
if (bindLen > 7) value[7] = v7;
if (bindLen > 8) value[8] = v8;
if (bindLen > 9) value[9] = v9;
break;
case 64 /* TypePureObject */:
value = {};
if (bindLen > 0) value[/** @type {?} */bindings[0].name] = v0;
if (bindLen > 1) value[/** @type {?} */bindings[1].name] = v1;
if (bindLen > 2) value[/** @type {?} */bindings[2].name] = v2;
if (bindLen > 3) value[/** @type {?} */bindings[3].name] = v3;
if (bindLen > 4) value[/** @type {?} */bindings[4].name] = v4;
if (bindLen > 5) value[/** @type {?} */bindings[5].name] = v5;
if (bindLen > 6) value[/** @type {?} */bindings[6].name] = v6;
if (bindLen > 7) value[/** @type {?} */bindings[7].name] = v7;
if (bindLen > 8) value[/** @type {?} */bindings[8].name] = v8;
if (bindLen > 9) value[/** @type {?} */bindings[9].name] = v9;
break;
case 128 /* TypePurePipe */:
var /** @type {?} */pipe = v0;
switch (bindLen) {
case 1:
value = pipe.transform(v0);
break;
case 2:
value = pipe.transform(v1);
break;
case 3:
value = pipe.transform(v1, v2);
break;
case 4:
value = pipe.transform(v1, v2, v3);
break;
case 5:
value = pipe.transform(v1, v2, v3, v4);
break;
case 6:
value = pipe.transform(v1, v2, v3, v4, v5);
break;
case 7:
value = pipe.transform(v1, v2, v3, v4, v5, v6);
break;
case 8:
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
break;
case 9:
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
break;
case 10:
value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
break;
}
break;
}
data.value = value;
}
return changed;
}
/**
* @param {?} view
* @param {?} def
* @param {?} values
* @return {?}
*/
function checkAndUpdatePureExpressionDynamic(view, def, values) {
var /** @type {?} */bindings = def.bindings;
var /** @type {?} */changed = false;
for (var /** @type {?} */i = 0; i < values.length; i++) {
// Note: We need to loop over all values, so that
// the old values are updates as well!
if (checkAndUpdateBinding(view, def, i, values[i])) {
changed = true;
}
}
if (changed) {
var /** @type {?} */data = asPureExpressionData(view, def.nodeIndex);
var /** @type {?} */value = void 0;
switch (def.flags & 201347067 /* Types */) {case 32 /* TypePureArray */:
value = values;
break;
case 64 /* TypePureObject */:
value = {};
for (var /** @type {?} */i = 0; i < values.length; i++) {
value[/** @type {?} */bindings[i].name] = values[i];
}
break;
case 128 /* TypePurePipe */:
var /** @type {?} */pipe = values[0];
var /** @type {?} */params = values.slice(1);
value = pipe.transform.apply(pipe, params);
break;
}
data.value = value;
}
return changed;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} checkIndex
* @param {?} ngContentIndex
* @param {?} staticText
* @return {?}
*/
function textDef(checkIndex, ngContentIndex, staticText) {
var /** @type {?} */bindings = new Array(staticText.length - 1);
for (var /** @type {?} */i = 1; i < staticText.length; i++) {
bindings[i - 1] = {
flags: 8 /* TypeProperty */
, name: null,
ns: null,
nonMinifiedName: null,
securityContext: null,
suffix: staticText[i]
};
}
return {
// will bet set by the view definition
nodeIndex: -1,
parent: null,
renderParent: null,
bindingIndex: -1,
outputIndex: -1,
// regular values
checkIndex: checkIndex,
flags: 2 /* TypeText */
, childFlags: 0,
directChildFlags: 0,
childMatchedQueries: 0,
matchedQueries: {},
matchedQueryIds: 0,
references: {}, ngContentIndex: ngContentIndex,
childCount: 0, bindings: bindings,
bindingFlags: 8 /* TypeProperty */
, outputs: [],
element: null,
provider: null,
text: { prefix: staticText[0] },
query: null,
ngContent: null
};
}
/**
* @param {?} view
* @param {?} renderHost
* @param {?} def
* @return {?}
*/
function createText(view, renderHost, def) {
var /** @type {?} */renderNode$$1;
var /** @type {?} */renderer = view.renderer;
renderNode$$1 = renderer.createText( /** @type {?} */def.text.prefix);
var /** @type {?} */parentEl = getParentRenderElement(view, renderHost, def);
if (parentEl) {
renderer.appendChild(parentEl, renderNode$$1);
}
return { renderText: renderNode$$1 };
}
/**
* @param {?} view
* @param {?} def
* @param {?} v0
* @param {?} v1
* @param {?} v2
* @param {?} v3
* @param {?} v4
* @param {?} v5
* @param {?} v6
* @param {?} v7
* @param {?} v8
* @param {?} v9
* @return {?}
*/
function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */changed = false;
var /** @type {?} */bindings = def.bindings;
var /** @type {?} */bindLen = bindings.length;
if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0)) changed = true;
if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1)) changed = true;
if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2)) changed = true;
if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3)) changed = true;
if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4)) changed = true;
if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5)) changed = true;
if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6)) changed = true;
if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7)) changed = true;
if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8)) changed = true;
if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9)) changed = true;
if (changed) {
var /** @type {?} */value = /** @type {?} */def.text.prefix;
if (bindLen > 0) value += _addInterpolationPart(v0, bindings[0]);
if (bindLen > 1) value += _addInterpolationPart(v1, bindings[1]);
if (bindLen > 2) value += _addInterpolationPart(v2, bindings[2]);
if (bindLen > 3) value += _addInterpolationPart(v3, bindings[3]);
if (bindLen > 4) value += _addInterpolationPart(v4, bindings[4]);
if (bindLen > 5) value += _addInterpolationPart(v5, bindings[5]);
if (bindLen > 6) value += _addInterpolationPart(v6, bindings[6]);
if (bindLen > 7) value += _addInterpolationPart(v7, bindings[7]);
if (bindLen > 8) value += _addInterpolationPart(v8, bindings[8]);
if (bindLen > 9) value += _addInterpolationPart(v9, bindings[9]);
var /** @type {?} */renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
view.renderer.setValue(renderNode$$1, value);
}
return changed;
}
/**
* @param {?} view
* @param {?} def
* @param {?} values
* @return {?}
*/
function checkAndUpdateTextDynamic(view, def, values) {
var /** @type {?} */bindings = def.bindings;
var /** @type {?} */changed = false;
for (var /** @type {?} */i = 0; i < values.length; i++) {
// Note: We need to loop over all values, so that
// the old values are updates as well!
if (checkAndUpdateBinding(view, def, i, values[i])) {
changed = true;
}
}
if (changed) {
var /** @type {?} */value = '';
for (var /** @type {?} */i = 0; i < values.length; i++) {
value = value + _addInterpolationPart(values[i], bindings[i]);
}
value = /** @type {?} */def.text.prefix + value;
var /** @type {?} */renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
view.renderer.setValue(renderNode$$1, value);
}
return changed;
}
/**
* @param {?} value
* @param {?} binding
* @return {?}
*/
function _addInterpolationPart(value, binding) {
var /** @type {?} */valueStr = value != null ? value.toString() : '';
return valueStr + binding.suffix;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} flags
* @param {?} nodes
* @param {?=} updateDirectives
* @param {?=} updateRenderer
* @return {?}
*/
function viewDef(flags, nodes, updateDirectives, updateRenderer) {
// clone nodes and set auto calculated values
var /** @type {?} */viewBindingCount = 0;
var /** @type {?} */viewDisposableCount = 0;
var /** @type {?} */viewNodeFlags = 0;
var /** @type {?} */viewRootNodeFlags = 0;
var /** @type {?} */viewMatchedQueries = 0;
var /** @type {?} */currentParent = null;
var /** @type {?} */currentRenderParent = null;
var /** @type {?} */currentElementHasPublicProviders = false;
var /** @type {?} */currentElementHasPrivateProviders = false;
var /** @type {?} */lastRenderRootNode = null;
for (var /** @type {?} */i = 0; i < nodes.length; i++) {
var /** @type {?} */node = nodes[i];
node.nodeIndex = i;
node.parent = currentParent;
node.bindingIndex = viewBindingCount;
node.outputIndex = viewDisposableCount;
node.renderParent = currentRenderParent;
viewNodeFlags |= node.flags;
viewMatchedQueries |= node.matchedQueryIds;
if (node.element) {
var /** @type {?} */elDef = node.element;
elDef.publicProviders = currentParent ? /** @type {?} */currentParent.element.publicProviders : Object.create(null);
elDef.allProviders = elDef.publicProviders;
// Note: We assume that all providers of an element are before any child element!
currentElementHasPublicProviders = false;
currentElementHasPrivateProviders = false;
if (node.element.template) {
viewMatchedQueries |= node.element.template.nodeMatchedQueries;
}
}
validateNode(currentParent, node, nodes.length);
viewBindingCount += node.bindings.length;
viewDisposableCount += node.outputs.length;
if (!currentRenderParent && node.flags & 3 /* CatRenderNode */) {
lastRenderRootNode = node;
}
if (node.flags & 20224 /* CatProvider */) {
if (!currentElementHasPublicProviders) {
currentElementHasPublicProviders = true; /** @type {?} */
/** @type {?} */currentParent.element.publicProviders = Object.create( /** @type {?} */ /** @type {?} */currentParent.element.publicProviders); /** @type {?} */
/** @type {?} */currentParent.element.allProviders = /** @type {?} */ /** @type {?} */currentParent.element.publicProviders;
}
var /** @type {?} */isPrivateService = (node.flags & 8192 /* PrivateProvider */) !== 0;
var /** @type {?} */isComponent = (node.flags & 32768 /* Component */) !== 0;
if (!isPrivateService || isComponent) {
/** @type {?} */ /** @type {?} */ /** @type {?} */currentParent.element.publicProviders[tokenKey( /** @type {?} */node.provider.token)] = node;
} else {
if (!currentElementHasPrivateProviders) {
currentElementHasPrivateProviders = true; /** @type {?} */
/** @type {?} */currentParent.element.allProviders = Object.create( /** @type {?} */ /** @type {?} */currentParent.element.publicProviders);
} /** @type {?} */
/** @type {?} */ /** @type {?} */currentParent.element.allProviders[tokenKey( /** @type {?} */node.provider.token)] = node;
}
if (isComponent) {
/** @type {?} */ /** @type {?} */currentParent.element.componentProvider = node;
}
}
if (currentParent) {
currentParent.childFlags |= node.flags;
currentParent.directChildFlags |= node.flags;
currentParent.childMatchedQueries |= node.matchedQueryIds;
if (node.element && node.element.template) {
currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
}
} else {
viewRootNodeFlags |= node.flags;
}
if (node.childCount > 0) {
currentParent = node;
if (!isNgContainer(node)) {
currentRenderParent = node;
}
} else {
// When the current node has no children, check if it is the last children of its parent.
// When it is, propagate the flags up.
// The loop is required because an element could be the last transitive children of several
// elements. We loop to either the root or the highest opened element (= with remaining
// children)
while (currentParent && i === currentParent.nodeIndex + currentParent.childCount) {
var /** @type {?} */newParent = currentParent.parent;
if (newParent) {
newParent.childFlags |= currentParent.childFlags;
newParent.childMatchedQueries |= currentParent.childMatchedQueries;
}
currentParent = newParent;
// We also need to update the render parent & account for ng-container
if (currentParent && isNgContainer(currentParent)) {
currentRenderParent = currentParent.renderParent;
} else {
currentRenderParent = currentParent;
}
}
}
}
var /** @type {?} */handleEvent = function (view, nodeIndex, eventName, event) {
return (/** @type {?} */nodes[nodeIndex].element.handleEvent(view, eventName, event)
);
};
return {
// Will be filled later...
factory: null,
nodeFlags: viewNodeFlags,
rootNodeFlags: viewRootNodeFlags,
nodeMatchedQueries: viewMatchedQueries, flags: flags,
nodes: nodes,
updateDirectives: updateDirectives || NOOP,
updateRenderer: updateRenderer || NOOP, handleEvent: handleEvent,
bindingCount: viewBindingCount,
outputCount: viewDisposableCount, lastRenderRootNode: lastRenderRootNode
};
}
/**
* @param {?} node
* @return {?}
*/
function isNgContainer(node) {
return (node.flags & 1 /* TypeElement */) !== 0 && /** @type {?} */node.element.name === null;
}
/**
* @param {?} parent
* @param {?} node
* @param {?} nodeCount
* @return {?}
*/
function validateNode(parent, node, nodeCount) {
var /** @type {?} */template = node.element && node.element.template;
if (template) {
if (!template.lastRenderRootNode) {
throw new Error("Illegal State: Embedded templates without nodes are not allowed!");
}
if (template.lastRenderRootNode && template.lastRenderRootNode.flags & 16777216 /* EmbeddedViews */) {
throw new Error("Illegal State: Last root node of a template can't have embedded views, at index " + node.nodeIndex + "!");
}
}
if (node.flags & 20224 /* CatProvider */) {
var /** @type {?} */parentFlags = parent ? parent.flags : 0;
if ((parentFlags & 1 /* TypeElement */) === 0) {
throw new Error("Illegal State: StaticProvider/Directive nodes need to be children of elements or anchors, at index " + node.nodeIndex + "!");
}
}
if (node.query) {
if (node.flags & 67108864 /* TypeContentQuery */ && (!parent || (parent.flags & 16384 /* TypeDirective */) === 0)) {
throw new Error("Illegal State: Content Query nodes need to be children of directives, at index " + node.nodeIndex + "!");
}
if (node.flags & 134217728 /* TypeViewQuery */ && parent) {
throw new Error("Illegal State: View Query nodes have to be top level nodes, at index " + node.nodeIndex + "!");
}
}
if (node.childCount) {
var /** @type {?} */parentEnd = parent ? parent.nodeIndex + parent.childCount : nodeCount - 1;
if (node.nodeIndex <= parentEnd && node.nodeIndex + node.childCount > parentEnd) {
throw new Error("Illegal State: childCount of node leads outside of parent, at index " + node.nodeIndex + "!");
}
}
}
/**
* @param {?} parent
* @param {?} anchorDef
* @param {?} viewDef
* @param {?=} context
* @return {?}
*/
function createEmbeddedView(parent, anchorDef$$1, viewDef, context) {
// embedded views are seen as siblings to the anchor, so we need
// to get the parent of the anchor and use it as parentIndex.
var /** @type {?} */view = createView(parent.root, parent.renderer, parent, anchorDef$$1, viewDef);
initView(view, parent.component, context);
createViewNodes(view);
return view;
}
/**
* @param {?} root
* @param {?} def
* @param {?=} context
* @return {?}
*/
function createRootView(root, def, context) {
var /** @type {?} */view = createView(root, root.renderer, null, null, def);
initView(view, context, context);
createViewNodes(view);
return view;
}
/**
* @param {?} parentView
* @param {?} nodeDef
* @param {?} viewDef
* @param {?} hostElement
* @return {?}
*/
function createComponentView(parentView, nodeDef, viewDef, hostElement) {
var /** @type {?} */rendererType = /** @type {?} */nodeDef.element.componentRendererType;
var /** @type {?} */compRenderer;
if (!rendererType) {
compRenderer = parentView.root.renderer;
} else {
compRenderer = parentView.root.rendererFactory.createRenderer(hostElement, rendererType);
}
return createView(parentView.root, compRenderer, parentView, /** @type {?} */nodeDef.element.componentProvider, viewDef);
}
/**
* @param {?} root
* @param {?} renderer
* @param {?} parent
* @param {?} parentNodeDef
* @param {?} def
* @return {?}
*/
function createView(root, renderer, parent, parentNodeDef, def) {
var /** @type {?} */nodes = new Array(def.nodes.length);
var /** @type {?} */disposables = def.outputCount ? new Array(def.outputCount) : null;
var /** @type {?} */view = {
def: def,
parent: parent,
viewContainerParent: null, parentNodeDef: parentNodeDef,
context: null,
component: null, nodes: nodes,
state: 13 /* CatInit */, root: root, renderer: renderer,
oldValues: new Array(def.bindingCount), disposables: disposables,
initIndex: -1
};
return view;
}
/**
* @param {?} view
* @param {?} component
* @param {?} context
* @return {?}
*/
function initView(view, component, context) {
view.component = component;
view.context = context;
}
/**
* @param {?} view
* @return {?}
*/
function createViewNodes(view) {
var /** @type {?} */renderHost;
if (isComponentView(view)) {
var /** @type {?} */hostDef = view.parentNodeDef;
renderHost = asElementData( /** @type {?} */view.parent, /** @type {?} */ /** @type {?} */hostDef.parent.nodeIndex).renderElement;
}
var /** @type {?} */def = view.def;
var /** @type {?} */nodes = view.nodes;
for (var /** @type {?} */i = 0; i < def.nodes.length; i++) {
var /** @type {?} */nodeDef = def.nodes[i];
Services.setCurrentNode(view, i);
var /** @type {?} */nodeData = void 0;
switch (nodeDef.flags & 201347067 /* Types */) {case 1 /* TypeElement */:
var /** @type {?} */el = /** @type {?} */createElement(view, renderHost, nodeDef);
var /** @type {?} */componentView = /** @type {?} */undefined;
if (nodeDef.flags & 33554432 /* ComponentView */) {
var /** @type {?} */compViewDef = resolveDefinition( /** @type {?} */ /** @type {?} */nodeDef.element.componentView);
componentView = Services.createComponentView(view, nodeDef, compViewDef, el);
}
listenToElementOutputs(view, componentView, nodeDef, el);
nodeData = /** @type {?} */{
renderElement: el,
componentView: componentView,
viewContainer: null,
template: /** @type {?} */nodeDef.element.template ? createTemplateData(view, nodeDef) : undefined
};
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
}
break;
case 2 /* TypeText */:
nodeData = /** @type {?} */createText(view, renderHost, nodeDef);
break;
case 512 /* TypeClassProvider */:
case 1024 /* TypeFactoryProvider */:
case 2048 /* TypeUseExistingProvider */:
case 256 /* TypeValueProvider */:
{
nodeData = nodes[i];
if (!nodeData && !(nodeDef.flags & 4096 /* LazyProvider */)) {
var /** @type {?} */instance = createProviderInstance(view, nodeDef);
nodeData = /** @type {?} */{ instance: instance };
}
break;
}
case 16 /* TypePipe */:
{
var /** @type {?} */instance = createPipeInstance(view, nodeDef);
nodeData = /** @type {?} */{ instance: instance };
break;
}
case 16384 /* TypeDirective */:
{
nodeData = nodes[i];
if (!nodeData) {
var /** @type {?} */instance = createDirectiveInstance(view, nodeDef);
nodeData = /** @type {?} */{ instance: instance };
}
if (nodeDef.flags & 32768 /* Component */) {
var /** @type {?} */compView = asElementData(view, /** @type {?} */nodeDef.parent.nodeIndex).componentView;
initView(compView, nodeData.instance, nodeData.instance);
}
break;
}
case 32 /* TypePureArray */:
case 64 /* TypePureObject */:
case 128 /* TypePurePipe */:
nodeData = /** @type {?} */createPureExpression(view, nodeDef);
break;
case 67108864 /* TypeContentQuery */:
case 134217728 /* TypeViewQuery */:
nodeData = /** @type {?} */createQuery();
break;
case 8 /* TypeNgContent */:
appendNgContent(view, renderHost, nodeDef);
// no runtime data needed for NgContent...
nodeData = undefined;
break;
}
nodes[i] = nodeData;
}
// Create the ViewData.nodes of component views after we created everything else,
// so that e.g. ng-content works
execComponentViewsAction(view, ViewAction.CreateViewNodes);
// fill static content and view queries
execQueriesAction(view, 67108864 /* TypeContentQuery */ | 134217728 /* TypeViewQuery */, 268435456 /* StaticQuery */, 0 /* CheckAndUpdate */);
}
/**
* @param {?} view
* @return {?}
*/
function checkNoChangesView(view) {
markProjectedViewsForCheck(view);
Services.updateDirectives(view, 1 /* CheckNoChanges */);
execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
Services.updateRenderer(view, 1 /* CheckNoChanges */);
execComponentViewsAction(view, ViewAction.CheckNoChanges);
// Note: We don't check queries for changes as we didn't do this in v2.x.
// TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
}
/**
* @param {?} view
* @return {?}
*/
function checkAndUpdateView(view) {
if (view.state & 1 /* BeforeFirstCheck */) {
view.state &= ~1 /* BeforeFirstCheck */;
view.state |= 2 /* FirstCheck */;
} else {
view.state &= ~2 /* FirstCheck */;
}
shiftInitState(view, 0 /* InitState_BeforeInit */, 256 /* InitState_CallingOnInit */);
markProjectedViewsForCheck(view);
Services.updateDirectives(view, 0 /* CheckAndUpdate */);
execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
execQueriesAction(view, 67108864 /* TypeContentQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
var /** @type {?} */callInit = shiftInitState(view, 256 /* InitState_CallingOnInit */, 512 /* InitState_CallingAfterContentInit */);
callLifecycleHooksChildrenFirst(view, 2097152 /* AfterContentChecked */ | (callInit ? 1048576 /* AfterContentInit */ : 0));
Services.updateRenderer(view, 0 /* CheckAndUpdate */);
execComponentViewsAction(view, ViewAction.CheckAndUpdate);
execQueriesAction(view, 134217728 /* TypeViewQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
callInit = shiftInitState(view, 512 /* InitState_CallingAfterContentInit */, 768 /* InitState_CallingAfterViewInit */);
callLifecycleHooksChildrenFirst(view, 8388608 /* AfterViewChecked */ | (callInit ? 4194304 /* AfterViewInit */ : 0));
if (view.def.flags & 2 /* OnPush */) {
view.state &= ~8 /* ChecksEnabled */;
}
view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
shiftInitState(view, 768 /* InitState_CallingAfterViewInit */, 1024 /* InitState_AfterInit */);
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} argStyle
* @param {?=} v0
* @param {?=} v1
* @param {?=} v2
* @param {?=} v3
* @param {?=} v4
* @param {?=} v5
* @param {?=} v6
* @param {?=} v7
* @param {?=} v8
* @param {?=} v9
* @return {?}
*/
function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
if (argStyle === 0 /* Inline */) {
return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
} else {
return checkAndUpdateNodeDynamic(view, nodeDef, v0);
}
}
/**
* @param {?} view
* @return {?}
*/
function markProjectedViewsForCheck(view) {
var /** @type {?} */def = view.def;
if (!(def.nodeFlags & 4 /* ProjectedTemplate */)) {
return;
}
for (var /** @type {?} */i = 0; i < def.nodes.length; i++) {
var /** @type {?} */nodeDef = def.nodes[i];
if (nodeDef.flags & 4 /* ProjectedTemplate */) {
var /** @type {?} */projectedViews = asElementData(view, i).template._projectedViews;
if (projectedViews) {
for (var /** @type {?} */i_1 = 0; i_1 < projectedViews.length; i_1++) {
var /** @type {?} */projectedView = projectedViews[i_1];
projectedView.state |= 32 /* CheckProjectedView */;
markParentViewsForCheckProjectedViews(projectedView, view);
}
}
} else if ((nodeDef.childFlags & 4 /* ProjectedTemplate */) === 0) {
// a parent with leafs
// no child is a component,
// then skip the children
i += nodeDef.childCount;
}
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?=} v0
* @param {?=} v1
* @param {?=} v2
* @param {?=} v3
* @param {?=} v4
* @param {?=} v5
* @param {?=} v6
* @param {?=} v7
* @param {?=} v8
* @param {?=} v9
* @return {?}
*/
function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
switch (nodeDef.flags & 201347067 /* Types */) {case 1 /* TypeElement */:
return checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
case 2 /* TypeText */:
return checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
case 16384 /* TypeDirective */:
return checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
case 32 /* TypePureArray */:
case 64 /* TypePureObject */:
case 128 /* TypePurePipe */:
return checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
default:
throw 'unreachable';
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} values
* @return {?}
*/
function checkAndUpdateNodeDynamic(view, nodeDef, values) {
switch (nodeDef.flags & 201347067 /* Types */) {case 1 /* TypeElement */:
return checkAndUpdateElementDynamic(view, nodeDef, values);
case 2 /* TypeText */:
return checkAndUpdateTextDynamic(view, nodeDef, values);
case 16384 /* TypeDirective */:
return checkAndUpdateDirectiveDynamic(view, nodeDef, values);
case 32 /* TypePureArray */:
case 64 /* TypePureObject */:
case 128 /* TypePurePipe */:
return checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
default:
throw 'unreachable';
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} argStyle
* @param {?=} v0
* @param {?=} v1
* @param {?=} v2
* @param {?=} v3
* @param {?=} v4
* @param {?=} v5
* @param {?=} v6
* @param {?=} v7
* @param {?=} v8
* @param {?=} v9
* @return {?}
*/
function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
if (argStyle === 0 /* Inline */) {
checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
} else {
checkNoChangesNodeDynamic(view, nodeDef, v0);
}
// Returning false is ok here as we would have thrown in case of a change.
return false;
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} v0
* @param {?} v1
* @param {?} v2
* @param {?} v3
* @param {?} v4
* @param {?} v5
* @param {?} v6
* @param {?} v7
* @param {?} v8
* @param {?} v9
* @return {?}
*/
function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */bindLen = nodeDef.bindings.length;
if (bindLen > 0) checkBindingNoChanges(view, nodeDef, 0, v0);
if (bindLen > 1) checkBindingNoChanges(view, nodeDef, 1, v1);
if (bindLen > 2) checkBindingNoChanges(view, nodeDef, 2, v2);
if (bindLen > 3) checkBindingNoChanges(view, nodeDef, 3, v3);
if (bindLen > 4) checkBindingNoChanges(view, nodeDef, 4, v4);
if (bindLen > 5) checkBindingNoChanges(view, nodeDef, 5, v5);
if (bindLen > 6) checkBindingNoChanges(view, nodeDef, 6, v6);
if (bindLen > 7) checkBindingNoChanges(view, nodeDef, 7, v7);
if (bindLen > 8) checkBindingNoChanges(view, nodeDef, 8, v8);
if (bindLen > 9) checkBindingNoChanges(view, nodeDef, 9, v9);
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} values
* @return {?}
*/
function checkNoChangesNodeDynamic(view, nodeDef, values) {
for (var /** @type {?} */i = 0; i < values.length; i++) {
checkBindingNoChanges(view, nodeDef, i, values[i]);
}
}
/**
* Workaround https://github.com/angular/tsickle/issues/497
* @suppress {misplacedTypeAnnotation}
* @param {?} view
* @param {?} nodeDef
* @return {?}
*/
function checkNoChangesQuery(view, nodeDef) {
var /** @type {?} */queryList = asQueryList(view, nodeDef.nodeIndex);
if (queryList.dirty) {
throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.nodeIndex), "Query " + /** @type {?} */nodeDef.query.id + " not dirty", "Query " + /** @type {?} */nodeDef.query.id + " dirty", (view.state & 1 /* BeforeFirstCheck */) !== 0);
}
}
/**
* @param {?} view
* @return {?}
*/
function destroyView(view) {
if (view.state & 128 /* Destroyed */) {
return;
}
execEmbeddedViewsAction(view, ViewAction.Destroy);
execComponentViewsAction(view, ViewAction.Destroy);
callLifecycleHooksChildrenFirst(view, 131072 /* OnDestroy */);
if (view.disposables) {
for (var /** @type {?} */i = 0; i < view.disposables.length; i++) {
view.disposables[i]();
}
}
detachProjectedView(view);
if (view.renderer.destroyNode) {
destroyViewNodes(view);
}
if (isComponentView(view)) {
view.renderer.destroy();
}
view.state |= 128 /* Destroyed */;
}
/**
* @param {?} view
* @return {?}
*/
function destroyViewNodes(view) {
var /** @type {?} */len = view.def.nodes.length;
for (var /** @type {?} */i = 0; i < len; i++) {
var /** @type {?} */def = view.def.nodes[i];
if (def.flags & 1 /* TypeElement */) {
/** @type {?} */view.renderer.destroyNode(asElementData(view, i).renderElement);
} else if (def.flags & 2 /* TypeText */) {
/** @type {?} */view.renderer.destroyNode(asTextData(view, i).renderText);
} else if (def.flags & 67108864 /* TypeContentQuery */ || def.flags & 134217728 /* TypeViewQuery */) {
asQueryList(view, i).destroy();
}
}
}
/** @enum {number} */
var ViewAction = {
CreateViewNodes: 0,
CheckNoChanges: 1,
CheckNoChangesProjectedViews: 2,
CheckAndUpdate: 3,
CheckAndUpdateProjectedViews: 4,
Destroy: 5
};
ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
ViewAction[ViewAction.CheckNoChangesProjectedViews] = "CheckNoChangesProjectedViews";
ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
ViewAction[ViewAction.CheckAndUpdateProjectedViews] = "CheckAndUpdateProjectedViews";
ViewAction[ViewAction.Destroy] = "Destroy";
/**
* @param {?} view
* @param {?} action
* @return {?}
*/
function execComponentViewsAction(view, action) {
var /** @type {?} */def = view.def;
if (!(def.nodeFlags & 33554432 /* ComponentView */)) {
return;
}
for (var /** @type {?} */i = 0; i < def.nodes.length; i++) {
var /** @type {?} */nodeDef = def.nodes[i];
if (nodeDef.flags & 33554432 /* ComponentView */) {
// a leaf
callViewAction(asElementData(view, i).componentView, action);
} else if ((nodeDef.childFlags & 33554432 /* ComponentView */) === 0) {
// a parent with leafs
// no child is a component,
// then skip the children
i += nodeDef.childCount;
}
}
}
/**
* @param {?} view
* @param {?} action
* @return {?}
*/
function execEmbeddedViewsAction(view, action) {
var /** @type {?} */def = view.def;
if (!(def.nodeFlags & 16777216 /* EmbeddedViews */)) {
return;
}
for (var /** @type {?} */i = 0; i < def.nodes.length; i++) {
var /** @type {?} */nodeDef = def.nodes[i];
if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
// a leaf
var /** @type {?} */embeddedViews = /** @type {?} */asElementData(view, i).viewContainer._embeddedViews;
for (var /** @type {?} */k = 0; k < embeddedViews.length; k++) {
callViewAction(embeddedViews[k], action);
}
} else if ((nodeDef.childFlags & 16777216 /* EmbeddedViews */) === 0) {
// a parent with leafs
// no child is a component,
// then skip the children
i += nodeDef.childCount;
}
}
}
/**
* @param {?} view
* @param {?} action
* @return {?}
*/
function callViewAction(view, action) {
var /** @type {?} */viewState = view.state;
switch (action) {
case ViewAction.CheckNoChanges:
if ((viewState & 128 /* Destroyed */) === 0) {
if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
checkNoChangesView(view);
} else if (viewState & 64 /* CheckProjectedViews */) {
execProjectedViewsAction(view, ViewAction.CheckNoChangesProjectedViews);
}
}
break;
case ViewAction.CheckNoChangesProjectedViews:
if ((viewState & 128 /* Destroyed */) === 0) {
if (viewState & 32 /* CheckProjectedView */) {
checkNoChangesView(view);
} else if (viewState & 64 /* CheckProjectedViews */) {
execProjectedViewsAction(view, action);
}
}
break;
case ViewAction.CheckAndUpdate:
if ((viewState & 128 /* Destroyed */) === 0) {
if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
checkAndUpdateView(view);
} else if (viewState & 64 /* CheckProjectedViews */) {
execProjectedViewsAction(view, ViewAction.CheckAndUpdateProjectedViews);
}
}
break;
case ViewAction.CheckAndUpdateProjectedViews:
if ((viewState & 128 /* Destroyed */) === 0) {
if (viewState & 32 /* CheckProjectedView */) {
checkAndUpdateView(view);
} else if (viewState & 64 /* CheckProjectedViews */) {
execProjectedViewsAction(view, action);
}
}
break;
case ViewAction.Destroy:
// Note: destroyView recurses over all views,
// so we don't need to special case projected views here.
destroyView(view);
break;
case ViewAction.CreateViewNodes:
createViewNodes(view);
break;
}
}
/**
* @param {?} view
* @param {?} action
* @return {?}
*/
function execProjectedViewsAction(view, action) {
execEmbeddedViewsAction(view, action);
execComponentViewsAction(view, action);
}
/**
* @param {?} view
* @param {?} queryFlags
* @param {?} staticDynamicQueryFlag
* @param {?} checkType
* @return {?}
*/
function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
return;
}
var /** @type {?} */nodeCount = view.def.nodes.length;
for (var /** @type {?} */i = 0; i < nodeCount; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & queryFlags && nodeDef.flags & staticDynamicQueryFlag) {
Services.setCurrentNode(view, nodeDef.nodeIndex);
switch (checkType) {
case 0 /* CheckAndUpdate */:
checkAndUpdateQuery(view, nodeDef);
break;
case 1 /* CheckNoChanges */:
checkNoChangesQuery(view, nodeDef);
break;
}
}
if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
// no child has a matching query
// then skip the children
i += nodeDef.childCount;
}
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var initialized = false;
/**
* @return {?}
*/
function initServicesIfNeeded() {
if (initialized) {
return;
}
initialized = true;
var /** @type {?} */services = isDevMode() ? createDebugServices() : createProdServices();
Services.setCurrentNode = services.setCurrentNode;
Services.createRootView = services.createRootView;
Services.createEmbeddedView = services.createEmbeddedView;
Services.createComponentView = services.createComponentView;
Services.createNgModuleRef = services.createNgModuleRef;
Services.overrideProvider = services.overrideProvider;
Services.overrideComponentView = services.overrideComponentView;
Services.clearOverrides = services.clearOverrides;
Services.checkAndUpdateView = services.checkAndUpdateView;
Services.checkNoChangesView = services.checkNoChangesView;
Services.destroyView = services.destroyView;
Services.resolveDep = resolveDep;
Services.createDebugContext = services.createDebugContext;
Services.handleEvent = services.handleEvent;
Services.updateDirectives = services.updateDirectives;
Services.updateRenderer = services.updateRenderer;
Services.dirtyParentQueries = dirtyParentQueries;
}
/**
* @return {?}
*/
function createProdServices() {
return {
setCurrentNode: function () {},
createRootView: createProdRootView,
createEmbeddedView: createEmbeddedView,
createComponentView: createComponentView,
createNgModuleRef: createNgModuleRef,
overrideProvider: NOOP,
overrideComponentView: NOOP,
clearOverrides: NOOP,
checkAndUpdateView: checkAndUpdateView,
checkNoChangesView: checkNoChangesView,
destroyView: destroyView,
createDebugContext: function (view, nodeIndex) {
return new DebugContext_(view, nodeIndex);
},
handleEvent: function (view, nodeIndex, eventName, event) {
return view.def.handleEvent(view, nodeIndex, eventName, event);
},
updateDirectives: function (view, checkType) {
return view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode : prodCheckNoChangesNode, view);
},
updateRenderer: function (view, checkType) {
return view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode : prodCheckNoChangesNode, view);
}
};
}
/**
* @return {?}
*/
function createDebugServices() {
return {
setCurrentNode: debugSetCurrentNode,
createRootView: debugCreateRootView,
createEmbeddedView: debugCreateEmbeddedView,
createComponentView: debugCreateComponentView,
createNgModuleRef: debugCreateNgModuleRef,
overrideProvider: debugOverrideProvider,
overrideComponentView: debugOverrideComponentView,
clearOverrides: debugClearOverrides,
checkAndUpdateView: debugCheckAndUpdateView,
checkNoChangesView: debugCheckNoChangesView,
destroyView: debugDestroyView,
createDebugContext: function (view, nodeIndex) {
return new DebugContext_(view, nodeIndex);
},
handleEvent: debugHandleEvent,
updateDirectives: debugUpdateDirectives,
updateRenderer: debugUpdateRenderer
};
}
/**
* @param {?} elInjector
* @param {?} projectableNodes
* @param {?} rootSelectorOrNode
* @param {?} def
* @param {?} ngModule
* @param {?=} context
* @return {?}
*/
function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
var /** @type {?} */rendererFactory = ngModule.injector.get(RendererFactory2);
return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
}
/**
* @param {?} elInjector
* @param {?} projectableNodes
* @param {?} rootSelectorOrNode
* @param {?} def
* @param {?} ngModule
* @param {?=} context
* @return {?}
*/
function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
var /** @type {?} */rendererFactory = ngModule.injector.get(RendererFactory2);
var /** @type {?} */root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
var /** @type {?} */defWithOverride = applyProviderOverridesToView(def);
return callWithDebugContext(DebugAction.create, createRootView, null, [root, defWithOverride, context]);
}
/**
* @param {?} elInjector
* @param {?} ngModule
* @param {?} rendererFactory
* @param {?} projectableNodes
* @param {?} rootSelectorOrNode
* @return {?}
*/
function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
var /** @type {?} */sanitizer = ngModule.injector.get(Sanitizer);
var /** @type {?} */errorHandler = ngModule.injector.get(ErrorHandler);
var /** @type {?} */renderer = rendererFactory.createRenderer(null, null);
return {
ngModule: ngModule,
injector: elInjector, projectableNodes: projectableNodes,
selectorOrNode: rootSelectorOrNode, sanitizer: sanitizer, rendererFactory: rendererFactory, renderer: renderer, errorHandler: errorHandler
};
}
/**
* @param {?} parentView
* @param {?} anchorDef
* @param {?} viewDef
* @param {?=} context
* @return {?}
*/
function debugCreateEmbeddedView(parentView, anchorDef, viewDef$$1, context) {
var /** @type {?} */defWithOverride = applyProviderOverridesToView(viewDef$$1);
return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parentView, anchorDef, defWithOverride, context]);
}
/**
* @param {?} parentView
* @param {?} nodeDef
* @param {?} viewDef
* @param {?} hostElement
* @return {?}
*/
function debugCreateComponentView(parentView, nodeDef, viewDef$$1, hostElement) {
var /** @type {?} */overrideComponentView = viewDefOverrides.get( /** @type {?} */ /** @type {?} */ /** @type {?} */nodeDef.element.componentProvider.provider.token);
if (overrideComponentView) {
viewDef$$1 = overrideComponentView;
} else {
viewDef$$1 = applyProviderOverridesToView(viewDef$$1);
}
return callWithDebugContext(DebugAction.create, createComponentView, null, [parentView, nodeDef, viewDef$$1, hostElement]);
}
/**
* @param {?} moduleType
* @param {?} parentInjector
* @param {?} bootstrapComponents
* @param {?} def
* @return {?}
*/
function debugCreateNgModuleRef(moduleType, parentInjector, bootstrapComponents, def) {
var /** @type {?} */defWithOverride = applyProviderOverridesToNgModule(def);
return createNgModuleRef(moduleType, parentInjector, bootstrapComponents, defWithOverride);
}
var providerOverrides = new Map();
var viewDefOverrides = new Map();
/**
* @param {?} override
* @return {?}
*/
function debugOverrideProvider(override) {
providerOverrides.set(override.token, override);
}
/**
* @param {?} comp
* @param {?} compFactory
* @return {?}
*/
function debugOverrideComponentView(comp, compFactory) {
var /** @type {?} */hostViewDef = resolveDefinition(getComponentViewDefinitionFactory(compFactory));
var /** @type {?} */compViewDef = resolveDefinition( /** @type {?} */ /** @type {?} */hostViewDef.nodes[0].element.componentView);
viewDefOverrides.set(comp, compViewDef);
}
/**
* @return {?}
*/
function debugClearOverrides() {
providerOverrides.clear();
viewDefOverrides.clear();
}
/**
* @param {?} def
* @return {?}
*/
function applyProviderOverridesToView(def) {
if (providerOverrides.size === 0) {
return def;
}
var /** @type {?} */elementIndicesWithOverwrittenProviders = findElementIndicesWithOverwrittenProviders(def);
if (elementIndicesWithOverwrittenProviders.length === 0) {
return def;
}
// clone the whole view definition,
// as it maintains references between the nodes that are hard to update.
def = /** @type {?} */def.factory(function () {
return NOOP;
});
for (var /** @type {?} */i = 0; i < elementIndicesWithOverwrittenProviders.length; i++) {
applyProviderOverridesToElement(def, elementIndicesWithOverwrittenProviders[i]);
}
return def;
/**
* @param {?} def
* @return {?}
*/
function findElementIndicesWithOverwrittenProviders(def) {
var /** @type {?} */elIndicesWithOverwrittenProviders = [];
var /** @type {?} */lastElementDef = null;
for (var /** @type {?} */i = 0; i < def.nodes.length; i++) {
var /** @type {?} */nodeDef = def.nodes[i];
if (nodeDef.flags & 1 /* TypeElement */) {
lastElementDef = nodeDef;
}
if (lastElementDef && nodeDef.flags & 3840 /* CatProviderNoDirective */ && providerOverrides.has( /** @type {?} */nodeDef.provider.token)) {
elIndicesWithOverwrittenProviders.push( /** @type {?} */lastElementDef.nodeIndex);
lastElementDef = null;
}
}
return elIndicesWithOverwrittenProviders;
}
/**
* @param {?} viewDef
* @param {?} elIndex
* @return {?}
*/
function applyProviderOverridesToElement(viewDef$$1, elIndex) {
for (var /** @type {?} */i = elIndex + 1; i < viewDef$$1.nodes.length; i++) {
var /** @type {?} */nodeDef = viewDef$$1.nodes[i];
if (nodeDef.flags & 1 /* TypeElement */) {
// stop at the next element
return;
}
if (nodeDef.flags & 3840 /* CatProviderNoDirective */) {
var /** @type {?} */provider = /** @type {?} */nodeDef.provider;
var /** @type {?} */override = providerOverrides.get(provider.token);
if (override) {
nodeDef.flags = nodeDef.flags & ~3840 /* CatProviderNoDirective */ | override.flags;
provider.deps = splitDepsDsl(override.deps);
provider.value = override.value;
}
}
}
}
}
/**
* @param {?} def
* @return {?}
*/
function applyProviderOverridesToNgModule(def) {
var _a = calcHasOverrides(def),
hasOverrides = _a.hasOverrides,
hasDeprecatedOverrides = _a.hasDeprecatedOverrides;
if (!hasOverrides) {
return def;
}
// clone the whole view definition,
// as it maintains references between the nodes that are hard to update.
def = /** @type {?} */def.factory(function () {
return NOOP;
});
applyProviderOverrides(def);
return def;
/**
* @param {?} def
* @return {?}
*/
function calcHasOverrides(def) {
var /** @type {?} */hasOverrides = false;
var /** @type {?} */hasDeprecatedOverrides = false;
if (providerOverrides.size === 0) {
return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
}
def.providers.forEach(function (node) {
var /** @type {?} */override = providerOverrides.get(node.token);
if (node.flags & 3840 /* CatProviderNoDirective */ && override) {
hasOverrides = true;
hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
}
});
return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
}
/**
* @param {?} def
* @return {?}
*/
function applyProviderOverrides(def) {
for (var /** @type {?} */i = 0; i < def.providers.length; i++) {
var /** @type {?} */provider = def.providers[i];
if (hasDeprecatedOverrides) {
// We had a bug where me made
// all providers lazy. Keep this logic behind a flag
// for migrating existing users.
provider.flags |= 4096 /* LazyProvider */;
}
var /** @type {?} */override = providerOverrides.get(provider.token);
if (override) {
provider.flags = provider.flags & ~3840 /* CatProviderNoDirective */ | override.flags;
provider.deps = splitDepsDsl(override.deps);
provider.value = override.value;
}
}
}
}
/**
* @param {?} view
* @param {?} checkIndex
* @param {?} argStyle
* @param {?=} v0
* @param {?=} v1
* @param {?=} v2
* @param {?=} v3
* @param {?=} v4
* @param {?=} v5
* @param {?=} v6
* @param {?=} v7
* @param {?=} v8
* @param {?=} v9
* @return {?}
*/
function prodCheckAndUpdateNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */nodeDef = view.def.nodes[checkIndex];
checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
return nodeDef.flags & 224 /* CatPureExpression */ ? asPureExpressionData(view, checkIndex).value : undefined;
}
/**
* @param {?} view
* @param {?} checkIndex
* @param {?} argStyle
* @param {?=} v0
* @param {?=} v1
* @param {?=} v2
* @param {?=} v3
* @param {?=} v4
* @param {?=} v5
* @param {?=} v6
* @param {?=} v7
* @param {?=} v8
* @param {?=} v9
* @return {?}
*/
function prodCheckNoChangesNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
var /** @type {?} */nodeDef = view.def.nodes[checkIndex];
checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
return nodeDef.flags & 224 /* CatPureExpression */ ? asPureExpressionData(view, checkIndex).value : undefined;
}
/**
* @param {?} view
* @return {?}
*/
function debugCheckAndUpdateView(view) {
return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
}
/**
* @param {?} view
* @return {?}
*/
function debugCheckNoChangesView(view) {
return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
}
/**
* @param {?} view
* @return {?}
*/
function debugDestroyView(view) {
return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
}
/** @enum {number} */
var DebugAction = {
create: 0,
detectChanges: 1,
checkNoChanges: 2,
destroy: 3,
handleEvent: 4
};
DebugAction[DebugAction.create] = "create";
DebugAction[DebugAction.detectChanges] = "detectChanges";
DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
DebugAction[DebugAction.destroy] = "destroy";
DebugAction[DebugAction.handleEvent] = "handleEvent";
var _currentAction;
var _currentView;
var _currentNodeIndex;
/**
* @param {?} view
* @param {?} nodeIndex
* @return {?}
*/
function debugSetCurrentNode(view, nodeIndex) {
_currentView = view;
_currentNodeIndex = nodeIndex;
}
/**
* @param {?} view
* @param {?} nodeIndex
* @param {?} eventName
* @param {?} event
* @return {?}
*/
function debugHandleEvent(view, nodeIndex, eventName, event) {
debugSetCurrentNode(view, nodeIndex);
return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
}
/**
* @param {?} view
* @param {?} checkType
* @return {?}
*/
function debugUpdateDirectives(view, checkType) {
if (view.state & 128 /* Destroyed */) {
throw viewDestroyedError(DebugAction[_currentAction]);
}
debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
return view.def.updateDirectives(debugCheckDirectivesFn, view);
/**
* @param {?} view
* @param {?} nodeIndex
* @param {?} argStyle
* @param {...?} values
* @return {?}
*/
function debugCheckDirectivesFn(view, nodeIndex, argStyle) {
var values = [];
for (var _i = 3; _i < arguments.length; _i++) {
values[_i - 3] = arguments[_i];
}
var /** @type {?} */nodeDef = view.def.nodes[nodeIndex];
if (checkType === 0 /* CheckAndUpdate */) {
debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
} else {
debugCheckNoChangesNode(view, nodeDef, argStyle, values);
}
if (nodeDef.flags & 16384 /* TypeDirective */) {
debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
}
return nodeDef.flags & 224 /* CatPureExpression */ ? asPureExpressionData(view, nodeDef.nodeIndex).value : undefined;
}
}
/**
* @param {?} view
* @param {?} checkType
* @return {?}
*/
function debugUpdateRenderer(view, checkType) {
if (view.state & 128 /* Destroyed */) {
throw viewDestroyedError(DebugAction[_currentAction]);
}
debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
return view.def.updateRenderer(debugCheckRenderNodeFn, view);
/**
* @param {?} view
* @param {?} nodeIndex
* @param {?} argStyle
* @param {...?} values
* @return {?}
*/
function debugCheckRenderNodeFn(view, nodeIndex, argStyle) {
var values = [];
for (var _i = 3; _i < arguments.length; _i++) {
values[_i - 3] = arguments[_i];
}
var /** @type {?} */nodeDef = view.def.nodes[nodeIndex];
if (checkType === 0 /* CheckAndUpdate */) {
debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
} else {
debugCheckNoChangesNode(view, nodeDef, argStyle, values);
}
if (nodeDef.flags & 3 /* CatRenderNode */) {
debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
}
return nodeDef.flags & 224 /* CatPureExpression */ ? asPureExpressionData(view, nodeDef.nodeIndex).value : undefined;
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} argStyle
* @param {?} givenValues
* @return {?}
*/
function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
var /** @type {?} */changed = /** @type {?} */checkAndUpdateNode.apply(void 0, [view, nodeDef, argStyle].concat(givenValues));
if (changed) {
var /** @type {?} */values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
if (nodeDef.flags & 16384 /* TypeDirective */) {
var /** @type {?} */bindingValues = {};
for (var /** @type {?} */i = 0; i < nodeDef.bindings.length; i++) {
var /** @type {?} */binding = nodeDef.bindings[i];
var /** @type {?} */value = values[i];
if (binding.flags & 8 /* TypeProperty */) {
bindingValues[normalizeDebugBindingName( /** @type {?} */binding.nonMinifiedName)] = normalizeDebugBindingValue(value);
}
}
var /** @type {?} */elDef = /** @type {?} */nodeDef.parent;
var /** @type {?} */el = asElementData(view, elDef.nodeIndex).renderElement;
if (! /** @type {?} */elDef.element.name) {
// a comment.
view.renderer.setValue(el, "bindings=" + JSON.stringify(bindingValues, null, 2));
} else {
// a regular element.
for (var /** @type {?} */attr in bindingValues) {
var /** @type {?} */value = bindingValues[attr];
if (value != null) {
view.renderer.setAttribute(el, attr, value);
} else {
view.renderer.removeAttribute(el, attr);
}
}
}
}
}
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} argStyle
* @param {?} values
* @return {?}
*/
function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
/** @type {?} */checkNoChangesNode.apply(void 0, [view, nodeDef, argStyle].concat(values));
}
/**
* @param {?} name
* @return {?}
*/
function normalizeDebugBindingName(name) {
// Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
return "ng-reflect-" + name;
}
var CAMEL_CASE_REGEXP = /([A-Z])/g;
/**
* @param {?} input
* @return {?}
*/
function camelCaseToDashCase(input) {
return input.replace(CAMEL_CASE_REGEXP, function () {
var m = [];
for (var _i = 0; _i < arguments.length; _i++) {
m[_i] = arguments[_i];
}
return '-' + m[1].toLowerCase();
});
}
/**
* @param {?} value
* @return {?}
*/
function normalizeDebugBindingValue(value) {
try {
// Limit the size of the value as otherwise the DOM just gets polluted.
return value != null ? value.toString().slice(0, 30) : value;
} catch ( /** @type {?} */e) {
return '[ERROR] Exception while trying to serialize the value';
}
}
/**
* @param {?} view
* @param {?} nodeIndex
* @return {?}
*/
function nextDirectiveWithBinding(view, nodeIndex) {
for (var /** @type {?} */i = nodeIndex; i < view.def.nodes.length; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & 16384 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
return i;
}
}
return null;
}
/**
* @param {?} view
* @param {?} nodeIndex
* @return {?}
*/
function nextRenderNodeWithBinding(view, nodeIndex) {
for (var /** @type {?} */i = nodeIndex; i < view.def.nodes.length; i++) {
var /** @type {?} */nodeDef = view.def.nodes[i];
if (nodeDef.flags & 3 /* CatRenderNode */ && nodeDef.bindings && nodeDef.bindings.length) {
return i;
}
}
return null;
}
var DebugContext_ = /** @class */function () {
function DebugContext_(view, nodeIndex) {
this.view = view;
this.nodeIndex = nodeIndex;
if (nodeIndex == null) {
this.nodeIndex = nodeIndex = 0;
}
this.nodeDef = view.def.nodes[nodeIndex];
var /** @type {?} */elDef = this.nodeDef;
var /** @type {?} */elView = view;
while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
elDef = /** @type {?} */elDef.parent;
}
if (!elDef) {
while (!elDef && elView) {
elDef = /** @type {?} */viewParentEl(elView);
elView = /** @type {?} */elView.parent;
}
}
this.elDef = elDef;
this.elView = elView;
}
Object.defineProperty(DebugContext_.prototype, "elOrCompView", {
get: /**
* @return {?}
*/
function () {
// Has to be done lazily as we use the DebugContext also during creation of elements...
return asElementData(this.elView, this.elDef.nodeIndex).componentView || this.view;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "injector", {
get: /**
* @return {?}
*/
function () {
return createInjector(this.elView, this.elDef);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "component", {
get: /**
* @return {?}
*/
function () {
return this.elOrCompView.component;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "context", {
get: /**
* @return {?}
*/
function () {
return this.elOrCompView.context;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "providerTokens", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */tokens = [];
if (this.elDef) {
for (var /** @type {?} */i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
var /** @type {?} */childDef = this.elView.def.nodes[i];
if (childDef.flags & 20224 /* CatProvider */) {
tokens.push( /** @type {?} */childDef.provider.token);
}
i += childDef.childCount;
}
}
return tokens;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "references", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */references = {};
if (this.elDef) {
collectReferences(this.elView, this.elDef, references);
for (var /** @type {?} */i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
var /** @type {?} */childDef = this.elView.def.nodes[i];
if (childDef.flags & 20224 /* CatProvider */) {
collectReferences(this.elView, childDef, references);
}
i += childDef.childCount;
}
}
return references;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "componentRenderElement", {
get: /**
* @return {?}
*/
function () {
var /** @type {?} */elData = findHostElement(this.elOrCompView);
return elData ? elData.renderElement : undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DebugContext_.prototype, "renderNode", {
get: /**
* @return {?}
*/
function () {
return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) : renderNode(this.elView, this.elDef);
},
enumerable: true,
configurable: true
});
/**
* @param {?} console
* @param {...?} values
* @return {?}
*/
DebugContext_.prototype.logError = /**
* @param {?} console
* @param {...?} values
* @return {?}
*/
function (console) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
var /** @type {?} */logViewDef;
var /** @type {?} */logNodeIndex;
if (this.nodeDef.flags & 2 /* TypeText */) {
logViewDef = this.view.def;
logNodeIndex = this.nodeDef.nodeIndex;
} else {
logViewDef = this.elView.def;
logNodeIndex = this.elDef.nodeIndex;
}
// Note: we only generate a log function for text and element nodes
// to make the generated code as small as possible.
var /** @type {?} */renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
var /** @type {?} */currRenderNodeIndex = -1;
var /** @type {?} */nodeLogger = function () {
currRenderNodeIndex++;
if (currRenderNodeIndex === renderNodeIndex) {
return (_a = console.error).bind.apply(_a, [console].concat(values));
} else {
return NOOP;
}
var _a;
}; /** @type {?} */
logViewDef.factory(nodeLogger);
if (currRenderNodeIndex < renderNodeIndex) {
console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
console.error.apply(console, values);
}
};
return DebugContext_;
}();
/**
* @param {?} viewDef
* @param {?} nodeIndex
* @return {?}
*/
function getRenderNodeIndex(viewDef$$1, nodeIndex) {
var /** @type {?} */renderNodeIndex = -1;
for (var /** @type {?} */i = 0; i <= nodeIndex; i++) {
var /** @type {?} */nodeDef = viewDef$$1.nodes[i];
if (nodeDef.flags & 3 /* CatRenderNode */) {
renderNodeIndex++;
}
}
return renderNodeIndex;
}
/**
* @param {?} view
* @return {?}
*/
function findHostElement(view) {
while (view && !isComponentView(view)) {
view = /** @type {?} */view.parent;
}
if (view.parent) {
return asElementData(view.parent, /** @type {?} */viewParentEl(view).nodeIndex);
}
return null;
}
/**
* @param {?} view
* @param {?} nodeDef
* @param {?} references
* @return {?}
*/
function collectReferences(view, nodeDef, references) {
for (var /** @type {?} */refName in nodeDef.references) {
references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
}
}
/**
* @param {?} action
* @param {?} fn
* @param {?} self
* @param {?} args
* @return {?}
*/
function callWithDebugContext(action, fn, self, args) {
var /** @type {?} */oldAction = _currentAction;
var /** @type {?} */oldView = _currentView;
var /** @type {?} */oldNodeIndex = _currentNodeIndex;
try {
_currentAction = action;
var /** @type {?} */result = fn.apply(self, args);
_currentView = oldView;
_currentNodeIndex = oldNodeIndex;
_currentAction = oldAction;
return result;
} catch ( /** @type {?} */e) {
if (isViewDebugError(e) || !_currentView) {
throw e;
}
throw viewWrappedDebugError(e, /** @type {?} */getCurrentDebugContext());
}
}
/**
* @return {?}
*/
function getCurrentDebugContext() {
return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
}
var DebugRendererFactory2 = /** @class */function () {
function DebugRendererFactory2(delegate) {
this.delegate = delegate;
}
/**
* @param {?} element
* @param {?} renderData
* @return {?}
*/
DebugRendererFactory2.prototype.createRenderer = /**
* @param {?} element
* @param {?} renderData
* @return {?}
*/
function (element, renderData) {
return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
};
/**
* @return {?}
*/
DebugRendererFactory2.prototype.begin = /**
* @return {?}
*/
function () {
if (this.delegate.begin) {
this.delegate.begin();
}
};
/**
* @return {?}
*/
DebugRendererFactory2.prototype.end = /**
* @return {?}
*/
function () {
if (this.delegate.end) {
this.delegate.end();
}
};
/**
* @return {?}
*/
DebugRendererFactory2.prototype.whenRenderingDone = /**
* @return {?}
*/
function () {
if (this.delegate.whenRenderingDone) {
return this.delegate.whenRenderingDone();
}
return Promise.resolve(null);
};
return DebugRendererFactory2;
}();
var DebugRenderer2 = /** @class */function () {
function DebugRenderer2(delegate) {
this.delegate = delegate;
}
Object.defineProperty(DebugRenderer2.prototype, "data", {
get: /**
* @return {?}
*/
function () {
return this.delegate.data;
},
enumerable: true,
configurable: true
});
/**
* @param {?} node
* @return {?}
*/
DebugRenderer2.prototype.destroyNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
removeDebugNodeFromIndex( /** @type {?} */getDebugNode(node));
if (this.delegate.destroyNode) {
this.delegate.destroyNode(node);
}
};
/**
* @return {?}
*/
DebugRenderer2.prototype.destroy = /**
* @return {?}
*/
function () {
this.delegate.destroy();
};
/**
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
DebugRenderer2.prototype.createElement = /**
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
function (name, namespace) {
var /** @type {?} */el = this.delegate.createElement(name, namespace);
var /** @type {?} */debugCtx = getCurrentDebugContext();
if (debugCtx) {
var /** @type {?} */debugEl = new DebugElement(el, null, debugCtx);
debugEl.name = name;
indexDebugNode(debugEl);
}
return el;
};
/**
* @param {?} value
* @return {?}
*/
DebugRenderer2.prototype.createComment = /**
* @param {?} value
* @return {?}
*/
function (value) {
var /** @type {?} */comment = this.delegate.createComment(value);
var /** @type {?} */debugCtx = getCurrentDebugContext();
if (debugCtx) {
indexDebugNode(new DebugNode(comment, null, debugCtx));
}
return comment;
};
/**
* @param {?} value
* @return {?}
*/
DebugRenderer2.prototype.createText = /**
* @param {?} value
* @return {?}
*/
function (value) {
var /** @type {?} */text = this.delegate.createText(value);
var /** @type {?} */debugCtx = getCurrentDebugContext();
if (debugCtx) {
indexDebugNode(new DebugNode(text, null, debugCtx));
}
return text;
};
/**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
DebugRenderer2.prototype.appendChild = /**
* @param {?} parent
* @param {?} newChild
* @return {?}
*/
function (parent, newChild) {
var /** @type {?} */debugEl = getDebugNode(parent);
var /** @type {?} */debugChildEl = getDebugNode(newChild);
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
debugEl.addChild(debugChildEl);
}
this.delegate.appendChild(parent, newChild);
};
/**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
DebugRenderer2.prototype.insertBefore = /**
* @param {?} parent
* @param {?} newChild
* @param {?} refChild
* @return {?}
*/
function (parent, newChild, refChild) {
var /** @type {?} */debugEl = getDebugNode(parent);
var /** @type {?} */debugChildEl = getDebugNode(newChild);
var /** @type {?} */debugRefEl = /** @type {?} */getDebugNode(refChild);
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
debugEl.insertBefore(debugRefEl, debugChildEl);
}
this.delegate.insertBefore(parent, newChild, refChild);
};
/**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
DebugRenderer2.prototype.removeChild = /**
* @param {?} parent
* @param {?} oldChild
* @return {?}
*/
function (parent, oldChild) {
var /** @type {?} */debugEl = getDebugNode(parent);
var /** @type {?} */debugChildEl = getDebugNode(oldChild);
if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
debugEl.removeChild(debugChildEl);
}
this.delegate.removeChild(parent, oldChild);
};
/**
* @param {?} selectorOrNode
* @return {?}
*/
DebugRenderer2.prototype.selectRootElement = /**
* @param {?} selectorOrNode
* @return {?}
*/
function (selectorOrNode) {
var /** @type {?} */el = this.delegate.selectRootElement(selectorOrNode);
var /** @type {?} */debugCtx = getCurrentDebugContext();
if (debugCtx) {
indexDebugNode(new DebugElement(el, null, debugCtx));
}
return el;
};
/**
* @param {?} el
* @param {?} name
* @param {?} value
* @param {?=} namespace
* @return {?}
*/
DebugRenderer2.prototype.setAttribute = /**
* @param {?} el
* @param {?} name
* @param {?} value
* @param {?=} namespace
* @return {?}
*/
function (el, name, value, namespace) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
var /** @type {?} */fullName = namespace ? namespace + ':' + name : name;
debugEl.attributes[fullName] = value;
}
this.delegate.setAttribute(el, name, value, namespace);
};
/**
* @param {?} el
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
DebugRenderer2.prototype.removeAttribute = /**
* @param {?} el
* @param {?} name
* @param {?=} namespace
* @return {?}
*/
function (el, name, namespace) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
var /** @type {?} */fullName = namespace ? namespace + ':' + name : name;
debugEl.attributes[fullName] = null;
}
this.delegate.removeAttribute(el, name, namespace);
};
/**
* @param {?} el
* @param {?} name
* @return {?}
*/
DebugRenderer2.prototype.addClass = /**
* @param {?} el
* @param {?} name
* @return {?}
*/
function (el, name) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
debugEl.classes[name] = true;
}
this.delegate.addClass(el, name);
};
/**
* @param {?} el
* @param {?} name
* @return {?}
*/
DebugRenderer2.prototype.removeClass = /**
* @param {?} el
* @param {?} name
* @return {?}
*/
function (el, name) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
debugEl.classes[name] = false;
}
this.delegate.removeClass(el, name);
};
/**
* @param {?} el
* @param {?} style
* @param {?} value
* @param {?} flags
* @return {?}
*/
DebugRenderer2.prototype.setStyle = /**
* @param {?} el
* @param {?} style
* @param {?} value
* @param {?} flags
* @return {?}
*/
function (el, style, value, flags) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
debugEl.styles[style] = value;
}
this.delegate.setStyle(el, style, value, flags);
};
/**
* @param {?} el
* @param {?} style
* @param {?} flags
* @return {?}
*/
DebugRenderer2.prototype.removeStyle = /**
* @param {?} el
* @param {?} style
* @param {?} flags
* @return {?}
*/
function (el, style, flags) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
debugEl.styles[style] = null;
}
this.delegate.removeStyle(el, style, flags);
};
/**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
DebugRenderer2.prototype.setProperty = /**
* @param {?} el
* @param {?} name
* @param {?} value
* @return {?}
*/
function (el, name, value) {
var /** @type {?} */debugEl = getDebugNode(el);
if (debugEl && debugEl instanceof DebugElement) {
debugEl.properties[name] = value;
}
this.delegate.setProperty(el, name, value);
};
/**
* @param {?} target
* @param {?} eventName
* @param {?} callback
* @return {?}
*/
DebugRenderer2.prototype.listen = /**
* @param {?} target
* @param {?} eventName
* @param {?} callback
* @return {?}
*/
function (target, eventName, callback) {
if (typeof target !== 'string') {
var /** @type {?} */debugEl = getDebugNode(target);
if (debugEl) {
debugEl.listeners.push(new EventListener(eventName, callback));
}
}
return this.delegate.listen(target, eventName, callback);
};
/**
* @param {?} node
* @return {?}
*/
DebugRenderer2.prototype.parentNode = /**
* @param {?} node
* @return {?}
*/
function (node) {
return this.delegate.parentNode(node);
};
/**
* @param {?} node
* @return {?}
*/
DebugRenderer2.prototype.nextSibling = /**
* @param {?} node
* @return {?}
*/
function (node) {
return this.delegate.nextSibling(node);
};
/**
* @param {?} node
* @param {?} value
* @return {?}
*/
DebugRenderer2.prototype.setValue = /**
* @param {?} node
* @param {?} value
* @return {?}
*/
function (node, value) {
return this.delegate.setValue(node, value);
};
return DebugRenderer2;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} override
* @return {?}
*/
function overrideProvider(override) {
initServicesIfNeeded();
return Services.overrideProvider(override);
}
/**
* @param {?} comp
* @param {?} componentFactory
* @return {?}
*/
function overrideComponentView(comp, componentFactory) {
initServicesIfNeeded();
return Services.overrideComponentView(comp, componentFactory);
}
/**
* @return {?}
*/
function clearOverrides() {
initServicesIfNeeded();
return Services.clearOverrides();
}
/**
* @param {?} ngModuleType
* @param {?} bootstrapComponents
* @param {?} defFactory
* @return {?}
*/
function createNgModuleFactory(ngModuleType, bootstrapComponents, defFactory) {
return new NgModuleFactory_(ngModuleType, bootstrapComponents, defFactory);
}
var NgModuleFactory_ = /** @class */function (_super) {
__extends(NgModuleFactory_, _super);
function NgModuleFactory_(moduleType, _bootstrapComponents, _ngModuleDefFactory) {
var _this =
// Attention: this ctor is called as top level function.
// Putting any logic in here will destroy closure tree shaking!
_super.call(this) || this;
_this.moduleType = moduleType;
_this._bootstrapComponents = _bootstrapComponents;
_this._ngModuleDefFactory = _ngModuleDefFactory;
return _this;
}
/**
* @param {?} parentInjector
* @return {?}
*/
NgModuleFactory_.prototype.create = /**
* @param {?} parentInjector
* @return {?}
*/
function (parentInjector) {
initServicesIfNeeded();
var /** @type {?} */def = resolveDefinition(this._ngModuleDefFactory);
return Services.createNgModuleRef(this.moduleType, parentInjector || Injector.NULL, this._bootstrapComponents, def);
};
return NgModuleFactory_;
}(NgModuleFactory);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
* @record
*/
/**
* \@experimental Animation support is experimental.
*/
/**
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link trigger trigger animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link state state animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link transition transition animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* \@experimental Animation support is experimental.
* @record
*/
/**
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link keyframes keyframes animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link style style animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link animate animate animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link animateChild animateChild animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link useAnimation useAnimation animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link sequence sequence animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link group group animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* Metadata representing the entry of animations. Instances of this interface are provided via the
* animation DSL when the {\@link stagger stagger animation function} is called.
*
* \@experimental Animation support is experimental.
* @record
*/
/**
* `trigger` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the
* {\@link Component#animations component animations metadata page} to gain a better
* understanding of how animations in Angular are used.
*
* `trigger` Creates an animation trigger which will a list of {\@link state state} and
* {\@link transition transition} entries that will be evaluated when the expression
* bound to the trigger changes.
*
* Triggers are registered within the component annotation data under the
* {\@link Component#animations animations section}. An animation trigger can be placed on an element
* within a template by referencing the name of the trigger followed by the expression value that
* the
* trigger is bound to (in the form of `[\@triggerName]="expression"`.
*
* Animation trigger bindings strigify values and then match the previous and current values against
* any linked transitions. If a boolean value is provided into the trigger binding then it will both
* be represented as `1` or `true` and `0` or `false` for a true and false boolean values
* respectively.
*
* ### Usage
*
* `trigger` will create an animation trigger reference based on the provided `name` value. The
* provided `animation` value is expected to be an array consisting of {\@link state state} and
* {\@link transition transition} declarations.
*
* ```typescript
* \@Component({
* selector: 'my-component',
* templateUrl: 'my-component-tpl.html',
* animations: [
* trigger("myAnimationTrigger", [
* state(...),
* state(...),
* transition(...),
* transition(...)
* ])
* ]
* })
* class MyComponent {
* myStatusExp = "something";
* }
* ```
*
* The template associated with this component will make use of the `myAnimationTrigger` animation
* trigger by binding to an element within its template code.
*
* ```html
* <!-- somewhere inside of my-component-tpl.html -->
* <div [\@myAnimationTrigger]="myStatusExp">...</div>
* ```
*
* ## Disable Animations
* A special animation control binding called `\@.disabled` can be placed on an element which will
* then disable animations for any inner animation triggers situated within the element as well as
* any animations on the element itself.
*
* When true, the `\@.disabled` binding will prevent all animations from rendering. The example
* below shows how to use this feature:
*
* ```ts
* \@Component({
* selector: 'my-component',
* template: `
* <div [\@.disabled]="isDisabled">
* <div [\@childAnimation]="exp"></div>
* </div>
* `,
* animations: [
* trigger("childAnimation", [
* // ...
* ])
* ]
* })
* class MyComponent {
* isDisabled = true;
* exp = '...';
* }
* ```
*
* The `\@childAnimation` trigger will not animate because `\@.disabled` prevents it from happening
* (when true).
*
* Note that `\@.disbled` will only disable all animations (this means any animations running on
* the same element will also be disabled).
*
* ### Disabling Animations Application-wide
* When an area of the template is set to have animations disabled, **all** inner components will
* also have their animations disabled as well. This means that all animations for an angular
* application can be disabled by placing a host binding set on `\@.disabled` on the topmost Angular
* component.
*
* ```ts
* import {Component, HostBinding} from '\@angular/core';
*
* \@Component({
* selector: 'app-component',
* templateUrl: 'app.component.html',
* })
* class AppComponent {
* \@HostBinding('\@.disabled')
* public animationsDisabled = true;
* }
* ```
*
* ### What about animations that us `query()` and `animateChild()`?
* Despite inner animations being disabled, a parent animation can {\@link query query} for inner
* elements located in disabled areas of the template and still animate them as it sees fit. This is
* also the case for when a sub animation is queried by a parent and then later animated using {\@link
* animateChild animateChild}.
*
* \@experimental Animation support is experimental.
* @param {?} name
* @param {?} definitions
* @return {?}
*/
function trigger$1(name, definitions) {
return { type: 7 /* Trigger */, name: name, definitions: definitions, options: {} };
}
/**
* `animate` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `animate` specifies an animation step that will apply the provided `styles` data for a given
* amount of time based on the provided `timing` expression value. Calls to `animate` are expected
* to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
* transition transition}.
*
* ### Usage
*
* The `animate` function accepts two input parameters: `timing` and `styles`:
*
* - `timing` is a string based value that can be a combination of a duration with optional delay
* and easing values. The format for the expression breaks down to `duration delay easing`
* (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
* delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
* `duration` value in millisecond form.
* - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
* keyframes keyframes}. If left empty then the styles from the destination state will be collected
* and used (this is useful when describing an animation step that will complete an animation by
* {\@link transition#the-final-animate-call animating to the final state}).
*
* ```typescript
* // various functions for specifying timing data
* animate(500, style(...))
* animate("1s", style(...))
* animate("100ms 0.5s", style(...))
* animate("5s ease", style(...))
* animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
*
* // either style() of keyframes() can be used
* animate(500, style({ background: "red" }))
* animate(500, keyframes([
* style({ background: "blue" })),
* style({ background: "red" }))
* ])
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} timings
* @param {?=} styles
* @return {?}
*/
function animate$1(timings, styles) {
if (styles === void 0) {
styles = null;
}
return { type: 4 /* Animate */, styles: styles, timings: timings };
}
/**
* `group` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
* useful when a series of styles must be animated/closed off at different starting/ending times.
*
* The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
* transition} and it will only continue to the next instruction once all of the inner animation
* steps have completed.
*
* ### Usage
*
* The `steps` data that is passed into the `group` animation function can either consist of {\@link
* style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
* within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
* animate#usage animate() with a delay value} to offset styles to be applied at a later time).
*
* ```typescript
* group([
* animate("1s", { background: "black" }))
* animate("2s", { color: "white" }))
* ])
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} steps
* @param {?=} options
* @return {?}
*/
function group$1(steps, options) {
if (options === void 0) {
options = null;
}
return { type: 3 /* Group */, steps: steps, options: options };
}
/**
* `sequence` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
* default when an array is passed as animation data into {\@link transition transition}.)
*
* The `sequence` function can either be used within a {\@link group group} or a {\@link transition
* transition} and it will only continue to the next instruction once each of the inner animation
* steps have completed.
*
* To perform animation styling in parallel with other animation steps then have a look at the
* {\@link group group} animation function.
*
* ### Usage
*
* The `steps` data that is passed into the `sequence` animation function can either consist of
* {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
* provided styling data immediately while a call to `animate()` will apply its styling data over a
* given time depending on its timing data.
*
* ```typescript
* sequence([
* style({ opacity: 0 })),
* animate("1s", { opacity: 1 }))
* ])
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} steps
* @param {?=} options
* @return {?}
*/
function sequence$1(steps, options) {
if (options === void 0) {
options = null;
}
return { type: 2 /* Sequence */, steps: steps, options: options };
}
/**
* `style` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `style` declares a key/value object containing CSS properties/styles that can then be used for
* {\@link state animation states}, within an {\@link sequence animation sequence}, or as styling data
* for both {\@link animate animate} and {\@link keyframes keyframes}.
*
* ### Usage
*
* `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
* to be defined.
*
* ```typescript
* // string values are used for css properties
* style({ background: "red", color: "blue" })
*
* // numerical (pixel) values are also supported
* style({ width: 100, height: 0 })
* ```
*
* #### Auto-styles (using `*`)
*
* When an asterix (`*`) character is used as a value then it will be detected from the element
* being animated and applied as animation data when the animation starts.
*
* This feature proves useful for a state depending on layout and/or environment factors; in such
* cases the styles are calculated just before the animation starts.
*
* ```typescript
* // the steps below will animate from 0 to the
* // actual height of the element
* style({ height: 0 }),
* animate("1s", style({ height: "*" }))
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} tokens
* @return {?}
*/
function style$1(tokens) {
return { type: 6 /* Style */, styles: tokens, offset: null };
}
/**
* `state` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `state` declares an animation state within the given trigger. When a state is active within a
* component then its associated styles will persist on the element that the trigger is attached to
* (even when the animation ends).
*
* To animate between states, have a look at the animation {\@link transition transition} DSL
* function. To register states to an animation trigger please have a look at the {\@link trigger
* trigger} function.
*
* #### The `void` state
*
* The `void` state value is a reserved word that angular uses to determine when the element is not
* apart of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
* associated element is void).
*
* #### The `*` (default) state
*
* The `*` state (when styled) is a fallback state that will be used if the state that is being
* animated is not declared within the trigger.
*
* ### Usage
*
* `state` will declare an animation state with its associated styles
* within the given trigger.
*
* - `stateNameExpr` can be one or more state names separated by commas.
* - `styles` refers to the {\@link style styling data} that will be persisted on the element once
* the state has been reached.
*
* ```typescript
* // "void" is a reserved name for a state and is used to represent
* // the state in which an element is detached from from the application.
* state("void", style({ height: 0 }))
*
* // user-defined states
* state("closed", style({ height: 0 }))
* state("open, visible", style({ height: "*" }))
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} name
* @param {?} styles
* @param {?=} options
* @return {?}
*/
function state$1(name, styles, options) {
return { type: 0 /* State */, name: name, styles: styles, options: options };
}
/**
* `keyframes` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `keyframes` specifies a collection of {\@link style style} entries each optionally characterized
* by an `offset` value.
*
* ### Usage
*
* The `keyframes` animation function is designed to be used alongside the {\@link animate animate}
* animation function. Instead of applying animations from where they are currently to their
* destination, keyframes can describe how each style entry is applied and at what point within the
* animation arc (much like CSS Keyframe Animations do).
*
* For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at what
* percentage of the animate time the styles will be applied.
*
* ```typescript
* // the provided offset values describe when each backgroundColor value is applied.
* animate("5s", keyframes([
* style({ backgroundColor: "red", offset: 0 }),
* style({ backgroundColor: "blue", offset: 0.2 }),
* style({ backgroundColor: "orange", offset: 0.3 }),
* style({ backgroundColor: "black", offset: 1 })
* ]))
* ```
*
* Alternatively, if there are no `offset` values used within the style entries then the offsets
* will be calculated automatically.
*
* ```typescript
* animate("5s", keyframes([
* style({ backgroundColor: "red" }) // offset = 0
* style({ backgroundColor: "blue" }) // offset = 0.33
* style({ backgroundColor: "orange" }) // offset = 0.66
* style({ backgroundColor: "black" }) // offset = 1
* ]))
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} steps
* @return {?}
*/
function keyframes$1(steps) {
return { type: 5 /* Keyframes */, steps: steps };
}
/**
* `transition` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. If this information is new, please navigate to the {\@link
* Component#animations component animations metadata page} to gain a better understanding of
* how animations in Angular are used.
*
* `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
* provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
* state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
* and/or ending state).
*
* A function can also be provided as the `stateChangeExpr` argument for a transition and this
* function will be executed each time a state change occurs. If the value returned within the
* function is true then the associated animation will be run.
*
* Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
* to animate to a state value and persist its styles then one or more {\@link state animation
* states} is expected to be defined.
*
* ### Usage
*
* An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
* what the previous state is and what the current state has become. In other words, if a transition
* is defined that matches the old/current state criteria then the associated animation will be
* triggered.
*
* ```typescript
* // all transition/state changes are defined within an animation trigger
* trigger("myAnimationTrigger", [
* // if a state is defined then its styles will be persisted when the
* // animation has fully completed itself
* state("on", style({ background: "green" })),
* state("off", style({ background: "grey" })),
*
* // a transition animation that will be kicked off when the state value
* // bound to "myAnimationTrigger" changes from "on" to "off"
* transition("on => off", animate(500)),
*
* // it is also possible to do run the same animation for both directions
* transition("on <=> off", animate(500)),
*
* // or to define multiple states pairs separated by commas
* transition("on => off, off => void", animate(500)),
*
* // this is a catch-all state change for when an element is inserted into
* // the page and the destination state is unknown
* transition("void => *", [
* style({ opacity: 0 }),
* animate(500)
* ]),
*
* // this will capture a state change between any states
* transition("* => *", animate("1s 0s")),
*
* // you can also go full out and include a function
* transition((fromState, toState) => {
* // when `true` then it will allow the animation below to be invoked
* return fromState == "off" && toState == "on";
* }, animate("1s 0s"))
* ])
* ```
*
* The template associated with this component will make use of the `myAnimationTrigger` animation
* trigger by binding to an element within its template code.
*
* ```html
* <!-- somewhere inside of my-component-tpl.html -->
* <div [\@myAnimationTrigger]="myStatusExp">...</div>
* ```
*
* #### The final `animate` call
*
* If the final step within the transition steps is a call to `animate()` that **only** uses a
* timing value with **no style data** then it will be automatically used as the final animation arc
* for the element to animate itself to the final state. This involves an automatic mix of
* adding/removing CSS styles so that the element will be in the exact state it should be for the
* applied state to be presented correctly.
*
* ```
* // start off by hiding the element, but make sure that it animates properly to whatever state
* // is currently active for "myAnimationTrigger"
* transition("void => *", [
* style({ opacity: 0 }),
* animate(500)
* ])
* ```
*
* ### Using :enter and :leave
*
* Given that enter (insertion) and leave (removal) animations are so common, the `transition`
* function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
* => void` state changes.
*
* ```
* transition(":enter", [
* style({ opacity: 0 }),
* animate(500, style({ opacity: 1 }))
* ]),
* transition(":leave", [
* animate(500, style({ opacity: 0 }))
* ])
* ```
*
* ### Boolean values
* if a trigger binding value is a boolean value then it can be matched using a transition
* expression that compares `true` and `false` or `1` and `0`.
*
* ```
* // in the template
* <div [\@openClose]="open ? true : false">...</div>
*
* // in the component metadata
* trigger('openClose', [
* state('true', style({ height: '*' })),
* state('false', style({ height: '0px' })),
* transition('false <=> true', animate(500))
* ])
* ```
*
* ### Using :increment and :decrement
* In addition to the :enter and :leave transition aliases, the :increment and :decrement aliases
* can be used to kick off a transition when a numeric value has increased or decreased in value.
*
* ```
* import {group, animate, query, transition, style, trigger} from '\@angular/animations';
* import {Component} from '\@angular/core';
*
* \@Component({
* selector: 'banner-carousel-component',
* styles: [`
* .banner-container {
* position:relative;
* height:500px;
* overflow:hidden;
* }
* .banner-container > .banner {
* position:absolute;
* left:0;
* top:0;
* font-size:200px;
* line-height:500px;
* font-weight:bold;
* text-align:center;
* width:100%;
* }
* `],
* template: `
* <button (click)="previous()">Previous</button>
* <button (click)="next()">Next</button>
* <hr>
* <div [\@bannerAnimation]="selectedIndex" class="banner-container">
* <div class="banner"> {{ banner }} </div>
* </div>
* `
* animations: [
* trigger('bannerAnimation', [
* transition(":increment", group([
* query(':enter', [
* style({ left: '100%' }),
* animate('0.5s ease-out', style('*'))
* ]),
* query(':leave', [
* animate('0.5s ease-out', style({ left: '-100%' }))
* ])
* ])),
* transition(":decrement", group([
* query(':enter', [
* style({ left: '-100%' }),
* animate('0.5s ease-out', style('*'))
* ]),
* query(':leave', [
* animate('0.5s ease-out', style({ left: '100%' }))
* ])
* ])),
* ])
* ]
* })
* class BannerCarouselComponent {
* allBanners: string[] = ['1', '2', '3', '4'];
* selectedIndex: number = 0;
*
* get banners() {
* return [this.allBanners[this.selectedIndex]];
* }
*
* previous() {
* this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
* }
*
* next() {
* this.selectedIndex = Math.min(this.selectedIndex + 1, this.allBanners.length - 1);
* }
* }
* ```
*
* {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
*
* \@experimental Animation support is experimental.
* @param {?} stateChangeExpr
* @param {?} steps
* @param {?=} options
* @return {?}
*/
function transition$1(stateChangeExpr, steps, options) {
if (options === void 0) {
options = null;
}
return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options: options };
}
/**
* `animation` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language.
*
* `var myAnimation = animation(...)` is designed to produce a reusable animation that can be later
* invoked in another animation or sequence. Reusable animations are designed to make use of
* animation parameters and the produced animation can be used via the `useAnimation` method.
*
* ```
* var fadeAnimation = animation([
* style({ opacity: '{{ start }}' }),
* animate('{{ time }}',
* style({ opacity: '{{ end }}'}))
* ], { params: { time: '1000ms', start: 0, end: 1 }});
* ```
*
* If parameters are attached to an animation then they act as **default parameter values**. When an
* animation is invoked via `useAnimation` then parameter values are allowed to be passed in
* directly. If any of the passed in parameter values are missing then the default values will be
* used.
*
* ```
* useAnimation(fadeAnimation, {
* params: {
* time: '2s',
* start: 1,
* end: 0
* }
* })
* ```
*
* If one or more parameter values are missing before animated then an error will be thrown.
*
* \@experimental Animation support is experimental.
* @param {?} steps
* @param {?=} options
* @return {?}
*/
/**
* `animateChild` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. It works by allowing a queried element to execute its own
* animation within the animation sequence.
*
* Each time an animation is triggered in angular, the parent animation
* will always get priority and any child animations will be blocked. In order
* for a child animation to run, the parent animation must query each of the elements
* containing child animations and then allow the animations to run using `animateChild`.
*
* The example HTML code below shows both parent and child elements that have animation
* triggers that will execute at the same time.
*
* ```html
* <!-- parent-child.component.html -->
* <button (click)="exp =! exp">Toggle</button>
* <hr>
*
* <div [\@parentAnimation]="exp">
* <header>Hello</header>
* <div [\@childAnimation]="exp">
* one
* </div>
* <div [\@childAnimation]="exp">
* two
* </div>
* <div [\@childAnimation]="exp">
* three
* </div>
* </div>
* ```
*
* Now when the `exp` value changes to true, only the `parentAnimation` animation will animate
* because it has priority. However, using `query` and `animateChild` each of the inner animations
* can also fire:
*
* ```ts
* // parent-child.component.ts
* import {trigger, transition, animate, style, query, animateChild} from '\@angular/animations';
* \@Component({
* selector: 'parent-child-component',
* animations: [
* trigger('parentAnimation', [
* transition('false => true', [
* query('header', [
* style({ opacity: 0 }),
* animate(500, style({ opacity: 1 }))
* ]),
* query('\@childAnimation', [
* animateChild()
* ])
* ])
* ]),
* trigger('childAnimation', [
* transition('false => true', [
* style({ opacity: 0 }),
* animate(500, style({ opacity: 1 }))
* ])
* ])
* ]
* })
* class ParentChildCmp {
* exp: boolean = false;
* }
* ```
*
* In the animation code above, when the `parentAnimation` transition kicks off it first queries to
* find the header element and fades it in. It then finds each of the sub elements that contain the
* `\@childAnimation` trigger and then allows for their animations to fire.
*
* This example can be further extended by using stagger:
*
* ```ts
* query('\@childAnimation', stagger(100, [
* animateChild()
* ]))
* ```
*
* Now each of the sub animations start off with respect to the `100ms` staggering step.
*
* ## The first frame of child animations
* When sub animations are executed using `animateChild` the animation engine will always apply the
* first frame of every sub animation immediately at the start of the animation sequence. This way
* the parent animation does not need to set any initial styling data on the sub elements before the
* sub animations kick off.
*
* In the example above the first frame of the `childAnimation`'s `false => true` transition
* consists of a style of `opacity: 0`. This is applied immediately when the `parentAnimation`
* animation transition sequence starts. Only then when the `\@childAnimation` is queried and called
* with `animateChild` will it then animate to its destination of `opacity: 1`.
*
* Note that this feature designed to be used alongside {\@link query query()} and it will only work
* with animations that are assigned using the Angular animation DSL (this means that CSS keyframes
* and transitions are not handled by this API).
*
* \@experimental Animation support is experimental.
* @param {?=} options
* @return {?}
*/
/**
* `useAnimation` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. It is used to kick off a reusable animation that is created using {\@link
* animation animation()}.
*
* \@experimental Animation support is experimental.
* @param {?} animation
* @param {?=} options
* @return {?}
*/
/**
* `query` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language.
*
* query() is used to find one or more inner elements within the current element that is
* being animated within the sequence. The provided animation steps are applied
* to the queried element (by default, an array is provided, then this will be
* treated as an animation sequence).
*
* ### Usage
*
* query() is designed to collect mutiple elements and works internally by using
* `element.querySelectorAll`. An additional options object can be provided which
* can be used to limit the total amount of items to be collected.
*
* ```js
* query('div', [
* animate(...),
* animate(...)
* ], { limit: 1 })
* ```
*
* query(), by default, will throw an error when zero items are found. If a query
* has the `optional` flag set to true then this error will be ignored.
*
* ```js
* query('.some-element-that-may-not-be-there', [
* animate(...),
* animate(...)
* ], { optional: true })
* ```
*
* ### Special Selector Values
*
* The selector value within a query can collect elements that contain angular-specific
* characteristics
* using special pseudo-selectors tokens.
*
* These include:
*
* - Querying for newly inserted/removed elements using `query(":enter")`/`query(":leave")`
* - Querying all currently animating elements using `query(":animating")`
* - Querying elements that contain an animation trigger using `query("\@triggerName")`
* - Querying all elements that contain an animation triggers using `query("\@*")`
* - Including the current element into the animation sequence using `query(":self")`
*
*
* Each of these pseudo-selector tokens can be merged together into a combined query selector
* string:
*
* ```
* query(':self, .record:enter, .record:leave, \@subTrigger', [...])
* ```
*
* ### Demo
*
* ```
* \@Component({
* selector: 'inner',
* template: `
* <div [\@queryAnimation]="exp">
* <h1>Title</h1>
* <div class="content">
* Blah blah blah
* </div>
* </div>
* `,
* animations: [
* trigger('queryAnimation', [
* transition('* => goAnimate', [
* // hide the inner elements
* query('h1', style({ opacity: 0 })),
* query('.content', style({ opacity: 0 })),
*
* // animate the inner elements in, one by one
* query('h1', animate(1000, style({ opacity: 1 })),
* query('.content', animate(1000, style({ opacity: 1 })),
* ])
* ])
* ]
* })
* class Cmp {
* exp = '';
*
* goAnimate() {
* this.exp = 'goAnimate';
* }
* }
* ```
*
* \@experimental Animation support is experimental.
* @param {?} selector
* @param {?} animation
* @param {?=} options
* @return {?}
*/
/**
* `stagger` is an animation-specific function that is designed to be used inside of Angular's
* animation DSL language. It is designed to be used inside of an animation {\@link query query()}
* and works by issuing a timing gap between after each queried item is animated.
*
* ### Usage
*
* In the example below there is a container element that wraps a list of items stamped out
* by an ngFor. The container element contains an animation trigger that will later be set
* to query for each of the inner items.
*
* ```html
* <!-- list.component.html -->
* <button (click)="toggle()">Show / Hide Items</button>
* <hr />
* <div [\@listAnimation]="items.length">
* <div *ngFor="let item of items">
* {{ item }}
* </div>
* </div>
* ```
*
* The component code for this looks as such:
*
* ```ts
* import {trigger, transition, style, animate, query, stagger} from '\@angular/animations';
* \@Component({
* templateUrl: 'list.component.html',
* animations: [
* trigger('listAnimation', [
* //...
* ])
* ]
* })
* class ListComponent {
* items = [];
*
* showItems() {
* this.items = [0,1,2,3,4];
* }
*
* hideItems() {
* this.items = [];
* }
*
* toggle() {
* this.items.length ? this.hideItems() : this.showItems();
* }
* }
* ```
*
* And now for the animation trigger code:
*
* ```ts
* trigger('listAnimation', [
* transition('* => *', [ // each time the binding value changes
* query(':leave', [
* stagger(100, [
* animate('0.5s', style({ opacity: 0 }))
* ])
* ]),
* query(':enter', [
* style({ opacity: 0 }),
* stagger(100, [
* animate('0.5s', style({ opacity: 1 }))
* ])
* ])
* ])
* ])
* ```
*
* Now each time the items are added/removed then either the opacity
* fade-in animation will run or each removed item will be faded out.
* When either of these animations occur then a stagger effect will be
* applied after each item's animation is started.
*
* \@experimental Animation support is experimental.
* @param {?} timings
* @param {?} animation
* @return {?}
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
*/
var AUTO_STYLE = '*';
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @record
*/
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} name
* @param {?} definitions
* @return {?}
*/
function trigger$$1(name, definitions) {
return trigger$1(name, definitions);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} timings
* @param {?=} styles
* @return {?}
*/
function animate$$1(timings, styles) {
return animate$1(timings, styles);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} steps
* @return {?}
*/
function group$$1(steps) {
return group$1(steps);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} steps
* @return {?}
*/
function sequence$$1(steps) {
return sequence$1(steps);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} tokens
* @return {?}
*/
function style$$1(tokens) {
return style$1(tokens);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} name
* @param {?} styles
* @return {?}
*/
function state$$1(name, styles) {
return state$1(name, styles);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} steps
* @return {?}
*/
function keyframes$$1(steps) {
return keyframes$1(steps);
}
/**
* @deprecated This symbol has moved. Please Import from \@angular/animations instead!
* @param {?} stateChangeExpr
* @param {?} steps
* @return {?}
*/
function transition$$1(stateChangeExpr, steps) {
return transition$1(stateChangeExpr, steps);
}
exports.createPlatform = createPlatform;
exports.assertPlatform = assertPlatform;
exports.destroyPlatform = destroyPlatform;
exports.getPlatform = getPlatform;
exports.PlatformRef = PlatformRef;
exports.ApplicationRef = ApplicationRef;
exports.enableProdMode = enableProdMode;
exports.isDevMode = isDevMode;
exports.createPlatformFactory = createPlatformFactory;
exports.NgProbeToken = NgProbeToken;
exports.APP_ID = APP_ID;
exports.PACKAGE_ROOT_URL = PACKAGE_ROOT_URL;
exports.PLATFORM_INITIALIZER = PLATFORM_INITIALIZER;
exports.PLATFORM_ID = PLATFORM_ID;
exports.APP_BOOTSTRAP_LISTENER = APP_BOOTSTRAP_LISTENER;
exports.APP_INITIALIZER = APP_INITIALIZER;
exports.ApplicationInitStatus = ApplicationInitStatus;
exports.DebugElement = DebugElement;
exports.DebugNode = DebugNode;
exports.asNativeElements = asNativeElements;
exports.getDebugNode = getDebugNode;
exports.Testability = Testability;
exports.TestabilityRegistry = TestabilityRegistry;
exports.setTestabilityGetter = setTestabilityGetter;
exports.TRANSLATIONS = TRANSLATIONS;
exports.TRANSLATIONS_FORMAT = TRANSLATIONS_FORMAT;
exports.LOCALE_ID = LOCALE_ID;
exports.MissingTranslationStrategy = MissingTranslationStrategy;
exports.ApplicationModule = ApplicationModule;
exports.wtfCreateScope = wtfCreateScope;
exports.wtfLeave = wtfLeave;
exports.wtfStartTimeRange = wtfStartTimeRange;
exports.wtfEndTimeRange = wtfEndTimeRange;
exports.Type = Type;
exports.EventEmitter = EventEmitter;
exports.ErrorHandler = ErrorHandler;
exports.Sanitizer = Sanitizer;
exports.SecurityContext = SecurityContext;
exports.ANALYZE_FOR_ENTRY_COMPONENTS = ANALYZE_FOR_ENTRY_COMPONENTS;
exports.Attribute = Attribute;
exports.ContentChild = ContentChild;
exports.ContentChildren = ContentChildren;
exports.Query = Query;
exports.ViewChild = ViewChild;
exports.ViewChildren = ViewChildren;
exports.Component = Component;
exports.Directive = Directive;
exports.HostBinding = HostBinding;
exports.HostListener = HostListener;
exports.Input = Input;
exports.Output = Output;
exports.Pipe = Pipe;
exports.CUSTOM_ELEMENTS_SCHEMA = CUSTOM_ELEMENTS_SCHEMA;
exports.NO_ERRORS_SCHEMA = NO_ERRORS_SCHEMA;
exports.NgModule = NgModule;
exports.ViewEncapsulation = ViewEncapsulation;
exports.Version = Version;
exports.VERSION = VERSION;
exports.forwardRef = forwardRef;
exports.resolveForwardRef = resolveForwardRef;
exports.Injector = Injector;
exports.ReflectiveInjector = ReflectiveInjector;
exports.ResolvedReflectiveFactory = ResolvedReflectiveFactory;
exports.ReflectiveKey = ReflectiveKey;
exports.InjectionToken = InjectionToken;
exports.Inject = Inject;
exports.Optional = Optional;
exports.Injectable = Injectable;
exports.Self = Self;
exports.SkipSelf = SkipSelf;
exports.Host = Host;
exports.NgZone = NgZone;
exports.RenderComponentType = RenderComponentType;
exports.Renderer = Renderer;
exports.Renderer2 = Renderer2;
exports.RendererFactory2 = RendererFactory2;
exports.RendererStyleFlags2 = RendererStyleFlags2;
exports.RootRenderer = RootRenderer;
exports.COMPILER_OPTIONS = COMPILER_OPTIONS;
exports.Compiler = Compiler;
exports.CompilerFactory = CompilerFactory;
exports.ModuleWithComponentFactories = ModuleWithComponentFactories;
exports.ComponentFactory = ComponentFactory;
exports.ComponentRef = ComponentRef;
exports.ComponentFactoryResolver = ComponentFactoryResolver;
exports.ElementRef = ElementRef;
exports.NgModuleFactory = NgModuleFactory;
exports.NgModuleRef = NgModuleRef;
exports.NgModuleFactoryLoader = NgModuleFactoryLoader;
exports.getModuleFactory = getModuleFactory;
exports.QueryList = QueryList;
exports.SystemJsNgModuleLoader = SystemJsNgModuleLoader;
exports.SystemJsNgModuleLoaderConfig = SystemJsNgModuleLoaderConfig;
exports.TemplateRef = TemplateRef;
exports.ViewContainerRef = ViewContainerRef;
exports.EmbeddedViewRef = EmbeddedViewRef;
exports.ViewRef = ViewRef;
exports.ChangeDetectionStrategy = ChangeDetectionStrategy;
exports.ChangeDetectorRef = ChangeDetectorRef;
exports.DefaultIterableDiffer = DefaultIterableDiffer;
exports.IterableDiffers = IterableDiffers;
exports.KeyValueDiffers = KeyValueDiffers;
exports.SimpleChange = SimpleChange;
exports.WrappedValue = WrappedValue;
exports.platformCore = platformCore;
exports.ɵALLOW_MULTIPLE_PLATFORMS = ALLOW_MULTIPLE_PLATFORMS;
exports.ɵAPP_ID_RANDOM_PROVIDER = APP_ID_RANDOM_PROVIDER;
exports.ɵValueUnwrapper = ValueUnwrapper;
exports.ɵdevModeEqual = devModeEqual;
exports.ɵisListLikeIterable = isListLikeIterable;
exports.ɵChangeDetectorStatus = ChangeDetectorStatus;
exports.ɵisDefaultChangeDetectionStrategy = isDefaultChangeDetectionStrategy;
exports.ɵConsole = Console;
exports.ɵComponentFactory = ComponentFactory;
exports.ɵCodegenComponentFactoryResolver = CodegenComponentFactoryResolver;
exports.ɵReflectionCapabilities = ReflectionCapabilities;
exports.ɵRenderDebugInfo = RenderDebugInfo;
exports.ɵglobal = _global;
exports.ɵlooseIdentical = looseIdentical;
exports.ɵstringify = stringify;
exports.ɵmakeDecorator = makeDecorator;
exports.ɵisObservable = isObservable;
exports.ɵisPromise = isPromise;
exports.ɵclearOverrides = clearOverrides;
exports.ɵoverrideComponentView = overrideComponentView;
exports.ɵoverrideProvider = overrideProvider;
exports.ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR;
exports.ɵregisterModuleFactory = registerModuleFactory;
exports.ɵEMPTY_ARRAY = EMPTY_ARRAY;
exports.ɵEMPTY_MAP = EMPTY_MAP;
exports.ɵand = anchorDef;
exports.ɵccf = createComponentFactory;
exports.ɵcmf = createNgModuleFactory;
exports.ɵcrt = createRendererType2;
exports.ɵdid = directiveDef;
exports.ɵeld = elementDef;
exports.ɵelementEventFullName = elementEventFullName;
exports.ɵgetComponentViewDefinitionFactory = getComponentViewDefinitionFactory;
exports.ɵinlineInterpolate = inlineInterpolate;
exports.ɵinterpolate = interpolate;
exports.ɵmod = moduleDef;
exports.ɵmpd = moduleProvideDef;
exports.ɵncd = ngContentDef;
exports.ɵnov = nodeValue;
exports.ɵpid = pipeDef;
exports.ɵprd = providerDef;
exports.ɵpad = pureArrayDef;
exports.ɵpod = pureObjectDef;
exports.ɵppd = purePipeDef;
exports.ɵqud = queryDef;
exports.ɵted = textDef;
exports.ɵunv = unwrapValue;
exports.ɵvid = viewDef;
exports.AUTO_STYLE = AUTO_STYLE;
exports.trigger = trigger$$1;
exports.animate = animate$$1;
exports.group = group$$1;
exports.sequence = sequence$$1;
exports.style = style$$1;
exports.state = state$$1;
exports.keyframes = keyframes$$1;
exports.transition = transition$$1;
exports.ɵx = animate$1;
exports.ɵy = group$1;
exports.ɵbc = keyframes$1;
exports.ɵz = sequence$1;
exports.ɵbb = state$1;
exports.ɵba = style$1;
exports.ɵbd = transition$1;
exports.ɵw = trigger$1;
exports.ɵk = _iterableDiffersFactory;
exports.ɵl = _keyValueDiffersFactory;
exports.ɵm = _localeFactory;
exports.ɵf = _appIdRandomProviderFactory;
exports.ɵg = defaultIterableDiffers;
exports.ɵh = defaultKeyValueDiffers;
exports.ɵi = DefaultIterableDifferFactory;
exports.ɵj = DefaultKeyValueDifferFactory;
exports.ɵb = StaticInjector;
exports.ɵc = ReflectiveInjector_;
exports.ɵd = ReflectiveDependency;
exports.ɵe = resolveReflectiveProviders;
exports.ɵn = wtfEnabled;
exports.ɵp = createScope;
exports.ɵo = detectWTF;
exports.ɵs = endTimeRange;
exports.ɵq = leave;
exports.ɵr = startTimeRange;
exports.ɵa = makeParamDecorator;
exports.ɵt = _def;
exports.ɵu = DebugContext;
Object.defineProperty(exports, '__esModule', { value: true });
});
System.registerDynamic('adal-angular', [], true, function ($__require, exports, module) {
var global = this || self,
GLOBAL = global;
//----------------------------------------------------------------------
// AdalJS v1.0.15
// @preserve Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
// Apache License 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//id
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//----------------------------------------------------------------------
var AuthenticationContext = function () {
'use strict';
/**
* Configuration options for Authentication Context.
* @class config
* @property {string} tenant - Your target tenant.
* @property {string} clientID - Client ID assigned to your app by Azure Active Directory.
* @property {string} redirectUri - Endpoint at which you expect to receive tokens.Defaults to `window.location.href`.
* @property {string} instance - Azure Active Directory Instance.Defaults to `https://login.microsoftonline.com/`.
* @property {Array} endpoints - Collection of {Endpoint-ResourceId} used for automatically attaching tokens in webApi calls.
* @property {Boolean} popUp - Set this to true to enable login in a popup winodow instead of a full redirect.Defaults to `false`.
* @property {string} localLoginUrl - Set this to redirect the user to a custom login page.
* @property {function} displayCall - User defined function of handling the navigation to Azure AD authorization endpoint in case of login. Defaults to 'null'.
* @property {string} postLogoutRedirectUri - Redirects the user to postLogoutRedirectUri after logout. Defaults is 'redirectUri'.
* @property {string} cacheLocation - Sets browser storage to either 'localStorage' or sessionStorage'. Defaults to 'sessionStorage'.
* @property {Array.<string>} anonymousEndpoints Array of keywords or URI's. Adal will not attach a token to outgoing requests that have these keywords or uri. Defaults to 'null'.
* @property {number} expireOffsetSeconds If the cached token is about to be expired in the expireOffsetSeconds (in seconds), Adal will renew the token instead of using the cached token. Defaults to 120 seconds.
* @property {string} correlationId Unique identifier used to map the request with the response. Defaults to RFC4122 version 4 guid (128 bits).
*/
/**
* Creates a new AuthenticationContext object.
* @constructor
* @param {config} config Configuration options for AuthenticationContext
*/
AuthenticationContext = function (config) {
/**
* Enum for request type
* @enum {string}
*/
this.REQUEST_TYPE = {
LOGIN: 'LOGIN',
RENEW_TOKEN: 'RENEW_TOKEN',
UNKNOWN: 'UNKNOWN'
};
/**
* Enum for storage constants
* @enum {string}
*/
this.CONSTANTS = {
ACCESS_TOKEN: 'access_token',
EXPIRES_IN: 'expires_in',
ID_TOKEN: 'id_token',
ERROR_DESCRIPTION: 'error_description',
SESSION_STATE: 'session_state',
STORAGE: {
TOKEN_KEYS: 'adal.token.keys',
ACCESS_TOKEN_KEY: 'adal.access.token.key',
EXPIRATION_KEY: 'adal.expiration.key',
STATE_LOGIN: 'adal.state.login',
STATE_RENEW: 'adal.state.renew',
NONCE_IDTOKEN: 'adal.nonce.idtoken',
SESSION_STATE: 'adal.session.state',
USERNAME: 'adal.username',
IDTOKEN: 'adal.idtoken',
ERROR: 'adal.error',
ERROR_DESCRIPTION: 'adal.error.description',
LOGIN_REQUEST: 'adal.login.request',
LOGIN_ERROR: 'adal.login.error',
RENEW_STATUS: 'adal.token.renew.status'
},
RESOURCE_DELIMETER: '|',
LOADFRAME_TIMEOUT: '6000',
TOKEN_RENEW_STATUS_CANCELED: 'Canceled',
TOKEN_RENEW_STATUS_COMPLETED: 'Completed',
TOKEN_RENEW_STATUS_IN_PROGRESS: 'In Progress',
LOGGING_LEVEL: {
ERROR: 0,
WARN: 1,
INFO: 2,
VERBOSE: 3
},
LEVEL_STRING_MAP: {
0: 'ERROR:',
1: 'WARNING:',
2: 'INFO:',
3: 'VERBOSE:'
},
POPUP_WIDTH: 483,
POPUP_HEIGHT: 600
};
if (AuthenticationContext.prototype._singletonInstance) {
return AuthenticationContext.prototype._singletonInstance;
}
AuthenticationContext.prototype._singletonInstance = this;
// public
this.instance = 'https://login.microsoftonline.com/';
this.config = {};
this.callback = null;
this.popUp = false;
this.isAngular = false;
// private
this._user = null;
this._activeRenewals = {};
this._loginInProgress = false;
this._acquireTokenInProgress = false;
window.renewStates = [];
window.callBackMappedToRenewStates = {};
window.callBacksMappedToRenewStates = {};
// validate before constructor assignments
if (config.displayCall && typeof config.displayCall !== 'function') {
throw new Error('displayCall is not a function');
}
if (!config.clientId) {
throw new Error('clientId is required');
}
this.config = this._cloneConfig(config);
if (this.config.navigateToLoginRequestUrl === undefined) this.config.navigateToLoginRequestUrl = true;
if (this.config.popUp) this.popUp = true;
if (this.config.callback && typeof this.config.callback === 'function') this.callback = this.config.callback;
if (this.config.instance) {
this.instance = this.config.instance;
}
// App can request idtoken for itself using clientid as resource
if (!this.config.loginResource) {
this.config.loginResource = this.config.clientId;
}
// redirect and logout_redirect are set to current location by default
if (!this.config.redirectUri) {
// strip off query parameters or hashes from the redirect uri as AAD does not allow those.
this.config.redirectUri = window.location.href.split("?")[0].split("#")[0];
}
if (!this.config.postLogoutRedirectUri) {
// strip off query parameters or hashes from the post logout redirect uri as AAD does not allow those.
this.config.postLogoutRedirectUri = window.location.href.split("?")[0].split("#")[0];
}
if (!this.config.anonymousEndpoints) {
this.config.anonymousEndpoints = [];
}
if (this.config.isAngular) {
this.isAngular = this.config.isAngular;
}
};
window.Logging = {
level: 0,
log: function (message) {}
};
/**
* Initiates the login process by redirecting the user to Azure AD authorization endpoint.
*/
AuthenticationContext.prototype.login = function (loginStartPage) {
// Token is not present and user needs to login
if (this._loginInProgress) {
this.info("Login in progress");
return;
}
var expectedState = this._guid();
this.config.state = expectedState;
this._idTokenNonce = this._guid();
this.verbose('Expected state: ' + expectedState + ' startPage:' + window.location.href);
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST, loginStartPage || window.location.href);
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR, '');
this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN, expectedState);
this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN, this._idTokenNonce);
this._saveItem(this.CONSTANTS.STORAGE.ERROR, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, '');
var urlNavigate = this._getNavigateUrl('id_token', null) + '&nonce=' + encodeURIComponent(this._idTokenNonce);
this._loginInProgress = true;
if (this.config.displayCall) {
// User defined way of handling the navigation
this.config.displayCall(urlNavigate);
} else if (this.popUp) {
this._loginPopup(urlNavigate);
} else {
this.promptUser(urlNavigate);
}
};
/**
* Configures popup window for login.
* @ignore
*/
AuthenticationContext.prototype._openPopup = function (urlNavigate, title, popUpWidth, popUpHeight) {
try {
/**
* adding winLeft and winTop to account for dual monitor
* using screenLeft and screenTop for IE8 and earlier
*/
var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
var winTop = window.screenTop ? window.screenTop : window.screenY;
/**
* window.innerWidth displays browser window's height and width excluding toolbars
* using document.documentElement.clientWidth for IE8 and earlier
*/
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var left = width / 2 - popUpWidth / 2 + winLeft;
var top = height / 2 - popUpHeight / 2 + winTop;
var popupWindow = window.open(urlNavigate, title, 'width=' + popUpWidth + ', height=' + popUpHeight + ', top=' + top + ', left=' + left);
if (popupWindow.focus) {
popupWindow.focus();
}
return popupWindow;
} catch (e) {
this.warn('Error opening popup, ' + e.message);
this._loginInProgress = false;
return null;
}
};
/**
* After authorization, the user will be sent to your specified redirect_uri with the user's bearer token
* attached to the URI fragment as an id_token field. It closes popup window after redirection.
* @ignore
*/
AuthenticationContext.prototype._loginPopup = function (urlNavigate, resource, callback) {
var popupWindow = this._openPopup(urlNavigate, "login", this.CONSTANTS.POPUP_WIDTH, this.CONSTANTS.POPUP_HEIGHT);
var loginCallback = callback || this.callback;
if (popupWindow == null) {
this.warn('Popup Window is null. This can happen if you are using IE');
this._saveItem(this.CONSTANTS.STORAGE.ERROR, 'Error opening popup');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, 'Popup Window is null. This can happen if you are using IE');
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR, 'Popup Window is null. This can happen if you are using IE');
if (resource && this._activeRenewals[resource]) {
this._activeRenewals[resource] = null;
}
this._loginInProgress = false;
this._acquireTokenInProgress = false;
if (loginCallback) loginCallback(this._getItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION), null, this._getItem(this.CONSTANTS.STORAGE.ERROR));
return;
}
if (this.config.redirectUri.indexOf('#') != -1) var registeredRedirectUri = this.config.redirectUri.split("#")[0];else var registeredRedirectUri = this.config.redirectUri;
var that = this;
var pollTimer = window.setInterval(function () {
if (!popupWindow || popupWindow.closed || popupWindow.closed === undefined) {
that._loginInProgress = false;
that._acquireTokenInProgress = false;
if (resource && that._activeRenewals[resource]) {
that._activeRenewals[resource] = null;
}
window.clearInterval(pollTimer);
}
try {
if (popupWindow.location.href.indexOf(registeredRedirectUri) != -1) {
if (that.isAngular) {
that._onPopUpHashChanged(popupWindow.location.hash);
} else {
that.handleWindowCallback(popupWindow.location.hash);
}
window.clearInterval(pollTimer);
that._loginInProgress = false;
that._acquireTokenInProgress = false;
that.info("Closing popup window");
popupWindow.close();
}
} catch (e) {}
}, 1);
};
AuthenticationContext.prototype._onPopUpHashChanged = function (hash) {
// Custom Event is not supported in IE, below IIFE will polyfill the CustomEvent() constructor functionality in Internet Explorer 9 and higher
(function () {
if (typeof window.CustomEvent === "function") {
return false;
}
function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
var evt = new CustomEvent('adal:popUpHashChanged', { detail: hash });
window.dispatchEvent(evt);
};
AuthenticationContext.prototype.loginInProgress = function () {
return this._loginInProgress;
};
/**
* Checks for the resource in the cache. By default, cache location is Session Storage
* @ignore
* @returns {Boolean} 'true' if login is in progress, else returns 'false'.
*/
AuthenticationContext.prototype._hasResource = function (key) {
var keys = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);
return keys && !this._isEmpty(keys) && keys.indexOf(key + this.CONSTANTS.RESOURCE_DELIMETER) > -1;
};
/**
* Gets token for the specified resource from the cache.
* @param {string} resource A URI that identifies the resource for which the token is requested.
* @returns {string} token if if it exists and not expired, otherwise null.
*/
AuthenticationContext.prototype.getCachedToken = function (resource) {
if (!this._hasResource(resource)) {
return null;
}
var token = this._getItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + resource);
var expiry = this._getItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + resource);
// If expiration is within offset, it will force renew
var offset = this.config.expireOffsetSeconds || 300;
if (expiry && expiry > this._now() + offset) {
return token;
} else {
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + resource, '');
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + resource, 0);
return null;
}
};
/**
* User information from idtoken.
* @class User
* @property {string} userName - username assigned from upn or email.
* @property {object} profile - properties parsed from idtoken.
*/
/**
* If user object exists, returns it. Else creates a new user object by decoding id_token from the cache.
* @returns {User} user object
*/
AuthenticationContext.prototype.getCachedUser = function () {
if (this._user) {
return this._user;
}
var idtoken = this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);
this._user = this._createUser(idtoken);
return this._user;
};
/**
* Adds the passed callback to the array of callbacks for the specified resource and puts the array on the window object.
* @param {string} resource A URI that identifies the resource for which the token is requested.
* @param {string} expectedState A unique identifier (guid).
* @param {tokenCallback} callback - The callback provided by the caller. It will be called with token or error.
*/
AuthenticationContext.prototype.registerCallback = function (expectedState, resource, callback) {
this._activeRenewals[resource] = expectedState;
if (!window.callBacksMappedToRenewStates[expectedState]) {
window.callBacksMappedToRenewStates[expectedState] = [];
}
var self = this;
window.callBacksMappedToRenewStates[expectedState].push(callback);
if (!window.callBackMappedToRenewStates[expectedState]) {
window.callBackMappedToRenewStates[expectedState] = function (errorDesc, token, error) {
self._activeRenewals[resource] = null;
for (var i = 0; i < window.callBacksMappedToRenewStates[expectedState].length; ++i) {
try {
window.callBacksMappedToRenewStates[expectedState][i](errorDesc, token, error);
} catch (error) {
self.warn(error);
}
}
window.callBacksMappedToRenewStates[expectedState] = null;
window.callBackMappedToRenewStates[expectedState] = null;
};
}
};
// var errorResponse = {error:'', error_description:''};
// var token = 'string token';
// callback(errorResponse, token)
// with callback
/**
* Acquires access token with hidden iframe
* @ignore
*/
AuthenticationContext.prototype._renewToken = function (resource, callback) {
// use iframe to try refresh token
// use given resource to create new authz url
this.info('renewToken is called for resource:' + resource);
var frameHandle = this._addAdalFrame('adalRenewFrame' + resource);
var expectedState = this._guid() + '|' + resource;
this.config.state = expectedState;
// renew happens in iframe, so it keeps javascript context
window.renewStates.push(expectedState);
this.verbose('Renew token Expected state: ' + expectedState);
var urlNavigate = this._getNavigateUrl('token', resource) + '&prompt=none';
urlNavigate = this._addHintParameters(urlNavigate);
this.registerCallback(expectedState, resource, callback);
this.verbose('Navigate to:' + urlNavigate);
frameHandle.src = 'about:blank';
this._loadFrameTimeout(urlNavigate, 'adalRenewFrame' + resource, resource);
};
/**
* Renews idtoken for app's own backend when resource is clientId and calls the callback with token/error
* @ignore
*/
AuthenticationContext.prototype._renewIdToken = function (callback) {
// use iframe to try refresh token
this.info('renewIdToken is called');
var frameHandle = this._addAdalFrame('adalIdTokenFrame');
var expectedState = this._guid() + '|' + this.config.clientId;
this._idTokenNonce = this._guid();
this._saveItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN, this._idTokenNonce);
this.config.state = expectedState;
// renew happens in iframe, so it keeps javascript context
window.renewStates.push(expectedState);
this.verbose('Renew Idtoken Expected state: ' + expectedState);
var urlNavigate = this._getNavigateUrl('id_token', null) + '&prompt=none';
urlNavigate = this._addHintParameters(urlNavigate);
urlNavigate += '&nonce=' + encodeURIComponent(this._idTokenNonce);
this.registerCallback(expectedState, this.config.clientId, callback);
this.idTokenNonce = null;
this.verbose('Navigate to:' + urlNavigate);
frameHandle.src = 'about:blank';
this._loadFrameTimeout(urlNavigate, 'adalIdTokenFrame', this.config.clientId);
};
/**
* Checks if the authorization endpoint URL contains query string parameters
* @ignore
*/
AuthenticationContext.prototype._urlContainsQueryStringParameter = function (name, url) {
// regex to detect pattern of a ? or & followed by the name parameter and an equals character
var regex = new RegExp("[\\?&]" + name + "=");
return regex.test(url);
};
// Calling _loadFrame but with a timeout to signal failure in loadframeStatus. Callbacks are left
// registered when network errors occur and subsequent token requests for same resource are registered to the pending request
/**
* @ignore
*/
AuthenticationContext.prototype._loadFrameTimeout = function (urlNavigation, frameName, resource) {
//set iframe session to pending
this.verbose('Set loading state to pending for: ' + resource);
this._saveItem(this.CONSTANTS.STORAGE.RENEW_STATUS + resource, this.CONSTANTS.TOKEN_RENEW_STATUS_IN_PROGRESS);
this._loadFrame(urlNavigation, frameName);
var self = this;
setTimeout(function () {
if (self._getItem(self.CONSTANTS.STORAGE.RENEW_STATUS + resource) === self.CONSTANTS.TOKEN_RENEW_STATUS_IN_PROGRESS) {
// fail the iframe session if it's in pending state
self.verbose('Loading frame has timed out after: ' + self.CONSTANTS.LOADFRAME_TIMEOUT / 1000 + ' seconds for resource ' + resource);
var expectedState = self._activeRenewals[resource];
if (expectedState && window.callBackMappedToRenewStates[expectedState]) {
window.callBackMappedToRenewStates[expectedState]('Token renewal operation failed due to timeout', null, 'Token Renewal Failed');
}
self._saveItem(self.CONSTANTS.STORAGE.RENEW_STATUS + resource, self.CONSTANTS.TOKEN_RENEW_STATUS_CANCELED);
}
}, self.CONSTANTS.LOADFRAME_TIMEOUT);
};
/**
* Loads iframe with authorization endpoint URL
* @ignore
*/
AuthenticationContext.prototype._loadFrame = function (urlNavigate, frameName) {
// This trick overcomes iframe navigation in IE
// IE does not load the page consistently in iframe
var self = this;
self.info('LoadFrame: ' + frameName);
var frameCheck = frameName;
setTimeout(function () {
var frameHandle = self._addAdalFrame(frameCheck);
if (frameHandle.src === '' || frameHandle.src === 'about:blank') {
frameHandle.src = urlNavigate;
self._loadFrame(urlNavigate, frameCheck);
}
}, 500);
};
/**
* @callback tokenCallback
* @param {string} error_description error description returned from AAD if token request fails.
* @param {string} token token returned from AAD if token request is successful.
* @param {string} error error message returned from AAD if token request fails.
*/
/**
* Acquires token from the cache if it is not expired. Otherwise sends request to AAD to obtain a new token.
* @param {string} resource ResourceUri identifying the target resource
* @param {tokenCallback} callback - The callback provided by the caller. It will be called with token or error.
*/
AuthenticationContext.prototype.acquireToken = function (resource, callback) {
if (this._isEmpty(resource)) {
this.warn('resource is required');
callback('resource is required', null, 'resource is required');
return;
}
var token = this.getCachedToken(resource);
if (token) {
this.info('Token is already in cache for resource:' + resource);
callback(null, token, null);
return;
}
if (!this._user) {
this.warn('User login is required');
callback('User login is required', null, 'login required');
return;
}
// refresh attept with iframe
//Already renewing for this resource, callback when we get the token.
if (this._activeRenewals[resource]) {
//Active renewals contains the state for each renewal.
this.registerCallback(this._activeRenewals[resource], resource, callback);
} else {
if (resource === this.config.clientId) {
// App uses idtoken to send to api endpoints
// Default resource is tracked as clientid to store this token
this.verbose('renewing idtoken');
this._renewIdToken(callback);
} else {
this._renewToken(resource, callback);
}
}
};
/**
* Acquires token (interactive flow using a popUp window) by sending request to AAD to obtain a new token.
* @param {string} resource ResourceUri identifying the target resource
* @param {string} extraQueryParameters extraQueryParameters to add to the authentication request
* @param {tokenCallback} callback - The callback provided by the caller. It will be called with token or error.
*/
AuthenticationContext.prototype.acquireTokenPopup = function (resource, extraQueryParameters, claims, callback) {
if (this._isEmpty(resource)) {
this.warn('resource is required');
callback('resource is required', null, 'resource is required');
return;
}
if (!this._user) {
this.warn('User login is required');
callback('User login is required', null, 'login required');
return;
}
if (this._acquireTokenInProgress) {
this.warn("Acquire token interactive is already in progress");
callback("Acquire token interactive is already in progress", null, "Acquire token interactive is already in progress");
return;
}
var expectedState = this._guid() + '|' + resource;
this.config.state = expectedState;
window.renewStates.push(expectedState);
this.verbose('Renew token Expected state: ' + expectedState);
var urlNavigate = this._getNavigateUrl('token', resource) + '&prompt=select_account';
if (extraQueryParameters) {
urlNavigate += encodeURIComponent(extraQueryParameters);
}
if (claims && urlNavigate.indexOf("&claims") === -1) {
urlNavigate += '&claims=' + encodeURIComponent(claims);
} else if (claims && urlNavigate.indexOf("&claims") !== -1) {
throw new Error('Claims cannot be passed as an extraQueryParameter');
}
urlNavigate = this._addHintParameters(urlNavigate);
this._acquireTokenInProgress = true;
this.info('acquireToken interactive is called for the resource ' + resource);
this.registerCallback(expectedState, resource, callback);
this._loginPopup(urlNavigate, resource, callback);
};
/**
* Acquires token (interactive flow using a redirect) by sending request to AAD to obtain a new token. In this case the callback passed in the Authentication
* request constructor will be called.
* @param {string} resource ResourceUri identifying the target resource
* @param {string} extraQueryParameters extraQueryParameters to add to the authentication request
*/
AuthenticationContext.prototype.acquireTokenRedirect = function (resource, extraQueryParameters, claims) {
if (this._isEmpty(resource)) {
this.warn('resource is required');
callback('resource is required', null, 'resource is required');
return;
}
if (!this._user) {
this.warn('User login is required');
callback('User login is required', null, 'login required');
return;
}
if (this._acquireTokenInProgress) {
this.warn("Acquire token interactive is already in progress");
callback("Acquire token interactive is already in progress", null, "Acquire token interactive is already in progress");
return;
}
var expectedState = this._guid() + '|' + resource;
this.config.state = expectedState;
window.renewStates.push(expectedState);
this.verbose('Renew token Expected state: ' + expectedState);
var urlNavigate = this._getNavigateUrl('token', resource) + '&prompt=select_account';
if (extraQueryParameters) {
urlNavigate += encodeURIComponent(extraQueryParameters);
}
if (claims && urlNavigate.indexOf("&claims") === -1) {
urlNavigate += '&claims=' + encodeURIComponent(claims);
} else if (claims && urlNavigate.indexOf("&claims") !== -1) {
throw new Error('Claims cannot be passed as an extraQueryParameter');
}
urlNavigate = this._addHintParameters(urlNavigate);
this._acquireTokenInProgress = true;
this.info('acquireToken interactive is called for the resource ' + resource);
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST, window.location.href);
this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, expectedState);
this.promptUser(urlNavigate);
};
/**
* Redirects the browser to Azure AD authorization endpoint.
* @param {string} urlNavigate Url of the authorization endpoint.
*/
AuthenticationContext.prototype.promptUser = function (urlNavigate) {
if (urlNavigate) {
this.info('Navigate to:' + urlNavigate);
window.location.replace(urlNavigate);
} else {
this.info('Navigate url is empty');
}
};
/**
* Clears cache items.
*/
AuthenticationContext.prototype.clearCache = function () {
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY, '');
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY, 0);
this._saveItem(this.CONSTANTS.STORAGE.SESSION_STATE, '');
this._saveItem(this.CONSTANTS.STORAGE.STATE_LOGIN, '');
window.renewStates = [];
this._saveItem(this.CONSTANTS.STORAGE.USERNAME, '');
this._saveItem(this.CONSTANTS.STORAGE.IDTOKEN, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, '');
var keys = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS);
if (!this._isEmpty(keys)) {
keys = keys.split(this.CONSTANTS.RESOURCE_DELIMETER);
for (var i = 0; i < keys.length; i++) {
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + keys[i], '');
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + keys[i], 0);
}
}
this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS, '');
};
/**
* Clears cache items for a given resource.
* @param {string} resource a URI that identifies the resource.
*/
AuthenticationContext.prototype.clearCacheForResource = function (resource) {
this._saveItem(this.CONSTANTS.STORAGE.STATE_RENEW, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, '');
if (this._hasResource(resource)) {
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + resource, '');
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + resource, 0);
}
};
/**
* Redirects user to logout endpoint.
* After logout, it will redirect to postLogoutRedirectUri if added as a property on the config object.
*/
AuthenticationContext.prototype.logOut = function () {
this.clearCache();
this._user = null;
var urlNavigate;
if (this.config.logOutUri) {
urlNavigate = this.config.logOutUri;
} else {
var tenant = 'common';
var logout = '';
if (this.config.tenant) {
tenant = this.config.tenant;
}
if (this.config.postLogoutRedirectUri) {
logout = 'post_logout_redirect_uri=' + encodeURIComponent(this.config.postLogoutRedirectUri);
}
urlNavigate = this.instance + tenant + '/oauth2/logout?' + logout;
}
this.info('Logout navigate to: ' + urlNavigate);
this.promptUser(urlNavigate);
};
AuthenticationContext.prototype._isEmpty = function (str) {
return typeof str === 'undefined' || !str || 0 === str.length;
};
/**
* @callback userCallback
* @param {string} error error message if user info is not available.
* @param {User} user user object retrieved from the cache.
*/
/**
* Calls the passed in callback with the user object or error message related to the user.
* @param {userCallback} callback - The callback provided by the caller. It will be called with user or error.
*/
AuthenticationContext.prototype.getUser = function (callback) {
// IDToken is first call
if (typeof callback !== 'function') {
throw new Error('callback is not a function');
}
// user in memory
if (this._user) {
callback(null, this._user);
return;
}
// frame is used to get idtoken
var idtoken = this._getItem(this.CONSTANTS.STORAGE.IDTOKEN);
if (!this._isEmpty(idtoken)) {
this.info('User exists in cache: ');
this._user = this._createUser(idtoken);
callback(null, this._user);
} else {
this.warn('User information is not available');
callback('User information is not available', null);
}
};
/**
* Adds login_hint to authorization URL which is used to pre-fill the username field of sign in page for the user if known ahead of time.
* domain_hint can be one of users/organisations which when added skips the email based discovery process of the user.
* @ignore
*/
AuthenticationContext.prototype._addHintParameters = function (urlNavigate) {
// include hint params only if upn is present
if (this._user && this._user.profile && this._user.profile.hasOwnProperty('upn')) {
// don't add login_hint twice if user provided it in the extraQueryParameter value
if (!this._urlContainsQueryStringParameter("login_hint", urlNavigate)) {
// add login_hint
urlNavigate += '&login_hint=' + encodeURIComponent(this._user.profile.upn);
}
// don't add domain_hint twice if user provided it in the extraQueryParameter value
if (!this._urlContainsQueryStringParameter("domain_hint", urlNavigate) && this._user.profile.upn.indexOf('@') > -1) {
var parts = this._user.profile.upn.split('@');
// local part can include @ in quotes. Sending last part handles that.
urlNavigate += '&domain_hint=' + encodeURIComponent(parts[parts.length - 1]);
}
}
return urlNavigate;
};
/**
* Creates a user object by decoding the id_token
* @ignore
*/
AuthenticationContext.prototype._createUser = function (idToken) {
var user = null;
var parsedJson = this._extractIdToken(idToken);
if (parsedJson && parsedJson.hasOwnProperty('aud')) {
if (parsedJson.aud.toLowerCase() === this.config.clientId.toLowerCase()) {
user = {
userName: '',
profile: parsedJson
};
if (parsedJson.hasOwnProperty('upn')) {
user.userName = parsedJson.upn;
} else if (parsedJson.hasOwnProperty('email')) {
user.userName = parsedJson.email;
}
} else {
this.warn('IdToken has invalid aud field');
}
}
return user;
};
/**
* Returns the anchor part(#) of the URL
* @ignore
*/
AuthenticationContext.prototype._getHash = function (hash) {
if (hash.indexOf('#/') > -1) {
hash = hash.substring(hash.indexOf('#/') + 2);
} else if (hash.indexOf('#') > -1) {
hash = hash.substring(1);
}
return hash;
};
/**
* Checks if the URL fragment contains access token, id token or error_description.
* @param {string} hash - Hash passed from redirect page
* @returns {Boolean} true if response contains id_token, access_token or error, false otherwise.
*/
AuthenticationContext.prototype.isCallback = function (hash) {
hash = this._getHash(hash);
var parameters = this._deserialize(hash);
return parameters.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION) || parameters.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN) || parameters.hasOwnProperty(this.CONSTANTS.ID_TOKEN);
};
/**
* Gets login error
* @returns {string} error message related to login.
*/
AuthenticationContext.prototype.getLoginError = function () {
return this._getItem(this.CONSTANTS.STORAGE.LOGIN_ERROR);
};
/**
* Request info object created from the response received from AAD.
* @class RequestInfo
* @property {object} parameters - object comprising of fields such as id_token/error, session_state, state, e.t.c.
* @property {REQUEST_TYPE} requestType - either LOGIN, RENEW_TOKEN or UNKNOWN.
* @property {boolean} stateMatch - true if state is valid, false otherwise.
* @property {string} stateResponse - unique guid used to match the response with the request.
* @property {boolean} valid - true if requestType contains id_token, access_token or error, false otherwise.
*/
/**
* Creates a requestInfo object from the URL fragment and returns it.
* @returns {RequestInfo} an object created from the redirect response from AAD comprising of the keys - parameters, requestType, stateMatch, stateResponse and valid.
*/
AuthenticationContext.prototype.getRequestInfo = function (hash) {
hash = this._getHash(hash);
var parameters = this._deserialize(hash);
var requestInfo = {
valid: false,
parameters: {},
stateMatch: false,
stateResponse: '',
requestType: this.REQUEST_TYPE.UNKNOWN
};
if (parameters) {
requestInfo.parameters = parameters;
if (parameters.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION) || parameters.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN) || parameters.hasOwnProperty(this.CONSTANTS.ID_TOKEN)) {
requestInfo.valid = true;
// which call
var stateResponse = '';
if (parameters.hasOwnProperty('state')) {
this.verbose('State: ' + parameters.state);
stateResponse = parameters.state;
} else {
this.warn('No state returned');
return requestInfo;
}
requestInfo.stateResponse = stateResponse;
// async calls can fire iframe and login request at the same time if developer does not use the API as expected
// incoming callback needs to be looked up to find the request type
if (stateResponse === this._getItem(this.CONSTANTS.STORAGE.STATE_LOGIN)) {
requestInfo.requestType = this.REQUEST_TYPE.LOGIN;
requestInfo.stateMatch = true;
return requestInfo;
} else if (stateResponse === this._getItem(this.CONSTANTS.STORAGE.STATE_RENEW)) {
requestInfo.requestType = this.REQUEST_TYPE.RENEW_TOKEN;
requestInfo.stateMatch = true;
return requestInfo;
}
// external api requests may have many renewtoken requests for different resource
if (!requestInfo.stateMatch && window.parent) {
var statesInParentContext = window.parent.renewStates;
for (var i = 0; i < statesInParentContext.length; i++) {
if (statesInParentContext[i] === requestInfo.stateResponse) {
requestInfo.requestType = this.REQUEST_TYPE.RENEW_TOKEN;
requestInfo.stateMatch = true;
break;
}
}
}
}
}
return requestInfo;
};
/**
* Extracts resource value from state.
* @ignore
*/
AuthenticationContext.prototype._getResourceFromState = function (state) {
if (state) {
var splitIndex = state.indexOf('|');
if (splitIndex > -1 && splitIndex + 1 < state.length) {
return state.substring(splitIndex + 1);
}
}
return '';
};
/**
* Saves token or error received in the response from AAD in the cache. In case of id_token, it also creates the user object.
*/
AuthenticationContext.prototype.saveTokenFromHash = function (requestInfo) {
this.info('State status:' + requestInfo.stateMatch + '; Request type:' + requestInfo.requestType);
this._saveItem(this.CONSTANTS.STORAGE.ERROR, '');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, '');
var resource = this._getResourceFromState(requestInfo.stateResponse);
// Record error
if (requestInfo.parameters.hasOwnProperty(this.CONSTANTS.ERROR_DESCRIPTION)) {
this.info('Error :' + requestInfo.parameters.error + '; Error description:' + requestInfo.parameters[this.CONSTANTS.ERROR_DESCRIPTION]);
this._saveItem(this.CONSTANTS.STORAGE.ERROR, requestInfo.parameters.error);
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, requestInfo.parameters[this.CONSTANTS.ERROR_DESCRIPTION]);
if (requestInfo.requestType === this.REQUEST_TYPE.LOGIN) {
this._loginInProgress = false;
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR, requestInfo.parameters.error_description);
}
} else {
// It must verify the state from redirect
if (requestInfo.stateMatch) {
// record tokens to storage if exists
this.info('State is right');
if (requestInfo.parameters.hasOwnProperty(this.CONSTANTS.SESSION_STATE)) {
this._saveItem(this.CONSTANTS.STORAGE.SESSION_STATE, requestInfo.parameters[this.CONSTANTS.SESSION_STATE]);
}
var keys;
if (requestInfo.parameters.hasOwnProperty(this.CONSTANTS.ACCESS_TOKEN)) {
this.info('Fragment has access token');
if (!this._hasResource(resource)) {
keys = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || '';
this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS, keys + resource + this.CONSTANTS.RESOURCE_DELIMETER);
}
// save token with related resource
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + resource, requestInfo.parameters[this.CONSTANTS.ACCESS_TOKEN]);
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + resource, this._expiresIn(requestInfo.parameters[this.CONSTANTS.EXPIRES_IN]));
}
if (requestInfo.parameters.hasOwnProperty(this.CONSTANTS.ID_TOKEN)) {
this.info('Fragment has id token');
this._loginInProgress = false;
this._user = this._createUser(requestInfo.parameters[this.CONSTANTS.ID_TOKEN]);
if (this._user && this._user.profile) {
if (this._user.profile.nonce !== this._getItem(this.CONSTANTS.STORAGE.NONCE_IDTOKEN)) {
this._user = null;
this._saveItem(this.CONSTANTS.STORAGE.LOGIN_ERROR, 'Nonce is not same as ' + this._idTokenNonce);
} else {
this._saveItem(this.CONSTANTS.STORAGE.IDTOKEN, requestInfo.parameters[this.CONSTANTS.ID_TOKEN]);
// Save idtoken as access token for app itself
resource = this.config.loginResource ? this.config.loginResource : this.config.clientId;
if (!this._hasResource(resource)) {
keys = this._getItem(this.CONSTANTS.STORAGE.TOKEN_KEYS) || '';
this._saveItem(this.CONSTANTS.STORAGE.TOKEN_KEYS, keys + resource + this.CONSTANTS.RESOURCE_DELIMETER);
}
this._saveItem(this.CONSTANTS.STORAGE.ACCESS_TOKEN_KEY + resource, requestInfo.parameters[this.CONSTANTS.ID_TOKEN]);
this._saveItem(this.CONSTANTS.STORAGE.EXPIRATION_KEY + resource, this._user.profile.exp);
}
} else {
this._saveItem(this.CONSTANTS.STORAGE.ERROR, 'invalid id_token');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, 'Invalid id_token. id_token: ' + requestInfo.parameters[this.CONSTANTS.ID_TOKEN]);
}
}
} else {
this._saveItem(this.CONSTANTS.STORAGE.ERROR, 'Invalid_state');
this._saveItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION, 'Invalid_state. state: ' + requestInfo.stateResponse);
}
}
this._saveItem(this.CONSTANTS.STORAGE.RENEW_STATUS + resource, this.CONSTANTS.TOKEN_RENEW_STATUS_COMPLETED);
};
/**
* Gets resource for given endpoint if mapping is provided with config.
* @param {string} endpoint - The URI for which the resource Id is requested.
* @returns {string} resource for this API endpoint.
*/
AuthenticationContext.prototype.getResourceForEndpoint = function (endpoint) {
// if user specified list of anonymous endpoints, no need to send token to these endpoints, return null.
if (this.config && this.config.anonymousEndpoints) {
for (var i = 0; i < this.config.anonymousEndpoints.length; i++) {
if (endpoint.indexOf(this.config.anonymousEndpoints[i]) > -1) {
return null;
}
}
}
if (this.config && this.config.endpoints) {
for (var configEndpoint in this.config.endpoints) {
// configEndpoint is like /api/Todo requested endpoint can be /api/Todo/1
if (endpoint.indexOf(configEndpoint) > -1) {
return this.config.endpoints[configEndpoint];
}
}
}
// default resource will be clientid if nothing specified
// App will use idtoken for calls to itself
// check if it's staring from http or https, needs to match with app host
if (endpoint.indexOf('http://') > -1 || endpoint.indexOf('https://') > -1) {
if (this._getHostFromUri(endpoint) === this._getHostFromUri(this.config.redirectUri)) {
return this.config.loginResource;
}
} else {
// in angular level, the url for $http interceptor call could be relative url,
// if it's relative call, we'll treat it as app backend call.
return this.config.loginResource;
}
// if not the app's own backend or not a domain listed in the endpoints structure
return null;
};
/**
* Strips the protocol part of the URL and returns it.
* @ignore
*/
AuthenticationContext.prototype._getHostFromUri = function (uri) {
// remove http:// or https:// from uri
var extractedUri = String(uri).replace(/^(https?:)\/\//, '');
extractedUri = extractedUri.split('/')[0];
return extractedUri;
};
/**
* This method must be called for processing the response received from AAD. It extracts the hash, processes the token or error, saves it in the cache and calls the registered callbacks with the result.
* @param {string} [hash=window.location.hash] - Hash fragment of Url.
*/
AuthenticationContext.prototype.handleWindowCallback = function (hash) {
// This is for regular javascript usage for redirect handling
// need to make sure this is for callback
if (hash == null) hash = window.location.hash;
if (this.isCallback(hash)) {
var requestInfo = this.getRequestInfo(hash);
this.info('Returned from redirect url');
this.saveTokenFromHash(requestInfo);
var token = null,
callback = null;
if (requestInfo.requestType === this.REQUEST_TYPE.RENEW_TOKEN && window.parent) {
// iframe call but same single page
this.verbose('Window is in iframe');
callback = window.parent.callBackMappedToRenewStates[requestInfo.stateResponse];
token = requestInfo.parameters[this.CONSTANTS.ACCESS_TOKEN] || requestInfo.parameters[this.CONSTANTS.ID_TOKEN];
} else if (requestInfo.requestType === this.REQUEST_TYPE.LOGIN) {
callback = this.callback;
token = requestInfo.parameters[this.CONSTANTS.ID_TOKEN];
}
try {
if (callback) callback(this._getItem(this.CONSTANTS.STORAGE.ERROR_DESCRIPTION), token, this._getItem(this.CONSTANTS.STORAGE.ERROR));
} catch (err) {
this.error('Error occurred in user defined callback function', err);
}
if (!this.popUp) {
window.location.hash = '';
if (this.config.navigateToLoginRequestUrl) window.location.href = this._getItem(this.CONSTANTS.STORAGE.LOGIN_REQUEST);
}
}
};
/**
* Constructs the authorization endpoint URL and returns it.
* @ignore
*/
AuthenticationContext.prototype._getNavigateUrl = function (responseType, resource) {
var tenant = 'common';
if (this.config.tenant) {
tenant = this.config.tenant;
}
var urlNavigate = this.instance + tenant + '/oauth2/authorize' + this._serialize(responseType, this.config, resource) + this._addLibMetadata();
this.info('Navigate url:' + urlNavigate);
return urlNavigate;
};
/**
* Returns the decoded id_token.
* @ignore
*/
AuthenticationContext.prototype._extractIdToken = function (encodedIdToken) {
// id token will be decoded to get the username
var decodedToken = this._decodeJwt(encodedIdToken);
if (!decodedToken) {
return null;
}
try {
var base64IdToken = decodedToken.JWSPayload;
var base64Decoded = this._base64DecodeStringUrlSafe(base64IdToken);
if (!base64Decoded) {
this.info('The returned id_token could not be base64 url safe decoded.');
return null;
}
// ECMA script has JSON built-in support
return JSON.parse(base64Decoded);
} catch (err) {
this.error('The returned id_token could not be decoded', err);
}
return null;
};
/**
* Decodes a string of data which has been encoded using base-64 encoding.
* @ignore
*/
AuthenticationContext.prototype._base64DecodeStringUrlSafe = function (base64IdToken) {
// html5 should support atob function for decoding
base64IdToken = base64IdToken.replace(/-/g, '+').replace(/_/g, '/');
if (window.atob) {
return decodeURIComponent(escape(window.atob(base64IdToken))); // jshint ignore:line
} else {
return decodeURIComponent(escape(this._decode(base64IdToken)));
}
};
//Take https://cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.js and https://en.wikipedia.org/wiki/Base64 as reference.
AuthenticationContext.prototype._decode = function (base64IdToken) {
var codes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
base64IdToken = String(base64IdToken).replace(/=+$/, '');
var length = base64IdToken.length;
if (length % 4 === 1) {
throw new Error('The token to be decoded is not correctly encoded.');
}
var h1,
h2,
h3,
h4,
bits,
c1,
c2,
c3,
decoded = '';
for (var i = 0; i < length; i += 4) {
//Every 4 base64 encoded character will be converted to 3 byte string, which is 24 bits
// then 6 bits per base64 encoded character
h1 = codes.indexOf(base64IdToken.charAt(i));
h2 = codes.indexOf(base64IdToken.charAt(i + 1));
h3 = codes.indexOf(base64IdToken.charAt(i + 2));
h4 = codes.indexOf(base64IdToken.charAt(i + 3));
// For padding, if last two are '='
if (i + 2 === length - 1) {
bits = h1 << 18 | h2 << 12 | h3 << 6;
c1 = bits >> 16 & 255;
c2 = bits >> 8 & 255;
decoded += String.fromCharCode(c1, c2);
break;
}
// if last one is '='
else if (i + 1 === length - 1) {
bits = h1 << 18 | h2 << 12;
c1 = bits >> 16 & 255;
decoded += String.fromCharCode(c1);
break;
}
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
// then convert to 3 byte chars
c1 = bits >> 16 & 255;
c2 = bits >> 8 & 255;
c3 = bits & 255;
decoded += String.fromCharCode(c1, c2, c3);
}
return decoded;
};
/**
* Decodes an id token into an object with header, payload and signature fields.
* @ignore
*/
// Adal.node js crack function
AuthenticationContext.prototype._decodeJwt = function (jwtToken) {
if (this._isEmpty(jwtToken)) {
return null;
};
var idTokenPartsRegex = /^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/;
var matches = idTokenPartsRegex.exec(jwtToken);
if (!matches || matches.length < 4) {
this.warn('The returned id_token is not parseable.');
return null;
}
var crackedToken = {
header: matches[1],
JWSPayload: matches[2],
JWSSig: matches[3]
};
return crackedToken;
};
/**
* Converts string to represent binary data in ASCII string format by translating it into a radix-64 representation and returns it
* @ignore
*/
AuthenticationContext.prototype._convertUrlSafeToRegularBase64EncodedString = function (str) {
return str.replace('-', '+').replace('_', '/');
};
/**
* Serializes the parameters for the authorization endpoint URL and returns the serialized uri string.
* @ignore
*/
AuthenticationContext.prototype._serialize = function (responseType, obj, resource) {
var str = [];
if (obj !== null) {
str.push('?response_type=' + responseType);
str.push('client_id=' + encodeURIComponent(obj.clientId));
if (resource) {
str.push('resource=' + encodeURIComponent(resource));
}
str.push('redirect_uri=' + encodeURIComponent(obj.redirectUri));
str.push('state=' + encodeURIComponent(obj.state));
if (obj.hasOwnProperty('slice')) {
str.push('slice=' + encodeURIComponent(obj.slice));
}
if (obj.hasOwnProperty('extraQueryParameter')) {
str.push(obj.extraQueryParameter);
}
var correlationId = obj.correlationId ? obj.correlationId : this._guid();
str.push('client-request-id=' + encodeURIComponent(correlationId));
}
return str.join('&');
};
/**
* Parses the query string parameters into a key-value pair object.
* @ignore
*/
AuthenticationContext.prototype._deserialize = function (query) {
var match,
pl = /\+/g,
// Regex for replacing addition symbol with a space
search = /([^&=]+)=([^&]*)/g,
decode = function (s) {
return decodeURIComponent(s.replace(pl, ' '));
},
obj = {};
match = search.exec(query);
while (match) {
obj[decode(match[1])] = decode(match[2]);
match = search.exec(query);
}
return obj;
};
/**
* Converts decimal value to hex equivalent
* @ignore
*/
AuthenticationContext.prototype._decimalToHex = function (number) {
var hex = number.toString(16);
while (hex.length < 2) {
hex = '0' + hex;
}
return hex;
};
/**
* Generates RFC4122 version 4 guid (128 bits)
* @ignore
*/
/* jshint ignore:start */
AuthenticationContext.prototype._guid = function () {
// RFC4122: The version 4 UUID is meant for generating UUIDs from truly-random or
// pseudo-random numbers.
// The algorithm is as follows:
// Set the two most significant bits (bits 6 and 7) of the
// clock_seq_hi_and_reserved to zero and one, respectively.
// Set the four most significant bits (bits 12 through 15) of the
// time_hi_and_version field to the 4-bit version number from
// Section 4.1.3. Version4
// Set all the other bits to randomly (or pseudo-randomly) chosen
// values.
// UUID = time-low "-" time-mid "-"time-high-and-version "-"clock-seq-reserved and low(2hexOctet)"-" node
// time-low = 4hexOctet
// time-mid = 2hexOctet
// time-high-and-version = 2hexOctet
// clock-seq-and-reserved = hexOctet:
// clock-seq-low = hexOctet
// node = 6hexOctet
// Format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
// y could be 1000, 1001, 1010, 1011 since most significant two bits needs to be 10
// y values are 8, 9, A, B
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
if (cryptoObj && cryptoObj.getRandomValues) {
var buffer = new Uint8Array(16);
cryptoObj.getRandomValues(buffer);
//buffer[6] and buffer[7] represents the time_hi_and_version field. We will set the four most significant bits (4 through 7) of buffer[6] to represent decimal number 4 (UUID version number).
buffer[6] |= 0x40; //buffer[6] | 01000000 will set the 6 bit to 1.
buffer[6] &= 0x4f; //buffer[6] & 01001111 will set the 4, 5, and 7 bit to 0 such that bits 4-7 == 0100 = "4".
//buffer[8] represents the clock_seq_hi_and_reserved field. We will set the two most significant bits (6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively.
buffer[8] |= 0x80; //buffer[8] | 10000000 will set the 7 bit to 1.
buffer[8] &= 0xbf; //buffer[8] & 10111111 will set the 6 bit to 0.
return this._decimalToHex(buffer[0]) + this._decimalToHex(buffer[1]) + this._decimalToHex(buffer[2]) + this._decimalToHex(buffer[3]) + '-' + this._decimalToHex(buffer[4]) + this._decimalToHex(buffer[5]) + '-' + this._decimalToHex(buffer[6]) + this._decimalToHex(buffer[7]) + '-' + this._decimalToHex(buffer[8]) + this._decimalToHex(buffer[9]) + '-' + this._decimalToHex(buffer[10]) + this._decimalToHex(buffer[11]) + this._decimalToHex(buffer[12]) + this._decimalToHex(buffer[13]) + this._decimalToHex(buffer[14]) + this._decimalToHex(buffer[15]);
} else {
var guidHolder = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
var hex = '0123456789abcdef';
var r = 0;
var guidResponse = "";
for (var i = 0; i < 36; i++) {
if (guidHolder[i] !== '-' && guidHolder[i] !== '4') {
// each x and y needs to be random
r = Math.random() * 16 | 0;
}
if (guidHolder[i] === 'x') {
guidResponse += hex[r];
} else if (guidHolder[i] === 'y') {
// clock-seq-and-reserved first hex is filtered and remaining hex values are random
r &= 0x3; // bit and with 0011 to set pos 2 to zero ?0??
r |= 0x8; // set pos 3 to 1 as 1???
guidResponse += hex[r];
} else {
guidResponse += guidHolder[i];
}
}
return guidResponse;
}
};
/* jshint ignore:end */
/**
* Calculates the expires in value in milliseconds for the acquired token
* @ignore
*/
AuthenticationContext.prototype._expiresIn = function (expires) {
// if AAD did not send "expires_in" property, use default expiration of 3599 seconds, for some reason AAD sends 3599 as "expires_in" value instead of 3600
if (!expires) expires = 3599;
return this._now() + parseInt(expires, 10);
};
/**
* Return the number of milliseconds since 1970/01/01
* @ignore
*/
AuthenticationContext.prototype._now = function () {
return Math.round(new Date().getTime() / 1000.0);
};
/**
* Adds the hidden iframe for silent token renewal
* @ignore
*/
AuthenticationContext.prototype._addAdalFrame = function (iframeId) {
if (typeof iframeId === 'undefined') {
return;
}
this.info('Add adal frame to document:' + iframeId);
var adalFrame = document.getElementById(iframeId);
if (!adalFrame) {
if (document.createElement && document.documentElement && (window.opera || window.navigator.userAgent.indexOf('MSIE 5.0') === -1)) {
var ifr = document.createElement('iframe');
ifr.setAttribute('id', iframeId);
ifr.style.visibility = 'hidden';
ifr.style.position = 'absolute';
ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
adalFrame = document.getElementsByTagName('body')[0].appendChild(ifr);
} else if (document.body && document.body.insertAdjacentHTML) {
document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeId + '" id="' + iframeId + '" style="display:none"></iframe>');
}
if (window.frames && window.frames[iframeId]) {
adalFrame = window.frames[iframeId];
}
}
return adalFrame;
};
/**
* Saves the key-value pair in the cache
* @ignore
*/
AuthenticationContext.prototype._saveItem = function (key, obj) {
if (this.config && this.config.cacheLocation && this.config.cacheLocation === 'localStorage') {
if (!this._supportsLocalStorage()) {
this.info('Local storage is not supported');
return false;
}
localStorage.setItem(key, obj);
return true;
}
// Default as session storage
if (!this._supportsSessionStorage()) {
this.info('Session storage is not supported');
return false;
}
sessionStorage.setItem(key, obj);
return true;
};
/**
* Searches the value for the given key in the cache
* @ignore
*/
AuthenticationContext.prototype._getItem = function (key) {
if (this.config && this.config.cacheLocation && this.config.cacheLocation === 'localStorage') {
if (!this._supportsLocalStorage()) {
this.info('Local storage is not supported');
return null;
}
return localStorage.getItem(key);
}
// Default as session storage
if (!this._supportsSessionStorage()) {
this.info('Session storage is not supported');
return null;
}
return sessionStorage.getItem(key);
};
/**
* Returns true if browser supports localStorage, false otherwise.
* @ignore
*/
AuthenticationContext.prototype._supportsLocalStorage = function () {
try {
if (!window.localStorage) return false; // Test availability
window.localStorage.setItem('storageTest', 'A'); // Try write
if (window.localStorage.getItem('storageTest') != 'A') return false; // Test read/write
window.localStorage.removeItem('storageTest'); // Try delete
if (window.localStorage.getItem('storageTest')) return false; // Test delete
return true; // Success
} catch (e) {
return false;
}
};
/**
* Returns true if browser supports sessionStorage, false otherwise.
* @ignore
*/
AuthenticationContext.prototype._supportsSessionStorage = function () {
try {
if (!window.sessionStorage) return false; // Test availability
window.sessionStorage.setItem('storageTest', 'A'); // Try write
if (window.sessionStorage.getItem('storageTest') != 'A') return false; // Test read/write
window.sessionStorage.removeItem('storageTest'); // Try delete
if (window.sessionStorage.getItem('storageTest')) return false; // Test delete
return true; // Success
} catch (e) {
return false;
}
};
/**
* Returns a cloned copy of the passed object.
* @ignore
*/
AuthenticationContext.prototype._cloneConfig = function (obj) {
if (null === obj || 'object' !== typeof obj) {
return obj;
}
var copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = obj[attr];
}
}
return copy;
};
/**
* Adds the library version and returns it.
* @ignore
*/
AuthenticationContext.prototype._addLibMetadata = function () {
// x-client-SKU
// x-client-Ver
return '&x-client-SKU=Js&x-client-Ver=' + this._libVersion();
};
/**
* Checks the Logging Level, constructs the Log message and logs it. Users need to implement/override this method to turn on Logging.
* @param {number} level - Level can be set 0,1,2 and 3 which turns on 'error', 'warning', 'info' or 'verbose' level logging respectively.
* @param {string} message - Message to log.
* @param {string} error - Error to log.
*/
AuthenticationContext.prototype.log = function (level, message, error) {
if (level <= Logging.level) {
var timestamp = new Date().toUTCString();
var formattedMessage = '';
if (this.config.correlationId) formattedMessage = timestamp + ':' + this.config.correlationId + '-' + this._libVersion() + '-' + this.CONSTANTS.LEVEL_STRING_MAP[level] + ' ' + message;else formattedMessage = timestamp + ':' + this._libVersion() + '-' + this.CONSTANTS.LEVEL_STRING_MAP[level] + ' ' + message;
if (error) {
formattedMessage += '\nstack:\n' + error.stack;
}
Logging.log(formattedMessage);
}
};
/**
* Logs messages when Logging Level is set to 0.
* @param {string} message - Message to log.
* @param {string} error - Error to log.
*/
AuthenticationContext.prototype.error = function (message, error) {
this.log(this.CONSTANTS.LOGGING_LEVEL.ERROR, message, error);
};
/**
* Logs messages when Logging Level is set to 1.
* @param {string} message - Message to log.
*/
AuthenticationContext.prototype.warn = function (message) {
this.log(this.CONSTANTS.LOGGING_LEVEL.WARN, message, null);
};
/**
* Logs messages when Logging Level is set to 2.
* @param {string} message - Message to log.
*/
AuthenticationContext.prototype.info = function (message) {
this.log(this.CONSTANTS.LOGGING_LEVEL.INFO, message, null);
};
/**
* Logs messages when Logging Level is set to 3.
* @param {string} message - Message to log.
*/
AuthenticationContext.prototype.verbose = function (message) {
this.log(this.CONSTANTS.LOGGING_LEVEL.VERBOSE, message, null);
};
/**
* Returns the library version.
* @ignore
*/
AuthenticationContext.prototype._libVersion = function () {
return '1.0.15';
};
/**
* Returns a reference of Authentication Context as a result of a require call.
* @ignore
*/
if (typeof module !== 'undefined' && module.exports) {
module.exports = AuthenticationContext;
module.exports.inject = function (conf) {
return new AuthenticationContext(conf);
};
}
return AuthenticationContext;
}();
});
System.registerDynamic("ng2-adal/services/adal.service.js", ["@angular/core", "rxjs/Observable", "adal-angular"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
var __decorate = exports && exports.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = $__require("@angular/core");
var Observable_1 = $__require("rxjs/Observable");
var adalLib = $__require("adal-angular");
var AdalService = function () {
function AdalService() {
this.oauthData = {
isAuthenticated: false,
userName: '',
loginError: '',
profile: {}
};
}
AdalService.prototype.init = function (configOptions) {
if (!configOptions) {
throw new Error('You must set config, when calling init.');
}
// redirect and logout_redirect are set to current location by default
var existingHash = window.location.hash;
var pathDefault = window.location.href;
if (existingHash) {
pathDefault = pathDefault.replace(existingHash, '');
}
configOptions.redirectUri = configOptions.redirectUri || pathDefault;
configOptions.postLogoutRedirectUri = configOptions.postLogoutRedirectUri || pathDefault;
// create instance with given config
this.adalContext = adalLib.inject(configOptions);
window.AuthenticationContext = this.adalContext.constructor;
// loginresource is used to set authenticated status
this.updateDataFromCache(this.adalContext.config.loginResource);
};
Object.defineProperty(AdalService.prototype, "config", {
get: function () {
return this.adalContext.config;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AdalService.prototype, "userInfo", {
get: function () {
return this.oauthData;
},
enumerable: true,
configurable: true
});
AdalService.prototype.login = function () {
this.adalContext.login();
};
AdalService.prototype.loginInProgress = function () {
return this.adalContext.loginInProgress();
};
AdalService.prototype.logOut = function () {
this.adalContext.logOut();
};
AdalService.prototype.handleWindowCallback = function () {
var hash = window.location.hash;
if (this.adalContext.isCallback(hash)) {
var requestInfo = this.adalContext.getRequestInfo(hash);
this.adalContext.saveTokenFromHash(requestInfo);
if (requestInfo.requestType === this.adalContext.REQUEST_TYPE.LOGIN) {
this.updateDataFromCache(this.adalContext.config.loginResource);
} else if (requestInfo.requestType === this.adalContext.REQUEST_TYPE.RENEW_TOKEN) {
this.adalContext.callback = window.parent.callBackMappedToRenewStates[requestInfo.stateResponse];
}
if (requestInfo.stateMatch) {
if (typeof this.adalContext.callback === 'function') {
if (requestInfo.requestType === this.adalContext.REQUEST_TYPE.RENEW_TOKEN) {
// Idtoken or Accestoken can be renewed
if (requestInfo.parameters['access_token']) {
this.adalContext.callback(this.adalContext._getItem(this.adalContext.CONSTANTS.STORAGE.ERROR_DESCRIPTION), requestInfo.parameters['access_token']);
} else if (requestInfo.parameters['id_token']) {
this.adalContext.callback(this.adalContext._getItem(this.adalContext.CONSTANTS.STORAGE.ERROR_DESCRIPTION), requestInfo.parameters['id_token']);
} else if (requestInfo.parameters['error']) {
this.adalContext.callback(this.adalContext._getItem(this.adalContext.CONSTANTS.STORAGE.ERROR_DESCRIPTION), null);
this.adalContext._renewFailed = true;
}
}
}
}
}
};
AdalService.prototype.getCachedToken = function (resource) {
return this.adalContext.getCachedToken(resource);
};
AdalService.prototype.acquireToken = function (resource) {
var _this = this;
return Observable_1.Observable.create(function (subscriber) {
_this.adalContext.acquireToken(resource, function (error, tokenOut) {
if (error) {
_this.adalContext.error('Error when acquiring token for resource: ' + resource, error);
subscriber.error(error);
} else {
subscriber.next(tokenOut);
}
subscriber.complete();
});
});
};
AdalService.prototype.getUser = function () {
var _this = this;
return Observable_1.Observable.create(function (subscriber) {
_this.adalContext.getUser(function (error, user) {
if (error) {
_this.adalContext.error('Error when getting user', error);
subscriber.next(null);
} else {
subscriber.next(user);
}
subscriber.complete();
});
});
};
AdalService.prototype.clearCache = function () {
this.adalContext.clearCache();
};
AdalService.prototype.clearCacheForResource = function (resource) {
this.adalContext.clearCacheForResource(resource);
};
AdalService.prototype.info = function (message) {
this.adalContext.info(message);
};
AdalService.prototype.verbose = function (message) {
this.adalContext.verbose(message);
};
AdalService.prototype.GetResourceForEndpoint = function (url) {
return this.adalContext.getResourceForEndpoint(url);
};
AdalService.prototype.refreshDataFromCache = function () {
this.updateDataFromCache(this.adalContext.config.loginResource);
};
AdalService.prototype.updateDataFromCache = function (resource) {
var token = this.adalContext.getCachedToken(resource);
this.oauthData.isAuthenticated = token !== null && token.length > 0;
var user = this.adalContext.getCachedUser() || { userName: '', profile: undefined };
this.oauthData.userName = user.userName;
this.oauthData.profile = user.profile;
this.oauthData.loginError = this.adalContext.getLoginError();
};
;
AdalService = __decorate([core_1.Injectable()], AdalService);
return AdalService;
}();
exports.AdalService = AdalService;
});
System.registerDynamic('rxjs/operators/catchError.js', ['../OuterSubscriber', '../util/subscribeToResult'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var OuterSubscriber_1 = $__require('../OuterSubscriber');
var subscribeToResult_1 = $__require('../util/subscribeToResult');
/**
* Catches errors on the observable to be handled by returning a new observable or throwing an error.
*
* <img src="./img/catch.png" width="100%">
*
* @example <caption>Continues with a different Observable when there's an error</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
* .subscribe(x => console.log(x));
* // 1, 2, 3, I, II, III, IV, V
*
* @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n === 4) {
* throw 'four!';
* }
* return n;
* })
* .catch((err, caught) => caught)
* .take(30)
* .subscribe(x => console.log(x));
* // 1, 2, 3, 1, 2, 3, ...
*
* @example <caption>Throws a new error when the source Observable throws an error</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => {
* throw 'error in source. Details: ' + err;
* })
* .subscribe(
* x => console.log(x),
* err => console.log(err)
* );
* // 1, 2, 3, error in source. Details: four!
*
* @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
* is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
* is returned by the `selector` will be used to continue the observable chain.
* @return {Observable} An observable that originates from either the source or the observable returned by the
* catch `selector` function.
* @name catchError
*/
function catchError(selector) {
return function catchErrorOperatorFunction(source) {
var operator = new CatchOperator(selector);
var caught = source.lift(operator);
return operator.caught = caught;
};
}
exports.catchError = catchError;
var CatchOperator = function () {
function CatchOperator(selector) {
this.selector = selector;
}
CatchOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
};
return CatchOperator;
}();
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var CatchSubscriber = function (_super) {
__extends(CatchSubscriber, _super);
function CatchSubscriber(destination, selector, caught) {
_super.call(this, destination);
this.selector = selector;
this.caught = caught;
}
// NOTE: overriding `error` instead of `_error` because we don't want
// to have this flag this subscriber as `isStopped`. We can mimic the
// behavior of the RetrySubscriber (from the `retry` operator), where
// we unsubscribe from our source chain, reset our Subscriber flags,
// then subscribe to the selector result.
CatchSubscriber.prototype.error = function (err) {
if (!this.isStopped) {
var result = void 0;
try {
result = this.selector(err, this.caught);
} catch (err2) {
_super.prototype.error.call(this, err2);
return;
}
this._unsubscribeAndRecycle();
this.add(subscribeToResult_1.subscribeToResult(this, result));
}
};
return CatchSubscriber;
}(OuterSubscriber_1.OuterSubscriber);
});
System.registerDynamic("rxjs/operator/catch.js", ["../operators/catchError"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var catchError_1 = $__require('../operators/catchError');
/**
* Catches errors on the observable to be handled by returning a new observable or throwing an error.
*
* <img src="./img/catch.png" width="100%">
*
* @example <caption>Continues with a different Observable when there's an error</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
* .subscribe(x => console.log(x));
* // 1, 2, 3, I, II, III, IV, V
*
* @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n === 4) {
* throw 'four!';
* }
* return n;
* })
* .catch((err, caught) => caught)
* .take(30)
* .subscribe(x => console.log(x));
* // 1, 2, 3, 1, 2, 3, ...
*
* @example <caption>Throws a new error when the source Observable throws an error</caption>
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => {
* throw 'error in source. Details: ' + err;
* })
* .subscribe(
* x => console.log(x),
* err => console.log(err)
* );
* // 1, 2, 3, error in source. Details: four!
*
* @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
* is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
* is returned by the `selector` will be used to continue the observable chain.
* @return {Observable} An observable that originates from either the source or the observable returned by the
* catch `selector` function.
* @method catch
* @name catch
* @owner Observable
*/
function _catch(selector) {
return catchError_1.catchError(selector)(this);
}
exports._catch = _catch;
});
System.registerDynamic('rxjs/add/operator/catch.js', ['../../Observable', '../../operator/catch'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Observable_1 = $__require('../../Observable');
var catch_1 = $__require('../../operator/catch');
Observable_1.Observable.prototype.catch = catch_1._catch;
Observable_1.Observable.prototype._catch = catch_1._catch;
});
System.registerDynamic('rxjs/operators/map.js', ['../Subscriber'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = $__require('../Subscriber');
/**
* Applies a given `project` function to each value emitted by the source
* Observable, and emits the resulting values as an Observable.
*
* <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
* it passes each source value through a transformation function to get
* corresponding output values.</span>
*
* <img src="./img/map.png" width="100%">
*
* Similar to the well known `Array.prototype.map` function, this operator
* applies a projection to each value and emits that projection in the output
* Observable.
*
* @example <caption>Map every click to the clientX position of that click</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var positions = clicks.map(ev => ev.clientX);
* positions.subscribe(x => console.log(x));
*
* @see {@link mapTo}
* @see {@link pluck}
*
* @param {function(value: T, index: number): R} project The function to apply
* to each `value` emitted by the source Observable. The `index` parameter is
* the number `i` for the i-th emission that has happened since the
* subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to define what `this` is in the
* `project` function.
* @return {Observable<R>} An Observable that emits the values from the source
* Observable transformed by the given `project` function.
* @method map
* @owner Observable
*/
function map(project, thisArg) {
return function mapOperation(source) {
if (typeof project !== 'function') {
throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
}
return source.lift(new MapOperator(project, thisArg));
};
}
exports.map = map;
var MapOperator = function () {
function MapOperator(project, thisArg) {
this.project = project;
this.thisArg = thisArg;
}
MapOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
};
return MapOperator;
}();
exports.MapOperator = MapOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var MapSubscriber = function (_super) {
__extends(MapSubscriber, _super);
function MapSubscriber(destination, project, thisArg) {
_super.call(this, destination);
this.project = project;
this.count = 0;
this.thisArg = thisArg || this;
}
// NOTE: This looks unoptimized, but it's actually purposefully NOT
// using try/catch optimizations.
MapSubscriber.prototype._next = function (value) {
var result;
try {
result = this.project.call(this.thisArg, value, this.count++);
} catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
};
return MapSubscriber;
}(Subscriber_1.Subscriber);
});
System.registerDynamic("rxjs/operator/map.js", ["../operators/map"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var map_1 = $__require('../operators/map');
/**
* Applies a given `project` function to each value emitted by the source
* Observable, and emits the resulting values as an Observable.
*
* <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
* it passes each source value through a transformation function to get
* corresponding output values.</span>
*
* <img src="./img/map.png" width="100%">
*
* Similar to the well known `Array.prototype.map` function, this operator
* applies a projection to each value and emits that projection in the output
* Observable.
*
* @example <caption>Map every click to the clientX position of that click</caption>
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var positions = clicks.map(ev => ev.clientX);
* positions.subscribe(x => console.log(x));
*
* @see {@link mapTo}
* @see {@link pluck}
*
* @param {function(value: T, index: number): R} project The function to apply
* to each `value` emitted by the source Observable. The `index` parameter is
* the number `i` for the i-th emission that has happened since the
* subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to define what `this` is in the
* `project` function.
* @return {Observable<R>} An Observable that emits the values from the source
* Observable transformed by the given `project` function.
* @method map
* @owner Observable
*/
function map(project, thisArg) {
return map_1.map(project, thisArg)(this);
}
exports.map = map;
});
System.registerDynamic('rxjs/add/operator/map.js', ['../../Observable', '../../operator/map'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Observable_1 = $__require('../../Observable');
var map_1 = $__require('../../operator/map');
Observable_1.Observable.prototype.map = map_1.map;
});
System.registerDynamic("rxjs/util/isArrayLike.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
exports.isArrayLike = function (x) {
return x && typeof x.length === 'number';
};
});
System.registerDynamic('rxjs/util/isPromise.js', [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
function isPromise(value) {
return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
}
exports.isPromise = isPromise;
});
System.registerDynamic('rxjs/symbol/iterator.js', ['../util/root'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var root_1 = $__require('../util/root');
function symbolIteratorPonyfill(root) {
var Symbol = root.Symbol;
if (typeof Symbol === 'function') {
if (!Symbol.iterator) {
Symbol.iterator = Symbol('iterator polyfill');
}
return Symbol.iterator;
} else {
// [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
var Set_1 = root.Set;
if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') {
return '@@iterator';
}
var Map_1 = root.Map;
// required for compatability with es6-shim
if (Map_1) {
var keys = Object.getOwnPropertyNames(Map_1.prototype);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
// according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) {
return key;
}
}
}
return '@@iterator';
}
}
exports.symbolIteratorPonyfill = symbolIteratorPonyfill;
exports.iterator = symbolIteratorPonyfill(root_1.root);
/**
* @deprecated use iterator instead
*/
exports.$$iterator = exports.iterator;
});
System.registerDynamic("rxjs/InnerSubscriber.js", ["./Subscriber"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = $__require('./Subscriber');
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var InnerSubscriber = function (_super) {
__extends(InnerSubscriber, _super);
function InnerSubscriber(parent, outerValue, outerIndex) {
_super.call(this);
this.parent = parent;
this.outerValue = outerValue;
this.outerIndex = outerIndex;
this.index = 0;
}
InnerSubscriber.prototype._next = function (value) {
this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
};
InnerSubscriber.prototype._error = function (error) {
this.parent.notifyError(error, this);
this.unsubscribe();
};
InnerSubscriber.prototype._complete = function () {
this.parent.notifyComplete(this);
this.unsubscribe();
};
return InnerSubscriber;
}(Subscriber_1.Subscriber);
exports.InnerSubscriber = InnerSubscriber;
});
System.registerDynamic('rxjs/util/subscribeToResult.js', ['./root', './isArrayLike', './isPromise', './isObject', '../Observable', '../symbol/iterator', '../InnerSubscriber', '../symbol/observable'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var root_1 = $__require('./root');
var isArrayLike_1 = $__require('./isArrayLike');
var isPromise_1 = $__require('./isPromise');
var isObject_1 = $__require('./isObject');
var Observable_1 = $__require('../Observable');
var iterator_1 = $__require('../symbol/iterator');
var InnerSubscriber_1 = $__require('../InnerSubscriber');
var observable_1 = $__require('../symbol/observable');
function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {
var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);
if (destination.closed) {
return null;
}
if (result instanceof Observable_1.Observable) {
if (result._isScalar) {
destination.next(result.value);
destination.complete();
return null;
} else {
destination.syncErrorThrowable = true;
return result.subscribe(destination);
}
} else if (isArrayLike_1.isArrayLike(result)) {
for (var i = 0, len = result.length; i < len && !destination.closed; i++) {
destination.next(result[i]);
}
if (!destination.closed) {
destination.complete();
}
} else if (isPromise_1.isPromise(result)) {
result.then(function (value) {
if (!destination.closed) {
destination.next(value);
destination.complete();
}
}, function (err) {
return destination.error(err);
}).then(null, function (err) {
// Escaping the Promise trap: globally throw unhandled errors
root_1.root.setTimeout(function () {
throw err;
});
});
return destination;
} else if (result && typeof result[iterator_1.iterator] === 'function') {
var iterator = result[iterator_1.iterator]();
do {
var item = iterator.next();
if (item.done) {
destination.complete();
break;
}
destination.next(item.value);
if (destination.closed) {
break;
}
} while (true);
} else if (result && typeof result[observable_1.observable] === 'function') {
var obs = result[observable_1.observable]();
if (typeof obs.subscribe !== 'function') {
destination.error(new TypeError('Provided object does not correctly implement Symbol.observable'));
} else {
return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex));
}
} else {
var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
var msg = "You provided " + value + " where a stream was expected." + ' You can provide an Observable, Promise, Array, or Iterable.';
destination.error(new TypeError(msg));
}
return null;
}
exports.subscribeToResult = subscribeToResult;
});
System.registerDynamic("rxjs/OuterSubscriber.js", ["./Subscriber"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = $__require('./Subscriber');
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var OuterSubscriber = function (_super) {
__extends(OuterSubscriber, _super);
function OuterSubscriber() {
_super.apply(this, arguments);
}
OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.destination.next(innerValue);
};
OuterSubscriber.prototype.notifyError = function (error, innerSub) {
this.destination.error(error);
};
OuterSubscriber.prototype.notifyComplete = function (innerSub) {
this.destination.complete();
};
return OuterSubscriber;
}(Subscriber_1.Subscriber);
exports.OuterSubscriber = OuterSubscriber;
});
System.registerDynamic('rxjs/operators/mergeMap.js', ['../util/subscribeToResult', '../OuterSubscriber'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var subscribeToResult_1 = $__require('../util/subscribeToResult');
var OuterSubscriber_1 = $__require('../OuterSubscriber');
/* tslint:enable:max-line-length */
/**
* Projects each source value to an Observable which is merged in the output
* Observable.
*
* <span class="informal">Maps each value to an Observable, then flattens all of
* these inner Observables using {@link mergeAll}.</span>
*
* <img src="./img/mergeMap.png" width="100%">
*
* Returns an Observable that emits items based on applying a function that you
* supply to each item emitted by the source Observable, where that function
* returns an Observable, and then merging those resulting Observables and
* emitting the results of this merger.
*
* @example <caption>Map and flatten each letter to an Observable ticking every 1 second</caption>
* var letters = Rx.Observable.of('a', 'b', 'c');
* var result = letters.mergeMap(x =>
* Rx.Observable.interval(1000).map(i => x+i)
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // a0
* // b0
* // c0
* // a1
* // b1
* // c1
* // continues to list a,b,c with respective ascending integers
*
* @see {@link concatMap}
* @see {@link exhaustMap}
* @see {@link merge}
* @see {@link mergeAll}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
* @see {@link switchMap}
*
* @param {function(value: T, ?index: number): ObservableInput} project A function
* that, when applied to an item emitted by the source Observable, returns an
* Observable.
* @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
* A function to produce the value on the output Observable based on the values
* and the indices of the source (outer) emission and the inner Observable
* emission. The arguments passed to this function are:
* - `outerValue`: the value that came from the source
* - `innerValue`: the value that came from the projected Observable
* - `outerIndex`: the "index" of the value that came from the source
* - `innerIndex`: the "index" of the value from the projected Observable
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @return {Observable} An Observable that emits the result of applying the
* projection function (and the optional `resultSelector`) to each item emitted
* by the source Observable and merging the results of the Observables obtained
* from this transformation.
* @method mergeMap
* @owner Observable
*/
function mergeMap(project, resultSelector, concurrent) {
if (concurrent === void 0) {
concurrent = Number.POSITIVE_INFINITY;
}
return function mergeMapOperatorFunction(source) {
if (typeof resultSelector === 'number') {
concurrent = resultSelector;
resultSelector = null;
}
return source.lift(new MergeMapOperator(project, resultSelector, concurrent));
};
}
exports.mergeMap = mergeMap;
var MergeMapOperator = function () {
function MergeMapOperator(project, resultSelector, concurrent) {
if (concurrent === void 0) {
concurrent = Number.POSITIVE_INFINITY;
}
this.project = project;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
}
MergeMapOperator.prototype.call = function (observer, source) {
return source.subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent));
};
return MergeMapOperator;
}();
exports.MergeMapOperator = MergeMapOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var MergeMapSubscriber = function (_super) {
__extends(MergeMapSubscriber, _super);
function MergeMapSubscriber(destination, project, resultSelector, concurrent) {
if (concurrent === void 0) {
concurrent = Number.POSITIVE_INFINITY;
}
_super.call(this, destination);
this.project = project;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
this.hasCompleted = false;
this.buffer = [];
this.active = 0;
this.index = 0;
}
MergeMapSubscriber.prototype._next = function (value) {
if (this.active < this.concurrent) {
this._tryNext(value);
} else {
this.buffer.push(value);
}
};
MergeMapSubscriber.prototype._tryNext = function (value) {
var result;
var index = this.index++;
try {
result = this.project(value, index);
} catch (err) {
this.destination.error(err);
return;
}
this.active++;
this._innerSub(result, value, index);
};
MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));
};
MergeMapSubscriber.prototype._complete = function () {
this.hasCompleted = true;
if (this.active === 0 && this.buffer.length === 0) {
this.destination.complete();
}
};
MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
if (this.resultSelector) {
this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex);
} else {
this.destination.next(innerValue);
}
};
MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) {
var result;
try {
result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
} catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
};
MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
var buffer = this.buffer;
this.remove(innerSub);
this.active--;
if (buffer.length > 0) {
this._next(buffer.shift());
} else if (this.active === 0 && this.hasCompleted) {
this.destination.complete();
}
};
return MergeMapSubscriber;
}(OuterSubscriber_1.OuterSubscriber);
exports.MergeMapSubscriber = MergeMapSubscriber;
});
System.registerDynamic("rxjs/operator/mergeMap.js", ["../operators/mergeMap"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var mergeMap_1 = $__require('../operators/mergeMap');
/* tslint:enable:max-line-length */
/**
* Projects each source value to an Observable which is merged in the output
* Observable.
*
* <span class="informal">Maps each value to an Observable, then flattens all of
* these inner Observables using {@link mergeAll}.</span>
*
* <img src="./img/mergeMap.png" width="100%">
*
* Returns an Observable that emits items based on applying a function that you
* supply to each item emitted by the source Observable, where that function
* returns an Observable, and then merging those resulting Observables and
* emitting the results of this merger.
*
* @example <caption>Map and flatten each letter to an Observable ticking every 1 second</caption>
* var letters = Rx.Observable.of('a', 'b', 'c');
* var result = letters.mergeMap(x =>
* Rx.Observable.interval(1000).map(i => x+i)
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // a0
* // b0
* // c0
* // a1
* // b1
* // c1
* // continues to list a,b,c with respective ascending integers
*
* @see {@link concatMap}
* @see {@link exhaustMap}
* @see {@link merge}
* @see {@link mergeAll}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
* @see {@link switchMap}
*
* @param {function(value: T, ?index: number): ObservableInput} project A function
* that, when applied to an item emitted by the source Observable, returns an
* Observable.
* @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
* A function to produce the value on the output Observable based on the values
* and the indices of the source (outer) emission and the inner Observable
* emission. The arguments passed to this function are:
* - `outerValue`: the value that came from the source
* - `innerValue`: the value that came from the projected Observable
* - `outerIndex`: the "index" of the value that came from the source
* - `innerIndex`: the "index" of the value from the projected Observable
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @return {Observable} An Observable that emits the result of applying the
* projection function (and the optional `resultSelector`) to each item emitted
* by the source Observable and merging the results of the Observables obtained
* from this transformation.
* @method mergeMap
* @owner Observable
*/
function mergeMap(project, resultSelector, concurrent) {
if (concurrent === void 0) {
concurrent = Number.POSITIVE_INFINITY;
}
return mergeMap_1.mergeMap(project, resultSelector, concurrent)(this);
}
exports.mergeMap = mergeMap;
});
System.registerDynamic('rxjs/add/operator/mergeMap.js', ['../../Observable', '../../operator/mergeMap'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Observable_1 = $__require('../../Observable');
var mergeMap_1 = $__require('../../operator/mergeMap');
Observable_1.Observable.prototype.mergeMap = mergeMap_1.mergeMap;
Observable_1.Observable.prototype.flatMap = mergeMap_1.mergeMap;
});
System.registerDynamic("rxjs/util/isArray.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
exports.isArray = Array.isArray || function (x) {
return x && typeof x.length === 'number';
};
});
System.registerDynamic("rxjs/util/isObject.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
function isObject(x) {
return x != null && typeof x === 'object';
}
exports.isObject = isObject;
});
System.registerDynamic("rxjs/util/isFunction.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
function isFunction(x) {
return typeof x === 'function';
}
exports.isFunction = isFunction;
});
System.registerDynamic("rxjs/util/tryCatch.js", ["./errorObject"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var errorObject_1 = $__require('./errorObject');
var tryCatchTarget;
function tryCatcher() {
try {
return tryCatchTarget.apply(this, arguments);
} catch (e) {
errorObject_1.errorObject.e = e;
return errorObject_1.errorObject;
}
}
function tryCatch(fn) {
tryCatchTarget = fn;
return tryCatcher;
}
exports.tryCatch = tryCatch;
;
});
System.registerDynamic("rxjs/util/errorObject.js", [], true, function ($__require, exports, module) {
"use strict";
// typeof any so that it we don't have to cast when comparing a result to the error object
var global = this || self,
GLOBAL = global;
exports.errorObject = { e: {} };
});
System.registerDynamic("rxjs/util/UnsubscriptionError.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
var UnsubscriptionError = function (_super) {
__extends(UnsubscriptionError, _super);
function UnsubscriptionError(errors) {
_super.call(this);
this.errors = errors;
var err = Error.call(this, errors ? errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) {
return i + 1 + ") " + err.toString();
}).join('\n ') : '');
this.name = err.name = 'UnsubscriptionError';
this.stack = err.stack;
this.message = err.message;
}
return UnsubscriptionError;
}(Error);
exports.UnsubscriptionError = UnsubscriptionError;
});
System.registerDynamic('rxjs/Subscription.js', ['./util/isArray', './util/isObject', './util/isFunction', './util/tryCatch', './util/errorObject', './util/UnsubscriptionError'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var isArray_1 = $__require('./util/isArray');
var isObject_1 = $__require('./util/isObject');
var isFunction_1 = $__require('./util/isFunction');
var tryCatch_1 = $__require('./util/tryCatch');
var errorObject_1 = $__require('./util/errorObject');
var UnsubscriptionError_1 = $__require('./util/UnsubscriptionError');
/**
* Represents a disposable resource, such as the execution of an Observable. A
* Subscription has one important method, `unsubscribe`, that takes no argument
* and just disposes the resource held by the subscription.
*
* Additionally, subscriptions may be grouped together through the `add()`
* method, which will attach a child Subscription to the current Subscription.
* When a Subscription is unsubscribed, all its children (and its grandchildren)
* will be unsubscribed as well.
*
* @class Subscription
*/
var Subscription = function () {
/**
* @param {function(): void} [unsubscribe] A function describing how to
* perform the disposal of resources when the `unsubscribe` method is called.
*/
function Subscription(unsubscribe) {
/**
* A flag to indicate whether this Subscription has already been unsubscribed.
* @type {boolean}
*/
this.closed = false;
this._parent = null;
this._parents = null;
this._subscriptions = null;
if (unsubscribe) {
this._unsubscribe = unsubscribe;
}
}
/**
* Disposes the resources held by the subscription. May, for instance, cancel
* an ongoing Observable execution or cancel any other type of work that
* started when the Subscription was created.
* @return {void}
*/
Subscription.prototype.unsubscribe = function () {
var hasErrors = false;
var errors;
if (this.closed) {
return;
}
var _a = this,
_parent = _a._parent,
_parents = _a._parents,
_unsubscribe = _a._unsubscribe,
_subscriptions = _a._subscriptions;
this.closed = true;
this._parent = null;
this._parents = null;
// null out _subscriptions first so any child subscriptions that attempt
// to remove themselves from this subscription will noop
this._subscriptions = null;
var index = -1;
var len = _parents ? _parents.length : 0;
// if this._parent is null, then so is this._parents, and we
// don't have to remove ourselves from any parent subscriptions.
while (_parent) {
_parent.remove(this);
// if this._parents is null or index >= len,
// then _parent is set to null, and the loop exits
_parent = ++index < len && _parents[index] || null;
}
if (isFunction_1.isFunction(_unsubscribe)) {
var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
if (trial === errorObject_1.errorObject) {
hasErrors = true;
errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ? flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
}
}
if (isArray_1.isArray(_subscriptions)) {
index = -1;
len = _subscriptions.length;
while (++index < len) {
var sub = _subscriptions[index];
if (isObject_1.isObject(sub)) {
var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
if (trial === errorObject_1.errorObject) {
hasErrors = true;
errors = errors || [];
var err = errorObject_1.errorObject.e;
if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
} else {
errors.push(err);
}
}
}
}
}
if (hasErrors) {
throw new UnsubscriptionError_1.UnsubscriptionError(errors);
}
};
/**
* Adds a tear down to be called during the unsubscribe() of this
* Subscription.
*
* If the tear down being added is a subscription that is already
* unsubscribed, is the same reference `add` is being called on, or is
* `Subscription.EMPTY`, it will not be added.
*
* If this subscription is already in an `closed` state, the passed
* tear down logic will be executed immediately.
*
* @param {TeardownLogic} teardown The additional logic to execute on
* teardown.
* @return {Subscription} Returns the Subscription used or created to be
* added to the inner subscriptions list. This Subscription can be used with
* `remove()` to remove the passed teardown logic from the inner subscriptions
* list.
*/
Subscription.prototype.add = function (teardown) {
if (!teardown || teardown === Subscription.EMPTY) {
return Subscription.EMPTY;
}
if (teardown === this) {
return this;
}
var subscription = teardown;
switch (typeof teardown) {
case 'function':
subscription = new Subscription(teardown);
case 'object':
if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
return subscription;
} else if (this.closed) {
subscription.unsubscribe();
return subscription;
} else if (typeof subscription._addParent !== 'function' /* quack quack */) {
var tmp = subscription;
subscription = new Subscription();
subscription._subscriptions = [tmp];
}
break;
default:
throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
}
var subscriptions = this._subscriptions || (this._subscriptions = []);
subscriptions.push(subscription);
subscription._addParent(this);
return subscription;
};
/**
* Removes a Subscription from the internal list of subscriptions that will
* unsubscribe during the unsubscribe process of this Subscription.
* @param {Subscription} subscription The subscription to remove.
* @return {void}
*/
Subscription.prototype.remove = function (subscription) {
var subscriptions = this._subscriptions;
if (subscriptions) {
var subscriptionIndex = subscriptions.indexOf(subscription);
if (subscriptionIndex !== -1) {
subscriptions.splice(subscriptionIndex, 1);
}
}
};
Subscription.prototype._addParent = function (parent) {
var _a = this,
_parent = _a._parent,
_parents = _a._parents;
if (!_parent || _parent === parent) {
// If we don't have a parent, or the new parent is the same as the
// current parent, then set this._parent to the new parent.
this._parent = parent;
} else if (!_parents) {
// If there's already one parent, but not multiple, allocate an Array to
// store the rest of the parent Subscriptions.
this._parents = [parent];
} else if (_parents.indexOf(parent) === -1) {
// Only add the new parent to the _parents list if it's not already there.
_parents.push(parent);
}
};
Subscription.EMPTY = function (empty) {
empty.closed = true;
return empty;
}(new Subscription());
return Subscription;
}();
exports.Subscription = Subscription;
function flattenUnsubscriptionErrors(errors) {
return errors.reduce(function (errs, err) {
return errs.concat(err instanceof UnsubscriptionError_1.UnsubscriptionError ? err.errors : err);
}, []);
}
});
System.registerDynamic('rxjs/Subscriber.js', ['./util/isFunction', './Subscription', './Observer', './symbol/rxSubscriber'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var isFunction_1 = $__require('./util/isFunction');
var Subscription_1 = $__require('./Subscription');
var Observer_1 = $__require('./Observer');
var rxSubscriber_1 = $__require('./symbol/rxSubscriber');
/**
* Implements the {@link Observer} interface and extends the
* {@link Subscription} class. While the {@link Observer} is the public API for
* consuming the values of an {@link Observable}, all Observers get converted to
* a Subscriber, in order to provide Subscription-like capabilities such as
* `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
* implementing operators, but it is rarely used as a public API.
*
* @class Subscriber<T>
*/
var Subscriber = function (_super) {
__extends(Subscriber, _super);
/**
* @param {Observer|function(value: T): void} [destinationOrNext] A partially
* defined Observer or a `next` callback function.
* @param {function(e: ?any): void} [error] The `error` callback of an
* Observer.
* @param {function(): void} [complete] The `complete` callback of an
* Observer.
*/
function Subscriber(destinationOrNext, error, complete) {
_super.call(this);
this.syncErrorValue = null;
this.syncErrorThrown = false;
this.syncErrorThrowable = false;
this.isStopped = false;
switch (arguments.length) {
case 0:
this.destination = Observer_1.empty;
break;
case 1:
if (!destinationOrNext) {
this.destination = Observer_1.empty;
break;
}
if (typeof destinationOrNext === 'object') {
if (destinationOrNext instanceof Subscriber) {
this.destination = destinationOrNext;
this.destination.add(this);
} else {
this.syncErrorThrowable = true;
this.destination = new SafeSubscriber(this, destinationOrNext);
}
break;
}
default:
this.syncErrorThrowable = true;
this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
break;
}
}
Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () {
return this;
};
/**
* A static factory for a Subscriber, given a (potentially partial) definition
* of an Observer.
* @param {function(x: ?T): void} [next] The `next` callback of an Observer.
* @param {function(e: ?any): void} [error] The `error` callback of an
* Observer.
* @param {function(): void} [complete] The `complete` callback of an
* Observer.
* @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
* Observer represented by the given arguments.
*/
Subscriber.create = function (next, error, complete) {
var subscriber = new Subscriber(next, error, complete);
subscriber.syncErrorThrowable = false;
return subscriber;
};
/**
* The {@link Observer} callback to receive notifications of type `next` from
* the Observable, with a value. The Observable may call this method 0 or more
* times.
* @param {T} [value] The `next` value.
* @return {void}
*/
Subscriber.prototype.next = function (value) {
if (!this.isStopped) {
this._next(value);
}
};
/**
* The {@link Observer} callback to receive notifications of type `error` from
* the Observable, with an attached {@link Error}. Notifies the Observer that
* the Observable has experienced an error condition.
* @param {any} [err] The `error` exception.
* @return {void}
*/
Subscriber.prototype.error = function (err) {
if (!this.isStopped) {
this.isStopped = true;
this._error(err);
}
};
/**
* The {@link Observer} callback to receive a valueless notification of type
* `complete` from the Observable. Notifies the Observer that the Observable
* has finished sending push-based notifications.
* @return {void}
*/
Subscriber.prototype.complete = function () {
if (!this.isStopped) {
this.isStopped = true;
this._complete();
}
};
Subscriber.prototype.unsubscribe = function () {
if (this.closed) {
return;
}
this.isStopped = true;
_super.prototype.unsubscribe.call(this);
};
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
Subscriber.prototype._error = function (err) {
this.destination.error(err);
this.unsubscribe();
};
Subscriber.prototype._complete = function () {
this.destination.complete();
this.unsubscribe();
};
Subscriber.prototype._unsubscribeAndRecycle = function () {
var _a = this,
_parent = _a._parent,
_parents = _a._parents;
this._parent = null;
this._parents = null;
this.unsubscribe();
this.closed = false;
this.isStopped = false;
this._parent = _parent;
this._parents = _parents;
return this;
};
return Subscriber;
}(Subscription_1.Subscription);
exports.Subscriber = Subscriber;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var SafeSubscriber = function (_super) {
__extends(SafeSubscriber, _super);
function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
_super.call(this);
this._parentSubscriber = _parentSubscriber;
var next;
var context = this;
if (isFunction_1.isFunction(observerOrNext)) {
next = observerOrNext;
} else if (observerOrNext) {
next = observerOrNext.next;
error = observerOrNext.error;
complete = observerOrNext.complete;
if (observerOrNext !== Observer_1.empty) {
context = Object.create(observerOrNext);
if (isFunction_1.isFunction(context.unsubscribe)) {
this.add(context.unsubscribe.bind(context));
}
context.unsubscribe = this.unsubscribe.bind(this);
}
}
this._context = context;
this._next = next;
this._error = error;
this._complete = complete;
}
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
} else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
};
SafeSubscriber.prototype.error = function (err) {
if (!this.isStopped) {
var _parentSubscriber = this._parentSubscriber;
if (this._error) {
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._error, err);
this.unsubscribe();
} else {
this.__tryOrSetError(_parentSubscriber, this._error, err);
this.unsubscribe();
}
} else if (!_parentSubscriber.syncErrorThrowable) {
this.unsubscribe();
throw err;
} else {
_parentSubscriber.syncErrorValue = err;
_parentSubscriber.syncErrorThrown = true;
this.unsubscribe();
}
}
};
SafeSubscriber.prototype.complete = function () {
var _this = this;
if (!this.isStopped) {
var _parentSubscriber = this._parentSubscriber;
if (this._complete) {
var wrappedComplete = function () {
return _this._complete.call(_this._context);
};
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(wrappedComplete);
this.unsubscribe();
} else {
this.__tryOrSetError(_parentSubscriber, wrappedComplete);
this.unsubscribe();
}
} else {
this.unsubscribe();
}
}
};
SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
try {
fn.call(this._context, value);
} catch (err) {
this.unsubscribe();
throw err;
}
};
SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
try {
fn.call(this._context, value);
} catch (err) {
parent.syncErrorValue = err;
parent.syncErrorThrown = true;
return true;
}
return false;
};
SafeSubscriber.prototype._unsubscribe = function () {
var _parentSubscriber = this._parentSubscriber;
this._context = null;
this._parentSubscriber = null;
_parentSubscriber.unsubscribe();
};
return SafeSubscriber;
}(Subscriber);
});
System.registerDynamic('rxjs/symbol/rxSubscriber.js', ['../util/root'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var root_1 = $__require('../util/root');
var Symbol = root_1.root.Symbol;
exports.rxSubscriber = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('rxSubscriber') : '@@rxSubscriber';
/**
* @deprecated use rxSubscriber instead
*/
exports.$$rxSubscriber = exports.rxSubscriber;
});
System.registerDynamic("rxjs/Observer.js", [], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
exports.empty = {
closed: true,
next: function (value) {},
error: function (err) {
throw err;
},
complete: function () {}
};
});
System.registerDynamic('rxjs/util/toSubscriber.js', ['../Subscriber', '../symbol/rxSubscriber', '../Observer'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Subscriber_1 = $__require('../Subscriber');
var rxSubscriber_1 = $__require('../symbol/rxSubscriber');
var Observer_1 = $__require('../Observer');
function toSubscriber(nextOrObserver, error, complete) {
if (nextOrObserver) {
if (nextOrObserver instanceof Subscriber_1.Subscriber) {
return nextOrObserver;
}
if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
return nextOrObserver[rxSubscriber_1.rxSubscriber]();
}
}
if (!nextOrObserver && !error && !complete) {
return new Subscriber_1.Subscriber(Observer_1.empty);
}
return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
}
exports.toSubscriber = toSubscriber;
});
System.registerDynamic('rxjs/util/root.js', [], true, function ($__require, exports, module) {
"use strict";
// CommonJS / Node have global context exposed as "global" variable.
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
// the global "global" var for now.
var global = this || self,
GLOBAL = global;
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && self;
var __global = typeof global !== 'undefined' && global;
var _root = __window || __global || __self;
exports.root = _root;
// Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
// This is needed when used with angular/tsickle which inserts a goog.module statement.
// Wrap in IIFE
(function () {
if (!_root) {
throw new Error('RxJS could not find any global context (window, self, global)');
}
})();
});
System.registerDynamic('rxjs/symbol/observable.js', ['../util/root'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var root_1 = $__require('../util/root');
function getSymbolObservable(context) {
var $$observable;
var Symbol = context.Symbol;
if (typeof Symbol === 'function') {
if (Symbol.observable) {
$$observable = Symbol.observable;
} else {
$$observable = Symbol('observable');
Symbol.observable = $$observable;
}
} else {
$$observable = '@@observable';
}
return $$observable;
}
exports.getSymbolObservable = getSymbolObservable;
exports.observable = getSymbolObservable(root_1.root);
/**
* @deprecated use observable instead
*/
exports.$$observable = exports.observable;
});
System.registerDynamic("rxjs/util/noop.js", [], true, function ($__require, exports, module) {
"use strict";
/* tslint:disable:no-empty */
var global = this || self,
GLOBAL = global;
function noop() {}
exports.noop = noop;
});
System.registerDynamic("rxjs/util/pipe.js", ["./noop"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var noop_1 = $__require('./noop');
/* tslint:enable:max-line-length */
function pipe() {
var fns = [];
for (var _i = 0; _i < arguments.length; _i++) {
fns[_i - 0] = arguments[_i];
}
return pipeFromArray(fns);
}
exports.pipe = pipe;
/* @internal */
function pipeFromArray(fns) {
if (!fns) {
return noop_1.noop;
}
if (fns.length === 1) {
return fns[0];
}
return function piped(input) {
return fns.reduce(function (prev, fn) {
return fn(prev);
}, input);
};
}
exports.pipeFromArray = pipeFromArray;
});
System.registerDynamic('rxjs/Observable.js', ['./util/root', './util/toSubscriber', './symbol/observable', './util/pipe'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var root_1 = $__require('./util/root');
var toSubscriber_1 = $__require('./util/toSubscriber');
var observable_1 = $__require('./symbol/observable');
var pipe_1 = $__require('./util/pipe');
/**
* A representation of any set of values over any amount of time. This is the most basic building block
* of RxJS.
*
* @class Observable<T>
*/
var Observable = function () {
/**
* @constructor
* @param {Function} subscribe the function that is called when the Observable is
* initially subscribed to. This function is given a Subscriber, to which new values
* can be `next`ed, or an `error` method can be called to raise an error, or
* `complete` can be called to notify of a successful completion.
*/
function Observable(subscribe) {
this._isScalar = false;
if (subscribe) {
this._subscribe = subscribe;
}
}
/**
* Creates a new Observable, with this Observable as the source, and the passed
* operator defined as the new observable's operator.
* @method lift
* @param {Operator} operator the operator defining the operation to take on the observable
* @return {Observable} a new observable with the Operator applied
*/
Observable.prototype.lift = function (operator) {
var observable = new Observable();
observable.source = this;
observable.operator = operator;
return observable;
};
/**
* Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.
*
* <span class="informal">Use it when you have all these Observables, but still nothing is happening.</span>
*
* `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It
* might be for example a function that you passed to a {@link create} static factory, but most of the time it is
* a library implementation, which defines what and when will be emitted by an Observable. This means that calling
* `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often
* thought.
*
* Apart from starting the execution of an Observable, this method allows you to listen for values
* that an Observable emits, as well as for when it completes or errors. You can achieve this in two
* following ways.
*
* The first way is creating an object that implements {@link Observer} interface. It should have methods
* defined by that interface, but note that it should be just a regular JavaScript object, which you can create
* yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do
* not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also
* that your object does not have to implement all methods. If you find yourself creating a method that doesn't
* do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will
* be left uncaught.
*
* The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.
* This means you can provide three functions as arguments to `subscribe`, where first function is equivalent
* of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer,
* if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`,
* since `subscribe` recognizes these functions by where they were placed in function call. When it comes
* to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown.
*
* Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object.
* This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean
* up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback
* provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.
*
* Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.
* It is an Observable itself that decides when these functions will be called. For example {@link of}
* by default emits all its values synchronously. Always check documentation for how given Observable
* will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}.
*
* @example <caption>Subscribe with an Observer</caption>
* const sumObserver = {
* sum: 0,
* next(value) {
* console.log('Adding: ' + value);
* this.sum = this.sum + value;
* },
* error() { // We actually could just remove this method,
* }, // since we do not really care about errors right now.
* complete() {
* console.log('Sum equals: ' + this.sum);
* }
* };
*
* Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.
* .subscribe(sumObserver);
*
* // Logs:
* // "Adding: 1"
* // "Adding: 2"
* // "Adding: 3"
* // "Sum equals: 6"
*
*
* @example <caption>Subscribe with functions</caption>
* let sum = 0;
*
* Rx.Observable.of(1, 2, 3)
* .subscribe(
* function(value) {
* console.log('Adding: ' + value);
* sum = sum + value;
* },
* undefined,
* function() {
* console.log('Sum equals: ' + sum);
* }
* );
*
* // Logs:
* // "Adding: 1"
* // "Adding: 2"
* // "Adding: 3"
* // "Sum equals: 6"
*
*
* @example <caption>Cancel a subscription</caption>
* const subscription = Rx.Observable.interval(1000).subscribe(
* num => console.log(num),
* undefined,
* () => console.log('completed!') // Will not be called, even
* ); // when cancelling subscription
*
*
* setTimeout(() => {
* subscription.unsubscribe();
* console.log('unsubscribed!');
* }, 2500);
*
* // Logs:
* // 0 after 1s
* // 1 after 2s
* // "unsubscribed!" after 2.5s
*
*
* @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called,
* or the first of three possible handlers, which is the handler for each value emitted from the subscribed
* Observable.
* @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided,
* the error will be thrown as unhandled.
* @param {Function} complete (optional) A handler for a terminal event resulting from successful completion.
* @return {ISubscription} a subscription reference to the registered handlers
* @method subscribe
*/
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
var operator = this.operator;
var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
if (operator) {
operator.call(sink, this.source);
} else {
sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink));
}
if (sink.syncErrorThrowable) {
sink.syncErrorThrowable = false;
if (sink.syncErrorThrown) {
throw sink.syncErrorValue;
}
}
return sink;
};
Observable.prototype._trySubscribe = function (sink) {
try {
return this._subscribe(sink);
} catch (err) {
sink.syncErrorThrown = true;
sink.syncErrorValue = err;
sink.error(err);
}
};
/**
* @method forEach
* @param {Function} next a handler for each value emitted by the observable
* @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
* @return {Promise} a promise that either resolves on observable completion or
* rejects with the handled error
*/
Observable.prototype.forEach = function (next, PromiseCtor) {
var _this = this;
if (!PromiseCtor) {
if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
PromiseCtor = root_1.root.Rx.config.Promise;
} else if (root_1.root.Promise) {
PromiseCtor = root_1.root.Promise;
}
}
if (!PromiseCtor) {
throw new Error('no Promise impl found');
}
return new PromiseCtor(function (resolve, reject) {
// Must be declared in a separate statement to avoid a RefernceError when
// accessing subscription below in the closure due to Temporal Dead Zone.
var subscription;
subscription = _this.subscribe(function (value) {
if (subscription) {
// if there is a subscription, then we can surmise
// the next handling is asynchronous. Any errors thrown
// need to be rejected explicitly and unsubscribe must be
// called manually
try {
next(value);
} catch (err) {
reject(err);
subscription.unsubscribe();
}
} else {
// if there is NO subscription, then we're getting a nexted
// value synchronously during subscription. We can just call it.
// If it errors, Observable's `subscribe` will ensure the
// unsubscription logic is called, then synchronously rethrow the error.
// After that, Promise will trap the error and send it
// down the rejection path.
next(value);
}
}, reject, resolve);
});
};
Observable.prototype._subscribe = function (subscriber) {
return this.source.subscribe(subscriber);
};
/**
* An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
* @method Symbol.observable
* @return {Observable} this instance of the observable
*/
Observable.prototype[observable_1.observable] = function () {
return this;
};
/* tslint:enable:max-line-length */
/**
* Used to stitch together functional operators into a chain.
* @method pipe
* @return {Observable} the Observable result of all of the operators having
* been called in the order they were passed in.
*
* @example
*
* import { map, filter, scan } from 'rxjs/operators';
*
* Rx.Observable.interval(1000)
* .pipe(
* filter(x => x % 2 === 0),
* map(x => x + x),
* scan((acc, x) => acc + x)
* )
* .subscribe(x => console.log(x))
*/
Observable.prototype.pipe = function () {
var operations = [];
for (var _i = 0; _i < arguments.length; _i++) {
operations[_i - 0] = arguments[_i];
}
if (operations.length === 0) {
return this;
}
return pipe_1.pipeFromArray(operations)(this);
};
/* tslint:enable:max-line-length */
Observable.prototype.toPromise = function (PromiseCtor) {
var _this = this;
if (!PromiseCtor) {
if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
PromiseCtor = root_1.root.Rx.config.Promise;
} else if (root_1.root.Promise) {
PromiseCtor = root_1.root.Promise;
}
}
if (!PromiseCtor) {
throw new Error('no Promise impl found');
}
return new PromiseCtor(function (resolve, reject) {
var value;
_this.subscribe(function (x) {
return value = x;
}, function (err) {
return reject(err);
}, function () {
return resolve(value);
});
});
};
// HACK: Since TypeScript inherits static properties too, we have to
// fight against TypeScript here so Subject can have a different static create signature
/**
* Creates a new cold Observable by calling the Observable constructor
* @static true
* @owner Observable
* @method create
* @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
* @return {Observable} a new cold observable
*/
Observable.create = function (subscribe) {
return new Observable(subscribe);
};
return Observable;
}();
exports.Observable = Observable;
});
System.registerDynamic("rxjs/observable/ErrorObservable.js", ["../Observable"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var __extends = exports && exports.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = $__require('../Observable');
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ErrorObservable = function (_super) {
__extends(ErrorObservable, _super);
function ErrorObservable(error, scheduler) {
_super.call(this);
this.error = error;
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits an error notification.
*
* <span class="informal">Just emits 'error', and nothing else.
* </span>
*
* <img src="./img/throw.png" width="100%">
*
* This static operator is useful for creating a simple Observable that only
* emits the error notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example <caption>Emit the number 7, then emit an error.</caption>
* var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @example <caption>Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13</caption>
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x === 13 ?
* Rx.Observable.throw('Thirteens are bad') :
* Rx.Observable.of('a', 'b', 'c')
* );
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link of}
*
* @param {any} error The particular Error to pass to the error notification.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the error notification.
* @return {Observable} An error Observable: emits only the error notification
* using the given error argument.
* @static true
* @name throw
* @owner Observable
*/
ErrorObservable.create = function (error, scheduler) {
return new ErrorObservable(error, scheduler);
};
ErrorObservable.dispatch = function (arg) {
var error = arg.error,
subscriber = arg.subscriber;
subscriber.error(error);
};
ErrorObservable.prototype._subscribe = function (subscriber) {
var error = this.error;
var scheduler = this.scheduler;
subscriber.syncErrorThrowable = true;
if (scheduler) {
return scheduler.schedule(ErrorObservable.dispatch, 0, {
error: error, subscriber: subscriber
});
} else {
subscriber.error(error);
}
};
return ErrorObservable;
}(Observable_1.Observable);
exports.ErrorObservable = ErrorObservable;
});
System.registerDynamic("rxjs/observable/throw.js", ["./ErrorObservable"], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var ErrorObservable_1 = $__require('./ErrorObservable');
exports._throw = ErrorObservable_1.ErrorObservable.create;
});
System.registerDynamic('rxjs/add/observable/throw.js', ['../../Observable', '../../observable/throw'], true, function ($__require, exports, module) {
"use strict";
var global = this || self,
GLOBAL = global;
var Observable_1 = $__require('../../Observable');
var throw_1 = $__require('../../observable/throw');
Observable_1.Observable.throw = throw_1._throw;
});
System.registerDynamic("ng2-adal/services/authHttp.service.js", ["@angular/core", "@angular/http", "rxjs/Observable", "./adal.service", "rxjs/add/operator/catch", "rxjs/add/operator/map", "rxjs/add/operator/mergeMap", "rxjs/add/observable/throw"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
var __decorate = exports && exports.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = exports && exports.__metadata || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = $__require("@angular/core");
var http_1 = $__require("@angular/http");
var Observable_1 = $__require("rxjs/Observable");
var adal_service_1 = $__require("./adal.service");
$__require("rxjs/add/operator/catch");
$__require("rxjs/add/operator/map");
$__require("rxjs/add/operator/mergeMap");
$__require("rxjs/add/observable/throw");
var AuthHttp = function () {
function AuthHttp(http, adalService) {
this.http = http;
this.adalService = adalService;
}
AuthHttp.prototype.get = function (url, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Get });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.post = function (url, body, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Post, body: body });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.delete = function (url, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Delete });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.patch = function (url, body, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Patch, body: body });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.put = function (url, body, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Put, body: body });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.head = function (url, options) {
var options1 = new http_1.RequestOptions({ method: http_1.RequestMethod.Put });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
};
AuthHttp.prototype.sendRequest = function (url, options) {
var _this = this;
// make a copy
var options1 = new http_1.RequestOptions();
options1.method = options.method;
options1 = options1.merge(options);
var resource = this.adalService.GetResourceForEndpoint(url);
var authenticatedCall;
if (resource) {
if (this.adalService.userInfo.isAuthenticated) {
authenticatedCall = this.adalService.acquireToken(resource).flatMap(function (token) {
if (options1.headers == null) {
options1.headers = new http_1.Headers();
}
options1.headers.set('Authorization', 'Bearer ' + token);
return _this.http.request(url, options1).catch(_this.handleError);
});
} else {
authenticatedCall = Observable_1.Observable.throw(new Error('User Not Authenticated.'));
}
} else {
authenticatedCall = this.http.request(url, options).map(this.extractData).catch(this.handleError);
}
return authenticatedCall;
};
AuthHttp.prototype.extractData = function (res) {
if (res.status < 200 || res.status >= 300) {
throw new Error('Bad response status: ' + res.status);
}
var body = {};
// if there is some content, parse it
if (res.status !== 204) {
body = res.json();
}
return body || {};
};
AuthHttp.prototype.handleError = function (error) {
return Observable_1.Observable.throw(error);
};
AuthHttp = __decorate([core_1.Injectable(), __metadata("design:paramtypes", [http_1.Http, adal_service_1.AdalService])], AuthHttp);
return AuthHttp;
}();
exports.AuthHttp = AuthHttp;
});
System.registerDynamic("ng2-adal/modules/authHttp.module.js", ["@angular/core", "./adal.module", "./../services/authHttp.service"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
var __decorate = exports && exports.__decorate || function (decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = $__require("@angular/core");
var adal_module_1 = $__require("./adal.module");
var authHttp_service_1 = $__require("./../services/authHttp.service");
var AuthHttpModule = function () {
function AuthHttpModule() {}
AuthHttpModule = __decorate([core_1.NgModule({
imports: [adal_module_1.AdalModule],
exports: [],
declarations: [],
providers: [authHttp_service_1.AuthHttp]
})], AuthHttpModule);
return AuthHttpModule;
}();
exports.AuthHttpModule = AuthHttpModule;
});
System.registerDynamic("ng2-adal/modules.js", ["./modules/adal.module", "./modules/authHttp.module"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
Object.defineProperty(exports, "__esModule", { value: true });
var adal_module_1 = $__require("./modules/adal.module");
exports.AdalModule = adal_module_1.AdalModule;
var authHttp_module_1 = $__require("./modules/authHttp.module");
exports.AuthHttpModule = authHttp_module_1.AuthHttpModule;
});
System.registerDynamic("ng2-adal/core.js", ["./services", "./modules"], true, function ($__require, exports, module) {
/**
* wfw-ngx-adal-observable - Use Azure AD Library - ADAL in Angular 5
* @version v2.0.4
* @link https://github.com/dvonhand-centric/wfw-ngx-adal
* @license MIT
*/
"use strict";
var global = this || self,
GLOBAL = global;
Object.defineProperty(exports, "__esModule", { value: true });
var services_1 = $__require("./services");
exports.AdalService = services_1.AdalService;
exports.AuthHttp = services_1.AuthHttp;
var modules_1 = $__require("./modules");
exports.AdalModule = modules_1.AdalModule;
exports.AuthHttpModule = modules_1.AuthHttpModule;
});
//# sourceMappingURL=ng2-adal.js.map