webpackJsonp(["vendor"],{ /***/ "./node_modules/@angular/common/esm5/common.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* unused harmony export ɵregisterLocaleData */ /* unused harmony export NgLocaleLocalization */ /* unused harmony export NgLocalization */ /* unused harmony export registerLocaleData */ /* unused harmony export Plural */ /* unused harmony export NumberFormatStyle */ /* unused harmony export FormStyle */ /* unused harmony export TranslationWidth */ /* unused harmony export FormatWidth */ /* unused harmony export NumberSymbol */ /* unused harmony export WeekDay */ /* unused harmony export getCurrencySymbol */ /* unused harmony export getLocaleDayPeriods */ /* unused harmony export getLocaleDayNames */ /* unused harmony export getLocaleMonthNames */ /* unused harmony export getLocaleId */ /* unused harmony export getLocaleEraNames */ /* unused harmony export getLocaleWeekEndRange */ /* unused harmony export getLocaleFirstDayOfWeek */ /* unused harmony export getLocaleDateFormat */ /* unused harmony export getLocaleDateTimeFormat */ /* unused harmony export getLocaleExtraDayPeriodRules */ /* unused harmony export getLocaleExtraDayPeriods */ /* unused harmony export getLocalePluralCase */ /* unused harmony export getLocaleTimeFormat */ /* unused harmony export getLocaleNumberSymbol */ /* unused harmony export getLocaleNumberFormat */ /* unused harmony export getLocaleCurrencyName */ /* unused harmony export getLocaleCurrencySymbol */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return parseCookieValue; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CommonModule; }); /* unused harmony export DeprecatedI18NPipesModule */ /* unused harmony export NgClass */ /* unused harmony export NgForOf */ /* unused harmony export NgForOfContext */ /* unused harmony export NgIf */ /* unused harmony export NgIfContext */ /* unused harmony export NgPlural */ /* unused harmony export NgPluralCase */ /* unused harmony export NgStyle */ /* unused harmony export NgSwitch */ /* unused harmony export NgSwitchCase */ /* unused harmony export NgSwitchDefault */ /* unused harmony export NgTemplateOutlet */ /* unused harmony export NgComponentOutlet */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return DOCUMENT; }); /* unused harmony export AsyncPipe */ /* unused harmony export DatePipe */ /* unused harmony export I18nPluralPipe */ /* unused harmony export I18nSelectPipe */ /* unused harmony export JsonPipe */ /* unused harmony export LowerCasePipe */ /* unused harmony export CurrencyPipe */ /* unused harmony export DecimalPipe */ /* unused harmony export PercentPipe */ /* unused harmony export SlicePipe */ /* unused harmony export UpperCasePipe */ /* unused harmony export TitleCasePipe */ /* unused harmony export DeprecatedDatePipe */ /* unused harmony export DeprecatedCurrencyPipe */ /* unused harmony export DeprecatedDecimalPipe */ /* unused harmony export DeprecatedPercentPipe */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return PLATFORM_BROWSER_ID; }); /* unused harmony export ɵPLATFORM_SERVER_ID */ /* unused harmony export ɵPLATFORM_WORKER_APP_ID */ /* unused harmony export ɵPLATFORM_WORKER_UI_ID */ /* unused harmony export isPlatformBrowser */ /* unused harmony export isPlatformServer */ /* unused harmony export isPlatformWorkerApp */ /* unused harmony export isPlatformWorkerUi */ /* unused harmony export VERSION */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return PlatformLocation; }); /* unused harmony export LOCATION_INITIALIZED */ /* unused harmony export LocationStrategy */ /* unused harmony export APP_BASE_HREF */ /* unused harmony export HashLocationStrategy */ /* unused harmony export PathLocationStrategy */ /* unused harmony export Location */ /* unused harmony export ɵe */ /* unused harmony export ɵd */ /* unused harmony export ɵa */ /* unused harmony export ɵb */ /* unused harmony export ɵg */ /* unused harmony export ɵf */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/esm5/core.js"); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_tslib__ = __webpack_require__("./node_modules/tslib/tslib.es6.js"); /** * @license Angular v5.2.9 * (c) 2010-2018 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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["y" /* 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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["y" /* 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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["t" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["x" /* 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) { Object(__WEBPACK_IMPORTED_MODULE_1_tslib__["b" /* __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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["x" /* Injectable */] }, ]; /** @nocollapse */ HashLocationStrategy.ctorParameters = function () { return [ { type: PlatformLocation, }, { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* 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 `` 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) { Object(__WEBPACK_IMPORTED_MODULE_1_tslib__["b" /* __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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["x" /* Injectable */] }, ]; /** @nocollapse */ PathLocationStrategy.ctorParameters = function () { return [ { type: PlatformLocation, }, { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* 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 /** * \@internal */ 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 /** * @param {?} n * @return {?} */ function plural(n) { var /** @type {?} */ i = Math.floor(Math.abs(n)), /** @type {?} */ v = n.toString().replace(/^[^.]*\.?/, '').length; if (i === 1 && v === 0) return 1; return 5; } 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', plural ]; /** * @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 getLastDefinedValue(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 getLastDefinedValue(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. * * Important: 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.: format narrow = $, format wide = US$, code = USD) * * \@experimental i18n support is experimental. * @param {?} code * @param {?} format * @return {?} */ function getCurrencySymbol(code, format) { var /** @type {?} */ currency = CURRENCIES[code] || []; var /** @type {?} */ symbolNarrow = currency[1]; if (format === 'narrow' && typeof symbolNarrow === 'string') { return symbolNarrow; } return currency[0] || code; } /** * @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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["y" /* 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 * @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) { Object(__WEBPACK_IMPORTED_MODULE_1_tslib__["b" /* __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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["x" /* Injectable */] }, ]; /** @nocollapse */ NgLocaleLocalization.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* LOCALE_ID */],] },] }, { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* 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 * ``` * ... * * ... * * ... * * ... * * ... * ``` * * \@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 (Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_25" /* ɵ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 " + Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_39" /* ɵ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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngClass]' },] }, ]; /** @nocollapse */ NgClass.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["B" /* IterableDiffers */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["C" /* KeyValueDiffers */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["r" /* ElementRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["R" /* Renderer2 */], }, ]; }; NgClass.propDecorators = { "klass": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */], args: ['class',] },], "ngClass": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ``` * * Customized injector/content * ``` * * * ``` * * Customized ngModuleFactory * ``` * * * ``` * ## 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(__WEBPACK_IMPORTED_MODULE_0__angular_core__["H" /* NgModuleRef */]); this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector); } else { this._moduleRef = null; } } var /** @type {?} */ componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver : elInjector.get(__WEBPACK_IMPORTED_MODULE_0__angular_core__["o" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngComponentOutlet]' },] }, ]; /** @nocollapse */ NgComponentOutlet.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, ]; }; NgComponentOutlet.propDecorators = { "ngComponentOutlet": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngComponentOutletInjector": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngComponentOutletContent": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngComponentOutletNgModuleFactory": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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`: 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. * * ``` *
  • * {{i}}/{{users.length}}. {{user}} default *
  • * ``` * * ### 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 `` 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 * * - `
  • ...
  • ` * * With `` element: * * ``` * *
  • ...
  • *
    * ``` * * ### 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 (Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_8" /* 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>> 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngFor][ngForOf]' },] }, ]; /** @nocollapse */ NgForOf.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* TemplateRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["B" /* IterableDiffers */], }, ]; }; NgForOf.propDecorators = { "ngForOf": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngForTrackBy": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngForTemplate": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 `` 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: * - `
    ...
    ` * - `
    ...
    ` * * Form with an else block: * ``` *
    ...
    * ... * ``` * * Form with a `then` and `else` block: * ``` *
    * ... * ... * ``` * * Form with storing the value locally: * ``` *
    {{value}}
    * ... * ``` * * \@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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngIf]' },] }, ]; /** @nocollapse */ NgIf.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* TemplateRef */], }, ]; }; NgIf.propDecorators = { "ngIf": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngIfThen": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngIfElse": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ... * ... * ... * * * * * * ... * * ``` * \@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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngSwitch]' },] }, ]; /** @nocollapse */ NgSwitch.ctorParameters = function () { return []; }; NgSwitch.propDecorators = { "ngSwitch": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ... * * ``` * \@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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngSwitchCase]' },] }, ]; /** @nocollapse */ NgSwitchCase.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* TemplateRef */], }, { type: NgSwitch, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* Host */] },] }, ]; }; NgSwitchCase.propDecorators = { "ngSwitchCase": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ... * ... * * ``` * * \@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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngSwitchDefault]' },] }, ]; /** @nocollapse */ NgSwitchDefault.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* TemplateRef */], }, { type: NgSwitch, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* 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 * ``` * * there is nothing * there is one * there are a few * * ``` * * \@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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngPlural]' },] }, ]; /** @nocollapse */ NgPlural.ctorParameters = function () { return [ { type: NgLocalization, }, ]; }; NgPlural.propDecorators = { "ngPlural": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ... * ... * * ``` * * 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngPluralCase]' },] }, ]; /** @nocollapse */ NgPluralCase.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["g" /* Attribute */], args: ['ngPluralCase',] },] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* TemplateRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, { type: NgPlural, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* 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 * ``` * ... * * ... * * ... * ``` * * \@description * * The styles are updated according to the value of the expression evaluation: * - keys are style names with an optional `.` 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; if (value != null) { this._renderer.setStyle(this._ngEl.nativeElement, name, /** @type {?} */ (value)); } else { this._renderer.removeStyle(this._ngEl.nativeElement, name); } }; NgStyle.decorators = [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngStyle]' },] }, ]; /** @nocollapse */ NgStyle.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["C" /* KeyValueDiffers */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["r" /* ElementRef */], }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["R" /* Renderer2 */], }, ]; }; NgStyle.propDecorators = { "ngStyle": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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 * ``` * * ``` * * \@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 its 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Directive */], args: [{ selector: '[ngTemplateOutlet]' },] }, ]; /** @nocollapse */ NgTemplateOutlet.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_2" /* ViewContainerRef */], }, ]; }; NgTemplateOutlet.propDecorators = { "ngTemplateOutletContext": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Input */] },], "ngTemplateOutlet": [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* 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]; default: // This default case is not needed by TypeScript compiler, as the switch is exhaustive. // However Closure Compiler does not understand that and reports an error in typed mode. // The `throw new Error` below works around the problem, and the unexpected: never variable // makes sure tsc still checks this code is unreachable. var /** @type {?} */ unexpected = name; throw new Error("unexpected translation type " + unexpected); } } /** * 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 '" + Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_39" /* ɵ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; var /** @type {?} */ match; 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 if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) { date = isoStringToDate(match); } else { date = new Date(value); } if (!isDate$1(date)) { throw invalidPipeArgumentError(DatePipe, value); } return formatDate(date, format, locale || this.locale, timezone); }; DatePipe.decorators = [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'date', pure: true },] }, ]; /** @nocollapse */ DatePipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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; // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100" var /** @type {?} */ dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear; var /** @type {?} */ timeSetter = match[8] ? date.setUTCHours : date.setHours; // if there is a timezone defined like "+01:00" or "+0100" 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 */ 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 (Object(__WEBPACK_IMPORTED_MODULE_1_tslib__["a" /* __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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'date', pure: true },] }, ]; /** @nocollapse */ DeprecatedDatePipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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; } 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(num); if (style === NumberFormatStyle.Percent) { parsedNumber = toPercent(parsedNumber); } 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; } /** * @param {?} parsedNumber * @return {?} */ function toPercent(parsedNumber) { // if the number is 0, don't do anything if (parsedNumber.digits[0] === 0) { return parsedNumber; } // Getting the current number of decimals var /** @type {?} */ fractionLen = parsedNumber.digits.length - parsedNumber.integerLen; if (parsedNumber.exponent) { parsedNumber.exponent += 2; } else { if (fractionLen === 0) { parsedNumber.digits.push(0, 0); } else if (fractionLen === 1) { parsedNumber.digits.push(0); } parsedNumber.integerLen += 2; } return parsedNumber; } /** * Parses a number. * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/ * @param {?} num * @return {?} */ function parseNumber(num) { var /** @type {?} */ numStr = Math.abs(num) + ''; 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); var /** @type {?} */ dropTrailingZeros = fractionSize !== 0; // Minimal length = nb of decimals required + current nb of integers // Any number besides that is optional and can be removed if it's a trailing 0 var /** @type {?} */ minLen = minFrac + parsedNumber.integerLen; // 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 ? d : d - 10; // d % 10 if (dropTrailingZeros) { // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52) if (digits[i] === 0 && i >= minLen) { digits.pop(); } else { dropTrailingZeros = false; } } return d >= 10 ? 1 : 0; // 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:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits} * - `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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'number' },] }, ]; /** @nocollapse */ DeprecatedDecimalPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'percent' },] }, ]; /** @nocollapse */ DeprecatedPercentPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'currency' },] }, ]; /** @nocollapse */ DeprecatedCurrencyPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["_4" /* 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 (Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_27" /* ɵisPromise */])(obj)) { return _promiseStrategy; } if (Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_26" /* ɵ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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'async', pure: false },] }, ]; /** @nocollapse */ AsyncPipe.ctorParameters = function () { return [ { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["j" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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:
    * {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits} * - `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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'number' },] }, ]; /** @nocollapse */ DecimalPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'percent' },] }, ]; /** @nocollapse */ PercentPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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 = getCurrencySymbol(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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* Pipe */], args: [{ name: 'currency' },] }, ]; /** @nocollapse */ CurrencyPipe.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["w" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* 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: * *
  • b
  • *
  • c
  • * * ## 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* 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 */ /** * 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["F" /* 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: __WEBPACK_IMPORTED_MODULE_0__angular_core__["F" /* 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 __WEBPACK_IMPORTED_MODULE_0__angular_core__["y" /* 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 */ /** * \@stable */ var VERSION = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["_1" /* Version */]('5.2.9'); /** * @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. */ /** * @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 this package. */ // This file only reexports content of the `src` folder. Keep it that way. /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * Generated bundle index. Do not edit. */ //# sourceMappingURL=common.js.map /***/ }), /***/ "./node_modules/@angular/compiler/esm5/compiler.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* unused harmony export core */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return CompilerConfig; }); /* unused harmony export preserveWhitespacesDefault */ /* unused harmony export isLoweredSymbol */ /* unused harmony export createLoweredSymbol */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return Identifiers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return JitCompiler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return DirectiveResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return PipeResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return NgModuleResolver; }); /* unused harmony export DEFAULT_INTERPOLATION_CONFIG */ /* unused harmony export InterpolationConfig */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return NgModuleCompiler; }); /* unused harmony export AssertNotNull */ /* unused harmony export BinaryOperator */ /* unused harmony export BinaryOperatorExpr */ /* unused harmony export BuiltinMethod */ /* unused harmony export BuiltinVar */ /* unused harmony export CastExpr */ /* unused harmony export ClassStmt */ /* unused harmony export CommaExpr */ /* unused harmony export CommentStmt */ /* unused harmony export ConditionalExpr */ /* unused harmony export DeclareFunctionStmt */ /* unused harmony export DeclareVarStmt */ /* unused harmony export ExpressionStatement */ /* unused harmony export ExternalExpr */ /* unused harmony export ExternalReference */ /* unused harmony export FunctionExpr */ /* unused harmony export IfStmt */ /* unused harmony export InstantiateExpr */ /* unused harmony export InvokeFunctionExpr */ /* unused harmony export InvokeMethodExpr */ /* unused harmony export LiteralArrayExpr */ /* unused harmony export LiteralExpr */ /* unused harmony export LiteralMapExpr */ /* unused harmony export NotExpr */ /* unused harmony export ReadKeyExpr */ /* unused harmony export ReadPropExpr */ /* unused harmony export ReadVarExpr */ /* unused harmony export ReturnStatement */ /* unused harmony export ThrowStmt */ /* unused harmony export TryCatchStmt */ /* unused harmony export WriteKeyExpr */ /* unused harmony export WritePropExpr */ /* unused harmony export WriteVarExpr */ /* unused harmony export StmtModifier */ /* unused harmony export Statement */ /* unused harmony export collectExternalReferences */ /* unused harmony export EmitterVisitorContext */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return ViewCompiler; }); /* unused harmony export getParseErrors */ /* unused harmony export isSyntaxError */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return syntaxError; }); /* unused harmony export Version */ /* unused harmony export VERSION */ /* unused harmony export TextAst */ /* unused harmony export BoundTextAst */ /* unused harmony export AttrAst */ /* unused harmony export BoundElementPropertyAst */ /* unused harmony export BoundEventAst */ /* unused harmony export ReferenceAst */ /* unused harmony export VariableAst */ /* unused harmony export ElementAst */ /* unused harmony export EmbeddedTemplateAst */ /* unused harmony export BoundDirectivePropertyAst */ /* unused harmony export DirectiveAst */ /* unused harmony export ProviderAst */ /* unused harmony export ProviderAstType */ /* unused harmony export NgContentAst */ /* unused harmony export PropertyBindingType */ /* unused harmony export NullTemplateVisitor */ /* unused harmony export RecursiveTemplateAstVisitor */ /* unused harmony export templateVisitAll */ /* unused harmony export identifierName */ /* unused harmony export identifierModuleUrl */ /* unused harmony export viewClassName */ /* unused harmony export rendererTypeName */ /* unused harmony export hostViewClassName */ /* unused harmony export componentFactoryName */ /* unused harmony export CompileSummaryKind */ /* unused harmony export tokenName */ /* unused harmony export tokenReference */ /* unused harmony export CompileStylesheetMetadata */ /* unused harmony export CompileTemplateMetadata */ /* unused harmony export CompileDirectiveMetadata */ /* unused harmony export CompilePipeMetadata */ /* unused harmony export CompileNgModuleMetadata */ /* unused harmony export TransitiveCompileNgModuleMetadata */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return ProviderMeta; }); /* unused harmony export flatten */ /* unused harmony export templateSourceUrl */ /* unused harmony export sharedStylesheetJitUrl */ /* unused harmony export ngModuleJitUrl */ /* unused harmony export templateJitUrl */ /* unused harmony export createAotUrlResolver */ /* unused harmony export createAotCompiler */ /* unused harmony export AotCompiler */ /* unused harmony export analyzeNgModules */ /* unused harmony export analyzeAndValidateNgModules */ /* unused harmony export analyzeFile */ /* unused harmony export mergeAnalyzedFiles */ /* unused harmony export GeneratedFile */ /* unused harmony export toTypeScript */ /* unused harmony export formattedError */ /* unused harmony export isFormattedError */ /* unused harmony export StaticReflector */ /* unused harmony export StaticSymbol */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return StaticSymbolCache; }); /* unused harmony export ResolvedStaticSymbol */ /* unused harmony export StaticSymbolResolver */ /* unused harmony export unescapeIdentifier */ /* unused harmony export unwrapResolvedMetadata */ /* unused harmony export AotSummaryResolver */ /* unused harmony export AstPath */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return SummaryResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return JitSummaryResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return CompileReflector; }); /* unused harmony export createUrlResolverWithoutPackagePrefix */ /* unused harmony export createOfflineCompileUrlResolver */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return UrlResolver; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return getUrlScheme; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return ResourceLoader; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return ElementSchemaRegistry; }); /* unused harmony export Extractor */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return I18NHtmlParser; }); /* unused harmony export MessageBundle */ /* unused harmony export Serializer */ /* unused harmony export Xliff */ /* unused harmony export Xliff2 */ /* unused harmony export Xmb */ /* unused harmony export Xtb */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return DirectiveNormalizer; }); /* unused harmony export ParserError */ /* unused harmony export ParseSpan */ /* unused harmony export AST */ /* unused harmony export Quote */ /* unused harmony export EmptyExpr */ /* unused harmony export ImplicitReceiver */ /* unused harmony export Chain */ /* unused harmony export Conditional */ /* unused harmony export PropertyRead */ /* unused harmony export PropertyWrite */ /* unused harmony export SafePropertyRead */ /* unused harmony export KeyedRead */ /* unused harmony export KeyedWrite */ /* unused harmony export BindingPipe */ /* unused harmony export LiteralPrimitive */ /* unused harmony export LiteralArray */ /* unused harmony export LiteralMap */ /* unused harmony export Interpolation */ /* unused harmony export Binary */ /* unused harmony export PrefixNot */ /* unused harmony export NonNullAssert */ /* unused harmony export MethodCall */ /* unused harmony export SafeMethodCall */ /* unused harmony export FunctionCall */ /* unused harmony export ASTWithSource */ /* unused harmony export TemplateBinding */ /* unused harmony export NullAstVisitor */ /* unused harmony export RecursiveAstVisitor */ /* unused harmony export AstTransformer */ /* unused harmony export visitAstChildren */ /* unused harmony export TokenType */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return Lexer; }); /* unused harmony export Token */ /* unused harmony export EOF */ /* unused harmony export isIdentifier */ /* unused harmony export isQuote */ /* unused harmony export SplitInterpolation */ /* unused harmony export TemplateBindingParseResult */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return Parser; }); /* unused harmony export _ParseAST */ /* unused harmony export ERROR_COMPONENT_TYPE */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CompileMetadataResolver; }); /* unused harmony export Text */ /* unused harmony export Expansion */ /* unused harmony export ExpansionCase */ /* unused harmony export Attribute */ /* unused harmony export Element */ /* unused harmony export Comment */ /* unused harmony export visitAll */ /* unused harmony export RecursiveVisitor */ /* unused harmony export findNode */ /* unused harmony export ParseTreeResult */ /* unused harmony export TreeError */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return HtmlParser; }); /* unused harmony export HtmlTagDefinition */ /* unused harmony export getHtmlTagDefinition */ /* unused harmony export TagContentType */ /* unused harmony export splitNsName */ /* unused harmony export isNgContainer */ /* unused harmony export isNgContent */ /* unused harmony export isNgTemplate */ /* unused harmony export getNsPrefix */ /* unused harmony export mergeNsAndName */ /* unused harmony export NAMED_ENTITIES */ /* unused harmony export NGSP_UNICODE */ /* unused harmony export debugOutputAstAsTypeScript */ /* unused harmony export TypeScriptEmitter */ /* unused harmony export ParseLocation */ /* unused harmony export ParseSourceFile */ /* unused harmony export ParseSourceSpan */ /* unused harmony export ParseErrorLevel */ /* unused harmony export ParseError */ /* unused harmony export typeSourceSpan */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return DomElementSchemaRegistry; }); /* unused harmony export CssSelector */ /* unused harmony export SelectorMatcher */ /* unused harmony export SelectorListContext */ /* unused harmony export SelectorContext */ /* unused harmony export StylesCompileDependency */ /* unused harmony export CompiledStylesheet */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return StyleCompiler; }); /* unused harmony export TemplateParseError */ /* unused harmony export TemplateParseResult */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return TemplateParser; }); /* unused harmony export splitClasses */ /* unused harmony export createElementCssSelector */ /* unused harmony export removeSummaryDuplicates */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_tslib__ = __webpack_require__("./node_modules/tslib/tslib.es6.js"); /** * @license Angular v5.2.9 * (c) 2010-2018 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 */ // Attention: // This file duplicates types and values from @angular/core // so that we are able to make @angular/compiler independent of @angular/core. // This is important to prevent a build cycle, as @angular/core needs to // be compiled with the compiler. /** * @record */ function Inject() { } var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); }); var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc }); }); /** * @record */ function Attribute() { } var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); }); /** * @record */ function Query() { } var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) { if (data === void 0) { data = {}; } return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ selector: selector, first: false, isViewQuery: false, descendants: false }, data)); }); var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) { if (data === void 0) { data = {}; } return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ selector: selector, first: true, isViewQuery: false, descendants: true }, data)); }); var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) { if (data === void 0) { data = {}; } return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ selector: selector, first: false, isViewQuery: true, descendants: true }, data)); }); var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) { return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ selector: selector, first: true, isViewQuery: true, descendants: true }, data)); }); /** * @record */ function Directive() { } var createDirective = makeMetadataFactory('Directive', function (dir) { if (dir === void 0) { dir = {}; } return dir; }); /** * @record */ function Component() { } /** @enum {number} */ var ViewEncapsulation = { Emulated: 0, Native: 1, None: 2, }; ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated"; ViewEncapsulation[ViewEncapsulation.Native] = "Native"; ViewEncapsulation[ViewEncapsulation.None] = "None"; /** @enum {number} */ var ChangeDetectionStrategy = { OnPush: 0, Default: 1, }; ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush"; ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default"; var createComponent = makeMetadataFactory('Component', function (c) { if (c === void 0) { c = {}; } return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ changeDetection: ChangeDetectionStrategy.Default }, c)); }); /** * @record */ function Pipe() { } var createPipe = makeMetadataFactory('Pipe', function (p) { return (Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ pure: true }, p)); }); /** * @record */ function Input() { } var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); /** * @record */ function Output() { } var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); }); /** * @record */ function HostBinding() { } var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); }); /** * @record */ function HostListener() { } var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); }); /** * @record */ function NgModule() { } var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; }); /** * @record */ function ModuleWithProviders() { } /** * @record */ function SchemaMetadata() { } var CUSTOM_ELEMENTS_SCHEMA = { name: 'custom-elements' }; var NO_ERRORS_SCHEMA = { name: 'no-errors-schema' }; var createOptional = makeMetadataFactory('Optional'); var createInjectable = makeMetadataFactory('Injectable'); var createSelf = makeMetadataFactory('Self'); var createSkipSelf = makeMetadataFactory('SkipSelf'); var createHost = makeMetadataFactory('Host'); var Type = Function; /** @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"; /** @enum {number} */ var NodeFlags = { None: 0, TypeElement: 1, TypeText: 2, ProjectedTemplate: 4, CatRenderNode: 3, TypeNgContent: 8, TypePipe: 16, TypePureArray: 32, TypePureObject: 64, TypePurePipe: 128, CatPureExpression: 224, TypeValueProvider: 256, TypeClassProvider: 512, TypeFactoryProvider: 1024, TypeUseExistingProvider: 2048, LazyProvider: 4096, PrivateProvider: 8192, TypeDirective: 16384, Component: 32768, CatProviderNoDirective: 3840, CatProvider: 20224, OnInit: 65536, OnDestroy: 131072, DoCheck: 262144, OnChanges: 524288, AfterContentInit: 1048576, AfterContentChecked: 2097152, AfterViewInit: 4194304, AfterViewChecked: 8388608, EmbeddedViews: 16777216, ComponentView: 33554432, TypeContentQuery: 67108864, TypeViewQuery: 134217728, StaticQuery: 268435456, DynamicQuery: 536870912, CatQuery: 201326592, // mutually exclusive values... Types: 201347067, }; /** @enum {number} */ var DepFlags = { None: 0, SkipSelf: 1, Optional: 2, Value: 8, }; /** @enum {number} */ var ArgumentType = { Inline: 0, Dynamic: 1, }; /** @enum {number} */ var BindingFlags = { TypeElementAttribute: 1, TypeElementClass: 2, TypeElementStyle: 4, TypeProperty: 8, SyntheticProperty: 16, SyntheticHostProperty: 32, CatSyntheticProperty: 48, // mutually exclusive values... Types: 15, }; /** @enum {number} */ var QueryBindingType = { First: 0, All: 1, }; /** @enum {number} */ var QueryValueType = { ElementRef: 0, RenderElement: 1, TemplateRef: 2, ViewContainerRef: 3, Provider: 4, }; /** @enum {number} */ var ViewFlags = { None: 0, OnPush: 2, }; /** @enum {number} */ var MissingTranslationStrategy = { Error: 0, Warning: 1, Ignore: 2, }; MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error"; MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning"; MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore"; /** * @record */ function MetadataFactory() { } /** * @template T * @param {?} name * @param {?=} props * @return {?} */ function makeMetadataFactory(name, props) { var /** @type {?} */ factory = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var /** @type {?} */ values = props ? props.apply(void 0, args) : {}; return Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({ ngMetadataName: name }, values); }; factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; }; factory.ngMetadataName = name; return factory; } /** * @record */ function Route() { } var core = Object.freeze({ Inject: Inject, createInject: createInject, createInjectionToken: createInjectionToken, Attribute: Attribute, createAttribute: createAttribute, Query: Query, createContentChildren: createContentChildren, createContentChild: createContentChild, createViewChildren: createViewChildren, createViewChild: createViewChild, Directive: Directive, createDirective: createDirective, Component: Component, ViewEncapsulation: ViewEncapsulation, ChangeDetectionStrategy: ChangeDetectionStrategy, createComponent: createComponent, Pipe: Pipe, createPipe: createPipe, Input: Input, createInput: createInput, Output: Output, createOutput: createOutput, HostBinding: HostBinding, createHostBinding: createHostBinding, HostListener: HostListener, createHostListener: createHostListener, NgModule: NgModule, createNgModule: createNgModule, ModuleWithProviders: ModuleWithProviders, SchemaMetadata: SchemaMetadata, CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA, createOptional: createOptional, createInjectable: createInjectable, createSelf: createSelf, createSkipSelf: createSkipSelf, createHost: createHost, Type: Type, SecurityContext: SecurityContext, NodeFlags: NodeFlags, DepFlags: DepFlags, ArgumentType: ArgumentType, BindingFlags: BindingFlags, QueryBindingType: QueryBindingType, QueryValueType: QueryValueType, ViewFlags: ViewFlags, MissingTranslationStrategy: MissingTranslationStrategy, MetadataFactory: MetadataFactory, Route: Route }); /** * @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 DASH_CASE_REGEXP = /-+([a-z0-9])/g; /** * @param {?} input * @return {?} */ function dashCaseToCamelCase(input) { return input.replace(DASH_CASE_REGEXP, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } return m[1].toUpperCase(); }); } /** * @param {?} input * @param {?} defaultValues * @return {?} */ function splitAtColon(input, defaultValues) { return _splitAt(input, ':', defaultValues); } /** * @param {?} input * @param {?} defaultValues * @return {?} */ function splitAtPeriod(input, defaultValues) { return _splitAt(input, '.', defaultValues); } /** * @param {?} input * @param {?} character * @param {?} defaultValues * @return {?} */ function _splitAt(input, character, defaultValues) { var /** @type {?} */ characterIndex = input.indexOf(character); if (characterIndex == -1) return defaultValues; return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()]; } /** * @param {?} value * @param {?} visitor * @param {?} context * @return {?} */ function visitValue(value, visitor, context) { if (Array.isArray(value)) { return visitor.visitArray(/** @type {?} */ (value), context); } if (isStrictStringMap(value)) { return visitor.visitStringMap(/** @type {?} */ (value), context); } if (value == null || typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') { return visitor.visitPrimitive(value, context); } return visitor.visitOther(value, context); } /** * @param {?} val * @return {?} */ function isDefined(val) { return val !== null && val !== undefined; } /** * @template T * @param {?} val * @return {?} */ function noUndefined(val) { return val === undefined ? /** @type {?} */ ((null)) : val; } /** * @record */ var ValueTransformer = /** @class */ (function () { function ValueTransformer() { } /** * @param {?} arr * @param {?} context * @return {?} */ ValueTransformer.prototype.visitArray = /** * @param {?} arr * @param {?} context * @return {?} */ function (arr, context) { var _this = this; return arr.map(function (value) { return visitValue(value, _this, context); }); }; /** * @param {?} map * @param {?} context * @return {?} */ ValueTransformer.prototype.visitStringMap = /** * @param {?} map * @param {?} context * @return {?} */ function (map, context) { var _this = this; var /** @type {?} */ result = {}; Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); }); return result; }; /** * @param {?} value * @param {?} context * @return {?} */ ValueTransformer.prototype.visitPrimitive = /** * @param {?} value * @param {?} context * @return {?} */ function (value, context) { return value; }; /** * @param {?} value * @param {?} context * @return {?} */ ValueTransformer.prototype.visitOther = /** * @param {?} value * @param {?} context * @return {?} */ function (value, context) { return value; }; return ValueTransformer; }()); var SyncAsync = { assertSync: function (value) { if (isPromise(value)) { throw new Error("Illegal state: value cannot be a promise"); } return value; }, then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); }, all: function (syncAsyncValues) { return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : /** @type {?} */ (syncAsyncValues); } }; /** * @param {?} msg * @param {?=} parseErrors * @return {?} */ function syntaxError(msg, parseErrors) { var /** @type {?} */ error = Error(msg); (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR] = true; if (parseErrors) (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] = parseErrors; return error; } var ERROR_SYNTAX_ERROR = 'ngSyntaxError'; var ERROR_PARSE_ERRORS = 'ngParseErrors'; /** * @param {?} error * @return {?} */ function isSyntaxError(error) { return (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR]; } /** * @param {?} error * @return {?} */ function getParseErrors(error) { return (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] || []; } /** * @param {?} s * @return {?} */ function escapeRegExp(s) { return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); } var STRING_MAP_PROTO = Object.getPrototypeOf({}); /** * @param {?} obj * @return {?} */ function isStrictStringMap(obj) { return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO; } /** * @param {?} str * @return {?} */ function utf8Encode(str) { var /** @type {?} */ encoded = ''; for (var /** @type {?} */ index = 0; index < str.length; index++) { var /** @type {?} */ codePoint = str.charCodeAt(index); // decode surrogate // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) { var /** @type {?} */ low = str.charCodeAt(index + 1); if (low >= 0xdc00 && low <= 0xdfff) { index++; codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000; } } if (codePoint <= 0x7f) { encoded += String.fromCharCode(codePoint); } else if (codePoint <= 0x7ff) { encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80); } else if (codePoint <= 0xffff) { encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80); } else if (codePoint <= 0x1fffff) { encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80); } } return encoded; } /** * @record */ /** * @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); } /** * Lazily retrieves the reference value from a forwardRef. * @param {?} type * @return {?} */ function resolveForwardRef(type) { if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) { return type(); } else { return type; } } /** * 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'; } var Version = /** @class */ (function () { function Version(full) { this.full = full; var /** @type {?} */ splits = full.split('.'); this.major = splits[0]; this.minor = splits[1]; this.patch = splits.slice(2).join('.'); } return Version; }()); /** * @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 */ /** * \@stable */ var VERSION = new Version('5.2.9'); /** * @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 Abstract Syntax Tree node representing part of a parsed Angular template. * @record */ /** * A segment of text within the template. */ var TextAst = /** @class */ (function () { function TextAst(value, ngContentIndex, sourceSpan) { this.value = value; this.ngContentIndex = ngContentIndex; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ TextAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitText(this, context); }; return TextAst; }()); /** * A bound expression within the text of a template. */ var BoundTextAst = /** @class */ (function () { function BoundTextAst(value, ngContentIndex, sourceSpan) { this.value = value; this.ngContentIndex = ngContentIndex; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ BoundTextAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitBoundText(this, context); }; return BoundTextAst; }()); /** * A plain attribute on an element. */ var AttrAst = /** @class */ (function () { function AttrAst(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ AttrAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitAttr(this, context); }; return AttrAst; }()); /** * A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g. * `[\@trigger]="stateExp"`) */ var BoundElementPropertyAst = /** @class */ (function () { function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) { this.name = name; this.type = type; this.securityContext = securityContext; this.value = value; this.unit = unit; this.sourceSpan = sourceSpan; this.isAnimation = this.type === PropertyBindingType.Animation; } /** * @param {?} visitor * @param {?} context * @return {?} */ BoundElementPropertyAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitElementProperty(this, context); }; return BoundElementPropertyAst; }()); /** * A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g. * `(\@trigger.phase)="callback($event)"`). */ var BoundEventAst = /** @class */ (function () { function BoundEventAst(name, target, phase, handler, sourceSpan) { this.name = name; this.target = target; this.phase = phase; this.handler = handler; this.sourceSpan = sourceSpan; this.fullName = BoundEventAst.calcFullName(this.name, this.target, this.phase); this.isAnimation = !!this.phase; } /** * @param {?} name * @param {?} target * @param {?} phase * @return {?} */ BoundEventAst.calcFullName = /** * @param {?} name * @param {?} target * @param {?} phase * @return {?} */ function (name, target, phase) { if (target) { return target + ":" + name; } else if (phase) { return "@" + name + "." + phase; } else { return name; } }; /** * @param {?} visitor * @param {?} context * @return {?} */ BoundEventAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitEvent(this, context); }; return BoundEventAst; }()); /** * A reference declaration on an element (e.g. `let someName="expression"`). */ var ReferenceAst = /** @class */ (function () { function ReferenceAst(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ ReferenceAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitReference(this, context); }; return ReferenceAst; }()); /** * A variable declaration on a (e.g. `var-someName="someLocalName"`). */ var VariableAst = /** @class */ (function () { function VariableAst(name, value, sourceSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ VariableAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitVariable(this, context); }; return VariableAst; }()); /** * An element declaration in a template. */ var ElementAst = /** @class */ (function () { function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) { this.name = name; this.attrs = attrs; this.inputs = inputs; this.outputs = outputs; this.references = references; this.directives = directives; this.providers = providers; this.hasViewContainer = hasViewContainer; this.queryMatches = queryMatches; this.children = children; this.ngContentIndex = ngContentIndex; this.sourceSpan = sourceSpan; this.endSourceSpan = endSourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ ElementAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitElement(this, context); }; return ElementAst; }()); /** * A `` element included in an Angular template. */ var EmbeddedTemplateAst = /** @class */ (function () { function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) { this.attrs = attrs; this.outputs = outputs; this.references = references; this.variables = variables; this.directives = directives; this.providers = providers; this.hasViewContainer = hasViewContainer; this.queryMatches = queryMatches; this.children = children; this.ngContentIndex = ngContentIndex; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ EmbeddedTemplateAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitEmbeddedTemplate(this, context); }; return EmbeddedTemplateAst; }()); /** * A directive property with a bound value (e.g. `*ngIf="condition"). */ var BoundDirectivePropertyAst = /** @class */ (function () { function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) { this.directiveName = directiveName; this.templateName = templateName; this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ BoundDirectivePropertyAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitDirectiveProperty(this, context); }; return BoundDirectivePropertyAst; }()); /** * A directive declared on an element. */ var DirectiveAst = /** @class */ (function () { function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) { this.directive = directive; this.inputs = inputs; this.hostProperties = hostProperties; this.hostEvents = hostEvents; this.contentQueryStartId = contentQueryStartId; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ DirectiveAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitDirective(this, context); }; return DirectiveAst; }()); /** * A provider declared on an element */ var ProviderAst = /** @class */ (function () { function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) { this.token = token; this.multiProvider = multiProvider; this.eager = eager; this.providers = providers; this.providerType = providerType; this.lifecycleHooks = lifecycleHooks; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ ProviderAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { // No visit method in the visitor for now... return null; }; return ProviderAst; }()); /** @enum {number} */ var ProviderAstType = { PublicService: 0, PrivateService: 1, Component: 2, Directive: 3, Builtin: 4, }; ProviderAstType[ProviderAstType.PublicService] = "PublicService"; ProviderAstType[ProviderAstType.PrivateService] = "PrivateService"; ProviderAstType[ProviderAstType.Component] = "Component"; ProviderAstType[ProviderAstType.Directive] = "Directive"; ProviderAstType[ProviderAstType.Builtin] = "Builtin"; /** * Position where content is to be projected (instance of `` in a template). */ var NgContentAst = /** @class */ (function () { function NgContentAst(index, ngContentIndex, sourceSpan) { this.index = index; this.ngContentIndex = ngContentIndex; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ NgContentAst.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitNgContent(this, context); }; return NgContentAst; }()); /** @enum {number} */ var PropertyBindingType = { /** * A normal binding to a property (e.g. `[property]="expression"`). */ Property: 0, /** * A binding to an element attribute (e.g. `[attr.name]="expression"`). */ Attribute: 1, /** * A binding to a CSS class (e.g. `[class.name]="condition"`). */ Class: 2, /** * A binding to a style rule (e.g. `[style.rule]="expression"`). */ Style: 3, /** * A binding to an animation reference (e.g. `[animate.key]="expression"`). */ Animation: 4, }; PropertyBindingType[PropertyBindingType.Property] = "Property"; PropertyBindingType[PropertyBindingType.Attribute] = "Attribute"; PropertyBindingType[PropertyBindingType.Class] = "Class"; PropertyBindingType[PropertyBindingType.Style] = "Style"; PropertyBindingType[PropertyBindingType.Animation] = "Animation"; /** * @record */ /** * A visitor for {\@link TemplateAst} trees that will process each node. * @record */ /** * A visitor that accepts each node but doesn't do anything. It is intended to be used * as the base class for a visitor that is only interested in a subset of the node types. */ var NullTemplateVisitor = /** @class */ (function () { function NullTemplateVisitor() { } /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitNgContent = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitEmbeddedTemplate = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitElement = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitReference = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitVariable = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitEvent = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitElementProperty = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitAttr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitBoundText = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitText = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitDirective = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullTemplateVisitor.prototype.visitDirectiveProperty = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; return NullTemplateVisitor; }()); /** * Base class that can be used to build a visitor that visits each node * in an template ast recursively. */ var RecursiveTemplateAstVisitor = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(RecursiveTemplateAstVisitor, _super); function RecursiveTemplateAstVisitor() { return _super.call(this) || this; } // Nodes with children /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveTemplateAstVisitor.prototype.visitEmbeddedTemplate = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.attrs); visit(ast.references); visit(ast.variables); visit(ast.directives); visit(ast.providers); visit(ast.children); }); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveTemplateAstVisitor.prototype.visitElement = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.attrs); visit(ast.inputs); visit(ast.outputs); visit(ast.references); visit(ast.directives); visit(ast.providers); visit(ast.children); }); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveTemplateAstVisitor.prototype.visitDirective = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.inputs); visit(ast.hostProperties); visit(ast.hostEvents); }); }; /** * @template T * @param {?} context * @param {?} cb * @return {?} */ RecursiveTemplateAstVisitor.prototype.visitChildren = /** * @template T * @param {?} context * @param {?} cb * @return {?} */ function (context, cb) { var /** @type {?} */ results = []; var /** @type {?} */ t = this; /** * @template T * @param {?} children * @return {?} */ function visit(children) { if (children && children.length) results.push(templateVisitAll(t, children, context)); } cb(visit); return [].concat.apply([], results); }; return RecursiveTemplateAstVisitor; }(NullTemplateVisitor)); /** * Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}. * @param {?} visitor * @param {?} asts * @param {?=} context * @return {?} */ function templateVisitAll(visitor, asts, context) { if (context === void 0) { context = null; } var /** @type {?} */ result = []; var /** @type {?} */ visit = visitor.visit ? function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } : function (ast) { return ast.visit(visitor, context); }; asts.forEach(function (ast) { var /** @type {?} */ astResult = visit(ast); if (astResult) { result.push(astResult); } }); 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 */ var CompilerConfig = /** @class */ (function () { function CompilerConfig(_a) { var _b = _a === void 0 ? {} : _a, _c = _b.defaultEncapsulation, defaultEncapsulation = _c === void 0 ? ViewEncapsulation.Emulated : _c, _d = _b.useJit, useJit = _d === void 0 ? true : _d, _e = _b.jitDevMode, jitDevMode = _e === void 0 ? false : _e, _f = _b.missingTranslation, missingTranslation = _f === void 0 ? null : _f, enableLegacyTemplate = _b.enableLegacyTemplate, preserveWhitespaces = _b.preserveWhitespaces, strictInjectionParameters = _b.strictInjectionParameters; this.defaultEncapsulation = defaultEncapsulation; this.useJit = !!useJit; this.jitDevMode = !!jitDevMode; this.missingTranslation = missingTranslation; this.enableLegacyTemplate = enableLegacyTemplate === true; this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces)); this.strictInjectionParameters = strictInjectionParameters === true; } return CompilerConfig; }()); /** * @param {?} preserveWhitespacesOption * @param {?=} defaultSetting * @return {?} */ function preserveWhitespacesDefault(preserveWhitespacesOption, defaultSetting) { if (defaultSetting === void 0) { defaultSetting = true; } return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption; } /** * @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 token representing the a reference to a static type. * * This token is unique for a filePath and name and can be used as a hash table key. */ var StaticSymbol = /** @class */ (function () { function StaticSymbol(filePath, name, members) { this.filePath = filePath; this.name = name; this.members = members; } /** * @return {?} */ StaticSymbol.prototype.assertNoMembers = /** * @return {?} */ function () { if (this.members.length) { throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + "."); } }; return StaticSymbol; }()); /** * A cache of static symbol used by the StaticReflector to return the same symbol for the * same symbol values. */ var StaticSymbolCache = /** @class */ (function () { function StaticSymbolCache() { this.cache = new Map(); } /** * @param {?} declarationFile * @param {?} name * @param {?=} members * @return {?} */ StaticSymbolCache.prototype.get = /** * @param {?} declarationFile * @param {?} name * @param {?=} members * @return {?} */ function (declarationFile, name, members) { members = members || []; var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : ''; var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix; var /** @type {?} */ result = this.cache.get(key); if (!result) { result = new StaticSymbol(declarationFile, name, members); this.cache.set(key, result); } return result; }; return StaticSymbolCache; }()); /** * @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 */ // group 0: "[prop] or (event) or @trigger" // group 1: "prop" from "[prop]" // group 2: "event" from "(event)" // group 3: "@trigger" from "@trigger" var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/; /** * @param {?} name * @return {?} */ function _sanitizeIdentifier(name) { return name.replace(/\W/g, '_'); } var _anonymousTypeIndex = 0; /** * @param {?} compileIdentifier * @return {?} */ function identifierName(compileIdentifier) { if (!compileIdentifier || !compileIdentifier.reference) { return null; } var /** @type {?} */ ref = compileIdentifier.reference; if (ref instanceof StaticSymbol) { return ref.name; } if (ref['__anonymousType']) { return ref['__anonymousType']; } var /** @type {?} */ identifier = stringify(ref); if (identifier.indexOf('(') >= 0) { // case: anonymous functions! identifier = "anonymous_" + _anonymousTypeIndex++; ref['__anonymousType'] = identifier; } else { identifier = _sanitizeIdentifier(identifier); } return identifier; } /** * @param {?} compileIdentifier * @return {?} */ function identifierModuleUrl(compileIdentifier) { var /** @type {?} */ ref = compileIdentifier.reference; if (ref instanceof StaticSymbol) { return ref.filePath; } // Runtime type return "./" + stringify(ref); } /** * @param {?} compType * @param {?} embeddedTemplateIndex * @return {?} */ function viewClassName(compType, embeddedTemplateIndex) { return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex; } /** * @param {?} compType * @return {?} */ function rendererTypeName(compType) { return "RenderType_" + identifierName({ reference: compType }); } /** * @param {?} compType * @return {?} */ function hostViewClassName(compType) { return "HostView_" + identifierName({ reference: compType }); } /** * @param {?} compType * @return {?} */ function componentFactoryName(compType) { return identifierName({ reference: compType }) + "NgFactory"; } /** * @record */ /** * @record */ /** @enum {number} */ var CompileSummaryKind = { Pipe: 0, Directive: 1, NgModule: 2, Injectable: 3, }; CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe"; CompileSummaryKind[CompileSummaryKind.Directive] = "Directive"; CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule"; CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable"; /** * A CompileSummary is the data needed to use a directive / pipe / module * in other modules / components. However, this data is not enough to compile * the directive / module itself. * @record */ /** * @record */ /** * @record */ /** * @record */ /** * @param {?} token * @return {?} */ function tokenName(token) { return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier); } /** * @param {?} token * @return {?} */ function tokenReference(token) { if (token.identifier != null) { return token.identifier.reference; } else { return token.value; } } /** * @record */ /** * Metadata regarding compilation of a type. * @record */ /** * @record */ /** * Metadata about a stylesheet */ var CompileStylesheetMetadata = /** @class */ (function () { function CompileStylesheetMetadata(_a) { var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls; this.moduleUrl = moduleUrl || null; this.styles = _normalizeArray(styles); this.styleUrls = _normalizeArray(styleUrls); } return CompileStylesheetMetadata; }()); /** * Summary Metadata regarding compilation of a template. * @record */ /** * Metadata regarding compilation of a template. */ var CompileTemplateMetadata = /** @class */ (function () { function CompileTemplateMetadata(_a) { var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, htmlAst = _a.htmlAst, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline, preserveWhitespaces = _a.preserveWhitespaces; this.encapsulation = encapsulation; this.template = template; this.templateUrl = templateUrl; this.htmlAst = htmlAst; this.styles = _normalizeArray(styles); this.styleUrls = _normalizeArray(styleUrls); this.externalStylesheets = _normalizeArray(externalStylesheets); this.animations = animations ? flatten(animations) : []; this.ngContentSelectors = ngContentSelectors || []; if (interpolation && interpolation.length != 2) { throw new Error("'interpolation' should have a start and an end symbol."); } this.interpolation = interpolation; this.isInline = isInline; this.preserveWhitespaces = preserveWhitespaces; } /** * @return {?} */ CompileTemplateMetadata.prototype.toSummary = /** * @return {?} */ function () { return { ngContentSelectors: this.ngContentSelectors, encapsulation: this.encapsulation, }; }; return CompileTemplateMetadata; }()); /** * @record */ /** * @record */ /** * Metadata regarding compilation of a directive. */ var CompileDirectiveMetadata = /** @class */ (function () { function CompileDirectiveMetadata(_a) { var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory; this.isHost = !!isHost; this.type = type; this.isComponent = isComponent; this.selector = selector; this.exportAs = exportAs; this.changeDetection = changeDetection; this.inputs = inputs; this.outputs = outputs; this.hostListeners = hostListeners; this.hostProperties = hostProperties; this.hostAttributes = hostAttributes; this.providers = _normalizeArray(providers); this.viewProviders = _normalizeArray(viewProviders); this.queries = _normalizeArray(queries); this.guards = guards; this.viewQueries = _normalizeArray(viewQueries); this.entryComponents = _normalizeArray(entryComponents); this.template = template; this.componentViewType = componentViewType; this.rendererType = rendererType; this.componentFactory = componentFactory; } /** * @param {?} __0 * @return {?} */ CompileDirectiveMetadata.create = /** * @param {?} __0 * @return {?} */ function (_a) { var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory; var /** @type {?} */ hostListeners = {}; var /** @type {?} */ hostProperties = {}; var /** @type {?} */ hostAttributes = {}; if (host != null) { Object.keys(host).forEach(function (key) { var /** @type {?} */ value = host[key]; var /** @type {?} */ matches = key.match(HOST_REG_EXP); if (matches === null) { hostAttributes[key] = value; } else if (matches[1] != null) { hostProperties[matches[1]] = value; } else if (matches[2] != null) { hostListeners[matches[2]] = value; } }); } var /** @type {?} */ inputsMap = {}; if (inputs != null) { inputs.forEach(function (bindConfig) { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]); inputsMap[parts[0]] = parts[1]; }); } var /** @type {?} */ outputsMap = {}; if (outputs != null) { outputs.forEach(function (bindConfig) { // canonical syntax: `dirProp: elProp` // if there is no `:`, use dirProp = elProp var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]); outputsMap[parts[0]] = parts[1]; }); } return new CompileDirectiveMetadata({ isHost: isHost, type: type, isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection, inputs: inputsMap, outputs: outputsMap, hostListeners: hostListeners, hostProperties: hostProperties, hostAttributes: hostAttributes, providers: providers, viewProviders: viewProviders, queries: queries, guards: guards, viewQueries: viewQueries, entryComponents: entryComponents, template: template, componentViewType: componentViewType, rendererType: rendererType, componentFactory: componentFactory, }); }; /** * @return {?} */ CompileDirectiveMetadata.prototype.toSummary = /** * @return {?} */ function () { return { summaryKind: CompileSummaryKind.Directive, type: this.type, isComponent: this.isComponent, selector: this.selector, exportAs: this.exportAs, inputs: this.inputs, outputs: this.outputs, hostListeners: this.hostListeners, hostProperties: this.hostProperties, hostAttributes: this.hostAttributes, providers: this.providers, viewProviders: this.viewProviders, queries: this.queries, guards: this.guards, viewQueries: this.viewQueries, entryComponents: this.entryComponents, changeDetection: this.changeDetection, template: this.template && this.template.toSummary(), componentViewType: this.componentViewType, rendererType: this.rendererType, componentFactory: this.componentFactory }; }; return CompileDirectiveMetadata; }()); /** * @record */ var CompilePipeMetadata = /** @class */ (function () { function CompilePipeMetadata(_a) { var type = _a.type, name = _a.name, pure = _a.pure; this.type = type; this.name = name; this.pure = !!pure; } /** * @return {?} */ CompilePipeMetadata.prototype.toSummary = /** * @return {?} */ function () { return { summaryKind: CompileSummaryKind.Pipe, type: this.type, name: this.name, pure: this.pure }; }; return CompilePipeMetadata; }()); /** * @record */ /** * Metadata regarding compilation of a module. */ var CompileNgModuleMetadata = /** @class */ (function () { function CompileNgModuleMetadata(_a) { var type = _a.type, providers = _a.providers, declaredDirectives = _a.declaredDirectives, exportedDirectives = _a.exportedDirectives, declaredPipes = _a.declaredPipes, exportedPipes = _a.exportedPipes, entryComponents = _a.entryComponents, bootstrapComponents = _a.bootstrapComponents, importedModules = _a.importedModules, exportedModules = _a.exportedModules, schemas = _a.schemas, transitiveModule = _a.transitiveModule, id = _a.id; this.type = type || null; this.declaredDirectives = _normalizeArray(declaredDirectives); this.exportedDirectives = _normalizeArray(exportedDirectives); this.declaredPipes = _normalizeArray(declaredPipes); this.exportedPipes = _normalizeArray(exportedPipes); this.providers = _normalizeArray(providers); this.entryComponents = _normalizeArray(entryComponents); this.bootstrapComponents = _normalizeArray(bootstrapComponents); this.importedModules = _normalizeArray(importedModules); this.exportedModules = _normalizeArray(exportedModules); this.schemas = _normalizeArray(schemas); this.id = id || null; this.transitiveModule = transitiveModule || null; } /** * @return {?} */ CompileNgModuleMetadata.prototype.toSummary = /** * @return {?} */ function () { var /** @type {?} */ module = /** @type {?} */ ((this.transitiveModule)); return { summaryKind: CompileSummaryKind.NgModule, type: this.type, entryComponents: module.entryComponents, providers: module.providers, modules: module.modules, exportedDirectives: module.exportedDirectives, exportedPipes: module.exportedPipes }; }; return CompileNgModuleMetadata; }()); var TransitiveCompileNgModuleMetadata = /** @class */ (function () { function TransitiveCompileNgModuleMetadata() { this.directivesSet = new Set(); this.directives = []; this.exportedDirectivesSet = new Set(); this.exportedDirectives = []; this.pipesSet = new Set(); this.pipes = []; this.exportedPipesSet = new Set(); this.exportedPipes = []; this.modulesSet = new Set(); this.modules = []; this.entryComponentsSet = new Set(); this.entryComponents = []; this.providers = []; } /** * @param {?} provider * @param {?} module * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addProvider = /** * @param {?} provider * @param {?} module * @return {?} */ function (provider, module) { this.providers.push({ provider: provider, module: module }); }; /** * @param {?} id * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addDirective = /** * @param {?} id * @return {?} */ function (id) { if (!this.directivesSet.has(id.reference)) { this.directivesSet.add(id.reference); this.directives.push(id); } }; /** * @param {?} id * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = /** * @param {?} id * @return {?} */ function (id) { if (!this.exportedDirectivesSet.has(id.reference)) { this.exportedDirectivesSet.add(id.reference); this.exportedDirectives.push(id); } }; /** * @param {?} id * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addPipe = /** * @param {?} id * @return {?} */ function (id) { if (!this.pipesSet.has(id.reference)) { this.pipesSet.add(id.reference); this.pipes.push(id); } }; /** * @param {?} id * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = /** * @param {?} id * @return {?} */ function (id) { if (!this.exportedPipesSet.has(id.reference)) { this.exportedPipesSet.add(id.reference); this.exportedPipes.push(id); } }; /** * @param {?} id * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addModule = /** * @param {?} id * @return {?} */ function (id) { if (!this.modulesSet.has(id.reference)) { this.modulesSet.add(id.reference); this.modules.push(id); } }; /** * @param {?} ec * @return {?} */ TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = /** * @param {?} ec * @return {?} */ function (ec) { if (!this.entryComponentsSet.has(ec.componentType)) { this.entryComponentsSet.add(ec.componentType); this.entryComponents.push(ec); } }; return TransitiveCompileNgModuleMetadata; }()); /** * @param {?} obj * @return {?} */ function _normalizeArray(obj) { return obj || []; } var ProviderMeta = /** @class */ (function () { function ProviderMeta(token, _a) { var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi; this.token = token; this.useClass = useClass || null; this.useValue = useValue; this.useExisting = useExisting; this.useFactory = useFactory || null; this.dependencies = deps || null; this.multi = !!multi; } return ProviderMeta; }()); /** * @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); }, []); } /** * @param {?} url * @return {?} */ function jitSourceUrl(url) { // Note: We need 3 "/" so that ng shows up as a separate domain // in the chrome dev tools. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///'); } /** * @param {?} ngModuleType * @param {?} compMeta * @param {?} templateMeta * @return {?} */ function templateSourceUrl(ngModuleType, compMeta, templateMeta) { var /** @type {?} */ url; if (templateMeta.isInline) { if (compMeta.type.reference instanceof StaticSymbol) { // Note: a .ts file might contain multiple components with inline templates, // so we need to give them unique urls, as these will be used for sourcemaps. url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html"; } else { url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html"; } } else { url = /** @type {?} */ ((templateMeta.templateUrl)); } return compMeta.type.reference instanceof StaticSymbol ? url : jitSourceUrl(url); } /** * @param {?} meta * @param {?} id * @return {?} */ function sharedStylesheetJitUrl(meta, id) { var /** @type {?} */ pathParts = /** @type {?} */ ((meta.moduleUrl)).split(/\/\\/g); var /** @type {?} */ baseName = pathParts[pathParts.length - 1]; return jitSourceUrl("css/" + id + baseName + ".ngstyle.js"); } /** * @param {?} moduleMeta * @return {?} */ function ngModuleJitUrl(moduleMeta) { return jitSourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js"); } /** * @param {?} ngModuleType * @param {?} compMeta * @return {?} */ function templateJitUrl(ngModuleType, compMeta) { return jitSourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js"); } /** * @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 path is an ordered set of elements. Typically a path is to a * particular offset in a source file. The head of the list is the top * most node. The tail is the node that contains the offset directly. * * For example, the expresion `a + b + c` might have an ast that looks * like: * + * / \ * a + * / \ * b c * * The path to the node at offset 9 would be `['+' at 1-10, '+' at 7-10, * 'c' at 9-10]` and the path the node at offset 1 would be * `['+' at 1-10, 'a' at 1-2]`. */ var AstPath = /** @class */ (function () { function AstPath(path, position) { if (position === void 0) { position = -1; } this.path = path; this.position = position; } Object.defineProperty(AstPath.prototype, "empty", { get: /** * @return {?} */ function () { return !this.path || !this.path.length; }, enumerable: true, configurable: true }); Object.defineProperty(AstPath.prototype, "head", { get: /** * @return {?} */ function () { return this.path[0]; }, enumerable: true, configurable: true }); Object.defineProperty(AstPath.prototype, "tail", { get: /** * @return {?} */ function () { return this.path[this.path.length - 1]; }, enumerable: true, configurable: true }); /** * @param {?} node * @return {?} */ AstPath.prototype.parentOf = /** * @param {?} node * @return {?} */ function (node) { return node && this.path[this.path.indexOf(node) - 1]; }; /** * @param {?} node * @return {?} */ AstPath.prototype.childOf = /** * @param {?} node * @return {?} */ function (node) { return this.path[this.path.indexOf(node) + 1]; }; /** * @template N * @param {?} ctor * @return {?} */ AstPath.prototype.first = /** * @template N * @param {?} ctor * @return {?} */ function (ctor) { for (var /** @type {?} */ i = this.path.length - 1; i >= 0; i--) { var /** @type {?} */ item = this.path[i]; if (item instanceof ctor) return /** @type {?} */ (item); } }; /** * @param {?} node * @return {?} */ AstPath.prototype.push = /** * @param {?} node * @return {?} */ function (node) { this.path.push(node); }; /** * @return {?} */ AstPath.prototype.pop = /** * @return {?} */ function () { return /** @type {?} */ ((this.path.pop())); }; return AstPath; }()); /** * @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 */ var Text = /** @class */ (function () { function Text(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ Text.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitText(this, context); }; return Text; }()); var Expansion = /** @class */ (function () { function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan) { this.switchValue = switchValue; this.type = type; this.cases = cases; this.sourceSpan = sourceSpan; this.switchValueSourceSpan = switchValueSourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ Expansion.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitExpansion(this, context); }; return Expansion; }()); var ExpansionCase = /** @class */ (function () { function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) { this.value = value; this.expression = expression; this.sourceSpan = sourceSpan; this.valueSourceSpan = valueSourceSpan; this.expSourceSpan = expSourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ ExpansionCase.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitExpansionCase(this, context); }; return ExpansionCase; }()); var Attribute$1 = /** @class */ (function () { function Attribute(name, value, sourceSpan, valueSpan) { this.name = name; this.value = value; this.sourceSpan = sourceSpan; this.valueSpan = valueSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ Attribute.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitAttribute(this, context); }; return Attribute; }()); var Element = /** @class */ (function () { function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) { if (startSourceSpan === void 0) { startSourceSpan = null; } if (endSourceSpan === void 0) { endSourceSpan = null; } this.name = name; this.attrs = attrs; this.children = children; this.sourceSpan = sourceSpan; this.startSourceSpan = startSourceSpan; this.endSourceSpan = endSourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ Element.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitElement(this, context); }; return Element; }()); var Comment = /** @class */ (function () { function Comment(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?} context * @return {?} */ Comment.prototype.visit = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitComment(this, context); }; return Comment; }()); /** * @record */ /** * @param {?} visitor * @param {?} nodes * @param {?=} context * @return {?} */ function visitAll(visitor, nodes, context) { if (context === void 0) { context = null; } var /** @type {?} */ result = []; var /** @type {?} */ visit = visitor.visit ? function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } : function (ast) { return ast.visit(visitor, context); }; nodes.forEach(function (ast) { var /** @type {?} */ astResult = visit(ast); if (astResult) { result.push(astResult); } }); return result; } var RecursiveVisitor = /** @class */ (function () { function RecursiveVisitor() { } /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitElement = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitChildren(context, function (visit) { visit(ast.attrs); visit(ast.children); }); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitAttribute = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitText = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitComment = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitExpansion = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitChildren(context, function (visit) { visit(ast.cases); }); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveVisitor.prototype.visitExpansionCase = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @template T * @param {?} context * @param {?} cb * @return {?} */ RecursiveVisitor.prototype.visitChildren = /** * @template T * @param {?} context * @param {?} cb * @return {?} */ function (context, cb) { var /** @type {?} */ results = []; var /** @type {?} */ t = this; /** * @template T * @param {?} children * @return {?} */ function visit(children) { if (children) results.push(visitAll(t, children, context)); } cb(visit); return [].concat.apply([], results); }; return RecursiveVisitor; }()); /** * @param {?} ast * @return {?} */ function spanOf(ast) { var /** @type {?} */ start = ast.sourceSpan.start.offset; var /** @type {?} */ end = ast.sourceSpan.end.offset; if (ast instanceof Element) { if (ast.endSourceSpan) { end = ast.endSourceSpan.end.offset; } else if (ast.children && ast.children.length) { end = spanOf(ast.children[ast.children.length - 1]).end; } } return { start: start, end: end }; } /** * @param {?} nodes * @param {?} position * @return {?} */ function findNode(nodes, position) { var /** @type {?} */ path = []; var /** @type {?} */ visitor = new /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} ast * @param {?} context * @return {?} */ class_1.prototype.visit = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var /** @type {?} */ span = spanOf(ast); if (span.start <= position && position < span.end) { path.push(ast); } else { // Returning a value here will result in the children being skipped. return true; } }; return class_1; }(RecursiveVisitor)); visitAll(visitor, nodes); return new AstPath(path, position); } /** * @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 {?} identifier * @param {?} value * @return {?} */ function assertArrayOfStrings(identifier, value) { if (value == null) { return; } if (!Array.isArray(value)) { throw new Error("Expected '" + identifier + "' to be an array of strings."); } for (var /** @type {?} */ i = 0; i < value.length; i += 1) { if (typeof value[i] !== 'string') { throw new Error("Expected '" + identifier + "' to be an array of strings."); } } } var INTERPOLATION_BLACKLIST_REGEXPS = [ /^\s*$/, /[<>]/, /^[{}]$/, /&(#|[a-z])/i, /^\/\//, ]; /** * @param {?} identifier * @param {?} value * @return {?} */ function assertInterpolationSymbols(identifier, value) { if (value != null && !(Array.isArray(value) && value.length == 2)) { throw new Error("Expected '" + identifier + "' to be an array, [start, end]."); } else if (value != null) { var /** @type {?} */ start_1 = /** @type {?} */ (value[0]); var /** @type {?} */ end_1 = /** @type {?} */ (value[1]); // black list checking INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) { if (regexp.test(start_1) || regexp.test(end_1)) { throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation 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 */ var InterpolationConfig = /** @class */ (function () { function InterpolationConfig(start, end) { this.start = start; this.end = end; } /** * @param {?} markers * @return {?} */ InterpolationConfig.fromArray = /** * @param {?} markers * @return {?} */ function (markers) { if (!markers) { return DEFAULT_INTERPOLATION_CONFIG; } assertInterpolationSymbols('interpolation', markers); return new InterpolationConfig(markers[0], markers[1]); }; return InterpolationConfig; }()); var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}'); /** * @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 StyleWithImports = /** @class */ (function () { function StyleWithImports(style, styleUrls) { this.style = style; this.styleUrls = styleUrls; } return StyleWithImports; }()); /** * @param {?} url * @return {?} */ function isStyleUrlResolvable(url) { if (url == null || url.length === 0 || url[0] == '/') return false; var /** @type {?} */ schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP); return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset'; } /** * Rewrites stylesheets by resolving and removing the \@import urls that * are either relative or don't have a `package:` scheme * @param {?} resolver * @param {?} baseUrl * @param {?} cssText * @return {?} */ function extractStyleUrls(resolver, baseUrl, cssText) { var /** @type {?} */ foundUrls = []; var /** @type {?} */ modifiedCssText = cssText.replace(CSS_STRIPPABLE_COMMENT_REGEXP, '') .replace(CSS_IMPORT_REGEXP, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var /** @type {?} */ url = m[1] || m[2]; if (!isStyleUrlResolvable(url)) { // Do not attempt to resolve non-package absolute URLs with URI // scheme return m[0]; } foundUrls.push(resolver.resolve(baseUrl, url)); return ''; }); return new StyleWithImports(modifiedCssText, foundUrls); } var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g; var CSS_STRIPPABLE_COMMENT_REGEXP = /\/\*(?!#\s*(?:sourceURL|sourceMappingURL)=)[\s\S]+?\*\//g; var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/; /** * @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 TagContentType = { RAW_TEXT: 0, ESCAPABLE_RAW_TEXT: 1, PARSABLE_DATA: 2, }; TagContentType[TagContentType.RAW_TEXT] = "RAW_TEXT"; TagContentType[TagContentType.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT"; TagContentType[TagContentType.PARSABLE_DATA] = "PARSABLE_DATA"; /** * @record */ /** * @param {?} elementName * @return {?} */ function splitNsName(elementName) { if (elementName[0] != ':') { return [null, elementName]; } var /** @type {?} */ colonIndex = elementName.indexOf(':', 1); if (colonIndex == -1) { throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\""); } return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)]; } /** * @param {?} tagName * @return {?} */ function isNgContainer(tagName) { return splitNsName(tagName)[1] === 'ng-container'; } /** * @param {?} tagName * @return {?} */ function isNgContent(tagName) { return splitNsName(tagName)[1] === 'ng-content'; } /** * @param {?} tagName * @return {?} */ function isNgTemplate(tagName) { return splitNsName(tagName)[1] === 'ng-template'; } /** * @param {?} fullName * @return {?} */ function getNsPrefix(fullName) { return fullName === null ? null : splitNsName(fullName)[0]; } /** * @param {?} prefix * @param {?} localName * @return {?} */ function mergeNsAndName(prefix, localName) { return prefix ? ":" + prefix + ":" + localName : localName; } // see http://www.w3.org/TR/html51/syntax.html#named-character-references // see https://html.spec.whatwg.org/multipage/entities.json // This list is not exhaustive to keep the compiler footprint low. // The `{` / `ƫ` syntax should be used when the named character reference does not // exist. var NAMED_ENTITIES = { 'Aacute': '\u00C1', 'aacute': '\u00E1', 'Acirc': '\u00C2', 'acirc': '\u00E2', 'acute': '\u00B4', 'AElig': '\u00C6', 'aelig': '\u00E6', 'Agrave': '\u00C0', 'agrave': '\u00E0', 'alefsym': '\u2135', 'Alpha': '\u0391', 'alpha': '\u03B1', 'amp': '&', 'and': '\u2227', 'ang': '\u2220', 'apos': '\u0027', 'Aring': '\u00C5', 'aring': '\u00E5', 'asymp': '\u2248', 'Atilde': '\u00C3', 'atilde': '\u00E3', 'Auml': '\u00C4', 'auml': '\u00E4', 'bdquo': '\u201E', 'Beta': '\u0392', 'beta': '\u03B2', 'brvbar': '\u00A6', 'bull': '\u2022', 'cap': '\u2229', 'Ccedil': '\u00C7', 'ccedil': '\u00E7', 'cedil': '\u00B8', 'cent': '\u00A2', 'Chi': '\u03A7', 'chi': '\u03C7', 'circ': '\u02C6', 'clubs': '\u2663', 'cong': '\u2245', 'copy': '\u00A9', 'crarr': '\u21B5', 'cup': '\u222A', 'curren': '\u00A4', 'dagger': '\u2020', 'Dagger': '\u2021', 'darr': '\u2193', 'dArr': '\u21D3', 'deg': '\u00B0', 'Delta': '\u0394', 'delta': '\u03B4', 'diams': '\u2666', 'divide': '\u00F7', 'Eacute': '\u00C9', 'eacute': '\u00E9', 'Ecirc': '\u00CA', 'ecirc': '\u00EA', 'Egrave': '\u00C8', 'egrave': '\u00E8', 'empty': '\u2205', 'emsp': '\u2003', 'ensp': '\u2002', 'Epsilon': '\u0395', 'epsilon': '\u03B5', 'equiv': '\u2261', 'Eta': '\u0397', 'eta': '\u03B7', 'ETH': '\u00D0', 'eth': '\u00F0', 'Euml': '\u00CB', 'euml': '\u00EB', 'euro': '\u20AC', 'exist': '\u2203', 'fnof': '\u0192', 'forall': '\u2200', 'frac12': '\u00BD', 'frac14': '\u00BC', 'frac34': '\u00BE', 'frasl': '\u2044', 'Gamma': '\u0393', 'gamma': '\u03B3', 'ge': '\u2265', 'gt': '>', 'harr': '\u2194', 'hArr': '\u21D4', 'hearts': '\u2665', 'hellip': '\u2026', 'Iacute': '\u00CD', 'iacute': '\u00ED', 'Icirc': '\u00CE', 'icirc': '\u00EE', 'iexcl': '\u00A1', 'Igrave': '\u00CC', 'igrave': '\u00EC', 'image': '\u2111', 'infin': '\u221E', 'int': '\u222B', 'Iota': '\u0399', 'iota': '\u03B9', 'iquest': '\u00BF', 'isin': '\u2208', 'Iuml': '\u00CF', 'iuml': '\u00EF', 'Kappa': '\u039A', 'kappa': '\u03BA', 'Lambda': '\u039B', 'lambda': '\u03BB', 'lang': '\u27E8', 'laquo': '\u00AB', 'larr': '\u2190', 'lArr': '\u21D0', 'lceil': '\u2308', 'ldquo': '\u201C', 'le': '\u2264', 'lfloor': '\u230A', 'lowast': '\u2217', 'loz': '\u25CA', 'lrm': '\u200E', 'lsaquo': '\u2039', 'lsquo': '\u2018', 'lt': '<', 'macr': '\u00AF', 'mdash': '\u2014', 'micro': '\u00B5', 'middot': '\u00B7', 'minus': '\u2212', 'Mu': '\u039C', 'mu': '\u03BC', 'nabla': '\u2207', 'nbsp': '\u00A0', 'ndash': '\u2013', 'ne': '\u2260', 'ni': '\u220B', 'not': '\u00AC', 'notin': '\u2209', 'nsub': '\u2284', 'Ntilde': '\u00D1', 'ntilde': '\u00F1', 'Nu': '\u039D', 'nu': '\u03BD', 'Oacute': '\u00D3', 'oacute': '\u00F3', 'Ocirc': '\u00D4', 'ocirc': '\u00F4', 'OElig': '\u0152', 'oelig': '\u0153', 'Ograve': '\u00D2', 'ograve': '\u00F2', 'oline': '\u203E', 'Omega': '\u03A9', 'omega': '\u03C9', 'Omicron': '\u039F', 'omicron': '\u03BF', 'oplus': '\u2295', 'or': '\u2228', 'ordf': '\u00AA', 'ordm': '\u00BA', 'Oslash': '\u00D8', 'oslash': '\u00F8', 'Otilde': '\u00D5', 'otilde': '\u00F5', 'otimes': '\u2297', 'Ouml': '\u00D6', 'ouml': '\u00F6', 'para': '\u00B6', 'permil': '\u2030', 'perp': '\u22A5', 'Phi': '\u03A6', 'phi': '\u03C6', 'Pi': '\u03A0', 'pi': '\u03C0', 'piv': '\u03D6', 'plusmn': '\u00B1', 'pound': '\u00A3', 'prime': '\u2032', 'Prime': '\u2033', 'prod': '\u220F', 'prop': '\u221D', 'Psi': '\u03A8', 'psi': '\u03C8', 'quot': '\u0022', 'radic': '\u221A', 'rang': '\u27E9', 'raquo': '\u00BB', 'rarr': '\u2192', 'rArr': '\u21D2', 'rceil': '\u2309', 'rdquo': '\u201D', 'real': '\u211C', 'reg': '\u00AE', 'rfloor': '\u230B', 'Rho': '\u03A1', 'rho': '\u03C1', 'rlm': '\u200F', 'rsaquo': '\u203A', 'rsquo': '\u2019', 'sbquo': '\u201A', 'Scaron': '\u0160', 'scaron': '\u0161', 'sdot': '\u22C5', 'sect': '\u00A7', 'shy': '\u00AD', 'Sigma': '\u03A3', 'sigma': '\u03C3', 'sigmaf': '\u03C2', 'sim': '\u223C', 'spades': '\u2660', 'sub': '\u2282', 'sube': '\u2286', 'sum': '\u2211', 'sup': '\u2283', 'sup1': '\u00B9', 'sup2': '\u00B2', 'sup3': '\u00B3', 'supe': '\u2287', 'szlig': '\u00DF', 'Tau': '\u03A4', 'tau': '\u03C4', 'there4': '\u2234', 'Theta': '\u0398', 'theta': '\u03B8', 'thetasym': '\u03D1', 'thinsp': '\u2009', 'THORN': '\u00DE', 'thorn': '\u00FE', 'tilde': '\u02DC', 'times': '\u00D7', 'trade': '\u2122', 'Uacute': '\u00DA', 'uacute': '\u00FA', 'uarr': '\u2191', 'uArr': '\u21D1', 'Ucirc': '\u00DB', 'ucirc': '\u00FB', 'Ugrave': '\u00D9', 'ugrave': '\u00F9', 'uml': '\u00A8', 'upsih': '\u03D2', 'Upsilon': '\u03A5', 'upsilon': '\u03C5', 'Uuml': '\u00DC', 'uuml': '\u00FC', 'weierp': '\u2118', 'Xi': '\u039E', 'xi': '\u03BE', 'Yacute': '\u00DD', 'yacute': '\u00FD', 'yen': '\u00A5', 'yuml': '\u00FF', 'Yuml': '\u0178', 'Zeta': '\u0396', 'zeta': '\u03B6', 'zwj': '\u200D', 'zwnj': '\u200C', }; // The &ngsp; pseudo-entity is denoting a space. see: // https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart var NGSP_UNICODE = '\uE500'; NAMED_ENTITIES['ngsp'] = NGSP_UNICODE; /** * @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 NG_CONTENT_SELECT_ATTR = 'select'; var LINK_ELEMENT = 'link'; var LINK_STYLE_REL_ATTR = 'rel'; var LINK_STYLE_HREF_ATTR = 'href'; var LINK_STYLE_REL_VALUE = 'stylesheet'; var STYLE_ELEMENT = 'style'; var SCRIPT_ELEMENT = 'script'; var NG_NON_BINDABLE_ATTR = 'ngNonBindable'; var NG_PROJECT_AS = 'ngProjectAs'; /** * @param {?} ast * @return {?} */ function preparseElement(ast) { var /** @type {?} */ selectAttr = /** @type {?} */ ((null)); var /** @type {?} */ hrefAttr = /** @type {?} */ ((null)); var /** @type {?} */ relAttr = /** @type {?} */ ((null)); var /** @type {?} */ nonBindable = false; var /** @type {?} */ projectAs = /** @type {?} */ ((null)); ast.attrs.forEach(function (attr) { var /** @type {?} */ lcAttrName = attr.name.toLowerCase(); if (lcAttrName == NG_CONTENT_SELECT_ATTR) { selectAttr = attr.value; } else if (lcAttrName == LINK_STYLE_HREF_ATTR) { hrefAttr = attr.value; } else if (lcAttrName == LINK_STYLE_REL_ATTR) { relAttr = attr.value; } else if (attr.name == NG_NON_BINDABLE_ATTR) { nonBindable = true; } else if (attr.name == NG_PROJECT_AS) { if (attr.value.length > 0) { projectAs = attr.value; } } }); selectAttr = normalizeNgContentSelect(selectAttr); var /** @type {?} */ nodeName = ast.name.toLowerCase(); var /** @type {?} */ type = PreparsedElementType.OTHER; if (isNgContent(nodeName)) { type = PreparsedElementType.NG_CONTENT; } else if (nodeName == STYLE_ELEMENT) { type = PreparsedElementType.STYLE; } else if (nodeName == SCRIPT_ELEMENT) { type = PreparsedElementType.SCRIPT; } else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) { type = PreparsedElementType.STYLESHEET; } return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs); } /** @enum {number} */ var PreparsedElementType = { NG_CONTENT: 0, STYLE: 1, STYLESHEET: 2, SCRIPT: 3, OTHER: 4, }; PreparsedElementType[PreparsedElementType.NG_CONTENT] = "NG_CONTENT"; PreparsedElementType[PreparsedElementType.STYLE] = "STYLE"; PreparsedElementType[PreparsedElementType.STYLESHEET] = "STYLESHEET"; PreparsedElementType[PreparsedElementType.SCRIPT] = "SCRIPT"; PreparsedElementType[PreparsedElementType.OTHER] = "OTHER"; var PreparsedElement = /** @class */ (function () { function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) { this.type = type; this.selectAttr = selectAttr; this.hrefAttr = hrefAttr; this.nonBindable = nonBindable; this.projectAs = projectAs; } return PreparsedElement; }()); /** * @param {?} selectAttr * @return {?} */ function normalizeNgContentSelect(selectAttr) { if (selectAttr === null || selectAttr.length === 0) { return '*'; } return selectAttr; } /** * @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 */ var DirectiveNormalizer = /** @class */ (function () { function DirectiveNormalizer(_resourceLoader, _urlResolver, _htmlParser, _config) { this._resourceLoader = _resourceLoader; this._urlResolver = _urlResolver; this._htmlParser = _htmlParser; this._config = _config; this._resourceLoaderCache = new Map(); } /** * @return {?} */ DirectiveNormalizer.prototype.clearCache = /** * @return {?} */ function () { this._resourceLoaderCache.clear(); }; /** * @param {?} normalizedDirective * @return {?} */ DirectiveNormalizer.prototype.clearCacheFor = /** * @param {?} normalizedDirective * @return {?} */ function (normalizedDirective) { var _this = this; if (!normalizedDirective.isComponent) { return; } var /** @type {?} */ template = /** @type {?} */ ((normalizedDirective.template)); this._resourceLoaderCache.delete(/** @type {?} */ ((template.templateUrl))); template.externalStylesheets.forEach(function (stylesheet) { _this._resourceLoaderCache.delete(/** @type {?} */ ((stylesheet.moduleUrl))); }); }; /** * @param {?} url * @return {?} */ DirectiveNormalizer.prototype._fetch = /** * @param {?} url * @return {?} */ function (url) { var /** @type {?} */ result = this._resourceLoaderCache.get(url); if (!result) { result = this._resourceLoader.get(url); this._resourceLoaderCache.set(url, result); } return result; }; /** * @param {?} prenormData * @return {?} */ DirectiveNormalizer.prototype.normalizeTemplate = /** * @param {?} prenormData * @return {?} */ function (prenormData) { var _this = this; if (isDefined(prenormData.template)) { if (isDefined(prenormData.templateUrl)) { throw syntaxError("'" + stringify(prenormData.componentType) + "' component cannot define both template and templateUrl"); } if (typeof prenormData.template !== 'string') { throw syntaxError("The template specified for component " + stringify(prenormData.componentType) + " is not a string"); } } else if (isDefined(prenormData.templateUrl)) { if (typeof prenormData.templateUrl !== 'string') { throw syntaxError("The templateUrl specified for component " + stringify(prenormData.componentType) + " is not a string"); } } else { throw syntaxError("No template specified for component " + stringify(prenormData.componentType)); } if (isDefined(prenormData.preserveWhitespaces) && typeof prenormData.preserveWhitespaces !== 'boolean') { throw syntaxError("The preserveWhitespaces option for component " + stringify(prenormData.componentType) + " must be a boolean"); } return SyncAsync.then(this._preParseTemplate(prenormData), function (preparsedTemplate) { return _this._normalizeTemplateMetadata(prenormData, preparsedTemplate); }); }; /** * @param {?} prenomData * @return {?} */ DirectiveNormalizer.prototype._preParseTemplate = /** * @param {?} prenomData * @return {?} */ function (prenomData) { var _this = this; var /** @type {?} */ template; var /** @type {?} */ templateUrl; if (prenomData.template != null) { template = prenomData.template; templateUrl = prenomData.moduleUrl; } else { templateUrl = this._urlResolver.resolve(prenomData.moduleUrl, /** @type {?} */ ((prenomData.templateUrl))); template = this._fetch(templateUrl); } return SyncAsync.then(template, function (template) { return _this._preparseLoadedTemplate(prenomData, template, templateUrl); }); }; /** * @param {?} prenormData * @param {?} template * @param {?} templateAbsUrl * @return {?} */ DirectiveNormalizer.prototype._preparseLoadedTemplate = /** * @param {?} prenormData * @param {?} template * @param {?} templateAbsUrl * @return {?} */ function (prenormData, template, templateAbsUrl) { var /** @type {?} */ isInline = !!prenormData.template; var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((prenormData.interpolation))); var /** @type {?} */ rootNodesAndErrors = this._htmlParser.parse(template, templateSourceUrl({ reference: prenormData.ngModuleType }, { type: { reference: prenormData.componentType } }, { isInline: isInline, templateUrl: templateAbsUrl }), true, interpolationConfig); if (rootNodesAndErrors.errors.length > 0) { var /** @type {?} */ errorString = rootNodesAndErrors.errors.join('\n'); throw syntaxError("Template parse errors:\n" + errorString); } var /** @type {?} */ templateMetadataStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: prenormData.styles, moduleUrl: prenormData.moduleUrl })); var /** @type {?} */ visitor = new TemplatePreparseVisitor(); visitAll(visitor, rootNodesAndErrors.rootNodes); var /** @type {?} */ templateStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: visitor.styles, styleUrls: visitor.styleUrls, moduleUrl: templateAbsUrl })); var /** @type {?} */ styles = templateMetadataStyles.styles.concat(templateStyles.styles); var /** @type {?} */ inlineStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls); var /** @type {?} */ styleUrls = this ._normalizeStylesheet(new CompileStylesheetMetadata({ styleUrls: prenormData.styleUrls, moduleUrl: prenormData.moduleUrl })) .styleUrls; return { template: template, templateUrl: templateAbsUrl, isInline: isInline, htmlAst: rootNodesAndErrors, styles: styles, inlineStyleUrls: inlineStyleUrls, styleUrls: styleUrls, ngContentSelectors: visitor.ngContentSelectors, }; }; /** * @param {?} prenormData * @param {?} preparsedTemplate * @return {?} */ DirectiveNormalizer.prototype._normalizeTemplateMetadata = /** * @param {?} prenormData * @param {?} preparsedTemplate * @return {?} */ function (prenormData, preparsedTemplate) { var _this = this; return SyncAsync.then(this._loadMissingExternalStylesheets(preparsedTemplate.styleUrls.concat(preparsedTemplate.inlineStyleUrls)), function (externalStylesheets) { return _this._normalizeLoadedTemplateMetadata(prenormData, preparsedTemplate, externalStylesheets); }); }; /** * @param {?} prenormData * @param {?} preparsedTemplate * @param {?} stylesheets * @return {?} */ DirectiveNormalizer.prototype._normalizeLoadedTemplateMetadata = /** * @param {?} prenormData * @param {?} preparsedTemplate * @param {?} stylesheets * @return {?} */ function (prenormData, preparsedTemplate, stylesheets) { var _this = this; // Algorithm: // - produce exactly 1 entry per original styleUrl in // CompileTemplateMetadata.externalStylesheets whith all styles inlined // - inline all styles that are referenced by the template into CompileTemplateMetadata.styles. // Reason: be able to determine how many stylesheets there are even without loading // the template nor the stylesheets, so we can create a stub for TypeScript always synchronously // (as resouce loading may be async) var /** @type {?} */ styles = preparsedTemplate.styles.slice(); this._inlineStyles(preparsedTemplate.inlineStyleUrls, stylesheets, styles); var /** @type {?} */ styleUrls = preparsedTemplate.styleUrls; var /** @type {?} */ externalStylesheets = styleUrls.map(function (styleUrl) { var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl))); var /** @type {?} */ styles = stylesheet.styles.slice(); _this._inlineStyles(stylesheet.styleUrls, stylesheets, styles); return new CompileStylesheetMetadata({ moduleUrl: styleUrl, styles: styles }); }); var /** @type {?} */ encapsulation = prenormData.encapsulation; if (encapsulation == null) { encapsulation = this._config.defaultEncapsulation; } if (encapsulation === ViewEncapsulation.Emulated && styles.length === 0 && styleUrls.length === 0) { encapsulation = ViewEncapsulation.None; } return new CompileTemplateMetadata({ encapsulation: encapsulation, template: preparsedTemplate.template, templateUrl: preparsedTemplate.templateUrl, htmlAst: preparsedTemplate.htmlAst, styles: styles, styleUrls: styleUrls, ngContentSelectors: preparsedTemplate.ngContentSelectors, animations: prenormData.animations, interpolation: prenormData.interpolation, isInline: preparsedTemplate.isInline, externalStylesheets: externalStylesheets, preserveWhitespaces: preserveWhitespacesDefault(prenormData.preserveWhitespaces, this._config.preserveWhitespaces), }); }; /** * @param {?} styleUrls * @param {?} stylesheets * @param {?} targetStyles * @return {?} */ DirectiveNormalizer.prototype._inlineStyles = /** * @param {?} styleUrls * @param {?} stylesheets * @param {?} targetStyles * @return {?} */ function (styleUrls, stylesheets, targetStyles) { var _this = this; styleUrls.forEach(function (styleUrl) { var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl))); stylesheet.styles.forEach(function (style) { return targetStyles.push(style); }); _this._inlineStyles(stylesheet.styleUrls, stylesheets, targetStyles); }); }; /** * @param {?} styleUrls * @param {?=} loadedStylesheets * @return {?} */ DirectiveNormalizer.prototype._loadMissingExternalStylesheets = /** * @param {?} styleUrls * @param {?=} loadedStylesheets * @return {?} */ function (styleUrls, loadedStylesheets) { var _this = this; if (loadedStylesheets === void 0) { loadedStylesheets = new Map(); } return SyncAsync.then(SyncAsync.all(styleUrls.filter(function (styleUrl) { return !loadedStylesheets.has(styleUrl); }) .map(function (styleUrl) { return SyncAsync.then(_this._fetch(styleUrl), function (loadedStyle) { var /** @type {?} */ stylesheet = _this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: [loadedStyle], moduleUrl: styleUrl })); loadedStylesheets.set(styleUrl, stylesheet); return _this._loadMissingExternalStylesheets(stylesheet.styleUrls, loadedStylesheets); }); })), function (_) { return loadedStylesheets; }); }; /** * @param {?} stylesheet * @return {?} */ DirectiveNormalizer.prototype._normalizeStylesheet = /** * @param {?} stylesheet * @return {?} */ function (stylesheet) { var _this = this; var /** @type {?} */ moduleUrl = /** @type {?} */ ((stylesheet.moduleUrl)); var /** @type {?} */ allStyleUrls = stylesheet.styleUrls.filter(isStyleUrlResolvable) .map(function (url) { return _this._urlResolver.resolve(moduleUrl, url); }); var /** @type {?} */ allStyles = stylesheet.styles.map(function (style) { var /** @type {?} */ styleWithImports = extractStyleUrls(_this._urlResolver, moduleUrl, style); allStyleUrls.push.apply(allStyleUrls, styleWithImports.styleUrls); return styleWithImports.style; }); return new CompileStylesheetMetadata({ styles: allStyles, styleUrls: allStyleUrls, moduleUrl: moduleUrl }); }; return DirectiveNormalizer; }()); var TemplatePreparseVisitor = /** @class */ (function () { function TemplatePreparseVisitor() { this.ngContentSelectors = []; this.styles = []; this.styleUrls = []; this.ngNonBindableStackCount = 0; } /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitElement = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var /** @type {?} */ preparsedElement = preparseElement(ast); switch (preparsedElement.type) { case PreparsedElementType.NG_CONTENT: if (this.ngNonBindableStackCount === 0) { this.ngContentSelectors.push(preparsedElement.selectAttr); } break; case PreparsedElementType.STYLE: var /** @type {?} */ textContent_1 = ''; ast.children.forEach(function (child) { if (child instanceof Text) { textContent_1 += child.value; } }); this.styles.push(textContent_1); break; case PreparsedElementType.STYLESHEET: this.styleUrls.push(preparsedElement.hrefAttr); break; default: break; } if (preparsedElement.nonBindable) { this.ngNonBindableStackCount++; } visitAll(this, ast.children); if (preparsedElement.nonBindable) { this.ngNonBindableStackCount--; } return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitExpansion = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { visitAll(this, ast.cases); }; /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitExpansionCase = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { visitAll(this, ast.expression); }; /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitComment = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitAttribute = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ TemplatePreparseVisitor.prototype.visitText = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; return TemplatePreparseVisitor; }()); /** * @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 QUERY_METADATA_IDENTIFIERS = [ createViewChild, createViewChildren, createContentChild, createContentChildren, ]; var DirectiveResolver = /** @class */ (function () { function DirectiveResolver(_reflector) { this._reflector = _reflector; } /** * @param {?} type * @return {?} */ DirectiveResolver.prototype.isDirective = /** * @param {?} type * @return {?} */ function (type) { var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type)); return typeMetadata && typeMetadata.some(isDirectiveMetadata); }; /** * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ DirectiveResolver.prototype.resolve = /** * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ function (type, throwIfNotFound) { if (throwIfNotFound === void 0) { throwIfNotFound = true; } var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type)); if (typeMetadata) { var /** @type {?} */ metadata = findLast(typeMetadata, isDirectiveMetadata); if (metadata) { var /** @type {?} */ propertyMetadata = this._reflector.propMetadata(type); var /** @type {?} */ guards = this._reflector.guards(type); return this._mergeWithPropertyMetadata(metadata, propertyMetadata, guards, type); } } if (throwIfNotFound) { throw new Error("No Directive annotation found on " + stringify(type)); } return null; }; /** * @param {?} dm * @param {?} propertyMetadata * @param {?} guards * @param {?} directiveType * @return {?} */ DirectiveResolver.prototype._mergeWithPropertyMetadata = /** * @param {?} dm * @param {?} propertyMetadata * @param {?} guards * @param {?} directiveType * @return {?} */ function (dm, propertyMetadata, guards, directiveType) { var /** @type {?} */ inputs = []; var /** @type {?} */ outputs = []; var /** @type {?} */ host = {}; var /** @type {?} */ queries = {}; Object.keys(propertyMetadata).forEach(function (propName) { var /** @type {?} */ input = findLast(propertyMetadata[propName], function (a) { return createInput.isTypeOf(a); }); if (input) { if (input.bindingPropertyName) { inputs.push(propName + ": " + input.bindingPropertyName); } else { inputs.push(propName); } } var /** @type {?} */ output = findLast(propertyMetadata[propName], function (a) { return createOutput.isTypeOf(a); }); if (output) { if (output.bindingPropertyName) { outputs.push(propName + ": " + output.bindingPropertyName); } else { outputs.push(propName); } } var /** @type {?} */ hostBindings = propertyMetadata[propName].filter(function (a) { return createHostBinding.isTypeOf(a); }); hostBindings.forEach(function (hostBinding) { if (hostBinding.hostPropertyName) { var /** @type {?} */ startWith = hostBinding.hostPropertyName[0]; if (startWith === '(') { throw new Error("@HostBinding can not bind to events. Use @HostListener instead."); } else if (startWith === '[') { throw new Error("@HostBinding parameter should be a property name, 'class.', or 'attr.'."); } host["[" + hostBinding.hostPropertyName + "]"] = propName; } else { host["[" + propName + "]"] = propName; } }); var /** @type {?} */ hostListeners = propertyMetadata[propName].filter(function (a) { return createHostListener.isTypeOf(a); }); hostListeners.forEach(function (hostListener) { var /** @type {?} */ args = hostListener.args || []; host["(" + hostListener.eventName + ")"] = propName + "(" + args.join(',') + ")"; }); var /** @type {?} */ query = findLast(propertyMetadata[propName], function (a) { return QUERY_METADATA_IDENTIFIERS.some(function (i) { return i.isTypeOf(a); }); }); if (query) { queries[propName] = query; } }); return this._merge(dm, inputs, outputs, host, queries, guards, directiveType); }; /** * @param {?} def * @return {?} */ DirectiveResolver.prototype._extractPublicName = /** * @param {?} def * @return {?} */ function (def) { return splitAtColon(def, [/** @type {?} */ ((null)), def])[1].trim(); }; /** * @param {?} bindings * @return {?} */ DirectiveResolver.prototype._dedupeBindings = /** * @param {?} bindings * @return {?} */ function (bindings) { var /** @type {?} */ names = new Set(); var /** @type {?} */ publicNames = new Set(); var /** @type {?} */ reversedResult = []; // go last to first to allow later entries to overwrite previous entries for (var /** @type {?} */ i = bindings.length - 1; i >= 0; i--) { var /** @type {?} */ binding = bindings[i]; var /** @type {?} */ name_1 = this._extractPublicName(binding); publicNames.add(name_1); if (!names.has(name_1)) { names.add(name_1); reversedResult.push(binding); } } return reversedResult.reverse(); }; /** * @param {?} directive * @param {?} inputs * @param {?} outputs * @param {?} host * @param {?} queries * @param {?} guards * @param {?} directiveType * @return {?} */ DirectiveResolver.prototype._merge = /** * @param {?} directive * @param {?} inputs * @param {?} outputs * @param {?} host * @param {?} queries * @param {?} guards * @param {?} directiveType * @return {?} */ function (directive, inputs, outputs, host, queries, guards, directiveType) { var /** @type {?} */ mergedInputs = this._dedupeBindings(directive.inputs ? directive.inputs.concat(inputs) : inputs); var /** @type {?} */ mergedOutputs = this._dedupeBindings(directive.outputs ? directive.outputs.concat(outputs) : outputs); var /** @type {?} */ mergedHost = directive.host ? Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({}, directive.host, host) : host; var /** @type {?} */ mergedQueries = directive.queries ? Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["a" /* __assign */])({}, directive.queries, queries) : queries; if (createComponent.isTypeOf(directive)) { var /** @type {?} */ comp = /** @type {?} */ (directive); return createComponent({ selector: comp.selector, inputs: mergedInputs, outputs: mergedOutputs, host: mergedHost, exportAs: comp.exportAs, moduleId: comp.moduleId, queries: mergedQueries, changeDetection: comp.changeDetection, providers: comp.providers, viewProviders: comp.viewProviders, entryComponents: comp.entryComponents, template: comp.template, templateUrl: comp.templateUrl, styles: comp.styles, styleUrls: comp.styleUrls, encapsulation: comp.encapsulation, animations: comp.animations, interpolation: comp.interpolation, preserveWhitespaces: directive.preserveWhitespaces, }); } else { return createDirective({ selector: directive.selector, inputs: mergedInputs, outputs: mergedOutputs, host: mergedHost, exportAs: directive.exportAs, queries: mergedQueries, providers: directive.providers, guards: guards }); } }; return DirectiveResolver; }()); /** * @param {?} type * @return {?} */ function isDirectiveMetadata(type) { return createDirective.isTypeOf(type) || createComponent.isTypeOf(type); } /** * @template T * @param {?} arr * @param {?} condition * @return {?} */ function findLast(arr, condition) { for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) { if (condition(arr[i])) { return arr[i]; } } 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 */ var $EOF = 0; var $TAB = 9; var $LF = 10; var $VTAB = 11; var $FF = 12; var $CR = 13; var $SPACE = 32; var $BANG = 33; var $DQ = 34; var $HASH = 35; var $$ = 36; var $PERCENT = 37; var $AMPERSAND = 38; var $SQ = 39; var $LPAREN = 40; var $RPAREN = 41; var $STAR = 42; var $PLUS = 43; var $COMMA = 44; var $MINUS = 45; var $PERIOD = 46; var $SLASH = 47; var $COLON = 58; var $SEMICOLON = 59; var $LT = 60; var $EQ = 61; var $GT = 62; var $QUESTION = 63; var $0 = 48; var $9 = 57; var $A = 65; var $E = 69; var $F = 70; var $X = 88; var $Z = 90; var $LBRACKET = 91; var $BACKSLASH = 92; var $RBRACKET = 93; var $CARET = 94; var $_ = 95; var $a = 97; var $e = 101; var $f = 102; var $n = 110; var $r = 114; var $t = 116; var $u = 117; var $v = 118; var $x = 120; var $z = 122; var $LBRACE = 123; var $BAR = 124; var $RBRACE = 125; var $NBSP = 160; var $BT = 96; /** * @param {?} code * @return {?} */ function isWhitespace(code) { return (code >= $TAB && code <= $SPACE) || (code == $NBSP); } /** * @param {?} code * @return {?} */ function isDigit(code) { return $0 <= code && code <= $9; } /** * @param {?} code * @return {?} */ function isAsciiLetter(code) { return code >= $a && code <= $z || code >= $A && code <= $Z; } /** * @param {?} code * @return {?} */ function isAsciiHexDigit(code) { return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code); } /** * @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 TokenType = { Character: 0, Identifier: 1, Keyword: 2, String: 3, Operator: 4, Number: 5, Error: 6, }; TokenType[TokenType.Character] = "Character"; TokenType[TokenType.Identifier] = "Identifier"; TokenType[TokenType.Keyword] = "Keyword"; TokenType[TokenType.String] = "String"; TokenType[TokenType.Operator] = "Operator"; TokenType[TokenType.Number] = "Number"; TokenType[TokenType.Error] = "Error"; var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this']; var Lexer = /** @class */ (function () { function Lexer() { } /** * @param {?} text * @return {?} */ Lexer.prototype.tokenize = /** * @param {?} text * @return {?} */ function (text) { var /** @type {?} */ scanner = new _Scanner(text); var /** @type {?} */ tokens = []; var /** @type {?} */ token = scanner.scanToken(); while (token != null) { tokens.push(token); token = scanner.scanToken(); } return tokens; }; return Lexer; }()); var Token = /** @class */ (function () { function Token(index, type, numValue, strValue) { this.index = index; this.type = type; this.numValue = numValue; this.strValue = strValue; } /** * @param {?} code * @return {?} */ Token.prototype.isCharacter = /** * @param {?} code * @return {?} */ function (code) { return this.type == TokenType.Character && this.numValue == code; }; /** * @return {?} */ Token.prototype.isNumber = /** * @return {?} */ function () { return this.type == TokenType.Number; }; /** * @return {?} */ Token.prototype.isString = /** * @return {?} */ function () { return this.type == TokenType.String; }; /** * @param {?} operater * @return {?} */ Token.prototype.isOperator = /** * @param {?} operater * @return {?} */ function (operater) { return this.type == TokenType.Operator && this.strValue == operater; }; /** * @return {?} */ Token.prototype.isIdentifier = /** * @return {?} */ function () { return this.type == TokenType.Identifier; }; /** * @return {?} */ Token.prototype.isKeyword = /** * @return {?} */ function () { return this.type == TokenType.Keyword; }; /** * @return {?} */ Token.prototype.isKeywordLet = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'let'; }; /** * @return {?} */ Token.prototype.isKeywordAs = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'as'; }; /** * @return {?} */ Token.prototype.isKeywordNull = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'null'; }; /** * @return {?} */ Token.prototype.isKeywordUndefined = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'undefined'; }; /** * @return {?} */ Token.prototype.isKeywordTrue = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'true'; }; /** * @return {?} */ Token.prototype.isKeywordFalse = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'false'; }; /** * @return {?} */ Token.prototype.isKeywordThis = /** * @return {?} */ function () { return this.type == TokenType.Keyword && this.strValue == 'this'; }; /** * @return {?} */ Token.prototype.isError = /** * @return {?} */ function () { return this.type == TokenType.Error; }; /** * @return {?} */ Token.prototype.toNumber = /** * @return {?} */ function () { return this.type == TokenType.Number ? this.numValue : -1; }; /** * @return {?} */ Token.prototype.toString = /** * @return {?} */ function () { switch (this.type) { case TokenType.Character: case TokenType.Identifier: case TokenType.Keyword: case TokenType.Operator: case TokenType.String: case TokenType.Error: return this.strValue; case TokenType.Number: return this.numValue.toString(); default: return null; } }; return Token; }()); /** * @param {?} index * @param {?} code * @return {?} */ function newCharacterToken(index, code) { return new Token(index, TokenType.Character, code, String.fromCharCode(code)); } /** * @param {?} index * @param {?} text * @return {?} */ function newIdentifierToken(index, text) { return new Token(index, TokenType.Identifier, 0, text); } /** * @param {?} index * @param {?} text * @return {?} */ function newKeywordToken(index, text) { return new Token(index, TokenType.Keyword, 0, text); } /** * @param {?} index * @param {?} text * @return {?} */ function newOperatorToken(index, text) { return new Token(index, TokenType.Operator, 0, text); } /** * @param {?} index * @param {?} text * @return {?} */ function newStringToken(index, text) { return new Token(index, TokenType.String, 0, text); } /** * @param {?} index * @param {?} n * @return {?} */ function newNumberToken(index, n) { return new Token(index, TokenType.Number, n, ''); } /** * @param {?} index * @param {?} message * @return {?} */ function newErrorToken(index, message) { return new Token(index, TokenType.Error, 0, message); } var EOF = new Token(-1, TokenType.Character, 0, ''); var _Scanner = /** @class */ (function () { function _Scanner(input) { this.input = input; this.peek = 0; this.index = -1; this.length = input.length; this.advance(); } /** * @return {?} */ _Scanner.prototype.advance = /** * @return {?} */ function () { this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index); }; /** * @return {?} */ _Scanner.prototype.scanToken = /** * @return {?} */ function () { var /** @type {?} */ input = this.input, /** @type {?} */ length = this.length; var /** @type {?} */ peek = this.peek, /** @type {?} */ index = this.index; // Skip whitespace. while (peek <= $SPACE) { if (++index >= length) { peek = $EOF; break; } else { peek = input.charCodeAt(index); } } this.peek = peek; this.index = index; if (index >= length) { return null; } // Handle identifiers and numbers. if (isIdentifierStart(peek)) return this.scanIdentifier(); if (isDigit(peek)) return this.scanNumber(index); var /** @type {?} */ start = index; switch (peek) { case $PERIOD: this.advance(); return isDigit(this.peek) ? this.scanNumber(start) : newCharacterToken(start, $PERIOD); case $LPAREN: case $RPAREN: case $LBRACE: case $RBRACE: case $LBRACKET: case $RBRACKET: case $COMMA: case $COLON: case $SEMICOLON: return this.scanCharacter(start, peek); case $SQ: case $DQ: return this.scanString(); case $HASH: case $PLUS: case $MINUS: case $STAR: case $SLASH: case $PERCENT: case $CARET: return this.scanOperator(start, String.fromCharCode(peek)); case $QUESTION: return this.scanComplexOperator(start, '?', $PERIOD, '.'); case $LT: case $GT: return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '='); case $BANG: case $EQ: return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '='); case $AMPERSAND: return this.scanComplexOperator(start, '&', $AMPERSAND, '&'); case $BAR: return this.scanComplexOperator(start, '|', $BAR, '|'); case $NBSP: while (isWhitespace(this.peek)) this.advance(); return this.scanToken(); } this.advance(); return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0); }; /** * @param {?} start * @param {?} code * @return {?} */ _Scanner.prototype.scanCharacter = /** * @param {?} start * @param {?} code * @return {?} */ function (start, code) { this.advance(); return newCharacterToken(start, code); }; /** * @param {?} start * @param {?} str * @return {?} */ _Scanner.prototype.scanOperator = /** * @param {?} start * @param {?} str * @return {?} */ function (start, str) { this.advance(); return newOperatorToken(start, str); }; /** * Tokenize a 2/3 char long operator * * @param start start index in the expression * @param one first symbol (always part of the operator) * @param twoCode code point for the second symbol * @param two second symbol (part of the operator when the second code point matches) * @param threeCode code point for the third symbol * @param three third symbol (part of the operator when provided and matches source expression) */ /** * Tokenize a 2/3 char long operator * * @param {?} start start index in the expression * @param {?} one first symbol (always part of the operator) * @param {?} twoCode code point for the second symbol * @param {?} two second symbol (part of the operator when the second code point matches) * @param {?=} threeCode code point for the third symbol * @param {?=} three third symbol (part of the operator when provided and matches source expression) * @return {?} */ _Scanner.prototype.scanComplexOperator = /** * Tokenize a 2/3 char long operator * * @param {?} start start index in the expression * @param {?} one first symbol (always part of the operator) * @param {?} twoCode code point for the second symbol * @param {?} two second symbol (part of the operator when the second code point matches) * @param {?=} threeCode code point for the third symbol * @param {?=} three third symbol (part of the operator when provided and matches source expression) * @return {?} */ function (start, one, twoCode, two, threeCode, three) { this.advance(); var /** @type {?} */ str = one; if (this.peek == twoCode) { this.advance(); str += two; } if (threeCode != null && this.peek == threeCode) { this.advance(); str += three; } return newOperatorToken(start, str); }; /** * @return {?} */ _Scanner.prototype.scanIdentifier = /** * @return {?} */ function () { var /** @type {?} */ start = this.index; this.advance(); while (isIdentifierPart(this.peek)) this.advance(); var /** @type {?} */ str = this.input.substring(start, this.index); return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) : newIdentifierToken(start, str); }; /** * @param {?} start * @return {?} */ _Scanner.prototype.scanNumber = /** * @param {?} start * @return {?} */ function (start) { var /** @type {?} */ simple = (this.index === start); this.advance(); // Skip initial digit. while (true) { if (isDigit(this.peek)) { // Do nothing. } else if (this.peek == $PERIOD) { simple = false; } else if (isExponentStart(this.peek)) { this.advance(); if (isExponentSign(this.peek)) this.advance(); if (!isDigit(this.peek)) return this.error('Invalid exponent', -1); simple = false; } else { break; } this.advance(); } var /** @type {?} */ str = this.input.substring(start, this.index); var /** @type {?} */ value = simple ? parseIntAutoRadix(str) : parseFloat(str); return newNumberToken(start, value); }; /** * @return {?} */ _Scanner.prototype.scanString = /** * @return {?} */ function () { var /** @type {?} */ start = this.index; var /** @type {?} */ quote = this.peek; this.advance(); // Skip initial quote. var /** @type {?} */ buffer = ''; var /** @type {?} */ marker = this.index; var /** @type {?} */ input = this.input; while (this.peek != quote) { if (this.peek == $BACKSLASH) { buffer += input.substring(marker, this.index); this.advance(); var /** @type {?} */ unescapedCode = void 0; // Workaround for TS2.1-introduced type strictness this.peek = this.peek; if (this.peek == $u) { // 4 character hex code for unicode character. var /** @type {?} */ hex = input.substring(this.index + 1, this.index + 5); if (/^[0-9a-f]+$/i.test(hex)) { unescapedCode = parseInt(hex, 16); } else { return this.error("Invalid unicode escape [\\u" + hex + "]", 0); } for (var /** @type {?} */ i = 0; i < 5; i++) { this.advance(); } } else { unescapedCode = unescape(this.peek); this.advance(); } buffer += String.fromCharCode(unescapedCode); marker = this.index; } else if (this.peek == $EOF) { return this.error('Unterminated quote', 0); } else { this.advance(); } } var /** @type {?} */ last = input.substring(marker, this.index); this.advance(); // Skip terminating quote. return newStringToken(start, buffer + last); }; /** * @param {?} message * @param {?} offset * @return {?} */ _Scanner.prototype.error = /** * @param {?} message * @param {?} offset * @return {?} */ function (message, offset) { var /** @type {?} */ position = this.index + offset; return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]"); }; return _Scanner; }()); /** * @param {?} code * @return {?} */ function isIdentifierStart(code) { return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || (code == $_) || (code == $$); } /** * @param {?} input * @return {?} */ function isIdentifier(input) { if (input.length == 0) return false; var /** @type {?} */ scanner = new _Scanner(input); if (!isIdentifierStart(scanner.peek)) return false; scanner.advance(); while (scanner.peek !== $EOF) { if (!isIdentifierPart(scanner.peek)) return false; scanner.advance(); } return true; } /** * @param {?} code * @return {?} */ function isIdentifierPart(code) { return isAsciiLetter(code) || isDigit(code) || (code == $_) || (code == $$); } /** * @param {?} code * @return {?} */ function isExponentStart(code) { return code == $e || code == $E; } /** * @param {?} code * @return {?} */ function isExponentSign(code) { return code == $MINUS || code == $PLUS; } /** * @param {?} code * @return {?} */ function isQuote(code) { return code === $SQ || code === $DQ || code === $BT; } /** * @param {?} code * @return {?} */ function unescape(code) { switch (code) { case $n: return $LF; case $f: return $FF; case $r: return $CR; case $t: return $TAB; case $v: return $VTAB; default: return code; } } /** * @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 */ var ParserError = /** @class */ (function () { function ParserError(message, input, errLocation, ctxLocation) { this.input = input; this.errLocation = errLocation; this.ctxLocation = ctxLocation; this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation; } return ParserError; }()); var ParseSpan = /** @class */ (function () { function ParseSpan(start, end) { this.start = start; this.end = end; } return ParseSpan; }()); var AST = /** @class */ (function () { function AST(span) { this.span = span; } /** * @param {?} visitor * @param {?=} context * @return {?} */ AST.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return null; }; /** * @return {?} */ AST.prototype.toString = /** * @return {?} */ function () { return 'AST'; }; return AST; }()); /** * Represents a quoted expression of the form: * * quote = prefix `:` uninterpretedExpression * prefix = identifier * uninterpretedExpression = arbitrary string * * A quoted expression is meant to be pre-processed by an AST transformer that * converts it into another AST that no longer contains quoted expressions. * It is meant to allow third-party developers to extend Angular template * expression language. The `uninterpretedExpression` part of the quote is * therefore not interpreted by the Angular's own expression parser. */ var Quote = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Quote, _super); function Quote(span, prefix, uninterpretedExpression, location) { var _this = _super.call(this, span) || this; _this.prefix = prefix; _this.uninterpretedExpression = uninterpretedExpression; _this.location = location; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Quote.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitQuote(this, context); }; /** * @return {?} */ Quote.prototype.toString = /** * @return {?} */ function () { return 'Quote'; }; return Quote; }(AST)); var EmptyExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(EmptyExpr, _super); function EmptyExpr() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ EmptyExpr.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } // do nothing }; return EmptyExpr; }(AST)); var ImplicitReceiver = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ImplicitReceiver, _super); function ImplicitReceiver() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ ImplicitReceiver.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitImplicitReceiver(this, context); }; return ImplicitReceiver; }(AST)); /** * Multiple expressions separated by a semicolon. */ var Chain = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Chain, _super); function Chain(span, expressions) { var _this = _super.call(this, span) || this; _this.expressions = expressions; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Chain.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitChain(this, context); }; return Chain; }(AST)); var Conditional = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Conditional, _super); function Conditional(span, condition, trueExp, falseExp) { var _this = _super.call(this, span) || this; _this.condition = condition; _this.trueExp = trueExp; _this.falseExp = falseExp; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Conditional.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitConditional(this, context); }; return Conditional; }(AST)); var PropertyRead = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(PropertyRead, _super); function PropertyRead(span, receiver, name) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ PropertyRead.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPropertyRead(this, context); }; return PropertyRead; }(AST)); var PropertyWrite = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(PropertyWrite, _super); function PropertyWrite(span, receiver, name, value) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.value = value; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ PropertyWrite.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPropertyWrite(this, context); }; return PropertyWrite; }(AST)); var SafePropertyRead = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(SafePropertyRead, _super); function SafePropertyRead(span, receiver, name) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ SafePropertyRead.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitSafePropertyRead(this, context); }; return SafePropertyRead; }(AST)); var KeyedRead = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(KeyedRead, _super); function KeyedRead(span, obj, key) { var _this = _super.call(this, span) || this; _this.obj = obj; _this.key = key; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ KeyedRead.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitKeyedRead(this, context); }; return KeyedRead; }(AST)); var KeyedWrite = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(KeyedWrite, _super); function KeyedWrite(span, obj, key, value) { var _this = _super.call(this, span) || this; _this.obj = obj; _this.key = key; _this.value = value; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ KeyedWrite.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitKeyedWrite(this, context); }; return KeyedWrite; }(AST)); var BindingPipe = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(BindingPipe, _super); function BindingPipe(span, exp, name, args) { var _this = _super.call(this, span) || this; _this.exp = exp; _this.name = name; _this.args = args; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ BindingPipe.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPipe(this, context); }; return BindingPipe; }(AST)); var LiteralPrimitive = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralPrimitive, _super); function LiteralPrimitive(span, value) { var _this = _super.call(this, span) || this; _this.value = value; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ LiteralPrimitive.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralPrimitive(this, context); }; return LiteralPrimitive; }(AST)); var LiteralArray = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralArray, _super); function LiteralArray(span, expressions) { var _this = _super.call(this, span) || this; _this.expressions = expressions; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ LiteralArray.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralArray(this, context); }; return LiteralArray; }(AST)); var LiteralMap = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralMap, _super); function LiteralMap(span, keys, values) { var _this = _super.call(this, span) || this; _this.keys = keys; _this.values = values; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ LiteralMap.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitLiteralMap(this, context); }; return LiteralMap; }(AST)); var Interpolation = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Interpolation, _super); function Interpolation(span, strings, expressions) { var _this = _super.call(this, span) || this; _this.strings = strings; _this.expressions = expressions; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Interpolation.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitInterpolation(this, context); }; return Interpolation; }(AST)); var Binary = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Binary, _super); function Binary(span, operation, left, right) { var _this = _super.call(this, span) || this; _this.operation = operation; _this.left = left; _this.right = right; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Binary.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitBinary(this, context); }; return Binary; }(AST)); var PrefixNot = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(PrefixNot, _super); function PrefixNot(span, expression) { var _this = _super.call(this, span) || this; _this.expression = expression; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ PrefixNot.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitPrefixNot(this, context); }; return PrefixNot; }(AST)); var NonNullAssert = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(NonNullAssert, _super); function NonNullAssert(span, expression) { var _this = _super.call(this, span) || this; _this.expression = expression; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ NonNullAssert.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitNonNullAssert(this, context); }; return NonNullAssert; }(AST)); var MethodCall = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(MethodCall, _super); function MethodCall(span, receiver, name, args) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.args = args; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ MethodCall.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitMethodCall(this, context); }; return MethodCall; }(AST)); var SafeMethodCall = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(SafeMethodCall, _super); function SafeMethodCall(span, receiver, name, args) { var _this = _super.call(this, span) || this; _this.receiver = receiver; _this.name = name; _this.args = args; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ SafeMethodCall.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitSafeMethodCall(this, context); }; return SafeMethodCall; }(AST)); var FunctionCall = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(FunctionCall, _super); function FunctionCall(span, target, args) { var _this = _super.call(this, span) || this; _this.target = target; _this.args = args; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ FunctionCall.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return visitor.visitFunctionCall(this, context); }; return FunctionCall; }(AST)); var ASTWithSource = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ASTWithSource, _super); function ASTWithSource(ast, source, location, errors) { var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this; _this.ast = ast; _this.source = source; _this.location = location; _this.errors = errors; return _this; } /** * @param {?} visitor * @param {?=} context * @return {?} */ ASTWithSource.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { if (context === void 0) { context = null; } return this.ast.visit(visitor, context); }; /** * @return {?} */ ASTWithSource.prototype.toString = /** * @return {?} */ function () { return this.source + " in " + this.location; }; return ASTWithSource; }(AST)); var TemplateBinding = /** @class */ (function () { function TemplateBinding(span, key, keyIsVar, name, expression) { this.span = span; this.key = key; this.keyIsVar = keyIsVar; this.name = name; this.expression = expression; } return TemplateBinding; }()); /** * @record */ var NullAstVisitor = /** @class */ (function () { function NullAstVisitor() { } /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitBinary = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitChain = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitConditional = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitFunctionCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitImplicitReceiver = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitInterpolation = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitKeyedRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitKeyedWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitLiteralArray = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitLiteralMap = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitLiteralPrimitive = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitPipe = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitPrefixNot = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitNonNullAssert = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitPropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitPropertyWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitQuote = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitSafeMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ NullAstVisitor.prototype.visitSafePropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; return NullAstVisitor; }()); var RecursiveAstVisitor = /** @class */ (function () { function RecursiveAstVisitor() { } /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitBinary = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.left.visit(this); ast.right.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitChain = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitAll(ast.expressions, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitConditional = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.condition.visit(this); ast.trueExp.visit(this); ast.falseExp.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitPipe = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.exp.visit(this); this.visitAll(ast.args, context); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitFunctionCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { /** @type {?} */ ((ast.target)).visit(this); this.visitAll(ast.args, context); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitImplicitReceiver = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitInterpolation = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitAll(ast.expressions, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitKeyedRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.obj.visit(this); ast.key.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitKeyedWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.obj.visit(this); ast.key.visit(this); ast.value.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralArray = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitAll(ast.expressions, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralMap = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitAll(ast.values, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralPrimitive = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visit(this); return this.visitAll(ast.args, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitPrefixNot = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.expression.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitNonNullAssert = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.expression.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitPropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitPropertyWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visit(this); ast.value.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitSafePropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visit(this); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitSafeMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visit(this); return this.visitAll(ast.args, context); }; /** * @param {?} asts * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitAll = /** * @param {?} asts * @param {?} context * @return {?} */ function (asts, context) { var _this = this; asts.forEach(function (ast) { return ast.visit(_this, context); }); return null; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitQuote = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return null; }; return RecursiveAstVisitor; }()); var AstTransformer = /** @class */ (function () { function AstTransformer() { } /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitImplicitReceiver = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return ast; }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitInterpolation = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralPrimitive = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new LiteralPrimitive(ast.span, ast.value); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitPropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitPropertyWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitSafePropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitSafeMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitFunctionCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new FunctionCall(ast.span, /** @type {?} */ ((ast.target)).visit(this), this.visitAll(ast.args)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralArray = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new LiteralArray(ast.span, this.visitAll(ast.expressions)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralMap = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitBinary = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitPrefixNot = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new PrefixNot(ast.span, ast.expression.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitNonNullAssert = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new NonNullAssert(ast.span, ast.expression.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitConditional = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitPipe = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitKeyedRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitKeyedWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this)); }; /** * @param {?} asts * @return {?} */ AstTransformer.prototype.visitAll = /** * @param {?} asts * @return {?} */ function (asts) { var /** @type {?} */ res = new Array(asts.length); for (var /** @type {?} */ i = 0; i < asts.length; ++i) { res[i] = asts[i].visit(this); } return res; }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitChain = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new Chain(ast.span, this.visitAll(ast.expressions)); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitQuote = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location); }; return AstTransformer; }()); /** * @param {?} ast * @param {?} visitor * @param {?=} context * @return {?} */ function visitAstChildren(ast, visitor, context) { /** * @param {?} ast * @return {?} */ function visit(ast) { visitor.visit && visitor.visit(ast, context) || ast.visit(visitor, context); } /** * @template T * @param {?} asts * @return {?} */ function visitAll(asts) { asts.forEach(visit); } ast.visit({ visitBinary: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.left); visit(ast.right); }, visitChain: /** * @param {?} ast * @return {?} */ function (ast) { visitAll(ast.expressions); }, visitConditional: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.condition); visit(ast.trueExp); visit(ast.falseExp); }, visitFunctionCall: /** * @param {?} ast * @return {?} */ function (ast) { if (ast.target) { visit(ast.target); } visitAll(ast.args); }, visitImplicitReceiver: /** * @param {?} ast * @return {?} */ function (ast) { }, visitInterpolation: /** * @param {?} ast * @return {?} */ function (ast) { visitAll(ast.expressions); }, visitKeyedRead: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.obj); visit(ast.key); }, visitKeyedWrite: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.obj); visit(ast.key); visit(ast.obj); }, visitLiteralArray: /** * @param {?} ast * @return {?} */ function (ast) { visitAll(ast.expressions); }, visitLiteralMap: /** * @param {?} ast * @return {?} */ function (ast) { }, visitLiteralPrimitive: /** * @param {?} ast * @return {?} */ function (ast) { }, visitMethodCall: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.receiver); visitAll(ast.args); }, visitPipe: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.exp); visitAll(ast.args); }, visitPrefixNot: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.expression); }, visitNonNullAssert: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.expression); }, visitPropertyRead: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.receiver); }, visitPropertyWrite: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.receiver); visit(ast.value); }, visitQuote: /** * @param {?} ast * @return {?} */ function (ast) { }, visitSafeMethodCall: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.receiver); visitAll(ast.args); }, visitSafePropertyRead: /** * @param {?} ast * @return {?} */ function (ast) { visit(ast.receiver); }, }); } /** * @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 SplitInterpolation = /** @class */ (function () { function SplitInterpolation(strings, expressions, offsets) { this.strings = strings; this.expressions = expressions; this.offsets = offsets; } return SplitInterpolation; }()); var TemplateBindingParseResult = /** @class */ (function () { function TemplateBindingParseResult(templateBindings, warnings, errors) { this.templateBindings = templateBindings; this.warnings = warnings; this.errors = errors; } return TemplateBindingParseResult; }()); /** * @param {?} config * @return {?} */ function _createInterpolateRegExp(config) { var /** @type {?} */ pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end); return new RegExp(pattern, 'g'); } var Parser = /** @class */ (function () { function Parser(_lexer) { this._lexer = _lexer; this.errors = []; } /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.parseAction = /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } this._checkNoInterpolation(input, location, interpolationConfig); var /** @type {?} */ sourceToLex = this._stripComments(input); var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(input)); var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length) .parseChain(); return new ASTWithSource(ast, input, location, this.errors); }; /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.parseBinding = /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig); return new ASTWithSource(ast, input, location, this.errors); }; /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.parseSimpleBinding = /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig); var /** @type {?} */ errors = SimpleExpressionChecker.check(ast); if (errors.length > 0) { this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location); } return new ASTWithSource(ast, input, location, this.errors); }; /** * @param {?} message * @param {?} input * @param {?} errLocation * @param {?=} ctxLocation * @return {?} */ Parser.prototype._reportError = /** * @param {?} message * @param {?} input * @param {?} errLocation * @param {?=} ctxLocation * @return {?} */ function (message, input, errLocation, ctxLocation) { this.errors.push(new ParserError(message, input, errLocation, ctxLocation)); }; /** * @param {?} input * @param {?} location * @param {?} interpolationConfig * @return {?} */ Parser.prototype._parseBindingAst = /** * @param {?} input * @param {?} location * @param {?} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { // Quotes expressions use 3rd-party expression language. We don't want to use // our lexer or parser for that, so we check for that ahead of time. var /** @type {?} */ quote = this._parseQuote(input, location); if (quote != null) { return quote; } this._checkNoInterpolation(input, location, interpolationConfig); var /** @type {?} */ sourceToLex = this._stripComments(input); var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex); return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length) .parseChain(); }; /** * @param {?} input * @param {?} location * @return {?} */ Parser.prototype._parseQuote = /** * @param {?} input * @param {?} location * @return {?} */ function (input, location) { if (input == null) return null; var /** @type {?} */ prefixSeparatorIndex = input.indexOf(':'); if (prefixSeparatorIndex == -1) return null; var /** @type {?} */ prefix = input.substring(0, prefixSeparatorIndex).trim(); if (!isIdentifier(prefix)) return null; var /** @type {?} */ uninterpretedExpression = input.substring(prefixSeparatorIndex + 1); return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location); }; /** * @param {?} prefixToken * @param {?} input * @param {?} location * @return {?} */ Parser.prototype.parseTemplateBindings = /** * @param {?} prefixToken * @param {?} input * @param {?} location * @return {?} */ function (prefixToken, input, location) { var /** @type {?} */ tokens = this._lexer.tokenize(input); if (prefixToken) { // Prefix the tokens with the tokens from prefixToken but have them take no space (0 index). var /** @type {?} */ prefixTokens = this._lexer.tokenize(prefixToken).map(function (t) { t.index = 0; return t; }); tokens.unshift.apply(tokens, prefixTokens); } return new _ParseAST(input, location, tokens, input.length, false, this.errors, 0) .parseTemplateBindings(); }; /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.parseInterpolation = /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ split = this.splitInterpolation(input, location, interpolationConfig); if (split == null) return null; var /** @type {?} */ expressions = []; for (var /** @type {?} */ i = 0; i < split.expressions.length; ++i) { var /** @type {?} */ expressionText = split.expressions[i]; var /** @type {?} */ sourceToLex = this._stripComments(expressionText); var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex); var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length)) .parseChain(); expressions.push(ast); } return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors); }; /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.splitInterpolation = /** * @param {?} input * @param {?} location * @param {?=} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig); var /** @type {?} */ parts = input.split(regexp); if (parts.length <= 1) { return null; } var /** @type {?} */ strings = []; var /** @type {?} */ expressions = []; var /** @type {?} */ offsets = []; var /** @type {?} */ offset = 0; for (var /** @type {?} */ i = 0; i < parts.length; i++) { var /** @type {?} */ part = parts[i]; if (i % 2 === 0) { // fixed string strings.push(part); offset += part.length; } else if (part.trim().length > 0) { offset += interpolationConfig.start.length; expressions.push(part); offsets.push(offset); offset += part.length + interpolationConfig.end.length; } else { this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location); expressions.push('$implict'); offsets.push(offset); } } return new SplitInterpolation(strings, expressions, offsets); }; /** * @param {?} input * @param {?} location * @return {?} */ Parser.prototype.wrapLiteralPrimitive = /** * @param {?} input * @param {?} location * @return {?} */ function (input, location) { return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors); }; /** * @param {?} input * @return {?} */ Parser.prototype._stripComments = /** * @param {?} input * @return {?} */ function (input) { var /** @type {?} */ i = this._commentStart(input); return i != null ? input.substring(0, i).trim() : input; }; /** * @param {?} input * @return {?} */ Parser.prototype._commentStart = /** * @param {?} input * @return {?} */ function (input) { var /** @type {?} */ outerQuote = null; for (var /** @type {?} */ i = 0; i < input.length - 1; i++) { var /** @type {?} */ char = input.charCodeAt(i); var /** @type {?} */ nextChar = input.charCodeAt(i + 1); if (char === $SLASH && nextChar == $SLASH && outerQuote == null) return i; if (outerQuote === char) { outerQuote = null; } else if (outerQuote == null && isQuote(char)) { outerQuote = char; } } return null; }; /** * @param {?} input * @param {?} location * @param {?} interpolationConfig * @return {?} */ Parser.prototype._checkNoInterpolation = /** * @param {?} input * @param {?} location * @param {?} interpolationConfig * @return {?} */ function (input, location, interpolationConfig) { var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig); var /** @type {?} */ parts = input.split(regexp); if (parts.length > 1) { this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location); } }; /** * @param {?} parts * @param {?} partInErrIdx * @param {?} interpolationConfig * @return {?} */ Parser.prototype._findInterpolationErrorColumn = /** * @param {?} parts * @param {?} partInErrIdx * @param {?} interpolationConfig * @return {?} */ function (parts, partInErrIdx, interpolationConfig) { var /** @type {?} */ errLocation = ''; for (var /** @type {?} */ j = 0; j < partInErrIdx; j++) { errLocation += j % 2 === 0 ? parts[j] : "" + interpolationConfig.start + parts[j] + interpolationConfig.end; } return errLocation.length; }; return Parser; }()); var _ParseAST = /** @class */ (function () { function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) { this.input = input; this.location = location; this.tokens = tokens; this.inputLength = inputLength; this.parseAction = parseAction; this.errors = errors; this.offset = offset; this.rparensExpected = 0; this.rbracketsExpected = 0; this.rbracesExpected = 0; this.index = 0; } /** * @param {?} offset * @return {?} */ _ParseAST.prototype.peek = /** * @param {?} offset * @return {?} */ function (offset) { var /** @type {?} */ i = this.index + offset; return i < this.tokens.length ? this.tokens[i] : EOF; }; Object.defineProperty(_ParseAST.prototype, "next", { get: /** * @return {?} */ function () { return this.peek(0); }, enumerable: true, configurable: true }); Object.defineProperty(_ParseAST.prototype, "inputIndex", { get: /** * @return {?} */ function () { return (this.index < this.tokens.length) ? this.next.index + this.offset : this.inputLength + this.offset; }, enumerable: true, configurable: true }); /** * @param {?} start * @return {?} */ _ParseAST.prototype.span = /** * @param {?} start * @return {?} */ function (start) { return new ParseSpan(start, this.inputIndex); }; /** * @return {?} */ _ParseAST.prototype.advance = /** * @return {?} */ function () { this.index++; }; /** * @param {?} code * @return {?} */ _ParseAST.prototype.optionalCharacter = /** * @param {?} code * @return {?} */ function (code) { if (this.next.isCharacter(code)) { this.advance(); return true; } else { return false; } }; /** * @return {?} */ _ParseAST.prototype.peekKeywordLet = /** * @return {?} */ function () { return this.next.isKeywordLet(); }; /** * @return {?} */ _ParseAST.prototype.peekKeywordAs = /** * @return {?} */ function () { return this.next.isKeywordAs(); }; /** * @param {?} code * @return {?} */ _ParseAST.prototype.expectCharacter = /** * @param {?} code * @return {?} */ function (code) { if (this.optionalCharacter(code)) return; this.error("Missing expected " + String.fromCharCode(code)); }; /** * @param {?} op * @return {?} */ _ParseAST.prototype.optionalOperator = /** * @param {?} op * @return {?} */ function (op) { if (this.next.isOperator(op)) { this.advance(); return true; } else { return false; } }; /** * @param {?} operator * @return {?} */ _ParseAST.prototype.expectOperator = /** * @param {?} operator * @return {?} */ function (operator) { if (this.optionalOperator(operator)) return; this.error("Missing expected operator " + operator); }; /** * @return {?} */ _ParseAST.prototype.expectIdentifierOrKeyword = /** * @return {?} */ function () { var /** @type {?} */ n = this.next; if (!n.isIdentifier() && !n.isKeyword()) { this.error("Unexpected token " + n + ", expected identifier or keyword"); return ''; } this.advance(); return /** @type {?} */ (n.toString()); }; /** * @return {?} */ _ParseAST.prototype.expectIdentifierOrKeywordOrString = /** * @return {?} */ function () { var /** @type {?} */ n = this.next; if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) { this.error("Unexpected token " + n + ", expected identifier, keyword, or string"); return ''; } this.advance(); return /** @type {?} */ (n.toString()); }; /** * @return {?} */ _ParseAST.prototype.parseChain = /** * @return {?} */ function () { var /** @type {?} */ exprs = []; var /** @type {?} */ start = this.inputIndex; while (this.index < this.tokens.length) { var /** @type {?} */ expr = this.parsePipe(); exprs.push(expr); if (this.optionalCharacter($SEMICOLON)) { if (!this.parseAction) { this.error('Binding expression cannot contain chained expression'); } while (this.optionalCharacter($SEMICOLON)) { } // read all semicolons } else if (this.index < this.tokens.length) { this.error("Unexpected token '" + this.next + "'"); } } if (exprs.length == 0) return new EmptyExpr(this.span(start)); if (exprs.length == 1) return exprs[0]; return new Chain(this.span(start), exprs); }; /** * @return {?} */ _ParseAST.prototype.parsePipe = /** * @return {?} */ function () { var /** @type {?} */ result = this.parseExpression(); if (this.optionalOperator('|')) { if (this.parseAction) { this.error('Cannot have a pipe in an action expression'); } do { var /** @type {?} */ name_1 = this.expectIdentifierOrKeyword(); var /** @type {?} */ args = []; while (this.optionalCharacter($COLON)) { args.push(this.parseExpression()); } result = new BindingPipe(this.span(result.span.start), result, name_1, args); } while (this.optionalOperator('|')); } return result; }; /** * @return {?} */ _ParseAST.prototype.parseExpression = /** * @return {?} */ function () { return this.parseConditional(); }; /** * @return {?} */ _ParseAST.prototype.parseConditional = /** * @return {?} */ function () { var /** @type {?} */ start = this.inputIndex; var /** @type {?} */ result = this.parseLogicalOr(); if (this.optionalOperator('?')) { var /** @type {?} */ yes = this.parsePipe(); var /** @type {?} */ no = void 0; if (!this.optionalCharacter($COLON)) { var /** @type {?} */ end = this.inputIndex; var /** @type {?} */ expression = this.input.substring(start, end); this.error("Conditional expression " + expression + " requires all 3 expressions"); no = new EmptyExpr(this.span(start)); } else { no = this.parsePipe(); } return new Conditional(this.span(start), result, yes, no); } else { return result; } }; /** * @return {?} */ _ParseAST.prototype.parseLogicalOr = /** * @return {?} */ function () { // '||' var /** @type {?} */ result = this.parseLogicalAnd(); while (this.optionalOperator('||')) { var /** @type {?} */ right = this.parseLogicalAnd(); result = new Binary(this.span(result.span.start), '||', result, right); } return result; }; /** * @return {?} */ _ParseAST.prototype.parseLogicalAnd = /** * @return {?} */ function () { // '&&' var /** @type {?} */ result = this.parseEquality(); while (this.optionalOperator('&&')) { var /** @type {?} */ right = this.parseEquality(); result = new Binary(this.span(result.span.start), '&&', result, right); } return result; }; /** * @return {?} */ _ParseAST.prototype.parseEquality = /** * @return {?} */ function () { // '==','!=','===','!==' var /** @type {?} */ result = this.parseRelational(); while (this.next.type == TokenType.Operator) { var /** @type {?} */ operator = this.next.strValue; switch (operator) { case '==': case '===': case '!=': case '!==': this.advance(); var /** @type {?} */ right = this.parseRelational(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; /** * @return {?} */ _ParseAST.prototype.parseRelational = /** * @return {?} */ function () { // '<', '>', '<=', '>=' var /** @type {?} */ result = this.parseAdditive(); while (this.next.type == TokenType.Operator) { var /** @type {?} */ operator = this.next.strValue; switch (operator) { case '<': case '>': case '<=': case '>=': this.advance(); var /** @type {?} */ right = this.parseAdditive(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; /** * @return {?} */ _ParseAST.prototype.parseAdditive = /** * @return {?} */ function () { // '+', '-' var /** @type {?} */ result = this.parseMultiplicative(); while (this.next.type == TokenType.Operator) { var /** @type {?} */ operator = this.next.strValue; switch (operator) { case '+': case '-': this.advance(); var /** @type {?} */ right = this.parseMultiplicative(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; /** * @return {?} */ _ParseAST.prototype.parseMultiplicative = /** * @return {?} */ function () { // '*', '%', '/' var /** @type {?} */ result = this.parsePrefix(); while (this.next.type == TokenType.Operator) { var /** @type {?} */ operator = this.next.strValue; switch (operator) { case '*': case '%': case '/': this.advance(); var /** @type {?} */ right = this.parsePrefix(); result = new Binary(this.span(result.span.start), operator, result, right); continue; } break; } return result; }; /** * @return {?} */ _ParseAST.prototype.parsePrefix = /** * @return {?} */ function () { if (this.next.type == TokenType.Operator) { var /** @type {?} */ start = this.inputIndex; var /** @type {?} */ operator = this.next.strValue; var /** @type {?} */ result = void 0; switch (operator) { case '+': this.advance(); result = this.parsePrefix(); return new Binary(this.span(start), '-', result, new LiteralPrimitive(new ParseSpan(start, start), 0)); case '-': this.advance(); result = this.parsePrefix(); return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result); case '!': this.advance(); result = this.parsePrefix(); return new PrefixNot(this.span(start), result); } } return this.parseCallChain(); }; /** * @return {?} */ _ParseAST.prototype.parseCallChain = /** * @return {?} */ function () { var /** @type {?} */ result = this.parsePrimary(); while (true) { if (this.optionalCharacter($PERIOD)) { result = this.parseAccessMemberOrMethodCall(result, false); } else if (this.optionalOperator('?.')) { result = this.parseAccessMemberOrMethodCall(result, true); } else if (this.optionalCharacter($LBRACKET)) { this.rbracketsExpected++; var /** @type {?} */ key = this.parsePipe(); this.rbracketsExpected--; this.expectCharacter($RBRACKET); if (this.optionalOperator('=')) { var /** @type {?} */ value = this.parseConditional(); result = new KeyedWrite(this.span(result.span.start), result, key, value); } else { result = new KeyedRead(this.span(result.span.start), result, key); } } else if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var /** @type {?} */ args = this.parseCallArguments(); this.rparensExpected--; this.expectCharacter($RPAREN); result = new FunctionCall(this.span(result.span.start), result, args); } else if (this.optionalOperator('!')) { result = new NonNullAssert(this.span(result.span.start), result); } else { return result; } } }; /** * @return {?} */ _ParseAST.prototype.parsePrimary = /** * @return {?} */ function () { var /** @type {?} */ start = this.inputIndex; if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var /** @type {?} */ result = this.parsePipe(); this.rparensExpected--; this.expectCharacter($RPAREN); return result; } else if (this.next.isKeywordNull()) { this.advance(); return new LiteralPrimitive(this.span(start), null); } else if (this.next.isKeywordUndefined()) { this.advance(); return new LiteralPrimitive(this.span(start), void 0); } else if (this.next.isKeywordTrue()) { this.advance(); return new LiteralPrimitive(this.span(start), true); } else if (this.next.isKeywordFalse()) { this.advance(); return new LiteralPrimitive(this.span(start), false); } else if (this.next.isKeywordThis()) { this.advance(); return new ImplicitReceiver(this.span(start)); } else if (this.optionalCharacter($LBRACKET)) { this.rbracketsExpected++; var /** @type {?} */ elements = this.parseExpressionList($RBRACKET); this.rbracketsExpected--; this.expectCharacter($RBRACKET); return new LiteralArray(this.span(start), elements); } else if (this.next.isCharacter($LBRACE)) { return this.parseLiteralMap(); } else if (this.next.isIdentifier()) { return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false); } else if (this.next.isNumber()) { var /** @type {?} */ value = this.next.toNumber(); this.advance(); return new LiteralPrimitive(this.span(start), value); } else if (this.next.isString()) { var /** @type {?} */ literalValue = this.next.toString(); this.advance(); return new LiteralPrimitive(this.span(start), literalValue); } else if (this.index >= this.tokens.length) { this.error("Unexpected end of expression: " + this.input); return new EmptyExpr(this.span(start)); } else { this.error("Unexpected token " + this.next); return new EmptyExpr(this.span(start)); } }; /** * @param {?} terminator * @return {?} */ _ParseAST.prototype.parseExpressionList = /** * @param {?} terminator * @return {?} */ function (terminator) { var /** @type {?} */ result = []; if (!this.next.isCharacter(terminator)) { do { result.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); } return result; }; /** * @return {?} */ _ParseAST.prototype.parseLiteralMap = /** * @return {?} */ function () { var /** @type {?} */ keys = []; var /** @type {?} */ values = []; var /** @type {?} */ start = this.inputIndex; this.expectCharacter($LBRACE); if (!this.optionalCharacter($RBRACE)) { this.rbracesExpected++; do { var /** @type {?} */ quoted = this.next.isString(); var /** @type {?} */ key = this.expectIdentifierOrKeywordOrString(); keys.push({ key: key, quoted: quoted }); this.expectCharacter($COLON); values.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); this.rbracesExpected--; this.expectCharacter($RBRACE); } return new LiteralMap(this.span(start), keys, values); }; /** * @param {?} receiver * @param {?=} isSafe * @return {?} */ _ParseAST.prototype.parseAccessMemberOrMethodCall = /** * @param {?} receiver * @param {?=} isSafe * @return {?} */ function (receiver, isSafe) { if (isSafe === void 0) { isSafe = false; } var /** @type {?} */ start = receiver.span.start; var /** @type {?} */ id = this.expectIdentifierOrKeyword(); if (this.optionalCharacter($LPAREN)) { this.rparensExpected++; var /** @type {?} */ args = this.parseCallArguments(); this.expectCharacter($RPAREN); this.rparensExpected--; var /** @type {?} */ span = this.span(start); return isSafe ? new SafeMethodCall(span, receiver, id, args) : new MethodCall(span, receiver, id, args); } else { if (isSafe) { if (this.optionalOperator('=')) { this.error('The \'?.\' operator cannot be used in the assignment'); return new EmptyExpr(this.span(start)); } else { return new SafePropertyRead(this.span(start), receiver, id); } } else { if (this.optionalOperator('=')) { if (!this.parseAction) { this.error('Bindings cannot contain assignments'); return new EmptyExpr(this.span(start)); } var /** @type {?} */ value = this.parseConditional(); return new PropertyWrite(this.span(start), receiver, id, value); } else { return new PropertyRead(this.span(start), receiver, id); } } } }; /** * @return {?} */ _ParseAST.prototype.parseCallArguments = /** * @return {?} */ function () { if (this.next.isCharacter($RPAREN)) return []; var /** @type {?} */ positionals = []; do { positionals.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); return /** @type {?} */ (positionals); }; /** * An identifier, a keyword, a string with an optional `-` inbetween. */ /** * An identifier, a keyword, a string with an optional `-` inbetween. * @return {?} */ _ParseAST.prototype.expectTemplateBindingKey = /** * An identifier, a keyword, a string with an optional `-` inbetween. * @return {?} */ function () { var /** @type {?} */ result = ''; var /** @type {?} */ operatorFound = false; do { result += this.expectIdentifierOrKeywordOrString(); operatorFound = this.optionalOperator('-'); if (operatorFound) { result += '-'; } } while (operatorFound); return result.toString(); }; /** * @return {?} */ _ParseAST.prototype.parseTemplateBindings = /** * @return {?} */ function () { var /** @type {?} */ bindings = []; var /** @type {?} */ prefix = /** @type {?} */ ((null)); var /** @type {?} */ warnings = []; while (this.index < this.tokens.length) { var /** @type {?} */ start = this.inputIndex; var /** @type {?} */ keyIsVar = this.peekKeywordLet(); if (keyIsVar) { this.advance(); } var /** @type {?} */ rawKey = this.expectTemplateBindingKey(); var /** @type {?} */ key = rawKey; if (!keyIsVar) { if (prefix == null) { prefix = key; } else { key = prefix + key[0].toUpperCase() + key.substring(1); } } this.optionalCharacter($COLON); var /** @type {?} */ name_2 = /** @type {?} */ ((null)); var /** @type {?} */ expression = /** @type {?} */ ((null)); if (keyIsVar) { if (this.optionalOperator('=')) { name_2 = this.expectTemplateBindingKey(); } else { name_2 = '\$implicit'; } } else if (this.peekKeywordAs()) { var /** @type {?} */ letStart = this.inputIndex; this.advance(); // consume `as` name_2 = rawKey; key = this.expectTemplateBindingKey(); // read local var name keyIsVar = true; } else if (this.next !== EOF && !this.peekKeywordLet()) { var /** @type {?} */ start_1 = this.inputIndex; var /** @type {?} */ ast = this.parsePipe(); var /** @type {?} */ source = this.input.substring(start_1 - this.offset, this.inputIndex - this.offset); expression = new ASTWithSource(ast, source, this.location, this.errors); } bindings.push(new TemplateBinding(this.span(start), key, keyIsVar, name_2, expression)); if (this.peekKeywordAs() && !keyIsVar) { var /** @type {?} */ letStart = this.inputIndex; this.advance(); // consume `as` var /** @type {?} */ letName = this.expectTemplateBindingKey(); // read local var name bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, /** @type {?} */ ((null)))); } if (!this.optionalCharacter($SEMICOLON)) { this.optionalCharacter($COMMA); } } return new TemplateBindingParseResult(bindings, warnings, this.errors); }; /** * @param {?} message * @param {?=} index * @return {?} */ _ParseAST.prototype.error = /** * @param {?} message * @param {?=} index * @return {?} */ function (message, index) { if (index === void 0) { index = null; } this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location)); this.skip(); }; /** * @param {?=} index * @return {?} */ _ParseAST.prototype.locationText = /** * @param {?=} index * @return {?} */ function (index) { if (index === void 0) { index = null; } if (index == null) index = this.index; return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" : "at the end of the expression"; }; /** * @return {?} */ _ParseAST.prototype.skip = /** * @return {?} */ function () { var /** @type {?} */ n = this.next; while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) && (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) && (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) && (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) { if (this.next.isError()) { this.errors.push(new ParserError(/** @type {?} */ ((this.next.toString())), this.input, this.locationText(), this.location)); } this.advance(); n = this.next; } }; return _ParseAST; }()); var SimpleExpressionChecker = /** @class */ (function () { function SimpleExpressionChecker() { this.errors = []; } /** * @param {?} ast * @return {?} */ SimpleExpressionChecker.check = /** * @param {?} ast * @return {?} */ function (ast) { var /** @type {?} */ s = new SimpleExpressionChecker(); ast.visit(s); return s.errors; }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitImplicitReceiver = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitInterpolation = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitLiteralPrimitive = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitPropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitPropertyWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitSafePropertyRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitSafeMethodCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitFunctionCall = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitLiteralArray = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitAll(ast.expressions); }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitLiteralMap = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitAll(ast.values); }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitBinary = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitPrefixNot = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitNonNullAssert = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitConditional = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitPipe = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.errors.push('pipes'); }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitKeyedRead = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitKeyedWrite = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} asts * @return {?} */ SimpleExpressionChecker.prototype.visitAll = /** * @param {?} asts * @return {?} */ function (asts) { var _this = this; return asts.map(function (node) { return node.visit(_this); }); }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitChain = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; /** * @param {?} ast * @param {?} context * @return {?} */ SimpleExpressionChecker.prototype.visitQuote = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { }; return SimpleExpressionChecker; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ParseLocation = /** @class */ (function () { function ParseLocation(file, offset, line, col) { this.file = file; this.offset = offset; this.line = line; this.col = col; } /** * @return {?} */ ParseLocation.prototype.toString = /** * @return {?} */ function () { return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url; }; /** * @param {?} delta * @return {?} */ ParseLocation.prototype.moveBy = /** * @param {?} delta * @return {?} */ function (delta) { var /** @type {?} */ source = this.file.content; var /** @type {?} */ len = source.length; var /** @type {?} */ offset = this.offset; var /** @type {?} */ line = this.line; var /** @type {?} */ col = this.col; while (offset > 0 && delta < 0) { offset--; delta++; var /** @type {?} */ ch = source.charCodeAt(offset); if (ch == $LF) { line--; var /** @type {?} */ priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF)); col = priorLine > 0 ? offset - priorLine : offset; } else { col--; } } while (offset < len && delta > 0) { var /** @type {?} */ ch = source.charCodeAt(offset); offset++; delta--; if (ch == $LF) { line++; col = 0; } else { col++; } } return new ParseLocation(this.file, offset, line, col); }; // Return the source around the location // Up to `maxChars` or `maxLines` on each side of the location /** * @param {?} maxChars * @param {?} maxLines * @return {?} */ ParseLocation.prototype.getContext = /** * @param {?} maxChars * @param {?} maxLines * @return {?} */ function (maxChars, maxLines) { var /** @type {?} */ content = this.file.content; var /** @type {?} */ startOffset = this.offset; if (startOffset != null) { if (startOffset > content.length - 1) { startOffset = content.length - 1; } var /** @type {?} */ endOffset = startOffset; var /** @type {?} */ ctxChars = 0; var /** @type {?} */ ctxLines = 0; while (ctxChars < maxChars && startOffset > 0) { startOffset--; ctxChars++; if (content[startOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } ctxChars = 0; ctxLines = 0; while (ctxChars < maxChars && endOffset < content.length - 1) { endOffset++; ctxChars++; if (content[endOffset] == '\n') { if (++ctxLines == maxLines) { break; } } } return { before: content.substring(startOffset, this.offset), after: content.substring(this.offset, endOffset + 1), }; } return null; }; return ParseLocation; }()); var ParseSourceFile = /** @class */ (function () { function ParseSourceFile(content, url) { this.content = content; this.url = url; } return ParseSourceFile; }()); var ParseSourceSpan = /** @class */ (function () { function ParseSourceSpan(start, end, details) { if (details === void 0) { details = null; } this.start = start; this.end = end; this.details = details; } /** * @return {?} */ ParseSourceSpan.prototype.toString = /** * @return {?} */ function () { return this.start.file.content.substring(this.start.offset, this.end.offset); }; return ParseSourceSpan; }()); /** @enum {number} */ var ParseErrorLevel = { WARNING: 0, ERROR: 1, }; ParseErrorLevel[ParseErrorLevel.WARNING] = "WARNING"; ParseErrorLevel[ParseErrorLevel.ERROR] = "ERROR"; var ParseError = /** @class */ (function () { function ParseError(span, msg, level) { if (level === void 0) { level = ParseErrorLevel.ERROR; } this.span = span; this.msg = msg; this.level = level; } /** * @return {?} */ ParseError.prototype.contextualMessage = /** * @return {?} */ function () { var /** @type {?} */ ctx = this.span.start.getContext(100, 3); return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" : this.msg; }; /** * @return {?} */ ParseError.prototype.toString = /** * @return {?} */ function () { var /** @type {?} */ details = this.span.details ? ", " + this.span.details : ''; return this.contextualMessage() + ": " + this.span.start + details; }; return ParseError; }()); /** * @param {?} kind * @param {?} type * @return {?} */ function typeSourceSpan(kind, type) { var /** @type {?} */ moduleUrl = identifierModuleUrl(type); var /** @type {?} */ sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl : "in " + kind + " " + identifierName(type); var /** @type {?} */ sourceFile = new ParseSourceFile('', sourceFileName); return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -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 */ /** @enum {number} */ var TokenType$1 = { TAG_OPEN_START: 0, TAG_OPEN_END: 1, TAG_OPEN_END_VOID: 2, TAG_CLOSE: 3, TEXT: 4, ESCAPABLE_RAW_TEXT: 5, RAW_TEXT: 6, COMMENT_START: 7, COMMENT_END: 8, CDATA_START: 9, CDATA_END: 10, ATTR_NAME: 11, ATTR_VALUE: 12, DOC_TYPE: 13, EXPANSION_FORM_START: 14, EXPANSION_CASE_VALUE: 15, EXPANSION_CASE_EXP_START: 16, EXPANSION_CASE_EXP_END: 17, EXPANSION_FORM_END: 18, EOF: 19, }; TokenType$1[TokenType$1.TAG_OPEN_START] = "TAG_OPEN_START"; TokenType$1[TokenType$1.TAG_OPEN_END] = "TAG_OPEN_END"; TokenType$1[TokenType$1.TAG_OPEN_END_VOID] = "TAG_OPEN_END_VOID"; TokenType$1[TokenType$1.TAG_CLOSE] = "TAG_CLOSE"; TokenType$1[TokenType$1.TEXT] = "TEXT"; TokenType$1[TokenType$1.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT"; TokenType$1[TokenType$1.RAW_TEXT] = "RAW_TEXT"; TokenType$1[TokenType$1.COMMENT_START] = "COMMENT_START"; TokenType$1[TokenType$1.COMMENT_END] = "COMMENT_END"; TokenType$1[TokenType$1.CDATA_START] = "CDATA_START"; TokenType$1[TokenType$1.CDATA_END] = "CDATA_END"; TokenType$1[TokenType$1.ATTR_NAME] = "ATTR_NAME"; TokenType$1[TokenType$1.ATTR_VALUE] = "ATTR_VALUE"; TokenType$1[TokenType$1.DOC_TYPE] = "DOC_TYPE"; TokenType$1[TokenType$1.EXPANSION_FORM_START] = "EXPANSION_FORM_START"; TokenType$1[TokenType$1.EXPANSION_CASE_VALUE] = "EXPANSION_CASE_VALUE"; TokenType$1[TokenType$1.EXPANSION_CASE_EXP_START] = "EXPANSION_CASE_EXP_START"; TokenType$1[TokenType$1.EXPANSION_CASE_EXP_END] = "EXPANSION_CASE_EXP_END"; TokenType$1[TokenType$1.EXPANSION_FORM_END] = "EXPANSION_FORM_END"; TokenType$1[TokenType$1.EOF] = "EOF"; var Token$1 = /** @class */ (function () { function Token(type, parts, sourceSpan) { this.type = type; this.parts = parts; this.sourceSpan = sourceSpan; } return Token; }()); var TokenError = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(TokenError, _super); function TokenError(errorMsg, tokenType, span) { var _this = _super.call(this, span, errorMsg) || this; _this.tokenType = tokenType; return _this; } return TokenError; }(ParseError)); var TokenizeResult = /** @class */ (function () { function TokenizeResult(tokens, errors) { this.tokens = tokens; this.errors = errors; } return TokenizeResult; }()); /** * @param {?} source * @param {?} url * @param {?} getTagDefinition * @param {?=} tokenizeExpansionForms * @param {?=} interpolationConfig * @return {?} */ function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) { if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig) .tokenize(); } var _CR_OR_CRLF_REGEXP = /\r\n?/g; /** * @param {?} charCode * @return {?} */ function _unexpectedCharacterErrorMsg(charCode) { var /** @type {?} */ char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode); return "Unexpected character \"" + char + "\""; } /** * @param {?} entitySrc * @return {?} */ function _unknownEntityErrorMsg(entitySrc) { return "Unknown entity \"" + entitySrc + "\" - use the \"&#;\" or \"&#x;\" syntax"; } var _ControlFlowError = /** @class */ (function () { function _ControlFlowError(error) { this.error = error; } return _ControlFlowError; }()); var _Tokenizer = /** @class */ (function () { /** * @param _file The html source * @param _getTagDefinition * @param _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false) * @param _interpolationConfig */ function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) { if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } this._file = _file; this._getTagDefinition = _getTagDefinition; this._tokenizeIcu = _tokenizeIcu; this._interpolationConfig = _interpolationConfig; this._peek = -1; this._nextPeek = -1; this._index = -1; this._line = 0; this._column = -1; this._expansionCaseStack = []; this._inInterpolation = false; this.tokens = []; this.errors = []; this._input = _file.content; this._length = _file.content.length; this._advance(); } /** * @param {?} content * @return {?} */ _Tokenizer.prototype._processCarriageReturns = /** * @param {?} content * @return {?} */ function (content) { // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream // In order to keep the original position in the source, we can not // pre-process it. // Instead CRs are processed right before instantiating the tokens. return content.replace(_CR_OR_CRLF_REGEXP, '\n'); }; /** * @return {?} */ _Tokenizer.prototype.tokenize = /** * @return {?} */ function () { while (this._peek !== $EOF) { var /** @type {?} */ start = this._getLocation(); try { if (this._attemptCharCode($LT)) { if (this._attemptCharCode($BANG)) { if (this._attemptCharCode($LBRACKET)) { this._consumeCdata(start); } else if (this._attemptCharCode($MINUS)) { this._consumeComment(start); } else { this._consumeDocType(start); } } else if (this._attemptCharCode($SLASH)) { this._consumeTagClose(start); } else { this._consumeTagOpen(start); } } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) { this._consumeText(); } } catch (/** @type {?} */ e) { if (e instanceof _ControlFlowError) { this.errors.push(e.error); } else { throw e; } } } this._beginToken(TokenType$1.EOF); this._endToken([]); return new TokenizeResult(mergeTextTokens(this.tokens), this.errors); }; /** * \@internal * @return {?} whether an ICU token has been created */ _Tokenizer.prototype._tokenizeExpansionForm = /** * \@internal * @return {?} whether an ICU token has been created */ function () { if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) { this._consumeExpansionFormStart(); return true; } if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) { this._consumeExpansionCaseStart(); return true; } if (this._peek === $RBRACE) { if (this._isInExpansionCase()) { this._consumeExpansionCaseEnd(); return true; } if (this._isInExpansionForm()) { this._consumeExpansionFormEnd(); return true; } } return false; }; /** * @return {?} */ _Tokenizer.prototype._getLocation = /** * @return {?} */ function () { return new ParseLocation(this._file, this._index, this._line, this._column); }; /** * @param {?=} start * @param {?=} end * @return {?} */ _Tokenizer.prototype._getSpan = /** * @param {?=} start * @param {?=} end * @return {?} */ function (start, end) { if (start === void 0) { start = this._getLocation(); } if (end === void 0) { end = this._getLocation(); } return new ParseSourceSpan(start, end); }; /** * @param {?} type * @param {?=} start * @return {?} */ _Tokenizer.prototype._beginToken = /** * @param {?} type * @param {?=} start * @return {?} */ function (type, start) { if (start === void 0) { start = this._getLocation(); } this._currentTokenStart = start; this._currentTokenType = type; }; /** * @param {?} parts * @param {?=} end * @return {?} */ _Tokenizer.prototype._endToken = /** * @param {?} parts * @param {?=} end * @return {?} */ function (parts, end) { if (end === void 0) { end = this._getLocation(); } var /** @type {?} */ token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end)); this.tokens.push(token); this._currentTokenStart = /** @type {?} */ ((null)); this._currentTokenType = /** @type {?} */ ((null)); return token; }; /** * @param {?} msg * @param {?} span * @return {?} */ _Tokenizer.prototype._createError = /** * @param {?} msg * @param {?} span * @return {?} */ function (msg, span) { if (this._isInExpansionForm()) { msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)"; } var /** @type {?} */ error = new TokenError(msg, this._currentTokenType, span); this._currentTokenStart = /** @type {?} */ ((null)); this._currentTokenType = /** @type {?} */ ((null)); return new _ControlFlowError(error); }; /** * @return {?} */ _Tokenizer.prototype._advance = /** * @return {?} */ function () { if (this._index >= this._length) { throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan()); } if (this._peek === $LF) { this._line++; this._column = 0; } else if (this._peek !== $LF && this._peek !== $CR) { this._column++; } this._index++; this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index); this._nextPeek = this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1); }; /** * @param {?} charCode * @return {?} */ _Tokenizer.prototype._attemptCharCode = /** * @param {?} charCode * @return {?} */ function (charCode) { if (this._peek === charCode) { this._advance(); return true; } return false; }; /** * @param {?} charCode * @return {?} */ _Tokenizer.prototype._attemptCharCodeCaseInsensitive = /** * @param {?} charCode * @return {?} */ function (charCode) { if (compareCharCodeCaseInsensitive(this._peek, charCode)) { this._advance(); return true; } return false; }; /** * @param {?} charCode * @return {?} */ _Tokenizer.prototype._requireCharCode = /** * @param {?} charCode * @return {?} */ function (charCode) { var /** @type {?} */ location = this._getLocation(); if (!this._attemptCharCode(charCode)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location)); } }; /** * @param {?} chars * @return {?} */ _Tokenizer.prototype._attemptStr = /** * @param {?} chars * @return {?} */ function (chars) { var /** @type {?} */ len = chars.length; if (this._index + len > this._length) { return false; } var /** @type {?} */ initialPosition = this._savePosition(); for (var /** @type {?} */ i = 0; i < len; i++) { if (!this._attemptCharCode(chars.charCodeAt(i))) { // If attempting to parse the string fails, we want to reset the parser // to where it was before the attempt this._restorePosition(initialPosition); return false; } } return true; }; /** * @param {?} chars * @return {?} */ _Tokenizer.prototype._attemptStrCaseInsensitive = /** * @param {?} chars * @return {?} */ function (chars) { for (var /** @type {?} */ i = 0; i < chars.length; i++) { if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) { return false; } } return true; }; /** * @param {?} chars * @return {?} */ _Tokenizer.prototype._requireStr = /** * @param {?} chars * @return {?} */ function (chars) { var /** @type {?} */ location = this._getLocation(); if (!this._attemptStr(chars)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location)); } }; /** * @param {?} predicate * @return {?} */ _Tokenizer.prototype._attemptCharCodeUntilFn = /** * @param {?} predicate * @return {?} */ function (predicate) { while (!predicate(this._peek)) { this._advance(); } }; /** * @param {?} predicate * @param {?} len * @return {?} */ _Tokenizer.prototype._requireCharCodeUntilFn = /** * @param {?} predicate * @param {?} len * @return {?} */ function (predicate, len) { var /** @type {?} */ start = this._getLocation(); this._attemptCharCodeUntilFn(predicate); if (this._index - start.offset < len) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start)); } }; /** * @param {?} char * @return {?} */ _Tokenizer.prototype._attemptUntilChar = /** * @param {?} char * @return {?} */ function (char) { while (this._peek !== char) { this._advance(); } }; /** * @param {?} decodeEntities * @return {?} */ _Tokenizer.prototype._readChar = /** * @param {?} decodeEntities * @return {?} */ function (decodeEntities) { if (decodeEntities && this._peek === $AMPERSAND) { return this._decodeEntity(); } else { var /** @type {?} */ index = this._index; this._advance(); return this._input[index]; } }; /** * @return {?} */ _Tokenizer.prototype._decodeEntity = /** * @return {?} */ function () { var /** @type {?} */ start = this._getLocation(); this._advance(); if (this._attemptCharCode($HASH)) { var /** @type {?} */ isHex = this._attemptCharCode($x) || this._attemptCharCode($X); var /** @type {?} */ numberStart = this._getLocation().offset; this._attemptCharCodeUntilFn(isDigitEntityEnd); if (this._peek != $SEMICOLON) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan()); } this._advance(); var /** @type {?} */ strNum = this._input.substring(numberStart, this._index - 1); try { var /** @type {?} */ charCode = parseInt(strNum, isHex ? 16 : 10); return String.fromCharCode(charCode); } catch (/** @type {?} */ e) { var /** @type {?} */ entity = this._input.substring(start.offset + 1, this._index - 1); throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start)); } } else { var /** @type {?} */ startPosition = this._savePosition(); this._attemptCharCodeUntilFn(isNamedEntityEnd); if (this._peek != $SEMICOLON) { this._restorePosition(startPosition); return '&'; } this._advance(); var /** @type {?} */ name_1 = this._input.substring(start.offset + 1, this._index - 1); var /** @type {?} */ char = NAMED_ENTITIES[name_1]; if (!char) { throw this._createError(_unknownEntityErrorMsg(name_1), this._getSpan(start)); } return char; } }; /** * @param {?} decodeEntities * @param {?} firstCharOfEnd * @param {?} attemptEndRest * @return {?} */ _Tokenizer.prototype._consumeRawText = /** * @param {?} decodeEntities * @param {?} firstCharOfEnd * @param {?} attemptEndRest * @return {?} */ function (decodeEntities, firstCharOfEnd, attemptEndRest) { var /** @type {?} */ tagCloseStart; var /** @type {?} */ textStart = this._getLocation(); this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart); var /** @type {?} */ parts = []; while (true) { tagCloseStart = this._getLocation(); if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) { break; } if (this._index > tagCloseStart.offset) { // add the characters consumed by the previous if statement to the output parts.push(this._input.substring(tagCloseStart.offset, this._index)); } while (this._peek !== firstCharOfEnd) { parts.push(this._readChar(decodeEntities)); } } return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart); }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeComment = /** * @param {?} start * @return {?} */ function (start) { var _this = this; this._beginToken(TokenType$1.COMMENT_START, start); this._requireCharCode($MINUS); this._endToken([]); var /** @type {?} */ textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); }); this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end); this._endToken([]); }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeCdata = /** * @param {?} start * @return {?} */ function (start) { var _this = this; this._beginToken(TokenType$1.CDATA_START, start); this._requireStr('CDATA['); this._endToken([]); var /** @type {?} */ textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); }); this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end); this._endToken([]); }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeDocType = /** * @param {?} start * @return {?} */ function (start) { this._beginToken(TokenType$1.DOC_TYPE, start); this._attemptUntilChar($GT); this._advance(); this._endToken([this._input.substring(start.offset + 2, this._index - 1)]); }; /** * @return {?} */ _Tokenizer.prototype._consumePrefixAndName = /** * @return {?} */ function () { var /** @type {?} */ nameOrPrefixStart = this._index; var /** @type {?} */ prefix = /** @type {?} */ ((null)); while (this._peek !== $COLON && !isPrefixEnd(this._peek)) { this._advance(); } var /** @type {?} */ nameStart; if (this._peek === $COLON) { this._advance(); prefix = this._input.substring(nameOrPrefixStart, this._index - 1); nameStart = this._index; } else { nameStart = nameOrPrefixStart; } this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0); var /** @type {?} */ name = this._input.substring(nameStart, this._index); return [prefix, name]; }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeTagOpen = /** * @param {?} start * @return {?} */ function (start) { var /** @type {?} */ savedPos = this._savePosition(); var /** @type {?} */ tagName; var /** @type {?} */ lowercaseTagName; try { if (!isAsciiLetter(this._peek)) { throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan()); } var /** @type {?} */ nameStart = this._index; this._consumeTagOpenStart(start); tagName = this._input.substring(nameStart, this._index); lowercaseTagName = tagName.toLowerCase(); this._attemptCharCodeUntilFn(isNotWhitespace); while (this._peek !== $SLASH && this._peek !== $GT) { this._consumeAttributeName(); this._attemptCharCodeUntilFn(isNotWhitespace); if (this._attemptCharCode($EQ)) { this._attemptCharCodeUntilFn(isNotWhitespace); this._consumeAttributeValue(); } this._attemptCharCodeUntilFn(isNotWhitespace); } this._consumeTagOpenEnd(); } catch (/** @type {?} */ e) { if (e instanceof _ControlFlowError) { // When the start tag is invalid, assume we want a "<" this._restorePosition(savedPos); // Back to back text tokens are merged at the end this._beginToken(TokenType$1.TEXT, start); this._endToken(['<']); return; } throw e; } var /** @type {?} */ contentTokenType = this._getTagDefinition(tagName).contentType; if (contentTokenType === TagContentType.RAW_TEXT) { this._consumeRawTextWithTagClose(lowercaseTagName, false); } else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) { this._consumeRawTextWithTagClose(lowercaseTagName, true); } }; /** * @param {?} lowercaseTagName * @param {?} decodeEntities * @return {?} */ _Tokenizer.prototype._consumeRawTextWithTagClose = /** * @param {?} lowercaseTagName * @param {?} decodeEntities * @return {?} */ function (lowercaseTagName, decodeEntities) { var _this = this; var /** @type {?} */ textToken = this._consumeRawText(decodeEntities, $LT, function () { if (!_this._attemptCharCode($SLASH)) return false; _this._attemptCharCodeUntilFn(isNotWhitespace); if (!_this._attemptStrCaseInsensitive(lowercaseTagName)) return false; _this._attemptCharCodeUntilFn(isNotWhitespace); return _this._attemptCharCode($GT); }); this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end); this._endToken([/** @type {?} */ ((null)), lowercaseTagName]); }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeTagOpenStart = /** * @param {?} start * @return {?} */ function (start) { this._beginToken(TokenType$1.TAG_OPEN_START, start); var /** @type {?} */ parts = this._consumePrefixAndName(); this._endToken(parts); }; /** * @return {?} */ _Tokenizer.prototype._consumeAttributeName = /** * @return {?} */ function () { this._beginToken(TokenType$1.ATTR_NAME); var /** @type {?} */ prefixAndName = this._consumePrefixAndName(); this._endToken(prefixAndName); }; /** * @return {?} */ _Tokenizer.prototype._consumeAttributeValue = /** * @return {?} */ function () { this._beginToken(TokenType$1.ATTR_VALUE); var /** @type {?} */ value; if (this._peek === $SQ || this._peek === $DQ) { var /** @type {?} */ quoteChar = this._peek; this._advance(); var /** @type {?} */ parts = []; while (this._peek !== quoteChar) { parts.push(this._readChar(true)); } value = parts.join(''); this._advance(); } else { var /** @type {?} */ valueStart = this._index; this._requireCharCodeUntilFn(isNameEnd, 1); value = this._input.substring(valueStart, this._index); } this._endToken([this._processCarriageReturns(value)]); }; /** * @return {?} */ _Tokenizer.prototype._consumeTagOpenEnd = /** * @return {?} */ function () { var /** @type {?} */ tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END; this._beginToken(tokenType); this._requireCharCode($GT); this._endToken([]); }; /** * @param {?} start * @return {?} */ _Tokenizer.prototype._consumeTagClose = /** * @param {?} start * @return {?} */ function (start) { this._beginToken(TokenType$1.TAG_CLOSE, start); this._attemptCharCodeUntilFn(isNotWhitespace); var /** @type {?} */ prefixAndName = this._consumePrefixAndName(); this._attemptCharCodeUntilFn(isNotWhitespace); this._requireCharCode($GT); this._endToken(prefixAndName); }; /** * @return {?} */ _Tokenizer.prototype._consumeExpansionFormStart = /** * @return {?} */ function () { this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation()); this._requireCharCode($LBRACE); this._endToken([]); this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START); this._beginToken(TokenType$1.RAW_TEXT, this._getLocation()); var /** @type {?} */ condition = this._readUntil($COMMA); this._endToken([condition], this._getLocation()); this._requireCharCode($COMMA); this._attemptCharCodeUntilFn(isNotWhitespace); this._beginToken(TokenType$1.RAW_TEXT, this._getLocation()); var /** @type {?} */ type = this._readUntil($COMMA); this._endToken([type], this._getLocation()); this._requireCharCode($COMMA); this._attemptCharCodeUntilFn(isNotWhitespace); }; /** * @return {?} */ _Tokenizer.prototype._consumeExpansionCaseStart = /** * @return {?} */ function () { this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation()); var /** @type {?} */ value = this._readUntil($LBRACE).trim(); this._endToken([value], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation()); this._requireCharCode($LBRACE); this._endToken([], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START); }; /** * @return {?} */ _Tokenizer.prototype._consumeExpansionCaseEnd = /** * @return {?} */ function () { this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation()); this._requireCharCode($RBRACE); this._endToken([], this._getLocation()); this._attemptCharCodeUntilFn(isNotWhitespace); this._expansionCaseStack.pop(); }; /** * @return {?} */ _Tokenizer.prototype._consumeExpansionFormEnd = /** * @return {?} */ function () { this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation()); this._requireCharCode($RBRACE); this._endToken([]); this._expansionCaseStack.pop(); }; /** * @return {?} */ _Tokenizer.prototype._consumeText = /** * @return {?} */ function () { var /** @type {?} */ start = this._getLocation(); this._beginToken(TokenType$1.TEXT, start); var /** @type {?} */ parts = []; do { if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) { parts.push(this._interpolationConfig.start); this._inInterpolation = true; } else if (this._interpolationConfig && this._inInterpolation && this._attemptStr(this._interpolationConfig.end)) { parts.push(this._interpolationConfig.end); this._inInterpolation = false; } else { parts.push(this._readChar(true)); } } while (!this._isTextEnd()); this._endToken([this._processCarriageReturns(parts.join(''))]); }; /** * @return {?} */ _Tokenizer.prototype._isTextEnd = /** * @return {?} */ function () { if (this._peek === $LT || this._peek === $EOF) { return true; } if (this._tokenizeIcu && !this._inInterpolation) { if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) { // start of an expansion form return true; } if (this._peek === $RBRACE && this._isInExpansionCase()) { // end of and expansion case return true; } } return false; }; /** * @return {?} */ _Tokenizer.prototype._savePosition = /** * @return {?} */ function () { return [this._peek, this._index, this._column, this._line, this.tokens.length]; }; /** * @param {?} char * @return {?} */ _Tokenizer.prototype._readUntil = /** * @param {?} char * @return {?} */ function (char) { var /** @type {?} */ start = this._index; this._attemptUntilChar(char); return this._input.substring(start, this._index); }; /** * @param {?} position * @return {?} */ _Tokenizer.prototype._restorePosition = /** * @param {?} position * @return {?} */ function (position) { this._peek = position[0]; this._index = position[1]; this._column = position[2]; this._line = position[3]; var /** @type {?} */ nbTokens = position[4]; if (nbTokens < this.tokens.length) { // remove any extra tokens this.tokens = this.tokens.slice(0, nbTokens); } }; /** * @return {?} */ _Tokenizer.prototype._isInExpansionCase = /** * @return {?} */ function () { return this._expansionCaseStack.length > 0 && this._expansionCaseStack[this._expansionCaseStack.length - 1] === TokenType$1.EXPANSION_CASE_EXP_START; }; /** * @return {?} */ _Tokenizer.prototype._isInExpansionForm = /** * @return {?} */ function () { return this._expansionCaseStack.length > 0 && this._expansionCaseStack[this._expansionCaseStack.length - 1] === TokenType$1.EXPANSION_FORM_START; }; return _Tokenizer; }()); /** * @param {?} code * @return {?} */ function isNotWhitespace(code) { return !isWhitespace(code) || code === $EOF; } /** * @param {?} code * @return {?} */ function isNameEnd(code) { return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ || code === $EQ; } /** * @param {?} code * @return {?} */ function isPrefixEnd(code) { return (code < $a || $z < code) && (code < $A || $Z < code) && (code < $0 || code > $9); } /** * @param {?} code * @return {?} */ function isDigitEntityEnd(code) { return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code); } /** * @param {?} code * @return {?} */ function isNamedEntityEnd(code) { return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code); } /** * @param {?} input * @param {?} offset * @param {?} interpolationConfig * @return {?} */ function isExpansionFormStart(input, offset, interpolationConfig) { var /** @type {?} */ isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false; return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart; } /** * @param {?} peek * @return {?} */ function isExpansionCaseStart(peek) { return peek === $EQ || isAsciiLetter(peek) || isDigit(peek); } /** * @param {?} code1 * @param {?} code2 * @return {?} */ function compareCharCodeCaseInsensitive(code1, code2) { return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2); } /** * @param {?} code * @return {?} */ function toUpperCaseCharCode(code) { return code >= $a && code <= $z ? code - $a + $A : code; } /** * @param {?} srcTokens * @return {?} */ function mergeTextTokens(srcTokens) { var /** @type {?} */ dstTokens = []; var /** @type {?} */ lastDstToken = undefined; for (var /** @type {?} */ i = 0; i < srcTokens.length; i++) { var /** @type {?} */ token = srcTokens[i]; if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) { lastDstToken.parts[0] += token.parts[0]; lastDstToken.sourceSpan.end = token.sourceSpan.end; } else { lastDstToken = token; dstTokens.push(lastDstToken); } } return dstTokens; } /** * @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 TreeError = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(TreeError, _super); function TreeError(elementName, span, msg) { var _this = _super.call(this, span, msg) || this; _this.elementName = elementName; return _this; } /** * @param {?} elementName * @param {?} span * @param {?} msg * @return {?} */ TreeError.create = /** * @param {?} elementName * @param {?} span * @param {?} msg * @return {?} */ function (elementName, span, msg) { return new TreeError(elementName, span, msg); }; return TreeError; }(ParseError)); var ParseTreeResult = /** @class */ (function () { function ParseTreeResult(rootNodes, errors) { this.rootNodes = rootNodes; this.errors = errors; } return ParseTreeResult; }()); var Parser$1 = /** @class */ (function () { function Parser(getTagDefinition) { this.getTagDefinition = getTagDefinition; } /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ Parser.prototype.parse = /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ function (source, url, parseExpansionForms, interpolationConfig) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig); var /** @type {?} */ treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build(); return new ParseTreeResult(treeAndErrors.rootNodes, (/** @type {?} */ (tokensAndErrors.errors)).concat(treeAndErrors.errors)); }; return Parser; }()); var _TreeBuilder = /** @class */ (function () { function _TreeBuilder(tokens, getTagDefinition) { this.tokens = tokens; this.getTagDefinition = getTagDefinition; this._index = -1; this._rootNodes = []; this._errors = []; this._elementStack = []; this._advance(); } /** * @return {?} */ _TreeBuilder.prototype.build = /** * @return {?} */ function () { while (this._peek.type !== TokenType$1.EOF) { if (this._peek.type === TokenType$1.TAG_OPEN_START) { this._consumeStartTag(this._advance()); } else if (this._peek.type === TokenType$1.TAG_CLOSE) { this._consumeEndTag(this._advance()); } else if (this._peek.type === TokenType$1.CDATA_START) { this._closeVoidElement(); this._consumeCdata(this._advance()); } else if (this._peek.type === TokenType$1.COMMENT_START) { this._closeVoidElement(); this._consumeComment(this._advance()); } else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT || this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) { this._closeVoidElement(); this._consumeText(this._advance()); } else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) { this._consumeExpansion(this._advance()); } else { // Skip all other tokens... this._advance(); } } return new ParseTreeResult(this._rootNodes, this._errors); }; /** * @return {?} */ _TreeBuilder.prototype._advance = /** * @return {?} */ function () { var /** @type {?} */ prev = this._peek; if (this._index < this.tokens.length - 1) { // Note: there is always an EOF token at the end this._index++; } this._peek = this.tokens[this._index]; return prev; }; /** * @param {?} type * @return {?} */ _TreeBuilder.prototype._advanceIf = /** * @param {?} type * @return {?} */ function (type) { if (this._peek.type === type) { return this._advance(); } return null; }; /** * @param {?} startToken * @return {?} */ _TreeBuilder.prototype._consumeCdata = /** * @param {?} startToken * @return {?} */ function (startToken) { this._consumeText(this._advance()); this._advanceIf(TokenType$1.CDATA_END); }; /** * @param {?} token * @return {?} */ _TreeBuilder.prototype._consumeComment = /** * @param {?} token * @return {?} */ function (token) { var /** @type {?} */ text = this._advanceIf(TokenType$1.RAW_TEXT); this._advanceIf(TokenType$1.COMMENT_END); var /** @type {?} */ value = text != null ? text.parts[0].trim() : null; this._addToParent(new Comment(value, token.sourceSpan)); }; /** * @param {?} token * @return {?} */ _TreeBuilder.prototype._consumeExpansion = /** * @param {?} token * @return {?} */ function (token) { var /** @type {?} */ switchValue = this._advance(); var /** @type {?} */ type = this._advance(); var /** @type {?} */ cases = []; // read = while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) { var /** @type {?} */ expCase = this._parseExpansionCase(); if (!expCase) return; // error cases.push(expCase); } // read the final } if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) { this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'.")); return; } var /** @type {?} */ sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end); this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan)); this._advance(); }; /** * @return {?} */ _TreeBuilder.prototype._parseExpansionCase = /** * @return {?} */ function () { var /** @type {?} */ value = this._advance(); // read { if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) { this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'.")); return null; } // read until } var /** @type {?} */ start = this._advance(); var /** @type {?} */ exp = this._collectExpansionExpTokens(start); if (!exp) return null; var /** @type {?} */ end = this._advance(); exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan)); // parse everything in between { and } var /** @type {?} */ parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build(); if (parsedExp.errors.length > 0) { this._errors = this._errors.concat(/** @type {?} */ (parsedExp.errors)); return null; } var /** @type {?} */ sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end); var /** @type {?} */ expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end); return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan); }; /** * @param {?} start * @return {?} */ _TreeBuilder.prototype._collectExpansionExpTokens = /** * @param {?} start * @return {?} */ function (start) { var /** @type {?} */ exp = []; var /** @type {?} */ expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START]; while (true) { if (this._peek.type === TokenType$1.EXPANSION_FORM_START || this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) { expansionFormStack.push(this._peek.type); } if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) { if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) { expansionFormStack.pop(); if (expansionFormStack.length == 0) return exp; } else { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } } if (this._peek.type === TokenType$1.EXPANSION_FORM_END) { if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) { expansionFormStack.pop(); } else { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } } if (this._peek.type === TokenType$1.EOF) { this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'.")); return null; } exp.push(this._advance()); } }; /** * @param {?} token * @return {?} */ _TreeBuilder.prototype._consumeText = /** * @param {?} token * @return {?} */ function (token) { var /** @type {?} */ text = token.parts[0]; if (text.length > 0 && text[0] == '\n') { var /** @type {?} */ parent_1 = this._getParentElement(); if (parent_1 != null && parent_1.children.length == 0 && this.getTagDefinition(parent_1.name).ignoreFirstLf) { text = text.substring(1); } } if (text.length > 0) { this._addToParent(new Text(text, token.sourceSpan)); } }; /** * @return {?} */ _TreeBuilder.prototype._closeVoidElement = /** * @return {?} */ function () { var /** @type {?} */ el = this._getParentElement(); if (el && this.getTagDefinition(el.name).isVoid) { this._elementStack.pop(); } }; /** * @param {?} startTagToken * @return {?} */ _TreeBuilder.prototype._consumeStartTag = /** * @param {?} startTagToken * @return {?} */ function (startTagToken) { var /** @type {?} */ prefix = startTagToken.parts[0]; var /** @type {?} */ name = startTagToken.parts[1]; var /** @type {?} */ attrs = []; while (this._peek.type === TokenType$1.ATTR_NAME) { attrs.push(this._consumeAttr(this._advance())); } var /** @type {?} */ fullName = this._getElementFullName(prefix, name, this._getParentElement()); var /** @type {?} */ selfClosing = false; // Note: There could have been a tokenizer error // so that we don't get a token for the end tag... if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) { this._advance(); selfClosing = true; var /** @type {?} */ tagDef = this.getTagDefinition(fullName); if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) { this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\"")); } } else if (this._peek.type === TokenType$1.TAG_OPEN_END) { this._advance(); selfClosing = false; } var /** @type {?} */ end = this._peek.sourceSpan.start; var /** @type {?} */ span = new ParseSourceSpan(startTagToken.sourceSpan.start, end); var /** @type {?} */ el = new Element(fullName, attrs, [], span, span, undefined); this._pushElement(el); if (selfClosing) { this._popElement(fullName); el.endSourceSpan = span; } }; /** * @param {?} el * @return {?} */ _TreeBuilder.prototype._pushElement = /** * @param {?} el * @return {?} */ function (el) { var /** @type {?} */ parentEl = this._getParentElement(); if (parentEl && this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) { this._elementStack.pop(); } var /** @type {?} */ tagDef = this.getTagDefinition(el.name); var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container; if (parent && tagDef.requireExtraParent(parent.name)) { var /** @type {?} */ newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan); this._insertBeforeContainer(parent, container, newParent); } this._addToParent(el); this._elementStack.push(el); }; /** * @param {?} endTagToken * @return {?} */ _TreeBuilder.prototype._consumeEndTag = /** * @param {?} endTagToken * @return {?} */ function (endTagToken) { var /** @type {?} */ fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement()); if (this._getParentElement()) { /** @type {?} */ ((this._getParentElement())).endSourceSpan = endTagToken.sourceSpan; } if (this.getTagDefinition(fullName).isVoid) { this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\"")); } else if (!this._popElement(fullName)) { var /** @type {?} */ errMsg = "Unexpected closing tag \"" + fullName + "\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags"; this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg)); } }; /** * @param {?} fullName * @return {?} */ _TreeBuilder.prototype._popElement = /** * @param {?} fullName * @return {?} */ function (fullName) { for (var /** @type {?} */ stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) { var /** @type {?} */ el = this._elementStack[stackIndex]; if (el.name == fullName) { this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex); return true; } if (!this.getTagDefinition(el.name).closedByParent) { return false; } } return false; }; /** * @param {?} attrName * @return {?} */ _TreeBuilder.prototype._consumeAttr = /** * @param {?} attrName * @return {?} */ function (attrName) { var /** @type {?} */ fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]); var /** @type {?} */ end = attrName.sourceSpan.end; var /** @type {?} */ value = ''; var /** @type {?} */ valueSpan = /** @type {?} */ ((undefined)); if (this._peek.type === TokenType$1.ATTR_VALUE) { var /** @type {?} */ valueToken = this._advance(); value = valueToken.parts[0]; end = valueToken.sourceSpan.end; valueSpan = valueToken.sourceSpan; } return new Attribute$1(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan); }; /** * @return {?} */ _TreeBuilder.prototype._getParentElement = /** * @return {?} */ function () { return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null; }; /** * Returns the parent in the DOM and the container. * * `` elements are skipped as they are not rendered as DOM element. * @return {?} */ _TreeBuilder.prototype._getParentElementSkippingContainers = /** * Returns the parent in the DOM and the container. * * `` elements are skipped as they are not rendered as DOM element. * @return {?} */ function () { var /** @type {?} */ container = null; for (var /** @type {?} */ i = this._elementStack.length - 1; i >= 0; i--) { if (!isNgContainer(this._elementStack[i].name)) { return { parent: this._elementStack[i], container: container }; } container = this._elementStack[i]; } return { parent: null, container: container }; }; /** * @param {?} node * @return {?} */ _TreeBuilder.prototype._addToParent = /** * @param {?} node * @return {?} */ function (node) { var /** @type {?} */ parent = this._getParentElement(); if (parent != null) { parent.children.push(node); } else { this._rootNodes.push(node); } }; /** * Insert a node between the parent and the container. * When no container is given, the node is appended as a child of the parent. * Also updates the element stack accordingly. * * \@internal * @param {?} parent * @param {?} container * @param {?} node * @return {?} */ _TreeBuilder.prototype._insertBeforeContainer = /** * Insert a node between the parent and the container. * When no container is given, the node is appended as a child of the parent. * Also updates the element stack accordingly. * * \@internal * @param {?} parent * @param {?} container * @param {?} node * @return {?} */ function (parent, container, node) { if (!container) { this._addToParent(node); this._elementStack.push(node); } else { if (parent) { // replace the container with the new node in the children var /** @type {?} */ index = parent.children.indexOf(container); parent.children[index] = node; } else { this._rootNodes.push(node); } node.children.push(container); this._elementStack.splice(this._elementStack.indexOf(container), 0, node); } }; /** * @param {?} prefix * @param {?} localName * @param {?} parentElement * @return {?} */ _TreeBuilder.prototype._getElementFullName = /** * @param {?} prefix * @param {?} localName * @param {?} parentElement * @return {?} */ function (prefix, localName, parentElement) { if (prefix == null) { prefix = /** @type {?} */ ((this.getTagDefinition(localName).implicitNamespacePrefix)); if (prefix == null && parentElement != null) { prefix = getNsPrefix(parentElement.name); } } return mergeNsAndName(prefix, localName); }; return _TreeBuilder; }()); /** * @param {?} stack * @param {?} element * @return {?} */ function lastOnStack(stack, element) { return stack.length > 0 && stack[stack.length - 1] === element; } /** * @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 {?} message * @return {?} */ function digest(message) { return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]")); } /** * @param {?} message * @return {?} */ function decimalDigest(message) { if (message.id) { return message.id; } var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor(); var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); }); return computeMsgId(parts.join(''), message.meaning); } /** * Serialize the i18n ast to something xml-like in order to generate an UID. * * The visitor is also used in the i18n parser tests * * \@internal */ var _SerializerVisitor = /** @class */ (function () { function _SerializerVisitor() { } /** * @param {?} text * @param {?} context * @return {?} */ _SerializerVisitor.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return text.value; }; /** * @param {?} container * @param {?} context * @return {?} */ _SerializerVisitor.prototype.visitContainer = /** * @param {?} container * @param {?} context * @return {?} */ function (container, context) { var _this = this; return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]"; }; /** * @param {?} icu * @param {?} context * @return {?} */ _SerializerVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; }); return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}"; }; /** * @param {?} ph * @param {?} context * @return {?} */ _SerializerVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?} context * @return {?} */ function (ph, context) { var _this = this; return ph.isVoid ? "" : "" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + ""; }; /** * @param {?} ph * @param {?} context * @return {?} */ _SerializerVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?} context * @return {?} */ function (ph, context) { return ph.value ? "" + ph.value + "" : ""; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _SerializerVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { return "" + ph.value.visit(this) + ""; }; return _SerializerVisitor; }()); var serializerVisitor = new _SerializerVisitor(); /** * @param {?} nodes * @return {?} */ function serializeNodes(nodes) { return nodes.map(function (a) { return a.visit(serializerVisitor, null); }); } /** * Serialize the i18n ast to something xml-like in order to generate an UID. * * Ignore the ICU expressions so that message IDs stays identical if only the expression changes. * * \@internal */ var _SerializerIgnoreIcuExpVisitor = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_SerializerIgnoreIcuExpVisitor, _super); function _SerializerIgnoreIcuExpVisitor() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} icu * @param {?} context * @return {?} */ _SerializerIgnoreIcuExpVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; }); // Do not take the expression into account return "{" + icu.type + ", " + strCases.join(', ') + "}"; }; return _SerializerIgnoreIcuExpVisitor; }(_SerializerVisitor)); /** * Compute the SHA1 of the given string * * see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf * * WARNING: this function has not been designed not tested with security in mind. * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT. * @param {?} str * @return {?} */ function sha1(str) { var /** @type {?} */ utf8 = utf8Encode(str); var /** @type {?} */ words32 = stringToWords32(utf8, Endian.Big); var /** @type {?} */ len = utf8.length * 8; var /** @type {?} */ w = new Array(80); var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4]; words32[len >> 5] |= 0x80 << (24 - len % 32); words32[((len + 64 >> 9) << 4) + 15] = len; for (var /** @type {?} */ i = 0; i < words32.length; i += 16) { var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4]; for (var /** @type {?} */ j = 0; j < 80; j++) { if (j < 16) { w[j] = words32[i + j]; } else { w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); } var _c = fk(j, b, c, d), f = _c[0], k = _c[1]; var /** @type {?} */ temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32); _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4]; } _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4]; } return byteStringToHexString(words32ToByteString([a, b, c, d, e])); var _d, _e; } /** * @param {?} index * @param {?} b * @param {?} c * @param {?} d * @return {?} */ function fk(index, b, c, d) { if (index < 20) { return [(b & c) | (~b & d), 0x5a827999]; } if (index < 40) { return [b ^ c ^ d, 0x6ed9eba1]; } if (index < 60) { return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc]; } return [b ^ c ^ d, 0xca62c1d6]; } /** * Compute the fingerprint of the given string * * The output is 64 bit number encoded as a decimal string * * based on: * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java * @param {?} str * @return {?} */ function fingerprint(str) { var /** @type {?} */ utf8 = utf8Encode(str); var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1]; if (hi == 0 && (lo == 0 || lo == 1)) { hi = hi ^ 0x130f9bef; lo = lo ^ -0x6b5f56d8; } return [hi, lo]; } /** * @param {?} msg * @param {?} meaning * @return {?} */ function computeMsgId(msg, meaning) { var _a = fingerprint(msg), hi = _a[0], lo = _a[1]; if (meaning) { var _b = fingerprint(meaning), him = _b[0], lom = _b[1]; _c = add64(rol64([hi, lo], 1), [him, lom]), hi = _c[0], lo = _c[1]; } return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo])); var _c; } /** * @param {?} str * @param {?} c * @return {?} */ function hash32(str, c) { var _a = [0x9e3779b9, 0x9e3779b9], a = _a[0], b = _a[1]; var /** @type {?} */ i; var /** @type {?} */ len = str.length; for (i = 0; i + 12 <= len; i += 12) { a = add32(a, wordAt(str, i, Endian.Little)); b = add32(b, wordAt(str, i + 4, Endian.Little)); c = add32(c, wordAt(str, i + 8, Endian.Little)); _b = mix([a, b, c]), a = _b[0], b = _b[1], c = _b[2]; } a = add32(a, wordAt(str, i, Endian.Little)); b = add32(b, wordAt(str, i + 4, Endian.Little)); // the first byte of c is reserved for the length c = add32(c, len); c = add32(c, wordAt(str, i + 8, Endian.Little) << 8); return mix([a, b, c])[2]; var _b; } /** * @param {?} __0 * @return {?} */ function mix(_a) { var a = _a[0], b = _a[1], c = _a[2]; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 13; b = sub32(b, c); b = sub32(b, a); b ^= a << 8; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 13; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 12; b = sub32(b, c); b = sub32(b, a); b ^= a << 16; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 5; a = sub32(a, b); a = sub32(a, c); a ^= c >>> 3; b = sub32(b, c); b = sub32(b, a); b ^= a << 10; c = sub32(c, a); c = sub32(c, b); c ^= b >>> 15; return [a, b, c]; } /** @enum {number} */ var Endian = { Little: 0, Big: 1, }; Endian[Endian.Little] = "Little"; Endian[Endian.Big] = "Big"; /** * @param {?} a * @param {?} b * @return {?} */ function add32(a, b) { return add32to64(a, b)[1]; } /** * @param {?} a * @param {?} b * @return {?} */ function add32to64(a, b) { var /** @type {?} */ low = (a & 0xffff) + (b & 0xffff); var /** @type {?} */ high = (a >>> 16) + (b >>> 16) + (low >>> 16); return [high >>> 16, (high << 16) | (low & 0xffff)]; } /** * @param {?} __0 * @param {?} __1 * @return {?} */ function add64(_a, _b) { var ah = _a[0], al = _a[1]; var bh = _b[0], bl = _b[1]; var _c = add32to64(al, bl), carry = _c[0], l = _c[1]; var /** @type {?} */ h = add32(add32(ah, bh), carry); return [h, l]; } /** * @param {?} a * @param {?} b * @return {?} */ function sub32(a, b) { var /** @type {?} */ low = (a & 0xffff) - (b & 0xffff); var /** @type {?} */ high = (a >> 16) - (b >> 16) + (low >> 16); return (high << 16) | (low & 0xffff); } /** * @param {?} a * @param {?} count * @return {?} */ function rol32(a, count) { return (a << count) | (a >>> (32 - count)); } /** * @param {?} __0 * @param {?} count * @return {?} */ function rol64(_a, count) { var hi = _a[0], lo = _a[1]; var /** @type {?} */ h = (hi << count) | (lo >>> (32 - count)); var /** @type {?} */ l = (lo << count) | (hi >>> (32 - count)); return [h, l]; } /** * @param {?} str * @param {?} endian * @return {?} */ function stringToWords32(str, endian) { var /** @type {?} */ words32 = Array((str.length + 3) >>> 2); for (var /** @type {?} */ i = 0; i < words32.length; i++) { words32[i] = wordAt(str, i * 4, endian); } return words32; } /** * @param {?} str * @param {?} index * @return {?} */ function byteAt(str, index) { return index >= str.length ? 0 : str.charCodeAt(index) & 0xff; } /** * @param {?} str * @param {?} index * @param {?} endian * @return {?} */ function wordAt(str, index, endian) { var /** @type {?} */ word = 0; if (endian === Endian.Big) { for (var /** @type {?} */ i = 0; i < 4; i++) { word += byteAt(str, index + i) << (24 - 8 * i); } } else { for (var /** @type {?} */ i = 0; i < 4; i++) { word += byteAt(str, index + i) << 8 * i; } } return word; } /** * @param {?} words32 * @return {?} */ function words32ToByteString(words32) { return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, ''); } /** * @param {?} word * @return {?} */ function word32ToByteString(word) { var /** @type {?} */ str = ''; for (var /** @type {?} */ i = 0; i < 4; i++) { str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff); } return str; } /** * @param {?} str * @return {?} */ function byteStringToHexString(str) { var /** @type {?} */ hex = ''; for (var /** @type {?} */ i = 0; i < str.length; i++) { var /** @type {?} */ b = byteAt(str, i); hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16); } return hex.toLowerCase(); } /** * @param {?} str * @return {?} */ function byteStringToDecString(str) { var /** @type {?} */ decimal = ''; var /** @type {?} */ toThePower = '1'; for (var /** @type {?} */ i = str.length - 1; i >= 0; i--) { decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower)); toThePower = numberTimesBigInt(256, toThePower); } return decimal.split('').reverse().join(''); } /** * @param {?} x * @param {?} y * @return {?} */ function addBigInt(x, y) { var /** @type {?} */ sum = ''; var /** @type {?} */ len = Math.max(x.length, y.length); for (var /** @type {?} */ i = 0, /** @type {?} */ carry = 0; i < len || carry; i++) { var /** @type {?} */ tmpSum = carry + +(x[i] || 0) + +(y[i] || 0); if (tmpSum >= 10) { carry = 1; sum += tmpSum - 10; } else { carry = 0; sum += tmpSum; } } return sum; } /** * @param {?} num * @param {?} b * @return {?} */ function numberTimesBigInt(num, b) { var /** @type {?} */ product = ''; var /** @type {?} */ bToThePower = b; for (; num !== 0; num = num >>> 1) { if (num & 1) product = addBigInt(product, bToThePower); bToThePower = addBigInt(bToThePower, bToThePower); } return product; } /** * @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 Message = /** @class */ (function () { /** * @param nodes message AST * @param placeholders maps placeholder names to static content * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages) * @param meaning * @param description * @param id */ function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) { this.nodes = nodes; this.placeholders = placeholders; this.placeholderToMessage = placeholderToMessage; this.meaning = meaning; this.description = description; this.id = id; if (nodes.length) { this.sources = [{ filePath: nodes[0].sourceSpan.start.file.url, startLine: nodes[0].sourceSpan.start.line + 1, startCol: nodes[0].sourceSpan.start.col + 1, endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1, endCol: nodes[0].sourceSpan.start.col + 1 }]; } else { this.sources = []; } } return Message; }()); /** * @record */ /** * @record */ var Text$1 = /** @class */ (function () { function Text(value, sourceSpan) { this.value = value; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Text.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitText(this, context); }; return Text; }()); var Container = /** @class */ (function () { function Container(children, sourceSpan) { this.children = children; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Container.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitContainer(this, context); }; return Container; }()); var Icu = /** @class */ (function () { function Icu(expression, type, cases, sourceSpan) { this.expression = expression; this.type = type; this.cases = cases; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Icu.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitIcu(this, context); }; return Icu; }()); var TagPlaceholder = /** @class */ (function () { function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) { this.tag = tag; this.attrs = attrs; this.startName = startName; this.closeName = closeName; this.children = children; this.isVoid = isVoid; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ TagPlaceholder.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitTagPlaceholder(this, context); }; return TagPlaceholder; }()); var Placeholder = /** @class */ (function () { function Placeholder(value, name, sourceSpan) { this.value = value; this.name = name; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ Placeholder.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitPlaceholder(this, context); }; return Placeholder; }()); var IcuPlaceholder = /** @class */ (function () { function IcuPlaceholder(value, name, sourceSpan) { this.value = value; this.name = name; this.sourceSpan = sourceSpan; } /** * @param {?} visitor * @param {?=} context * @return {?} */ IcuPlaceholder.prototype.visit = /** * @param {?} visitor * @param {?=} context * @return {?} */ function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); }; return IcuPlaceholder; }()); /** * @record */ var CloneVisitor = /** @class */ (function () { function CloneVisitor() { } /** * @param {?} text * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return new Text$1(text.value, text.sourceSpan); }; /** * @param {?} container * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitContainer = /** * @param {?} container * @param {?=} context * @return {?} */ function (container, context) { var _this = this; var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); }); return new Container(children, container.sourceSpan); }; /** * @param {?} icu * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ cases = {}; Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); }); var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan); msg.expressionPlaceholder = icu.expressionPlaceholder; return msg; }; /** * @param {?} ph * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var _this = this; var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); }); return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan); }; /** * @param {?} ph * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { return new Placeholder(ph.value, ph.name, ph.sourceSpan); }; /** * @param {?} ph * @param {?=} context * @return {?} */ CloneVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan); }; return CloneVisitor; }()); var RecurseVisitor = /** @class */ (function () { function RecurseVisitor() { } /** * @param {?} text * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { }; /** * @param {?} container * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitContainer = /** * @param {?} container * @param {?=} context * @return {?} */ function (container, context) { var _this = this; container.children.forEach(function (child) { return child.visit(_this); }); }; /** * @param {?} icu * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); }); }; /** * @param {?} ph * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var _this = this; ph.children.forEach(function (child) { return child.visit(_this); }); }; /** * @param {?} ph * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { }; /** * @param {?} ph * @param {?=} context * @return {?} */ RecurseVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { }; return RecurseVisitor; }()); /** * @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 HtmlTagDefinition = /** @class */ (function () { function HtmlTagDefinition(_a) { var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, _c = _b.contentType, contentType = _c === void 0 ? TagContentType.PARSABLE_DATA : _c, _d = _b.closedByParent, closedByParent = _d === void 0 ? false : _d, _e = _b.isVoid, isVoid = _e === void 0 ? false : _e, _f = _b.ignoreFirstLf, ignoreFirstLf = _f === void 0 ? false : _f; var _this = this; this.closedByChildren = {}; this.closedByParent = false; this.canSelfClose = false; if (closedByChildren && closedByChildren.length > 0) { closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; }); } this.isVoid = isVoid; this.closedByParent = closedByParent || isVoid; if (requiredParents && requiredParents.length > 0) { this.requiredParents = {}; // The first parent is the list is automatically when none of the listed parents are present this.parentToAdd = requiredParents[0]; requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; }); } this.implicitNamespacePrefix = implicitNamespacePrefix || null; this.contentType = contentType; this.ignoreFirstLf = ignoreFirstLf; } /** * @param {?} currentParent * @return {?} */ HtmlTagDefinition.prototype.requireExtraParent = /** * @param {?} currentParent * @return {?} */ function (currentParent) { if (!this.requiredParents) { return false; } if (!currentParent) { return true; } var /** @type {?} */ lcParent = currentParent.toLowerCase(); var /** @type {?} */ isParentTemplate = lcParent === 'template' || currentParent === 'ng-template'; return !isParentTemplate && this.requiredParents[lcParent] != true; }; /** * @param {?} name * @return {?} */ HtmlTagDefinition.prototype.isClosedByChild = /** * @param {?} name * @return {?} */ function (name) { return this.isVoid || name.toLowerCase() in this.closedByChildren; }; return HtmlTagDefinition; }()); // see http://www.w3.org/TR/html51/syntax.html#optional-tags // This implementation does not fully conform to the HTML5 spec. var TAG_DEFINITIONS = { 'base': new HtmlTagDefinition({ isVoid: true }), 'meta': new HtmlTagDefinition({ isVoid: true }), 'area': new HtmlTagDefinition({ isVoid: true }), 'embed': new HtmlTagDefinition({ isVoid: true }), 'link': new HtmlTagDefinition({ isVoid: true }), 'img': new HtmlTagDefinition({ isVoid: true }), 'input': new HtmlTagDefinition({ isVoid: true }), 'param': new HtmlTagDefinition({ isVoid: true }), 'hr': new HtmlTagDefinition({ isVoid: true }), 'br': new HtmlTagDefinition({ isVoid: true }), 'source': new HtmlTagDefinition({ isVoid: true }), 'track': new HtmlTagDefinition({ isVoid: true }), 'wbr': new HtmlTagDefinition({ isVoid: true }), 'p': new HtmlTagDefinition({ closedByChildren: [ 'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul' ], closedByParent: true }), 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }), 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }), 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }), 'tr': new HtmlTagDefinition({ closedByChildren: ['tr'], requiredParents: ['tbody', 'tfoot', 'thead'], closedByParent: true }), 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }), 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }), 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }), 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }), 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }), 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }), 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }), 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }), 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }), 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }), 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }), 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }), 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }), 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }), 'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }), 'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }), 'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }), 'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }), }; var _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition(); /** * @param {?} tagName * @return {?} */ function getHtmlTagDefinition(tagName) { return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION; } /** * @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 TAG_TO_PLACEHOLDER_NAMES = { 'A': 'LINK', 'B': 'BOLD_TEXT', 'BR': 'LINE_BREAK', 'EM': 'EMPHASISED_TEXT', 'H1': 'HEADING_LEVEL1', 'H2': 'HEADING_LEVEL2', 'H3': 'HEADING_LEVEL3', 'H4': 'HEADING_LEVEL4', 'H5': 'HEADING_LEVEL5', 'H6': 'HEADING_LEVEL6', 'HR': 'HORIZONTAL_RULE', 'I': 'ITALIC_TEXT', 'LI': 'LIST_ITEM', 'LINK': 'MEDIA_LINK', 'OL': 'ORDERED_LIST', 'P': 'PARAGRAPH', 'Q': 'QUOTATION', 'S': 'STRIKETHROUGH_TEXT', 'SMALL': 'SMALL_TEXT', 'SUB': 'SUBSTRIPT', 'SUP': 'SUPERSCRIPT', 'TBODY': 'TABLE_BODY', 'TD': 'TABLE_CELL', 'TFOOT': 'TABLE_FOOTER', 'TH': 'TABLE_HEADER_CELL', 'THEAD': 'TABLE_HEADER', 'TR': 'TABLE_ROW', 'TT': 'MONOSPACED_TEXT', 'U': 'UNDERLINED_TEXT', 'UL': 'UNORDERED_LIST', }; /** * Creates unique names for placeholder with different content. * * Returns the same placeholder name when the content is identical. */ var PlaceholderRegistry = /** @class */ (function () { function PlaceholderRegistry() { this._placeHolderNameCounts = {}; this._signatureToName = {}; } /** * @param {?} tag * @param {?} attrs * @param {?} isVoid * @return {?} */ PlaceholderRegistry.prototype.getStartTagPlaceholderName = /** * @param {?} tag * @param {?} attrs * @param {?} isVoid * @return {?} */ function (tag, attrs, isVoid) { var /** @type {?} */ signature = this._hashTag(tag, attrs, isVoid); if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var /** @type {?} */ upperTag = tag.toUpperCase(); var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag; var /** @type {?} */ name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName); this._signatureToName[signature] = name; return name; }; /** * @param {?} tag * @return {?} */ PlaceholderRegistry.prototype.getCloseTagPlaceholderName = /** * @param {?} tag * @return {?} */ function (tag) { var /** @type {?} */ signature = this._hashClosingTag(tag); if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var /** @type {?} */ upperTag = tag.toUpperCase(); var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag; var /** @type {?} */ name = this._generateUniqueName("CLOSE_" + baseName); this._signatureToName[signature] = name; return name; }; /** * @param {?} name * @param {?} content * @return {?} */ PlaceholderRegistry.prototype.getPlaceholderName = /** * @param {?} name * @param {?} content * @return {?} */ function (name, content) { var /** @type {?} */ upperName = name.toUpperCase(); var /** @type {?} */ signature = "PH: " + upperName + "=" + content; if (this._signatureToName[signature]) { return this._signatureToName[signature]; } var /** @type {?} */ uniqueName = this._generateUniqueName(upperName); this._signatureToName[signature] = uniqueName; return uniqueName; }; /** * @param {?} name * @return {?} */ PlaceholderRegistry.prototype.getUniquePlaceholder = /** * @param {?} name * @return {?} */ function (name) { return this._generateUniqueName(name.toUpperCase()); }; /** * @param {?} tag * @param {?} attrs * @param {?} isVoid * @return {?} */ PlaceholderRegistry.prototype._hashTag = /** * @param {?} tag * @param {?} attrs * @param {?} isVoid * @return {?} */ function (tag, attrs, isVoid) { var /** @type {?} */ start = "<" + tag; var /** @type {?} */ strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join(''); var /** @type {?} */ end = isVoid ? '/>' : ">"; return start + strAttrs + end; }; /** * @param {?} tag * @return {?} */ PlaceholderRegistry.prototype._hashClosingTag = /** * @param {?} tag * @return {?} */ function (tag) { return this._hashTag("/" + tag, {}, false); }; /** * @param {?} base * @return {?} */ PlaceholderRegistry.prototype._generateUniqueName = /** * @param {?} base * @return {?} */ function (base) { var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base); if (!seen) { this._placeHolderNameCounts[base] = 1; return base; } var /** @type {?} */ id = this._placeHolderNameCounts[base]; this._placeHolderNameCounts[base] = id + 1; return base + "_" + id; }; return PlaceholderRegistry; }()); /** * @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 _expParser = new Parser(new Lexer()); /** * Returns a function converting html nodes to an i18n Message given an interpolationConfig * @param {?} interpolationConfig * @return {?} */ function createI18nMessageFactory(interpolationConfig) { var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig); return function (nodes, meaning, description, id) { return visitor.toI18nMessage(nodes, meaning, description, id); }; } var _I18nVisitor = /** @class */ (function () { function _I18nVisitor(_expressionParser, _interpolationConfig) { this._expressionParser = _expressionParser; this._interpolationConfig = _interpolationConfig; } /** * @param {?} nodes * @param {?} meaning * @param {?} description * @param {?} id * @return {?} */ _I18nVisitor.prototype.toI18nMessage = /** * @param {?} nodes * @param {?} meaning * @param {?} description * @param {?} id * @return {?} */ function (nodes, meaning, description, id) { this._isIcu = nodes.length == 1 && nodes[0] instanceof Expansion; this._icuDepth = 0; this._placeholderRegistry = new PlaceholderRegistry(); this._placeholderToContent = {}; this._placeholderToMessage = {}; var /** @type {?} */ i18nodes = visitAll(this, nodes, {}); return new Message(i18nodes, this._placeholderToContent, this._placeholderToMessage, meaning, description, id); }; /** * @param {?} el * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitElement = /** * @param {?} el * @param {?} context * @return {?} */ function (el, context) { var /** @type {?} */ children = visitAll(this, el.children); var /** @type {?} */ attrs = {}; el.attrs.forEach(function (attr) { // Do not visit the attributes, translatable ones are top-level ASTs attrs[attr.name] = attr.value; }); var /** @type {?} */ isVoid = getHtmlTagDefinition(el.name).isVoid; var /** @type {?} */ startPhName = this._placeholderRegistry.getStartTagPlaceholderName(el.name, attrs, isVoid); this._placeholderToContent[startPhName] = /** @type {?} */ ((el.sourceSpan)).toString(); var /** @type {?} */ closePhName = ''; if (!isVoid) { closePhName = this._placeholderRegistry.getCloseTagPlaceholderName(el.name); this._placeholderToContent[closePhName] = ""; } return new TagPlaceholder(el.name, attrs, startPhName, closePhName, children, isVoid, /** @type {?} */ ((el.sourceSpan))); }; /** * @param {?} attribute * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { return this._visitTextWithInterpolation(attribute.value, attribute.sourceSpan); }; /** * @param {?} text * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return this._visitTextWithInterpolation(text.value, /** @type {?} */ ((text.sourceSpan))); }; /** * @param {?} comment * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { return null; }; /** * @param {?} icu * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var _this = this; this._icuDepth++; var /** @type {?} */ i18nIcuCases = {}; var /** @type {?} */ i18nIcu = new Icu(icu.switchValue, icu.type, i18nIcuCases, icu.sourceSpan); icu.cases.forEach(function (caze) { i18nIcuCases[caze.value] = new Container(caze.expression.map(function (node) { return node.visit(_this, {}); }), caze.expSourceSpan); }); this._icuDepth--; if (this._isIcu || this._icuDepth > 0) { // Returns an ICU node when: // - the message (vs a part of the message) is an ICU message, or // - the ICU message is nested. var /** @type {?} */ expPh = this._placeholderRegistry.getUniquePlaceholder("VAR_" + icu.type); i18nIcu.expressionPlaceholder = expPh; this._placeholderToContent[expPh] = icu.switchValue; return i18nIcu; } // Else returns a placeholder // ICU placeholders should not be replaced with their original content but with the their // translations. We need to create a new visitor (they are not re-entrant) to compute the // message id. // TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString()); var /** @type {?} */ visitor = new _I18nVisitor(this._expressionParser, this._interpolationConfig); this._placeholderToMessage[phName] = visitor.toI18nMessage([icu], '', '', ''); return new IcuPlaceholder(i18nIcu, phName, icu.sourceSpan); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ _I18nVisitor.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { throw new Error('Unreachable code'); }; /** * @param {?} text * @param {?} sourceSpan * @return {?} */ _I18nVisitor.prototype._visitTextWithInterpolation = /** * @param {?} text * @param {?} sourceSpan * @return {?} */ function (text, sourceSpan) { var /** @type {?} */ splitInterpolation = this._expressionParser.splitInterpolation(text, sourceSpan.start.toString(), this._interpolationConfig); if (!splitInterpolation) { // No expression, return a single text return new Text$1(text, sourceSpan); } // Return a group of text + expressions var /** @type {?} */ nodes = []; var /** @type {?} */ container = new Container(nodes, sourceSpan); var _a = this._interpolationConfig, sDelimiter = _a.start, eDelimiter = _a.end; for (var /** @type {?} */ i = 0; i < splitInterpolation.strings.length - 1; i++) { var /** @type {?} */ expression = splitInterpolation.expressions[i]; var /** @type {?} */ baseName = _extractPlaceholderName(expression) || 'INTERPOLATION'; var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName(baseName, expression); if (splitInterpolation.strings[i].length) { // No need to add empty strings nodes.push(new Text$1(splitInterpolation.strings[i], sourceSpan)); } nodes.push(new Placeholder(expression, phName, sourceSpan)); this._placeholderToContent[phName] = sDelimiter + expression + eDelimiter; } // The last index contains no expression var /** @type {?} */ lastStringIdx = splitInterpolation.strings.length - 1; if (splitInterpolation.strings[lastStringIdx].length) { nodes.push(new Text$1(splitInterpolation.strings[lastStringIdx], sourceSpan)); } return container; }; return _I18nVisitor; }()); var _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g; /** * @param {?} input * @return {?} */ function _extractPlaceholderName(input) { return input.split(_CUSTOM_PH_EXP)[2]; } /** * @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 i18n error. */ var I18nError = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(I18nError, _super); function I18nError(span, msg) { return _super.call(this, span, msg) || this; } return I18nError; }(ParseError)); /** * @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 _I18N_ATTR = 'i18n'; var _I18N_ATTR_PREFIX = 'i18n-'; var _I18N_COMMENT_PREFIX_REGEXP = /^i18n:?/; var MEANING_SEPARATOR = '|'; var ID_SEPARATOR = '@@'; var i18nCommentsWarned = false; /** * Extract translatable messages from an html AST * @param {?} nodes * @param {?} interpolationConfig * @param {?} implicitTags * @param {?} implicitAttrs * @return {?} */ function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) { var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs); return visitor.extract(nodes, interpolationConfig); } /** * @param {?} nodes * @param {?} translations * @param {?} interpolationConfig * @param {?} implicitTags * @param {?} implicitAttrs * @return {?} */ function mergeTranslations(nodes, translations, interpolationConfig, implicitTags, implicitAttrs) { var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs); return visitor.merge(nodes, translations, interpolationConfig); } var ExtractionResult = /** @class */ (function () { function ExtractionResult(messages, errors) { this.messages = messages; this.errors = errors; } return ExtractionResult; }()); /** @enum {number} */ var _VisitorMode = { Extract: 0, Merge: 1, }; _VisitorMode[_VisitorMode.Extract] = "Extract"; _VisitorMode[_VisitorMode.Merge] = "Merge"; /** * This Visitor is used: * 1. to extract all the translatable strings from an html AST (see `extract()`), * 2. to replace the translatable strings with the actual translations (see `merge()`) * * \@internal */ var _Visitor = /** @class */ (function () { function _Visitor(_implicitTags, _implicitAttrs) { this._implicitTags = _implicitTags; this._implicitAttrs = _implicitAttrs; } /** * Extracts the messages from the tree */ /** * Extracts the messages from the tree * @param {?} nodes * @param {?} interpolationConfig * @return {?} */ _Visitor.prototype.extract = /** * Extracts the messages from the tree * @param {?} nodes * @param {?} interpolationConfig * @return {?} */ function (nodes, interpolationConfig) { var _this = this; this._init(_VisitorMode.Extract, interpolationConfig); nodes.forEach(function (node) { return node.visit(_this, null); }); if (this._inI18nBlock) { this._reportError(nodes[nodes.length - 1], 'Unclosed block'); } return new ExtractionResult(this._messages, this._errors); }; /** * Returns a tree where all translatable nodes are translated */ /** * Returns a tree where all translatable nodes are translated * @param {?} nodes * @param {?} translations * @param {?} interpolationConfig * @return {?} */ _Visitor.prototype.merge = /** * Returns a tree where all translatable nodes are translated * @param {?} nodes * @param {?} translations * @param {?} interpolationConfig * @return {?} */ function (nodes, translations, interpolationConfig) { this._init(_VisitorMode.Merge, interpolationConfig); this._translations = translations; // Construct a single fake root element var /** @type {?} */ wrapper = new Element('wrapper', [], nodes, /** @type {?} */ ((undefined)), undefined, undefined); var /** @type {?} */ translatedNode = wrapper.visit(this, null); if (this._inI18nBlock) { this._reportError(nodes[nodes.length - 1], 'Unclosed block'); } return new ParseTreeResult(translatedNode.children, this._errors); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ _Visitor.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { // Parse cases for translatable html attributes var /** @type {?} */ expression = visitAll(this, icuCase.expression, context); if (this._mode === _VisitorMode.Merge) { return new ExpansionCase(icuCase.value, expression, icuCase.sourceSpan, icuCase.valueSourceSpan, icuCase.expSourceSpan); } }; /** * @param {?} icu * @param {?} context * @return {?} */ _Visitor.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { this._mayBeAddBlockChildren(icu); var /** @type {?} */ wasInIcu = this._inIcu; if (!this._inIcu) { // nested ICU messages should not be extracted but top-level translated as a whole if (this._isInTranslatableSection) { this._addMessage([icu]); } this._inIcu = true; } var /** @type {?} */ cases = visitAll(this, icu.cases, context); if (this._mode === _VisitorMode.Merge) { icu = new Expansion(icu.switchValue, icu.type, cases, icu.sourceSpan, icu.switchValueSourceSpan); } this._inIcu = wasInIcu; return icu; }; /** * @param {?} comment * @param {?} context * @return {?} */ _Visitor.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { var /** @type {?} */ isOpening = _isOpeningComment(comment); if (isOpening && this._isInTranslatableSection) { this._reportError(comment, 'Could not start a block inside a translatable section'); return; } var /** @type {?} */ isClosing = _isClosingComment(comment); if (isClosing && !this._inI18nBlock) { this._reportError(comment, 'Trying to close an unopened block'); return; } if (!this._inI18nNode && !this._inIcu) { if (!this._inI18nBlock) { if (isOpening) { // deprecated from v5 you should use instead of i18n comments if (!i18nCommentsWarned && /** @type {?} */ (console) && /** @type {?} */ (console.warn)) { i18nCommentsWarned = true; var /** @type {?} */ details = comment.sourceSpan.details ? ", " + comment.sourceSpan.details : ''; // TODO(ocombe): use a log service once there is a public one available console.warn("I18n comments are deprecated, use an element instead (" + comment.sourceSpan.start + details + ")"); } this._inI18nBlock = true; this._blockStartDepth = this._depth; this._blockChildren = []; this._blockMeaningAndDesc = /** @type {?} */ ((comment.value)).replace(_I18N_COMMENT_PREFIX_REGEXP, '').trim(); this._openTranslatableSection(comment); } } else { if (isClosing) { if (this._depth == this._blockStartDepth) { this._closeTranslatableSection(comment, this._blockChildren); this._inI18nBlock = false; var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(this._blockChildren, this._blockMeaningAndDesc))); // merge attributes in sections var /** @type {?} */ nodes = this._translateMessage(comment, message); return visitAll(this, nodes); } else { this._reportError(comment, 'I18N blocks should not cross element boundaries'); return; } } } } }; /** * @param {?} text * @param {?} context * @return {?} */ _Visitor.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { if (this._isInTranslatableSection) { this._mayBeAddBlockChildren(text); } return text; }; /** * @param {?} el * @param {?} context * @return {?} */ _Visitor.prototype.visitElement = /** * @param {?} el * @param {?} context * @return {?} */ function (el, context) { var _this = this; this._mayBeAddBlockChildren(el); this._depth++; var /** @type {?} */ wasInI18nNode = this._inI18nNode; var /** @type {?} */ wasInImplicitNode = this._inImplicitNode; var /** @type {?} */ childNodes = []; var /** @type {?} */ translatedChildNodes = /** @type {?} */ ((undefined)); // Extract: // - top level nodes with the (implicit) "i18n" attribute if not already in a section // - ICU messages var /** @type {?} */ i18nAttr = _getI18nAttr(el); var /** @type {?} */ i18nMeta = i18nAttr ? i18nAttr.value : ''; var /** @type {?} */ isImplicit = this._implicitTags.some(function (tag) { return el.name === tag; }) && !this._inIcu && !this._isInTranslatableSection; var /** @type {?} */ isTopLevelImplicit = !wasInImplicitNode && isImplicit; this._inImplicitNode = wasInImplicitNode || isImplicit; if (!this._isInTranslatableSection && !this._inIcu) { if (i18nAttr || isTopLevelImplicit) { this._inI18nNode = true; var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(el.children, i18nMeta))); translatedChildNodes = this._translateMessage(el, message); } if (this._mode == _VisitorMode.Extract) { var /** @type {?} */ isTranslatable = i18nAttr || isTopLevelImplicit; if (isTranslatable) this._openTranslatableSection(el); visitAll(this, el.children); if (isTranslatable) this._closeTranslatableSection(el, el.children); } } else { if (i18nAttr || isTopLevelImplicit) { this._reportError(el, 'Could not mark an element as translatable inside a translatable section'); } if (this._mode == _VisitorMode.Extract) { // Descend into child nodes for extraction visitAll(this, el.children); } } if (this._mode === _VisitorMode.Merge) { var /** @type {?} */ visitNodes = translatedChildNodes || el.children; visitNodes.forEach(function (child) { var /** @type {?} */ visited = child.visit(_this, context); if (visited && !_this._isInTranslatableSection) { // Do not add the children from translatable sections (= i18n blocks here) // They will be added later in this loop when the block closes (i.e. on ``) childNodes = childNodes.concat(visited); } }); } this._visitAttributesOf(el); this._depth--; this._inI18nNode = wasInI18nNode; this._inImplicitNode = wasInImplicitNode; if (this._mode === _VisitorMode.Merge) { var /** @type {?} */ translatedAttrs = this._translateAttributes(el); return new Element(el.name, translatedAttrs, childNodes, el.sourceSpan, el.startSourceSpan, el.endSourceSpan); } return null; }; /** * @param {?} attribute * @param {?} context * @return {?} */ _Visitor.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { throw new Error('unreachable code'); }; /** * @param {?} mode * @param {?} interpolationConfig * @return {?} */ _Visitor.prototype._init = /** * @param {?} mode * @param {?} interpolationConfig * @return {?} */ function (mode, interpolationConfig) { this._mode = mode; this._inI18nBlock = false; this._inI18nNode = false; this._depth = 0; this._inIcu = false; this._msgCountAtSectionStart = undefined; this._errors = []; this._messages = []; this._inImplicitNode = false; this._createI18nMessage = createI18nMessageFactory(interpolationConfig); }; /** * @param {?} el * @return {?} */ _Visitor.prototype._visitAttributesOf = /** * @param {?} el * @return {?} */ function (el) { var _this = this; var /** @type {?} */ explicitAttrNameToValue = {}; var /** @type {?} */ implicitAttrNames = this._implicitAttrs[el.name] || []; el.attrs.filter(function (attr) { return attr.name.startsWith(_I18N_ATTR_PREFIX); }) .forEach(function (attr) { return explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] = attr.value; }); el.attrs.forEach(function (attr) { if (attr.name in explicitAttrNameToValue) { _this._addMessage([attr], explicitAttrNameToValue[attr.name]); } else if (implicitAttrNames.some(function (name) { return attr.name === name; })) { _this._addMessage([attr]); } }); }; /** * @param {?} ast * @param {?=} msgMeta * @return {?} */ _Visitor.prototype._addMessage = /** * @param {?} ast * @param {?=} msgMeta * @return {?} */ function (ast, msgMeta) { if (ast.length == 0 || ast.length == 1 && ast[0] instanceof Attribute$1 && !(/** @type {?} */ (ast[0])).value) { // Do not create empty messages return null; } var _a = _parseMessageMeta(msgMeta), meaning = _a.meaning, description = _a.description, id = _a.id; var /** @type {?} */ message = this._createI18nMessage(ast, meaning, description, id); this._messages.push(message); return message; }; /** * @param {?} el * @param {?} message * @return {?} */ _Visitor.prototype._translateMessage = /** * @param {?} el * @param {?} message * @return {?} */ function (el, message) { if (message && this._mode === _VisitorMode.Merge) { var /** @type {?} */ nodes = this._translations.get(message); if (nodes) { return nodes; } this._reportError(el, "Translation unavailable for message id=\"" + this._translations.digest(message) + "\""); } return []; }; /** * @param {?} el * @return {?} */ _Visitor.prototype._translateAttributes = /** * @param {?} el * @return {?} */ function (el) { var _this = this; var /** @type {?} */ attributes = el.attrs; var /** @type {?} */ i18nParsedMessageMeta = {}; attributes.forEach(function (attr) { if (attr.name.startsWith(_I18N_ATTR_PREFIX)) { i18nParsedMessageMeta[attr.name.slice(_I18N_ATTR_PREFIX.length)] = _parseMessageMeta(attr.value); } }); var /** @type {?} */ translatedAttributes = []; attributes.forEach(function (attr) { if (attr.name === _I18N_ATTR || attr.name.startsWith(_I18N_ATTR_PREFIX)) { // strip i18n specific attributes return; } if (attr.value && attr.value != '' && i18nParsedMessageMeta.hasOwnProperty(attr.name)) { var _a = i18nParsedMessageMeta[attr.name], meaning = _a.meaning, description = _a.description, id = _a.id; var /** @type {?} */ message = _this._createI18nMessage([attr], meaning, description, id); var /** @type {?} */ nodes = _this._translations.get(message); if (nodes) { if (nodes.length == 0) { translatedAttributes.push(new Attribute$1(attr.name, '', attr.sourceSpan)); } else if (nodes[0] instanceof Text) { var /** @type {?} */ value = (/** @type {?} */ (nodes[0])).value; translatedAttributes.push(new Attribute$1(attr.name, value, attr.sourceSpan)); } else { _this._reportError(el, "Unexpected translation for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")"); } } else { _this._reportError(el, "Translation unavailable for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")"); } } else { translatedAttributes.push(attr); } }); return translatedAttributes; }; /** * Add the node as a child of the block when: * - we are in a block, * - we are not inside a ICU message (those are handled separately), * - the node is a "direct child" of the block * @param {?} node * @return {?} */ _Visitor.prototype._mayBeAddBlockChildren = /** * Add the node as a child of the block when: * - we are in a block, * - we are not inside a ICU message (those are handled separately), * - the node is a "direct child" of the block * @param {?} node * @return {?} */ function (node) { if (this._inI18nBlock && !this._inIcu && this._depth == this._blockStartDepth) { this._blockChildren.push(node); } }; /** * Marks the start of a section, see `_closeTranslatableSection` * @param {?} node * @return {?} */ _Visitor.prototype._openTranslatableSection = /** * Marks the start of a section, see `_closeTranslatableSection` * @param {?} node * @return {?} */ function (node) { if (this._isInTranslatableSection) { this._reportError(node, 'Unexpected section start'); } else { this._msgCountAtSectionStart = this._messages.length; } }; Object.defineProperty(_Visitor.prototype, "_isInTranslatableSection", { get: /** * A translatable section could be: * - the content of translatable element, * - nodes between `` and `` comments * @return {?} */ function () { return this._msgCountAtSectionStart !== void 0; }, enumerable: true, configurable: true }); /** * Terminates a section. * * If a section has only one significant children (comments not significant) then we should not * keep the message from this children: * * `

    {ICU message}

    ` would produce two messages: * - one for the

    content with meaning and description, * - another one for the ICU message. * * In this case the last message is discarded as it contains less information (the AST is * otherwise identical). * * Note that we should still keep messages extracted from attributes inside the section (ie in the * ICU message here) * @param {?} node * @param {?} directChildren * @return {?} */ _Visitor.prototype._closeTranslatableSection = /** * Terminates a section. * * If a section has only one significant children (comments not significant) then we should not * keep the message from this children: * * `

    {ICU message}

    ` would produce two messages: * - one for the

    content with meaning and description, * - another one for the ICU message. * * In this case the last message is discarded as it contains less information (the AST is * otherwise identical). * * Note that we should still keep messages extracted from attributes inside the section (ie in the * ICU message here) * @param {?} node * @param {?} directChildren * @return {?} */ function (node, directChildren) { if (!this._isInTranslatableSection) { this._reportError(node, 'Unexpected section end'); return; } var /** @type {?} */ startIndex = this._msgCountAtSectionStart; var /** @type {?} */ significantChildren = directChildren.reduce(function (count, node) { return count + (node instanceof Comment ? 0 : 1); }, 0); if (significantChildren == 1) { for (var /** @type {?} */ i = this._messages.length - 1; i >= /** @type {?} */ ((startIndex)); i--) { var /** @type {?} */ ast = this._messages[i].nodes; if (!(ast.length == 1 && ast[0] instanceof Text$1)) { this._messages.splice(i, 1); break; } } } this._msgCountAtSectionStart = undefined; }; /** * @param {?} node * @param {?} msg * @return {?} */ _Visitor.prototype._reportError = /** * @param {?} node * @param {?} msg * @return {?} */ function (node, msg) { this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), msg)); }; return _Visitor; }()); /** * @param {?} n * @return {?} */ function _isOpeningComment(n) { return !!(n instanceof Comment && n.value && n.value.startsWith('i18n')); } /** * @param {?} n * @return {?} */ function _isClosingComment(n) { return !!(n instanceof Comment && n.value && n.value === '/i18n'); } /** * @param {?} p * @return {?} */ function _getI18nAttr(p) { return p.attrs.find(function (attr) { return attr.name === _I18N_ATTR; }) || null; } /** * @param {?=} i18n * @return {?} */ function _parseMessageMeta(i18n) { if (!i18n) return { meaning: '', description: '', id: '' }; var /** @type {?} */ idIndex = i18n.indexOf(ID_SEPARATOR); var /** @type {?} */ descIndex = i18n.indexOf(MEANING_SEPARATOR); var _a = (idIndex > -1) ? [i18n.slice(0, idIndex), i18n.slice(idIndex + 2)] : [i18n, ''], meaningAndDesc = _a[0], id = _a[1]; var _b = (descIndex > -1) ? [meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] : ['', meaningAndDesc], meaning = _b[0], description = _b[1]; return { meaning: meaning, description: description, id: 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 */ var XmlTagDefinition = /** @class */ (function () { function XmlTagDefinition() { this.closedByParent = false; this.contentType = TagContentType.PARSABLE_DATA; this.isVoid = false; this.ignoreFirstLf = false; this.canSelfClose = true; } /** * @param {?} currentParent * @return {?} */ XmlTagDefinition.prototype.requireExtraParent = /** * @param {?} currentParent * @return {?} */ function (currentParent) { return false; }; /** * @param {?} name * @return {?} */ XmlTagDefinition.prototype.isClosedByChild = /** * @param {?} name * @return {?} */ function (name) { return false; }; return XmlTagDefinition; }()); var _TAG_DEFINITION = new XmlTagDefinition(); /** * @param {?} tagName * @return {?} */ function getXmlTagDefinition(tagName) { return _TAG_DEFINITION; } /** * @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 XmlParser = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(XmlParser, _super); function XmlParser() { return _super.call(this, getXmlTagDefinition) || this; } /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @return {?} */ XmlParser.prototype.parse = /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @return {?} */ function (source, url, parseExpansionForms) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } return _super.prototype.parse.call(this, source, url, parseExpansionForms); }; return XmlParser; }(Parser$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 */ /** * @abstract */ var Serializer = /** @class */ (function () { function Serializer() { } // Creates a name mapper, see `PlaceholderMapper` // Returning `null` means that no name mapping is used. /** * @param {?} message * @return {?} */ Serializer.prototype.createNameMapper = /** * @param {?} message * @return {?} */ function (message) { return null; }; return Serializer; }()); /** * A `PlaceholderMapper` converts placeholder names from internal to serialized representation and * back. * * It should be used for serialization format that put constraints on the placeholder names. * @record */ /** * A simple mapper that take a function to transform an internal name to a public name */ var SimplePlaceholderMapper = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(SimplePlaceholderMapper, _super); // create a mapping from the message function SimplePlaceholderMapper(message, mapName) { var _this = _super.call(this) || this; _this.mapName = mapName; _this.internalToPublic = {}; _this.publicToNextId = {}; _this.publicToInternal = {}; message.nodes.forEach(function (node) { return node.visit(_this); }); return _this; } /** * @param {?} internalName * @return {?} */ SimplePlaceholderMapper.prototype.toPublicName = /** * @param {?} internalName * @return {?} */ function (internalName) { return this.internalToPublic.hasOwnProperty(internalName) ? this.internalToPublic[internalName] : null; }; /** * @param {?} publicName * @return {?} */ SimplePlaceholderMapper.prototype.toInternalName = /** * @param {?} publicName * @return {?} */ function (publicName) { return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] : null; }; /** * @param {?} text * @param {?=} context * @return {?} */ SimplePlaceholderMapper.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return null; }; /** * @param {?} ph * @param {?=} context * @return {?} */ SimplePlaceholderMapper.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { this.visitPlaceholderName(ph.startName); _super.prototype.visitTagPlaceholder.call(this, ph, context); this.visitPlaceholderName(ph.closeName); }; /** * @param {?} ph * @param {?=} context * @return {?} */ SimplePlaceholderMapper.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { this.visitPlaceholderName(ph.name); }; /** * @param {?} ph * @param {?=} context * @return {?} */ SimplePlaceholderMapper.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { this.visitPlaceholderName(ph.name); }; /** * @param {?} internalName * @return {?} */ SimplePlaceholderMapper.prototype.visitPlaceholderName = /** * @param {?} internalName * @return {?} */ function (internalName) { if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) { return; } var /** @type {?} */ publicName = this.mapName(internalName); if (this.publicToInternal.hasOwnProperty(publicName)) { // Create a new XMB when it has already been used var /** @type {?} */ nextId = this.publicToNextId[publicName]; this.publicToNextId[publicName] = nextId + 1; publicName = publicName + "_" + nextId; } else { this.publicToNextId[publicName] = 1; } this.internalToPublic[internalName] = publicName; this.publicToInternal[publicName] = internalName; }; return SimplePlaceholderMapper; }(RecurseVisitor)); /** * @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 */ var _Visitor$1 = /** @class */ (function () { function _Visitor() { } /** * @param {?} tag * @return {?} */ _Visitor.prototype.visitTag = /** * @param {?} tag * @return {?} */ function (tag) { var _this = this; var /** @type {?} */ strAttrs = this._serializeAttributes(tag.attrs); if (tag.children.length == 0) { return "<" + tag.name + strAttrs + "/>"; } var /** @type {?} */ strChildren = tag.children.map(function (node) { return node.visit(_this); }); return "<" + tag.name + strAttrs + ">" + strChildren.join('') + ""; }; /** * @param {?} text * @return {?} */ _Visitor.prototype.visitText = /** * @param {?} text * @return {?} */ function (text) { return text.value; }; /** * @param {?} decl * @return {?} */ _Visitor.prototype.visitDeclaration = /** * @param {?} decl * @return {?} */ function (decl) { return ""; }; /** * @param {?} attrs * @return {?} */ _Visitor.prototype._serializeAttributes = /** * @param {?} attrs * @return {?} */ function (attrs) { var /** @type {?} */ strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' '); return strAttrs.length > 0 ? ' ' + strAttrs : ''; }; /** * @param {?} doctype * @return {?} */ _Visitor.prototype.visitDoctype = /** * @param {?} doctype * @return {?} */ function (doctype) { return ""; }; return _Visitor; }()); var _visitor = new _Visitor$1(); /** * @param {?} nodes * @return {?} */ function serialize(nodes) { return nodes.map(function (node) { return node.visit(_visitor); }).join(''); } /** * @record */ var Declaration = /** @class */ (function () { function Declaration(unescapedAttrs) { var _this = this; this.attrs = {}; Object.keys(unescapedAttrs).forEach(function (k) { _this.attrs[k] = _escapeXml(unescapedAttrs[k]); }); } /** * @param {?} visitor * @return {?} */ Declaration.prototype.visit = /** * @param {?} visitor * @return {?} */ function (visitor) { return visitor.visitDeclaration(this); }; return Declaration; }()); var Doctype = /** @class */ (function () { function Doctype(rootTag, dtd) { this.rootTag = rootTag; this.dtd = dtd; } /** * @param {?} visitor * @return {?} */ Doctype.prototype.visit = /** * @param {?} visitor * @return {?} */ function (visitor) { return visitor.visitDoctype(this); }; return Doctype; }()); var Tag = /** @class */ (function () { function Tag(name, unescapedAttrs, children) { if (unescapedAttrs === void 0) { unescapedAttrs = {}; } if (children === void 0) { children = []; } var _this = this; this.name = name; this.children = children; this.attrs = {}; Object.keys(unescapedAttrs).forEach(function (k) { _this.attrs[k] = _escapeXml(unescapedAttrs[k]); }); } /** * @param {?} visitor * @return {?} */ Tag.prototype.visit = /** * @param {?} visitor * @return {?} */ function (visitor) { return visitor.visitTag(this); }; return Tag; }()); var Text$2 = /** @class */ (function () { function Text(unescapedValue) { this.value = _escapeXml(unescapedValue); } /** * @param {?} visitor * @return {?} */ Text.prototype.visit = /** * @param {?} visitor * @return {?} */ function (visitor) { return visitor.visitText(this); }; return Text; }()); var CR = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(CR, _super); function CR(ws) { if (ws === void 0) { ws = 0; } return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this; } return CR; }(Text$2)); var _ESCAPED_CHARS = [ [/&/g, '&'], [/"/g, '"'], [/'/g, '''], [//g, '>'], ]; /** * @param {?} text * @return {?} */ function _escapeXml(text) { return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text); } /** * @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 _VERSION = '1.2'; var _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2'; // TODO(vicb): make this a param (s/_/-/) var _DEFAULT_SOURCE_LANG = 'en'; var _PLACEHOLDER_TAG = 'x'; var _MARKER_TAG = 'mrk'; var _FILE_TAG = 'file'; var _SOURCE_TAG = 'source'; var _SEGMENT_SOURCE_TAG = 'seg-source'; var _TARGET_TAG = 'target'; var _UNIT_TAG = 'trans-unit'; var _CONTEXT_GROUP_TAG = 'context-group'; var _CONTEXT_TAG = 'context'; var Xliff = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Xliff, _super); function Xliff() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} messages * @param {?} locale * @return {?} */ Xliff.prototype.write = /** * @param {?} messages * @param {?} locale * @return {?} */ function (messages, locale) { var /** @type {?} */ visitor = new _WriteVisitor(); var /** @type {?} */ transUnits = []; messages.forEach(function (message) { var /** @type {?} */ contextTags = []; message.sources.forEach(function (source) { var /** @type {?} */ contextGroupTag = new Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' }); contextGroupTag.children.push(new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [new Text$2(source.filePath)]), new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [new Text$2("" + source.startLine)]), new CR(8)); contextTags.push(new CR(8), contextGroupTag); }); var /** @type {?} */ transUnit = new Tag(_UNIT_TAG, { id: message.id, datatype: 'html' }); (_a = transUnit.children).push.apply(_a, [new CR(8), new Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes))].concat(contextTags)); if (message.description) { transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'description' }, [new Text$2(message.description)])); } if (message.meaning) { transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'meaning' }, [new Text$2(message.meaning)])); } transUnit.children.push(new CR(6)); transUnits.push(new CR(6), transUnit); var _a; }); var /** @type {?} */ body = new Tag('body', {}, transUnits.concat([new CR(4)])); var /** @type {?} */ file = new Tag('file', { 'source-language': locale || _DEFAULT_SOURCE_LANG, datatype: 'plaintext', original: 'ng2.template', }, [new CR(4), body, new CR(2)]); var /** @type {?} */ xliff = new Tag('xliff', { version: _VERSION, xmlns: _XMLNS }, [new CR(2), file, new CR()]); return serialize([ new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR() ]); }; /** * @param {?} content * @param {?} url * @return {?} */ Xliff.prototype.load = /** * @param {?} content * @param {?} url * @return {?} */ function (content, url) { // xliff to xml nodes var /** @type {?} */ xliffParser = new XliffParser(); var _a = xliffParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors; // xml nodes to i18n nodes var /** @type {?} */ i18nNodesByMsgId = {}; var /** @type {?} */ converter = new XmlToI18n(); Object.keys(msgIdToHtml).forEach(function (msgId) { var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors; errors.push.apply(errors, e); i18nNodesByMsgId[msgId] = i18nNodes; }); if (errors.length) { throw new Error("xliff parse errors:\n" + errors.join('\n')); } return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId }; }; /** * @param {?} message * @return {?} */ Xliff.prototype.digest = /** * @param {?} message * @return {?} */ function (message) { return digest(message); }; return Xliff; }(Serializer)); var _WriteVisitor = /** @class */ (function () { function _WriteVisitor() { } /** * @param {?} text * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return [new Text$2(text.value)]; }; /** * @param {?} container * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitContainer = /** * @param {?} container * @param {?=} context * @return {?} */ function (container, context) { var _this = this; var /** @type {?} */ nodes = []; container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); }); return nodes; }; /** * @param {?} icu * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")]; Object.keys(icu.cases).forEach(function (c) { nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")])); }); nodes.push(new Text$2("}")); return nodes; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ ctype = getCtypeForTag(ph.tag); if (ph.isVoid) { // void tags have no children nor closing tags return [new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + "/>" })]; } var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + ">" }); var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.closeName, ctype: ctype, 'equiv-text': "" }); return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]); }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': "{{" + ph.value + "}}" })]; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ equivText = "{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}"; return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': equivText })]; }; /** * @param {?} nodes * @return {?} */ _WriteVisitor.prototype.serialize = /** * @param {?} nodes * @return {?} */ function (nodes) { var _this = this; return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); })); }; return _WriteVisitor; }()); var XliffParser = /** @class */ (function () { function XliffParser() { this._locale = null; } /** * @param {?} xliff * @param {?} url * @return {?} */ XliffParser.prototype.parse = /** * @param {?} xliff * @param {?} url * @return {?} */ function (xliff, url) { this._unitMlString = null; this._msgIdToHtml = {}; var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false); this._errors = xml.errors; visitAll(this, xml.rootNodes, null); return { msgIdToHtml: this._msgIdToHtml, errors: this._errors, locale: this._locale, }; }; /** * @param {?} element * @param {?} context * @return {?} */ XliffParser.prototype.visitElement = /** * @param {?} element * @param {?} context * @return {?} */ function (element, context) { switch (element.name) { case _UNIT_TAG: this._unitMlString = /** @type {?} */ ((null)); var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; }); if (!idAttr) { this._addError(element, "<" + _UNIT_TAG + "> misses the \"id\" attribute"); } else { var /** @type {?} */ id = idAttr.value; if (this._msgIdToHtml.hasOwnProperty(id)) { this._addError(element, "Duplicated translations for msg " + id); } else { visitAll(this, element.children, null); if (typeof this._unitMlString === 'string') { this._msgIdToHtml[id] = this._unitMlString; } else { this._addError(element, "Message " + id + " misses a translation"); } } } break; // ignore those tags case _SOURCE_TAG: case _SEGMENT_SOURCE_TAG: break; case _TARGET_TAG: var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset; var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset; var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content; var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd); this._unitMlString = innerText; break; case _FILE_TAG: var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'target-language'; }); if (localeAttr) { this._locale = localeAttr.value; } visitAll(this, element.children, null); break; default: // TODO(vicb): assert file structure, xliff version // For now only recurse on unhandled nodes visitAll(this, element.children, null); } }; /** * @param {?} attribute * @param {?} context * @return {?} */ XliffParser.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} text * @param {?} context * @return {?} */ XliffParser.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { }; /** * @param {?} comment * @param {?} context * @return {?} */ XliffParser.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} expansion * @param {?} context * @return {?} */ XliffParser.prototype.visitExpansion = /** * @param {?} expansion * @param {?} context * @return {?} */ function (expansion, context) { }; /** * @param {?} expansionCase * @param {?} context * @return {?} */ XliffParser.prototype.visitExpansionCase = /** * @param {?} expansionCase * @param {?} context * @return {?} */ function (expansionCase, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ XliffParser.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message)); }; return XliffParser; }()); var XmlToI18n = /** @class */ (function () { function XmlToI18n() { } /** * @param {?} message * @param {?} url * @return {?} */ XmlToI18n.prototype.convert = /** * @param {?} message * @param {?} url * @return {?} */ function (message, url) { var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true); this._errors = xmlIcu.errors; var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ? [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes)); return { i18nNodes: i18nNodes, errors: this._errors, }; }; /** * @param {?} text * @param {?} context * @return {?} */ XmlToI18n.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); }; /** * @param {?} el * @param {?} context * @return {?} */ XmlToI18n.prototype.visitElement = /** * @param {?} el * @param {?} context * @return {?} */ function (el, context) { if (el.name === _PLACEHOLDER_TAG) { var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'id'; }); if (nameAttr) { return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan))); } this._addError(el, "<" + _PLACEHOLDER_TAG + "> misses the \"id\" attribute"); return null; } if (el.name === _MARKER_TAG) { return [].concat.apply([], visitAll(this, el.children)); } this._addError(el, "Unexpected tag"); return null; }; /** * @param {?} icu * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var /** @type {?} */ caseMap = {}; visitAll(this, icu.cases).forEach(function (c) { caseMap[c.value] = new Container(c.nodes, icu.sourceSpan); }); return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { return { value: icuCase.value, nodes: visitAll(this, icuCase.expression), }; }; /** * @param {?} comment * @param {?} context * @return {?} */ XmlToI18n.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} attribute * @param {?} context * @return {?} */ XmlToI18n.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ XmlToI18n.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message)); }; return XmlToI18n; }()); /** * @param {?} tag * @return {?} */ function getCtypeForTag(tag) { switch (tag.toLowerCase()) { case 'br': return 'lb'; case 'img': return 'image'; default: return "x-" + tag; } } /** * @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 _VERSION$1 = '2.0'; var _XMLNS$1 = 'urn:oasis:names:tc:xliff:document:2.0'; // TODO(vicb): make this a param (s/_/-/) var _DEFAULT_SOURCE_LANG$1 = 'en'; var _PLACEHOLDER_TAG$1 = 'ph'; var _PLACEHOLDER_SPANNING_TAG = 'pc'; var _MARKER_TAG$1 = 'mrk'; var _XLIFF_TAG = 'xliff'; var _SOURCE_TAG$1 = 'source'; var _TARGET_TAG$1 = 'target'; var _UNIT_TAG$1 = 'unit'; var Xliff2 = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Xliff2, _super); function Xliff2() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} messages * @param {?} locale * @return {?} */ Xliff2.prototype.write = /** * @param {?} messages * @param {?} locale * @return {?} */ function (messages, locale) { var /** @type {?} */ visitor = new _WriteVisitor$1(); var /** @type {?} */ units = []; messages.forEach(function (message) { var /** @type {?} */ unit = new Tag(_UNIT_TAG$1, { id: message.id }); var /** @type {?} */ notes = new Tag('notes'); if (message.description || message.meaning) { if (message.description) { notes.children.push(new CR(8), new Tag('note', { category: 'description' }, [new Text$2(message.description)])); } if (message.meaning) { notes.children.push(new CR(8), new Tag('note', { category: 'meaning' }, [new Text$2(message.meaning)])); } } message.sources.forEach(function (source) { notes.children.push(new CR(8), new Tag('note', { category: 'location' }, [ new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : '')) ])); }); notes.children.push(new CR(6)); unit.children.push(new CR(6), notes); var /** @type {?} */ segment = new Tag('segment'); segment.children.push(new CR(8), new Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), new CR(6)); unit.children.push(new CR(6), segment, new CR(4)); units.push(new CR(4), unit); }); var /** @type {?} */ file = new Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, units.concat([new CR(2)])); var /** @type {?} */ xliff = new Tag(_XLIFF_TAG, { version: _VERSION$1, xmlns: _XMLNS$1, srcLang: locale || _DEFAULT_SOURCE_LANG$1 }, [new CR(2), file, new CR()]); return serialize([ new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR() ]); }; /** * @param {?} content * @param {?} url * @return {?} */ Xliff2.prototype.load = /** * @param {?} content * @param {?} url * @return {?} */ function (content, url) { // xliff to xml nodes var /** @type {?} */ xliff2Parser = new Xliff2Parser(); var _a = xliff2Parser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors; // xml nodes to i18n nodes var /** @type {?} */ i18nNodesByMsgId = {}; var /** @type {?} */ converter = new XmlToI18n$1(); Object.keys(msgIdToHtml).forEach(function (msgId) { var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors; errors.push.apply(errors, e); i18nNodesByMsgId[msgId] = i18nNodes; }); if (errors.length) { throw new Error("xliff2 parse errors:\n" + errors.join('\n')); } return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId }; }; /** * @param {?} message * @return {?} */ Xliff2.prototype.digest = /** * @param {?} message * @return {?} */ function (message) { return decimalDigest(message); }; return Xliff2; }(Serializer)); var _WriteVisitor$1 = /** @class */ (function () { function _WriteVisitor() { } /** * @param {?} text * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return [new Text$2(text.value)]; }; /** * @param {?} container * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitContainer = /** * @param {?} container * @param {?=} context * @return {?} */ function (container, context) { var _this = this; var /** @type {?} */ nodes = []; container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); }); return nodes; }; /** * @param {?} icu * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")]; Object.keys(icu.cases).forEach(function (c) { nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")])); }); nodes.push(new Text$2("}")); return nodes; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var _this = this; var /** @type {?} */ type = getTypeForTag(ph.tag); if (ph.isVoid) { var /** @type {?} */ tagPh = new Tag(_PLACEHOLDER_TAG$1, { id: (this._nextPlaceholderId++).toString(), equiv: ph.startName, type: type, disp: "<" + ph.tag + "/>", }); return [tagPh]; } var /** @type {?} */ tagPc = new Tag(_PLACEHOLDER_SPANNING_TAG, { id: (this._nextPlaceholderId++).toString(), equivStart: ph.startName, equivEnd: ph.closeName, type: type, dispStart: "<" + ph.tag + ">", dispEnd: "", }); var /** @type {?} */ nodes = [].concat.apply([], ph.children.map(function (node) { return node.visit(_this); })); if (nodes.length) { nodes.forEach(function (node) { return tagPc.children.push(node); }); } else { tagPc.children.push(new Text$2('')); } return [tagPc]; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString(); return [new Tag(_PLACEHOLDER_TAG$1, { id: idStr, equiv: ph.name, disp: "{{" + ph.value + "}}", })]; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _WriteVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ cases = Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' '); var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString(); return [new Tag(_PLACEHOLDER_TAG$1, { id: idStr, equiv: ph.name, disp: "{" + ph.value.expression + ", " + ph.value.type + ", " + cases + "}" })]; }; /** * @param {?} nodes * @return {?} */ _WriteVisitor.prototype.serialize = /** * @param {?} nodes * @return {?} */ function (nodes) { var _this = this; this._nextPlaceholderId = 0; return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); })); }; return _WriteVisitor; }()); var Xliff2Parser = /** @class */ (function () { function Xliff2Parser() { this._locale = null; } /** * @param {?} xliff * @param {?} url * @return {?} */ Xliff2Parser.prototype.parse = /** * @param {?} xliff * @param {?} url * @return {?} */ function (xliff, url) { this._unitMlString = null; this._msgIdToHtml = {}; var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false); this._errors = xml.errors; visitAll(this, xml.rootNodes, null); return { msgIdToHtml: this._msgIdToHtml, errors: this._errors, locale: this._locale, }; }; /** * @param {?} element * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitElement = /** * @param {?} element * @param {?} context * @return {?} */ function (element, context) { switch (element.name) { case _UNIT_TAG$1: this._unitMlString = null; var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; }); if (!idAttr) { this._addError(element, "<" + _UNIT_TAG$1 + "> misses the \"id\" attribute"); } else { var /** @type {?} */ id = idAttr.value; if (this._msgIdToHtml.hasOwnProperty(id)) { this._addError(element, "Duplicated translations for msg " + id); } else { visitAll(this, element.children, null); if (typeof this._unitMlString === 'string') { this._msgIdToHtml[id] = this._unitMlString; } else { this._addError(element, "Message " + id + " misses a translation"); } } } break; case _SOURCE_TAG$1: // ignore source message break; case _TARGET_TAG$1: var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset; var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset; var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content; var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd); this._unitMlString = innerText; break; case _XLIFF_TAG: var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'trgLang'; }); if (localeAttr) { this._locale = localeAttr.value; } var /** @type {?} */ versionAttr = element.attrs.find(function (attr) { return attr.name === 'version'; }); if (versionAttr) { var /** @type {?} */ version = versionAttr.value; if (version !== '2.0') { this._addError(element, "The XLIFF file version " + version + " is not compatible with XLIFF 2.0 serializer"); } else { visitAll(this, element.children, null); } } break; default: visitAll(this, element.children, null); } }; /** * @param {?} attribute * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} text * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { }; /** * @param {?} comment * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} expansion * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitExpansion = /** * @param {?} expansion * @param {?} context * @return {?} */ function (expansion, context) { }; /** * @param {?} expansionCase * @param {?} context * @return {?} */ Xliff2Parser.prototype.visitExpansionCase = /** * @param {?} expansionCase * @param {?} context * @return {?} */ function (expansionCase, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ Xliff2Parser.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(node.sourceSpan, message)); }; return Xliff2Parser; }()); var XmlToI18n$1 = /** @class */ (function () { function XmlToI18n() { } /** * @param {?} message * @param {?} url * @return {?} */ XmlToI18n.prototype.convert = /** * @param {?} message * @param {?} url * @return {?} */ function (message, url) { var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true); this._errors = xmlIcu.errors; var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ? [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes)); return { i18nNodes: i18nNodes, errors: this._errors, }; }; /** * @param {?} text * @param {?} context * @return {?} */ XmlToI18n.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return new Text$1(text.value, text.sourceSpan); }; /** * @param {?} el * @param {?} context * @return {?} */ XmlToI18n.prototype.visitElement = /** * @param {?} el * @param {?} context * @return {?} */ function (el, context) { var _this = this; switch (el.name) { case _PLACEHOLDER_TAG$1: var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'equiv'; }); if (nameAttr) { return [new Placeholder('', nameAttr.value, el.sourceSpan)]; } this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equiv\" attribute"); break; case _PLACEHOLDER_SPANNING_TAG: var /** @type {?} */ startAttr = el.attrs.find(function (attr) { return attr.name === 'equivStart'; }); var /** @type {?} */ endAttr = el.attrs.find(function (attr) { return attr.name === 'equivEnd'; }); if (!startAttr) { this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivStart\" attribute"); } else if (!endAttr) { this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivEnd\" attribute"); } else { var /** @type {?} */ startId = startAttr.value; var /** @type {?} */ endId = endAttr.value; var /** @type {?} */ nodes = []; return nodes.concat.apply(nodes, [new Placeholder('', startId, el.sourceSpan)].concat(el.children.map(function (node) { return node.visit(_this, null); }), [new Placeholder('', endId, el.sourceSpan)])); } break; case _MARKER_TAG$1: return [].concat.apply([], visitAll(this, el.children)); default: this._addError(el, "Unexpected tag"); } return null; }; /** * @param {?} icu * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var /** @type {?} */ caseMap = {}; visitAll(this, icu.cases).forEach(function (c) { caseMap[c.value] = new Container(c.nodes, icu.sourceSpan); }); return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { return { value: icuCase.value, nodes: [].concat.apply([], visitAll(this, icuCase.expression)), }; }; /** * @param {?} comment * @param {?} context * @return {?} */ XmlToI18n.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} attribute * @param {?} context * @return {?} */ XmlToI18n.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ XmlToI18n.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(node.sourceSpan, message)); }; return XmlToI18n; }()); /** * @param {?} tag * @return {?} */ function getTypeForTag(tag) { switch (tag.toLowerCase()) { case 'br': case 'b': case 'i': case 'u': return 'fmt'; case 'img': return 'image'; case 'a': return 'link'; default: return '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 */ var _MESSAGES_TAG = 'messagebundle'; var _MESSAGE_TAG = 'msg'; var _PLACEHOLDER_TAG$2 = 'ph'; var _EXEMPLE_TAG = 'ex'; var _SOURCE_TAG$2 = 'source'; var _DOCTYPE = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; var Xmb = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Xmb, _super); function Xmb() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} messages * @param {?} locale * @return {?} */ Xmb.prototype.write = /** * @param {?} messages * @param {?} locale * @return {?} */ function (messages, locale) { var /** @type {?} */ exampleVisitor = new ExampleVisitor(); var /** @type {?} */ visitor = new _Visitor$2(); var /** @type {?} */ rootNode = new Tag(_MESSAGES_TAG); messages.forEach(function (message) { var /** @type {?} */ attrs = { id: message.id }; if (message.description) { attrs['desc'] = message.description; } if (message.meaning) { attrs['meaning'] = message.meaning; } var /** @type {?} */ sourceTags = []; message.sources.forEach(function (source) { sourceTags.push(new Tag(_SOURCE_TAG$2, {}, [ new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : '')) ])); }); rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, sourceTags.concat(visitor.serialize(message.nodes)))); }); rootNode.children.push(new CR()); return serialize([ new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), new Doctype(_MESSAGES_TAG, _DOCTYPE), new CR(), exampleVisitor.addDefaultExamples(rootNode), new CR(), ]); }; /** * @param {?} content * @param {?} url * @return {?} */ Xmb.prototype.load = /** * @param {?} content * @param {?} url * @return {?} */ function (content, url) { throw new Error('Unsupported'); }; /** * @param {?} message * @return {?} */ Xmb.prototype.digest = /** * @param {?} message * @return {?} */ function (message) { return digest$1(message); }; /** * @param {?} message * @return {?} */ Xmb.prototype.createNameMapper = /** * @param {?} message * @return {?} */ function (message) { return new SimplePlaceholderMapper(message, toPublicName); }; return Xmb; }(Serializer)); var _Visitor$2 = /** @class */ (function () { function _Visitor() { } /** * @param {?} text * @param {?=} context * @return {?} */ _Visitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return [new Text$2(text.value)]; }; /** * @param {?} container * @param {?} context * @return {?} */ _Visitor.prototype.visitContainer = /** * @param {?} container * @param {?} context * @return {?} */ function (container, context) { var _this = this; var /** @type {?} */ nodes = []; container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); }); return nodes; }; /** * @param {?} icu * @param {?=} context * @return {?} */ _Visitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")]; Object.keys(icu.cases).forEach(function (c) { nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")])); }); nodes.push(new Text$2("}")); return nodes; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _Visitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ startEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("<" + ph.tag + ">")]); var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.startName }, [startEx]); if (ph.isVoid) { // void tags have no children nor closing tags return [startTagPh]; } var /** @type {?} */ closeEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("")]); var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.closeName }, [closeEx]); return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]); }; /** * @param {?} ph * @param {?=} context * @return {?} */ _Visitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [new Text$2("{{" + ph.value + "}}")]); return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])]; }; /** * @param {?} ph * @param {?=} context * @return {?} */ _Visitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [ new Text$2("{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}") ]); return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])]; }; /** * @param {?} nodes * @return {?} */ _Visitor.prototype.serialize = /** * @param {?} nodes * @return {?} */ function (nodes) { var _this = this; return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); })); }; return _Visitor; }()); /** * @param {?} message * @return {?} */ function digest$1(message) { return decimalDigest(message); } var ExampleVisitor = /** @class */ (function () { function ExampleVisitor() { } /** * @param {?} node * @return {?} */ ExampleVisitor.prototype.addDefaultExamples = /** * @param {?} node * @return {?} */ function (node) { node.visit(this); return node; }; /** * @param {?} tag * @return {?} */ ExampleVisitor.prototype.visitTag = /** * @param {?} tag * @return {?} */ function (tag) { var _this = this; if (tag.name === _PLACEHOLDER_TAG$2) { if (!tag.children || tag.children.length == 0) { var /** @type {?} */ exText = new Text$2(tag.attrs['name'] || '...'); tag.children = [new Tag(_EXEMPLE_TAG, {}, [exText])]; } } else if (tag.children) { tag.children.forEach(function (node) { return node.visit(_this); }); } }; /** * @param {?} text * @return {?} */ ExampleVisitor.prototype.visitText = /** * @param {?} text * @return {?} */ function (text) { }; /** * @param {?} decl * @return {?} */ ExampleVisitor.prototype.visitDeclaration = /** * @param {?} decl * @return {?} */ function (decl) { }; /** * @param {?} doctype * @return {?} */ ExampleVisitor.prototype.visitDoctype = /** * @param {?} doctype * @return {?} */ function (doctype) { }; return ExampleVisitor; }()); /** * @param {?} internalName * @return {?} */ function toPublicName(internalName) { return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_'); } /** * @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 _TRANSLATIONS_TAG = 'translationbundle'; var _TRANSLATION_TAG = 'translation'; var _PLACEHOLDER_TAG$3 = 'ph'; var Xtb = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(Xtb, _super); function Xtb() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} messages * @param {?} locale * @return {?} */ Xtb.prototype.write = /** * @param {?} messages * @param {?} locale * @return {?} */ function (messages, locale) { throw new Error('Unsupported'); }; /** * @param {?} content * @param {?} url * @return {?} */ Xtb.prototype.load = /** * @param {?} content * @param {?} url * @return {?} */ function (content, url) { // xtb to xml nodes var /** @type {?} */ xtbParser = new XtbParser(); var _a = xtbParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors; // xml nodes to i18n nodes var /** @type {?} */ i18nNodesByMsgId = {}; var /** @type {?} */ converter = new XmlToI18n$2(); // Because we should be able to load xtb files that rely on features not supported by angular, // we need to delay the conversion of html to i18n nodes so that non angular messages are not // converted Object.keys(msgIdToHtml).forEach(function (msgId) { var /** @type {?} */ valueFn = function () { var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, errors = _a.errors; if (errors.length) { throw new Error("xtb parse errors:\n" + errors.join('\n')); } return i18nNodes; }; createLazyProperty(i18nNodesByMsgId, msgId, valueFn); }); if (errors.length) { throw new Error("xtb parse errors:\n" + errors.join('\n')); } return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId }; }; /** * @param {?} message * @return {?} */ Xtb.prototype.digest = /** * @param {?} message * @return {?} */ function (message) { return digest$1(message); }; /** * @param {?} message * @return {?} */ Xtb.prototype.createNameMapper = /** * @param {?} message * @return {?} */ function (message) { return new SimplePlaceholderMapper(message, toPublicName); }; return Xtb; }(Serializer)); /** * @param {?} messages * @param {?} id * @param {?} valueFn * @return {?} */ function createLazyProperty(messages, id, valueFn) { Object.defineProperty(messages, id, { configurable: true, enumerable: true, get: function () { var /** @type {?} */ value = valueFn(); Object.defineProperty(messages, id, { enumerable: true, value: value }); return value; }, set: function (_) { throw new Error('Could not overwrite an XTB translation'); }, }); } var XtbParser = /** @class */ (function () { function XtbParser() { this._locale = null; } /** * @param {?} xtb * @param {?} url * @return {?} */ XtbParser.prototype.parse = /** * @param {?} xtb * @param {?} url * @return {?} */ function (xtb, url) { this._bundleDepth = 0; this._msgIdToHtml = {}; // We can not parse the ICU messages at this point as some messages might not originate // from Angular that could not be lex'd. var /** @type {?} */ xml = new XmlParser().parse(xtb, url, false); this._errors = xml.errors; visitAll(this, xml.rootNodes); return { msgIdToHtml: this._msgIdToHtml, errors: this._errors, locale: this._locale, }; }; /** * @param {?} element * @param {?} context * @return {?} */ XtbParser.prototype.visitElement = /** * @param {?} element * @param {?} context * @return {?} */ function (element, context) { switch (element.name) { case _TRANSLATIONS_TAG: this._bundleDepth++; if (this._bundleDepth > 1) { this._addError(element, "<" + _TRANSLATIONS_TAG + "> elements can not be nested"); } var /** @type {?} */ langAttr = element.attrs.find(function (attr) { return attr.name === 'lang'; }); if (langAttr) { this._locale = langAttr.value; } visitAll(this, element.children, null); this._bundleDepth--; break; case _TRANSLATION_TAG: var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; }); if (!idAttr) { this._addError(element, "<" + _TRANSLATION_TAG + "> misses the \"id\" attribute"); } else { var /** @type {?} */ id = idAttr.value; if (this._msgIdToHtml.hasOwnProperty(id)) { this._addError(element, "Duplicated translations for msg " + id); } else { var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset; var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset; var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content; var /** @type {?} */ innerText = content.slice(/** @type {?} */ ((innerTextStart)), /** @type {?} */ ((innerTextEnd))); this._msgIdToHtml[id] = innerText; } } break; default: this._addError(element, 'Unexpected tag'); } }; /** * @param {?} attribute * @param {?} context * @return {?} */ XtbParser.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} text * @param {?} context * @return {?} */ XtbParser.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { }; /** * @param {?} comment * @param {?} context * @return {?} */ XtbParser.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} expansion * @param {?} context * @return {?} */ XtbParser.prototype.visitExpansion = /** * @param {?} expansion * @param {?} context * @return {?} */ function (expansion, context) { }; /** * @param {?} expansionCase * @param {?} context * @return {?} */ XtbParser.prototype.visitExpansionCase = /** * @param {?} expansionCase * @param {?} context * @return {?} */ function (expansionCase, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ XtbParser.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message)); }; return XtbParser; }()); var XmlToI18n$2 = /** @class */ (function () { function XmlToI18n() { } /** * @param {?} message * @param {?} url * @return {?} */ XmlToI18n.prototype.convert = /** * @param {?} message * @param {?} url * @return {?} */ function (message, url) { var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true); this._errors = xmlIcu.errors; var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ? [] : visitAll(this, xmlIcu.rootNodes); return { i18nNodes: i18nNodes, errors: this._errors, }; }; /** * @param {?} text * @param {?} context * @return {?} */ XmlToI18n.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); }; /** * @param {?} icu * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { var /** @type {?} */ caseMap = {}; visitAll(this, icu.cases).forEach(function (c) { caseMap[c.value] = new Container(c.nodes, icu.sourceSpan); }); return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ XmlToI18n.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { return { value: icuCase.value, nodes: visitAll(this, icuCase.expression), }; }; /** * @param {?} el * @param {?} context * @return {?} */ XmlToI18n.prototype.visitElement = /** * @param {?} el * @param {?} context * @return {?} */ function (el, context) { if (el.name === _PLACEHOLDER_TAG$3) { var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'name'; }); if (nameAttr) { return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan))); } this._addError(el, "<" + _PLACEHOLDER_TAG$3 + "> misses the \"name\" attribute"); } else { this._addError(el, "Unexpected tag"); } return null; }; /** * @param {?} comment * @param {?} context * @return {?} */ XmlToI18n.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { }; /** * @param {?} attribute * @param {?} context * @return {?} */ XmlToI18n.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { }; /** * @param {?} node * @param {?} message * @return {?} */ XmlToI18n.prototype._addError = /** * @param {?} node * @param {?} message * @return {?} */ function (node, message) { this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message)); }; return XmlToI18n; }()); /** * @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 HtmlParser = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(HtmlParser, _super); function HtmlParser() { return _super.call(this, getHtmlTagDefinition) || this; } /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ HtmlParser.prototype.parse = /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ function (source, url, parseExpansionForms, interpolationConfig) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig); }; return HtmlParser; }(Parser$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 */ /** * A container for translated messages */ var TranslationBundle = /** @class */ (function () { function TranslationBundle(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console) { if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; } if (missingTranslationStrategy === void 0) { missingTranslationStrategy = MissingTranslationStrategy.Warning; } this._i18nNodesByMsgId = _i18nNodesByMsgId; this.digest = digest; this.mapperFactory = mapperFactory; this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, locale, digest, /** @type {?} */ ((mapperFactory)), missingTranslationStrategy, console); } // Creates a `TranslationBundle` by parsing the given `content` with the `serializer`. /** * @param {?} content * @param {?} url * @param {?} serializer * @param {?} missingTranslationStrategy * @param {?=} console * @return {?} */ TranslationBundle.load = /** * @param {?} content * @param {?} url * @param {?} serializer * @param {?} missingTranslationStrategy * @param {?=} console * @return {?} */ function (content, url, serializer, missingTranslationStrategy, console) { var _a = serializer.load(content, url), locale = _a.locale, i18nNodesByMsgId = _a.i18nNodesByMsgId; var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); }; var /** @type {?} */ mapperFactory = function (m) { return ((serializer.createNameMapper(m))); }; return new TranslationBundle(i18nNodesByMsgId, locale, digestFn, mapperFactory, missingTranslationStrategy, console); }; // Returns the translation as HTML nodes from the given source message. /** * @param {?} srcMsg * @return {?} */ TranslationBundle.prototype.get = /** * @param {?} srcMsg * @return {?} */ function (srcMsg) { var /** @type {?} */ html = this._i18nToHtml.convert(srcMsg); if (html.errors.length) { throw new Error(html.errors.join('\n')); } return html.nodes; }; /** * @param {?} srcMsg * @return {?} */ TranslationBundle.prototype.has = /** * @param {?} srcMsg * @return {?} */ function (srcMsg) { return this.digest(srcMsg) in this._i18nNodesByMsgId; }; return TranslationBundle; }()); var I18nToHtmlVisitor = /** @class */ (function () { function I18nToHtmlVisitor(_i18nNodesByMsgId, _locale, _digest, _mapperFactory, _missingTranslationStrategy, _console) { if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; } this._i18nNodesByMsgId = _i18nNodesByMsgId; this._locale = _locale; this._digest = _digest; this._mapperFactory = _mapperFactory; this._missingTranslationStrategy = _missingTranslationStrategy; this._console = _console; this._contextStack = []; this._errors = []; } /** * @param {?} srcMsg * @return {?} */ I18nToHtmlVisitor.prototype.convert = /** * @param {?} srcMsg * @return {?} */ function (srcMsg) { this._contextStack.length = 0; this._errors.length = 0; // i18n to text var /** @type {?} */ text = this._convertToText(srcMsg); // text to html var /** @type {?} */ url = srcMsg.nodes[0].sourceSpan.start.file.url; var /** @type {?} */ html = new HtmlParser().parse(text, url, true); return { nodes: html.rootNodes, errors: this._errors.concat(html.errors), }; }; /** * @param {?} text * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitText = /** * @param {?} text * @param {?=} context * @return {?} */ function (text, context) { return text.value; }; /** * @param {?} container * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitContainer = /** * @param {?} container * @param {?=} context * @return {?} */ function (container, context) { var _this = this; return container.children.map(function (n) { return n.visit(_this); }).join(''); }; /** * @param {?} icu * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitIcu = /** * @param {?} icu * @param {?=} context * @return {?} */ function (icu, context) { var _this = this; var /** @type {?} */ cases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; }); // TODO(vicb): Once all format switch to using expression placeholders // we should throw when the placeholder is not in the source message var /** @type {?} */ exp = this._srcMsg.placeholders.hasOwnProperty(icu.expression) ? this._srcMsg.placeholders[icu.expression] : icu.expression; return "{" + exp + ", " + icu.type + ", " + cases.join(' ') + "}"; }; /** * @param {?} ph * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var /** @type {?} */ phName = this._mapper(ph.name); if (this._srcMsg.placeholders.hasOwnProperty(phName)) { return this._srcMsg.placeholders[phName]; } if (this._srcMsg.placeholderToMessage.hasOwnProperty(phName)) { return this._convertToText(this._srcMsg.placeholderToMessage[phName]); } this._addError(ph, "Unknown placeholder \"" + ph.name + "\""); return ''; }; // Loaded message contains only placeholders (vs tag and icu placeholders). // However when a translation can not be found, we need to serialize the source message // which can contain tag placeholders /** * @param {?} ph * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitTagPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { var _this = this; var /** @type {?} */ tag = "" + ph.tag; var /** @type {?} */ attrs = Object.keys(ph.attrs).map(function (name) { return name + "=\"" + ph.attrs[name] + "\""; }).join(' '); if (ph.isVoid) { return "<" + tag + " " + attrs + "/>"; } var /** @type {?} */ children = ph.children.map(function (c) { return c.visit(_this); }).join(''); return "<" + tag + " " + attrs + ">" + children + ""; }; // Loaded message contains only placeholders (vs tag and icu placeholders). // However when a translation can not be found, we need to serialize the source message // which can contain tag placeholders /** * @param {?} ph * @param {?=} context * @return {?} */ I18nToHtmlVisitor.prototype.visitIcuPlaceholder = /** * @param {?} ph * @param {?=} context * @return {?} */ function (ph, context) { // An ICU placeholder references the source message to be serialized return this._convertToText(this._srcMsg.placeholderToMessage[ph.name]); }; /** * Convert a source message to a translated text string: * - text nodes are replaced with their translation, * - placeholders are replaced with their content, * - ICU nodes are converted to ICU expressions. * @param {?} srcMsg * @return {?} */ I18nToHtmlVisitor.prototype._convertToText = /** * Convert a source message to a translated text string: * - text nodes are replaced with their translation, * - placeholders are replaced with their content, * - ICU nodes are converted to ICU expressions. * @param {?} srcMsg * @return {?} */ function (srcMsg) { var _this = this; var /** @type {?} */ id = this._digest(srcMsg); var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null; var /** @type {?} */ nodes; this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper }); this._srcMsg = srcMsg; if (this._i18nNodesByMsgId.hasOwnProperty(id)) { // When there is a translation use its nodes as the source // And create a mapper to convert serialized placeholder names to internal names nodes = this._i18nNodesByMsgId[id]; this._mapper = function (name) { return mapper ? /** @type {?} */ ((mapper.toInternalName(name))) : name; }; } else { // When no translation has been found // - report an error / a warning / nothing, // - use the nodes from the original message // - placeholders are already internal and need no mapper if (this._missingTranslationStrategy === MissingTranslationStrategy.Error) { var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : ''; this._addError(srcMsg.nodes[0], "Missing translation for message \"" + id + "\"" + ctx); } else if (this._console && this._missingTranslationStrategy === MissingTranslationStrategy.Warning) { var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : ''; this._console.warn("Missing translation for message \"" + id + "\"" + ctx); } nodes = srcMsg.nodes; this._mapper = function (name) { return name; }; } var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join(''); var /** @type {?} */ context = /** @type {?} */ ((this._contextStack.pop())); this._srcMsg = context.msg; this._mapper = context.mapper; return text; }; /** * @param {?} el * @param {?} msg * @return {?} */ I18nToHtmlVisitor.prototype._addError = /** * @param {?} el * @param {?} msg * @return {?} */ function (el, msg) { this._errors.push(new I18nError(el.sourceSpan, msg)); }; return I18nToHtmlVisitor; }()); /** * @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 I18NHtmlParser = /** @class */ (function () { function I18NHtmlParser(_htmlParser, translations, translationsFormat, missingTranslation, console) { if (missingTranslation === void 0) { missingTranslation = MissingTranslationStrategy.Warning; } this._htmlParser = _htmlParser; if (translations) { var /** @type {?} */ serializer = createSerializer(translationsFormat); this._translationBundle = TranslationBundle.load(translations, 'i18n', serializer, missingTranslation, console); } else { this._translationBundle = new TranslationBundle({}, null, digest, undefined, missingTranslation, console); } } /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ I18NHtmlParser.prototype.parse = /** * @param {?} source * @param {?} url * @param {?=} parseExpansionForms * @param {?=} interpolationConfig * @return {?} */ function (source, url, parseExpansionForms, interpolationConfig) { if (parseExpansionForms === void 0) { parseExpansionForms = false; } if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; } var /** @type {?} */ parseResult = this._htmlParser.parse(source, url, parseExpansionForms, interpolationConfig); if (parseResult.errors.length) { return new ParseTreeResult(parseResult.rootNodes, parseResult.errors); } return mergeTranslations(parseResult.rootNodes, this._translationBundle, interpolationConfig, [], {}); }; return I18NHtmlParser; }()); /** * @param {?=} format * @return {?} */ function createSerializer(format) { format = (format || 'xlf').toLowerCase(); switch (format) { case 'xmb': return new Xmb(); case 'xtb': return new Xtb(); case 'xliff2': case 'xlf2': return new Xliff2(); case 'xliff': case 'xlf': default: return new Xliff(); } } /** * @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 STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; var GENERATED_FILE = /\.ngfactory\.|\.ngsummary\./; var JIT_SUMMARY_FILE = /\.ngsummary\./; var JIT_SUMMARY_NAME = /NgSummary$/; /** * @param {?} filePath * @param {?=} forceSourceFile * @return {?} */ function ngfactoryFilePath(filePath, forceSourceFile) { if (forceSourceFile === void 0) { forceSourceFile = false; } var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile); return urlWithSuffix[0] + ".ngfactory" + normalizeGenFileSuffix(urlWithSuffix[1]); } /** * @param {?} filePath * @return {?} */ function stripGeneratedFileSuffix(filePath) { return filePath.replace(GENERATED_FILE, '.'); } /** * @param {?} filePath * @return {?} */ function isGeneratedFile(filePath) { return GENERATED_FILE.test(filePath); } /** * @param {?} path * @param {?=} forceSourceFile * @return {?} */ function splitTypescriptSuffix(path, forceSourceFile) { if (forceSourceFile === void 0) { forceSourceFile = false; } if (path.endsWith('.d.ts')) { return [path.slice(0, -5), forceSourceFile ? '.ts' : '.d.ts']; } var /** @type {?} */ lastDot = path.lastIndexOf('.'); if (lastDot !== -1) { return [path.substring(0, lastDot), path.substring(lastDot)]; } return [path, '']; } /** * @param {?} srcFileSuffix * @return {?} */ function normalizeGenFileSuffix(srcFileSuffix) { return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix; } /** * @param {?} fileName * @return {?} */ function summaryFileName(fileName) { var /** @type {?} */ fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, ''); return fileNameWithoutSuffix + ".ngsummary.json"; } /** * @param {?} fileName * @param {?=} forceSourceFile * @return {?} */ function summaryForJitFileName(fileName, forceSourceFile) { if (forceSourceFile === void 0) { forceSourceFile = false; } var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(stripGeneratedFileSuffix(fileName), forceSourceFile); return urlWithSuffix[0] + ".ngsummary" + urlWithSuffix[1]; } /** * @param {?} filePath * @return {?} */ function stripSummaryForJitFileSuffix(filePath) { return filePath.replace(JIT_SUMMARY_FILE, '.'); } /** * @param {?} symbolName * @return {?} */ function summaryForJitName(symbolName) { return symbolName + "NgSummary"; } /** * @param {?} symbolName * @return {?} */ function stripSummaryForJitNameSuffix(symbolName) { return symbolName.replace(JIT_SUMMARY_NAME, ''); } var LOWERED_SYMBOL = /\u0275\d+/; /** * @param {?} name * @return {?} */ function isLoweredSymbol(name) { return LOWERED_SYMBOL.test(name); } /** * @param {?} id * @return {?} */ function createLoweredSymbol(id) { return "\u0275" + 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 */ var CORE = '@angular/core'; var Identifiers = /** @class */ (function () { function Identifiers() { } Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = { name: 'ANALYZE_FOR_ENTRY_COMPONENTS', moduleName: CORE, }; Identifiers.ElementRef = { name: 'ElementRef', moduleName: CORE }; Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleName: CORE }; Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleName: CORE }; Identifiers.ChangeDetectorRef = { name: 'ChangeDetectorRef', moduleName: CORE, }; Identifiers.QueryList = { name: 'QueryList', moduleName: CORE }; Identifiers.TemplateRef = { name: 'TemplateRef', moduleName: CORE }; Identifiers.CodegenComponentFactoryResolver = { name: 'ɵCodegenComponentFactoryResolver', moduleName: CORE, }; Identifiers.ComponentFactoryResolver = { name: 'ComponentFactoryResolver', moduleName: CORE, }; Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleName: CORE }; Identifiers.ComponentRef = { name: 'ComponentRef', moduleName: CORE }; Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleName: CORE }; Identifiers.createModuleFactory = { name: 'ɵcmf', moduleName: CORE, }; Identifiers.moduleDef = { name: 'ɵmod', moduleName: CORE, }; Identifiers.moduleProviderDef = { name: 'ɵmpd', moduleName: CORE, }; Identifiers.RegisterModuleFactoryFn = { name: 'ɵregisterModuleFactory', moduleName: CORE, }; Identifiers.Injector = { name: 'Injector', moduleName: CORE }; Identifiers.ViewEncapsulation = { name: 'ViewEncapsulation', moduleName: CORE, }; Identifiers.ChangeDetectionStrategy = { name: 'ChangeDetectionStrategy', moduleName: CORE, }; Identifiers.SecurityContext = { name: 'SecurityContext', moduleName: CORE, }; Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleName: CORE }; Identifiers.TRANSLATIONS_FORMAT = { name: 'TRANSLATIONS_FORMAT', moduleName: CORE, }; Identifiers.inlineInterpolate = { name: 'ɵinlineInterpolate', moduleName: CORE, }; Identifiers.interpolate = { name: 'ɵinterpolate', moduleName: CORE }; Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleName: CORE }; Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleName: CORE }; Identifiers.Renderer = { name: 'Renderer', moduleName: CORE }; Identifiers.viewDef = { name: 'ɵvid', moduleName: CORE }; Identifiers.elementDef = { name: 'ɵeld', moduleName: CORE }; Identifiers.anchorDef = { name: 'ɵand', moduleName: CORE }; Identifiers.textDef = { name: 'ɵted', moduleName: CORE }; Identifiers.directiveDef = { name: 'ɵdid', moduleName: CORE }; Identifiers.providerDef = { name: 'ɵprd', moduleName: CORE }; Identifiers.queryDef = { name: 'ɵqud', moduleName: CORE }; Identifiers.pureArrayDef = { name: 'ɵpad', moduleName: CORE }; Identifiers.pureObjectDef = { name: 'ɵpod', moduleName: CORE }; Identifiers.purePipeDef = { name: 'ɵppd', moduleName: CORE }; Identifiers.pipeDef = { name: 'ɵpid', moduleName: CORE }; Identifiers.nodeValue = { name: 'ɵnov', moduleName: CORE }; Identifiers.ngContentDef = { name: 'ɵncd', moduleName: CORE }; Identifiers.unwrapValue = { name: 'ɵunv', moduleName: CORE }; Identifiers.createRendererType2 = { name: 'ɵcrt', moduleName: CORE }; // type only Identifiers.RendererType2 = { name: 'RendererType2', moduleName: CORE, }; // type only Identifiers.ViewDefinition = { name: 'ɵViewDefinition', moduleName: CORE, }; Identifiers.createComponentFactory = { name: 'ɵccf', moduleName: CORE }; return Identifiers; }()); /** * @param {?} reference * @return {?} */ function createTokenForReference(reference) { return { identifier: { reference: reference } }; } /** * @param {?} reflector * @param {?} reference * @return {?} */ function createTokenForExternalReference(reflector, reference) { return createTokenForReference(reflector.resolveExternalReference(reference)); } /** * @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 LifecycleHooks = { OnInit: 0, OnDestroy: 1, DoCheck: 2, OnChanges: 3, AfterContentInit: 4, AfterContentChecked: 5, AfterViewInit: 6, AfterViewChecked: 7, }; LifecycleHooks[LifecycleHooks.OnInit] = "OnInit"; LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy"; LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck"; LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges"; LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit"; LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked"; LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit"; LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked"; var LIFECYCLE_HOOKS_VALUES = [ LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges, LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit, LifecycleHooks.AfterViewChecked ]; /** * @param {?} reflector * @param {?} hook * @param {?} token * @return {?} */ function hasLifecycleHook(reflector, hook, token) { return reflector.hasLifecycleHook(token, getHookName(hook)); } /** * @param {?} reflector * @param {?} token * @return {?} */ function getAllLifecycleHooks(reflector, token) { return LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); }); } /** * @param {?} hook * @return {?} */ function getHookName(hook) { switch (hook) { case LifecycleHooks.OnInit: return 'ngOnInit'; case LifecycleHooks.OnDestroy: return 'ngOnDestroy'; case LifecycleHooks.DoCheck: return 'ngDoCheck'; case LifecycleHooks.OnChanges: return 'ngOnChanges'; case LifecycleHooks.AfterContentInit: return 'ngAfterContentInit'; case LifecycleHooks.AfterContentChecked: return 'ngAfterContentChecked'; case LifecycleHooks.AfterViewInit: return 'ngAfterViewInit'; case LifecycleHooks.AfterViewChecked: return 'ngAfterViewChecked'; } } /** * @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 _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + //":not(" '([-\\w]+)|' + // "tag" '(?:\\.([-\\w]+))|' + // ".class" '(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' + // "[name]", "[name=value]", '(\\))|' + // ")" '(\\s*,\\s*)', // "," 'g'); /** * A css selector contains an element name, * css classes and attribute/value pairs with the purpose * of selecting subsets out of them. */ var CssSelector = /** @class */ (function () { function CssSelector() { this.element = null; this.classNames = []; this.attrs = []; this.notSelectors = []; } /** * @param {?} selector * @return {?} */ CssSelector.parse = /** * @param {?} selector * @return {?} */ function (selector) { var /** @type {?} */ results = []; var /** @type {?} */ _addResult = function (res, cssSel) { if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 && cssSel.attrs.length == 0) { cssSel.element = '*'; } res.push(cssSel); }; var /** @type {?} */ cssSelector = new CssSelector(); var /** @type {?} */ match; var /** @type {?} */ current = cssSelector; var /** @type {?} */ inNot = false; _SELECTOR_REGEXP.lastIndex = 0; while (match = _SELECTOR_REGEXP.exec(selector)) { if (match[1]) { if (inNot) { throw new Error('Nesting :not is not allowed in a selector'); } inNot = true; current = new CssSelector(); cssSelector.notSelectors.push(current); } if (match[2]) { current.setElement(match[2]); } if (match[3]) { current.addClassName(match[3]); } if (match[4]) { current.addAttribute(match[4], match[6]); } if (match[7]) { inNot = false; current = cssSelector; } if (match[8]) { if (inNot) { throw new Error('Multiple selectors in :not are not supported'); } _addResult(results, cssSelector); cssSelector = current = new CssSelector(); } } _addResult(results, cssSelector); return results; }; /** * @return {?} */ CssSelector.prototype.isElementSelector = /** * @return {?} */ function () { return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 && this.notSelectors.length === 0; }; /** * @return {?} */ CssSelector.prototype.hasElementSelector = /** * @return {?} */ function () { return !!this.element; }; /** * @param {?=} element * @return {?} */ CssSelector.prototype.setElement = /** * @param {?=} element * @return {?} */ function (element) { if (element === void 0) { element = null; } this.element = element; }; /** Gets a template string for an element that matches the selector. */ /** * Gets a template string for an element that matches the selector. * @return {?} */ CssSelector.prototype.getMatchingElementTemplate = /** * Gets a template string for an element that matches the selector. * @return {?} */ function () { var /** @type {?} */ tagName = this.element || 'div'; var /** @type {?} */ classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : ''; var /** @type {?} */ attrs = ''; for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) { var /** @type {?} */ attrName = this.attrs[i]; var /** @type {?} */ attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : ''; attrs += " " + attrName + attrValue; } return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" : "<" + tagName + classAttr + attrs + ">"; }; /** * @param {?} name * @param {?=} value * @return {?} */ CssSelector.prototype.addAttribute = /** * @param {?} name * @param {?=} value * @return {?} */ function (name, value) { if (value === void 0) { value = ''; } this.attrs.push(name, value && value.toLowerCase() || ''); }; /** * @param {?} name * @return {?} */ CssSelector.prototype.addClassName = /** * @param {?} name * @return {?} */ function (name) { this.classNames.push(name.toLowerCase()); }; /** * @return {?} */ CssSelector.prototype.toString = /** * @return {?} */ function () { var /** @type {?} */ res = this.element || ''; if (this.classNames) { this.classNames.forEach(function (klass) { return res += "." + klass; }); } if (this.attrs) { for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) { var /** @type {?} */ name_1 = this.attrs[i]; var /** @type {?} */ value = this.attrs[i + 1]; res += "[" + name_1 + (value ? '=' + value : '') + "]"; } } this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; }); return res; }; return CssSelector; }()); /** * Reads a list of CssSelectors and allows to calculate which ones * are contained in a given CssSelector. */ var SelectorMatcher = /** @class */ (function () { function SelectorMatcher() { this._elementMap = new Map(); this._elementPartialMap = new Map(); this._classMap = new Map(); this._classPartialMap = new Map(); this._attrValueMap = new Map(); this._attrValuePartialMap = new Map(); this._listContexts = []; } /** * @param {?} notSelectors * @return {?} */ SelectorMatcher.createNotMatcher = /** * @param {?} notSelectors * @return {?} */ function (notSelectors) { var /** @type {?} */ notMatcher = new SelectorMatcher(); notMatcher.addSelectables(notSelectors, null); return notMatcher; }; /** * @param {?} cssSelectors * @param {?=} callbackCtxt * @return {?} */ SelectorMatcher.prototype.addSelectables = /** * @param {?} cssSelectors * @param {?=} callbackCtxt * @return {?} */ function (cssSelectors, callbackCtxt) { var /** @type {?} */ listContext = /** @type {?} */ ((null)); if (cssSelectors.length > 1) { listContext = new SelectorListContext(cssSelectors); this._listContexts.push(listContext); } for (var /** @type {?} */ i = 0; i < cssSelectors.length; i++) { this._addSelectable(cssSelectors[i], callbackCtxt, listContext); } }; /** * Add an object that can be found later on by calling `match`. * @param {?} cssSelector A css selector * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function * @param {?} listContext * @return {?} */ SelectorMatcher.prototype._addSelectable = /** * Add an object that can be found later on by calling `match`. * @param {?} cssSelector A css selector * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function * @param {?} listContext * @return {?} */ function (cssSelector, callbackCtxt, listContext) { var /** @type {?} */ matcher = this; var /** @type {?} */ element = cssSelector.element; var /** @type {?} */ classNames = cssSelector.classNames; var /** @type {?} */ attrs = cssSelector.attrs; var /** @type {?} */ selectable = new SelectorContext(cssSelector, callbackCtxt, listContext); if (element) { var /** @type {?} */ isTerminal = attrs.length === 0 && classNames.length === 0; if (isTerminal) { this._addTerminal(matcher._elementMap, element, selectable); } else { matcher = this._addPartial(matcher._elementPartialMap, element); } } if (classNames) { for (var /** @type {?} */ i = 0; i < classNames.length; i++) { var /** @type {?} */ isTerminal = attrs.length === 0 && i === classNames.length - 1; var /** @type {?} */ className = classNames[i]; if (isTerminal) { this._addTerminal(matcher._classMap, className, selectable); } else { matcher = this._addPartial(matcher._classPartialMap, className); } } } if (attrs) { for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) { var /** @type {?} */ isTerminal = i === attrs.length - 2; var /** @type {?} */ name_2 = attrs[i]; var /** @type {?} */ value = attrs[i + 1]; if (isTerminal) { var /** @type {?} */ terminalMap = matcher._attrValueMap; var /** @type {?} */ terminalValuesMap = terminalMap.get(name_2); if (!terminalValuesMap) { terminalValuesMap = new Map(); terminalMap.set(name_2, terminalValuesMap); } this._addTerminal(terminalValuesMap, value, selectable); } else { var /** @type {?} */ partialMap = matcher._attrValuePartialMap; var /** @type {?} */ partialValuesMap = partialMap.get(name_2); if (!partialValuesMap) { partialValuesMap = new Map(); partialMap.set(name_2, partialValuesMap); } matcher = this._addPartial(partialValuesMap, value); } } } }; /** * @param {?} map * @param {?} name * @param {?} selectable * @return {?} */ SelectorMatcher.prototype._addTerminal = /** * @param {?} map * @param {?} name * @param {?} selectable * @return {?} */ function (map, name, selectable) { var /** @type {?} */ terminalList = map.get(name); if (!terminalList) { terminalList = []; map.set(name, terminalList); } terminalList.push(selectable); }; /** * @param {?} map * @param {?} name * @return {?} */ SelectorMatcher.prototype._addPartial = /** * @param {?} map * @param {?} name * @return {?} */ function (map, name) { var /** @type {?} */ matcher = map.get(name); if (!matcher) { matcher = new SelectorMatcher(); map.set(name, matcher); } return matcher; }; /** * Find the objects that have been added via `addSelectable` * whose css selector is contained in the given css selector. * @param cssSelector A css selector * @param matchedCallback This callback will be called with the object handed into `addSelectable` * @return boolean true if a match was found */ /** * Find the objects that have been added via `addSelectable` * whose css selector is contained in the given css selector. * @param {?} cssSelector A css selector * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable` * @return {?} boolean true if a match was found */ SelectorMatcher.prototype.match = /** * Find the objects that have been added via `addSelectable` * whose css selector is contained in the given css selector. * @param {?} cssSelector A css selector * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable` * @return {?} boolean true if a match was found */ function (cssSelector, matchedCallback) { var /** @type {?} */ result = false; var /** @type {?} */ element = /** @type {?} */ ((cssSelector.element)); var /** @type {?} */ classNames = cssSelector.classNames; var /** @type {?} */ attrs = cssSelector.attrs; for (var /** @type {?} */ i = 0; i < this._listContexts.length; i++) { this._listContexts[i].alreadyMatched = false; } result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result; result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) || result; if (classNames) { for (var /** @type {?} */ i = 0; i < classNames.length; i++) { var /** @type {?} */ className = classNames[i]; result = this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result; result = this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) || result; } } if (attrs) { for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) { var /** @type {?} */ name_3 = attrs[i]; var /** @type {?} */ value = attrs[i + 1]; var /** @type {?} */ terminalValuesMap = /** @type {?} */ ((this._attrValueMap.get(name_3))); if (value) { result = this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result; } result = this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result; var /** @type {?} */ partialValuesMap = /** @type {?} */ ((this._attrValuePartialMap.get(name_3))); if (value) { result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result; } result = this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result; } } return result; }; /** @internal */ /** * \@internal * @param {?} map * @param {?} name * @param {?} cssSelector * @param {?} matchedCallback * @return {?} */ SelectorMatcher.prototype._matchTerminal = /** * \@internal * @param {?} map * @param {?} name * @param {?} cssSelector * @param {?} matchedCallback * @return {?} */ function (map, name, cssSelector, matchedCallback) { if (!map || typeof name !== 'string') { return false; } var /** @type {?} */ selectables = map.get(name) || []; var /** @type {?} */ starSelectables = /** @type {?} */ ((map.get('*'))); if (starSelectables) { selectables = selectables.concat(starSelectables); } if (selectables.length === 0) { return false; } var /** @type {?} */ selectable; var /** @type {?} */ result = false; for (var /** @type {?} */ i = 0; i < selectables.length; i++) { selectable = selectables[i]; result = selectable.finalize(cssSelector, matchedCallback) || result; } return result; }; /** @internal */ /** * \@internal * @param {?} map * @param {?} name * @param {?} cssSelector * @param {?} matchedCallback * @return {?} */ SelectorMatcher.prototype._matchPartial = /** * \@internal * @param {?} map * @param {?} name * @param {?} cssSelector * @param {?} matchedCallback * @return {?} */ function (map, name, cssSelector, matchedCallback) { if (!map || typeof name !== 'string') { return false; } var /** @type {?} */ nestedSelector = map.get(name); if (!nestedSelector) { return false; } // TODO(perf): get rid of recursion and measure again // TODO(perf): don't pass the whole selector into the recursion, // but only the not processed parts return nestedSelector.match(cssSelector, matchedCallback); }; return SelectorMatcher; }()); var SelectorListContext = /** @class */ (function () { function SelectorListContext(selectors) { this.selectors = selectors; this.alreadyMatched = false; } return SelectorListContext; }()); var SelectorContext = /** @class */ (function () { function SelectorContext(selector, cbContext, listContext) { this.selector = selector; this.cbContext = cbContext; this.listContext = listContext; this.notSelectors = selector.notSelectors; } /** * @param {?} cssSelector * @param {?} callback * @return {?} */ SelectorContext.prototype.finalize = /** * @param {?} cssSelector * @param {?} callback * @return {?} */ function (cssSelector, callback) { var /** @type {?} */ result = true; if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) { var /** @type {?} */ notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors); result = !notMatcher.match(cssSelector, null); } if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) { if (this.listContext) { this.listContext.alreadyMatched = true; } callback(this.selector, this.cbContext); } return result; }; return SelectorContext; }()); /** * @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_COMPONENT_TYPE = 'ngComponentType'; var CompileMetadataResolver = /** @class */ (function () { function CompileMetadataResolver(_config, _htmlParser, _ngModuleResolver, _directiveResolver, _pipeResolver, _summaryResolver, _schemaRegistry, _directiveNormalizer, _console, _staticSymbolCache, _reflector, _errorCollector) { this._config = _config; this._htmlParser = _htmlParser; this._ngModuleResolver = _ngModuleResolver; this._directiveResolver = _directiveResolver; this._pipeResolver = _pipeResolver; this._summaryResolver = _summaryResolver; this._schemaRegistry = _schemaRegistry; this._directiveNormalizer = _directiveNormalizer; this._console = _console; this._staticSymbolCache = _staticSymbolCache; this._reflector = _reflector; this._errorCollector = _errorCollector; this._nonNormalizedDirectiveCache = new Map(); this._directiveCache = new Map(); this._summaryCache = new Map(); this._pipeCache = new Map(); this._ngModuleCache = new Map(); this._ngModuleOfTypes = new Map(); } /** * @return {?} */ CompileMetadataResolver.prototype.getReflector = /** * @return {?} */ function () { return this._reflector; }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.clearCacheFor = /** * @param {?} type * @return {?} */ function (type) { var /** @type {?} */ dirMeta = this._directiveCache.get(type); this._directiveCache.delete(type); this._nonNormalizedDirectiveCache.delete(type); this._summaryCache.delete(type); this._pipeCache.delete(type); this._ngModuleOfTypes.delete(type); // Clear all of the NgModule as they contain transitive information! this._ngModuleCache.clear(); if (dirMeta) { this._directiveNormalizer.clearCacheFor(dirMeta); } }; /** * @return {?} */ CompileMetadataResolver.prototype.clearCache = /** * @return {?} */ function () { this._directiveCache.clear(); this._nonNormalizedDirectiveCache.clear(); this._summaryCache.clear(); this._pipeCache.clear(); this._ngModuleCache.clear(); this._ngModuleOfTypes.clear(); this._directiveNormalizer.clearCache(); }; /** * @param {?} baseType * @param {?} name * @return {?} */ CompileMetadataResolver.prototype._createProxyClass = /** * @param {?} baseType * @param {?} name * @return {?} */ function (baseType, name) { var /** @type {?} */ delegate = null; var /** @type {?} */ proxyClass = /** @type {?} */ (function () { if (!delegate) { throw new Error("Illegal state: Class " + name + " for type " + stringify(baseType) + " is not compiled yet!"); } return delegate.apply(this, arguments); }); proxyClass.setDelegate = function (d) { delegate = d; (/** @type {?} */ (proxyClass)).prototype = d.prototype; }; // Make stringify work correctly (/** @type {?} */ (proxyClass)).overriddenName = name; return proxyClass; }; /** * @param {?} dirType * @param {?} name * @return {?} */ CompileMetadataResolver.prototype.getGeneratedClass = /** * @param {?} dirType * @param {?} name * @return {?} */ function (dirType, name) { if (dirType instanceof StaticSymbol) { return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), name); } else { return this._createProxyClass(dirType, name); } }; /** * @param {?} dirType * @return {?} */ CompileMetadataResolver.prototype.getComponentViewClass = /** * @param {?} dirType * @return {?} */ function (dirType) { return this.getGeneratedClass(dirType, viewClassName(dirType, 0)); }; /** * @param {?} dirType * @return {?} */ CompileMetadataResolver.prototype.getHostComponentViewClass = /** * @param {?} dirType * @return {?} */ function (dirType) { return this.getGeneratedClass(dirType, hostViewClassName(dirType)); }; /** * @param {?} dirType * @return {?} */ CompileMetadataResolver.prototype.getHostComponentType = /** * @param {?} dirType * @return {?} */ function (dirType) { var /** @type {?} */ name = identifierName({ reference: dirType }) + "_Host"; if (dirType instanceof StaticSymbol) { return this._staticSymbolCache.get(dirType.filePath, name); } else { var /** @type {?} */ HostClass = /** @type {?} */ (function HostClass() { }); HostClass.overriddenName = name; return HostClass; } }; /** * @param {?} dirType * @return {?} */ CompileMetadataResolver.prototype.getRendererType = /** * @param {?} dirType * @return {?} */ function (dirType) { if (dirType instanceof StaticSymbol) { return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), rendererTypeName(dirType)); } else { // returning an object as proxy, // that we fill later during runtime compilation. return /** @type {?} */ ({}); } }; /** * @param {?} selector * @param {?} dirType * @param {?} inputs * @param {?} outputs * @return {?} */ CompileMetadataResolver.prototype.getComponentFactory = /** * @param {?} selector * @param {?} dirType * @param {?} inputs * @param {?} outputs * @return {?} */ function (selector, dirType, inputs, outputs) { if (dirType instanceof StaticSymbol) { return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), componentFactoryName(dirType)); } else { var /** @type {?} */ hostView = this.getHostComponentViewClass(dirType); // Note: ngContentSelectors will be filled later once the template is // loaded. var /** @type {?} */ createComponentFactory = this._reflector.resolveExternalReference(Identifiers.createComponentFactory); return createComponentFactory(selector, dirType, /** @type {?} */ (hostView), inputs, outputs, []); } }; /** * @param {?} factory * @param {?} ngContentSelectors * @return {?} */ CompileMetadataResolver.prototype.initComponentFactory = /** * @param {?} factory * @param {?} ngContentSelectors * @return {?} */ function (factory, ngContentSelectors) { if (!(factory instanceof StaticSymbol)) { (_a = (/** @type {?} */ (factory)).ngContentSelectors).push.apply(_a, ngContentSelectors); } var _a; }; /** * @param {?} type * @param {?} kind * @return {?} */ CompileMetadataResolver.prototype._loadSummary = /** * @param {?} type * @param {?} kind * @return {?} */ function (type, kind) { var /** @type {?} */ typeSummary = this._summaryCache.get(type); if (!typeSummary) { var /** @type {?} */ summary = this._summaryResolver.resolveSummary(type); typeSummary = summary ? summary.type : null; this._summaryCache.set(type, typeSummary || null); } return typeSummary && typeSummary.summaryKind === kind ? typeSummary : null; }; /** * @param {?} compMeta * @param {?=} hostViewType * @return {?} */ CompileMetadataResolver.prototype.getHostComponentMetadata = /** * @param {?} compMeta * @param {?=} hostViewType * @return {?} */ function (compMeta, hostViewType) { var /** @type {?} */ hostType = this.getHostComponentType(compMeta.type.reference); if (!hostViewType) { hostViewType = this.getHostComponentViewClass(hostType); } // Note: ! is ok here as this method should only be called with normalized directive // metadata, which always fills in the selector. var /** @type {?} */ template = CssSelector.parse(/** @type {?} */ ((compMeta.selector)))[0].getMatchingElementTemplate(); var /** @type {?} */ templateUrl = ''; var /** @type {?} */ htmlAst = this._htmlParser.parse(template, templateUrl); return CompileDirectiveMetadata.create({ isHost: true, type: { reference: hostType, diDeps: [], lifecycleHooks: [] }, template: new CompileTemplateMetadata({ encapsulation: ViewEncapsulation.None, template: template, templateUrl: templateUrl, htmlAst: htmlAst, styles: [], styleUrls: [], ngContentSelectors: [], animations: [], isInline: true, externalStylesheets: [], interpolation: null, preserveWhitespaces: false, }), exportAs: null, changeDetection: ChangeDetectionStrategy.Default, inputs: [], outputs: [], host: {}, isComponent: true, selector: '*', providers: [], viewProviders: [], queries: [], guards: {}, viewQueries: [], componentViewType: hostViewType, rendererType: /** @type {?} */ ({ id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {} }), entryComponents: [], componentFactory: null }); }; /** * @param {?} ngModuleType * @param {?} directiveType * @param {?} isSync * @return {?} */ CompileMetadataResolver.prototype.loadDirectiveMetadata = /** * @param {?} ngModuleType * @param {?} directiveType * @param {?} isSync * @return {?} */ function (ngModuleType, directiveType, isSync) { var _this = this; if (this._directiveCache.has(directiveType)) { return null; } directiveType = resolveForwardRef(directiveType); var _a = /** @type {?} */ ((this.getNonNormalizedDirectiveMetadata(directiveType))), annotation = _a.annotation, metadata = _a.metadata; var /** @type {?} */ createDirectiveMetadata = function (templateMetadata) { var /** @type {?} */ normalizedDirMeta = new CompileDirectiveMetadata({ isHost: false, type: metadata.type, isComponent: metadata.isComponent, selector: metadata.selector, exportAs: metadata.exportAs, changeDetection: metadata.changeDetection, inputs: metadata.inputs, outputs: metadata.outputs, hostListeners: metadata.hostListeners, hostProperties: metadata.hostProperties, hostAttributes: metadata.hostAttributes, providers: metadata.providers, viewProviders: metadata.viewProviders, queries: metadata.queries, guards: metadata.guards, viewQueries: metadata.viewQueries, entryComponents: metadata.entryComponents, componentViewType: metadata.componentViewType, rendererType: metadata.rendererType, componentFactory: metadata.componentFactory, template: templateMetadata }); if (templateMetadata) { _this.initComponentFactory(/** @type {?} */ ((metadata.componentFactory)), templateMetadata.ngContentSelectors); } _this._directiveCache.set(directiveType, normalizedDirMeta); _this._summaryCache.set(directiveType, normalizedDirMeta.toSummary()); return null; }; if (metadata.isComponent) { var /** @type {?} */ template = /** @type {?} */ ((metadata.template)); var /** @type {?} */ templateMeta = this._directiveNormalizer.normalizeTemplate({ ngModuleType: ngModuleType, componentType: directiveType, moduleUrl: this._reflector.componentModuleUrl(directiveType, annotation), encapsulation: template.encapsulation, template: template.template, templateUrl: template.templateUrl, styles: template.styles, styleUrls: template.styleUrls, animations: template.animations, interpolation: template.interpolation, preserveWhitespaces: template.preserveWhitespaces }); if (isPromise(templateMeta) && isSync) { this._reportError(componentStillLoadingError(directiveType), directiveType); return null; } return SyncAsync.then(templateMeta, createDirectiveMetadata); } else { // directive createDirectiveMetadata(null); return null; } }; /** * @param {?} directiveType * @return {?} */ CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata = /** * @param {?} directiveType * @return {?} */ function (directiveType) { var _this = this; directiveType = resolveForwardRef(directiveType); if (!directiveType) { return null; } var /** @type {?} */ cacheEntry = this._nonNormalizedDirectiveCache.get(directiveType); if (cacheEntry) { return cacheEntry; } var /** @type {?} */ dirMeta = this._directiveResolver.resolve(directiveType, false); if (!dirMeta) { return null; } var /** @type {?} */ nonNormalizedTemplateMetadata = /** @type {?} */ ((undefined)); if (createComponent.isTypeOf(dirMeta)) { // component var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta); assertArrayOfStrings('styles', compMeta.styles); assertArrayOfStrings('styleUrls', compMeta.styleUrls); assertInterpolationSymbols('interpolation', compMeta.interpolation); var /** @type {?} */ animations = compMeta.animations; nonNormalizedTemplateMetadata = new CompileTemplateMetadata({ encapsulation: noUndefined(compMeta.encapsulation), template: noUndefined(compMeta.template), templateUrl: noUndefined(compMeta.templateUrl), htmlAst: null, styles: compMeta.styles || [], styleUrls: compMeta.styleUrls || [], animations: animations || [], interpolation: noUndefined(compMeta.interpolation), isInline: !!compMeta.template, externalStylesheets: [], ngContentSelectors: [], preserveWhitespaces: noUndefined(dirMeta.preserveWhitespaces), }); } var /** @type {?} */ changeDetectionStrategy = /** @type {?} */ ((null)); var /** @type {?} */ viewProviders = []; var /** @type {?} */ entryComponentMetadata = []; var /** @type {?} */ selector = dirMeta.selector; if (createComponent.isTypeOf(dirMeta)) { // Component var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta); changeDetectionStrategy = /** @type {?} */ ((compMeta.changeDetection)); if (compMeta.viewProviders) { viewProviders = this._getProvidersMetadata(compMeta.viewProviders, entryComponentMetadata, "viewProviders for \"" + stringifyType(directiveType) + "\"", [], directiveType); } if (compMeta.entryComponents) { entryComponentMetadata = flattenAndDedupeArray(compMeta.entryComponents) .map(function (type) { return ((_this._getEntryComponentMetadata(type))); }) .concat(entryComponentMetadata); } if (!selector) { selector = this._schemaRegistry.getDefaultComponentElementName(); } } else { // Directive if (!selector) { this._reportError(syntaxError("Directive " + stringifyType(directiveType) + " has no selector, please add it!"), directiveType); selector = 'error'; } } var /** @type {?} */ providers = []; if (dirMeta.providers != null) { providers = this._getProvidersMetadata(dirMeta.providers, entryComponentMetadata, "providers for \"" + stringifyType(directiveType) + "\"", [], directiveType); } var /** @type {?} */ queries = []; var /** @type {?} */ viewQueries = []; if (dirMeta.queries != null) { queries = this._getQueriesMetadata(dirMeta.queries, false, directiveType); viewQueries = this._getQueriesMetadata(dirMeta.queries, true, directiveType); } var /** @type {?} */ metadata = CompileDirectiveMetadata.create({ isHost: false, selector: selector, exportAs: noUndefined(dirMeta.exportAs), isComponent: !!nonNormalizedTemplateMetadata, type: this._getTypeMetadata(directiveType), template: nonNormalizedTemplateMetadata, changeDetection: changeDetectionStrategy, inputs: dirMeta.inputs || [], outputs: dirMeta.outputs || [], host: dirMeta.host || {}, providers: providers || [], viewProviders: viewProviders || [], queries: queries || [], guards: dirMeta.guards || {}, viewQueries: viewQueries || [], entryComponents: entryComponentMetadata, componentViewType: nonNormalizedTemplateMetadata ? this.getComponentViewClass(directiveType) : null, rendererType: nonNormalizedTemplateMetadata ? this.getRendererType(directiveType) : null, componentFactory: null }); if (nonNormalizedTemplateMetadata) { metadata.componentFactory = this.getComponentFactory(selector, directiveType, metadata.inputs, metadata.outputs); } cacheEntry = { metadata: metadata, annotation: dirMeta }; this._nonNormalizedDirectiveCache.set(directiveType, cacheEntry); return cacheEntry; }; /** * Gets the metadata for the given directive. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. */ /** * Gets the metadata for the given directive. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. * @param {?} directiveType * @return {?} */ CompileMetadataResolver.prototype.getDirectiveMetadata = /** * Gets the metadata for the given directive. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. * @param {?} directiveType * @return {?} */ function (directiveType) { var /** @type {?} */ dirMeta = /** @type {?} */ ((this._directiveCache.get(directiveType))); if (!dirMeta) { this._reportError(syntaxError("Illegal state: getDirectiveMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Directive " + stringifyType(directiveType) + "."), directiveType); } return dirMeta; }; /** * @param {?} dirType * @return {?} */ CompileMetadataResolver.prototype.getDirectiveSummary = /** * @param {?} dirType * @return {?} */ function (dirType) { var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive)); if (!dirSummary) { this._reportError(syntaxError("Illegal state: Could not load the summary for directive " + stringifyType(dirType) + "."), dirType); } return dirSummary; }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.isDirective = /** * @param {?} type * @return {?} */ function (type) { return !!this._loadSummary(type, CompileSummaryKind.Directive) || this._directiveResolver.isDirective(type); }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.isPipe = /** * @param {?} type * @return {?} */ function (type) { return !!this._loadSummary(type, CompileSummaryKind.Pipe) || this._pipeResolver.isPipe(type); }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.isNgModule = /** * @param {?} type * @return {?} */ function (type) { return !!this._loadSummary(type, CompileSummaryKind.NgModule) || this._ngModuleResolver.isNgModule(type); }; /** * @param {?} moduleType * @param {?=} alreadyCollecting * @return {?} */ CompileMetadataResolver.prototype.getNgModuleSummary = /** * @param {?} moduleType * @param {?=} alreadyCollecting * @return {?} */ function (moduleType, alreadyCollecting) { if (alreadyCollecting === void 0) { alreadyCollecting = null; } var /** @type {?} */ moduleSummary = /** @type {?} */ (this._loadSummary(moduleType, CompileSummaryKind.NgModule)); if (!moduleSummary) { var /** @type {?} */ moduleMeta = this.getNgModuleMetadata(moduleType, false, alreadyCollecting); moduleSummary = moduleMeta ? moduleMeta.toSummary() : null; if (moduleSummary) { this._summaryCache.set(moduleType, moduleSummary); } } return moduleSummary; }; /** * Loads the declared directives and pipes of an NgModule. */ /** * Loads the declared directives and pipes of an NgModule. * @param {?} moduleType * @param {?} isSync * @param {?=} throwIfNotFound * @return {?} */ CompileMetadataResolver.prototype.loadNgModuleDirectiveAndPipeMetadata = /** * Loads the declared directives and pipes of an NgModule. * @param {?} moduleType * @param {?} isSync * @param {?=} throwIfNotFound * @return {?} */ function (moduleType, isSync, throwIfNotFound) { var _this = this; if (throwIfNotFound === void 0) { throwIfNotFound = true; } var /** @type {?} */ ngModule = this.getNgModuleMetadata(moduleType, throwIfNotFound); var /** @type {?} */ loading = []; if (ngModule) { ngModule.declaredDirectives.forEach(function (id) { var /** @type {?} */ promise = _this.loadDirectiveMetadata(moduleType, id.reference, isSync); if (promise) { loading.push(promise); } }); ngModule.declaredPipes.forEach(function (id) { return _this._loadPipeMetadata(id.reference); }); } return Promise.all(loading); }; /** * @param {?} moduleType * @param {?=} throwIfNotFound * @param {?=} alreadyCollecting * @return {?} */ CompileMetadataResolver.prototype.getNgModuleMetadata = /** * @param {?} moduleType * @param {?=} throwIfNotFound * @param {?=} alreadyCollecting * @return {?} */ function (moduleType, throwIfNotFound, alreadyCollecting) { var _this = this; if (throwIfNotFound === void 0) { throwIfNotFound = true; } if (alreadyCollecting === void 0) { alreadyCollecting = null; } moduleType = resolveForwardRef(moduleType); var /** @type {?} */ compileMeta = this._ngModuleCache.get(moduleType); if (compileMeta) { return compileMeta; } var /** @type {?} */ meta = this._ngModuleResolver.resolve(moduleType, throwIfNotFound); if (!meta) { return null; } var /** @type {?} */ declaredDirectives = []; var /** @type {?} */ exportedNonModuleIdentifiers = []; var /** @type {?} */ declaredPipes = []; var /** @type {?} */ importedModules = []; var /** @type {?} */ exportedModules = []; var /** @type {?} */ providers = []; var /** @type {?} */ entryComponents = []; var /** @type {?} */ bootstrapComponents = []; var /** @type {?} */ schemas = []; if (meta.imports) { flattenAndDedupeArray(meta.imports).forEach(function (importedType) { var /** @type {?} */ importedModuleType = /** @type {?} */ ((undefined)); if (isValidType(importedType)) { importedModuleType = importedType; } else if (importedType && importedType.ngModule) { var /** @type {?} */ moduleWithProviders = importedType; importedModuleType = moduleWithProviders.ngModule; if (moduleWithProviders.providers) { providers.push.apply(providers, _this._getProvidersMetadata(moduleWithProviders.providers, entryComponents, "provider for the NgModule '" + stringifyType(importedModuleType) + "'", [], importedType)); } } if (importedModuleType) { if (_this._checkSelfImport(moduleType, importedModuleType)) return; if (!alreadyCollecting) alreadyCollecting = new Set(); if (alreadyCollecting.has(importedModuleType)) { _this._reportError(syntaxError(_this._getTypeDescriptor(importedModuleType) + " '" + stringifyType(importedType) + "' is imported recursively by the module '" + stringifyType(moduleType) + "'."), moduleType); return; } alreadyCollecting.add(importedModuleType); var /** @type {?} */ importedModuleSummary = _this.getNgModuleSummary(importedModuleType, alreadyCollecting); alreadyCollecting.delete(importedModuleType); if (!importedModuleSummary) { _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(importedType) + " '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'. Please add a @NgModule annotation."), moduleType); return; } importedModules.push(importedModuleSummary); } else { _this._reportError(syntaxError("Unexpected value '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'"), moduleType); return; } }); } if (meta.exports) { flattenAndDedupeArray(meta.exports).forEach(function (exportedType) { if (!isValidType(exportedType)) { _this._reportError(syntaxError("Unexpected value '" + stringifyType(exportedType) + "' exported by the module '" + stringifyType(moduleType) + "'"), moduleType); return; } if (!alreadyCollecting) alreadyCollecting = new Set(); if (alreadyCollecting.has(exportedType)) { _this._reportError(syntaxError(_this._getTypeDescriptor(exportedType) + " '" + stringify(exportedType) + "' is exported recursively by the module '" + stringifyType(moduleType) + "'"), moduleType); return; } alreadyCollecting.add(exportedType); var /** @type {?} */ exportedModuleSummary = _this.getNgModuleSummary(exportedType, alreadyCollecting); alreadyCollecting.delete(exportedType); if (exportedModuleSummary) { exportedModules.push(exportedModuleSummary); } else { exportedNonModuleIdentifiers.push(_this._getIdentifierMetadata(exportedType)); } }); } // Note: This will be modified later, so we rely on // getting a new instance every time! var /** @type {?} */ transitiveModule = this._getTransitiveNgModuleMetadata(importedModules, exportedModules); if (meta.declarations) { flattenAndDedupeArray(meta.declarations).forEach(function (declaredType) { if (!isValidType(declaredType)) { _this._reportError(syntaxError("Unexpected value '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'"), moduleType); return; } var /** @type {?} */ declaredIdentifier = _this._getIdentifierMetadata(declaredType); if (_this.isDirective(declaredType)) { transitiveModule.addDirective(declaredIdentifier); declaredDirectives.push(declaredIdentifier); _this._addTypeToModule(declaredType, moduleType); } else if (_this.isPipe(declaredType)) { transitiveModule.addPipe(declaredIdentifier); transitiveModule.pipes.push(declaredIdentifier); declaredPipes.push(declaredIdentifier); _this._addTypeToModule(declaredType, moduleType); } else { _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(declaredType) + " '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'. Please add a @Pipe/@Directive/@Component annotation."), moduleType); return; } }); } var /** @type {?} */ exportedDirectives = []; var /** @type {?} */ exportedPipes = []; exportedNonModuleIdentifiers.forEach(function (exportedId) { if (transitiveModule.directivesSet.has(exportedId.reference)) { exportedDirectives.push(exportedId); transitiveModule.addExportedDirective(exportedId); } else if (transitiveModule.pipesSet.has(exportedId.reference)) { exportedPipes.push(exportedId); transitiveModule.addExportedPipe(exportedId); } else { _this._reportError(syntaxError("Can't export " + _this._getTypeDescriptor(exportedId.reference) + " " + stringifyType(exportedId.reference) + " from " + stringifyType(moduleType) + " as it was neither declared nor imported!"), moduleType); return; } }); // The providers of the module have to go last // so that they overwrite any other provider we already added. if (meta.providers) { providers.push.apply(providers, this._getProvidersMetadata(meta.providers, entryComponents, "provider for the NgModule '" + stringifyType(moduleType) + "'", [], moduleType)); } if (meta.entryComponents) { entryComponents.push.apply(entryComponents, flattenAndDedupeArray(meta.entryComponents) .map(function (type) { return ((_this._getEntryComponentMetadata(type))); })); } if (meta.bootstrap) { flattenAndDedupeArray(meta.bootstrap).forEach(function (type) { if (!isValidType(type)) { _this._reportError(syntaxError("Unexpected value '" + stringifyType(type) + "' used in the bootstrap property of module '" + stringifyType(moduleType) + "'"), moduleType); return; } bootstrapComponents.push(_this._getIdentifierMetadata(type)); }); } entryComponents.push.apply(entryComponents, bootstrapComponents.map(function (type) { return ((_this._getEntryComponentMetadata(type.reference))); })); if (meta.schemas) { schemas.push.apply(schemas, flattenAndDedupeArray(meta.schemas)); } compileMeta = new CompileNgModuleMetadata({ type: this._getTypeMetadata(moduleType), providers: providers, entryComponents: entryComponents, bootstrapComponents: bootstrapComponents, schemas: schemas, declaredDirectives: declaredDirectives, exportedDirectives: exportedDirectives, declaredPipes: declaredPipes, exportedPipes: exportedPipes, importedModules: importedModules, exportedModules: exportedModules, transitiveModule: transitiveModule, id: meta.id || null, }); entryComponents.forEach(function (id) { return transitiveModule.addEntryComponent(id); }); providers.forEach(function (provider) { return transitiveModule.addProvider(provider, /** @type {?} */ ((compileMeta)).type); }); transitiveModule.addModule(compileMeta.type); this._ngModuleCache.set(moduleType, compileMeta); return compileMeta; }; /** * @param {?} moduleType * @param {?} importedModuleType * @return {?} */ CompileMetadataResolver.prototype._checkSelfImport = /** * @param {?} moduleType * @param {?} importedModuleType * @return {?} */ function (moduleType, importedModuleType) { if (moduleType === importedModuleType) { this._reportError(syntaxError("'" + stringifyType(moduleType) + "' module can't import itself"), moduleType); return true; } return false; }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype._getTypeDescriptor = /** * @param {?} type * @return {?} */ function (type) { if (isValidType(type)) { if (this.isDirective(type)) { return 'directive'; } if (this.isPipe(type)) { return 'pipe'; } if (this.isNgModule(type)) { return 'module'; } } if ((/** @type {?} */ (type)).provide) { return 'provider'; } return 'value'; }; /** * @param {?} type * @param {?} moduleType * @return {?} */ CompileMetadataResolver.prototype._addTypeToModule = /** * @param {?} type * @param {?} moduleType * @return {?} */ function (type, moduleType) { var /** @type {?} */ oldModule = this._ngModuleOfTypes.get(type); if (oldModule && oldModule !== moduleType) { this._reportError(syntaxError("Type " + stringifyType(type) + " is part of the declarations of 2 modules: " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + "! " + ("Please consider moving " + stringifyType(type) + " to a higher module that imports " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ". ") + ("You can also create a new NgModule that exports and includes " + stringifyType(type) + " then import that NgModule in " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ".")), moduleType); return; } this._ngModuleOfTypes.set(type, moduleType); }; /** * @param {?} importedModules * @param {?} exportedModules * @return {?} */ CompileMetadataResolver.prototype._getTransitiveNgModuleMetadata = /** * @param {?} importedModules * @param {?} exportedModules * @return {?} */ function (importedModules, exportedModules) { // collect `providers` / `entryComponents` from all imported and all exported modules var /** @type {?} */ result = new TransitiveCompileNgModuleMetadata(); var /** @type {?} */ modulesByToken = new Map(); importedModules.concat(exportedModules).forEach(function (modSummary) { modSummary.modules.forEach(function (mod) { return result.addModule(mod); }); modSummary.entryComponents.forEach(function (comp) { return result.addEntryComponent(comp); }); var /** @type {?} */ addedTokens = new Set(); modSummary.providers.forEach(function (entry) { var /** @type {?} */ tokenRef = tokenReference(entry.provider.token); var /** @type {?} */ prevModules = modulesByToken.get(tokenRef); if (!prevModules) { prevModules = new Set(); modulesByToken.set(tokenRef, prevModules); } var /** @type {?} */ moduleRef = entry.module.reference; // Note: the providers of one module may still contain multiple providers // per token (e.g. for multi providers), and we need to preserve these. if (addedTokens.has(tokenRef) || !prevModules.has(moduleRef)) { prevModules.add(moduleRef); addedTokens.add(tokenRef); result.addProvider(entry.provider, entry.module); } }); }); exportedModules.forEach(function (modSummary) { modSummary.exportedDirectives.forEach(function (id) { return result.addExportedDirective(id); }); modSummary.exportedPipes.forEach(function (id) { return result.addExportedPipe(id); }); }); importedModules.forEach(function (modSummary) { modSummary.exportedDirectives.forEach(function (id) { return result.addDirective(id); }); modSummary.exportedPipes.forEach(function (id) { return result.addPipe(id); }); }); return result; }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype._getIdentifierMetadata = /** * @param {?} type * @return {?} */ function (type) { type = resolveForwardRef(type); return { reference: type }; }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.isInjectable = /** * @param {?} type * @return {?} */ function (type) { var /** @type {?} */ annotations = this._reflector.annotations(type); return annotations.some(function (ann) { return createInjectable.isTypeOf(ann); }); }; /** * @param {?} type * @return {?} */ CompileMetadataResolver.prototype.getInjectableSummary = /** * @param {?} type * @return {?} */ function (type) { return { summaryKind: CompileSummaryKind.Injectable, type: this._getTypeMetadata(type, null, false) }; }; /** * @param {?} type * @param {?=} dependencies * @return {?} */ CompileMetadataResolver.prototype._getInjectableMetadata = /** * @param {?} type * @param {?=} dependencies * @return {?} */ function (type, dependencies) { if (dependencies === void 0) { dependencies = null; } var /** @type {?} */ typeSummary = this._loadSummary(type, CompileSummaryKind.Injectable); if (typeSummary) { return typeSummary.type; } return this._getTypeMetadata(type, dependencies); }; /** * @param {?} type * @param {?=} dependencies * @param {?=} throwOnUnknownDeps * @return {?} */ CompileMetadataResolver.prototype._getTypeMetadata = /** * @param {?} type * @param {?=} dependencies * @param {?=} throwOnUnknownDeps * @return {?} */ function (type, dependencies, throwOnUnknownDeps) { if (dependencies === void 0) { dependencies = null; } if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; } var /** @type {?} */ identifier = this._getIdentifierMetadata(type); return { reference: identifier.reference, diDeps: this._getDependenciesMetadata(identifier.reference, dependencies, throwOnUnknownDeps), lifecycleHooks: getAllLifecycleHooks(this._reflector, identifier.reference), }; }; /** * @param {?} factory * @param {?=} dependencies * @return {?} */ CompileMetadataResolver.prototype._getFactoryMetadata = /** * @param {?} factory * @param {?=} dependencies * @return {?} */ function (factory, dependencies) { if (dependencies === void 0) { dependencies = null; } factory = resolveForwardRef(factory); return { reference: factory, diDeps: this._getDependenciesMetadata(factory, dependencies) }; }; /** * Gets the metadata for the given pipe. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. */ /** * Gets the metadata for the given pipe. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. * @param {?} pipeType * @return {?} */ CompileMetadataResolver.prototype.getPipeMetadata = /** * Gets the metadata for the given pipe. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first. * @param {?} pipeType * @return {?} */ function (pipeType) { var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType); if (!pipeMeta) { this._reportError(syntaxError("Illegal state: getPipeMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Pipe " + stringifyType(pipeType) + "."), pipeType); } return pipeMeta || null; }; /** * @param {?} pipeType * @return {?} */ CompileMetadataResolver.prototype.getPipeSummary = /** * @param {?} pipeType * @return {?} */ function (pipeType) { var /** @type {?} */ pipeSummary = /** @type {?} */ (this._loadSummary(pipeType, CompileSummaryKind.Pipe)); if (!pipeSummary) { this._reportError(syntaxError("Illegal state: Could not load the summary for pipe " + stringifyType(pipeType) + "."), pipeType); } return pipeSummary; }; /** * @param {?} pipeType * @return {?} */ CompileMetadataResolver.prototype.getOrLoadPipeMetadata = /** * @param {?} pipeType * @return {?} */ function (pipeType) { var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType); if (!pipeMeta) { pipeMeta = this._loadPipeMetadata(pipeType); } return pipeMeta; }; /** * @param {?} pipeType * @return {?} */ CompileMetadataResolver.prototype._loadPipeMetadata = /** * @param {?} pipeType * @return {?} */ function (pipeType) { pipeType = resolveForwardRef(pipeType); var /** @type {?} */ pipeAnnotation = /** @type {?} */ ((this._pipeResolver.resolve(pipeType))); var /** @type {?} */ pipeMeta = new CompilePipeMetadata({ type: this._getTypeMetadata(pipeType), name: pipeAnnotation.name, pure: !!pipeAnnotation.pure }); this._pipeCache.set(pipeType, pipeMeta); this._summaryCache.set(pipeType, pipeMeta.toSummary()); return pipeMeta; }; /** * @param {?} typeOrFunc * @param {?} dependencies * @param {?=} throwOnUnknownDeps * @return {?} */ CompileMetadataResolver.prototype._getDependenciesMetadata = /** * @param {?} typeOrFunc * @param {?} dependencies * @param {?=} throwOnUnknownDeps * @return {?} */ function (typeOrFunc, dependencies, throwOnUnknownDeps) { var _this = this; if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; } var /** @type {?} */ hasUnknownDeps = false; var /** @type {?} */ params = dependencies || this._reflector.parameters(typeOrFunc) || []; var /** @type {?} */ dependenciesMetadata = params.map(function (param) { var /** @type {?} */ isAttribute = false; var /** @type {?} */ isHost = false; var /** @type {?} */ isSelf = false; var /** @type {?} */ isSkipSelf = false; var /** @type {?} */ isOptional = false; var /** @type {?} */ token = null; if (Array.isArray(param)) { param.forEach(function (paramEntry) { if (createHost.isTypeOf(paramEntry)) { isHost = true; } else if (createSelf.isTypeOf(paramEntry)) { isSelf = true; } else if (createSkipSelf.isTypeOf(paramEntry)) { isSkipSelf = true; } else if (createOptional.isTypeOf(paramEntry)) { isOptional = true; } else if (createAttribute.isTypeOf(paramEntry)) { isAttribute = true; token = paramEntry.attributeName; } else if (createInject.isTypeOf(paramEntry)) { token = paramEntry.token; } else if (createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) { token = paramEntry; } else if (isValidType(paramEntry) && token == null) { token = paramEntry; } }); } else { token = param; } if (token == null) { hasUnknownDeps = true; return /** @type {?} */ ((null)); } return { isAttribute: isAttribute, isHost: isHost, isSelf: isSelf, isSkipSelf: isSkipSelf, isOptional: isOptional, token: _this._getTokenMetadata(token) }; }); if (hasUnknownDeps) { var /** @type {?} */ depsTokens = dependenciesMetadata.map(function (dep) { return dep ? stringifyType(dep.token) : '?'; }).join(', '); var /** @type {?} */ message = "Can't resolve all parameters for " + stringifyType(typeOrFunc) + ": (" + depsTokens + ")."; if (throwOnUnknownDeps || this._config.strictInjectionParameters) { this._reportError(syntaxError(message), typeOrFunc); } else { this._console.warn("Warning: " + message + " This will become an error in Angular v6.x"); } } return dependenciesMetadata; }; /** * @param {?} token * @return {?} */ CompileMetadataResolver.prototype._getTokenMetadata = /** * @param {?} token * @return {?} */ function (token) { token = resolveForwardRef(token); var /** @type {?} */ compileToken; if (typeof token === 'string') { compileToken = { value: token }; } else { compileToken = { identifier: { reference: token } }; } return compileToken; }; /** * @param {?} providers * @param {?} targetEntryComponents * @param {?=} debugInfo * @param {?=} compileProviders * @param {?=} type * @return {?} */ CompileMetadataResolver.prototype._getProvidersMetadata = /** * @param {?} providers * @param {?} targetEntryComponents * @param {?=} debugInfo * @param {?=} compileProviders * @param {?=} type * @return {?} */ function (providers, targetEntryComponents, debugInfo, compileProviders, type) { var _this = this; if (compileProviders === void 0) { compileProviders = []; } providers.forEach(function (provider, providerIdx) { if (Array.isArray(provider)) { _this._getProvidersMetadata(provider, targetEntryComponents, debugInfo, compileProviders); } else { provider = resolveForwardRef(provider); var /** @type {?} */ providerMeta = /** @type {?} */ ((undefined)); if (provider && typeof provider === 'object' && provider.hasOwnProperty('provide')) { _this._validateProvider(provider); providerMeta = new ProviderMeta(provider.provide, provider); } else if (isValidType(provider)) { providerMeta = new ProviderMeta(provider, { useClass: provider }); } else if (provider === void 0) { _this._reportError(syntaxError("Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files.")); return; } else { var /** @type {?} */ providersInfo = (/** @type {?} */ (providers.reduce(function (soFar, seenProvider, seenProviderIdx) { if (seenProviderIdx < providerIdx) { soFar.push("" + stringifyType(seenProvider)); } else if (seenProviderIdx == providerIdx) { soFar.push("?" + stringifyType(seenProvider) + "?"); } else if (seenProviderIdx == providerIdx + 1) { soFar.push('...'); } return soFar; }, []))) .join(', '); _this._reportError(syntaxError("Invalid " + (debugInfo ? debugInfo : 'provider') + " - only instances of Provider and Type are allowed, got: [" + providersInfo + "]"), type); return; } if (providerMeta.token === _this._reflector.resolveExternalReference(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS)) { targetEntryComponents.push.apply(targetEntryComponents, _this._getEntryComponentsFromProvider(providerMeta, type)); } else { compileProviders.push(_this.getProviderMetadata(providerMeta)); } } }); return compileProviders; }; /** * @param {?} provider * @return {?} */ CompileMetadataResolver.prototype._validateProvider = /** * @param {?} provider * @return {?} */ function (provider) { if (provider.hasOwnProperty('useClass') && provider.useClass == null) { this._reportError(syntaxError("Invalid provider for " + stringifyType(provider.provide) + ". useClass cannot be " + provider.useClass + ".\n Usually it happens when:\n 1. There's a circular dependency (might be caused by using index.ts (barrel) files).\n 2. Class was used before it was declared. Use forwardRef in this case.")); } }; /** * @param {?} provider * @param {?=} type * @return {?} */ CompileMetadataResolver.prototype._getEntryComponentsFromProvider = /** * @param {?} provider * @param {?=} type * @return {?} */ function (provider, type) { var _this = this; var /** @type {?} */ components = []; var /** @type {?} */ collectedIdentifiers = []; if (provider.useFactory || provider.useExisting || provider.useClass) { this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!"), type); return []; } if (!provider.multi) { this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!"), type); return []; } extractIdentifiers(provider.useValue, collectedIdentifiers); collectedIdentifiers.forEach(function (identifier) { var /** @type {?} */ entry = _this._getEntryComponentMetadata(identifier.reference, false); if (entry) { components.push(entry); } }); return components; }; /** * @param {?} dirType * @param {?=} throwIfNotFound * @return {?} */ CompileMetadataResolver.prototype._getEntryComponentMetadata = /** * @param {?} dirType * @param {?=} throwIfNotFound * @return {?} */ function (dirType, throwIfNotFound) { if (throwIfNotFound === void 0) { throwIfNotFound = true; } var /** @type {?} */ dirMeta = this.getNonNormalizedDirectiveMetadata(dirType); if (dirMeta && dirMeta.metadata.isComponent) { return { componentType: dirType, componentFactory: /** @type {?} */ ((dirMeta.metadata.componentFactory)) }; } var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive)); if (dirSummary && dirSummary.isComponent) { return { componentType: dirType, componentFactory: /** @type {?} */ ((dirSummary.componentFactory)) }; } if (throwIfNotFound) { throw syntaxError(dirType.name + " cannot be used as an entry component."); } return null; }; /** * @param {?} provider * @return {?} */ CompileMetadataResolver.prototype.getProviderMetadata = /** * @param {?} provider * @return {?} */ function (provider) { var /** @type {?} */ compileDeps = /** @type {?} */ ((undefined)); var /** @type {?} */ compileTypeMetadata = /** @type {?} */ ((null)); var /** @type {?} */ compileFactoryMetadata = /** @type {?} */ ((null)); var /** @type {?} */ token = this._getTokenMetadata(provider.token); if (provider.useClass) { compileTypeMetadata = this._getInjectableMetadata(provider.useClass, provider.dependencies); compileDeps = compileTypeMetadata.diDeps; if (provider.token === provider.useClass) { // use the compileTypeMetadata as it contains information about lifecycleHooks... token = { identifier: compileTypeMetadata }; } } else if (provider.useFactory) { compileFactoryMetadata = this._getFactoryMetadata(provider.useFactory, provider.dependencies); compileDeps = compileFactoryMetadata.diDeps; } return { token: token, useClass: compileTypeMetadata, useValue: provider.useValue, useFactory: compileFactoryMetadata, useExisting: provider.useExisting ? this._getTokenMetadata(provider.useExisting) : undefined, deps: compileDeps, multi: provider.multi }; }; /** * @param {?} queries * @param {?} isViewQuery * @param {?} directiveType * @return {?} */ CompileMetadataResolver.prototype._getQueriesMetadata = /** * @param {?} queries * @param {?} isViewQuery * @param {?} directiveType * @return {?} */ function (queries, isViewQuery, directiveType) { var _this = this; var /** @type {?} */ res = []; Object.keys(queries).forEach(function (propertyName) { var /** @type {?} */ query = queries[propertyName]; if (query.isViewQuery === isViewQuery) { res.push(_this._getQueryMetadata(query, propertyName, directiveType)); } }); return res; }; /** * @param {?} selector * @return {?} */ CompileMetadataResolver.prototype._queryVarBindings = /** * @param {?} selector * @return {?} */ function (selector) { return selector.split(/\s*,\s*/); }; /** * @param {?} q * @param {?} propertyName * @param {?} typeOrFunc * @return {?} */ CompileMetadataResolver.prototype._getQueryMetadata = /** * @param {?} q * @param {?} propertyName * @param {?} typeOrFunc * @return {?} */ function (q, propertyName, typeOrFunc) { var _this = this; var /** @type {?} */ selectors; if (typeof q.selector === 'string') { selectors = this._queryVarBindings(q.selector).map(function (varName) { return _this._getTokenMetadata(varName); }); } else { if (!q.selector) { this._reportError(syntaxError("Can't construct a query for the property \"" + propertyName + "\" of \"" + stringifyType(typeOrFunc) + "\" since the query selector wasn't defined."), typeOrFunc); selectors = []; } else { selectors = [this._getTokenMetadata(q.selector)]; } } return { selectors: selectors, first: q.first, descendants: q.descendants, propertyName: propertyName, read: q.read ? this._getTokenMetadata(q.read) : /** @type {?} */ ((null)) }; }; /** * @param {?} error * @param {?=} type * @param {?=} otherType * @return {?} */ CompileMetadataResolver.prototype._reportError = /** * @param {?} error * @param {?=} type * @param {?=} otherType * @return {?} */ function (error, type, otherType) { if (this._errorCollector) { this._errorCollector(error, type); if (otherType) { this._errorCollector(error, otherType); } } else { throw error; } }; return CompileMetadataResolver; }()); /** * @param {?} tree * @param {?=} out * @return {?} */ function flattenArray(tree, out) { if (out === void 0) { out = []; } if (tree) { for (var /** @type {?} */ i = 0; i < tree.length; i++) { var /** @type {?} */ item = resolveForwardRef(tree[i]); if (Array.isArray(item)) { flattenArray(item, out); } else { out.push(item); } } } return out; } /** * @param {?} array * @return {?} */ function dedupeArray(array) { if (array) { return Array.from(new Set(array)); } return []; } /** * @param {?} tree * @return {?} */ function flattenAndDedupeArray(tree) { return dedupeArray(flattenArray(tree)); } /** * @param {?} value * @return {?} */ function isValidType(value) { return (value instanceof StaticSymbol) || (value instanceof Type); } /** * @param {?} value * @param {?} targetIdentifiers * @return {?} */ function extractIdentifiers(value, targetIdentifiers) { visitValue(value, new _CompileValueConverter(), targetIdentifiers); } var _CompileValueConverter = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_CompileValueConverter, _super); function _CompileValueConverter() { return _super !== null && _super.apply(this, arguments) || this; } /** * @param {?} value * @param {?} targetIdentifiers * @return {?} */ _CompileValueConverter.prototype.visitOther = /** * @param {?} value * @param {?} targetIdentifiers * @return {?} */ function (value, targetIdentifiers) { targetIdentifiers.push({ reference: value }); }; return _CompileValueConverter; }(ValueTransformer)); /** * @param {?} type * @return {?} */ function stringifyType(type) { if (type instanceof StaticSymbol) { return type.name + " in " + type.filePath; } else { return stringify(type); } } /** * Indicates that a component is still being loaded in a synchronous compile. * @param {?} compType * @return {?} */ function componentStillLoadingError(compType) { var /** @type {?} */ error = Error("Can't compile synchronously as " + stringify(compType) + " is still being loaded!"); (/** @type {?} */ (error))[ERROR_COMPONENT_TYPE] = compType; 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 */ /** @enum {number} */ var TypeModifier = { Const: 0, }; TypeModifier[TypeModifier.Const] = "Const"; /** * @abstract */ var Type$1 = /** @class */ (function () { function Type(modifiers) { if (modifiers === void 0) { modifiers = null; } this.modifiers = modifiers; if (!modifiers) { this.modifiers = []; } } /** * @param {?} modifier * @return {?} */ Type.prototype.hasModifier = /** * @param {?} modifier * @return {?} */ function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; }; return Type; }()); /** @enum {number} */ var BuiltinTypeName = { Dynamic: 0, Bool: 1, String: 2, Int: 3, Number: 4, Function: 5, Inferred: 6, }; BuiltinTypeName[BuiltinTypeName.Dynamic] = "Dynamic"; BuiltinTypeName[BuiltinTypeName.Bool] = "Bool"; BuiltinTypeName[BuiltinTypeName.String] = "String"; BuiltinTypeName[BuiltinTypeName.Int] = "Int"; BuiltinTypeName[BuiltinTypeName.Number] = "Number"; BuiltinTypeName[BuiltinTypeName.Function] = "Function"; BuiltinTypeName[BuiltinTypeName.Inferred] = "Inferred"; var BuiltinType = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(BuiltinType, _super); function BuiltinType(name, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.name = name; return _this; } /** * @param {?} visitor * @param {?} context * @return {?} */ BuiltinType.prototype.visitType = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitBuiltintType(this, context); }; return BuiltinType; }(Type$1)); var ExpressionType = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ExpressionType, _super); function ExpressionType(value, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.value = value; return _this; } /** * @param {?} visitor * @param {?} context * @return {?} */ ExpressionType.prototype.visitType = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitExpressionType(this, context); }; return ExpressionType; }(Type$1)); var ArrayType = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ArrayType, _super); function ArrayType(of, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.of = of; return _this; } /** * @param {?} visitor * @param {?} context * @return {?} */ ArrayType.prototype.visitType = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitArrayType(this, context); }; return ArrayType; }(Type$1)); var MapType = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(MapType, _super); function MapType(valueType, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers) || this; _this.valueType = valueType || null; return _this; } /** * @param {?} visitor * @param {?} context * @return {?} */ MapType.prototype.visitType = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitMapType(this, context); }; return MapType; }(Type$1)); var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic); var INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred); var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool); var INT_TYPE = new BuiltinType(BuiltinTypeName.Int); var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number); var STRING_TYPE = new BuiltinType(BuiltinTypeName.String); var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function); /** * @record */ /** @enum {number} */ var BinaryOperator = { Equals: 0, NotEquals: 1, Identical: 2, NotIdentical: 3, Minus: 4, Plus: 5, Divide: 6, Multiply: 7, Modulo: 8, And: 9, Or: 10, Lower: 11, LowerEquals: 12, Bigger: 13, BiggerEquals: 14, }; BinaryOperator[BinaryOperator.Equals] = "Equals"; BinaryOperator[BinaryOperator.NotEquals] = "NotEquals"; BinaryOperator[BinaryOperator.Identical] = "Identical"; BinaryOperator[BinaryOperator.NotIdentical] = "NotIdentical"; BinaryOperator[BinaryOperator.Minus] = "Minus"; BinaryOperator[BinaryOperator.Plus] = "Plus"; BinaryOperator[BinaryOperator.Divide] = "Divide"; BinaryOperator[BinaryOperator.Multiply] = "Multiply"; BinaryOperator[BinaryOperator.Modulo] = "Modulo"; BinaryOperator[BinaryOperator.And] = "And"; BinaryOperator[BinaryOperator.Or] = "Or"; BinaryOperator[BinaryOperator.Lower] = "Lower"; BinaryOperator[BinaryOperator.LowerEquals] = "LowerEquals"; BinaryOperator[BinaryOperator.Bigger] = "Bigger"; BinaryOperator[BinaryOperator.BiggerEquals] = "BiggerEquals"; /** * @template T * @param {?} base * @param {?} other * @return {?} */ function nullSafeIsEquivalent(base, other) { if (base == null || other == null) { return base == other; } return base.isEquivalent(other); } /** * @template T * @param {?} base * @param {?} other * @return {?} */ function areAllEquivalent(base, other) { var /** @type {?} */ len = base.length; if (len !== other.length) { return false; } for (var /** @type {?} */ i = 0; i < len; i++) { if (!base[i].isEquivalent(other[i])) { return false; } } return true; } /** * @abstract */ var Expression = /** @class */ (function () { function Expression(type, sourceSpan) { this.type = type || null; this.sourceSpan = sourceSpan || null; } /** * @param {?} name * @param {?=} sourceSpan * @return {?} */ Expression.prototype.prop = /** * @param {?} name * @param {?=} sourceSpan * @return {?} */ function (name, sourceSpan) { return new ReadPropExpr(this, name, null, sourceSpan); }; /** * @param {?} index * @param {?=} type * @param {?=} sourceSpan * @return {?} */ Expression.prototype.key = /** * @param {?} index * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function (index, type, sourceSpan) { return new ReadKeyExpr(this, index, type, sourceSpan); }; /** * @param {?} name * @param {?} params * @param {?=} sourceSpan * @return {?} */ Expression.prototype.callMethod = /** * @param {?} name * @param {?} params * @param {?=} sourceSpan * @return {?} */ function (name, params, sourceSpan) { return new InvokeMethodExpr(this, name, params, null, sourceSpan); }; /** * @param {?} params * @param {?=} sourceSpan * @return {?} */ Expression.prototype.callFn = /** * @param {?} params * @param {?=} sourceSpan * @return {?} */ function (params, sourceSpan) { return new InvokeFunctionExpr(this, params, null, sourceSpan); }; /** * @param {?} params * @param {?=} type * @param {?=} sourceSpan * @return {?} */ Expression.prototype.instantiate = /** * @param {?} params * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function (params, type, sourceSpan) { return new InstantiateExpr(this, params, type, sourceSpan); }; /** * @param {?} trueCase * @param {?=} falseCase * @param {?=} sourceSpan * @return {?} */ Expression.prototype.conditional = /** * @param {?} trueCase * @param {?=} falseCase * @param {?=} sourceSpan * @return {?} */ function (trueCase, falseCase, sourceSpan) { if (falseCase === void 0) { falseCase = null; } return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.equals = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.notEquals = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.identical = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.notIdentical = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.minus = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.plus = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.divide = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.multiply = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.modulo = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.and = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.or = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.lower = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.lowerEquals = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.bigger = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan); }; /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ Expression.prototype.biggerEquals = /** * @param {?} rhs * @param {?=} sourceSpan * @return {?} */ function (rhs, sourceSpan) { return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan); }; /** * @param {?=} sourceSpan * @return {?} */ Expression.prototype.isBlank = /** * @param {?=} sourceSpan * @return {?} */ function (sourceSpan) { // Note: We use equals by purpose here to compare to null and undefined in JS. // We use the typed null to allow strictNullChecks to narrow types. return this.equals(TYPED_NULL_EXPR, sourceSpan); }; /** * @param {?} type * @param {?=} sourceSpan * @return {?} */ Expression.prototype.cast = /** * @param {?} type * @param {?=} sourceSpan * @return {?} */ function (type, sourceSpan) { return new CastExpr(this, type, sourceSpan); }; /** * @return {?} */ Expression.prototype.toStmt = /** * @return {?} */ function () { return new ExpressionStatement(this, null); }; return Expression; }()); /** @enum {number} */ var BuiltinVar = { This: 0, Super: 1, CatchError: 2, CatchStack: 3, }; BuiltinVar[BuiltinVar.This] = "This"; BuiltinVar[BuiltinVar.Super] = "Super"; BuiltinVar[BuiltinVar.CatchError] = "CatchError"; BuiltinVar[BuiltinVar.CatchStack] = "CatchStack"; var ReadVarExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ReadVarExpr, _super); function ReadVarExpr(name, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; if (typeof name === 'string') { _this.name = name; _this.builtin = null; } else { _this.name = null; _this.builtin = /** @type {?} */ (name); } return _this; } /** * @param {?} e * @return {?} */ ReadVarExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin; }; /** * @param {?} visitor * @param {?} context * @return {?} */ ReadVarExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitReadVarExpr(this, context); }; /** * @param {?} value * @return {?} */ ReadVarExpr.prototype.set = /** * @param {?} value * @return {?} */ function (value) { if (!this.name) { throw new Error("Built in variable " + this.builtin + " can not be assigned to."); } return new WriteVarExpr(this.name, value, null, this.sourceSpan); }; return ReadVarExpr; }(Expression)); var WriteVarExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(WriteVarExpr, _super); function WriteVarExpr(name, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.name = name; _this.value = value; return _this; } /** * @param {?} e * @return {?} */ WriteVarExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ WriteVarExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitWriteVarExpr(this, context); }; /** * @param {?=} type * @param {?=} modifiers * @return {?} */ WriteVarExpr.prototype.toDeclStmt = /** * @param {?=} type * @param {?=} modifiers * @return {?} */ function (type, modifiers) { return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan); }; return WriteVarExpr; }(Expression)); var WriteKeyExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(WriteKeyExpr, _super); function WriteKeyExpr(receiver, index, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.receiver = receiver; _this.index = index; _this.value = value; return _this; } /** * @param {?} e * @return {?} */ WriteKeyExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ WriteKeyExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitWriteKeyExpr(this, context); }; return WriteKeyExpr; }(Expression)); var WritePropExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(WritePropExpr, _super); function WritePropExpr(receiver, name, value, type, sourceSpan) { var _this = _super.call(this, type || value.type, sourceSpan) || this; _this.receiver = receiver; _this.name = name; _this.value = value; return _this; } /** * @param {?} e * @return {?} */ WritePropExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.value.isEquivalent(e.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ WritePropExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitWritePropExpr(this, context); }; return WritePropExpr; }(Expression)); /** @enum {number} */ var BuiltinMethod = { ConcatArray: 0, SubscribeObservable: 1, Bind: 2, }; BuiltinMethod[BuiltinMethod.ConcatArray] = "ConcatArray"; BuiltinMethod[BuiltinMethod.SubscribeObservable] = "SubscribeObservable"; BuiltinMethod[BuiltinMethod.Bind] = "Bind"; var InvokeMethodExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(InvokeMethodExpr, _super); function InvokeMethodExpr(receiver, method, args, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.args = args; if (typeof method === 'string') { _this.name = method; _this.builtin = null; } else { _this.name = null; _this.builtin = /** @type {?} */ (method); } return _this; } /** * @param {?} e * @return {?} */ InvokeMethodExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args); }; /** * @param {?} visitor * @param {?} context * @return {?} */ InvokeMethodExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitInvokeMethodExpr(this, context); }; return InvokeMethodExpr; }(Expression)); var InvokeFunctionExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(InvokeFunctionExpr, _super); function InvokeFunctionExpr(fn, args, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.fn = fn; _this.args = args; return _this; } /** * @param {?} e * @return {?} */ InvokeFunctionExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) && areAllEquivalent(this.args, e.args); }; /** * @param {?} visitor * @param {?} context * @return {?} */ InvokeFunctionExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitInvokeFunctionExpr(this, context); }; return InvokeFunctionExpr; }(Expression)); var InstantiateExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(InstantiateExpr, _super); function InstantiateExpr(classExpr, args, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.classExpr = classExpr; _this.args = args; return _this; } /** * @param {?} e * @return {?} */ InstantiateExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) && areAllEquivalent(this.args, e.args); }; /** * @param {?} visitor * @param {?} context * @return {?} */ InstantiateExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitInstantiateExpr(this, context); }; return InstantiateExpr; }(Expression)); var LiteralExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralExpr, _super); function LiteralExpr(value, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; return _this; } /** * @param {?} e * @return {?} */ LiteralExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof LiteralExpr && this.value === e.value; }; /** * @param {?} visitor * @param {?} context * @return {?} */ LiteralExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitLiteralExpr(this, context); }; return LiteralExpr; }(Expression)); var ExternalExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ExternalExpr, _super); function ExternalExpr(value, type, typeParams, sourceSpan) { if (typeParams === void 0) { typeParams = null; } var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; _this.typeParams = typeParams; return _this; } /** * @param {?} e * @return {?} */ ExternalExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof ExternalExpr && this.value.name === e.value.name && this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime; }; /** * @param {?} visitor * @param {?} context * @return {?} */ ExternalExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitExternalExpr(this, context); }; return ExternalExpr; }(Expression)); var ExternalReference = /** @class */ (function () { function ExternalReference(moduleName, name, runtime) { this.moduleName = moduleName; this.name = name; this.runtime = runtime; } return ExternalReference; }()); var ConditionalExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ConditionalExpr, _super); function ConditionalExpr(condition, trueCase, falseCase, type, sourceSpan) { if (falseCase === void 0) { falseCase = null; } var _this = _super.call(this, type || trueCase.type, sourceSpan) || this; _this.condition = condition; _this.falseCase = falseCase; _this.trueCase = trueCase; return _this; } /** * @param {?} e * @return {?} */ ConditionalExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) && this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ConditionalExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitConditionalExpr(this, context); }; return ConditionalExpr; }(Expression)); var NotExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(NotExpr, _super); function NotExpr(condition, sourceSpan) { var _this = _super.call(this, BOOL_TYPE, sourceSpan) || this; _this.condition = condition; return _this; } /** * @param {?} e * @return {?} */ NotExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof NotExpr && this.condition.isEquivalent(e.condition); }; /** * @param {?} visitor * @param {?} context * @return {?} */ NotExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitNotExpr(this, context); }; return NotExpr; }(Expression)); var AssertNotNull = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(AssertNotNull, _super); function AssertNotNull(condition, sourceSpan) { var _this = _super.call(this, condition.type, sourceSpan) || this; _this.condition = condition; return _this; } /** * @param {?} e * @return {?} */ AssertNotNull.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition); }; /** * @param {?} visitor * @param {?} context * @return {?} */ AssertNotNull.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitAssertNotNullExpr(this, context); }; return AssertNotNull; }(Expression)); var CastExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(CastExpr, _super); function CastExpr(value, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.value = value; return _this; } /** * @param {?} e * @return {?} */ CastExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof CastExpr && this.value.isEquivalent(e.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ CastExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitCastExpr(this, context); }; return CastExpr; }(Expression)); var FnParam = /** @class */ (function () { function FnParam(name, type) { if (type === void 0) { type = null; } this.name = name; this.type = type; } /** * @param {?} param * @return {?} */ FnParam.prototype.isEquivalent = /** * @param {?} param * @return {?} */ function (param) { return this.name === param.name; }; return FnParam; }()); var FunctionExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(FunctionExpr, _super); function FunctionExpr(params, statements, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.params = params; _this.statements = statements; return _this; } /** * @param {?} e * @return {?} */ FunctionExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) && areAllEquivalent(this.statements, e.statements); }; /** * @param {?} visitor * @param {?} context * @return {?} */ FunctionExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitFunctionExpr(this, context); }; /** * @param {?} name * @param {?=} modifiers * @return {?} */ FunctionExpr.prototype.toDeclStmt = /** * @param {?} name * @param {?=} modifiers * @return {?} */ function (name, modifiers) { if (modifiers === void 0) { modifiers = null; } return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan); }; return FunctionExpr; }(Expression)); var BinaryOperatorExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(BinaryOperatorExpr, _super); function BinaryOperatorExpr(operator, lhs, rhs, type, sourceSpan) { var _this = _super.call(this, type || lhs.type, sourceSpan) || this; _this.operator = operator; _this.rhs = rhs; _this.lhs = lhs; return _this; } /** * @param {?} e * @return {?} */ BinaryOperatorExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof BinaryOperatorExpr && this.operator === e.operator && this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs); }; /** * @param {?} visitor * @param {?} context * @return {?} */ BinaryOperatorExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitBinaryOperatorExpr(this, context); }; return BinaryOperatorExpr; }(Expression)); var ReadPropExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ReadPropExpr, _super); function ReadPropExpr(receiver, name, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.name = name; return _this; } /** * @param {?} e * @return {?} */ ReadPropExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name; }; /** * @param {?} visitor * @param {?} context * @return {?} */ ReadPropExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitReadPropExpr(this, context); }; /** * @param {?} value * @return {?} */ ReadPropExpr.prototype.set = /** * @param {?} value * @return {?} */ function (value) { return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan); }; return ReadPropExpr; }(Expression)); var ReadKeyExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ReadKeyExpr, _super); function ReadKeyExpr(receiver, index, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.receiver = receiver; _this.index = index; return _this; } /** * @param {?} e * @return {?} */ ReadKeyExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) && this.index.isEquivalent(e.index); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ReadKeyExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitReadKeyExpr(this, context); }; /** * @param {?} value * @return {?} */ ReadKeyExpr.prototype.set = /** * @param {?} value * @return {?} */ function (value) { return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan); }; return ReadKeyExpr; }(Expression)); var LiteralArrayExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralArrayExpr, _super); function LiteralArrayExpr(entries, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.entries = entries; return _this; } /** * @param {?} e * @return {?} */ LiteralArrayExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries); }; /** * @param {?} visitor * @param {?} context * @return {?} */ LiteralArrayExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitLiteralArrayExpr(this, context); }; return LiteralArrayExpr; }(Expression)); var LiteralMapEntry = /** @class */ (function () { function LiteralMapEntry(key, value, quoted) { this.key = key; this.value = value; this.quoted = quoted; } /** * @param {?} e * @return {?} */ LiteralMapEntry.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return this.key === e.key && this.value.isEquivalent(e.value); }; return LiteralMapEntry; }()); var LiteralMapExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(LiteralMapExpr, _super); function LiteralMapExpr(entries, type, sourceSpan) { var _this = _super.call(this, type, sourceSpan) || this; _this.entries = entries; _this.valueType = null; if (type) { _this.valueType = type.valueType; } return _this; } /** * @param {?} e * @return {?} */ LiteralMapExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries); }; /** * @param {?} visitor * @param {?} context * @return {?} */ LiteralMapExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitLiteralMapExpr(this, context); }; return LiteralMapExpr; }(Expression)); var CommaExpr = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(CommaExpr, _super); function CommaExpr(parts, sourceSpan) { var _this = _super.call(this, parts[parts.length - 1].type, sourceSpan) || this; _this.parts = parts; return _this; } /** * @param {?} e * @return {?} */ CommaExpr.prototype.isEquivalent = /** * @param {?} e * @return {?} */ function (e) { return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts); }; /** * @param {?} visitor * @param {?} context * @return {?} */ CommaExpr.prototype.visitExpression = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitCommaExpr(this, context); }; return CommaExpr; }(Expression)); /** * @record */ var THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null); var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null); var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null); var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null); var NULL_EXPR = new LiteralExpr(null, null, null); var TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null); /** @enum {number} */ var StmtModifier = { Final: 0, Private: 1, Exported: 2, }; StmtModifier[StmtModifier.Final] = "Final"; StmtModifier[StmtModifier.Private] = "Private"; StmtModifier[StmtModifier.Exported] = "Exported"; /** * @abstract */ var Statement = /** @class */ (function () { function Statement(modifiers, sourceSpan) { this.modifiers = modifiers || []; this.sourceSpan = sourceSpan || null; } /** * @param {?} modifier * @return {?} */ Statement.prototype.hasModifier = /** * @param {?} modifier * @return {?} */ function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; }; return Statement; }()); var DeclareVarStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(DeclareVarStmt, _super); function DeclareVarStmt(name, value, type, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.value = value; _this.type = type || value.type; return _this; } /** * @param {?} stmt * @return {?} */ DeclareVarStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof DeclareVarStmt && this.name === stmt.name && this.value.isEquivalent(stmt.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ DeclareVarStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitDeclareVarStmt(this, context); }; return DeclareVarStmt; }(Statement)); var DeclareFunctionStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(DeclareFunctionStmt, _super); function DeclareFunctionStmt(name, params, statements, type, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.params = params; _this.statements = statements; _this.type = type || null; return _this; } /** * @param {?} stmt * @return {?} */ DeclareFunctionStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) && areAllEquivalent(this.statements, stmt.statements); }; /** * @param {?} visitor * @param {?} context * @return {?} */ DeclareFunctionStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitDeclareFunctionStmt(this, context); }; return DeclareFunctionStmt; }(Statement)); var ExpressionStatement = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ExpressionStatement, _super); function ExpressionStatement(expr, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.expr = expr; return _this; } /** * @param {?} stmt * @return {?} */ ExpressionStatement.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ExpressionStatement.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitExpressionStmt(this, context); }; return ExpressionStatement; }(Statement)); var ReturnStatement = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ReturnStatement, _super); function ReturnStatement(value, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.value = value; return _this; } /** * @param {?} stmt * @return {?} */ ReturnStatement.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ReturnStatement.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitReturnStmt(this, context); }; return ReturnStatement; }(Statement)); var AbstractClassPart = /** @class */ (function () { function AbstractClassPart(type, modifiers) { this.modifiers = modifiers; if (!modifiers) { this.modifiers = []; } this.type = type || null; } /** * @param {?} modifier * @return {?} */ AbstractClassPart.prototype.hasModifier = /** * @param {?} modifier * @return {?} */ function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; }; return AbstractClassPart; }()); var ClassField = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ClassField, _super); function ClassField(name, type, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; return _this; } /** * @param {?} f * @return {?} */ ClassField.prototype.isEquivalent = /** * @param {?} f * @return {?} */ function (f) { return this.name === f.name; }; return ClassField; }(AbstractClassPart)); var ClassMethod = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ClassMethod, _super); function ClassMethod(name, params, body, type, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; _this.params = params; _this.body = body; return _this; } /** * @param {?} m * @return {?} */ ClassMethod.prototype.isEquivalent = /** * @param {?} m * @return {?} */ function (m) { return this.name === m.name && areAllEquivalent(this.body, m.body); }; return ClassMethod; }(AbstractClassPart)); var ClassGetter = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ClassGetter, _super); function ClassGetter(name, body, type, modifiers) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, type, modifiers) || this; _this.name = name; _this.body = body; return _this; } /** * @param {?} m * @return {?} */ ClassGetter.prototype.isEquivalent = /** * @param {?} m * @return {?} */ function (m) { return this.name === m.name && areAllEquivalent(this.body, m.body); }; return ClassGetter; }(AbstractClassPart)); var ClassStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ClassStmt, _super); function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan) { if (modifiers === void 0) { modifiers = null; } var _this = _super.call(this, modifiers, sourceSpan) || this; _this.name = name; _this.parent = parent; _this.fields = fields; _this.getters = getters; _this.constructorMethod = constructorMethod; _this.methods = methods; return _this; } /** * @param {?} stmt * @return {?} */ ClassStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof ClassStmt && this.name === stmt.name && nullSafeIsEquivalent(this.parent, stmt.parent) && areAllEquivalent(this.fields, stmt.fields) && areAllEquivalent(this.getters, stmt.getters) && this.constructorMethod.isEquivalent(stmt.constructorMethod) && areAllEquivalent(this.methods, stmt.methods); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ClassStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitDeclareClassStmt(this, context); }; return ClassStmt; }(Statement)); var IfStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(IfStmt, _super); function IfStmt(condition, trueCase, falseCase, sourceSpan) { if (falseCase === void 0) { falseCase = []; } var _this = _super.call(this, null, sourceSpan) || this; _this.condition = condition; _this.trueCase = trueCase; _this.falseCase = falseCase; return _this; } /** * @param {?} stmt * @return {?} */ IfStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) && areAllEquivalent(this.trueCase, stmt.trueCase) && areAllEquivalent(this.falseCase, stmt.falseCase); }; /** * @param {?} visitor * @param {?} context * @return {?} */ IfStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitIfStmt(this, context); }; return IfStmt; }(Statement)); var CommentStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(CommentStmt, _super); function CommentStmt(comment, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.comment = comment; return _this; } /** * @param {?} stmt * @return {?} */ CommentStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof CommentStmt; }; /** * @param {?} visitor * @param {?} context * @return {?} */ CommentStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitCommentStmt(this, context); }; return CommentStmt; }(Statement)); var TryCatchStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(TryCatchStmt, _super); function TryCatchStmt(bodyStmts, catchStmts, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.bodyStmts = bodyStmts; _this.catchStmts = catchStmts; return _this; } /** * @param {?} stmt * @return {?} */ TryCatchStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) && areAllEquivalent(this.catchStmts, stmt.catchStmts); }; /** * @param {?} visitor * @param {?} context * @return {?} */ TryCatchStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitTryCatchStmt(this, context); }; return TryCatchStmt; }(Statement)); var ThrowStmt = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ThrowStmt, _super); function ThrowStmt(error, sourceSpan) { var _this = _super.call(this, null, sourceSpan) || this; _this.error = error; return _this; } /** * @param {?} stmt * @return {?} */ ThrowStmt.prototype.isEquivalent = /** * @param {?} stmt * @return {?} */ function (stmt) { return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error); }; /** * @param {?} visitor * @param {?} context * @return {?} */ ThrowStmt.prototype.visitStatement = /** * @param {?} visitor * @param {?} context * @return {?} */ function (visitor, context) { return visitor.visitThrowStmt(this, context); }; return ThrowStmt; }(Statement)); /** * @record */ var AstTransformer$1 = /** @class */ (function () { function AstTransformer() { } /** * @param {?} expr * @param {?} context * @return {?} */ AstTransformer.prototype.transformExpr = /** * @param {?} expr * @param {?} context * @return {?} */ function (expr, context) { return expr; }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.transformStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return stmt; }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitReadVarExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(ast, context); }; /** * @param {?} expr * @param {?} context * @return {?} */ AstTransformer.prototype.visitWriteVarExpr = /** * @param {?} expr * @param {?} context * @return {?} */ function (expr, context) { return this.transformExpr(new WriteVarExpr(expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; /** * @param {?} expr * @param {?} context * @return {?} */ AstTransformer.prototype.visitWriteKeyExpr = /** * @param {?} expr * @param {?} context * @return {?} */ function (expr, context) { return this.transformExpr(new WriteKeyExpr(expr.receiver.visitExpression(this, context), expr.index.visitExpression(this, context), expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; /** * @param {?} expr * @param {?} context * @return {?} */ AstTransformer.prototype.visitWritePropExpr = /** * @param {?} expr * @param {?} context * @return {?} */ function (expr, context) { return this.transformExpr(new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitInvokeMethodExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var /** @type {?} */ method = ast.builtin || ast.name; return this.transformExpr(new InvokeMethodExpr(ast.receiver.visitExpression(this, context), /** @type {?} */ ((method)), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitInvokeFunctionExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitInstantiateExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitExternalExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitConditionalExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new ConditionalExpr(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), /** @type {?} */ ((ast.falseCase)).visitExpression(this, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitNotExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new NotExpr(ast.condition.visitExpression(this, context), ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitAssertNotNullExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new AssertNotNull(ast.condition.visitExpression(this, context), ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitCastExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new CastExpr(ast.value.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitFunctionExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new FunctionExpr(ast.params, this.visitAllStatements(ast.statements, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitBinaryOperatorExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitReadPropExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitReadKeyExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralArrayExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context), ast.type, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitLiteralMapExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var _this = this; var /** @type {?} */ entries = ast.entries.map(function (entry) { return new LiteralMapEntry(entry.key, entry.value.visitExpression(_this, context), entry.quoted); }); var /** @type {?} */ mapType = new MapType(ast.valueType, null); return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context); }; /** * @param {?} ast * @param {?} context * @return {?} */ AstTransformer.prototype.visitCommaExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.transformExpr(new CommaExpr(this.visitAllExpressions(ast.parts, context), ast.sourceSpan), context); }; /** * @param {?} exprs * @param {?} context * @return {?} */ AstTransformer.prototype.visitAllExpressions = /** * @param {?} exprs * @param {?} context * @return {?} */ function (exprs, context) { var _this = this; return exprs.map(function (expr) { return expr.visitExpression(_this, context); }); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitDeclareVarStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new DeclareVarStmt(stmt.name, stmt.value.visitExpression(this, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitDeclareFunctionStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new DeclareFunctionStmt(stmt.name, stmt.params, this.visitAllStatements(stmt.statements, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitExpressionStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new ExpressionStatement(stmt.expr.visitExpression(this, context), stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitReturnStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new ReturnStatement(stmt.value.visitExpression(this, context), stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitDeclareClassStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { var _this = this; var /** @type {?} */ parent = /** @type {?} */ ((stmt.parent)).visitExpression(this, context); var /** @type {?} */ getters = stmt.getters.map(function (getter) { return new ClassGetter(getter.name, _this.visitAllStatements(getter.body, context), getter.type, getter.modifiers); }); var /** @type {?} */ ctorMethod = stmt.constructorMethod && new ClassMethod(stmt.constructorMethod.name, stmt.constructorMethod.params, this.visitAllStatements(stmt.constructorMethod.body, context), stmt.constructorMethod.type, stmt.constructorMethod.modifiers); var /** @type {?} */ methods = stmt.methods.map(function (method) { return new ClassMethod(method.name, method.params, _this.visitAllStatements(method.body, context), method.type, method.modifiers); }); return this.transformStmt(new ClassStmt(stmt.name, parent, stmt.fields, getters, ctorMethod, methods, stmt.modifiers, stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitIfStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context), stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitTryCatchStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context), stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitThrowStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(new ThrowStmt(stmt.error.visitExpression(this, context), stmt.sourceSpan), context); }; /** * @param {?} stmt * @param {?} context * @return {?} */ AstTransformer.prototype.visitCommentStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return this.transformStmt(stmt, context); }; /** * @param {?} stmts * @param {?} context * @return {?} */ AstTransformer.prototype.visitAllStatements = /** * @param {?} stmts * @param {?} context * @return {?} */ function (stmts, context) { var _this = this; return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); }); }; return AstTransformer; }()); var RecursiveAstVisitor$1 = /** @class */ (function () { function RecursiveAstVisitor() { } /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitType = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return ast; }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitExpression = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { if (ast.type) { ast.type.visitType(this, context); } return ast; }; /** * @param {?} type * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitBuiltintType = /** * @param {?} type * @param {?} context * @return {?} */ function (type, context) { return this.visitType(type, context); }; /** * @param {?} type * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitExpressionType = /** * @param {?} type * @param {?} context * @return {?} */ function (type, context) { type.value.visitExpression(this, context); return this.visitType(type, context); }; /** * @param {?} type * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitArrayType = /** * @param {?} type * @param {?} context * @return {?} */ function (type, context) { return this.visitType(type, context); }; /** * @param {?} type * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitMapType = /** * @param {?} type * @param {?} context * @return {?} */ function (type, context) { return this.visitType(type, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitReadVarExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitWriteVarExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitWriteKeyExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visitExpression(this, context); ast.index.visitExpression(this, context); ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitWritePropExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visitExpression(this, context); ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitInvokeMethodExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitInvokeFunctionExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.fn.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitInstantiateExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.classExpr.visitExpression(this, context); this.visitAllExpressions(ast.args, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitExternalExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var _this = this; if (ast.typeParams) { ast.typeParams.forEach(function (type) { return type.visitType(_this, context); }); } return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitConditionalExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.condition.visitExpression(this, context); ast.trueCase.visitExpression(this, context); /** @type {?} */ ((ast.falseCase)).visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitNotExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.condition.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitAssertNotNullExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.condition.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitCastExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.value.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitFunctionExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitAllStatements(ast.statements, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitBinaryOperatorExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.lhs.visitExpression(this, context); ast.rhs.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitReadPropExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitReadKeyExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { ast.receiver.visitExpression(this, context); ast.index.visitExpression(this, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralArrayExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitAllExpressions(ast.entries, context); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitLiteralMapExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { var _this = this; ast.entries.forEach(function (entry) { return entry.value.visitExpression(_this, context); }); return this.visitExpression(ast, context); }; /** * @param {?} ast * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitCommaExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.visitAllExpressions(ast.parts, context); return this.visitExpression(ast, context); }; /** * @param {?} exprs * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitAllExpressions = /** * @param {?} exprs * @param {?} context * @return {?} */ function (exprs, context) { var _this = this; exprs.forEach(function (expr) { return expr.visitExpression(_this, context); }); }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitDeclareVarStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { stmt.value.visitExpression(this, context); if (stmt.type) { stmt.type.visitType(this, context); } return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitDeclareFunctionStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { this.visitAllStatements(stmt.statements, context); if (stmt.type) { stmt.type.visitType(this, context); } return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitExpressionStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { stmt.expr.visitExpression(this, context); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitReturnStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { stmt.value.visitExpression(this, context); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitDeclareClassStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { var _this = this; /** @type {?} */ ((stmt.parent)).visitExpression(this, context); stmt.getters.forEach(function (getter) { return _this.visitAllStatements(getter.body, context); }); if (stmt.constructorMethod) { this.visitAllStatements(stmt.constructorMethod.body, context); } stmt.methods.forEach(function (method) { return _this.visitAllStatements(method.body, context); }); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitIfStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { stmt.condition.visitExpression(this, context); this.visitAllStatements(stmt.trueCase, context); this.visitAllStatements(stmt.falseCase, context); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitTryCatchStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { this.visitAllStatements(stmt.bodyStmts, context); this.visitAllStatements(stmt.catchStmts, context); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitThrowStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { stmt.error.visitExpression(this, context); return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitCommentStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { return stmt; }; /** * @param {?} stmts * @param {?} context * @return {?} */ RecursiveAstVisitor.prototype.visitAllStatements = /** * @param {?} stmts * @param {?} context * @return {?} */ function (stmts, context) { var _this = this; stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); }); }; return RecursiveAstVisitor; }()); /** * @param {?} stmts * @return {?} */ function findReadVarNames(stmts) { var /** @type {?} */ visitor = new _ReadVarVisitor(); visitor.visitAllStatements(stmts, null); return visitor.varNames; } var _ReadVarVisitor = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_ReadVarVisitor, _super); function _ReadVarVisitor() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.varNames = new Set(); return _this; } /** * @param {?} stmt * @param {?} context * @return {?} */ _ReadVarVisitor.prototype.visitDeclareFunctionStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { // Don't descend into nested functions return stmt; }; /** * @param {?} stmt * @param {?} context * @return {?} */ _ReadVarVisitor.prototype.visitDeclareClassStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { // Don't descend into nested classes return stmt; }; /** * @param {?} ast * @param {?} context * @return {?} */ _ReadVarVisitor.prototype.visitReadVarExpr = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { if (ast.name) { this.varNames.add(ast.name); } return null; }; return _ReadVarVisitor; }(RecursiveAstVisitor$1)); /** * @param {?} stmts * @return {?} */ function collectExternalReferences(stmts) { var /** @type {?} */ visitor = new _FindExternalReferencesVisitor(); visitor.visitAllStatements(stmts, null); return visitor.externalReferences; } var _FindExternalReferencesVisitor = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_FindExternalReferencesVisitor, _super); function _FindExternalReferencesVisitor() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.externalReferences = []; return _this; } /** * @param {?} e * @param {?} context * @return {?} */ _FindExternalReferencesVisitor.prototype.visitExternalExpr = /** * @param {?} e * @param {?} context * @return {?} */ function (e, context) { this.externalReferences.push(e.value); return _super.prototype.visitExternalExpr.call(this, e, context); }; return _FindExternalReferencesVisitor; }(RecursiveAstVisitor$1)); /** * @param {?} stmt * @param {?} sourceSpan * @return {?} */ function applySourceSpanToStatementIfNeeded(stmt, sourceSpan) { if (!sourceSpan) { return stmt; } var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan); return stmt.visitStatement(transformer, null); } /** * @param {?} expr * @param {?} sourceSpan * @return {?} */ function applySourceSpanToExpressionIfNeeded(expr, sourceSpan) { if (!sourceSpan) { return expr; } var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan); return expr.visitExpression(transformer, null); } var _ApplySourceSpanTransformer = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_ApplySourceSpanTransformer, _super); function _ApplySourceSpanTransformer(sourceSpan) { var _this = _super.call(this) || this; _this.sourceSpan = sourceSpan; return _this; } /** * @param {?} obj * @return {?} */ _ApplySourceSpanTransformer.prototype._clone = /** * @param {?} obj * @return {?} */ function (obj) { var /** @type {?} */ clone = Object.create(obj.constructor.prototype); for (var /** @type {?} */ prop in obj) { clone[prop] = obj[prop]; } return clone; }; /** * @param {?} expr * @param {?} context * @return {?} */ _ApplySourceSpanTransformer.prototype.transformExpr = /** * @param {?} expr * @param {?} context * @return {?} */ function (expr, context) { if (!expr.sourceSpan) { expr = this._clone(expr); expr.sourceSpan = this.sourceSpan; } return expr; }; /** * @param {?} stmt * @param {?} context * @return {?} */ _ApplySourceSpanTransformer.prototype.transformStmt = /** * @param {?} stmt * @param {?} context * @return {?} */ function (stmt, context) { if (!stmt.sourceSpan) { stmt = this._clone(stmt); stmt.sourceSpan = this.sourceSpan; } return stmt; }; return _ApplySourceSpanTransformer; }(AstTransformer$1)); /** * @param {?} name * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function variable(name, type, sourceSpan) { return new ReadVarExpr(name, type, sourceSpan); } /** * @param {?} id * @param {?=} typeParams * @param {?=} sourceSpan * @return {?} */ function importExpr(id, typeParams, sourceSpan) { if (typeParams === void 0) { typeParams = null; } return new ExternalExpr(id, null, typeParams, sourceSpan); } /** * @param {?} id * @param {?=} typeParams * @param {?=} typeModifiers * @return {?} */ function importType(id, typeParams, typeModifiers) { if (typeParams === void 0) { typeParams = null; } if (typeModifiers === void 0) { typeModifiers = null; } return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null; } /** * @param {?} expr * @param {?=} typeModifiers * @return {?} */ function expressionType(expr, typeModifiers) { if (typeModifiers === void 0) { typeModifiers = null; } return new ExpressionType(expr, typeModifiers); } /** * @param {?} values * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function literalArr(values, type, sourceSpan) { return new LiteralArrayExpr(values, type, sourceSpan); } /** * @param {?} values * @param {?=} type * @return {?} */ function literalMap(values, type) { if (type === void 0) { type = null; } return new LiteralMapExpr(values.map(function (e) { return new LiteralMapEntry(e.key, e.value, e.quoted); }), type, null); } /** * @param {?} expr * @param {?=} sourceSpan * @return {?} */ function not(expr, sourceSpan) { return new NotExpr(expr, sourceSpan); } /** * @param {?} expr * @param {?=} sourceSpan * @return {?} */ function assertNotNull(expr, sourceSpan) { return new AssertNotNull(expr, sourceSpan); } /** * @param {?} params * @param {?} body * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function fn(params, body, type, sourceSpan) { return new FunctionExpr(params, body, type, sourceSpan); } /** * @param {?} value * @param {?=} type * @param {?=} sourceSpan * @return {?} */ function literal(value, type, sourceSpan) { return new LiteralExpr(value, type, sourceSpan); } /** * @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 ProviderError = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ProviderError, _super); function ProviderError(message, span) { return _super.call(this, span, message) || this; } return ProviderError; }(ParseError)); /** * @record */ var ProviderViewContext = /** @class */ (function () { function ProviderViewContext(reflector, component) { var _this = this; this.reflector = reflector; this.component = component; this.errors = []; this.viewQueries = _getViewQueries(component); this.viewProviders = new Map(); component.viewProviders.forEach(function (provider) { if (_this.viewProviders.get(tokenReference(provider.token)) == null) { _this.viewProviders.set(tokenReference(provider.token), true); } }); } return ProviderViewContext; }()); var ProviderElementContext = /** @class */ (function () { function ProviderElementContext(viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, isTemplate, contentQueryStartId, _sourceSpan) { var _this = this; this.viewContext = viewContext; this._parent = _parent; this._isViewRoot = _isViewRoot; this._directiveAsts = _directiveAsts; this._sourceSpan = _sourceSpan; this._transformedProviders = new Map(); this._seenProviders = new Map(); this._queriedTokens = new Map(); this.transformedHasViewContainer = false; this._attrs = {}; attrs.forEach(function (attrAst) { return _this._attrs[attrAst.name] = attrAst.value; }); var /** @type {?} */ directivesMeta = _directiveAsts.map(function (directiveAst) { return directiveAst.directive; }); this._allProviders = _resolveProvidersFromDirectives(directivesMeta, _sourceSpan, viewContext.errors); this._contentQueries = _getContentQueries(contentQueryStartId, directivesMeta); Array.from(this._allProviders.values()).forEach(function (provider) { _this._addQueryReadsTo(provider.token, provider.token, _this._queriedTokens); }); if (isTemplate) { var /** @type {?} */ templateRefId = createTokenForExternalReference(this.viewContext.reflector, Identifiers.TemplateRef); this._addQueryReadsTo(templateRefId, templateRefId, this._queriedTokens); } refs.forEach(function (refAst) { var /** @type {?} */ defaultQueryValue = refAst.value || createTokenForExternalReference(_this.viewContext.reflector, Identifiers.ElementRef); _this._addQueryReadsTo({ value: refAst.name }, defaultQueryValue, _this._queriedTokens); }); if (this._queriedTokens.get(this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef))) { this.transformedHasViewContainer = true; } // create the providers that we know are eager first Array.from(this._allProviders.values()).forEach(function (provider) { var /** @type {?} */ eager = provider.eager || _this._queriedTokens.get(tokenReference(provider.token)); if (eager) { _this._getOrCreateLocalProvider(provider.providerType, provider.token, true); } }); } /** * @return {?} */ ProviderElementContext.prototype.afterElement = /** * @return {?} */ function () { var _this = this; // collect lazy providers Array.from(this._allProviders.values()).forEach(function (provider) { _this._getOrCreateLocalProvider(provider.providerType, provider.token, false); }); }; Object.defineProperty(ProviderElementContext.prototype, "transformProviders", { get: /** * @return {?} */ function () { // Note: Maps keep their insertion order. var /** @type {?} */ lazyProviders = []; var /** @type {?} */ eagerProviders = []; this._transformedProviders.forEach(function (provider) { if (provider.eager) { eagerProviders.push(provider); } else { lazyProviders.push(provider); } }); return lazyProviders.concat(eagerProviders); }, enumerable: true, configurable: true }); Object.defineProperty(ProviderElementContext.prototype, "transformedDirectiveAsts", { get: /** * @return {?} */ function () { var /** @type {?} */ sortedProviderTypes = this.transformProviders.map(function (provider) { return provider.token.identifier; }); var /** @type {?} */ sortedDirectives = this._directiveAsts.slice(); sortedDirectives.sort(function (dir1, dir2) { return sortedProviderTypes.indexOf(dir1.directive.type) - sortedProviderTypes.indexOf(dir2.directive.type); }); return sortedDirectives; }, enumerable: true, configurable: true }); Object.defineProperty(ProviderElementContext.prototype, "queryMatches", { get: /** * @return {?} */ function () { var /** @type {?} */ allMatches = []; this._queriedTokens.forEach(function (matches) { allMatches.push.apply(allMatches, matches); }); return allMatches; }, enumerable: true, configurable: true }); /** * @param {?} token * @param {?} defaultValue * @param {?} queryReadTokens * @return {?} */ ProviderElementContext.prototype._addQueryReadsTo = /** * @param {?} token * @param {?} defaultValue * @param {?} queryReadTokens * @return {?} */ function (token, defaultValue, queryReadTokens) { this._getQueriesFor(token).forEach(function (query) { var /** @type {?} */ queryValue = query.meta.read || defaultValue; var /** @type {?} */ tokenRef = tokenReference(queryValue); var /** @type {?} */ queryMatches = queryReadTokens.get(tokenRef); if (!queryMatches) { queryMatches = []; queryReadTokens.set(tokenRef, queryMatches); } queryMatches.push({ queryId: query.queryId, value: queryValue }); }); }; /** * @param {?} token * @return {?} */ ProviderElementContext.prototype._getQueriesFor = /** * @param {?} token * @return {?} */ function (token) { var /** @type {?} */ result = []; var /** @type {?} */ currentEl = this; var /** @type {?} */ distance = 0; var /** @type {?} */ queries; while (currentEl !== null) { queries = currentEl._contentQueries.get(tokenReference(token)); if (queries) { result.push.apply(result, queries.filter(function (query) { return query.meta.descendants || distance <= 1; })); } if (currentEl._directiveAsts.length > 0) { distance++; } currentEl = currentEl._parent; } queries = this.viewContext.viewQueries.get(tokenReference(token)); if (queries) { result.push.apply(result, queries); } return result; }; /** * @param {?} requestingProviderType * @param {?} token * @param {?} eager * @return {?} */ ProviderElementContext.prototype._getOrCreateLocalProvider = /** * @param {?} requestingProviderType * @param {?} token * @param {?} eager * @return {?} */ function (requestingProviderType, token, eager) { var _this = this; var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token)); if (!resolvedProvider || ((requestingProviderType === ProviderAstType.Directive || requestingProviderType === ProviderAstType.PublicService) && resolvedProvider.providerType === ProviderAstType.PrivateService) || ((requestingProviderType === ProviderAstType.PrivateService || requestingProviderType === ProviderAstType.PublicService) && resolvedProvider.providerType === ProviderAstType.Builtin)) { return null; } var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token)); if (transformedProviderAst) { return transformedProviderAst; } if (this._seenProviders.get(tokenReference(token)) != null) { this.viewContext.errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), this._sourceSpan)); return null; } this._seenProviders.set(tokenReference(token), true); var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) { var /** @type {?} */ transformedUseValue = provider.useValue; var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting)); var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined)); if (provider.useExisting != null) { var /** @type {?} */ existingDiDep = /** @type {?} */ ((_this._getDependency(resolvedProvider.providerType, { token: provider.useExisting }, eager))); if (existingDiDep.token != null) { transformedUseExisting = existingDiDep.token; } else { transformedUseExisting = /** @type {?} */ ((null)); transformedUseValue = existingDiDep.value; } } else if (provider.useFactory) { var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps; transformedDeps = deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); }); } else if (provider.useClass) { var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps; transformedDeps = deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); }); } return _transformProvider(provider, { useExisting: transformedUseExisting, useValue: transformedUseValue, deps: transformedDeps }); }); transformedProviderAst = _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders }); this._transformedProviders.set(tokenReference(token), transformedProviderAst); return transformedProviderAst; }; /** * @param {?} requestingProviderType * @param {?} dep * @param {?=} eager * @return {?} */ ProviderElementContext.prototype._getLocalDependency = /** * @param {?} requestingProviderType * @param {?} dep * @param {?=} eager * @return {?} */ function (requestingProviderType, dep, eager) { if (eager === void 0) { eager = false; } if (dep.isAttribute) { var /** @type {?} */ attrValue = this._attrs[/** @type {?} */ ((dep.token)).value]; return { isValue: true, value: attrValue == null ? null : attrValue }; } if (dep.token != null) { // access builtints if ((requestingProviderType === ProviderAstType.Directive || requestingProviderType === ProviderAstType.Component)) { if (tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.Renderer) || tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.ElementRef) || tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.ChangeDetectorRef) || tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.TemplateRef)) { return dep; } if (tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) { (/** @type {?} */ (this)).transformedHasViewContainer = true; } } // access the injector if (tokenReference(dep.token) === this.viewContext.reflector.resolveExternalReference(Identifiers.Injector)) { return dep; } // access providers if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) { return dep; } } return null; }; /** * @param {?} requestingProviderType * @param {?} dep * @param {?=} eager * @return {?} */ ProviderElementContext.prototype._getDependency = /** * @param {?} requestingProviderType * @param {?} dep * @param {?=} eager * @return {?} */ function (requestingProviderType, dep, eager) { if (eager === void 0) { eager = false; } var /** @type {?} */ currElement = this; var /** @type {?} */ currEager = eager; var /** @type {?} */ result = null; if (!dep.isSkipSelf) { result = this._getLocalDependency(requestingProviderType, dep, eager); } if (dep.isSelf) { if (!result && dep.isOptional) { result = { isValue: true, value: null }; } } else { // check parent elements while (!result && currElement._parent) { var /** @type {?} */ prevElement = currElement; currElement = currElement._parent; if (prevElement._isViewRoot) { currEager = false; } result = currElement._getLocalDependency(ProviderAstType.PublicService, dep, currEager); } // check @Host restriction if (!result) { if (!dep.isHost || this.viewContext.component.isHost || this.viewContext.component.type.reference === tokenReference(/** @type {?} */ ((dep.token))) || this.viewContext.viewProviders.get(tokenReference(/** @type {?} */ ((dep.token)))) != null) { result = dep; } else { result = dep.isOptional ? result = { isValue: true, value: null } : null; } } } if (!result) { this.viewContext.errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), this._sourceSpan)); } return result; }; return ProviderElementContext; }()); var NgModuleProviderAnalyzer = /** @class */ (function () { function NgModuleProviderAnalyzer(reflector, ngModule, extraProviders, sourceSpan) { var _this = this; this.reflector = reflector; this._transformedProviders = new Map(); this._seenProviders = new Map(); this._errors = []; this._allProviders = new Map(); ngModule.transitiveModule.modules.forEach(function (ngModuleType) { var /** @type {?} */ ngModuleProvider = { token: { identifier: ngModuleType }, useClass: ngModuleType }; _resolveProviders([ngModuleProvider], ProviderAstType.PublicService, true, sourceSpan, _this._errors, _this._allProviders); }); _resolveProviders(ngModule.transitiveModule.providers.map(function (entry) { return entry.provider; }).concat(extraProviders), ProviderAstType.PublicService, false, sourceSpan, this._errors, this._allProviders); } /** * @return {?} */ NgModuleProviderAnalyzer.prototype.parse = /** * @return {?} */ function () { var _this = this; Array.from(this._allProviders.values()).forEach(function (provider) { _this._getOrCreateLocalProvider(provider.token, provider.eager); }); if (this._errors.length > 0) { var /** @type {?} */ errorString = this._errors.join('\n'); throw new Error("Provider parse errors:\n" + errorString); } // Note: Maps keep their insertion order. var /** @type {?} */ lazyProviders = []; var /** @type {?} */ eagerProviders = []; this._transformedProviders.forEach(function (provider) { if (provider.eager) { eagerProviders.push(provider); } else { lazyProviders.push(provider); } }); return lazyProviders.concat(eagerProviders); }; /** * @param {?} token * @param {?} eager * @return {?} */ NgModuleProviderAnalyzer.prototype._getOrCreateLocalProvider = /** * @param {?} token * @param {?} eager * @return {?} */ function (token, eager) { var _this = this; var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token)); if (!resolvedProvider) { return null; } var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token)); if (transformedProviderAst) { return transformedProviderAst; } if (this._seenProviders.get(tokenReference(token)) != null) { this._errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), resolvedProvider.sourceSpan)); return null; } this._seenProviders.set(tokenReference(token), true); var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) { var /** @type {?} */ transformedUseValue = provider.useValue; var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting)); var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined)); if (provider.useExisting != null) { var /** @type {?} */ existingDiDep = _this._getDependency({ token: provider.useExisting }, eager, resolvedProvider.sourceSpan); if (existingDiDep.token != null) { transformedUseExisting = existingDiDep.token; } else { transformedUseExisting = /** @type {?} */ ((null)); transformedUseValue = existingDiDep.value; } } else if (provider.useFactory) { var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps; transformedDeps = deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); }); } else if (provider.useClass) { var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps; transformedDeps = deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); }); } return _transformProvider(provider, { useExisting: transformedUseExisting, useValue: transformedUseValue, deps: transformedDeps }); }); transformedProviderAst = _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders }); this._transformedProviders.set(tokenReference(token), transformedProviderAst); return transformedProviderAst; }; /** * @param {?} dep * @param {?=} eager * @param {?=} requestorSourceSpan * @return {?} */ NgModuleProviderAnalyzer.prototype._getDependency = /** * @param {?} dep * @param {?=} eager * @param {?=} requestorSourceSpan * @return {?} */ function (dep, eager, requestorSourceSpan) { if (eager === void 0) { eager = false; } var /** @type {?} */ foundLocal = false; if (!dep.isSkipSelf && dep.token != null) { // access the injector if (tokenReference(dep.token) === this.reflector.resolveExternalReference(Identifiers.Injector) || tokenReference(dep.token) === this.reflector.resolveExternalReference(Identifiers.ComponentFactoryResolver)) { foundLocal = true; // access providers } else if (this._getOrCreateLocalProvider(dep.token, eager) != null) { foundLocal = true; } } var /** @type {?} */ result = dep; if (dep.isSelf && !foundLocal) { if (dep.isOptional) { result = { isValue: true, value: null }; } else { this._errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), requestorSourceSpan)); } } return result; }; return NgModuleProviderAnalyzer; }()); /** * @param {?} provider * @param {?} __1 * @return {?} */ function _transformProvider(provider, _a) { var useExisting = _a.useExisting, useValue = _a.useValue, deps = _a.deps; return { token: provider.token, useClass: provider.useClass, useExisting: useExisting, useFactory: provider.useFactory, useValue: useValue, deps: deps, multi: provider.multi }; } /** * @param {?} provider * @param {?} __1 * @return {?} */ function _transformProviderAst(provider, _a) { var eager = _a.eager, providers = _a.providers; return new ProviderAst(provider.token, provider.multiProvider, provider.eager || eager, providers, provider.providerType, provider.lifecycleHooks, provider.sourceSpan); } /** * @param {?} directives * @param {?} sourceSpan * @param {?} targetErrors * @return {?} */ function _resolveProvidersFromDirectives(directives, sourceSpan, targetErrors) { var /** @type {?} */ providersByToken = new Map(); directives.forEach(function (directive) { var /** @type {?} */ dirProvider = { token: { identifier: directive.type }, useClass: directive.type }; _resolveProviders([dirProvider], directive.isComponent ? ProviderAstType.Component : ProviderAstType.Directive, true, sourceSpan, targetErrors, providersByToken); }); // Note: directives need to be able to overwrite providers of a component! var /** @type {?} */ directivesWithComponentFirst = directives.filter(function (dir) { return dir.isComponent; }).concat(directives.filter(function (dir) { return !dir.isComponent; })); directivesWithComponentFirst.forEach(function (directive) { _resolveProviders(directive.providers, ProviderAstType.PublicService, false, sourceSpan, targetErrors, providersByToken); _resolveProviders(directive.viewProviders, ProviderAstType.PrivateService, false, sourceSpan, targetErrors, providersByToken); }); return providersByToken; } /** * @param {?} providers * @param {?} providerType * @param {?} eager * @param {?} sourceSpan * @param {?} targetErrors * @param {?} targetProvidersByToken * @return {?} */ function _resolveProviders(providers, providerType, eager, sourceSpan, targetErrors, targetProvidersByToken) { providers.forEach(function (provider) { var /** @type {?} */ resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token)); if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) { targetErrors.push(new ProviderError("Mixing multi and non multi provider is not possible for token " + tokenName(resolvedProvider.token), sourceSpan)); } if (!resolvedProvider) { var /** @type {?} */ lifecycleHooks = provider.token.identifier && (/** @type {?} */ (provider.token.identifier)).lifecycleHooks ? (/** @type {?} */ (provider.token.identifier)).lifecycleHooks : []; var /** @type {?} */ isUseValue = !(provider.useClass || provider.useExisting || provider.useFactory); resolvedProvider = new ProviderAst(provider.token, !!provider.multi, eager || isUseValue, [provider], providerType, lifecycleHooks, sourceSpan); targetProvidersByToken.set(tokenReference(provider.token), resolvedProvider); } else { if (!provider.multi) { resolvedProvider.providers.length = 0; } resolvedProvider.providers.push(provider); } }); } /** * @param {?} component * @return {?} */ function _getViewQueries(component) { // Note: queries start with id 1 so we can use the number in a Bloom filter! var /** @type {?} */ viewQueryId = 1; var /** @type {?} */ viewQueries = new Map(); if (component.viewQueries) { component.viewQueries.forEach(function (query) { return _addQueryToTokenMap(viewQueries, { meta: query, queryId: viewQueryId++ }); }); } return viewQueries; } /** * @param {?} contentQueryStartId * @param {?} directives * @return {?} */ function _getContentQueries(contentQueryStartId, directives) { var /** @type {?} */ contentQueryId = contentQueryStartId; var /** @type {?} */ contentQueries = new Map(); directives.forEach(function (directive, directiveIndex) { if (directive.queries) { directive.queries.forEach(function (query) { return _addQueryToTokenMap(contentQueries, { meta: query, queryId: contentQueryId++ }); }); } }); return contentQueries; } /** * @param {?} map * @param {?} query * @return {?} */ function _addQueryToTokenMap(map, query) { query.meta.selectors.forEach(function (token) { var /** @type {?} */ entry = map.get(tokenReference(token)); if (!entry) { entry = []; map.set(tokenReference(token), entry); } entry.push(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 */ var QUOTED_KEYS = '$quoted$'; /** * @param {?} ctx * @param {?} value * @param {?=} type * @return {?} */ function convertValueToOutputAst(ctx, value, type) { if (type === void 0) { type = null; } return visitValue(value, new _ValueOutputAstTransformer(ctx), type); } var _ValueOutputAstTransformer = /** @class */ (function () { function _ValueOutputAstTransformer(ctx) { this.ctx = ctx; } /** * @param {?} arr * @param {?} type * @return {?} */ _ValueOutputAstTransformer.prototype.visitArray = /** * @param {?} arr * @param {?} type * @return {?} */ function (arr, type) { var _this = this; return literalArr(arr.map(function (value) { return visitValue(value, _this, null); }), type); }; /** * @param {?} map * @param {?} type * @return {?} */ _ValueOutputAstTransformer.prototype.visitStringMap = /** * @param {?} map * @param {?} type * @return {?} */ function (map, type) { var _this = this; var /** @type {?} */ entries = []; var /** @type {?} */ quotedSet = new Set(map && map[QUOTED_KEYS]); Object.keys(map).forEach(function (key) { entries.push(new LiteralMapEntry(key, visitValue(map[key], _this, null), quotedSet.has(key))); }); return new LiteralMapExpr(entries, type); }; /** * @param {?} value * @param {?} type * @return {?} */ _ValueOutputAstTransformer.prototype.visitPrimitive = /** * @param {?} value * @param {?} type * @return {?} */ function (value, type) { return literal(value, type); }; /** * @param {?} value * @param {?} type * @return {?} */ _ValueOutputAstTransformer.prototype.visitOther = /** * @param {?} value * @param {?} type * @return {?} */ function (value, type) { if (value instanceof Expression) { return value; } else { return this.ctx.importExpr(value); } }; return _ValueOutputAstTransformer; }()); /** * @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 {?} ctx * @param {?} providerAst * @return {?} */ function providerDef(ctx, providerAst) { var /** @type {?} */ flags = 0; if (!providerAst.eager) { flags |= 4096 /* LazyProvider */; } if (providerAst.providerType === ProviderAstType.PrivateService) { flags |= 8192 /* PrivateProvider */; } providerAst.lifecycleHooks.forEach(function (lifecycleHook) { // for regular providers, we only support ngOnDestroy if (lifecycleHook === LifecycleHooks.OnDestroy || providerAst.providerType === ProviderAstType.Directive || providerAst.providerType === ProviderAstType.Component) { flags |= lifecycleHookToNodeFlag(lifecycleHook); } }); var _a = providerAst.multiProvider ? multiProviderDef(ctx, flags, providerAst.providers) : singleProviderDef(ctx, flags, providerAst.providerType, providerAst.providers[0]), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr; return { providerExpr: providerExpr, flags: providerFlags, depsExpr: depsExpr, tokenExpr: tokenExpr(ctx, providerAst.token), }; } /** * @param {?} ctx * @param {?} flags * @param {?} providers * @return {?} */ function multiProviderDef(ctx, flags, providers) { var /** @type {?} */ allDepDefs = []; var /** @type {?} */ allParams = []; var /** @type {?} */ exprs = providers.map(function (provider, providerIndex) { var /** @type {?} */ expr; if (provider.useClass) { var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useClass.diDeps); expr = ctx.importExpr(provider.useClass.reference).instantiate(depExprs); } else if (provider.useFactory) { var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useFactory.diDeps); expr = ctx.importExpr(provider.useFactory.reference).callFn(depExprs); } else if (provider.useExisting) { var /** @type {?} */ depExprs = convertDeps(providerIndex, [{ token: provider.useExisting }]); expr = depExprs[0]; } else { expr = convertValueToOutputAst(ctx, provider.useValue); } return expr; }); var /** @type {?} */ providerExpr = fn(allParams, [new ReturnStatement(literalArr(exprs))], INFERRED_TYPE); return { providerExpr: providerExpr, flags: flags | 1024 /* TypeFactoryProvider */, depsExpr: literalArr(allDepDefs) }; /** * @param {?} providerIndex * @param {?} deps * @return {?} */ function convertDeps(providerIndex, deps) { return deps.map(function (dep, depIndex) { var /** @type {?} */ paramName = "p" + providerIndex + "_" + depIndex; allParams.push(new FnParam(paramName, DYNAMIC_TYPE)); allDepDefs.push(depDef(ctx, dep)); return variable(paramName); }); } } /** * @param {?} ctx * @param {?} flags * @param {?} providerType * @param {?} providerMeta * @return {?} */ function singleProviderDef(ctx, flags, providerType, providerMeta) { var /** @type {?} */ providerExpr; var /** @type {?} */ deps; if (providerType === ProviderAstType.Directive || providerType === ProviderAstType.Component) { providerExpr = ctx.importExpr(/** @type {?} */ ((providerMeta.useClass)).reference); flags |= 16384 /* TypeDirective */; deps = providerMeta.deps || /** @type {?} */ ((providerMeta.useClass)).diDeps; } else { if (providerMeta.useClass) { providerExpr = ctx.importExpr(providerMeta.useClass.reference); flags |= 512 /* TypeClassProvider */; deps = providerMeta.deps || providerMeta.useClass.diDeps; } else if (providerMeta.useFactory) { providerExpr = ctx.importExpr(providerMeta.useFactory.reference); flags |= 1024 /* TypeFactoryProvider */; deps = providerMeta.deps || providerMeta.useFactory.diDeps; } else if (providerMeta.useExisting) { providerExpr = NULL_EXPR; flags |= 2048 /* TypeUseExistingProvider */; deps = [{ token: providerMeta.useExisting }]; } else { providerExpr = convertValueToOutputAst(ctx, providerMeta.useValue); flags |= 256 /* TypeValueProvider */; deps = []; } } var /** @type {?} */ depsExpr = literalArr(deps.map(function (dep) { return depDef(ctx, dep); })); return { providerExpr: providerExpr, flags: flags, depsExpr: depsExpr }; } /** * @param {?} ctx * @param {?} tokenMeta * @return {?} */ function tokenExpr(ctx, tokenMeta) { return tokenMeta.identifier ? ctx.importExpr(tokenMeta.identifier.reference) : literal(tokenMeta.value); } /** * @param {?} ctx * @param {?} dep * @return {?} */ function depDef(ctx, dep) { // Note: the following fields have already been normalized out by provider_analyzer: // - isAttribute, isSelf, isHost var /** @type {?} */ expr = dep.isValue ? convertValueToOutputAst(ctx, dep.value) : tokenExpr(ctx, /** @type {?} */ ((dep.token))); var /** @type {?} */ flags = 0; if (dep.isSkipSelf) { flags |= 1 /* SkipSelf */; } if (dep.isOptional) { flags |= 2 /* Optional */; } if (dep.isValue) { flags |= 8 /* Value */; } return flags === 0 /* None */ ? expr : literalArr([literal(flags), expr]); } /** * @param {?} lifecycleHook * @return {?} */ function lifecycleHookToNodeFlag(lifecycleHook) { var /** @type {?} */ nodeFlag = 0; switch (lifecycleHook) { case LifecycleHooks.AfterContentChecked: nodeFlag = 2097152 /* AfterContentChecked */; break; case LifecycleHooks.AfterContentInit: nodeFlag = 1048576 /* AfterContentInit */; break; case LifecycleHooks.AfterViewChecked: nodeFlag = 8388608 /* AfterViewChecked */; break; case LifecycleHooks.AfterViewInit: nodeFlag = 4194304 /* AfterViewInit */; break; case LifecycleHooks.DoCheck: nodeFlag = 262144 /* DoCheck */; break; case LifecycleHooks.OnChanges: nodeFlag = 524288 /* OnChanges */; break; case LifecycleHooks.OnDestroy: nodeFlag = 131072 /* OnDestroy */; break; case LifecycleHooks.OnInit: nodeFlag = 65536 /* OnInit */; break; } return nodeFlag; } /** * @param {?} reflector * @param {?} ctx * @param {?} flags * @param {?} entryComponents * @return {?} */ function componentFactoryResolverProviderDef(reflector, ctx, flags, entryComponents) { var /** @type {?} */ entryComponentFactories = entryComponents.map(function (entryComponent) { return ctx.importExpr(entryComponent.componentFactory); }); var /** @type {?} */ token = createTokenForExternalReference(reflector, Identifiers.ComponentFactoryResolver); var /** @type {?} */ classMeta = { diDeps: [ { isValue: true, value: literalArr(entryComponentFactories) }, { token: token, isSkipSelf: true, isOptional: true }, { token: createTokenForExternalReference(reflector, Identifiers.NgModuleRef) }, ], lifecycleHooks: [], reference: reflector.resolveExternalReference(Identifiers.CodegenComponentFactoryResolver) }; var _a = singleProviderDef(ctx, flags, ProviderAstType.PrivateService, { token: token, multi: false, useClass: classMeta, }), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr; return { providerExpr: providerExpr, flags: providerFlags, depsExpr: depsExpr, tokenExpr: tokenExpr(ctx, token) }; } /** * @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 NgModuleCompileResult = /** @class */ (function () { function NgModuleCompileResult(ngModuleFactoryVar) { this.ngModuleFactoryVar = ngModuleFactoryVar; } return NgModuleCompileResult; }()); var LOG_VAR = variable('_l'); var NgModuleCompiler = /** @class */ (function () { function NgModuleCompiler(reflector) { this.reflector = reflector; } /** * @param {?} ctx * @param {?} ngModuleMeta * @param {?} extraProviders * @return {?} */ NgModuleCompiler.prototype.compile = /** * @param {?} ctx * @param {?} ngModuleMeta * @param {?} extraProviders * @return {?} */ function (ctx, ngModuleMeta, extraProviders) { var /** @type {?} */ sourceSpan = typeSourceSpan('NgModule', ngModuleMeta.type); var /** @type {?} */ entryComponentFactories = ngModuleMeta.transitiveModule.entryComponents; var /** @type {?} */ bootstrapComponents = ngModuleMeta.bootstrapComponents; var /** @type {?} */ providerParser = new NgModuleProviderAnalyzer(this.reflector, ngModuleMeta, extraProviders, sourceSpan); var /** @type {?} */ providerDefs = [componentFactoryResolverProviderDef(this.reflector, ctx, 0 /* None */, entryComponentFactories)] .concat(providerParser.parse().map(function (provider) { return providerDef(ctx, provider); })) .map(function (_a) { var providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr; return importExpr(Identifiers.moduleProviderDef).callFn([ literal(flags), tokenExpr, providerExpr, depsExpr ]); }); var /** @type {?} */ ngModuleDef = importExpr(Identifiers.moduleDef).callFn([literalArr(providerDefs)]); var /** @type {?} */ ngModuleDefFactory = fn([new FnParam(/** @type {?} */ ((LOG_VAR.name)))], [new ReturnStatement(ngModuleDef)], INFERRED_TYPE); var /** @type {?} */ ngModuleFactoryVar = identifierName(ngModuleMeta.type) + "NgFactory"; this._createNgModuleFactory(ctx, ngModuleMeta.type.reference, importExpr(Identifiers.createModuleFactory).callFn([ ctx.importExpr(ngModuleMeta.type.reference), literalArr(bootstrapComponents.map(function (id) { return ctx.importExpr(id.reference); })), ngModuleDefFactory ])); if (ngModuleMeta.id) { var /** @type {?} */ registerFactoryStmt = importExpr(Identifiers.RegisterModuleFactoryFn) .callFn([literal(ngModuleMeta.id), variable(ngModuleFactoryVar)]) .toStmt(); ctx.statements.push(registerFactoryStmt); } return new NgModuleCompileResult(ngModuleFactoryVar); }; /** * @param {?} ctx * @param {?} ngModuleReference * @return {?} */ NgModuleCompiler.prototype.createStub = /** * @param {?} ctx * @param {?} ngModuleReference * @return {?} */ function (ctx, ngModuleReference) { this._createNgModuleFactory(ctx, ngModuleReference, NULL_EXPR); }; /** * @param {?} ctx * @param {?} reference * @param {?} value * @return {?} */ NgModuleCompiler.prototype._createNgModuleFactory = /** * @param {?} ctx * @param {?} reference * @param {?} value * @return {?} */ function (ctx, reference, value) { var /** @type {?} */ ngModuleFactoryVar = identifierName({ reference: reference }) + "NgFactory"; var /** @type {?} */ ngModuleFactoryStmt = variable(ngModuleFactoryVar) .set(value) .toDeclStmt(importType(Identifiers.NgModuleFactory, [/** @type {?} */ ((expressionType(ctx.importExpr(reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]); ctx.statements.push(ngModuleFactoryStmt); }; return NgModuleCompiler; }()); /** * @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 */ /** * Resolves types to {\@link NgModule}. */ var NgModuleResolver = /** @class */ (function () { function NgModuleResolver(_reflector) { this._reflector = _reflector; } /** * @param {?} type * @return {?} */ NgModuleResolver.prototype.isNgModule = /** * @param {?} type * @return {?} */ function (type) { return this._reflector.annotations(type).some(createNgModule.isTypeOf); }; /** * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ NgModuleResolver.prototype.resolve = /** * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ function (type, throwIfNotFound) { if (throwIfNotFound === void 0) { throwIfNotFound = true; } var /** @type {?} */ ngModuleMeta = findLast(this._reflector.annotations(type), createNgModule.isTypeOf); if (ngModuleMeta) { return ngModuleMeta; } else { if (throwIfNotFound) { throw new Error("No NgModule metadata found for '" + stringify(type) + "'."); } return null; } }; return NgModuleResolver; }()); /** * @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 */ // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit var VERSION$1 = 3; var JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,'; var SourceMapGenerator = /** @class */ (function () { function SourceMapGenerator(file) { if (file === void 0) { file = null; } this.file = file; this.sourcesContent = new Map(); this.lines = []; this.lastCol0 = 0; this.hasMappings = false; } // The content is `null` when the content is expected to be loaded using the URL /** * @param {?} url * @param {?=} content * @return {?} */ SourceMapGenerator.prototype.addSource = /** * @param {?} url * @param {?=} content * @return {?} */ function (url, content) { if (content === void 0) { content = null; } if (!this.sourcesContent.has(url)) { this.sourcesContent.set(url, content); } return this; }; /** * @return {?} */ SourceMapGenerator.prototype.addLine = /** * @return {?} */ function () { this.lines.push([]); this.lastCol0 = 0; return this; }; /** * @param {?} col0 * @param {?=} sourceUrl * @param {?=} sourceLine0 * @param {?=} sourceCol0 * @return {?} */ SourceMapGenerator.prototype.addMapping = /** * @param {?} col0 * @param {?=} sourceUrl * @param {?=} sourceLine0 * @param {?=} sourceCol0 * @return {?} */ function (col0, sourceUrl, sourceLine0, sourceCol0) { if (!this.currentLine) { throw new Error("A line must be added before mappings can be added"); } if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) { throw new Error("Unknown source file \"" + sourceUrl + "\""); } if (col0 == null) { throw new Error("The column in the generated code must be provided"); } if (col0 < this.lastCol0) { throw new Error("Mapping should be added in output order"); } if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) { throw new Error("The source location must be provided when a source url is provided"); } this.hasMappings = true; this.lastCol0 = col0; this.currentLine.push({ col0: col0, sourceUrl: sourceUrl, sourceLine0: sourceLine0, sourceCol0: sourceCol0 }); return this; }; Object.defineProperty(SourceMapGenerator.prototype, "currentLine", { get: /** * @return {?} */ function () { return this.lines.slice(-1)[0]; }, enumerable: true, configurable: true }); /** * @return {?} */ SourceMapGenerator.prototype.toJSON = /** * @return {?} */ function () { var _this = this; if (!this.hasMappings) { return null; } var /** @type {?} */ sourcesIndex = new Map(); var /** @type {?} */ sources = []; var /** @type {?} */ sourcesContent = []; Array.from(this.sourcesContent.keys()).forEach(function (url, i) { sourcesIndex.set(url, i); sources.push(url); sourcesContent.push(_this.sourcesContent.get(url) || null); }); var /** @type {?} */ mappings = ''; var /** @type {?} */ lastCol0 = 0; var /** @type {?} */ lastSourceIndex = 0; var /** @type {?} */ lastSourceLine0 = 0; var /** @type {?} */ lastSourceCol0 = 0; this.lines.forEach(function (segments) { lastCol0 = 0; mappings += segments .map(function (segment) { // zero-based starting column of the line in the generated code var /** @type {?} */ segAsStr = toBase64VLQ(segment.col0 - lastCol0); lastCol0 = segment.col0; if (segment.sourceUrl != null) { // zero-based index into the “sources” list segAsStr += toBase64VLQ(/** @type {?} */ ((sourcesIndex.get(segment.sourceUrl))) - lastSourceIndex); lastSourceIndex = /** @type {?} */ ((sourcesIndex.get(segment.sourceUrl))); // the zero-based starting line in the original source segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceLine0)) - lastSourceLine0); lastSourceLine0 = /** @type {?} */ ((segment.sourceLine0)); // the zero-based starting column in the original source segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceCol0)) - lastSourceCol0); lastSourceCol0 = /** @type {?} */ ((segment.sourceCol0)); } return segAsStr; }) .join(','); mappings += ';'; }); mappings = mappings.slice(0, -1); return { 'file': this.file || '', 'version': VERSION$1, 'sourceRoot': '', 'sources': sources, 'sourcesContent': sourcesContent, 'mappings': mappings, }; }; /** * @return {?} */ SourceMapGenerator.prototype.toJsComment = /** * @return {?} */ function () { return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) : ''; }; return SourceMapGenerator; }()); /** * @param {?} value * @return {?} */ function toBase64String(value) { var /** @type {?} */ b64 = ''; value = utf8Encode(value); for (var /** @type {?} */ i = 0; i < value.length;) { var /** @type {?} */ i1 = value.charCodeAt(i++); var /** @type {?} */ i2 = value.charCodeAt(i++); var /** @type {?} */ i3 = value.charCodeAt(i++); b64 += toBase64Digit(i1 >> 2); b64 += toBase64Digit(((i1 & 3) << 4) | (isNaN(i2) ? 0 : i2 >> 4)); b64 += isNaN(i2) ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 >> 6)); b64 += isNaN(i2) || isNaN(i3) ? '=' : toBase64Digit(i3 & 63); } return b64; } /** * @param {?} value * @return {?} */ function toBase64VLQ(value) { value = value < 0 ? ((-value) << 1) + 1 : value << 1; var /** @type {?} */ out = ''; do { var /** @type {?} */ digit = value & 31; value = value >> 5; if (value > 0) { digit = digit | 32; } out += toBase64Digit(digit); } while (value > 0); return out; } var B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; /** * @param {?} value * @return {?} */ function toBase64Digit(value) { if (value < 0 || value >= 64) { throw new Error("Can only encode value in the range [0, 63]"); } return B64_DIGITS[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 _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g; var _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i; var _INDENT_WITH = ' '; var CATCH_ERROR_VAR$1 = variable('error', null, null); var CATCH_STACK_VAR$1 = variable('stack', null, null); /** * @record */ var _EmittedLine = /** @class */ (function () { function _EmittedLine(indent) { this.indent = indent; this.partsLength = 0; this.parts = []; this.srcSpans = []; } return _EmittedLine; }()); var EmitterVisitorContext = /** @class */ (function () { function EmitterVisitorContext(_indent) { this._indent = _indent; this._classes = []; this._preambleLineCount = 0; this._lines = [new _EmittedLine(_indent)]; } /** * @return {?} */ EmitterVisitorContext.createRoot = /** * @return {?} */ function () { return new EmitterVisitorContext(0); }; Object.defineProperty(EmitterVisitorContext.prototype, "_currentLine", { get: /** * @return {?} */ function () { return this._lines[this._lines.length - 1]; }, enumerable: true, configurable: true }); /** * @param {?=} from * @param {?=} lastPart * @return {?} */ EmitterVisitorContext.prototype.println = /** * @param {?=} from * @param {?=} lastPart * @return {?} */ function (from, lastPart) { if (lastPart === void 0) { lastPart = ''; } this.print(from || null, lastPart, true); }; /** * @return {?} */ EmitterVisitorContext.prototype.lineIsEmpty = /** * @return {?} */ function () { return this._currentLine.parts.length === 0; }; /** * @return {?} */ EmitterVisitorContext.prototype.lineLength = /** * @return {?} */ function () { return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength; }; /** * @param {?} from * @param {?} part * @param {?=} newLine * @return {?} */ EmitterVisitorContext.prototype.print = /** * @param {?} from * @param {?} part * @param {?=} newLine * @return {?} */ function (from, part, newLine) { if (newLine === void 0) { newLine = false; } if (part.length > 0) { this._currentLine.parts.push(part); this._currentLine.partsLength += part.length; this._currentLine.srcSpans.push(from && from.sourceSpan || null); } if (newLine) { this._lines.push(new _EmittedLine(this._indent)); } }; /** * @return {?} */ EmitterVisitorContext.prototype.removeEmptyLastLine = /** * @return {?} */ function () { if (this.lineIsEmpty()) { this._lines.pop(); } }; /** * @return {?} */ EmitterVisitorContext.prototype.incIndent = /** * @return {?} */ function () { this._indent++; if (this.lineIsEmpty()) { this._currentLine.indent = this._indent; } }; /** * @return {?} */ EmitterVisitorContext.prototype.decIndent = /** * @return {?} */ function () { this._indent--; if (this.lineIsEmpty()) { this._currentLine.indent = this._indent; } }; /** * @param {?} clazz * @return {?} */ EmitterVisitorContext.prototype.pushClass = /** * @param {?} clazz * @return {?} */ function (clazz) { this._classes.push(clazz); }; /** * @return {?} */ EmitterVisitorContext.prototype.popClass = /** * @return {?} */ function () { return /** @type {?} */ ((this._classes.pop())); }; Object.defineProperty(EmitterVisitorContext.prototype, "currentClass", { get: /** * @return {?} */ function () { return this._classes.length > 0 ? this._classes[this._classes.length - 1] : null; }, enumerable: true, configurable: true }); /** * @return {?} */ EmitterVisitorContext.prototype.toSource = /** * @return {?} */ function () { return this.sourceLines .map(function (l) { return l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''; }) .join('\n'); }; /** * @param {?} genFilePath * @param {?=} startsAtLine * @return {?} */ EmitterVisitorContext.prototype.toSourceMapGenerator = /** * @param {?} genFilePath * @param {?=} startsAtLine * @return {?} */ function (genFilePath, startsAtLine) { if (startsAtLine === void 0) { startsAtLine = 0; } var /** @type {?} */ map = new SourceMapGenerator(genFilePath); var /** @type {?} */ firstOffsetMapped = false; var /** @type {?} */ mapFirstOffsetIfNeeded = function () { if (!firstOffsetMapped) { // Add a single space so that tools won't try to load the file from disk. // Note: We are using virtual urls like `ng:///`, so we have to // provide a content here. map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0); firstOffsetMapped = true; } }; for (var /** @type {?} */ i = 0; i < startsAtLine; i++) { map.addLine(); mapFirstOffsetIfNeeded(); } this.sourceLines.forEach(function (line, lineIdx) { map.addLine(); var /** @type {?} */ spans = line.srcSpans; var /** @type {?} */ parts = line.parts; var /** @type {?} */ col0 = line.indent * _INDENT_WITH.length; var /** @type {?} */ spanIdx = 0; // skip leading parts without source spans while (spanIdx < spans.length && !spans[spanIdx]) { col0 += parts[spanIdx].length; spanIdx++; } if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) { firstOffsetMapped = true; } else { mapFirstOffsetIfNeeded(); } while (spanIdx < spans.length) { var /** @type {?} */ span = /** @type {?} */ ((spans[spanIdx])); var /** @type {?} */ source = span.start.file; var /** @type {?} */ sourceLine = span.start.line; var /** @type {?} */ sourceCol = span.start.col; map.addSource(source.url, source.content) .addMapping(col0, source.url, sourceLine, sourceCol); col0 += parts[spanIdx].length; spanIdx++; // assign parts without span or the same span to the previous segment while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) { col0 += parts[spanIdx].length; spanIdx++; } } }); return map; }; /** * @param {?} count * @return {?} */ EmitterVisitorContext.prototype.setPreambleLineCount = /** * @param {?} count * @return {?} */ function (count) { return this._preambleLineCount = count; }; /** * @param {?} line * @param {?} column * @return {?} */ EmitterVisitorContext.prototype.spanOf = /** * @param {?} line * @param {?} column * @return {?} */ function (line, column) { var /** @type {?} */ emittedLine = this._lines[line - this._preambleLineCount]; if (emittedLine) { var /** @type {?} */ columnsLeft = column - _createIndent(emittedLine.indent).length; for (var /** @type {?} */ partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) { var /** @type {?} */ part = emittedLine.parts[partIndex]; if (part.length > columnsLeft) { return emittedLine.srcSpans[partIndex]; } columnsLeft -= part.length; } } return null; }; Object.defineProperty(EmitterVisitorContext.prototype, "sourceLines", { get: /** * @return {?} */ function () { if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) { return this._lines.slice(0, -1); } return this._lines; }, enumerable: true, configurable: true }); return EmitterVisitorContext; }()); /** * @abstract */ var AbstractEmitterVisitor = /** @class */ (function () { function AbstractEmitterVisitor(_escapeDollarInStrings) { this._escapeDollarInStrings = _escapeDollarInStrings; } /** * @param {?} stmt * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitExpressionStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { stmt.expr.visitExpression(this, ctx); ctx.println(stmt, ';'); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitReturnStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { ctx.print(stmt, "return "); stmt.value.visitExpression(this, ctx); ctx.println(stmt, ';'); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitIfStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { ctx.print(stmt, "if ("); stmt.condition.visitExpression(this, ctx); ctx.print(stmt, ") {"); var /** @type {?} */ hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0; if (stmt.trueCase.length <= 1 && !hasElseCase) { ctx.print(stmt, " "); this.visitAllStatements(stmt.trueCase, ctx); ctx.removeEmptyLastLine(); ctx.print(stmt, " "); } else { ctx.println(); ctx.incIndent(); this.visitAllStatements(stmt.trueCase, ctx); ctx.decIndent(); if (hasElseCase) { ctx.println(stmt, "} else {"); ctx.incIndent(); this.visitAllStatements(stmt.falseCase, ctx); ctx.decIndent(); } } ctx.println(stmt, "}"); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitThrowStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { ctx.print(stmt, "throw "); stmt.error.visitExpression(this, ctx); ctx.println(stmt, ";"); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitCommentStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { var /** @type {?} */ lines = stmt.comment.split('\n'); lines.forEach(function (line) { ctx.println(stmt, "// " + line); }); return null; }; /** * @param {?} expr * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitWriteVarExpr = /** * @param {?} expr * @param {?} ctx * @return {?} */ function (expr, ctx) { var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } ctx.print(expr, expr.name + " = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; /** * @param {?} expr * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitWriteKeyExpr = /** * @param {?} expr * @param {?} ctx * @return {?} */ function (expr, ctx) { var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } expr.receiver.visitExpression(this, ctx); ctx.print(expr, "["); expr.index.visitExpression(this, ctx); ctx.print(expr, "] = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; /** * @param {?} expr * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitWritePropExpr = /** * @param {?} expr * @param {?} ctx * @return {?} */ function (expr, ctx) { var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty(); if (!lineWasEmpty) { ctx.print(expr, '('); } expr.receiver.visitExpression(this, ctx); ctx.print(expr, "." + expr.name + " = "); expr.value.visitExpression(this, ctx); if (!lineWasEmpty) { ctx.print(expr, ')'); } return null; }; /** * @param {?} expr * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitInvokeMethodExpr = /** * @param {?} expr * @param {?} ctx * @return {?} */ function (expr, ctx) { expr.receiver.visitExpression(this, ctx); var /** @type {?} */ name = expr.name; if (expr.builtin != null) { name = this.getBuiltinMethodName(expr.builtin); if (name == null) { // some builtins just mean to skip the call. return null; } } ctx.print(expr, "." + name + "("); this.visitAllExpressions(expr.args, ctx, ","); ctx.print(expr, ")"); return null; }; /** * @param {?} expr * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitInvokeFunctionExpr = /** * @param {?} expr * @param {?} ctx * @return {?} */ function (expr, ctx) { expr.fn.visitExpression(this, ctx); ctx.print(expr, "("); this.visitAllExpressions(expr.args, ctx, ','); ctx.print(expr, ")"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitReadVarExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var /** @type {?} */ varName = /** @type {?} */ ((ast.name)); if (ast.builtin != null) { switch (ast.builtin) { case BuiltinVar.Super: varName = 'super'; break; case BuiltinVar.This: varName = 'this'; break; case BuiltinVar.CatchError: varName = /** @type {?} */ ((CATCH_ERROR_VAR$1.name)); break; case BuiltinVar.CatchStack: varName = /** @type {?} */ ((CATCH_STACK_VAR$1.name)); break; default: throw new Error("Unknown builtin variable " + ast.builtin); } } ctx.print(ast, varName); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitInstantiateExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "new "); ast.classExpr.visitExpression(this, ctx); ctx.print(ast, "("); this.visitAllExpressions(ast.args, ctx, ','); ctx.print(ast, ")"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitLiteralExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var /** @type {?} */ value = ast.value; if (typeof value === 'string') { ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings)); } else { ctx.print(ast, "" + value); } return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitConditionalExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "("); ast.condition.visitExpression(this, ctx); ctx.print(ast, '? '); ast.trueCase.visitExpression(this, ctx); ctx.print(ast, ': '); /** @type {?} */ ((ast.falseCase)).visitExpression(this, ctx); ctx.print(ast, ")"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitNotExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, '!'); ast.condition.visitExpression(this, ctx); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitAssertNotNullExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ast.condition.visitExpression(this, ctx); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitBinaryOperatorExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var /** @type {?} */ opStr; switch (ast.operator) { case BinaryOperator.Equals: opStr = '=='; break; case BinaryOperator.Identical: opStr = '==='; break; case BinaryOperator.NotEquals: opStr = '!='; break; case BinaryOperator.NotIdentical: opStr = '!=='; break; case BinaryOperator.And: opStr = '&&'; break; case BinaryOperator.Or: opStr = '||'; break; case BinaryOperator.Plus: opStr = '+'; break; case BinaryOperator.Minus: opStr = '-'; break; case BinaryOperator.Divide: opStr = '/'; break; case BinaryOperator.Multiply: opStr = '*'; break; case BinaryOperator.Modulo: opStr = '%'; break; case BinaryOperator.Lower: opStr = '<'; break; case BinaryOperator.LowerEquals: opStr = '<='; break; case BinaryOperator.Bigger: opStr = '>'; break; case BinaryOperator.BiggerEquals: opStr = '>='; break; default: throw new Error("Unknown operator " + ast.operator); } ctx.print(ast, "("); ast.lhs.visitExpression(this, ctx); ctx.print(ast, " " + opStr + " "); ast.rhs.visitExpression(this, ctx); ctx.print(ast, ")"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitReadPropExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ast.receiver.visitExpression(this, ctx); ctx.print(ast, "."); ctx.print(ast, ast.name); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitReadKeyExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ast.receiver.visitExpression(this, ctx); ctx.print(ast, "["); ast.index.visitExpression(this, ctx); ctx.print(ast, "]"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitLiteralArrayExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "["); this.visitAllExpressions(ast.entries, ctx, ','); ctx.print(ast, "]"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitLiteralMapExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var _this = this; ctx.print(ast, "{"); this.visitAllObjects(function (entry) { ctx.print(ast, escapeIdentifier(entry.key, _this._escapeDollarInStrings, entry.quoted) + ":"); entry.value.visitExpression(_this, ctx); }, ast.entries, ctx, ','); ctx.print(ast, "}"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitCommaExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, '('); this.visitAllExpressions(ast.parts, ctx, ','); ctx.print(ast, ')'); return null; }; /** * @param {?} expressions * @param {?} ctx * @param {?} separator * @return {?} */ AbstractEmitterVisitor.prototype.visitAllExpressions = /** * @param {?} expressions * @param {?} ctx * @param {?} separator * @return {?} */ function (expressions, ctx, separator) { var _this = this; this.visitAllObjects(function (expr) { return expr.visitExpression(_this, ctx); }, expressions, ctx, separator); }; /** * @template T * @param {?} handler * @param {?} expressions * @param {?} ctx * @param {?} separator * @return {?} */ AbstractEmitterVisitor.prototype.visitAllObjects = /** * @template T * @param {?} handler * @param {?} expressions * @param {?} ctx * @param {?} separator * @return {?} */ function (handler, expressions, ctx, separator) { var /** @type {?} */ incrementedIndent = false; for (var /** @type {?} */ i = 0; i < expressions.length; i++) { if (i > 0) { if (ctx.lineLength() > 80) { ctx.print(null, separator, true); if (!incrementedIndent) { // continuation are marked with double indent. ctx.incIndent(); ctx.incIndent(); incrementedIndent = true; } } else { ctx.print(null, separator, false); } } handler(expressions[i]); } if (incrementedIndent) { // continuation are marked with double indent. ctx.decIndent(); ctx.decIndent(); } }; /** * @param {?} statements * @param {?} ctx * @return {?} */ AbstractEmitterVisitor.prototype.visitAllStatements = /** * @param {?} statements * @param {?} ctx * @return {?} */ function (statements, ctx) { var _this = this; statements.forEach(function (stmt) { return stmt.visitStatement(_this, ctx); }); }; return AbstractEmitterVisitor; }()); /** * @param {?} input * @param {?} escapeDollar * @param {?=} alwaysQuote * @return {?} */ function escapeIdentifier(input, escapeDollar, alwaysQuote) { if (alwaysQuote === void 0) { alwaysQuote = true; } if (input == null) { return null; } var /** @type {?} */ body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, function () { var match = []; for (var _i = 0; _i < arguments.length; _i++) { match[_i] = arguments[_i]; } if (match[0] == '$') { return escapeDollar ? '\\$' : '$'; } else if (match[0] == '\n') { return '\\n'; } else if (match[0] == '\r') { return '\\r'; } else { return "\\" + match[0]; } }); var /** @type {?} */ requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body); return requiresQuotes ? "'" + body + "'" : body; } /** * @param {?} count * @return {?} */ function _createIndent(count) { var /** @type {?} */ res = ''; for (var /** @type {?} */ i = 0; i < count; i++) { res += _INDENT_WITH; } 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 */ /** * @param {?} ast * @return {?} */ function debugOutputAstAsTypeScript(ast) { var /** @type {?} */ converter = new _TsEmitterVisitor(); var /** @type {?} */ ctx = EmitterVisitorContext.createRoot(); var /** @type {?} */ asts = Array.isArray(ast) ? ast : [ast]; asts.forEach(function (ast) { if (ast instanceof Statement) { ast.visitStatement(converter, ctx); } else if (ast instanceof Expression) { ast.visitExpression(converter, ctx); } else if (ast instanceof Type$1) { ast.visitType(converter, ctx); } else { throw new Error("Don't know how to print debug info for " + ast); } }); return ctx.toSource(); } var TypeScriptEmitter = /** @class */ (function () { function TypeScriptEmitter() { } /** * @param {?} genFilePath * @param {?} stmts * @param {?=} preamble * @param {?=} emitSourceMaps * @param {?=} referenceFilter * @return {?} */ TypeScriptEmitter.prototype.emitStatementsAndContext = /** * @param {?} genFilePath * @param {?} stmts * @param {?=} preamble * @param {?=} emitSourceMaps * @param {?=} referenceFilter * @return {?} */ function (genFilePath, stmts, preamble, emitSourceMaps, referenceFilter) { if (preamble === void 0) { preamble = ''; } if (emitSourceMaps === void 0) { emitSourceMaps = true; } var /** @type {?} */ converter = new _TsEmitterVisitor(referenceFilter); var /** @type {?} */ ctx = EmitterVisitorContext.createRoot(); converter.visitAllStatements(stmts, ctx); var /** @type {?} */ preambleLines = preamble ? preamble.split('\n') : []; converter.reexports.forEach(function (reexports, exportedModuleName) { var /** @type {?} */ reexportsCode = reexports.map(function (reexport) { return reexport.name + " as " + reexport.as; }).join(','); preambleLines.push("export {" + reexportsCode + "} from '" + exportedModuleName + "';"); }); converter.importsWithPrefixes.forEach(function (prefix, importedModuleName) { // Note: can't write the real word for import as it screws up system.js auto detection... preambleLines.push("imp" + ("ort * as " + prefix + " from '" + importedModuleName + "';")); }); var /** @type {?} */ sm = emitSourceMaps ? ctx.toSourceMapGenerator(genFilePath, preambleLines.length).toJsComment() : ''; var /** @type {?} */ lines = preambleLines.concat([ctx.toSource(), sm]); if (sm) { // always add a newline at the end, as some tools have bugs without it. lines.push(''); } ctx.setPreambleLineCount(preambleLines.length); return { sourceText: lines.join('\n'), context: ctx }; }; /** * @param {?} genFilePath * @param {?} stmts * @param {?=} preamble * @return {?} */ TypeScriptEmitter.prototype.emitStatements = /** * @param {?} genFilePath * @param {?} stmts * @param {?=} preamble * @return {?} */ function (genFilePath, stmts, preamble) { if (preamble === void 0) { preamble = ''; } return this.emitStatementsAndContext(genFilePath, stmts, preamble).sourceText; }; return TypeScriptEmitter; }()); var _TsEmitterVisitor = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(_TsEmitterVisitor, _super); function _TsEmitterVisitor(referenceFilter) { var _this = _super.call(this, false) || this; _this.referenceFilter = referenceFilter; _this.typeExpression = 0; _this.importsWithPrefixes = new Map(); _this.reexports = new Map(); return _this; } /** * @param {?} t * @param {?} ctx * @param {?=} defaultType * @return {?} */ _TsEmitterVisitor.prototype.visitType = /** * @param {?} t * @param {?} ctx * @param {?=} defaultType * @return {?} */ function (t, ctx, defaultType) { if (defaultType === void 0) { defaultType = 'any'; } if (t) { this.typeExpression++; t.visitType(this, ctx); this.typeExpression--; } else { ctx.print(null, defaultType); } }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitLiteralExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var /** @type {?} */ value = ast.value; if (value == null && ast.type != INFERRED_TYPE) { ctx.print(ast, "(" + value + " as any)"); return null; } return _super.prototype.visitLiteralExpr.call(this, ast, ctx); }; // Temporary workaround to support strictNullCheck enabled consumers of ngc emit. // In SNC mode, [] have the type never[], so we cast here to any[]. // TODO: narrow the cast to a more explicit type, or use a pattern that does not // start with [].concat. see https://github.com/angular/angular/pull/11846 /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitLiteralArrayExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { if (ast.entries.length === 0) { ctx.print(ast, '('); } var /** @type {?} */ result = _super.prototype.visitLiteralArrayExpr.call(this, ast, ctx); if (ast.entries.length === 0) { ctx.print(ast, ' as any[])'); } return result; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitExternalExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { this._visitIdentifier(ast.value, ast.typeParams, ctx); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitAssertNotNullExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { var /** @type {?} */ result = _super.prototype.visitAssertNotNullExpr.call(this, ast, ctx); ctx.print(ast, '!'); return result; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitDeclareVarStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { if (stmt.hasModifier(StmtModifier.Exported) && stmt.value instanceof ExternalExpr && !stmt.type) { // check for a reexport var _a = stmt.value.value, name_1 = _a.name, moduleName = _a.moduleName; if (moduleName) { var /** @type {?} */ reexports = this.reexports.get(moduleName); if (!reexports) { reexports = []; this.reexports.set(moduleName, reexports); } reexports.push({ name: /** @type {?} */ ((name_1)), as: stmt.name }); return null; } } if (stmt.hasModifier(StmtModifier.Exported)) { ctx.print(stmt, "export "); } if (stmt.hasModifier(StmtModifier.Final)) { ctx.print(stmt, "const"); } else { ctx.print(stmt, "var"); } ctx.print(stmt, " " + stmt.name); this._printColonType(stmt.type, ctx); ctx.print(stmt, " = "); stmt.value.visitExpression(this, ctx); ctx.println(stmt, ";"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitCastExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "(<"); /** @type {?} */ ((ast.type)).visitType(this, ctx); ctx.print(ast, ">"); ast.value.visitExpression(this, ctx); ctx.print(ast, ")"); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitInstantiateExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "new "); this.typeExpression++; ast.classExpr.visitExpression(this, ctx); this.typeExpression--; ctx.print(ast, "("); this.visitAllExpressions(ast.args, ctx, ','); ctx.print(ast, ")"); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitDeclareClassStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { var _this = this; ctx.pushClass(stmt); if (stmt.hasModifier(StmtModifier.Exported)) { ctx.print(stmt, "export "); } ctx.print(stmt, "class " + stmt.name); if (stmt.parent != null) { ctx.print(stmt, " extends "); this.typeExpression++; stmt.parent.visitExpression(this, ctx); this.typeExpression--; } ctx.println(stmt, " {"); ctx.incIndent(); stmt.fields.forEach(function (field) { return _this._visitClassField(field, ctx); }); if (stmt.constructorMethod != null) { this._visitClassConstructor(stmt, ctx); } stmt.getters.forEach(function (getter) { return _this._visitClassGetter(getter, ctx); }); stmt.methods.forEach(function (method) { return _this._visitClassMethod(method, ctx); }); ctx.decIndent(); ctx.println(stmt, "}"); ctx.popClass(); return null; }; /** * @param {?} field * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitClassField = /** * @param {?} field * @param {?} ctx * @return {?} */ function (field, ctx) { if (field.hasModifier(StmtModifier.Private)) { // comment out as a workaround for #10967 ctx.print(null, "/*private*/ "); } ctx.print(null, field.name); this._printColonType(field.type, ctx); ctx.println(null, ";"); }; /** * @param {?} getter * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitClassGetter = /** * @param {?} getter * @param {?} ctx * @return {?} */ function (getter, ctx) { if (getter.hasModifier(StmtModifier.Private)) { ctx.print(null, "private "); } ctx.print(null, "get " + getter.name + "()"); this._printColonType(getter.type, ctx); ctx.println(null, " {"); ctx.incIndent(); this.visitAllStatements(getter.body, ctx); ctx.decIndent(); ctx.println(null, "}"); }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitClassConstructor = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { ctx.print(stmt, "constructor("); this._visitParams(stmt.constructorMethod.params, ctx); ctx.println(stmt, ") {"); ctx.incIndent(); this.visitAllStatements(stmt.constructorMethod.body, ctx); ctx.decIndent(); ctx.println(stmt, "}"); }; /** * @param {?} method * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitClassMethod = /** * @param {?} method * @param {?} ctx * @return {?} */ function (method, ctx) { if (method.hasModifier(StmtModifier.Private)) { ctx.print(null, "private "); } ctx.print(null, method.name + "("); this._visitParams(method.params, ctx); ctx.print(null, ")"); this._printColonType(method.type, ctx, 'void'); ctx.println(null, " {"); ctx.incIndent(); this.visitAllStatements(method.body, ctx); ctx.decIndent(); ctx.println(null, "}"); }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitFunctionExpr = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ctx.print(ast, "("); this._visitParams(ast.params, ctx); ctx.print(ast, ")"); this._printColonType(ast.type, ctx, 'void'); ctx.println(ast, " => {"); ctx.incIndent(); this.visitAllStatements(ast.statements, ctx); ctx.decIndent(); ctx.print(ast, "}"); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitDeclareFunctionStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { if (stmt.hasModifier(StmtModifier.Exported)) { ctx.print(stmt, "export "); } ctx.print(stmt, "function " + stmt.name + "("); this._visitParams(stmt.params, ctx); ctx.print(stmt, ")"); this._printColonType(stmt.type, ctx, 'void'); ctx.println(stmt, " {"); ctx.incIndent(); this.visitAllStatements(stmt.statements, ctx); ctx.decIndent(); ctx.println(stmt, "}"); return null; }; /** * @param {?} stmt * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitTryCatchStmt = /** * @param {?} stmt * @param {?} ctx * @return {?} */ function (stmt, ctx) { ctx.println(stmt, "try {"); ctx.incIndent(); this.visitAllStatements(stmt.bodyStmts, ctx); ctx.decIndent(); ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {"); ctx.incIndent(); var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack', null)).toDeclStmt(null, [ StmtModifier.Final ]))].concat(stmt.catchStmts); this.visitAllStatements(catchStmts, ctx); ctx.decIndent(); ctx.println(stmt, "}"); return null; }; /** * @param {?} type * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitBuiltintType = /** * @param {?} type * @param {?} ctx * @return {?} */ function (type, ctx) { var /** @type {?} */ typeStr; switch (type.name) { case BuiltinTypeName.Bool: typeStr = 'boolean'; break; case BuiltinTypeName.Dynamic: typeStr = 'any'; break; case BuiltinTypeName.Function: typeStr = 'Function'; break; case BuiltinTypeName.Number: typeStr = 'number'; break; case BuiltinTypeName.Int: typeStr = 'number'; break; case BuiltinTypeName.String: typeStr = 'string'; break; default: throw new Error("Unsupported builtin type " + type.name); } ctx.print(null, typeStr); return null; }; /** * @param {?} ast * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitExpressionType = /** * @param {?} ast * @param {?} ctx * @return {?} */ function (ast, ctx) { ast.value.visitExpression(this, ctx); return null; }; /** * @param {?} type * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitArrayType = /** * @param {?} type * @param {?} ctx * @return {?} */ function (type, ctx) { this.visitType(type.of, ctx); ctx.print(null, "[]"); return null; }; /** * @param {?} type * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype.visitMapType = /** * @param {?} type * @param {?} ctx * @return {?} */ function (type, ctx) { ctx.print(null, "{[key: string]:"); this.visitType(type.valueType, ctx); ctx.print(null, "}"); return null; }; /** * @param {?} method * @return {?} */ _TsEmitterVisitor.prototype.getBuiltinMethodName = /** * @param {?} method * @return {?} */ function (method) { var /** @type {?} */ name; switch (method) { case BuiltinMethod.ConcatArray: name = 'concat'; break; case BuiltinMethod.SubscribeObservable: name = 'subscribe'; break; case BuiltinMethod.Bind: name = 'bind'; break; default: throw new Error("Unknown builtin method: " + method); } return name; }; /** * @param {?} params * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitParams = /** * @param {?} params * @param {?} ctx * @return {?} */ function (params, ctx) { var _this = this; this.visitAllObjects(function (param) { ctx.print(null, param.name); _this._printColonType(param.type, ctx); }, params, ctx, ','); }; /** * @param {?} value * @param {?} typeParams * @param {?} ctx * @return {?} */ _TsEmitterVisitor.prototype._visitIdentifier = /** * @param {?} value * @param {?} typeParams * @param {?} ctx * @return {?} */ function (value, typeParams, ctx) { var _this = this; var name = value.name, moduleName = value.moduleName; if (this.referenceFilter && this.referenceFilter(value)) { ctx.print(null, '(null as any)'); return; } if (moduleName) { var /** @type {?} */ prefix = this.importsWithPrefixes.get(moduleName); if (prefix == null) { prefix = "i" + this.importsWithPrefixes.size; this.importsWithPrefixes.set(moduleName, prefix); } ctx.print(null, prefix + "."); } ctx.print(null, /** @type {?} */ ((name))); if (this.typeExpression > 0) { // If we are in a type expression that refers to a generic type then supply // the required type parameters. If there were not enough type parameters // supplied, supply any as the type. Outside a type expression the reference // should not supply type parameters and be treated as a simple value reference // to the constructor function itself. var /** @type {?} */ suppliedParameters = typeParams || []; if (suppliedParameters.length > 0) { ctx.print(null, "<"); this.visitAllObjects(function (type) { return type.visitType(_this, ctx); }, /** @type {?} */ ((typeParams)), ctx, ','); ctx.print(null, ">"); } } }; /** * @param {?} type * @param {?} ctx * @param {?=} defaultType * @return {?} */ _TsEmitterVisitor.prototype._printColonType = /** * @param {?} type * @param {?} ctx * @param {?=} defaultType * @return {?} */ function (type, ctx, defaultType) { if (type !== INFERRED_TYPE) { ctx.print(null, ':'); this.visitType(type, ctx, defaultType); } }; return _TsEmitterVisitor; }(AbstractEmitterVisitor)); /** * @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 */ /** * Resolve a `Type` for {\@link Pipe}. * * This interface can be overridden by the application developer to create custom behavior. * * See {\@link Compiler} */ var PipeResolver = /** @class */ (function () { function PipeResolver(_reflector) { this._reflector = _reflector; } /** * @param {?} type * @return {?} */ PipeResolver.prototype.isPipe = /** * @param {?} type * @return {?} */ function (type) { var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type)); return typeMetadata && typeMetadata.some(createPipe.isTypeOf); }; /** * Return {@link Pipe} for a given `Type`. */ /** * Return {\@link Pipe} for a given `Type`. * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ PipeResolver.prototype.resolve = /** * Return {\@link Pipe} for a given `Type`. * @param {?} type * @param {?=} throwIfNotFound * @return {?} */ function (type, throwIfNotFound) { if (throwIfNotFound === void 0) { throwIfNotFound = true; } var /** @type {?} */ metas = this._reflector.annotations(resolveForwardRef(type)); if (metas) { var /** @type {?} */ annotation = findLast(metas, createPipe.isTypeOf); if (annotation) { return annotation; } } if (throwIfNotFound) { throw new Error("No Pipe decorator found on " + stringify(type)); } return null; }; return PipeResolver; }()); /** * @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 */ /** * Map from tagName|propertyName SecurityContext. Properties applying to all tags use '*'. */ var SECURITY_SCHEMA = {}; /** * @param {?} ctx * @param {?} specs * @return {?} */ function registerContext(ctx, specs) { for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; SECURITY_SCHEMA[spec.toLowerCase()] = ctx; } } // Case is insignificant below, all element and attribute names are lower-cased for lookup. registerContext(SecurityContext.HTML, [ 'iframe|srcdoc', '*|innerHTML', '*|outerHTML', ]); registerContext(SecurityContext.STYLE, ['*|style']); // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them. registerContext(SecurityContext.URL, [ '*|formAction', 'area|href', 'area|ping', 'audio|src', 'a|href', 'a|ping', 'blockquote|cite', 'body|background', 'del|cite', 'form|action', 'img|src', 'img|srcset', 'input|src', 'ins|cite', 'q|cite', 'source|src', 'source|srcset', 'track|src', 'video|poster', 'video|src', ]); registerContext(SecurityContext.RESOURCE_URL, [ 'applet|code', 'applet|codebase', 'base|href', 'embed|src', 'frame|src', 'head|profile', 'html|manifest', 'iframe|src', 'link|href', 'media|src', 'object|codebase', 'object|data', 'script|src', ]); /** * @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 */ var ElementSchemaRegistry = /** @class */ (function () { function ElementSchemaRegistry() { } return ElementSchemaRegistry; }()); /** * @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 BOOLEAN = 'boolean'; var NUMBER = 'number'; var STRING = 'string'; var OBJECT = 'object'; /** * This array represents the DOM schema. It encodes inheritance, properties, and events. * * ## Overview * * Each line represents one kind of element. The `element_inheritance` and properties are joined * using `element_inheritance|properties` syntax. * * ## Element Inheritance * * The `element_inheritance` can be further subdivided as `element1,element2,...^parentElement`. * Here the individual elements are separated by `,` (commas). Every element in the list * has identical properties. * * An `element` may inherit additional properties from `parentElement` If no `^parentElement` is * specified then `""` (blank) element is assumed. * * NOTE: The blank element inherits from root `[Element]` element, the super element of all * elements. * * NOTE an element prefix such as `:svg:` has no special meaning to the schema. * * ## Properties * * Each element has a set of properties separated by `,` (commas). Each property can be prefixed * by a special character designating its type: * * - (no prefix): property is a string. * - `*`: property represents an event. * - `!`: property is a boolean. * - `#`: property is a number. * - `%`: property is an object. * * ## Query * * The class creates an internal squas representation which allows to easily answer the query of * if a given property exist on a given element. * * NOTE: We don't yet support querying for types or events. * NOTE: This schema is auto extracted from `schema_extractor.ts` located in the test folder, * see dom_element_schema_registry_spec.ts */ var SCHEMA = [ '[Element]|textContent,%classList,className,id,innerHTML,*beforecopy,*beforecut,*beforepaste,*copy,*cut,*paste,*search,*selectstart,*webkitfullscreenchange,*webkitfullscreenerror,*wheel,outerHTML,#scrollLeft,#scrollTop,slot' + ',*message,*mozfullscreenchange,*mozfullscreenerror,*mozpointerlockchange,*mozpointerlockerror,*webglcontextcreationerror,*webglcontextlost,*webglcontextrestored', '[HTMLElement]^[Element]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate', 'abbr,address,article,aside,b,bdi,bdo,cite,code,dd,dfn,dt,em,figcaption,figure,footer,header,i,kbd,main,mark,nav,noscript,rb,rp,rt,rtc,ruby,s,samp,section,small,strong,sub,sup,u,var,wbr^[HTMLElement]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate', 'media^[HTMLElement]|!autoplay,!controls,%controlsList,%crossOrigin,#currentTime,!defaultMuted,#defaultPlaybackRate,!disableRemotePlayback,!loop,!muted,*encrypted,*waitingforkey,#playbackRate,preload,src,%srcObject,#volume', ':svg:^[HTMLElement]|*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,%style,#tabIndex', ':svg:graphics^:svg:|', ':svg:animation^:svg:|*begin,*end,*repeat', ':svg:geometry^:svg:|', ':svg:componentTransferFunction^:svg:|', ':svg:gradient^:svg:|', ':svg:textContent^:svg:graphics|', ':svg:textPositioning^:svg:textContent|', 'a^[HTMLElement]|charset,coords,download,hash,host,hostname,href,hreflang,name,password,pathname,ping,port,protocol,referrerPolicy,rel,rev,search,shape,target,text,type,username', 'area^[HTMLElement]|alt,coords,download,hash,host,hostname,href,!noHref,password,pathname,ping,port,protocol,referrerPolicy,rel,search,shape,target,username', 'audio^media|', 'br^[HTMLElement]|clear', 'base^[HTMLElement]|href,target', 'body^[HTMLElement]|aLink,background,bgColor,link,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,text,vLink', 'button^[HTMLElement]|!autofocus,!disabled,formAction,formEnctype,formMethod,!formNoValidate,formTarget,name,type,value', 'canvas^[HTMLElement]|#height,#width', 'content^[HTMLElement]|select', 'dl^[HTMLElement]|!compact', 'datalist^[HTMLElement]|', 'details^[HTMLElement]|!open', 'dialog^[HTMLElement]|!open,returnValue', 'dir^[HTMLElement]|!compact', 'div^[HTMLElement]|align', 'embed^[HTMLElement]|align,height,name,src,type,width', 'fieldset^[HTMLElement]|!disabled,name', 'font^[HTMLElement]|color,face,size', 'form^[HTMLElement]|acceptCharset,action,autocomplete,encoding,enctype,method,name,!noValidate,target', 'frame^[HTMLElement]|frameBorder,longDesc,marginHeight,marginWidth,name,!noResize,scrolling,src', 'frameset^[HTMLElement]|cols,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,rows', 'hr^[HTMLElement]|align,color,!noShade,size,width', 'head^[HTMLElement]|', 'h1,h2,h3,h4,h5,h6^[HTMLElement]|align', 'html^[HTMLElement]|version', 'iframe^[HTMLElement]|align,!allowFullscreen,frameBorder,height,longDesc,marginHeight,marginWidth,name,referrerPolicy,%sandbox,scrolling,src,srcdoc,width', 'img^[HTMLElement]|align,alt,border,%crossOrigin,#height,#hspace,!isMap,longDesc,lowsrc,name,referrerPolicy,sizes,src,srcset,useMap,#vspace,#width', 'input^[HTMLElement]|accept,align,alt,autocapitalize,autocomplete,!autofocus,!checked,!defaultChecked,defaultValue,dirName,!disabled,%files,formAction,formEnctype,formMethod,!formNoValidate,formTarget,#height,!incremental,!indeterminate,max,#maxLength,min,#minLength,!multiple,name,pattern,placeholder,!readOnly,!required,selectionDirection,#selectionEnd,#selectionStart,#size,src,step,type,useMap,value,%valueAsDate,#valueAsNumber,#width', 'li^[HTMLElement]|type,#value', 'label^[HTMLElement]|htmlFor', 'legend^[HTMLElement]|align', 'link^[HTMLElement]|as,charset,%crossOrigin,!disabled,href,hreflang,integrity,media,referrerPolicy,rel,%relList,rev,%sizes,target,type', 'map^[HTMLElement]|name', 'marquee^[HTMLElement]|behavior,bgColor,direction,height,#hspace,#loop,#scrollAmount,#scrollDelay,!trueSpeed,#vspace,width', 'menu^[HTMLElement]|!compact', 'meta^[HTMLElement]|content,httpEquiv,name,scheme', 'meter^[HTMLElement]|#high,#low,#max,#min,#optimum,#value', 'ins,del^[HTMLElement]|cite,dateTime', 'ol^[HTMLElement]|!compact,!reversed,#start,type', 'object^[HTMLElement]|align,archive,border,code,codeBase,codeType,data,!declare,height,#hspace,name,standby,type,useMap,#vspace,width', 'optgroup^[HTMLElement]|!disabled,label', 'option^[HTMLElement]|!defaultSelected,!disabled,label,!selected,text,value', 'output^[HTMLElement]|defaultValue,%htmlFor,name,value', 'p^[HTMLElement]|align', 'param^[HTMLElement]|name,type,value,valueType', 'picture^[HTMLElement]|', 'pre^[HTMLElement]|#width', 'progress^[HTMLElement]|#max,#value', 'q,blockquote,cite^[HTMLElement]|', 'script^[HTMLElement]|!async,charset,%crossOrigin,!defer,event,htmlFor,integrity,src,text,type', 'select^[HTMLElement]|!autofocus,!disabled,#length,!multiple,name,!required,#selectedIndex,#size,value', 'shadow^[HTMLElement]|', 'slot^[HTMLElement]|name', 'source^[HTMLElement]|media,sizes,src,srcset,type', 'span^[HTMLElement]|', 'style^[HTMLElement]|!disabled,media,type', 'caption^[HTMLElement]|align', 'th,td^[HTMLElement]|abbr,align,axis,bgColor,ch,chOff,#colSpan,headers,height,!noWrap,#rowSpan,scope,vAlign,width', 'col,colgroup^[HTMLElement]|align,ch,chOff,#span,vAlign,width', 'table^[HTMLElement]|align,bgColor,border,%caption,cellPadding,cellSpacing,frame,rules,summary,%tFoot,%tHead,width', 'tr^[HTMLElement]|align,bgColor,ch,chOff,vAlign', 'tfoot,thead,tbody^[HTMLElement]|align,ch,chOff,vAlign', 'template^[HTMLElement]|', 'textarea^[HTMLElement]|autocapitalize,!autofocus,#cols,defaultValue,dirName,!disabled,#maxLength,#minLength,name,placeholder,!readOnly,!required,#rows,selectionDirection,#selectionEnd,#selectionStart,value,wrap', 'title^[HTMLElement]|text', 'track^[HTMLElement]|!default,kind,label,src,srclang', 'ul^[HTMLElement]|!compact,type', 'unknown^[HTMLElement]|', 'video^media|#height,poster,#width', ':svg:a^:svg:graphics|', ':svg:animate^:svg:animation|', ':svg:animateMotion^:svg:animation|', ':svg:animateTransform^:svg:animation|', ':svg:circle^:svg:geometry|', ':svg:clipPath^:svg:graphics|', ':svg:defs^:svg:graphics|', ':svg:desc^:svg:|', ':svg:discard^:svg:|', ':svg:ellipse^:svg:geometry|', ':svg:feBlend^:svg:|', ':svg:feColorMatrix^:svg:|', ':svg:feComponentTransfer^:svg:|', ':svg:feComposite^:svg:|', ':svg:feConvolveMatrix^:svg:|', ':svg:feDiffuseLighting^:svg:|', ':svg:feDisplacementMap^:svg:|', ':svg:feDistantLight^:svg:|', ':svg:feDropShadow^:svg:|', ':svg:feFlood^:svg:|', ':svg:feFuncA^:svg:componentTransferFunction|', ':svg:feFuncB^:svg:componentTransferFunction|', ':svg:feFuncG^:svg:componentTransferFunction|', ':svg:feFuncR^:svg:componentTransferFunction|', ':svg:feGaussianBlur^:svg:|', ':svg:feImage^:svg:|', ':svg:feMerge^:svg:|', ':svg:feMergeNode^:svg:|', ':svg:feMorphology^:svg:|', ':svg:feOffset^:svg:|', ':svg:fePointLight^:svg:|', ':svg:feSpecularLighting^:svg:|', ':svg:feSpotLight^:svg:|', ':svg:feTile^:svg:|', ':svg:feTurbulence^:svg:|', ':svg:filter^:svg:|', ':svg:foreignObject^:svg:graphics|', ':svg:g^:svg:graphics|', ':svg:image^:svg:graphics|', ':svg:line^:svg:geometry|', ':svg:linearGradient^:svg:gradient|', ':svg:mpath^:svg:|', ':svg:marker^:svg:|', ':svg:mask^:svg:|', ':svg:metadata^:svg:|', ':svg:path^:svg:geometry|', ':svg:pattern^:svg:|', ':svg:polygon^:svg:geometry|', ':svg:polyline^:svg:geometry|', ':svg:radialGradient^:svg:gradient|', ':svg:rect^:svg:geometry|', ':svg:svg^:svg:graphics|#currentScale,#zoomAndPan', ':svg:script^:svg:|type', ':svg:set^:svg:animation|', ':svg:stop^:svg:|', ':svg:style^:svg:|!disabled,media,title,type', ':svg:switch^:svg:graphics|', ':svg:symbol^:svg:|', ':svg:tspan^:svg:textPositioning|', ':svg:text^:svg:textPositioning|', ':svg:textPath^:svg:textContent|', ':svg:title^:svg:|', ':svg:use^:svg:graphics|', ':svg:view^:svg:|#zoomAndPan', 'data^[HTMLElement]|value', 'keygen^[HTMLElement]|!autofocus,challenge,!disabled,form,keytype,name', 'menuitem^[HTMLElement]|type,label,icon,!disabled,!checked,radiogroup,!default', 'summary^[HTMLElement]|', 'time^[HTMLElement]|dateTime', ':svg:cursor^:svg:|', ]; var _ATTR_TO_PROP = { 'class': 'className', 'for': 'htmlFor', 'formaction': 'formAction', 'innerHtml': 'innerHTML', 'readonly': 'readOnly', 'tabindex': 'tabIndex', }; var DomElementSchemaRegistry = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(DomElementSchemaRegistry, _super); function DomElementSchemaRegistry() { var _this = _super.call(this) || this; _this._schema = {}; SCHEMA.forEach(function (encodedType) { var /** @type {?} */ type = {}; var _a = encodedType.split('|'), strType = _a[0], strProperties = _a[1]; var /** @type {?} */ properties = strProperties.split(','); var _b = strType.split('^'), typeNames = _b[0], superName = _b[1]; typeNames.split(',').forEach(function (tag) { return _this._schema[tag.toLowerCase()] = type; }); var /** @type {?} */ superType = superName && _this._schema[superName.toLowerCase()]; if (superType) { Object.keys(superType).forEach(function (prop) { type[prop] = superType[prop]; }); } properties.forEach(function (property) { if (property.length > 0) { switch (property[0]) { case '*': // We don't yet support events. // If ever allowing to bind to events, GO THROUGH A SECURITY REVIEW, allowing events // will // almost certainly introduce bad XSS vulnerabilities. // type[property.substring(1)] = EVENT; break; case '!': type[property.substring(1)] = BOOLEAN; break; case '#': type[property.substring(1)] = NUMBER; break; case '%': type[property.substring(1)] = OBJECT; break; default: type[property] = STRING; } } }); }); return _this; } /** * @param {?} tagName * @param {?} propName * @param {?} schemaMetas * @return {?} */ DomElementSchemaRegistry.prototype.hasProperty = /** * @param {?} tagName * @param {?} propName * @param {?} schemaMetas * @return {?} */ function (tagName, propName, schemaMetas) { if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) { return true; } if (tagName.indexOf('-') > -1) { if (isNgContainer(tagName) || isNgContent(tagName)) { return false; } if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) { // Can't tell now as we don't know which properties a custom element will get // once it is instantiated return true; } } var /** @type {?} */ elementProperties = this._schema[tagName.toLowerCase()] || this._schema['unknown']; return !!elementProperties[propName]; }; /** * @param {?} tagName * @param {?} schemaMetas * @return {?} */ DomElementSchemaRegistry.prototype.hasElement = /** * @param {?} tagName * @param {?} schemaMetas * @return {?} */ function (tagName, schemaMetas) { if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) { return true; } if (tagName.indexOf('-') > -1) { if (isNgContainer(tagName) || isNgContent(tagName)) { return true; } if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) { // Allow any custom elements return true; } } return !!this._schema[tagName.toLowerCase()]; }; /** * securityContext returns the security context for the given property on the given DOM tag. * * Tag and property name are statically known and cannot change at runtime, i.e. it is not * possible to bind a value into a changing attribute or tag name. * * The filtering is white list based. All attributes in the schema above are assumed to have the * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known * attack vectors are assigned their appropriate context. */ /** * securityContext returns the security context for the given property on the given DOM tag. * * Tag and property name are statically known and cannot change at runtime, i.e. it is not * possible to bind a value into a changing attribute or tag name. * * The filtering is white list based. All attributes in the schema above are assumed to have the * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known * attack vectors are assigned their appropriate context. * @param {?} tagName * @param {?} propName * @param {?} isAttribute * @return {?} */ DomElementSchemaRegistry.prototype.securityContext = /** * securityContext returns the security context for the given property on the given DOM tag. * * Tag and property name are statically known and cannot change at runtime, i.e. it is not * possible to bind a value into a changing attribute or tag name. * * The filtering is white list based. All attributes in the schema above are assumed to have the * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known * attack vectors are assigned their appropriate context. * @param {?} tagName * @param {?} propName * @param {?} isAttribute * @return {?} */ function (tagName, propName, isAttribute) { if (isAttribute) { // NB: For security purposes, use the mapped property name, not the attribute name. propName = this.getMappedPropName(propName); } // Make sure comparisons are case insensitive, so that case differences between attribute and // property names do not have a security impact. tagName = tagName.toLowerCase(); propName = propName.toLowerCase(); var /** @type {?} */ ctx = SECURITY_SCHEMA[tagName + '|' + propName]; if (ctx) { return ctx; } ctx = SECURITY_SCHEMA['*|' + propName]; return ctx ? ctx : SecurityContext.NONE; }; /** * @param {?} propName * @return {?} */ DomElementSchemaRegistry.prototype.getMappedPropName = /** * @param {?} propName * @return {?} */ function (propName) { return _ATTR_TO_PROP[propName] || propName; }; /** * @return {?} */ DomElementSchemaRegistry.prototype.getDefaultComponentElementName = /** * @return {?} */ function () { return 'ng-component'; }; /** * @param {?} name * @return {?} */ DomElementSchemaRegistry.prototype.validateProperty = /** * @param {?} name * @return {?} */ function (name) { if (name.toLowerCase().startsWith('on')) { var /** @type {?} */ msg = "Binding to event property '" + name + "' is disallowed for security reasons, " + ("please use (" + name.slice(2) + ")=...") + ("\nIf '" + name + "' is a directive input, make sure the directive is imported by the") + " current module."; return { error: true, msg: msg }; } else { return { error: false }; } }; /** * @param {?} name * @return {?} */ DomElementSchemaRegistry.prototype.validateAttribute = /** * @param {?} name * @return {?} */ function (name) { if (name.toLowerCase().startsWith('on')) { var /** @type {?} */ msg = "Binding to event attribute '" + name + "' is disallowed for security reasons, " + ("please use (" + name.slice(2) + ")=..."); return { error: true, msg: msg }; } else { return { error: false }; } }; /** * @return {?} */ DomElementSchemaRegistry.prototype.allKnownElementNames = /** * @return {?} */ function () { return Object.keys(this._schema); }; /** * @param {?} propName * @return {?} */ DomElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = /** * @param {?} propName * @return {?} */ function (propName) { return dashCaseToCamelCase(propName); }; /** * @param {?} camelCaseProp * @param {?} userProvidedProp * @param {?} val * @return {?} */ DomElementSchemaRegistry.prototype.normalizeAnimationStyleValue = /** * @param {?} camelCaseProp * @param {?} userProvidedProp * @param {?} val * @return {?} */ function (camelCaseProp, userProvidedProp, val) { var /** @type {?} */ unit = ''; var /** @type {?} */ strVal = val.toString().trim(); var /** @type {?} */ errorMsg = /** @type {?} */ ((null)); if (_isPixelDimensionStyle(camelCaseProp) && val !== 0 && val !== '0') { if (typeof val === 'number') { unit = 'px'; } else { var /** @type {?} */ valAndSuffixMatch = val.match(/^[+-]?[\d\.]+([a-z]*)$/); if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) { errorMsg = "Please provide a CSS unit value for " + userProvidedProp + ":" + val; } } } return { error: errorMsg, value: strVal + unit }; }; return DomElementSchemaRegistry; }(ElementSchemaRegistry)); /** * @param {?} prop * @return {?} */ function _isPixelDimensionStyle(prop) { switch (prop) { case 'width': case 'height': case 'minWidth': case 'minHeight': case 'maxWidth': case 'maxHeight': case 'left': case 'top': case 'bottom': case 'right': case 'fontSize': case 'outlineWidth': case 'outlineOffset': case 'paddingTop': case 'paddingLeft': case 'paddingBottom': case 'paddingRight': case 'marginTop': case 'marginLeft': case 'marginBottom': case 'marginRight': case 'borderRadius': case 'borderWidth': case 'borderTopWidth': case 'borderLeftWidth': case 'borderRightWidth': case 'borderBottomWidth': case 'textIndent': return true; default: return false; } } /** * @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 file is a port of shadowCSS from webcomponents.js to TypeScript. * * Please make sure to keep to edits in sync with the source file. * * Source: * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js * * The original file level comment is reproduced below */ /* This is a limited shim for ShadowDOM css styling. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles The intention here is to support only the styling features which can be relatively simply implemented. The goal is to allow users to avoid the most obvious pitfalls and do so without compromising performance significantly. For ShadowDOM styling that's not covered here, a set of best practices can be provided that should allow users to accomplish more complex styling. The following is a list of specific ShadowDOM styling features and a brief discussion of the approach used to shim. Shimmed features: * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host element using the :host rule. To shim this feature, the :host styles are reformatted and prefixed with a given scope name and promoted to a document level stylesheet. For example, given a scope name of .foo, a rule like this: :host { background: red; } } becomes: .foo { background: red; } * encapsulation: Styles defined within ShadowDOM, apply only to dom inside the ShadowDOM. Polymer uses one of two techniques to implement this feature. By default, rules are prefixed with the host element tag name as a descendant selector. This ensures styling does not leak out of the 'top' of the element's ShadowDOM. For example, div { font-weight: bold; } becomes: x-foo div { font-weight: bold; } becomes: Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then selectors are scoped by adding an attribute selector suffix to each simple selector that contains the host element tag name. Each element in the element's ShadowDOM template is also given the scope attribute. Thus, these rules match only elements that have the scope attribute. For example, given a scope name of x-foo, a rule like this: div { font-weight: bold; } becomes: div[x-foo] { font-weight: bold; } Note that elements that are dynamically added to a scope must have the scope selector added to them manually. * upper/lower bound encapsulation: Styles which are defined outside a shadowRoot should not cross the ShadowDOM boundary and should not apply inside a shadowRoot. This styling behavior is not emulated. Some possible ways to do this that were rejected due to complexity and/or performance concerns include: (1) reset every possible property for every possible selector for a given scope name; (2) re-implement css in javascript. As an alternative, users should make sure to use selectors specific to the scope in which they are working. * ::distributed: This behavior is not emulated. It's often not necessary to style the contents of a specific insertion point and instead, descendants of the host element can be styled selectively. Users can also create an extra node around an insertion point and style that node's contents via descendent selectors. For example, with a shadowRoot like this: could become:

    Note the use of @polyfill in the comment above a ShadowDOM specific style declaration. This is a directive to the styling shim to use the selector in comments in lieu of the next selector when running under polyfill. */ var ShadowCss = /** @class */ (function () { function ShadowCss() { this.strictStyling = true; } /* * Shim some cssText with the given selector. Returns cssText that can * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css). * * When strictStyling is true: * - selector is the attribute added to all elements inside the host, * - hostSelector is the attribute added to the host itself. */ /** * @param {?} cssText * @param {?} selector * @param {?=} hostSelector * @return {?} */ ShadowCss.prototype.shimCssText = /** * @param {?} cssText * @param {?} selector * @param {?=} hostSelector * @return {?} */ function (cssText, selector, hostSelector) { if (hostSelector === void 0) { hostSelector = ''; } var /** @type {?} */ commentsWithHash = extractCommentsWithHash(cssText); cssText = stripComments(cssText); cssText = this._insertDirectives(cssText); var /** @type {?} */ scopedCssText = this._scopeCssText(cssText, selector, hostSelector); return [scopedCssText].concat(commentsWithHash).join('\n'); }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._insertDirectives = /** * @param {?} cssText * @return {?} */ function (cssText) { cssText = this._insertPolyfillDirectivesInCssText(cssText); return this._insertPolyfillRulesInCssText(cssText); }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._insertPolyfillDirectivesInCssText = /** * @param {?} cssText * @return {?} */ function (cssText) { // Difference with webcomponents.js: does not handle comments return cssText.replace(_cssContentNextSelectorRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } return m[2] + '{'; }); }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._insertPolyfillRulesInCssText = /** * @param {?} cssText * @return {?} */ function (cssText) { // Difference with webcomponents.js: does not handle comments return cssText.replace(_cssContentRuleRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var /** @type {?} */ rule = m[0].replace(m[1], '').replace(m[2], ''); return m[4] + rule; }); }; /** * @param {?} cssText * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ ShadowCss.prototype._scopeCssText = /** * @param {?} cssText * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ function (cssText, scopeSelector, hostSelector) { var /** @type {?} */ unscopedRules = this._extractUnscopedRulesFromCssText(cssText); // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively cssText = this._insertPolyfillHostInCssText(cssText); cssText = this._convertColonHost(cssText); cssText = this._convertColonHostContext(cssText); cssText = this._convertShadowDOMSelectors(cssText); if (scopeSelector) { cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector); } cssText = cssText + '\n' + unscopedRules; return cssText.trim(); }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._extractUnscopedRulesFromCssText = /** * @param {?} cssText * @return {?} */ function (cssText) { // Difference with webcomponents.js: does not handle comments var /** @type {?} */ r = ''; var /** @type {?} */ m; _cssContentUnscopedRuleRe.lastIndex = 0; while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) { var /** @type {?} */ rule = m[0].replace(m[2], '').replace(m[1], m[4]); r += rule + '\n\n'; } return r; }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._convertColonHost = /** * @param {?} cssText * @return {?} */ function (cssText) { return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer); }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._convertColonHostContext = /** * @param {?} cssText * @return {?} */ function (cssText) { return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer); }; /** * @param {?} cssText * @param {?} regExp * @param {?} partReplacer * @return {?} */ ShadowCss.prototype._convertColonRule = /** * @param {?} cssText * @param {?} regExp * @param {?} partReplacer * @return {?} */ function (cssText, regExp, partReplacer) { // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule return cssText.replace(regExp, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } if (m[2]) { var /** @type {?} */ parts = m[2].split(','); var /** @type {?} */ r = []; for (var /** @type {?} */ i = 0; i < parts.length; i++) { var /** @type {?} */ p = parts[i].trim(); if (!p) break; r.push(partReplacer(_polyfillHostNoCombinator, p, m[3])); } return r.join(','); } else { return _polyfillHostNoCombinator + m[3]; } }); }; /** * @param {?} host * @param {?} part * @param {?} suffix * @return {?} */ ShadowCss.prototype._colonHostContextPartReplacer = /** * @param {?} host * @param {?} part * @param {?} suffix * @return {?} */ function (host, part, suffix) { if (part.indexOf(_polyfillHost) > -1) { return this._colonHostPartReplacer(host, part, suffix); } else { return host + part + suffix + ', ' + part + ' ' + host + suffix; } }; /** * @param {?} host * @param {?} part * @param {?} suffix * @return {?} */ ShadowCss.prototype._colonHostPartReplacer = /** * @param {?} host * @param {?} part * @param {?} suffix * @return {?} */ function (host, part, suffix) { return host + part.replace(_polyfillHost, '') + suffix; }; /** * @param {?} cssText * @return {?} */ ShadowCss.prototype._convertShadowDOMSelectors = /** * @param {?} cssText * @return {?} */ function (cssText) { return _shadowDOMSelectorsRe.reduce(function (result, pattern) { return result.replace(pattern, ' '); }, cssText); }; /** * @param {?} cssText * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ ShadowCss.prototype._scopeSelectors = /** * @param {?} cssText * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ function (cssText, scopeSelector, hostSelector) { var _this = this; return processRules(cssText, function (rule) { var /** @type {?} */ selector = rule.selector; var /** @type {?} */ content = rule.content; if (rule.selector[0] != '@') { selector = _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling); } else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') || rule.selector.startsWith('@page') || rule.selector.startsWith('@document')) { content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector); } return new CssRule(selector, content); }); }; /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @param {?} strict * @return {?} */ ShadowCss.prototype._scopeSelector = /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @param {?} strict * @return {?} */ function (selector, scopeSelector, hostSelector, strict) { var _this = this; return selector.split(',') .map(function (part) { return part.trim().split(_shadowDeepSelectors); }) .map(function (deepParts) { var shallowPart = deepParts[0], otherParts = deepParts.slice(1); var /** @type {?} */ applyScope = function (shallowPart) { if (_this._selectorNeedsScoping(shallowPart, scopeSelector)) { return strict ? _this._applyStrictSelectorScope(shallowPart, scopeSelector, hostSelector) : _this._applySelectorScope(shallowPart, scopeSelector, hostSelector); } else { return shallowPart; } }; return [applyScope(shallowPart)].concat(otherParts).join(' '); }) .join(', '); }; /** * @param {?} selector * @param {?} scopeSelector * @return {?} */ ShadowCss.prototype._selectorNeedsScoping = /** * @param {?} selector * @param {?} scopeSelector * @return {?} */ function (selector, scopeSelector) { var /** @type {?} */ re = this._makeScopeMatcher(scopeSelector); return !re.test(selector); }; /** * @param {?} scopeSelector * @return {?} */ ShadowCss.prototype._makeScopeMatcher = /** * @param {?} scopeSelector * @return {?} */ function (scopeSelector) { var /** @type {?} */ lre = /\[/g; var /** @type {?} */ rre = /\]/g; scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]'); return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm'); }; /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ ShadowCss.prototype._applySelectorScope = /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ function (selector, scopeSelector, hostSelector) { // Difference from webcomponents.js: scopeSelector could not be an array return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector); }; /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ ShadowCss.prototype._applySimpleSelectorScope = /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ function (selector, scopeSelector, hostSelector) { // In Android browser, the lastIndex is not reset when the regex is used in String.replace() _polyfillHostRe.lastIndex = 0; if (_polyfillHostRe.test(selector)) { var /** @type {?} */ replaceBy_1 = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector; return selector .replace(_polyfillHostNoCombinatorRe, function (hnc, selector) { return selector.replace(/([^:]*)(:*)(.*)/, function (_, before, colon, after) { return before + replaceBy_1 + colon + after; }); }) .replace(_polyfillHostRe, replaceBy_1 + ' '); } return scopeSelector + ' ' + selector; }; /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ ShadowCss.prototype._applyStrictSelectorScope = /** * @param {?} selector * @param {?} scopeSelector * @param {?} hostSelector * @return {?} */ function (selector, scopeSelector, hostSelector) { var _this = this; var /** @type {?} */ isRe = /\[is=([^\]]*)\]/g; scopeSelector = scopeSelector.replace(isRe, function (_) { var parts = []; for (var _i = 1; _i < arguments.length; _i++) { parts[_i - 1] = arguments[_i]; } return parts[0]; }); var /** @type {?} */ attrName = '[' + scopeSelector + ']'; var /** @type {?} */ _scopeSelectorPart = function (p) { var /** @type {?} */ scopedP = p.trim(); if (!scopedP) { return ''; } if (p.indexOf(_polyfillHostNoCombinator) > -1) { scopedP = _this._applySimpleSelectorScope(p, scopeSelector, hostSelector); } else { // remove :host since it should be unnecessary var /** @type {?} */ t = p.replace(_polyfillHostRe, ''); if (t.length > 0) { var /** @type {?} */ matches = t.match(/([^:]*)(:*)(.*)/); if (matches) { scopedP = matches[1] + attrName + matches[2] + matches[3]; } } } return scopedP; }; var /** @type {?} */ safeContent = new SafeSelector(selector); selector = safeContent.content(); var /** @type {?} */ scopedSelector = ''; var /** @type {?} */ startIndex = 0; var /** @type {?} */ res; var /** @type {?} */ sep = /( |>|\+|~(?!=))\s*/g; // If a selector appears before :host it should not be shimmed as it // matches on ancestor elements and not on elements in the host's shadow // `:host-context(div)` is transformed to // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator` // the `div` is not part of the component in the 2nd selectors and should not be scoped. // Historically `component-tag:host` was matching the component so we also want to preserve // this behavior to avoid breaking legacy apps (it should not match). // The behavior should be: // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything) // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a // `:host-context(tag)`) var /** @type {?} */ hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1; // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present var /** @type {?} */ shouldScope = !hasHost; while ((res = sep.exec(selector)) !== null) { var /** @type {?} */ separator = res[1]; var /** @type {?} */ part_1 = selector.slice(startIndex, res.index).trim(); shouldScope = shouldScope || part_1.indexOf(_polyfillHostNoCombinator) > -1; var /** @type {?} */ scopedPart = shouldScope ? _scopeSelectorPart(part_1) : part_1; scopedSelector += scopedPart + " " + separator + " "; startIndex = sep.lastIndex; } var /** @type {?} */ part = selector.substring(startIndex); shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1; scopedSelector += shouldScope ? _scopeSelectorPart(part) : part; // replace the placeholders with their original values return safeContent.restore(scopedSelector); }; /** * @param {?} selector * @return {?} */ ShadowCss.prototype._insertPolyfillHostInCssText = /** * @param {?} selector * @return {?} */ function (selector) { return selector.replace(_colonHostContextRe, _polyfillHostContext) .replace(_colonHostRe, _polyfillHost); }; return ShadowCss; }()); var SafeSelector = /** @class */ (function () { function SafeSelector(selector) { var _this = this; this.placeholders = []; this.index = 0; // Replaces attribute selectors with placeholders. // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator. selector = selector.replace(/(\[[^\]]*\])/g, function (_, keep) { var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__"; _this.placeholders.push(keep); _this.index++; return replaceBy; }); // Replaces the expression in `:nth-child(2n + 1)` with a placeholder. // WS and "+" would otherwise be interpreted as selector separators. this._content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, function (_, pseudo, exp) { var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__"; _this.placeholders.push(exp); _this.index++; return pseudo + replaceBy; }); } /** * @param {?} content * @return {?} */ SafeSelector.prototype.restore = /** * @param {?} content * @return {?} */ function (content) { var _this = this; return content.replace(/__ph-(\d+)__/g, function (ph, index) { return _this.placeholders[+index]; }); }; /** * @return {?} */ SafeSelector.prototype.content = /** * @return {?} */ function () { return this._content; }; return SafeSelector; }()); var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim; var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim; var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim; var _polyfillHost = '-shadowcsshost'; // note: :host-context pre-processed to -shadowcsshostcontext. var _polyfillHostContext = '-shadowcsscontext'; var _parenSuffix = ')(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)'; var _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim'); var _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim'); var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator'; var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/; var _shadowDOMSelectorsRe = [ /::shadow/g, /::content/g, /\/shadow-deep\//g, /\/shadow\//g, ]; // The deep combinator is deprecated in the CSS spec // Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future. // see https://github.com/angular/angular/pull/17677 var _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g; var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$'; var _polyfillHostRe = /-shadowcsshost/gim; var _colonHostRe = /:host/gim; var _colonHostContextRe = /:host-context/gim; var _commentRe = /\/\*\s*[\s\S]*?\*\//g; /** * @param {?} input * @return {?} */ function stripComments(input) { return input.replace(_commentRe, ''); } var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g; /** * @param {?} input * @return {?} */ function extractCommentsWithHash(input) { return input.match(_commentWithHashRe) || []; } var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g; var _curlyRe = /([{}])/g; var OPEN_CURLY = '{'; var CLOSE_CURLY = '}'; var BLOCK_PLACEHOLDER = '%BLOCK%'; var CssRule = /** @class */ (function () { function CssRule(selector, content) { this.selector = selector; this.content = content; } return CssRule; }()); /** * @param {?} input * @param {?} ruleCallback * @return {?} */ function processRules(input, ruleCallback) { var /** @type {?} */ inputWithEscapedBlocks = escapeBlocks(input); var /** @type {?} */ nextBlockIndex = 0; return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function () { var m = []; for (var _i = 0; _i < arguments.length; _i++) { m[_i] = arguments[_i]; } var /** @type {?} */ selector = m[2]; var /** @type {?} */ content = ''; var /** @type {?} */ suffix = m[4]; var /** @type {?} */ contentPrefix = ''; if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) { content = inputWithEscapedBlocks.blocks[nextBlockIndex++]; suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1); contentPrefix = '{'; } var /** @type {?} */ rule = ruleCallback(new CssRule(selector, content)); return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix; }); } var StringWithEscapedBlocks = /** @class */ (function () { function StringWithEscapedBlocks(escapedString, blocks) { this.escapedString = escapedString; this.blocks = blocks; } return StringWithEscapedBlocks; }()); /** * @param {?} input * @return {?} */ function escapeBlocks(input) { var /** @type {?} */ inputParts = input.split(_curlyRe); var /** @type {?} */ resultParts = []; var /** @type {?} */ escapedBlocks = []; var /** @type {?} */ bracketCount = 0; var /** @type {?} */ currentBlockParts = []; for (var /** @type {?} */ partIndex = 0; partIndex < inputParts.length; partIndex++) { var /** @type {?} */ part = inputParts[partIndex]; if (part == CLOSE_CURLY) { bracketCount--; } if (bracketCount > 0) { currentBlockParts.push(part); } else { if (currentBlockParts.length > 0) { escapedBlocks.push(currentBlockParts.join('')); resultParts.push(BLOCK_PLACEHOLDER); currentBlockParts = []; } resultParts.push(part); } if (part == OPEN_CURLY) { bracketCount++; } } if (currentBlockParts.length > 0) { escapedBlocks.push(currentBlockParts.join('')); resultParts.push(BLOCK_PLACEHOLDER); } return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks); } /** * @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 COMPONENT_VARIABLE = '%COMP%'; var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE; var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE; var StylesCompileDependency = /** @class */ (function () { function StylesCompileDependency(name, moduleUrl, setValue) { this.name = name; this.moduleUrl = moduleUrl; this.setValue = setValue; } return StylesCompileDependency; }()); var CompiledStylesheet = /** @class */ (function () { function CompiledStylesheet(outputCtx, stylesVar, dependencies, isShimmed, meta) { this.outputCtx = outputCtx; this.stylesVar = stylesVar; this.dependencies = dependencies; this.isShimmed = isShimmed; this.meta = meta; } return CompiledStylesheet; }()); var StyleCompiler = /** @class */ (function () { function StyleCompiler(_urlResolver) { this._urlResolver = _urlResolver; this._shadowCss = new ShadowCss(); } /** * @param {?} outputCtx * @param {?} comp * @return {?} */ StyleCompiler.prototype.compileComponent = /** * @param {?} outputCtx * @param {?} comp * @return {?} */ function (outputCtx, comp) { var /** @type {?} */ template = /** @type {?} */ ((comp.template)); return this._compileStyles(outputCtx, comp, new CompileStylesheetMetadata({ styles: template.styles, styleUrls: template.styleUrls, moduleUrl: identifierModuleUrl(comp.type) }), this.needsStyleShim(comp), true); }; /** * @param {?} outputCtx * @param {?} comp * @param {?} stylesheet * @param {?=} shim * @return {?} */ StyleCompiler.prototype.compileStyles = /** * @param {?} outputCtx * @param {?} comp * @param {?} stylesheet * @param {?=} shim * @return {?} */ function (outputCtx, comp, stylesheet, shim) { if (shim === void 0) { shim = this.needsStyleShim(comp); } return this._compileStyles(outputCtx, comp, stylesheet, shim, false); }; /** * @param {?} comp * @return {?} */ StyleCompiler.prototype.needsStyleShim = /** * @param {?} comp * @return {?} */ function (comp) { return /** @type {?} */ ((comp.template)).encapsulation === ViewEncapsulation.Emulated; }; /** * @param {?} outputCtx * @param {?} comp * @param {?} stylesheet * @param {?} shim * @param {?} isComponentStylesheet * @return {?} */ StyleCompiler.prototype._compileStyles = /** * @param {?} outputCtx * @param {?} comp * @param {?} stylesheet * @param {?} shim * @param {?} isComponentStylesheet * @return {?} */ function (outputCtx, comp, stylesheet, shim, isComponentStylesheet) { var _this = this; var /** @type {?} */ styleExpressions = stylesheet.styles.map(function (plainStyle) { return literal(_this._shimIfNeeded(plainStyle, shim)); }); var /** @type {?} */ dependencies = []; stylesheet.styleUrls.forEach(function (styleUrl) { var /** @type {?} */ exprIndex = styleExpressions.length; // Note: This placeholder will be filled later. styleExpressions.push(/** @type {?} */ ((null))); dependencies.push(new StylesCompileDependency(getStylesVarName(null), styleUrl, function (value) { return styleExpressions[exprIndex] = outputCtx.importExpr(value); })); }); // styles variable contains plain strings and arrays of other styles arrays (recursive), // so we set its type to dynamic. var /** @type {?} */ stylesVar = getStylesVarName(isComponentStylesheet ? comp : null); var /** @type {?} */ stmt = variable(stylesVar) .set(literalArr(styleExpressions, new ArrayType(DYNAMIC_TYPE, [TypeModifier.Const]))) .toDeclStmt(null, isComponentStylesheet ? [StmtModifier.Final] : [ StmtModifier.Final, StmtModifier.Exported ]); outputCtx.statements.push(stmt); return new CompiledStylesheet(outputCtx, stylesVar, dependencies, shim, stylesheet); }; /** * @param {?} style * @param {?} shim * @return {?} */ StyleCompiler.prototype._shimIfNeeded = /** * @param {?} style * @param {?} shim * @return {?} */ function (style, shim) { return shim ? this._shadowCss.shimCssText(style, CONTENT_ATTR, HOST_ATTR) : style; }; return StyleCompiler; }()); /** * @param {?} component * @return {?} */ function getStylesVarName(component) { var /** @type {?} */ result = "styles"; if (component) { result += "_" + identifierName(component.type); } 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 */ var PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces'; var SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']); // Equivalent to \s with \u00a0 (non-breaking space) excluded. // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp var WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; var NO_WS_REGEXP = new RegExp("[^" + WS_CHARS + "]"); var WS_REPLACE_REGEXP = new RegExp("[" + WS_CHARS + "]{2,}", 'g'); /** * @param {?} attrs * @return {?} */ function hasPreserveWhitespacesAttr(attrs) { return attrs.some(function (attr) { return attr.name === PRESERVE_WS_ATTR_NAME; }); } /** * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see: * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32 * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character * and later on replaced by a space. We are re-implementing the same idea here. * @param {?} value * @return {?} */ function replaceNgsp(value) { // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' '); } /** * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules: * - consider spaces, tabs and new lines as whitespace characters; * - drop text nodes consisting of whitespace characters only; * - for all other text nodes replace consecutive whitespace characters with one space; * - convert &ngsp; pseudo-entity to a single space; * * Removal and trimming of whitespaces have positive performance impact (less code to generate * while compiling templates, faster view creation). At the same time it can be "destructive" * in some cases (whitespaces can influence layout). Because of the potential of breaking layout * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for * whitespace removal. The default option for whitespace removal will be revisited in Angular 6 * and might be changed to "on" by default. */ var WhitespaceVisitor = /** @class */ (function () { function WhitespaceVisitor() { } /** * @param {?} element * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitElement = /** * @param {?} element * @param {?} context * @return {?} */ function (element, context) { if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) { // don't descent into elements where we need to preserve whitespaces // but still visit all attributes to eliminate one used as a market to preserve WS return new Element(element.name, visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan); } return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan); }; /** * @param {?} attribute * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null; }; /** * @param {?} text * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { var /** @type {?} */ isNotBlank = text.value.match(NO_WS_REGEXP); if (isNotBlank) { return new Text(replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan); } return null; }; /** * @param {?} comment * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { return comment; }; /** * @param {?} expansion * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitExpansion = /** * @param {?} expansion * @param {?} context * @return {?} */ function (expansion, context) { return expansion; }; /** * @param {?} expansionCase * @param {?} context * @return {?} */ WhitespaceVisitor.prototype.visitExpansionCase = /** * @param {?} expansionCase * @param {?} context * @return {?} */ function (expansionCase, context) { return expansionCase; }; return WhitespaceVisitor; }()); /** * @param {?} htmlAstWithErrors * @return {?} */ function removeWhitespaces(htmlAstWithErrors) { return new ParseTreeResult(visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors); } /** * @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://cldr.unicode.org/index/cldr-spec/plural-rules var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other']; /** * Expands special forms into elements. * * For example, * * ``` * { messages.length, plural, * =0 {zero} * =1 {one} * other {more than one} * } * ``` * * will be expanded into * * ``` * * zero * one * more than one * * ``` * @param {?} nodes * @return {?} */ function expandNodes(nodes) { var /** @type {?} */ expander = new _Expander(); return new ExpansionResult(visitAll(expander, nodes), expander.isExpanded, expander.errors); } var ExpansionResult = /** @class */ (function () { function ExpansionResult(nodes, expanded, errors) { this.nodes = nodes; this.expanded = expanded; this.errors = errors; } return ExpansionResult; }()); var ExpansionError = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(ExpansionError, _super); function ExpansionError(span, errorMsg) { return _super.call(this, span, errorMsg) || this; } return ExpansionError; }(ParseError)); /** * Expand expansion forms (plural, select) to directives * * \@internal */ var _Expander = /** @class */ (function () { function _Expander() { this.isExpanded = false; this.errors = []; } /** * @param {?} element * @param {?} context * @return {?} */ _Expander.prototype.visitElement = /** * @param {?} element * @param {?} context * @return {?} */ function (element, context) { return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan); }; /** * @param {?} attribute * @param {?} context * @return {?} */ _Expander.prototype.visitAttribute = /** * @param {?} attribute * @param {?} context * @return {?} */ function (attribute, context) { return attribute; }; /** * @param {?} text * @param {?} context * @return {?} */ _Expander.prototype.visitText = /** * @param {?} text * @param {?} context * @return {?} */ function (text, context) { return text; }; /** * @param {?} comment * @param {?} context * @return {?} */ _Expander.prototype.visitComment = /** * @param {?} comment * @param {?} context * @return {?} */ function (comment, context) { return comment; }; /** * @param {?} icu * @param {?} context * @return {?} */ _Expander.prototype.visitExpansion = /** * @param {?} icu * @param {?} context * @return {?} */ function (icu, context) { this.isExpanded = true; return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) : _expandDefaultForm(icu, this.errors); }; /** * @param {?} icuCase * @param {?} context * @return {?} */ _Expander.prototype.visitExpansionCase = /** * @param {?} icuCase * @param {?} context * @return {?} */ function (icuCase, context) { throw new Error('Should not be reached'); }; return _Expander; }()); /** * @param {?} ast * @param {?} errors * @return {?} */ function _expandPluralForm(ast, errors) { var /** @type {?} */ children = ast.cases.map(function (c) { if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) { errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=\" or one of " + PLURAL_CASES.join(", "))); } var /** @type {?} */ expansionResult = expandNodes(c.expression); errors.push.apply(errors, expansionResult.errors); return new Element("ng-template", [new Attribute$1('ngPluralCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan); }); var /** @type {?} */ switchAttr = new Attribute$1('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan); return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan); } /** * @param {?} ast * @param {?} errors * @return {?} */ function _expandDefaultForm(ast, errors) { var /** @type {?} */ children = ast.cases.map(function (c) { var /** @type {?} */ expansionResult = expandNodes(c.expression); errors.push.apply(errors, expansionResult.errors); if (c.value === 'other') { // other is the default case when no values match return new Element("ng-template", [new Attribute$1('ngSwitchDefault', '', c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan); } return new Element("ng-template", [new Attribute$1('ngSwitchCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan); }); var /** @type {?} */ switchAttr = new Attribute$1('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan); return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan); } /** * @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 PROPERTY_PARTS_SEPARATOR = '.'; var ATTRIBUTE_PREFIX = 'attr'; var CLASS_PREFIX = 'class'; var STYLE_PREFIX = 'style'; var ANIMATE_PROP_PREFIX = 'animate-'; /** @enum {number} */ var BoundPropertyType = { DEFAULT: 0, LITERAL_ATTR: 1, ANIMATION: 2, }; BoundPropertyType[BoundPropertyType.DEFAULT] = "DEFAULT"; BoundPropertyType[BoundPropertyType.LITERAL_ATTR] = "LITERAL_ATTR"; BoundPropertyType[BoundPropertyType.ANIMATION] = "ANIMATION"; /** * Represents a parsed property. */ var BoundProperty = /** @class */ (function () { function BoundProperty(name, expression, type, sourceSpan) { this.name = name; this.expression = expression; this.type = type; this.sourceSpan = sourceSpan; this.isLiteral = this.type === BoundPropertyType.LITERAL_ATTR; this.isAnimation = this.type === BoundPropertyType.ANIMATION; } return BoundProperty; }()); /** * Parses bindings in templates and in the directive host area. */ var BindingParser = /** @class */ (function () { function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, _targetErrors) { var _this = this; this._exprParser = _exprParser; this._interpolationConfig = _interpolationConfig; this._schemaRegistry = _schemaRegistry; this._targetErrors = _targetErrors; this.pipesByName = new Map(); this._usedPipes = new Map(); pipes.forEach(function (pipe) { return _this.pipesByName.set(pipe.name, pipe); }); } /** * @return {?} */ BindingParser.prototype.getUsedPipes = /** * @return {?} */ function () { return Array.from(this._usedPipes.values()); }; /** * @param {?} dirMeta * @param {?} elementSelector * @param {?} sourceSpan * @return {?} */ BindingParser.prototype.createDirectiveHostPropertyAsts = /** * @param {?} dirMeta * @param {?} elementSelector * @param {?} sourceSpan * @return {?} */ function (dirMeta, elementSelector, sourceSpan) { var _this = this; if (dirMeta.hostProperties) { var /** @type {?} */ boundProps_1 = []; Object.keys(dirMeta.hostProperties).forEach(function (propName) { var /** @type {?} */ expression = dirMeta.hostProperties[propName]; if (typeof expression === 'string') { _this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1); } else { _this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan); } }); return boundProps_1.map(function (prop) { return _this.createElementPropertyAst(elementSelector, prop); }); } return null; }; /** * @param {?} dirMeta * @param {?} sourceSpan * @return {?} */ BindingParser.prototype.createDirectiveHostEventAsts = /** * @param {?} dirMeta * @param {?} sourceSpan * @return {?} */ function (dirMeta, sourceSpan) { var _this = this; if (dirMeta.hostListeners) { var /** @type {?} */ targetEventAsts_1 = []; Object.keys(dirMeta.hostListeners).forEach(function (propName) { var /** @type {?} */ expression = dirMeta.hostListeners[propName]; if (typeof expression === 'string') { _this.parseEvent(propName, expression, sourceSpan, [], targetEventAsts_1); } else { _this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan); } }); return targetEventAsts_1; } return null; }; /** * @param {?} value * @param {?} sourceSpan * @return {?} */ BindingParser.prototype.parseInterpolation = /** * @param {?} value * @param {?} sourceSpan * @return {?} */ function (value, sourceSpan) { var /** @type {?} */ sourceInfo = sourceSpan.start.toString(); try { var /** @type {?} */ ast = /** @type {?} */ ((this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig))); if (ast) this._reportExpressionParserErrors(ast.errors, sourceSpan); this._checkPipes(ast, sourceSpan); return ast; } catch (/** @type {?} */ e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; /** * @param {?} prefixToken * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @param {?} targetVars * @return {?} */ BindingParser.prototype.parseInlineTemplateBinding = /** * @param {?} prefixToken * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @param {?} targetVars * @return {?} */ function (prefixToken, value, sourceSpan, targetMatchableAttrs, targetProps, targetVars) { var /** @type {?} */ bindings = this._parseTemplateBindings(prefixToken, value, sourceSpan); for (var /** @type {?} */ i = 0; i < bindings.length; i++) { var /** @type {?} */ binding = bindings[i]; if (binding.keyIsVar) { targetVars.push(new VariableAst(binding.key, binding.name, sourceSpan)); } else if (binding.expression) { this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps); } else { targetMatchableAttrs.push([binding.key, '']); this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps); } } }; /** * @param {?} prefixToken * @param {?} value * @param {?} sourceSpan * @return {?} */ BindingParser.prototype._parseTemplateBindings = /** * @param {?} prefixToken * @param {?} value * @param {?} sourceSpan * @return {?} */ function (prefixToken, value, sourceSpan) { var _this = this; var /** @type {?} */ sourceInfo = sourceSpan.start.toString(); try { var /** @type {?} */ bindingsResult = this._exprParser.parseTemplateBindings(prefixToken, value, sourceInfo); this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan); bindingsResult.templateBindings.forEach(function (binding) { if (binding.expression) { _this._checkPipes(binding.expression, sourceSpan); } }); bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); }); return bindingsResult.templateBindings; } catch (/** @type {?} */ e) { this._reportError("" + e, sourceSpan); return []; } }; /** * @param {?} name * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ BindingParser.prototype.parseLiteralAttr = /** * @param {?} name * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ function (name, value, sourceSpan, targetMatchableAttrs, targetProps) { if (_isAnimationLabel(name)) { name = name.substring(1); if (value) { this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." + " Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR); } this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps); } else { targetProps.push(new BoundProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), BoundPropertyType.LITERAL_ATTR, sourceSpan)); } }; /** * @param {?} name * @param {?} expression * @param {?} isHost * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ BindingParser.prototype.parsePropertyBinding = /** * @param {?} name * @param {?} expression * @param {?} isHost * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) { var /** @type {?} */ isAnimationProp = false; if (name.startsWith(ANIMATE_PROP_PREFIX)) { isAnimationProp = true; name = name.substring(ANIMATE_PROP_PREFIX.length); } else if (_isAnimationLabel(name)) { isAnimationProp = true; name = name.substring(1); } if (isAnimationProp) { this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps); } else { this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps); } }; /** * @param {?} name * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ BindingParser.prototype.parsePropertyInterpolation = /** * @param {?} name * @param {?} value * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ function (name, value, sourceSpan, targetMatchableAttrs, targetProps) { var /** @type {?} */ expr = this.parseInterpolation(value, sourceSpan); if (expr) { this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps); return true; } return false; }; /** * @param {?} name * @param {?} ast * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ BindingParser.prototype._parsePropertyAst = /** * @param {?} name * @param {?} ast * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) { targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]); targetProps.push(new BoundProperty(name, ast, BoundPropertyType.DEFAULT, sourceSpan)); }; /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ BindingParser.prototype._parseAnimation = /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetProps * @return {?} */ function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) { // This will occur when a @trigger is not paired with an expression. // For animations it is valid to not have an expression since */void // states will be applied by angular when the element is attached/detached var /** @type {?} */ ast = this._parseBinding(expression || 'undefined', false, sourceSpan); targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]); targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan)); }; /** * @param {?} value * @param {?} isHostBinding * @param {?} sourceSpan * @return {?} */ BindingParser.prototype._parseBinding = /** * @param {?} value * @param {?} isHostBinding * @param {?} sourceSpan * @return {?} */ function (value, isHostBinding, sourceSpan) { var /** @type {?} */ sourceInfo = sourceSpan.start.toString(); try { var /** @type {?} */ ast = isHostBinding ? this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) : this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig); if (ast) this._reportExpressionParserErrors(ast.errors, sourceSpan); this._checkPipes(ast, sourceSpan); return ast; } catch (/** @type {?} */ e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; /** * @param {?} elementSelector * @param {?} boundProp * @return {?} */ BindingParser.prototype.createElementPropertyAst = /** * @param {?} elementSelector * @param {?} boundProp * @return {?} */ function (elementSelector, boundProp) { if (boundProp.isAnimation) { return new BoundElementPropertyAst(boundProp.name, PropertyBindingType.Animation, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan); } var /** @type {?} */ unit = null; var /** @type {?} */ bindingType = /** @type {?} */ ((undefined)); var /** @type {?} */ boundPropertyName = null; var /** @type {?} */ parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR); var /** @type {?} */ securityContexts = /** @type {?} */ ((undefined)); // Check check for special cases (prefix style, attr, class) if (parts.length > 1) { if (parts[0] == ATTRIBUTE_PREFIX) { boundPropertyName = parts[1]; this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true); securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true); var /** @type {?} */ nsSeparatorIdx = boundPropertyName.indexOf(':'); if (nsSeparatorIdx > -1) { var /** @type {?} */ ns = boundPropertyName.substring(0, nsSeparatorIdx); var /** @type {?} */ name_1 = boundPropertyName.substring(nsSeparatorIdx + 1); boundPropertyName = mergeNsAndName(ns, name_1); } bindingType = PropertyBindingType.Attribute; } else if (parts[0] == CLASS_PREFIX) { boundPropertyName = parts[1]; bindingType = PropertyBindingType.Class; securityContexts = [SecurityContext.NONE]; } else if (parts[0] == STYLE_PREFIX) { unit = parts.length > 2 ? parts[2] : null; boundPropertyName = parts[1]; bindingType = PropertyBindingType.Style; securityContexts = [SecurityContext.STYLE]; } } // If not a special case, use the full property name if (boundPropertyName === null) { boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name); securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false); bindingType = PropertyBindingType.Property; this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false); } return new BoundElementPropertyAst(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan); }; /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetEvents * @return {?} */ BindingParser.prototype.parseEvent = /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetEvents * @return {?} */ function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) { if (_isAnimationLabel(name)) { name = name.substr(1); this._parseAnimationEvent(name, expression, sourceSpan, targetEvents); } else { this._parseEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents); } }; /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetEvents * @return {?} */ BindingParser.prototype._parseAnimationEvent = /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetEvents * @return {?} */ function (name, expression, sourceSpan, targetEvents) { var /** @type {?} */ matches = splitAtPeriod(name, [name, '']); var /** @type {?} */ eventName = matches[0]; var /** @type {?} */ phase = matches[1].toLowerCase(); if (phase) { switch (phase) { case 'start': case 'done': var /** @type {?} */ ast = this._parseAction(expression, sourceSpan); targetEvents.push(new BoundEventAst(eventName, null, phase, ast, sourceSpan)); break; default: this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan); break; } } else { this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan); } }; /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetEvents * @return {?} */ BindingParser.prototype._parseEvent = /** * @param {?} name * @param {?} expression * @param {?} sourceSpan * @param {?} targetMatchableAttrs * @param {?} targetEvents * @return {?} */ function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) { // long format: 'target: eventName' var _a = splitAtColon(name, [/** @type {?} */ ((null)), name]), target = _a[0], eventName = _a[1]; var /** @type {?} */ ast = this._parseAction(expression, sourceSpan); targetMatchableAttrs.push([/** @type {?} */ ((name)), /** @type {?} */ ((ast.source))]); targetEvents.push(new BoundEventAst(eventName, target, null, ast, sourceSpan)); // Don't detect directives for event names for now, // so don't add the event name to the matchableAttrs }; /** * @param {?} value * @param {?} sourceSpan * @return {?} */ BindingParser.prototype._parseAction = /** * @param {?} value * @param {?} sourceSpan * @return {?} */ function (value, sourceSpan) { var /** @type {?} */ sourceInfo = sourceSpan.start.toString(); try { var /** @type {?} */ ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig); if (ast) { this._reportExpressionParserErrors(ast.errors, sourceSpan); } if (!ast || ast.ast instanceof EmptyExpr) { this._reportError("Empty expressions are not allowed", sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } this._checkPipes(ast, sourceSpan); return ast; } catch (/** @type {?} */ e) { this._reportError("" + e, sourceSpan); return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo); } }; /** * @param {?} message * @param {?} sourceSpan * @param {?=} level * @return {?} */ BindingParser.prototype._reportError = /** * @param {?} message * @param {?} sourceSpan * @param {?=} level * @return {?} */ function (message, sourceSpan, level) { if (level === void 0) { level = ParseErrorLevel.ERROR; } this._targetErrors.push(new ParseError(sourceSpan, message, level)); }; /** * @param {?} errors * @param {?} sourceSpan * @return {?} */ BindingParser.prototype._reportExpressionParserErrors = /** * @param {?} errors * @param {?} sourceSpan * @return {?} */ function (errors, sourceSpan) { for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) { var error = errors_1[_i]; this._reportError(error.message, sourceSpan); } }; /** * @param {?} ast * @param {?} sourceSpan * @return {?} */ BindingParser.prototype._checkPipes = /** * @param {?} ast * @param {?} sourceSpan * @return {?} */ function (ast, sourceSpan) { var _this = this; if (ast) { var /** @type {?} */ collector = new PipeCollector(); ast.visit(collector); collector.pipes.forEach(function (ast, pipeName) { var /** @type {?} */ pipeMeta = _this.pipesByName.get(pipeName); if (!pipeMeta) { _this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end))); } else { _this._usedPipes.set(pipeName, pipeMeta); } }); } }; /** * @param {?} propName the name of the property / attribute * @param {?} sourceSpan * @param {?} isAttr true when binding to an attribute * @return {?} */ BindingParser.prototype._validatePropertyOrAttributeName = /** * @param {?} propName the name of the property / attribute * @param {?} sourceSpan * @param {?} isAttr true when binding to an attribute * @return {?} */ function (propName, sourceSpan, isAttr) { var /** @type {?} */ report = isAttr ? this._schemaRegistry.validateAttribute(propName) : this._schemaRegistry.validateProperty(propName); if (report.error) { this._reportError(/** @type {?} */ ((report.msg)), sourceSpan, ParseErrorLevel.ERROR); } }; return BindingParser; }()); var PipeCollector = /** @class */ (function (_super) { Object(__WEBPACK_IMPORTED_MODULE_0_tslib__["b" /* __extends */])(PipeCollector, _super); function PipeCollector() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.pipes = new Map(); return _this; } /** * @param {?} ast * @param {?} context * @return {?} */ PipeCollector.prototype.visitPipe = /** * @param {?} ast * @param {?} context * @return {?} */ function (ast, context) { this.pipes.set(ast.name, ast); ast.exp.visit(this); this.visitAll(ast.args, context); return null; }; return PipeCollector; }(RecursiveAstVisitor)); /** * @param {?} name * @return {?} */ function _isAnimationLabel(name) { return name[0] == '@'; } /** * @param {?} registry * @param {?} selector * @param {?} propName * @param {?} isAttribute * @return {?} */ function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) { var /** @type {?} */ ctxs = []; CssSelector.parse(selector).forEach(function (selector) { var /** @type {?} */ elementNames = selector.element ? [selector.element] : registry.allKnownElementNames(); var /** @type {?} */ notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); }) .map(function (selector) { return selector.element; })); var /** @type {?} */ possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); }); ctxs.push.apply(ctxs, possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); })); }); return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort(); } /** * @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 BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/; // Group 1 = "bind-" var KW_BIND_IDX = 1; // Group 2 = "let-" var KW_LET_IDX = 2; // Group 3 = "ref-/#" var KW_REF_IDX = 3; // Group 4 = "on-" var KW_ON_IDX = 4; // Group 5 = "bindon-" var KW_BINDON_IDX = 5; // Group 6 = "@" var KW_AT_IDX = 6; // Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@" var IDENT_KW_IDX = 7; // Group 8 = identifier inside [()] var IDENT_BANANA_BOX_IDX = 8; // Group 9 = identifier inside [] var IDENT_PROPERTY_IDX = 9; // Group 10 = identifier inside () var IDENT_EVENT_IDX = 10; // deprecated in 4.x var TEMPLATE_ELEMENT = 'template'; // deprecated in 4.x var TEMPLATE_ATTR = 'template'; var TEMPLATE_ATTR_PREFIX = '*'; var CLASS_ATTR = 'class'; var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0]; var TEMPLATE_ELEMENT_DEPRECATION_WARNING = 'The