UNPKG

465 kBJavaScriptView Raw
1/**
2 * @license Angular v4.1.1
3 * (c) 2010-2017 Google, Inc. https://angular.io/
4 * License: MIT
5 */
6(function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs/Observable'), require('rxjs/observable/merge'), require('rxjs/operator/share'), require('rxjs/Subject')) :
8 typeof define === 'function' && define.amd ? define(['exports', 'rxjs/Observable', 'rxjs/observable/merge', 'rxjs/operator/share', 'rxjs/Subject'], factory) :
9 (factory((global.ng = global.ng || {}, global.ng.core = global.ng.core || {}),global.Rx,global.Rx.Observable,global.Rx.Observable.prototype,global.Rx));
10}(this, (function (exports,rxjs_Observable,rxjs_observable_merge,rxjs_operator_share,rxjs_Subject) { 'use strict';
11
12var __extends = (undefined && undefined.__extends) || function (d, b) {
13 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
14 function __() { this.constructor = d; }
15 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16};
17/**
18 * @license Angular v4.1.1
19 * (c) 2010-2017 Google, Inc. https://angular.io/
20 * License: MIT
21 */
22/**
23 * Creates a token that can be used in a DI Provider.
24 *
25 * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
26 *
27 * ```typescript
28 * var t = new OpaqueToken("value");
29 *
30 * var injector = Injector.resolveAndCreate([
31 * {provide: t, useValue: "bindingValue"}
32 * ]);
33 *
34 * expect(injector.get(t)).toEqual("bindingValue");
35 * ```
36 *
37 * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
38 * caused by multiple providers using the same string as two different tokens.
39 *
40 * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
41 * error messages.
42 * @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>`
43 * instead.
44 */
45var OpaqueToken = (function () {
46 /**
47 * @param {?} _desc
48 */
49 function OpaqueToken(_desc) {
50 this._desc = _desc;
51 }
52 /**
53 * @return {?}
54 */
55 OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
56 return OpaqueToken;
57}());
58/**
59 * Creates a token that can be used in a DI Provider.
60 *
61 * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
62 * runtime representation) such as when injecting an interface, callable type, array or
63 * parametrized type.
64 *
65 * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
66 * the `Injector`. This provides additional level of type safety.
67 *
68 * ```
69 * interface MyInterface {...}
70 * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
71 * // myInterface is inferred to be MyInterface.
72 * ```
73 *
74 * ### Example
75 *
76 * {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
77 *
78 * \@stable
79 */
80var InjectionToken = (function (_super) {
81 __extends(InjectionToken, _super);
82 /**
83 * @param {?} desc
84 */
85 function InjectionToken(desc) {
86 return _super.call(this, desc) || this;
87 }
88 /**
89 * @return {?}
90 */
91 InjectionToken.prototype.toString = function () { return "InjectionToken " + this._desc; };
92 return InjectionToken;
93}(OpaqueToken));
94/**
95 * @license
96 * Copyright Google Inc. All Rights Reserved.
97 *
98 * Use of this source code is governed by an MIT-style license that can be
99 * found in the LICENSE file at https://angular.io/license
100 */
101var __window = typeof window !== 'undefined' && window;
102var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
103 self instanceof WorkerGlobalScope && self;
104var __global = typeof global !== 'undefined' && global;
105var _global = __window || __global || __self;
106var _symbolIterator = null;
107/**
108 * @return {?}
109 */
110function getSymbolIterator() {
111 if (!_symbolIterator) {
112 var /** @type {?} */ Symbol = _global['Symbol'];
113 if (Symbol && Symbol.iterator) {
114 _symbolIterator = Symbol.iterator;
115 }
116 else {
117 // es6-shim specific logic
118 var /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
119 for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
120 var /** @type {?} */ key = keys[i];
121 if (key !== 'entries' && key !== 'size' &&
122 ((Map)).prototype[key] === Map.prototype['entries']) {
123 _symbolIterator = key;
124 }
125 }
126 }
127 }
128 return _symbolIterator;
129}
130/**
131 * @param {?} fn
132 * @return {?}
133 */
134function scheduleMicroTask(fn) {
135 Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
136}
137/**
138 * @param {?} a
139 * @param {?} b
140 * @return {?}
141 */
142function looseIdentical(a, b) {
143 return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
144}
145/**
146 * @param {?} token
147 * @return {?}
148 */
149function stringify(token) {
150 if (typeof token === 'string') {
151 return token;
152 }
153 if (token == null) {
154 return '' + token;
155 }
156 if (token.overriddenName) {
157 return "" + token.overriddenName;
158 }
159 if (token.name) {
160 return "" + token.name;
161 }
162 var /** @type {?} */ res = token.toString();
163 if (res == null) {
164 return '' + res;
165 }
166 var /** @type {?} */ newLineIndex = res.indexOf('\n');
167 return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
168}
169/**
170 * @license
171 * Copyright Google Inc. All Rights Reserved.
172 *
173 * Use of this source code is governed by an MIT-style license that can be
174 * found in the LICENSE file at https://angular.io/license
175 */
176var _nextClassId = 0;
177var Reflect = _global['Reflect'];
178/**
179 * @param {?} annotation
180 * @return {?}
181 */
182function extractAnnotation(annotation) {
183 if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
184 // it is a decorator, extract annotation
185 annotation = annotation.annotation;
186 }
187 return annotation;
188}
189/**
190 * @param {?} fnOrArray
191 * @param {?} key
192 * @return {?}
193 */
194function applyParams(fnOrArray, key) {
195 if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
196 fnOrArray === Number || fnOrArray === Array) {
197 throw new Error("Can not use native " + stringify(fnOrArray) + " as constructor");
198 }
199 if (typeof fnOrArray === 'function') {
200 return fnOrArray;
201 }
202 if (Array.isArray(fnOrArray)) {
203 var /** @type {?} */ annotations = (fnOrArray);
204 var /** @type {?} */ annoLength = annotations.length - 1;
205 var /** @type {?} */ fn = fnOrArray[annoLength];
206 if (typeof fn !== 'function') {
207 throw new Error("Last position of Class method array must be Function in key " + key + " was '" + stringify(fn) + "'");
208 }
209 if (annoLength != fn.length) {
210 throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + stringify(fn));
211 }
212 var /** @type {?} */ paramsAnnotations = [];
213 for (var /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
214 var /** @type {?} */ paramAnnotations = [];
215 paramsAnnotations.push(paramAnnotations);
216 var /** @type {?} */ annotation = annotations[i];
217 if (Array.isArray(annotation)) {
218 for (var /** @type {?} */ j = 0; j < annotation.length; j++) {
219 paramAnnotations.push(extractAnnotation(annotation[j]));
220 }
221 }
222 else if (typeof annotation === 'function') {
223 paramAnnotations.push(extractAnnotation(annotation));
224 }
225 else {
226 paramAnnotations.push(annotation);
227 }
228 }
229 Reflect.defineMetadata('parameters', paramsAnnotations, fn);
230 return fn;
231 }
232 throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + stringify(fnOrArray) + "'");
233}
234/**
235 * Provides a way for expressing ES6 classes with parameter annotations in ES5.
236 *
237 * ## Basic Example
238 *
239 * ```
240 * var Greeter = ng.Class({
241 * constructor: function(name) {
242 * this.name = name;
243 * },
244 *
245 * greet: function() {
246 * alert('Hello ' + this.name + '!');
247 * }
248 * });
249 * ```
250 *
251 * is equivalent to ES6:
252 *
253 * ```
254 * class Greeter {
255 * constructor(name) {
256 * this.name = name;
257 * }
258 *
259 * greet() {
260 * alert('Hello ' + this.name + '!');
261 * }
262 * }
263 * ```
264 *
265 * or equivalent to ES5:
266 *
267 * ```
268 * var Greeter = function (name) {
269 * this.name = name;
270 * }
271 *
272 * Greeter.prototype.greet = function () {
273 * alert('Hello ' + this.name + '!');
274 * }
275 * ```
276 *
277 * ### Example with parameter annotations
278 *
279 * ```
280 * var MyService = ng.Class({
281 * constructor: [String, [new Optional(), Service], function(name, myService) {
282 * ...
283 * }]
284 * });
285 * ```
286 *
287 * is equivalent to ES6:
288 *
289 * ```
290 * class MyService {
291 * constructor(name: string, \@Optional() myService: Service) {
292 * ...
293 * }
294 * }
295 * ```
296 *
297 * ### Example with inheritance
298 *
299 * ```
300 * var Shape = ng.Class({
301 * constructor: (color) {
302 * this.color = color;
303 * }
304 * });
305 *
306 * var Square = ng.Class({
307 * extends: Shape,
308 * constructor: function(color, size) {
309 * Shape.call(this, color);
310 * this.size = size;
311 * }
312 * });
313 * ```
314 * @suppress {globalThis}
315 * \@stable
316 * @param {?} clsDef
317 * @return {?}
318 */
319function Class(clsDef) {
320 var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
321 var /** @type {?} */ proto = constructor.prototype;
322 if (clsDef.hasOwnProperty('extends')) {
323 if (typeof clsDef.extends === 'function') {
324 ((constructor)).prototype = proto =
325 Object.create(((clsDef.extends)).prototype);
326 }
327 else {
328 throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
329 }
330 }
331 for (var /** @type {?} */ key in clsDef) {
332 if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
333 proto[key] = applyParams(clsDef[key], key);
334 }
335 }
336 if (this && this.annotations instanceof Array) {
337 Reflect.defineMetadata('annotations', this.annotations, constructor);
338 }
339 var /** @type {?} */ constructorName = constructor['name'];
340 if (!constructorName || constructorName === 'constructor') {
341 ((constructor))['overriddenName'] = "class" + _nextClassId++;
342 }
343 return (constructor);
344}
345/**
346 * @suppress {globalThis}
347 * @param {?} name
348 * @param {?} props
349 * @param {?=} parentClass
350 * @param {?=} chainFn
351 * @return {?}
352 */
353function makeDecorator(name, props, parentClass, chainFn) {
354 var /** @type {?} */ metaCtor = makeMetadataCtor([props]);
355 /**
356 * @param {?} objOrType
357 * @return {?}
358 */
359 function DecoratorFactory(objOrType) {
360 if (!(Reflect && Reflect.getOwnMetadata)) {
361 throw 'reflect-metadata shim is required when using class decorators';
362 }
363 if (this instanceof DecoratorFactory) {
364 metaCtor.call(this, objOrType);
365 return this;
366 }
367 var /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
368 var /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
369 chainAnnotation.push(annotationInstance);
370 var /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
371 var /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
372 annotations.push(annotationInstance);
373 Reflect.defineMetadata('annotations', annotations, cls);
374 return cls;
375 });
376 TypeDecorator.annotations = chainAnnotation;
377 TypeDecorator.Class = Class;
378 if (chainFn)
379 chainFn(TypeDecorator);
380 return TypeDecorator;
381 }
382 if (parentClass) {
383 DecoratorFactory.prototype = Object.create(parentClass.prototype);
384 }
385 DecoratorFactory.prototype.toString = function () { return "@" + name; };
386 ((DecoratorFactory)).annotationCls = DecoratorFactory;
387 return DecoratorFactory;
388}
389/**
390 * @param {?} props
391 * @return {?}
392 */
393function makeMetadataCtor(props) {
394 return function ctor() {
395 var _this = this;
396 var args = [];
397 for (var _i = 0; _i < arguments.length; _i++) {
398 args[_i] = arguments[_i];
399 }
400 props.forEach(function (prop, i) {
401 var /** @type {?} */ argVal = args[i];
402 if (Array.isArray(prop)) {
403 // plain parameter
404 _this[prop[0]] = argVal === undefined ? prop[1] : argVal;
405 }
406 else {
407 for (var /** @type {?} */ propName in prop) {
408 _this[propName] =
409 argVal && argVal.hasOwnProperty(propName) ? argVal[propName] : prop[propName];
410 }
411 }
412 });
413 };
414}
415/**
416 * @param {?} name
417 * @param {?} props
418 * @param {?=} parentClass
419 * @return {?}
420 */
421function makeParamDecorator(name, props, parentClass) {
422 var /** @type {?} */ metaCtor = makeMetadataCtor(props);
423 /**
424 * @param {...?} args
425 * @return {?}
426 */
427 function ParamDecoratorFactory() {
428 var args = [];
429 for (var _i = 0; _i < arguments.length; _i++) {
430 args[_i] = arguments[_i];
431 }
432 if (this instanceof ParamDecoratorFactory) {
433 metaCtor.apply(this, args);
434 return this;
435 }
436 var /** @type {?} */ annotationInstance = new (((ParamDecoratorFactory)).bind.apply(((ParamDecoratorFactory)), [void 0].concat(args)))();
437 ((ParamDecorator)).annotation = annotationInstance;
438 return ParamDecorator;
439 /**
440 * @param {?} cls
441 * @param {?} unusedKey
442 * @param {?} index
443 * @return {?}
444 */
445 function ParamDecorator(cls, unusedKey, index) {
446 var /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
447 // there might be gaps if some in between parameters do not have annotations.
448 // we pad with nulls.
449 while (parameters.length <= index) {
450 parameters.push(null);
451 }
452 parameters[index] = parameters[index] || []; /** @type {?} */
453 ((parameters[index])).push(annotationInstance);
454 Reflect.defineMetadata('parameters', parameters, cls);
455 return cls;
456 }
457 }
458 if (parentClass) {
459 ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
460 }
461 ParamDecoratorFactory.prototype.toString = function () { return "@" + name; };
462 ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
463 return ParamDecoratorFactory;
464}
465/**
466 * @param {?} name
467 * @param {?} props
468 * @param {?=} parentClass
469 * @return {?}
470 */
471function makePropDecorator(name, props, parentClass) {
472 var /** @type {?} */ metaCtor = makeMetadataCtor(props);
473 /**
474 * @param {...?} args
475 * @return {?}
476 */
477 function PropDecoratorFactory() {
478 var args = [];
479 for (var _i = 0; _i < arguments.length; _i++) {
480 args[_i] = arguments[_i];
481 }
482 if (this instanceof PropDecoratorFactory) {
483 metaCtor.apply(this, args);
484 return this;
485 }
486 var /** @type {?} */ decoratorInstance = new (((PropDecoratorFactory)).bind.apply(((PropDecoratorFactory)), [void 0].concat(args)))();
487 return function PropDecorator(target, name) {
488 var /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
489 meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
490 meta[name].unshift(decoratorInstance);
491 Reflect.defineMetadata('propMetadata', meta, target.constructor);
492 };
493 }
494 if (parentClass) {
495 PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
496 }
497 PropDecoratorFactory.prototype.toString = function () { return "@" + name; };
498 ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
499 return PropDecoratorFactory;
500}
501/**
502 * @license
503 * Copyright Google Inc. All Rights Reserved.
504 *
505 * Use of this source code is governed by an MIT-style license that can be
506 * found in the LICENSE file at https://angular.io/license
507 */
508/**
509 * This token can be used to create a virtual provider that will populate the
510 * `entryComponents` fields of components and ng modules based on its `useValue`.
511 * All components that are referenced in the `useValue` value (either directly
512 * or in a nested array or map) will be added to the `entryComponents` property.
513 *
514 * ### Example
515 * The following example shows how the router can populate the `entryComponents`
516 * field of an NgModule based on the router configuration which refers
517 * to components.
518 *
519 * ```typescript
520 * // helper function inside the router
521 * function provideRoutes(routes) {
522 * return [
523 * {provide: ROUTES, useValue: routes},
524 * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
525 * ];
526 * }
527 *
528 * // user code
529 * let routes = [
530 * {path: '/root', component: RootComp},
531 * {path: '/teams', component: TeamsComp}
532 * ];
533 *
534 * \@NgModule({
535 * providers: [provideRoutes(routes)]
536 * })
537 * class ModuleWithRoutes {}
538 * ```
539 *
540 * \@experimental
541 */
542var ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
543/**
544 * Attribute decorator and metadata.
545 *
546 * \@stable
547 * \@Annotation
548 */
549var Attribute = makeParamDecorator('Attribute', [['attributeName', undefined]]);
550/**
551 * Base class for query metadata.
552 *
553 * See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
554 * more information.
555 *
556 * \@stable
557 * @abstract
558 */
559var Query = (function () {
560 function Query() {
561 }
562 return Query;
563}());
564/**
565 * ContentChildren decorator and metadata.
566 *
567 * \@stable
568 * \@Annotation
569 */
570var ContentChildren = makePropDecorator('ContentChildren', [
571 ['selector', undefined], {
572 first: false,
573 isViewQuery: false,
574 descendants: false,
575 read: undefined,
576 }
577], Query);
578/**
579 * ContentChild decorator and metadata.
580 *
581 * \@stable
582 * \@Annotation
583 */
584var ContentChild = makePropDecorator('ContentChild', [
585 ['selector', undefined], {
586 first: true,
587 isViewQuery: false,
588 descendants: true,
589 read: undefined,
590 }
591], Query);
592/**
593 * ViewChildren decorator and metadata.
594 *
595 * \@stable
596 * \@Annotation
597 */
598var ViewChildren = makePropDecorator('ViewChildren', [
599 ['selector', undefined], {
600 first: false,
601 isViewQuery: true,
602 descendants: true,
603 read: undefined,
604 }
605], Query);
606/**
607 * ViewChild decorator and metadata.
608 *
609 * \@stable
610 * \@Annotation
611 */
612var ViewChild = makePropDecorator('ViewChild', [
613 ['selector', undefined], {
614 first: true,
615 isViewQuery: true,
616 descendants: true,
617 read: undefined,
618 }
619], Query);
620var ChangeDetectionStrategy = {};
621ChangeDetectionStrategy.OnPush = 0;
622ChangeDetectionStrategy.Default = 1;
623ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
624ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
625var ChangeDetectorStatus = {};
626ChangeDetectorStatus.CheckOnce = 0;
627ChangeDetectorStatus.Checked = 1;
628ChangeDetectorStatus.CheckAlways = 2;
629ChangeDetectorStatus.Detached = 3;
630ChangeDetectorStatus.Errored = 4;
631ChangeDetectorStatus.Destroyed = 5;
632ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
633ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
634ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
635ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
636ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
637ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
638/**
639 * @param {?} changeDetectionStrategy
640 * @return {?}
641 */
642function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
643 return changeDetectionStrategy == null ||
644 changeDetectionStrategy === ChangeDetectionStrategy.Default;
645}
646/**
647 * @license
648 * Copyright Google Inc. All Rights Reserved.
649 *
650 * Use of this source code is governed by an MIT-style license that can be
651 * found in the LICENSE file at https://angular.io/license
652 */
653/**
654 * Directive decorator and metadata.
655 *
656 * \@stable
657 * \@Annotation
658 */
659var Directive = makeDecorator('Directive', {
660 selector: undefined,
661 inputs: undefined,
662 outputs: undefined,
663 host: undefined,
664 providers: undefined,
665 exportAs: undefined,
666 queries: undefined
667});
668/**
669 * Component decorator and metadata.
670 *
671 * \@stable
672 * \@Annotation
673 */
674var Component = makeDecorator('Component', {
675 selector: undefined,
676 inputs: undefined,
677 outputs: undefined,
678 host: undefined,
679 exportAs: undefined,
680 moduleId: undefined,
681 providers: undefined,
682 viewProviders: undefined,
683 changeDetection: ChangeDetectionStrategy.Default,
684 queries: undefined,
685 templateUrl: undefined,
686 template: undefined,
687 styleUrls: undefined,
688 styles: undefined,
689 animations: undefined,
690 encapsulation: undefined,
691 interpolation: undefined,
692 entryComponents: undefined
693}, Directive);
694/**
695 * Pipe decorator and metadata.
696 *
697 * \@stable
698 * \@Annotation
699 */
700var Pipe = makeDecorator('Pipe', {
701 name: undefined,
702 pure: true,
703});
704/**
705 * Input decorator and metadata.
706 *
707 * \@stable
708 * \@Annotation
709 */
710var Input = makePropDecorator('Input', [['bindingPropertyName', undefined]]);
711/**
712 * Output decorator and metadata.
713 *
714 * \@stable
715 * \@Annotation
716 */
717var Output = makePropDecorator('Output', [['bindingPropertyName', undefined]]);
718/**
719 * HostBinding decorator and metadata.
720 *
721 * \@stable
722 * \@Annotation
723 */
724var HostBinding = makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
725/**
726 * HostListener decorator and metadata.
727 *
728 * \@stable
729 * \@Annotation
730 */
731var HostListener = makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
732/**
733 * @license
734 * Copyright Google Inc. All Rights Reserved.
735 *
736 * Use of this source code is governed by an MIT-style license that can be
737 * found in the LICENSE file at https://angular.io/license
738 */
739/**
740 * Defines a schema that will allow:
741 * - any non-Angular elements with a `-` in their name,
742 * - any properties on elements with a `-` in their name which is the common rule for custom
743 * elements.
744 *
745 * \@stable
746 */
747var CUSTOM_ELEMENTS_SCHEMA = {
748 name: 'custom-elements'
749};
750/**
751 * Defines a schema that will allow any property on any element.
752 *
753 * \@experimental
754 */
755var NO_ERRORS_SCHEMA = {
756 name: 'no-errors-schema'
757};
758/**
759 * NgModule decorator and metadata.
760 *
761 * \@stable
762 * \@Annotation
763 */
764var NgModule = makeDecorator('NgModule', {
765 providers: undefined,
766 declarations: undefined,
767 imports: undefined,
768 exports: undefined,
769 entryComponents: undefined,
770 bootstrap: undefined,
771 schemas: undefined,
772 id: undefined,
773});
774var ViewEncapsulation = {};
775ViewEncapsulation.Emulated = 0;
776ViewEncapsulation.Native = 1;
777ViewEncapsulation.None = 2;
778ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
779ViewEncapsulation[ViewEncapsulation.Native] = "Native";
780ViewEncapsulation[ViewEncapsulation.None] = "None";
781/**
782 * Metadata properties available for configuring Views.
783 *
784 * For details on the `\@Component` annotation, see {\@link Component}.
785 *
786 * ### Example
787 *
788 * ```
789 * \@Component({
790 * selector: 'greet',
791 * template: 'Hello {{name}}!',
792 * })
793 * class Greet {
794 * name: string;
795 *
796 * constructor() {
797 * this.name = 'World';
798 * }
799 * }
800 * ```
801 *
802 * @deprecated Use Component instead.
803 *
804 * {\@link Component}
805 */
806var ViewMetadata = (function () {
807 /**
808 * @param {?=} __0
809 */
810 function ViewMetadata(_a) {
811 var _b = _a === void 0 ? {} : _a, templateUrl = _b.templateUrl, template = _b.template, encapsulation = _b.encapsulation, styles = _b.styles, styleUrls = _b.styleUrls, animations = _b.animations, interpolation = _b.interpolation;
812 this.templateUrl = templateUrl;
813 this.template = template;
814 this.styleUrls = styleUrls;
815 this.styles = styles;
816 this.encapsulation = encapsulation;
817 this.animations = animations;
818 this.interpolation = interpolation;
819 }
820 return ViewMetadata;
821}());
822/**
823 * @license
824 * Copyright Google Inc. All Rights Reserved.
825 *
826 * Use of this source code is governed by an MIT-style license that can be
827 * found in the LICENSE file at https://angular.io/license
828 */
829/**
830 * \@whatItDoes Represents the version of Angular
831 *
832 * \@stable
833 */
834var Version = (function () {
835 /**
836 * @param {?} full
837 */
838 function Version(full) {
839 this.full = full;
840 }
841 Object.defineProperty(Version.prototype, "major", {
842 /**
843 * @return {?}
844 */
845 get: function () { return this.full.split('.')[0]; },
846 enumerable: true,
847 configurable: true
848 });
849 Object.defineProperty(Version.prototype, "minor", {
850 /**
851 * @return {?}
852 */
853 get: function () { return this.full.split('.')[1]; },
854 enumerable: true,
855 configurable: true
856 });
857 Object.defineProperty(Version.prototype, "patch", {
858 /**
859 * @return {?}
860 */
861 get: function () { return this.full.split('.').slice(2).join('.'); },
862 enumerable: true,
863 configurable: true
864 });
865 return Version;
866}());
867/**
868 * \@stable
869 */
870var VERSION = new Version('4.1.1');
871/**
872 * @license
873 * Copyright Google Inc. All Rights Reserved.
874 *
875 * Use of this source code is governed by an MIT-style license that can be
876 * found in the LICENSE file at https://angular.io/license
877 */
878/**
879 * Inject decorator and metadata.
880 *
881 * \@stable
882 * \@Annotation
883 */
884var Inject = makeParamDecorator('Inject', [['token', undefined]]);
885/**
886 * Optional decorator and metadata.
887 *
888 * \@stable
889 * \@Annotation
890 */
891var Optional = makeParamDecorator('Optional', []);
892/**
893 * Injectable decorator and metadata.
894 *
895 * \@stable
896 * \@Annotation
897 */
898var Injectable = makeDecorator('Injectable', []);
899/**
900 * Self decorator and metadata.
901 *
902 * \@stable
903 * \@Annotation
904 */
905var Self = makeParamDecorator('Self', []);
906/**
907 * SkipSelf decorator and metadata.
908 *
909 * \@stable
910 * \@Annotation
911 */
912var SkipSelf = makeParamDecorator('SkipSelf', []);
913/**
914 * Host decorator and metadata.
915 *
916 * \@stable
917 * \@Annotation
918 */
919var Host = makeParamDecorator('Host', []);
920/**
921 * @license
922 * Copyright Google Inc. All Rights Reserved.
923 *
924 * Use of this source code is governed by an MIT-style license that can be
925 * found in the LICENSE file at https://angular.io/license
926 */
927/**
928 * Allows to refer to references which are not yet defined.
929 *
930 * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
931 * DI is declared,
932 * but not yet defined. It is also used when the `token` which we use when creating a query is not
933 * yet defined.
934 *
935 * ### Example
936 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
937 * \@experimental
938 * @param {?} forwardRefFn
939 * @return {?}
940 */
941function forwardRef(forwardRefFn) {
942 ((forwardRefFn)).__forward_ref__ = forwardRef;
943 ((forwardRefFn)).toString = function () { return stringify(this()); };
944 return (((forwardRefFn)));
945}
946/**
947 * Lazily retrieves the reference value from a forwardRef.
948 *
949 * Acts as the identity function when given a non-forward-ref value.
950 *
951 * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
952 *
953 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
954 *
955 * See: {\@link forwardRef}
956 * \@experimental
957 * @param {?} type
958 * @return {?}
959 */
960function resolveForwardRef(type) {
961 if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
962 type.__forward_ref__ === forwardRef) {
963 return ((type))();
964 }
965 else {
966 return type;
967 }
968}
969/**
970 * @license
971 * Copyright Google Inc. All Rights Reserved.
972 *
973 * Use of this source code is governed by an MIT-style license that can be
974 * found in the LICENSE file at https://angular.io/license
975 */
976var _THROW_IF_NOT_FOUND = new Object();
977var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
978var _NullInjector = (function () {
979 function _NullInjector() {
980 }
981 /**
982 * @param {?} token
983 * @param {?=} notFoundValue
984 * @return {?}
985 */
986 _NullInjector.prototype.get = function (token, notFoundValue) {
987 if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
988 if (notFoundValue === _THROW_IF_NOT_FOUND) {
989 throw new Error("No provider for " + stringify(token) + "!");
990 }
991 return notFoundValue;
992 };
993 return _NullInjector;
994}());
995/**
996 * \@whatItDoes Injector interface
997 * \@howToUse
998 * ```
999 * const injector: Injector = ...;
1000 * injector.get(...);
1001 * ```
1002 *
1003 * \@description
1004 * For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
1005 *
1006 * ### Example
1007 *
1008 * {\@example core/di/ts/injector_spec.ts region='Injector'}
1009 *
1010 * `Injector` returns itself when given `Injector` as a token:
1011 * {\@example core/di/ts/injector_spec.ts region='injectInjector'}
1012 *
1013 * \@stable
1014 * @abstract
1015 */
1016var Injector = (function () {
1017 function Injector() {
1018 }
1019 /**
1020 * Retrieves an instance from the injector based on the provided token.
1021 * If not found:
1022 * - Throws an error if no `notFoundValue` that is not equal to
1023 * Injector.THROW_IF_NOT_FOUND is given
1024 * - Returns the `notFoundValue` otherwise
1025 * @abstract
1026 * @template T
1027 * @param {?} token
1028 * @param {?=} notFoundValue
1029 * @return {?}
1030 */
1031 Injector.prototype.get = function (token, notFoundValue) { };
1032 /**
1033 * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
1034 * @suppress {duplicate}
1035 * @abstract
1036 * @param {?} token
1037 * @param {?=} notFoundValue
1038 * @return {?}
1039 */
1040 Injector.prototype.get = function (token, notFoundValue) { };
1041 return Injector;
1042}());
1043Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
1044Injector.NULL = new _NullInjector();
1045/**
1046 * @license
1047 * Copyright Google Inc. All Rights Reserved.
1048 *
1049 * Use of this source code is governed by an MIT-style license that can be
1050 * found in the LICENSE file at https://angular.io/license
1051 */
1052var ERROR_COMPONENT_TYPE = 'ngComponentType';
1053var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
1054var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
1055var ERROR_LOGGER = 'ngErrorLogger';
1056/**
1057 * @param {?} error
1058 * @return {?}
1059 */
1060/**
1061 * @param {?} error
1062 * @return {?}
1063 */
1064function getDebugContext(error) {
1065 return ((error))[ERROR_DEBUG_CONTEXT];
1066}
1067/**
1068 * @param {?} error
1069 * @return {?}
1070 */
1071function getOriginalError(error) {
1072 return ((error))[ERROR_ORIGINAL_ERROR];
1073}
1074/**
1075 * @param {?} error
1076 * @return {?}
1077 */
1078function getErrorLogger(error) {
1079 return ((error))[ERROR_LOGGER] || defaultErrorLogger;
1080}
1081/**
1082 * @param {?} console
1083 * @param {...?} values
1084 * @return {?}
1085 */
1086function defaultErrorLogger(console) {
1087 var values = [];
1088 for (var _i = 1; _i < arguments.length; _i++) {
1089 values[_i - 1] = arguments[_i];
1090 }
1091 console.error.apply(console, values);
1092}
1093/**
1094 * @license
1095 * Copyright Google Inc. All Rights Reserved.
1096 *
1097 * Use of this source code is governed by an MIT-style license that can be
1098 * found in the LICENSE file at https://angular.io/license
1099 */
1100/**
1101 * \@whatItDoes Provides a hook for centralized exception handling.
1102 *
1103 * \@description
1104 *
1105 * The default implementation of `ErrorHandler` prints error messages to the `console`. To
1106 * intercept error handling, write a custom exception handler that replaces this default as
1107 * appropriate for your app.
1108 *
1109 * ### Example
1110 *
1111 * ```
1112 * class MyErrorHandler implements ErrorHandler {
1113 * handleError(error) {
1114 * // do something with the exception
1115 * }
1116 * }
1117 *
1118 * \@NgModule({
1119 * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
1120 * })
1121 * class MyModule {}
1122 * ```
1123 *
1124 * \@stable
1125 */
1126var ErrorHandler = (function () {
1127 /**
1128 * @param {?=} deprecatedParameter
1129 */
1130 function ErrorHandler(
1131 /**
1132 * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
1133 * rethrow.
1134 */
1135 deprecatedParameter) {
1136 /**
1137 * \@internal
1138 */
1139 this._console = console;
1140 }
1141 /**
1142 * @param {?} error
1143 * @return {?}
1144 */
1145 ErrorHandler.prototype.handleError = function (error) {
1146 var /** @type {?} */ originalError = this._findOriginalError(error);
1147 var /** @type {?} */ context = this._findContext(error);
1148 // Note: Browser consoles show the place from where console.error was called.
1149 // We can use this to give users additional information about the error.
1150 var /** @type {?} */ errorLogger = getErrorLogger(error);
1151 errorLogger(this._console, "ERROR", error);
1152 if (originalError) {
1153 errorLogger(this._console, "ORIGINAL ERROR", originalError);
1154 }
1155 if (context) {
1156 errorLogger(this._console, 'ERROR CONTEXT', context);
1157 }
1158 };
1159 /**
1160 * \@internal
1161 * @param {?} error
1162 * @return {?}
1163 */
1164 ErrorHandler.prototype._findContext = function (error) {
1165 if (error) {
1166 return getDebugContext(error) ? getDebugContext(error) :
1167 this._findContext(getOriginalError(error));
1168 }
1169 return null;
1170 };
1171 /**
1172 * \@internal
1173 * @param {?} error
1174 * @return {?}
1175 */
1176 ErrorHandler.prototype._findOriginalError = function (error) {
1177 var /** @type {?} */ e = getOriginalError(error);
1178 while (e && getOriginalError(e)) {
1179 e = getOriginalError(e);
1180 }
1181 return e;
1182 };
1183 return ErrorHandler;
1184}());
1185/**
1186 * @param {?} message
1187 * @param {?} originalError
1188 * @return {?}
1189 */
1190function wrappedError(message, originalError) {
1191 var /** @type {?} */ msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
1192 var /** @type {?} */ error = Error(msg);
1193 ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1194 return error;
1195}
1196/**
1197 * @license
1198 * Copyright Google Inc. All Rights Reserved.
1199 *
1200 * Use of this source code is governed by an MIT-style license that can be
1201 * found in the LICENSE file at https://angular.io/license
1202 */
1203/**
1204 * @param {?} keys
1205 * @return {?}
1206 */
1207function findFirstClosedCycle(keys) {
1208 var /** @type {?} */ res = [];
1209 for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
1210 if (res.indexOf(keys[i]) > -1) {
1211 res.push(keys[i]);
1212 return res;
1213 }
1214 res.push(keys[i]);
1215 }
1216 return res;
1217}
1218/**
1219 * @param {?} keys
1220 * @return {?}
1221 */
1222function constructResolvingPath(keys) {
1223 if (keys.length > 1) {
1224 var /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
1225 var /** @type {?} */ tokenStrs = reversed.map(function (k) { return stringify(k.token); });
1226 return ' (' + tokenStrs.join(' -> ') + ')';
1227 }
1228 return '';
1229}
1230/**
1231 * @param {?} injector
1232 * @param {?} key
1233 * @param {?} constructResolvingMessage
1234 * @param {?=} originalError
1235 * @return {?}
1236 */
1237function injectionError(injector, key, constructResolvingMessage, originalError) {
1238 var /** @type {?} */ error = ((originalError ? wrappedError('', originalError) : Error()));
1239 error.addKey = addKey;
1240 error.keys = [key];
1241 error.injectors = [injector];
1242 error.constructResolvingMessage = constructResolvingMessage;
1243 error.message = error.constructResolvingMessage();
1244 ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1245 return error;
1246}
1247/**
1248 * @this {?}
1249 * @param {?} injector
1250 * @param {?} key
1251 * @return {?}
1252 */
1253function addKey(injector, key) {
1254 this.injectors.push(injector);
1255 this.keys.push(key);
1256 this.message = this.constructResolvingMessage();
1257}
1258/**
1259 * Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
1260 * {\@link Injector} does not have a {\@link Provider} for the given key.
1261 *
1262 * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
1263 *
1264 * ```typescript
1265 * class A {
1266 * constructor(b:B) {}
1267 * }
1268 *
1269 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1270 * ```
1271 * @param {?} injector
1272 * @param {?} key
1273 * @return {?}
1274 */
1275function noProviderError(injector, key) {
1276 return injectionError(injector, key, function () {
1277 var /** @type {?} */ first = stringify(this.keys[0].token);
1278 return "No provider for " + first + "!" + constructResolvingPath(this.keys);
1279 });
1280}
1281/**
1282 * Thrown when dependencies form a cycle.
1283 *
1284 * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
1285 *
1286 * ```typescript
1287 * var injector = Injector.resolveAndCreate([
1288 * {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
1289 * {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
1290 * ]);
1291 *
1292 * expect(() => injector.get("one")).toThrowError();
1293 * ```
1294 *
1295 * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
1296 * @param {?} injector
1297 * @param {?} key
1298 * @return {?}
1299 */
1300function cyclicDependencyError(injector, key) {
1301 return injectionError(injector, key, function () {
1302 return "Cannot instantiate cyclic dependency!" + constructResolvingPath(this.keys);
1303 });
1304}
1305/**
1306 * Thrown when a constructing type returns with an Error.
1307 *
1308 * The `InstantiationError` class contains the original error plus the dependency graph which caused
1309 * this object to be instantiated.
1310 *
1311 * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
1312 *
1313 * ```typescript
1314 * class A {
1315 * constructor() {
1316 * throw new Error('message');
1317 * }
1318 * }
1319 *
1320 * var injector = Injector.resolveAndCreate([A]);
1321 * try {
1322 * injector.get(A);
1323 * } catch (e) {
1324 * expect(e instanceof InstantiationError).toBe(true);
1325 * expect(e.originalException.message).toEqual("message");
1326 * expect(e.originalStack).toBeDefined();
1327 * }
1328 * ```
1329 * @param {?} injector
1330 * @param {?} originalException
1331 * @param {?} originalStack
1332 * @param {?} key
1333 * @return {?}
1334 */
1335function instantiationError(injector, originalException, originalStack, key) {
1336 return injectionError(injector, key, function () {
1337 var /** @type {?} */ first = stringify(this.keys[0].token);
1338 return getOriginalError(this).message + ": Error during instantiation of " + first + "!" + constructResolvingPath(this.keys) + ".";
1339 }, originalException);
1340}
1341/**
1342 * Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
1343 * creation.
1344 *
1345 * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
1346 *
1347 * ```typescript
1348 * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
1349 * ```
1350 * @param {?} provider
1351 * @return {?}
1352 */
1353function invalidProviderError(provider) {
1354 return Error("Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
1355}
1356/**
1357 * Thrown when the class has no annotation information.
1358 *
1359 * Lack of annotation information prevents the {\@link Injector} from determining which dependencies
1360 * need to be injected into the constructor.
1361 *
1362 * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
1363 *
1364 * ```typescript
1365 * class A {
1366 * constructor(b) {}
1367 * }
1368 *
1369 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1370 * ```
1371 *
1372 * This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
1373 *
1374 * ```typescript
1375 * class B {}
1376 *
1377 * class A {
1378 * constructor(b:B) {} // no information about the parameter types of A is available at runtime.
1379 * }
1380 *
1381 * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
1382 * ```
1383 * \@stable
1384 * @param {?} typeOrFunc
1385 * @param {?} params
1386 * @return {?}
1387 */
1388function noAnnotationError(typeOrFunc, params) {
1389 var /** @type {?} */ signature = [];
1390 for (var /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
1391 var /** @type {?} */ parameter = params[i];
1392 if (!parameter || parameter.length == 0) {
1393 signature.push('?');
1394 }
1395 else {
1396 signature.push(parameter.map(stringify).join(' '));
1397 }
1398 }
1399 return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
1400 signature.join(', ') + '). ' +
1401 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
1402 stringify(typeOrFunc) + '\' is decorated with Injectable.');
1403}
1404/**
1405 * Thrown when getting an object by index.
1406 *
1407 * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
1408 *
1409 * ```typescript
1410 * class A {}
1411 *
1412 * var injector = Injector.resolveAndCreate([A]);
1413 *
1414 * expect(() => injector.getAt(100)).toThrowError();
1415 * ```
1416 * \@stable
1417 * @param {?} index
1418 * @return {?}
1419 */
1420function outOfBoundsError(index) {
1421 return Error("Index " + index + " is out-of-bounds.");
1422}
1423/**
1424 * Thrown when a multi provider and a regular provider are bound to the same token.
1425 *
1426 * ### Example
1427 *
1428 * ```typescript
1429 * expect(() => Injector.resolveAndCreate([
1430 * { provide: "Strings", useValue: "string1", multi: true},
1431 * { provide: "Strings", useValue: "string2", multi: false}
1432 * ])).toThrowError();
1433 * ```
1434 * @param {?} provider1
1435 * @param {?} provider2
1436 * @return {?}
1437 */
1438function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
1439 return Error("Cannot mix multi providers and regular providers, got: " + provider1 + " " + provider2);
1440}
1441/**
1442 * @license
1443 * Copyright Google Inc. All Rights Reserved.
1444 *
1445 * Use of this source code is governed by an MIT-style license that can be
1446 * found in the LICENSE file at https://angular.io/license
1447 */
1448/**
1449 * A unique object used for retrieving items from the {\@link ReflectiveInjector}.
1450 *
1451 * Keys have:
1452 * - a system-wide unique `id`.
1453 * - a `token`.
1454 *
1455 * `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
1456 * the
1457 * injector to store created objects in a more efficient way.
1458 *
1459 * `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
1460 * resolving
1461 * providers.
1462 * \@experimental
1463 */
1464var ReflectiveKey = (function () {
1465 /**
1466 * Private
1467 * @param {?} token
1468 * @param {?} id
1469 */
1470 function ReflectiveKey(token, id) {
1471 this.token = token;
1472 this.id = id;
1473 if (!token) {
1474 throw new Error('Token must be defined!');
1475 }
1476 }
1477 Object.defineProperty(ReflectiveKey.prototype, "displayName", {
1478 /**
1479 * Returns a stringified token.
1480 * @return {?}
1481 */
1482 get: function () { return stringify(this.token); },
1483 enumerable: true,
1484 configurable: true
1485 });
1486 /**
1487 * Retrieves a `Key` for a token.
1488 * @param {?} token
1489 * @return {?}
1490 */
1491 ReflectiveKey.get = function (token) {
1492 return _globalKeyRegistry.get(resolveForwardRef(token));
1493 };
1494 Object.defineProperty(ReflectiveKey, "numberOfKeys", {
1495 /**
1496 * @return {?} the number of keys registered in the system.
1497 */
1498 get: function () { return _globalKeyRegistry.numberOfKeys; },
1499 enumerable: true,
1500 configurable: true
1501 });
1502 return ReflectiveKey;
1503}());
1504/**
1505 * \@internal
1506 */
1507var KeyRegistry = (function () {
1508 function KeyRegistry() {
1509 this._allKeys = new Map();
1510 }
1511 /**
1512 * @param {?} token
1513 * @return {?}
1514 */
1515 KeyRegistry.prototype.get = function (token) {
1516 if (token instanceof ReflectiveKey)
1517 return token;
1518 if (this._allKeys.has(token)) {
1519 return ((this._allKeys.get(token)));
1520 }
1521 var /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
1522 this._allKeys.set(token, newKey);
1523 return newKey;
1524 };
1525 Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
1526 /**
1527 * @return {?}
1528 */
1529 get: function () { return this._allKeys.size; },
1530 enumerable: true,
1531 configurable: true
1532 });
1533 return KeyRegistry;
1534}());
1535var _globalKeyRegistry = new KeyRegistry();
1536/**
1537 * \@whatItDoes Represents a type that a Component or other object is instances of.
1538 *
1539 * \@description
1540 *
1541 * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
1542 * the `MyCustomComponent` constructor function.
1543 *
1544 * \@stable
1545 */
1546var Type = Function;
1547/**
1548 * @param {?} v
1549 * @return {?}
1550 */
1551function isType(v) {
1552 return typeof v === 'function';
1553}
1554/**
1555 * @license
1556 * Copyright Google Inc. All Rights Reserved.
1557 *
1558 * Use of this source code is governed by an MIT-style license that can be
1559 * found in the LICENSE file at https://angular.io/license
1560 */
1561/**
1562 * Attention: This regex has to hold even if the code is minified!
1563 */
1564var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
1565var ReflectionCapabilities = (function () {
1566 /**
1567 * @param {?=} reflect
1568 */
1569 function ReflectionCapabilities(reflect) {
1570 this._reflect = reflect || _global['Reflect'];
1571 }
1572 /**
1573 * @return {?}
1574 */
1575 ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; };
1576 /**
1577 * @template T
1578 * @param {?} t
1579 * @return {?}
1580 */
1581 ReflectionCapabilities.prototype.factory = function (t) { return function () {
1582 var args = [];
1583 for (var _i = 0; _i < arguments.length; _i++) {
1584 args[_i] = arguments[_i];
1585 }
1586 return new (t.bind.apply(t, [void 0].concat(args)))();
1587 }; };
1588 /**
1589 * \@internal
1590 * @param {?} paramTypes
1591 * @param {?} paramAnnotations
1592 * @return {?}
1593 */
1594 ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) {
1595 var /** @type {?} */ result;
1596 if (typeof paramTypes === 'undefined') {
1597 result = new Array(paramAnnotations.length);
1598 }
1599 else {
1600 result = new Array(paramTypes.length);
1601 }
1602 for (var /** @type {?} */ i = 0; i < result.length; i++) {
1603 // TS outputs Object for parameters without types, while Traceur omits
1604 // the annotations. For now we preserve the Traceur behavior to aid
1605 // migration, but this can be revisited.
1606 if (typeof paramTypes === 'undefined') {
1607 result[i] = [];
1608 }
1609 else if (paramTypes[i] != Object) {
1610 result[i] = [paramTypes[i]];
1611 }
1612 else {
1613 result[i] = [];
1614 }
1615 if (paramAnnotations && paramAnnotations[i] != null) {
1616 result[i] = result[i].concat(paramAnnotations[i]);
1617 }
1618 }
1619 return result;
1620 };
1621 /**
1622 * @param {?} type
1623 * @param {?} parentCtor
1624 * @return {?}
1625 */
1626 ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) {
1627 // If we have no decorators, we only have function.length as metadata.
1628 // In that case, to detect whether a child class declared an own constructor or not,
1629 // we need to look inside of that constructor to check whether it is
1630 // just calling the parent.
1631 // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
1632 // that sets 'design:paramtypes' to []
1633 // if a class inherits from another class but has no ctor declared itself.
1634 if (DELEGATE_CTOR.exec(type.toString())) {
1635 return null;
1636 }
1637 // Prefer the direct API.
1638 if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
1639 return ((type)).parameters;
1640 }
1641 // API of tsickle for lowering decorators to properties on the class.
1642 var /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
1643 if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
1644 // Newer tsickle uses a function closure
1645 // Retain the non-function case for compatibility with older tsickle
1646 var /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
1647 var /** @type {?} */ paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; });
1648 var /** @type {?} */ paramAnnotations = ctorParameters.map(function (ctorParam) { return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators); });
1649 return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1650 }
1651 // API for metadata created by invoking the decorators.
1652 if (this._reflect != null && this._reflect.getOwnMetadata != null) {
1653 var /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
1654 var /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
1655 if (paramTypes || paramAnnotations) {
1656 return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1657 }
1658 }
1659 // If a class has no decorators, at least create metadata
1660 // based on function.length.
1661 // Note: We know that this is a real constructor as we checked
1662 // the content of the constructor above.
1663 return new Array(((type.length))).fill(undefined);
1664 };
1665 /**
1666 * @param {?} type
1667 * @return {?}
1668 */
1669 ReflectionCapabilities.prototype.parameters = function (type) {
1670 // Note: only report metadata if we have at least one class decorator
1671 // to stay in sync with the static reflector.
1672 if (!isType(type)) {
1673 return [];
1674 }
1675 var /** @type {?} */ parentCtor = getParentCtor(type);
1676 var /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
1677 if (!parameters && parentCtor !== Object) {
1678 parameters = this.parameters(parentCtor);
1679 }
1680 return parameters || [];
1681 };
1682 /**
1683 * @param {?} typeOrFunc
1684 * @param {?} parentCtor
1685 * @return {?}
1686 */
1687 ReflectionCapabilities.prototype._ownAnnotations = function (typeOrFunc, parentCtor) {
1688 // Prefer the direct API.
1689 if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
1690 var /** @type {?} */ annotations = ((typeOrFunc)).annotations;
1691 if (typeof annotations === 'function' && annotations.annotations) {
1692 annotations = annotations.annotations;
1693 }
1694 return annotations;
1695 }
1696 // API of tsickle for lowering decorators to properties on the class.
1697 if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
1698 return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
1699 }
1700 // API for metadata created by invoking the decorators.
1701 if (this._reflect && this._reflect.getOwnMetadata) {
1702 return this._reflect.getOwnMetadata('annotations', typeOrFunc);
1703 }
1704 return null;
1705 };
1706 /**
1707 * @param {?} typeOrFunc
1708 * @return {?}
1709 */
1710 ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
1711 if (!isType(typeOrFunc)) {
1712 return [];
1713 }
1714 var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1715 var /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
1716 var /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
1717 return parentAnnotations.concat(ownAnnotations);
1718 };
1719 /**
1720 * @param {?} typeOrFunc
1721 * @param {?} parentCtor
1722 * @return {?}
1723 */
1724 ReflectionCapabilities.prototype._ownPropMetadata = function (typeOrFunc, parentCtor) {
1725 // Prefer the direct API.
1726 if (((typeOrFunc)).propMetadata &&
1727 ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
1728 var /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
1729 if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
1730 propMetadata = propMetadata.propMetadata;
1731 }
1732 return propMetadata;
1733 }
1734 // API of tsickle for lowering decorators to properties on the class.
1735 if (((typeOrFunc)).propDecorators &&
1736 ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
1737 var /** @type {?} */ propDecorators_1 = ((typeOrFunc)).propDecorators;
1738 var /** @type {?} */ propMetadata_1 = ({});
1739 Object.keys(propDecorators_1).forEach(function (prop) {
1740 propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]);
1741 });
1742 return propMetadata_1;
1743 }
1744 // API for metadata created by invoking the decorators.
1745 if (this._reflect && this._reflect.getOwnMetadata) {
1746 return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
1747 }
1748 return null;
1749 };
1750 /**
1751 * @param {?} typeOrFunc
1752 * @return {?}
1753 */
1754 ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) {
1755 if (!isType(typeOrFunc)) {
1756 return {};
1757 }
1758 var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1759 var /** @type {?} */ propMetadata = {};
1760 if (parentCtor !== Object) {
1761 var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentCtor);
1762 Object.keys(parentPropMetadata_1).forEach(function (propName) {
1763 propMetadata[propName] = parentPropMetadata_1[propName];
1764 });
1765 }
1766 var /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
1767 if (ownPropMetadata) {
1768 Object.keys(ownPropMetadata).forEach(function (propName) {
1769 var /** @type {?} */ decorators = [];
1770 if (propMetadata.hasOwnProperty(propName)) {
1771 decorators.push.apply(decorators, propMetadata[propName]);
1772 }
1773 decorators.push.apply(decorators, ownPropMetadata[propName]);
1774 propMetadata[propName] = decorators;
1775 });
1776 }
1777 return propMetadata;
1778 };
1779 /**
1780 * @param {?} type
1781 * @param {?} lcProperty
1782 * @return {?}
1783 */
1784 ReflectionCapabilities.prototype.hasLifecycleHook = function (type, lcProperty) {
1785 return type instanceof Type && lcProperty in type.prototype;
1786 };
1787 /**
1788 * @param {?} name
1789 * @return {?}
1790 */
1791 ReflectionCapabilities.prototype.getter = function (name) { return (new Function('o', 'return o.' + name + ';')); };
1792 /**
1793 * @param {?} name
1794 * @return {?}
1795 */
1796 ReflectionCapabilities.prototype.setter = function (name) {
1797 return (new Function('o', 'v', 'return o.' + name + ' = v;'));
1798 };
1799 /**
1800 * @param {?} name
1801 * @return {?}
1802 */
1803 ReflectionCapabilities.prototype.method = function (name) {
1804 var /** @type {?} */ functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
1805 return (new Function('o', 'args', functionBody));
1806 };
1807 /**
1808 * @param {?} type
1809 * @return {?}
1810 */
1811 ReflectionCapabilities.prototype.importUri = function (type) {
1812 // StaticSymbol
1813 if (typeof type === 'object' && type['filePath']) {
1814 return type['filePath'];
1815 }
1816 // Runtime type
1817 return "./" + stringify(type);
1818 };
1819 /**
1820 * @param {?} type
1821 * @return {?}
1822 */
1823 ReflectionCapabilities.prototype.resourceUri = function (type) { return "./" + stringify(type); };
1824 /**
1825 * @param {?} name
1826 * @param {?} moduleUrl
1827 * @param {?} members
1828 * @param {?} runtime
1829 * @return {?}
1830 */
1831 ReflectionCapabilities.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
1832 return runtime;
1833 };
1834 /**
1835 * @param {?} enumIdentifier
1836 * @param {?} name
1837 * @return {?}
1838 */
1839 ReflectionCapabilities.prototype.resolveEnum = function (enumIdentifier, name) { return enumIdentifier[name]; };
1840 return ReflectionCapabilities;
1841}());
1842/**
1843 * @param {?} decoratorInvocations
1844 * @return {?}
1845 */
1846function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
1847 if (!decoratorInvocations) {
1848 return [];
1849 }
1850 return decoratorInvocations.map(function (decoratorInvocation) {
1851 var /** @type {?} */ decoratorType = decoratorInvocation.type;
1852 var /** @type {?} */ annotationCls = decoratorType.annotationCls;
1853 var /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
1854 return new (annotationCls.bind.apply(annotationCls, [void 0].concat(annotationArgs)))();
1855 });
1856}
1857/**
1858 * @param {?} ctor
1859 * @return {?}
1860 */
1861function getParentCtor(ctor) {
1862 var /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
1863 var /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
1864 // Note: We always use `Object` as the null value
1865 // to simplify checking later on.
1866 return parentCtor || Object;
1867}
1868/**
1869 * Provides read-only access to reflection data about symbols. Used internally by Angular
1870 * to power dependency injection and compilation.
1871 * @abstract
1872 */
1873var ReflectorReader = (function () {
1874 function ReflectorReader() {
1875 }
1876 /**
1877 * @abstract
1878 * @param {?} typeOrFunc
1879 * @return {?}
1880 */
1881 ReflectorReader.prototype.parameters = function (typeOrFunc) { };
1882 /**
1883 * @abstract
1884 * @param {?} typeOrFunc
1885 * @return {?}
1886 */
1887 ReflectorReader.prototype.annotations = function (typeOrFunc) { };
1888 /**
1889 * @abstract
1890 * @param {?} typeOrFunc
1891 * @return {?}
1892 */
1893 ReflectorReader.prototype.propMetadata = function (typeOrFunc) { };
1894 /**
1895 * @abstract
1896 * @param {?} typeOrFunc
1897 * @return {?}
1898 */
1899 ReflectorReader.prototype.importUri = function (typeOrFunc) { };
1900 /**
1901 * @abstract
1902 * @param {?} typeOrFunc
1903 * @return {?}
1904 */
1905 ReflectorReader.prototype.resourceUri = function (typeOrFunc) { };
1906 /**
1907 * @abstract
1908 * @param {?} name
1909 * @param {?} moduleUrl
1910 * @param {?} members
1911 * @param {?} runtime
1912 * @return {?}
1913 */
1914 ReflectorReader.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) { };
1915 /**
1916 * @abstract
1917 * @param {?} identifier
1918 * @param {?} name
1919 * @return {?}
1920 */
1921 ReflectorReader.prototype.resolveEnum = function (identifier, name) { };
1922 return ReflectorReader;
1923}());
1924/**
1925 * @license
1926 * Copyright Google Inc. All Rights Reserved.
1927 *
1928 * Use of this source code is governed by an MIT-style license that can be
1929 * found in the LICENSE file at https://angular.io/license
1930 */
1931/**
1932 * Provides access to reflection data about symbols. Used internally by Angular
1933 * to power dependency injection and compilation.
1934 */
1935var Reflector = (function (_super) {
1936 __extends(Reflector, _super);
1937 /**
1938 * @param {?} reflectionCapabilities
1939 */
1940 function Reflector(reflectionCapabilities) {
1941 var _this = _super.call(this) || this;
1942 _this.reflectionCapabilities = reflectionCapabilities;
1943 return _this;
1944 }
1945 /**
1946 * @param {?} caps
1947 * @return {?}
1948 */
1949 Reflector.prototype.updateCapabilities = function (caps) { this.reflectionCapabilities = caps; };
1950 /**
1951 * @param {?} type
1952 * @return {?}
1953 */
1954 Reflector.prototype.factory = function (type) { return this.reflectionCapabilities.factory(type); };
1955 /**
1956 * @param {?} typeOrFunc
1957 * @return {?}
1958 */
1959 Reflector.prototype.parameters = function (typeOrFunc) {
1960 return this.reflectionCapabilities.parameters(typeOrFunc);
1961 };
1962 /**
1963 * @param {?} typeOrFunc
1964 * @return {?}
1965 */
1966 Reflector.prototype.annotations = function (typeOrFunc) {
1967 return this.reflectionCapabilities.annotations(typeOrFunc);
1968 };
1969 /**
1970 * @param {?} typeOrFunc
1971 * @return {?}
1972 */
1973 Reflector.prototype.propMetadata = function (typeOrFunc) {
1974 return this.reflectionCapabilities.propMetadata(typeOrFunc);
1975 };
1976 /**
1977 * @param {?} type
1978 * @param {?} lcProperty
1979 * @return {?}
1980 */
1981 Reflector.prototype.hasLifecycleHook = function (type, lcProperty) {
1982 return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
1983 };
1984 /**
1985 * @param {?} name
1986 * @return {?}
1987 */
1988 Reflector.prototype.getter = function (name) { return this.reflectionCapabilities.getter(name); };
1989 /**
1990 * @param {?} name
1991 * @return {?}
1992 */
1993 Reflector.prototype.setter = function (name) { return this.reflectionCapabilities.setter(name); };
1994 /**
1995 * @param {?} name
1996 * @return {?}
1997 */
1998 Reflector.prototype.method = function (name) { return this.reflectionCapabilities.method(name); };
1999 /**
2000 * @param {?} type
2001 * @return {?}
2002 */
2003 Reflector.prototype.importUri = function (type) { return this.reflectionCapabilities.importUri(type); };
2004 /**
2005 * @param {?} type
2006 * @return {?}
2007 */
2008 Reflector.prototype.resourceUri = function (type) { return this.reflectionCapabilities.resourceUri(type); };
2009 /**
2010 * @param {?} name
2011 * @param {?} moduleUrl
2012 * @param {?} members
2013 * @param {?} runtime
2014 * @return {?}
2015 */
2016 Reflector.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
2017 return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
2018 };
2019 /**
2020 * @param {?} identifier
2021 * @param {?} name
2022 * @return {?}
2023 */
2024 Reflector.prototype.resolveEnum = function (identifier, name) {
2025 return this.reflectionCapabilities.resolveEnum(identifier, name);
2026 };
2027 return Reflector;
2028}(ReflectorReader));
2029/**
2030 * @license
2031 * Copyright Google Inc. All Rights Reserved.
2032 *
2033 * Use of this source code is governed by an MIT-style license that can be
2034 * found in the LICENSE file at https://angular.io/license
2035 */
2036/**
2037 * The {@link Reflector} used internally in Angular to access metadata
2038 * about symbols.
2039 */
2040var reflector = new Reflector(new ReflectionCapabilities());
2041/**
2042 * @license
2043 * Copyright Google Inc. All Rights Reserved.
2044 *
2045 * Use of this source code is governed by an MIT-style license that can be
2046 * found in the LICENSE file at https://angular.io/license
2047 */
2048/**
2049 * `Dependency` is used by the framework to extend DI.
2050 * This is internal to Angular and should not be used directly.
2051 */
2052var ReflectiveDependency = (function () {
2053 /**
2054 * @param {?} key
2055 * @param {?} optional
2056 * @param {?} visibility
2057 */
2058 function ReflectiveDependency(key, optional, visibility) {
2059 this.key = key;
2060 this.optional = optional;
2061 this.visibility = visibility;
2062 }
2063 /**
2064 * @param {?} key
2065 * @return {?}
2066 */
2067 ReflectiveDependency.fromKey = function (key) {
2068 return new ReflectiveDependency(key, false, null);
2069 };
2070 return ReflectiveDependency;
2071}());
2072var _EMPTY_LIST = [];
2073var ResolvedReflectiveProvider_ = (function () {
2074 /**
2075 * @param {?} key
2076 * @param {?} resolvedFactories
2077 * @param {?} multiProvider
2078 */
2079 function ResolvedReflectiveProvider_(key, resolvedFactories, multiProvider) {
2080 this.key = key;
2081 this.resolvedFactories = resolvedFactories;
2082 this.multiProvider = multiProvider;
2083 }
2084 Object.defineProperty(ResolvedReflectiveProvider_.prototype, "resolvedFactory", {
2085 /**
2086 * @return {?}
2087 */
2088 get: function () { return this.resolvedFactories[0]; },
2089 enumerable: true,
2090 configurable: true
2091 });
2092 return ResolvedReflectiveProvider_;
2093}());
2094/**
2095 * An internal resolved representation of a factory function created by resolving {\@link
2096 * Provider}.
2097 * \@experimental
2098 */
2099var ResolvedReflectiveFactory = (function () {
2100 /**
2101 * @param {?} factory
2102 * @param {?} dependencies
2103 */
2104 function ResolvedReflectiveFactory(factory, dependencies) {
2105 this.factory = factory;
2106 this.dependencies = dependencies;
2107 }
2108 return ResolvedReflectiveFactory;
2109}());
2110/**
2111 * Resolve a single provider.
2112 * @param {?} provider
2113 * @return {?}
2114 */
2115function resolveReflectiveFactory(provider) {
2116 var /** @type {?} */ factoryFn;
2117 var /** @type {?} */ resolvedDeps;
2118 if (provider.useClass) {
2119 var /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
2120 factoryFn = reflector.factory(useClass);
2121 resolvedDeps = _dependenciesFor(useClass);
2122 }
2123 else if (provider.useExisting) {
2124 factoryFn = function (aliasInstance) { return aliasInstance; };
2125 resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
2126 }
2127 else if (provider.useFactory) {
2128 factoryFn = provider.useFactory;
2129 resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
2130 }
2131 else {
2132 factoryFn = function () { return provider.useValue; };
2133 resolvedDeps = _EMPTY_LIST;
2134 }
2135 return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
2136}
2137/**
2138 * Converts the {\@link Provider} into {\@link ResolvedProvider}.
2139 *
2140 * {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
2141 * convenience provider syntax.
2142 * @param {?} provider
2143 * @return {?}
2144 */
2145function resolveReflectiveProvider(provider) {
2146 return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
2147}
2148/**
2149 * Resolve a list of Providers.
2150 * @param {?} providers
2151 * @return {?}
2152 */
2153function resolveReflectiveProviders(providers) {
2154 var /** @type {?} */ normalized = _normalizeProviders(providers, []);
2155 var /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
2156 var /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
2157 return Array.from(resolvedProviderMap.values());
2158}
2159/**
2160 * Merges a list of ResolvedProviders into a list where
2161 * each key is contained exactly once and multi providers
2162 * have been merged.
2163 * @param {?} providers
2164 * @param {?} normalizedProvidersMap
2165 * @return {?}
2166 */
2167function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
2168 for (var /** @type {?} */ i = 0; i < providers.length; i++) {
2169 var /** @type {?} */ provider = providers[i];
2170 var /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
2171 if (existing) {
2172 if (provider.multiProvider !== existing.multiProvider) {
2173 throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
2174 }
2175 if (provider.multiProvider) {
2176 for (var /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
2177 existing.resolvedFactories.push(provider.resolvedFactories[j]);
2178 }
2179 }
2180 else {
2181 normalizedProvidersMap.set(provider.key.id, provider);
2182 }
2183 }
2184 else {
2185 var /** @type {?} */ resolvedProvider = void 0;
2186 if (provider.multiProvider) {
2187 resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
2188 }
2189 else {
2190 resolvedProvider = provider;
2191 }
2192 normalizedProvidersMap.set(provider.key.id, resolvedProvider);
2193 }
2194 }
2195 return normalizedProvidersMap;
2196}
2197/**
2198 * @param {?} providers
2199 * @param {?} res
2200 * @return {?}
2201 */
2202function _normalizeProviders(providers, res) {
2203 providers.forEach(function (b) {
2204 if (b instanceof Type) {
2205 res.push({ provide: b, useClass: b });
2206 }
2207 else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
2208 res.push(/** @type {?} */ (b));
2209 }
2210 else if (b instanceof Array) {
2211 _normalizeProviders(b, res);
2212 }
2213 else {
2214 throw invalidProviderError(b);
2215 }
2216 });
2217 return res;
2218}
2219/**
2220 * @param {?} typeOrFunc
2221 * @param {?=} dependencies
2222 * @return {?}
2223 */
2224function constructDependencies(typeOrFunc, dependencies) {
2225 if (!dependencies) {
2226 return _dependenciesFor(typeOrFunc);
2227 }
2228 else {
2229 var /** @type {?} */ params_1 = dependencies.map(function (t) { return [t]; });
2230 return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params_1); });
2231 }
2232}
2233/**
2234 * @param {?} typeOrFunc
2235 * @return {?}
2236 */
2237function _dependenciesFor(typeOrFunc) {
2238 var /** @type {?} */ params = reflector.parameters(typeOrFunc);
2239 if (!params)
2240 return [];
2241 if (params.some(function (p) { return p == null; })) {
2242 throw noAnnotationError(typeOrFunc, params);
2243 }
2244 return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
2245}
2246/**
2247 * @param {?} typeOrFunc
2248 * @param {?} metadata
2249 * @param {?} params
2250 * @return {?}
2251 */
2252function _extractToken(typeOrFunc, metadata, params) {
2253 var /** @type {?} */ token = null;
2254 var /** @type {?} */ optional = false;
2255 if (!Array.isArray(metadata)) {
2256 if (metadata instanceof Inject) {
2257 return _createDependency(metadata['token'], optional, null);
2258 }
2259 else {
2260 return _createDependency(metadata, optional, null);
2261 }
2262 }
2263 var /** @type {?} */ visibility = null;
2264 for (var /** @type {?} */ i = 0; i < metadata.length; ++i) {
2265 var /** @type {?} */ paramMetadata = metadata[i];
2266 if (paramMetadata instanceof Type) {
2267 token = paramMetadata;
2268 }
2269 else if (paramMetadata instanceof Inject) {
2270 token = paramMetadata['token'];
2271 }
2272 else if (paramMetadata instanceof Optional) {
2273 optional = true;
2274 }
2275 else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
2276 visibility = paramMetadata;
2277 }
2278 else if (paramMetadata instanceof InjectionToken) {
2279 token = paramMetadata;
2280 }
2281 }
2282 token = resolveForwardRef(token);
2283 if (token != null) {
2284 return _createDependency(token, optional, visibility);
2285 }
2286 else {
2287 throw noAnnotationError(typeOrFunc, params);
2288 }
2289}
2290/**
2291 * @param {?} token
2292 * @param {?} optional
2293 * @param {?} visibility
2294 * @return {?}
2295 */
2296function _createDependency(token, optional, visibility) {
2297 return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
2298}
2299/**
2300 * @license
2301 * Copyright Google Inc. All Rights Reserved.
2302 *
2303 * Use of this source code is governed by an MIT-style license that can be
2304 * found in the LICENSE file at https://angular.io/license
2305 */
2306// Threshold for the dynamic version
2307var UNDEFINED = new Object();
2308/**
2309 * A ReflectiveDependency injection container used for instantiating objects and resolving
2310 * dependencies.
2311 *
2312 * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
2313 * constructor dependencies.
2314 *
2315 * In typical use, application code asks for the dependencies in the constructor and they are
2316 * resolved by the `Injector`.
2317 *
2318 * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
2319 *
2320 * The following example creates an `Injector` configured to create `Engine` and `Car`.
2321 *
2322 * ```typescript
2323 * \@Injectable()
2324 * class Engine {
2325 * }
2326 *
2327 * \@Injectable()
2328 * class Car {
2329 * constructor(public engine:Engine) {}
2330 * }
2331 *
2332 * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2333 * var car = injector.get(Car);
2334 * expect(car instanceof Car).toBe(true);
2335 * expect(car.engine instanceof Engine).toBe(true);
2336 * ```
2337 *
2338 * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
2339 * resolve all of the object's dependencies automatically.
2340 *
2341 * \@stable
2342 * @abstract
2343 */
2344var ReflectiveInjector = (function () {
2345 function ReflectiveInjector() {
2346 }
2347 /**
2348 * Turns an array of provider definitions into an array of resolved providers.
2349 *
2350 * A resolution is a process of flattening multiple nested arrays and converting individual
2351 * providers into an array of {\@link ResolvedReflectiveProvider}s.
2352 *
2353 * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
2354 *
2355 * ```typescript
2356 * \@Injectable()
2357 * class Engine {
2358 * }
2359 *
2360 * \@Injectable()
2361 * class Car {
2362 * constructor(public engine:Engine) {}
2363 * }
2364 *
2365 * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
2366 *
2367 * expect(providers.length).toEqual(2);
2368 *
2369 * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
2370 * expect(providers[0].key.displayName).toBe("Car");
2371 * expect(providers[0].dependencies.length).toEqual(1);
2372 * expect(providers[0].factory).toBeDefined();
2373 *
2374 * expect(providers[1].key.displayName).toBe("Engine");
2375 * });
2376 * ```
2377 *
2378 * See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
2379 * @param {?} providers
2380 * @return {?}
2381 */
2382 ReflectiveInjector.resolve = function (providers) {
2383 return resolveReflectiveProviders(providers);
2384 };
2385 /**
2386 * Resolves an array of providers and creates an injector from those providers.
2387 *
2388 * The passed-in providers can be an array of `Type`, {\@link Provider},
2389 * or a recursive array of more providers.
2390 *
2391 * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
2392 *
2393 * ```typescript
2394 * \@Injectable()
2395 * class Engine {
2396 * }
2397 *
2398 * \@Injectable()
2399 * class Car {
2400 * constructor(public engine:Engine) {}
2401 * }
2402 *
2403 * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2404 * expect(injector.get(Car) instanceof Car).toBe(true);
2405 * ```
2406 *
2407 * This function is slower than the corresponding `fromResolvedProviders`
2408 * because it needs to resolve the passed-in providers first.
2409 * See {\@link Injector#resolve} and {\@link Injector#fromResolvedProviders}.
2410 * @param {?} providers
2411 * @param {?=} parent
2412 * @return {?}
2413 */
2414 ReflectiveInjector.resolveAndCreate = function (providers, parent) {
2415 var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2416 return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
2417 };
2418 /**
2419 * Creates an injector from previously resolved providers.
2420 *
2421 * This API is the recommended way to construct injectors in performance-sensitive parts.
2422 *
2423 * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
2424 *
2425 * ```typescript
2426 * \@Injectable()
2427 * class Engine {
2428 * }
2429 *
2430 * \@Injectable()
2431 * class Car {
2432 * constructor(public engine:Engine) {}
2433 * }
2434 *
2435 * var providers = ReflectiveInjector.resolve([Car, Engine]);
2436 * var injector = ReflectiveInjector.fromResolvedProviders(providers);
2437 * expect(injector.get(Car) instanceof Car).toBe(true);
2438 * ```
2439 * \@experimental
2440 * @param {?} providers
2441 * @param {?=} parent
2442 * @return {?}
2443 */
2444 ReflectiveInjector.fromResolvedProviders = function (providers, parent) {
2445 return new ReflectiveInjector_(providers, parent);
2446 };
2447 /**
2448 * Parent of this injector.
2449 *
2450 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2451 * -->
2452 *
2453 * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
2454 *
2455 * ```typescript
2456 * var parent = ReflectiveInjector.resolveAndCreate([]);
2457 * var child = parent.resolveAndCreateChild([]);
2458 * expect(child.parent).toBe(parent);
2459 * ```
2460 * @abstract
2461 * @return {?}
2462 */
2463 ReflectiveInjector.prototype.parent = function () { };
2464 /**
2465 * Resolves an array of providers and creates a child injector from those providers.
2466 *
2467 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2468 * -->
2469 *
2470 * The passed-in providers can be an array of `Type`, {\@link Provider},
2471 * or a recursive array of more providers.
2472 *
2473 * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
2474 *
2475 * ```typescript
2476 * class ParentProvider {}
2477 * class ChildProvider {}
2478 *
2479 * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
2480 * var child = parent.resolveAndCreateChild([ChildProvider]);
2481 *
2482 * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2483 * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2484 * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2485 * ```
2486 *
2487 * This function is slower than the corresponding `createChildFromResolved`
2488 * because it needs to resolve the passed-in providers first.
2489 * See {\@link Injector#resolve} and {\@link Injector#createChildFromResolved}.
2490 * @abstract
2491 * @param {?} providers
2492 * @return {?}
2493 */
2494 ReflectiveInjector.prototype.resolveAndCreateChild = function (providers) { };
2495 /**
2496 * Creates a child injector from previously resolved providers.
2497 *
2498 * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2499 * -->
2500 *
2501 * This API is the recommended way to construct injectors in performance-sensitive parts.
2502 *
2503 * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
2504 *
2505 * ```typescript
2506 * class ParentProvider {}
2507 * class ChildProvider {}
2508 *
2509 * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
2510 * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
2511 *
2512 * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
2513 * var child = parent.createChildFromResolved(childProviders);
2514 *
2515 * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2516 * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2517 * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2518 * ```
2519 * @abstract
2520 * @param {?} providers
2521 * @return {?}
2522 */
2523 ReflectiveInjector.prototype.createChildFromResolved = function (providers) { };
2524 /**
2525 * Resolves a provider and instantiates an object in the context of the injector.
2526 *
2527 * The created object does not get cached by the injector.
2528 *
2529 * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
2530 *
2531 * ```typescript
2532 * \@Injectable()
2533 * class Engine {
2534 * }
2535 *
2536 * \@Injectable()
2537 * class Car {
2538 * constructor(public engine:Engine) {}
2539 * }
2540 *
2541 * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2542 *
2543 * var car = injector.resolveAndInstantiate(Car);
2544 * expect(car.engine).toBe(injector.get(Engine));
2545 * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
2546 * ```
2547 * @abstract
2548 * @param {?} provider
2549 * @return {?}
2550 */
2551 ReflectiveInjector.prototype.resolveAndInstantiate = function (provider) { };
2552 /**
2553 * Instantiates an object using a resolved provider in the context of the injector.
2554 *
2555 * The created object does not get cached by the injector.
2556 *
2557 * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
2558 *
2559 * ```typescript
2560 * \@Injectable()
2561 * class Engine {
2562 * }
2563 *
2564 * \@Injectable()
2565 * class Car {
2566 * constructor(public engine:Engine) {}
2567 * }
2568 *
2569 * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2570 * var carProvider = ReflectiveInjector.resolve([Car])[0];
2571 * var car = injector.instantiateResolved(carProvider);
2572 * expect(car.engine).toBe(injector.get(Engine));
2573 * expect(car).not.toBe(injector.instantiateResolved(carProvider));
2574 * ```
2575 * @abstract
2576 * @param {?} provider
2577 * @return {?}
2578 */
2579 ReflectiveInjector.prototype.instantiateResolved = function (provider) { };
2580 /**
2581 * @abstract
2582 * @param {?} token
2583 * @param {?=} notFoundValue
2584 * @return {?}
2585 */
2586 ReflectiveInjector.prototype.get = function (token, notFoundValue) { };
2587 return ReflectiveInjector;
2588}());
2589var ReflectiveInjector_ = (function () {
2590 /**
2591 * Private
2592 * @param {?} _providers
2593 * @param {?=} _parent
2594 */
2595 function ReflectiveInjector_(_providers, _parent) {
2596 /**
2597 * \@internal
2598 */
2599 this._constructionCounter = 0;
2600 this._providers = _providers;
2601 this._parent = _parent || null;
2602 var len = _providers.length;
2603 this.keyIds = new Array(len);
2604 this.objs = new Array(len);
2605 for (var i = 0; i < len; i++) {
2606 this.keyIds[i] = _providers[i].key.id;
2607 this.objs[i] = UNDEFINED;
2608 }
2609 }
2610 /**
2611 * @param {?} token
2612 * @param {?=} notFoundValue
2613 * @return {?}
2614 */
2615 ReflectiveInjector_.prototype.get = function (token, notFoundValue) {
2616 if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
2617 return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
2618 };
2619 Object.defineProperty(ReflectiveInjector_.prototype, "parent", {
2620 /**
2621 * @return {?}
2622 */
2623 get: function () { return this._parent; },
2624 enumerable: true,
2625 configurable: true
2626 });
2627 /**
2628 * @param {?} providers
2629 * @return {?}
2630 */
2631 ReflectiveInjector_.prototype.resolveAndCreateChild = function (providers) {
2632 var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2633 return this.createChildFromResolved(ResolvedReflectiveProviders);
2634 };
2635 /**
2636 * @param {?} providers
2637 * @return {?}
2638 */
2639 ReflectiveInjector_.prototype.createChildFromResolved = function (providers) {
2640 var /** @type {?} */ inj = new ReflectiveInjector_(providers);
2641 inj._parent = this;
2642 return inj;
2643 };
2644 /**
2645 * @param {?} provider
2646 * @return {?}
2647 */
2648 ReflectiveInjector_.prototype.resolveAndInstantiate = function (provider) {
2649 return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
2650 };
2651 /**
2652 * @param {?} provider
2653 * @return {?}
2654 */
2655 ReflectiveInjector_.prototype.instantiateResolved = function (provider) {
2656 return this._instantiateProvider(provider);
2657 };
2658 /**
2659 * @param {?} index
2660 * @return {?}
2661 */
2662 ReflectiveInjector_.prototype.getProviderAtIndex = function (index) {
2663 if (index < 0 || index >= this._providers.length) {
2664 throw outOfBoundsError(index);
2665 }
2666 return this._providers[index];
2667 };
2668 /**
2669 * \@internal
2670 * @param {?} provider
2671 * @return {?}
2672 */
2673 ReflectiveInjector_.prototype._new = function (provider) {
2674 if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
2675 throw cyclicDependencyError(this, provider.key);
2676 }
2677 return this._instantiateProvider(provider);
2678 };
2679 /**
2680 * @return {?}
2681 */
2682 ReflectiveInjector_.prototype._getMaxNumberOfObjects = function () { return this.objs.length; };
2683 /**
2684 * @param {?} provider
2685 * @return {?}
2686 */
2687 ReflectiveInjector_.prototype._instantiateProvider = function (provider) {
2688 if (provider.multiProvider) {
2689 var /** @type {?} */ res = new Array(provider.resolvedFactories.length);
2690 for (var /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
2691 res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
2692 }
2693 return res;
2694 }
2695 else {
2696 return this._instantiate(provider, provider.resolvedFactories[0]);
2697 }
2698 };
2699 /**
2700 * @param {?} provider
2701 * @param {?} ResolvedReflectiveFactory
2702 * @return {?}
2703 */
2704 ReflectiveInjector_.prototype._instantiate = function (provider, ResolvedReflectiveFactory$$1) {
2705 var _this = this;
2706 var /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
2707 var /** @type {?} */ deps;
2708 try {
2709 deps =
2710 ResolvedReflectiveFactory$$1.dependencies.map(function (dep) { return _this._getByReflectiveDependency(dep); });
2711 }
2712 catch (e) {
2713 if (e.addKey) {
2714 e.addKey(this, provider.key);
2715 }
2716 throw e;
2717 }
2718 var /** @type {?} */ obj;
2719 try {
2720 obj = factory.apply(void 0, deps);
2721 }
2722 catch (e) {
2723 throw instantiationError(this, e, e.stack, provider.key);
2724 }
2725 return obj;
2726 };
2727 /**
2728 * @param {?} dep
2729 * @return {?}
2730 */
2731 ReflectiveInjector_.prototype._getByReflectiveDependency = function (dep) {
2732 return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
2733 };
2734 /**
2735 * @param {?} key
2736 * @param {?} visibility
2737 * @param {?} notFoundValue
2738 * @return {?}
2739 */
2740 ReflectiveInjector_.prototype._getByKey = function (key, visibility, notFoundValue) {
2741 if (key === INJECTOR_KEY) {
2742 return this;
2743 }
2744 if (visibility instanceof Self) {
2745 return this._getByKeySelf(key, notFoundValue);
2746 }
2747 else {
2748 return this._getByKeyDefault(key, notFoundValue, visibility);
2749 }
2750 };
2751 /**
2752 * @param {?} keyId
2753 * @return {?}
2754 */
2755 ReflectiveInjector_.prototype._getObjByKeyId = function (keyId) {
2756 for (var /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
2757 if (this.keyIds[i] === keyId) {
2758 if (this.objs[i] === UNDEFINED) {
2759 this.objs[i] = this._new(this._providers[i]);
2760 }
2761 return this.objs[i];
2762 }
2763 }
2764 return UNDEFINED;
2765 };
2766 /**
2767 * \@internal
2768 * @param {?} key
2769 * @param {?} notFoundValue
2770 * @return {?}
2771 */
2772 ReflectiveInjector_.prototype._throwOrNull = function (key, notFoundValue) {
2773 if (notFoundValue !== THROW_IF_NOT_FOUND) {
2774 return notFoundValue;
2775 }
2776 else {
2777 throw noProviderError(this, key);
2778 }
2779 };
2780 /**
2781 * \@internal
2782 * @param {?} key
2783 * @param {?} notFoundValue
2784 * @return {?}
2785 */
2786 ReflectiveInjector_.prototype._getByKeySelf = function (key, notFoundValue) {
2787 var /** @type {?} */ obj = this._getObjByKeyId(key.id);
2788 return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
2789 };
2790 /**
2791 * \@internal
2792 * @param {?} key
2793 * @param {?} notFoundValue
2794 * @param {?} visibility
2795 * @return {?}
2796 */
2797 ReflectiveInjector_.prototype._getByKeyDefault = function (key, notFoundValue, visibility) {
2798 var /** @type {?} */ inj;
2799 if (visibility instanceof SkipSelf) {
2800 inj = this._parent;
2801 }
2802 else {
2803 inj = this;
2804 }
2805 while (inj instanceof ReflectiveInjector_) {
2806 var /** @type {?} */ inj_ = (inj);
2807 var /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
2808 if (obj !== UNDEFINED)
2809 return obj;
2810 inj = inj_._parent;
2811 }
2812 if (inj !== null) {
2813 return inj.get(key.token, notFoundValue);
2814 }
2815 else {
2816 return this._throwOrNull(key, notFoundValue);
2817 }
2818 };
2819 Object.defineProperty(ReflectiveInjector_.prototype, "displayName", {
2820 /**
2821 * @return {?}
2822 */
2823 get: function () {
2824 var /** @type {?} */ providers = _mapProviders(this, function (b) { return ' "' + b.key.displayName + '" '; })
2825 .join(', ');
2826 return "ReflectiveInjector(providers: [" + providers + "])";
2827 },
2828 enumerable: true,
2829 configurable: true
2830 });
2831 /**
2832 * @return {?}
2833 */
2834 ReflectiveInjector_.prototype.toString = function () { return this.displayName; };
2835 return ReflectiveInjector_;
2836}());
2837var INJECTOR_KEY = ReflectiveKey.get(Injector);
2838/**
2839 * @param {?} injector
2840 * @param {?} fn
2841 * @return {?}
2842 */
2843function _mapProviders(injector, fn) {
2844 var /** @type {?} */ res = new Array(injector._providers.length);
2845 for (var /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
2846 res[i] = fn(injector.getProviderAtIndex(i));
2847 }
2848 return res;
2849}
2850/**
2851 * @license
2852 * Copyright Google Inc. All Rights Reserved.
2853 *
2854 * Use of this source code is governed by an MIT-style license that can be
2855 * found in the LICENSE file at https://angular.io/license
2856 */
2857/**
2858 * @module
2859 * @description
2860 * The `di` module provides dependency injection container services.
2861 */
2862/**
2863 * @license
2864 * Copyright Google Inc. All Rights Reserved.
2865 *
2866 * Use of this source code is governed by an MIT-style license that can be
2867 * found in the LICENSE file at https://angular.io/license
2868 */
2869/**
2870 * Determine if the argument is shaped like a Promise
2871 * @param {?} obj
2872 * @return {?}
2873 */
2874function isPromise(obj) {
2875 // allow any Promise/A+ compliant thenable.
2876 // It's up to the caller to ensure that obj.then conforms to the spec
2877 return !!obj && typeof obj.then === 'function';
2878}
2879/**
2880 * Determine if the argument is an Observable
2881 * @param {?} obj
2882 * @return {?}
2883 */
2884function isObservable(obj) {
2885 // TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
2886 return !!obj && typeof obj.subscribe === 'function';
2887}
2888/**
2889 * @license
2890 * Copyright Google Inc. All Rights Reserved.
2891 *
2892 * Use of this source code is governed by an MIT-style license that can be
2893 * found in the LICENSE file at https://angular.io/license
2894 */
2895/**
2896 * A function that will be executed when an application is initialized.
2897 * \@experimental
2898 */
2899var APP_INITIALIZER = new InjectionToken('Application Initializer');
2900/**
2901 * A class that reflects the state of running {\@link APP_INITIALIZER}s.
2902 *
2903 * \@experimental
2904 */
2905var ApplicationInitStatus = (function () {
2906 /**
2907 * @param {?} appInits
2908 */
2909 function ApplicationInitStatus(appInits) {
2910 var _this = this;
2911 this._done = false;
2912 var asyncInitPromises = [];
2913 if (appInits) {
2914 for (var i = 0; i < appInits.length; i++) {
2915 var initResult = appInits[i]();
2916 if (isPromise(initResult)) {
2917 asyncInitPromises.push(initResult);
2918 }
2919 }
2920 }
2921 this._donePromise = Promise.all(asyncInitPromises).then(function () { _this._done = true; });
2922 if (asyncInitPromises.length === 0) {
2923 this._done = true;
2924 }
2925 }
2926 Object.defineProperty(ApplicationInitStatus.prototype, "done", {
2927 /**
2928 * @return {?}
2929 */
2930 get: function () { return this._done; },
2931 enumerable: true,
2932 configurable: true
2933 });
2934 Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
2935 /**
2936 * @return {?}
2937 */
2938 get: function () { return this._donePromise; },
2939 enumerable: true,
2940 configurable: true
2941 });
2942 return ApplicationInitStatus;
2943}());
2944ApplicationInitStatus.decorators = [
2945 { type: Injectable },
2946];
2947/**
2948 * @nocollapse
2949 */
2950ApplicationInitStatus.ctorParameters = function () { return [
2951 { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
2952]; };
2953/**
2954 * @license
2955 * Copyright Google Inc. All Rights Reserved.
2956 *
2957 * Use of this source code is governed by an MIT-style license that can be
2958 * found in the LICENSE file at https://angular.io/license
2959 */
2960/**
2961 * A DI Token representing a unique string id assigned to the application by Angular and used
2962 * primarily for prefixing application attributes and CSS styles when
2963 * {\@link ViewEncapsulation#Emulated} is being used.
2964 *
2965 * If you need to avoid randomly generated value to be used as an application id, you can provide
2966 * a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
2967 * using this token.
2968 * \@experimental
2969 */
2970var APP_ID = new InjectionToken('AppId');
2971/**
2972 * @return {?}
2973 */
2974function _appIdRandomProviderFactory() {
2975 return "" + _randomChar() + _randomChar() + _randomChar();
2976}
2977/**
2978 * Providers that will generate a random APP_ID_TOKEN.
2979 * \@experimental
2980 */
2981var APP_ID_RANDOM_PROVIDER = {
2982 provide: APP_ID,
2983 useFactory: _appIdRandomProviderFactory,
2984 deps: [],
2985};
2986/**
2987 * @return {?}
2988 */
2989function _randomChar() {
2990 return String.fromCharCode(97 + Math.floor(Math.random() * 25));
2991}
2992/**
2993 * A function that will be executed when a platform is initialized.
2994 * \@experimental
2995 */
2996var PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
2997/**
2998 * A token that indicates an opaque platform id.
2999 * \@experimental
3000 */
3001var PLATFORM_ID = new InjectionToken('Platform ID');
3002/**
3003 * All callbacks provided via this token will be called for every component that is bootstrapped.
3004 * Signature of the callback:
3005 *
3006 * `(componentRef: ComponentRef) => void`.
3007 *
3008 * \@experimental
3009 */
3010var APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
3011/**
3012 * A token which indicates the root directory of the application
3013 * \@experimental
3014 */
3015var PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
3016/**
3017 * @license
3018 * Copyright Google Inc. All Rights Reserved.
3019 *
3020 * Use of this source code is governed by an MIT-style license that can be
3021 * found in the LICENSE file at https://angular.io/license
3022 */
3023var Console = (function () {
3024 function Console() {
3025 }
3026 /**
3027 * @param {?} message
3028 * @return {?}
3029 */
3030 Console.prototype.log = function (message) {
3031 // tslint:disable-next-line:no-console
3032 console.log(message);
3033 };
3034 /**
3035 * @param {?} message
3036 * @return {?}
3037 */
3038 Console.prototype.warn = function (message) {
3039 // tslint:disable-next-line:no-console
3040 console.warn(message);
3041 };
3042 return Console;
3043}());
3044Console.decorators = [
3045 { type: Injectable },
3046];
3047/**
3048 * @nocollapse
3049 */
3050Console.ctorParameters = function () { return []; };
3051/**
3052 * @license
3053 * Copyright Google Inc. All Rights Reserved.
3054 *
3055 * Use of this source code is governed by an MIT-style license that can be
3056 * found in the LICENSE file at https://angular.io/license
3057 */
3058/**
3059 * Combination of NgModuleFactory and ComponentFactorys.
3060 *
3061 * \@experimental
3062 */
3063var ModuleWithComponentFactories = (function () {
3064 /**
3065 * @param {?} ngModuleFactory
3066 * @param {?} componentFactories
3067 */
3068 function ModuleWithComponentFactories(ngModuleFactory, componentFactories) {
3069 this.ngModuleFactory = ngModuleFactory;
3070 this.componentFactories = componentFactories;
3071 }
3072 return ModuleWithComponentFactories;
3073}());
3074/**
3075 * @return {?}
3076 */
3077function _throwError() {
3078 throw new Error("Runtime compiler is not loaded");
3079}
3080/**
3081 * Low-level service for running the angular compiler during runtime
3082 * to create {\@link ComponentFactory}s, which
3083 * can later be used to create and render a Component instance.
3084 *
3085 * Each `\@NgModule` provides an own `Compiler` to its injector,
3086 * that will use the directives/pipes of the ng module for compilation
3087 * of components.
3088 * \@stable
3089 */
3090var Compiler = (function () {
3091 function Compiler() {
3092 }
3093 /**
3094 * Compiles the given NgModule and all of its components. All templates of the components listed
3095 * in `entryComponents` have to be inlined.
3096 * @template T
3097 * @param {?} moduleType
3098 * @return {?}
3099 */
3100 Compiler.prototype.compileModuleSync = function (moduleType) { throw _throwError(); };
3101 /**
3102 * Compiles the given NgModule and all of its components
3103 * @template T
3104 * @param {?} moduleType
3105 * @return {?}
3106 */
3107 Compiler.prototype.compileModuleAsync = function (moduleType) { throw _throwError(); };
3108 /**
3109 * Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
3110 * @template T
3111 * @param {?} moduleType
3112 * @return {?}
3113 */
3114 Compiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
3115 throw _throwError();
3116 };
3117 /**
3118 * Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
3119 * @template T
3120 * @param {?} moduleType
3121 * @return {?}
3122 */
3123 Compiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
3124 throw _throwError();
3125 };
3126 /**
3127 * Exposes the CSS-style selectors that have been used in `ngContent` directives within
3128 * the template of the given component.
3129 * This is used by the `upgrade` library to compile the appropriate transclude content
3130 * in the AngularJS wrapper component.
3131 *
3132 * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
3133 * @param {?} component
3134 * @return {?}
3135 */
3136 Compiler.prototype.getNgContentSelectors = function (component) { throw _throwError(); };
3137 /**
3138 * Clears all caches.
3139 * @return {?}
3140 */
3141 Compiler.prototype.clearCache = function () { };
3142 /**
3143 * Clears the cache for the given component/ngModule.
3144 * @param {?} type
3145 * @return {?}
3146 */
3147 Compiler.prototype.clearCacheFor = function (type) { };
3148 return Compiler;
3149}());
3150Compiler.decorators = [
3151 { type: Injectable },
3152];
3153/**
3154 * @nocollapse
3155 */
3156Compiler.ctorParameters = function () { return []; };
3157/**
3158 * Token to provide CompilerOptions in the platform injector.
3159 *
3160 * \@experimental
3161 */
3162var COMPILER_OPTIONS = new InjectionToken('compilerOptions');
3163/**
3164 * A factory for creating a Compiler
3165 *
3166 * \@experimental
3167 * @abstract
3168 */
3169var CompilerFactory = (function () {
3170 function CompilerFactory() {
3171 }
3172 /**
3173 * @abstract
3174 * @param {?=} options
3175 * @return {?}
3176 */
3177 CompilerFactory.prototype.createCompiler = function (options) { };
3178 return CompilerFactory;
3179}());
3180/**
3181 * @license
3182 * Copyright Google Inc. All Rights Reserved.
3183 *
3184 * Use of this source code is governed by an MIT-style license that can be
3185 * found in the LICENSE file at https://angular.io/license
3186 */
3187/**
3188 * Represents an instance of a Component created via a {\@link ComponentFactory}.
3189 *
3190 * `ComponentRef` provides access to the Component Instance as well other objects related to this
3191 * Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
3192 * method.
3193 * \@stable
3194 * @abstract
3195 */
3196var ComponentRef = (function () {
3197 function ComponentRef() {
3198 }
3199 /**
3200 * Location of the Host Element of this Component Instance.
3201 * @abstract
3202 * @return {?}
3203 */
3204 ComponentRef.prototype.location = function () { };
3205 /**
3206 * The injector on which the component instance exists.
3207 * @abstract
3208 * @return {?}
3209 */
3210 ComponentRef.prototype.injector = function () { };
3211 /**
3212 * The instance of the Component.
3213 * @abstract
3214 * @return {?}
3215 */
3216 ComponentRef.prototype.instance = function () { };
3217 /**
3218 * The {\@link ViewRef} of the Host View of this Component instance.
3219 * @abstract
3220 * @return {?}
3221 */
3222 ComponentRef.prototype.hostView = function () { };
3223 /**
3224 * The {\@link ChangeDetectorRef} of the Component instance.
3225 * @abstract
3226 * @return {?}
3227 */
3228 ComponentRef.prototype.changeDetectorRef = function () { };
3229 /**
3230 * The component type.
3231 * @abstract
3232 * @return {?}
3233 */
3234 ComponentRef.prototype.componentType = function () { };
3235 /**
3236 * Destroys the component instance and all of the data structures associated with it.
3237 * @abstract
3238 * @return {?}
3239 */
3240 ComponentRef.prototype.destroy = function () { };
3241 /**
3242 * Allows to register a callback that will be called when the component is destroyed.
3243 * @abstract
3244 * @param {?} callback
3245 * @return {?}
3246 */
3247 ComponentRef.prototype.onDestroy = function (callback) { };
3248 return ComponentRef;
3249}());
3250/**
3251 * \@stable
3252 * @abstract
3253 */
3254var ComponentFactory = (function () {
3255 function ComponentFactory() {
3256 }
3257 /**
3258 * @abstract
3259 * @return {?}
3260 */
3261 ComponentFactory.prototype.selector = function () { };
3262 /**
3263 * @abstract
3264 * @return {?}
3265 */
3266 ComponentFactory.prototype.componentType = function () { };
3267 /**
3268 * selector for all <ng-content> elements in the component.
3269 * @abstract
3270 * @return {?}
3271 */
3272 ComponentFactory.prototype.ngContentSelectors = function () { };
3273 /**
3274 * the inputs of the component.
3275 * @abstract
3276 * @return {?}
3277 */
3278 ComponentFactory.prototype.inputs = function () { };
3279 /**
3280 * the outputs of the component.
3281 * @abstract
3282 * @return {?}
3283 */
3284 ComponentFactory.prototype.outputs = function () { };
3285 /**
3286 * Creates a new component.
3287 * @abstract
3288 * @param {?} injector
3289 * @param {?=} projectableNodes
3290 * @param {?=} rootSelectorOrNode
3291 * @param {?=} ngModule
3292 * @return {?}
3293 */
3294 ComponentFactory.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) { };
3295 return ComponentFactory;
3296}());
3297/**
3298 * @license
3299 * Copyright Google Inc. All Rights Reserved.
3300 *
3301 * Use of this source code is governed by an MIT-style license that can be
3302 * found in the LICENSE file at https://angular.io/license
3303 */
3304/**
3305 * @param {?} component
3306 * @return {?}
3307 */
3308function noComponentFactoryError(component) {
3309 var /** @type {?} */ error = Error("No component factory found for " + stringify(component) + ". Did you add it to @NgModule.entryComponents?");
3310 ((error))[ERROR_COMPONENT] = component;
3311 return error;
3312}
3313var ERROR_COMPONENT = 'ngComponent';
3314/**
3315 * @param {?} error
3316 * @return {?}
3317 */
3318var _NullComponentFactoryResolver = (function () {
3319 function _NullComponentFactoryResolver() {
3320 }
3321 /**
3322 * @template T
3323 * @param {?} component
3324 * @return {?}
3325 */
3326 _NullComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
3327 throw noComponentFactoryError(component);
3328 };
3329 return _NullComponentFactoryResolver;
3330}());
3331/**
3332 * \@stable
3333 * @abstract
3334 */
3335var ComponentFactoryResolver = (function () {
3336 function ComponentFactoryResolver() {
3337 }
3338 /**
3339 * @abstract
3340 * @template T
3341 * @param {?} component
3342 * @return {?}
3343 */
3344 ComponentFactoryResolver.prototype.resolveComponentFactory = function (component) { };
3345 return ComponentFactoryResolver;
3346}());
3347ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
3348var CodegenComponentFactoryResolver = (function () {
3349 /**
3350 * @param {?} factories
3351 * @param {?} _parent
3352 * @param {?} _ngModule
3353 */
3354 function CodegenComponentFactoryResolver(factories, _parent, _ngModule) {
3355 this._parent = _parent;
3356 this._ngModule = _ngModule;
3357 this._factories = new Map();
3358 for (var i = 0; i < factories.length; i++) {
3359 var factory = factories[i];
3360 this._factories.set(factory.componentType, factory);
3361 }
3362 }
3363 /**
3364 * @template T
3365 * @param {?} component
3366 * @return {?}
3367 */
3368 CodegenComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
3369 var /** @type {?} */ factory = this._factories.get(component) || this._parent.resolveComponentFactory(component);
3370 return new ComponentFactoryBoundToModule(factory, this._ngModule);
3371 };
3372 return CodegenComponentFactoryResolver;
3373}());
3374var ComponentFactoryBoundToModule = (function (_super) {
3375 __extends(ComponentFactoryBoundToModule, _super);
3376 /**
3377 * @param {?} factory
3378 * @param {?} ngModule
3379 */
3380 function ComponentFactoryBoundToModule(factory, ngModule) {
3381 var _this = _super.call(this) || this;
3382 _this.factory = factory;
3383 _this.ngModule = ngModule;
3384 return _this;
3385 }
3386 Object.defineProperty(ComponentFactoryBoundToModule.prototype, "selector", {
3387 /**
3388 * @return {?}
3389 */
3390 get: function () { return this.factory.selector; },
3391 enumerable: true,
3392 configurable: true
3393 });
3394 Object.defineProperty(ComponentFactoryBoundToModule.prototype, "componentType", {
3395 /**
3396 * @return {?}
3397 */
3398 get: function () { return this.factory.componentType; },
3399 enumerable: true,
3400 configurable: true
3401 });
3402 Object.defineProperty(ComponentFactoryBoundToModule.prototype, "ngContentSelectors", {
3403 /**
3404 * @return {?}
3405 */
3406 get: function () { return this.factory.ngContentSelectors; },
3407 enumerable: true,
3408 configurable: true
3409 });
3410 Object.defineProperty(ComponentFactoryBoundToModule.prototype, "inputs", {
3411 /**
3412 * @return {?}
3413 */
3414 get: function () { return this.factory.inputs; },
3415 enumerable: true,
3416 configurable: true
3417 });
3418 Object.defineProperty(ComponentFactoryBoundToModule.prototype, "outputs", {
3419 /**
3420 * @return {?}
3421 */
3422 get: function () { return this.factory.outputs; },
3423 enumerable: true,
3424 configurable: true
3425 });
3426 /**
3427 * @param {?} injector
3428 * @param {?=} projectableNodes
3429 * @param {?=} rootSelectorOrNode
3430 * @param {?=} ngModule
3431 * @return {?}
3432 */
3433 ComponentFactoryBoundToModule.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
3434 return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
3435 };
3436 return ComponentFactoryBoundToModule;
3437}(ComponentFactory));
3438/**
3439 * @license
3440 * Copyright Google Inc. All Rights Reserved.
3441 *
3442 * Use of this source code is governed by an MIT-style license that can be
3443 * found in the LICENSE file at https://angular.io/license
3444 */
3445/**
3446 * Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
3447 *
3448 * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
3449 * NgModule Instance.
3450 *
3451 * \@stable
3452 * @abstract
3453 */
3454var NgModuleRef = (function () {
3455 function NgModuleRef() {
3456 }
3457 /**
3458 * The injector that contains all of the providers of the NgModule.
3459 * @abstract
3460 * @return {?}
3461 */
3462 NgModuleRef.prototype.injector = function () { };
3463 /**
3464 * The ComponentFactoryResolver to get hold of the ComponentFactories
3465 * declared in the `entryComponents` property of the module.
3466 * @abstract
3467 * @return {?}
3468 */
3469 NgModuleRef.prototype.componentFactoryResolver = function () { };
3470 /**
3471 * The NgModule instance.
3472 * @abstract
3473 * @return {?}
3474 */
3475 NgModuleRef.prototype.instance = function () { };
3476 /**
3477 * Destroys the module instance and all of the data structures associated with it.
3478 * @abstract
3479 * @return {?}
3480 */
3481 NgModuleRef.prototype.destroy = function () { };
3482 /**
3483 * Allows to register a callback that will be called when the module is destroyed.
3484 * @abstract
3485 * @param {?} callback
3486 * @return {?}
3487 */
3488 NgModuleRef.prototype.onDestroy = function (callback) { };
3489 return NgModuleRef;
3490}());
3491/**
3492 * \@experimental
3493 */
3494var NgModuleFactory = (function () {
3495 /**
3496 * @param {?} _injectorClass
3497 * @param {?} _moduleType
3498 */
3499 function NgModuleFactory(_injectorClass, _moduleType) {
3500 this._injectorClass = _injectorClass;
3501 this._moduleType = _moduleType;
3502 }
3503 Object.defineProperty(NgModuleFactory.prototype, "moduleType", {
3504 /**
3505 * @return {?}
3506 */
3507 get: function () { return this._moduleType; },
3508 enumerable: true,
3509 configurable: true
3510 });
3511 /**
3512 * @param {?} parentInjector
3513 * @return {?}
3514 */
3515 NgModuleFactory.prototype.create = function (parentInjector) {
3516 var /** @type {?} */ instance = new this._injectorClass(parentInjector || Injector.NULL);
3517 instance.create();
3518 return instance;
3519 };
3520 return NgModuleFactory;
3521}());
3522var _UNDEFINED = new Object();
3523/**
3524 * @abstract
3525 */
3526var NgModuleInjector = (function () {
3527 /**
3528 * @param {?} parent
3529 * @param {?} factories
3530 * @param {?} bootstrapFactories
3531 */
3532 function NgModuleInjector(parent, factories, bootstrapFactories) {
3533 var _this = this;
3534 this.parent = parent;
3535 this._destroyListeners = [];
3536 this._destroyed = false;
3537 this.bootstrapFactories =
3538 bootstrapFactories.map(function (f) { return new ComponentFactoryBoundToModule(f, _this); });
3539 this._cmpFactoryResolver = new CodegenComponentFactoryResolver(factories, parent.get(ComponentFactoryResolver, ComponentFactoryResolver.NULL), this);
3540 }
3541 /**
3542 * @return {?}
3543 */
3544 NgModuleInjector.prototype.create = function () { this.instance = this.createInternal(); };
3545 /**
3546 * @abstract
3547 * @return {?}
3548 */
3549 NgModuleInjector.prototype.createInternal = function () { };
3550 /**
3551 * @param {?} token
3552 * @param {?=} notFoundValue
3553 * @return {?}
3554 */
3555 NgModuleInjector.prototype.get = function (token, notFoundValue) {
3556 if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
3557 if (token === Injector || token === NgModuleRef) {
3558 return this;
3559 }
3560 if (token === ComponentFactoryResolver) {
3561 return this._cmpFactoryResolver;
3562 }
3563 var /** @type {?} */ result = this.getInternal(token, _UNDEFINED);
3564 return result === _UNDEFINED ? this.parent.get(token, notFoundValue) : result;
3565 };
3566 /**
3567 * @abstract
3568 * @param {?} token
3569 * @param {?} notFoundValue
3570 * @return {?}
3571 */
3572 NgModuleInjector.prototype.getInternal = function (token, notFoundValue) { };
3573 Object.defineProperty(NgModuleInjector.prototype, "injector", {
3574 /**
3575 * @return {?}
3576 */
3577 get: function () { return this; },
3578 enumerable: true,
3579 configurable: true
3580 });
3581 Object.defineProperty(NgModuleInjector.prototype, "componentFactoryResolver", {
3582 /**
3583 * @return {?}
3584 */
3585 get: function () { return this._cmpFactoryResolver; },
3586 enumerable: true,
3587 configurable: true
3588 });
3589 /**
3590 * @return {?}
3591 */
3592 NgModuleInjector.prototype.destroy = function () {
3593 if (this._destroyed) {
3594 throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
3595 }
3596 this._destroyed = true;
3597 this.destroyInternal();
3598 this._destroyListeners.forEach(function (listener) { return listener(); });
3599 };
3600 /**
3601 * @param {?} callback
3602 * @return {?}
3603 */
3604 NgModuleInjector.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
3605 /**
3606 * @abstract
3607 * @return {?}
3608 */
3609 NgModuleInjector.prototype.destroyInternal = function () { };
3610 return NgModuleInjector;
3611}());
3612/**
3613 * @license
3614 * Copyright Google Inc. All Rights Reserved.
3615 *
3616 * Use of this source code is governed by an MIT-style license that can be
3617 * found in the LICENSE file at https://angular.io/license
3618 */
3619var trace;
3620var events;
3621/**
3622 * @return {?}
3623 */
3624function detectWTF() {
3625 var /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
3626 if (wtf) {
3627 trace = wtf['trace'];
3628 if (trace) {
3629 events = trace['events'];
3630 return true;
3631 }
3632 }
3633 return false;
3634}
3635/**
3636 * @param {?} signature
3637 * @param {?=} flags
3638 * @return {?}
3639 */
3640function createScope$1(signature, flags) {
3641 if (flags === void 0) { flags = null; }
3642 return events.createScope(signature, flags);
3643}
3644/**
3645 * @template T
3646 * @param {?} scope
3647 * @param {?=} returnValue
3648 * @return {?}
3649 */
3650function leave(scope, returnValue) {
3651 trace.leaveScope(scope, returnValue);
3652 return returnValue;
3653}
3654/**
3655 * @param {?} rangeType
3656 * @param {?} action
3657 * @return {?}
3658 */
3659function startTimeRange(rangeType, action) {
3660 return trace.beginTimeRange(rangeType, action);
3661}
3662/**
3663 * @param {?} range
3664 * @return {?}
3665 */
3666function endTimeRange(range) {
3667 trace.endTimeRange(range);
3668}
3669/**
3670 * @license
3671 * Copyright Google Inc. All Rights Reserved.
3672 *
3673 * Use of this source code is governed by an MIT-style license that can be
3674 * found in the LICENSE file at https://angular.io/license
3675 */
3676/**
3677 * True if WTF is enabled.
3678 */
3679var wtfEnabled = detectWTF();
3680/**
3681 * @param {?=} arg0
3682 * @param {?=} arg1
3683 * @return {?}
3684 */
3685function noopScope(arg0, arg1) {
3686 return null;
3687}
3688/**
3689 * Create trace scope.
3690 *
3691 * Scopes must be strictly nested and are analogous to stack frames, but
3692 * do not have to follow the stack frames. Instead it is recommended that they follow logical
3693 * nesting. You may want to use
3694 * [Event
3695 * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
3696 * as they are defined in WTF.
3697 *
3698 * Used to mark scope entry. The return value is used to leave the scope.
3699 *
3700 * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
3701 *
3702 * someMethod() {
3703 * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
3704 * // DO SOME WORK HERE
3705 * return wtfLeave(s, 123); // Return value 123
3706 * }
3707 *
3708 * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
3709 * negatively impact the performance of your application. For this reason we recommend that
3710 * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
3711 * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
3712 * exception, will produce incorrect trace, but presence of exception signifies logic error which
3713 * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
3714 * an exception is expected during normal execution while profiling.
3715 *
3716 * \@experimental
3717 */
3718var wtfCreateScope = wtfEnabled ? createScope$1 : function (signature, flags) { return noopScope; };
3719/**
3720 * Used to mark end of Scope.
3721 *
3722 * - `scope` to end.
3723 * - `returnValue` (optional) to be passed to the WTF.
3724 *
3725 * Returns the `returnValue for easy chaining.
3726 * \@experimental
3727 */
3728var wtfLeave = wtfEnabled ? leave : function (s, r) { return r; };
3729/**
3730 * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
3731 * The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
3732 * enabled.
3733 *
3734 * someMethod() {
3735 * var s = wtfStartTimeRange('HTTP:GET', 'some.url');
3736 * var future = new Future.delay(5).then((_) {
3737 * wtfEndTimeRange(s);
3738 * });
3739 * }
3740 * \@experimental
3741 */
3742var wtfStartTimeRange = wtfEnabled ? startTimeRange : function (rangeType, action) { return null; };
3743/**
3744 * Ends a async time range operation.
3745 * [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
3746 * enabled.
3747 * \@experimental
3748 */
3749var wtfEndTimeRange = wtfEnabled ? endTimeRange : function (r) { return null; };
3750/**
3751 * @license
3752 * Copyright Google Inc. All Rights Reserved.
3753 *
3754 * Use of this source code is governed by an MIT-style license that can be
3755 * found in the LICENSE file at https://angular.io/license
3756 */
3757/**
3758 * Use by directives and components to emit custom Events.
3759 *
3760 * ### Examples
3761 *
3762 * In the following example, `Zippy` alternatively emits `open` and `close` events when its
3763 * title gets clicked:
3764 *
3765 * ```
3766 * \@Component({
3767 * selector: 'zippy',
3768 * template: `
3769 * <div class="zippy">
3770 * <div (click)="toggle()">Toggle</div>
3771 * <div [hidden]="!visible">
3772 * <ng-content></ng-content>
3773 * </div>
3774 * </div>`})
3775 * export class Zippy {
3776 * visible: boolean = true;
3777 * \@Output() open: EventEmitter<any> = new EventEmitter();
3778 * \@Output() close: EventEmitter<any> = new EventEmitter();
3779 *
3780 * toggle() {
3781 * this.visible = !this.visible;
3782 * if (this.visible) {
3783 * this.open.emit(null);
3784 * } else {
3785 * this.close.emit(null);
3786 * }
3787 * }
3788 * }
3789 * ```
3790 *
3791 * The events payload can be accessed by the parameter `$event` on the components output event
3792 * handler:
3793 *
3794 * ```
3795 * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
3796 * ```
3797 *
3798 * Uses Rx.Observable but provides an adapter to make it work as specified here:
3799 * https://github.com/jhusain/observable-spec
3800 *
3801 * Once a reference implementation of the spec is available, switch to it.
3802 * \@stable
3803 */
3804var EventEmitter = (function (_super) {
3805 __extends(EventEmitter, _super);
3806 /**
3807 * Creates an instance of [EventEmitter], which depending on [isAsync],
3808 * delivers events synchronously or asynchronously.
3809 * @param {?=} isAsync
3810 */
3811 function EventEmitter(isAsync) {
3812 if (isAsync === void 0) { isAsync = false; }
3813 var _this = _super.call(this) || this;
3814 _this.__isAsync = isAsync;
3815 return _this;
3816 }
3817 /**
3818 * @param {?=} value
3819 * @return {?}
3820 */
3821 EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
3822 /**
3823 * @param {?=} generatorOrNext
3824 * @param {?=} error
3825 * @param {?=} complete
3826 * @return {?}
3827 */
3828 EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
3829 var /** @type {?} */ schedulerFn;
3830 var /** @type {?} */ errorFn = function (err) { return null; };
3831 var /** @type {?} */ completeFn = function () { return null; };
3832 if (generatorOrNext && typeof generatorOrNext === 'object') {
3833 schedulerFn = this.__isAsync ? function (value) {
3834 setTimeout(function () { return generatorOrNext.next(value); });
3835 } : function (value) { generatorOrNext.next(value); };
3836 if (generatorOrNext.error) {
3837 errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
3838 function (err) { generatorOrNext.error(err); };
3839 }
3840 if (generatorOrNext.complete) {
3841 completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
3842 function () { generatorOrNext.complete(); };
3843 }
3844 }
3845 else {
3846 schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
3847 function (value) { generatorOrNext(value); };
3848 if (error) {
3849 errorFn =
3850 this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
3851 }
3852 if (complete) {
3853 completeFn =
3854 this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
3855 }
3856 }
3857 return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
3858 };
3859 return EventEmitter;
3860}(rxjs_Subject.Subject));
3861/**
3862 * @license
3863 * Copyright Google Inc. All Rights Reserved.
3864 *
3865 * Use of this source code is governed by an MIT-style license that can be
3866 * found in the LICENSE file at https://angular.io/license
3867 */
3868/**
3869 * An injectable service for executing work inside or outside of the Angular zone.
3870 *
3871 * The most common use of this service is to optimize performance when starting a work consisting of
3872 * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
3873 * Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
3874 * can reenter the Angular zone via {\@link #run}.
3875 *
3876 * <!-- TODO: add/fix links to:
3877 * - docs explaining zones and the use of zones in Angular and change-detection
3878 * - link to runOutsideAngular/run (throughout this file!)
3879 * -->
3880 *
3881 * ### Example
3882 *
3883 * ```
3884 * import {Component, NgZone} from '\@angular/core';
3885 * import {NgIf} from '\@angular/common';
3886 *
3887 * \@Component({
3888 * selector: 'ng-zone-demo'.
3889 * template: `
3890 * <h2>Demo: NgZone</h2>
3891 *
3892 * <p>Progress: {{progress}}%</p>
3893 * <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
3894 *
3895 * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
3896 * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
3897 * `,
3898 * })
3899 * export class NgZoneDemo {
3900 * progress: number = 0;
3901 * label: string;
3902 *
3903 * constructor(private _ngZone: NgZone) {}
3904 *
3905 * // Loop inside the Angular zone
3906 * // so the UI DOES refresh after each setTimeout cycle
3907 * processWithinAngularZone() {
3908 * this.label = 'inside';
3909 * this.progress = 0;
3910 * this._increaseProgress(() => console.log('Inside Done!'));
3911 * }
3912 *
3913 * // Loop outside of the Angular zone
3914 * // so the UI DOES NOT refresh after each setTimeout cycle
3915 * processOutsideOfAngularZone() {
3916 * this.label = 'outside';
3917 * this.progress = 0;
3918 * this._ngZone.runOutsideAngular(() => {
3919 * this._increaseProgress(() => {
3920 * // reenter the Angular zone and display done
3921 * this._ngZone.run(() => {console.log('Outside Done!') });
3922 * }}));
3923 * }
3924 *
3925 * _increaseProgress(doneCallback: () => void) {
3926 * this.progress += 1;
3927 * console.log(`Current progress: ${this.progress}%`);
3928 *
3929 * if (this.progress < 100) {
3930 * window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
3931 * } else {
3932 * doneCallback();
3933 * }
3934 * }
3935 * }
3936 * ```
3937 *
3938 * \@experimental
3939 */
3940var NgZone = (function () {
3941 /**
3942 * @param {?} __0
3943 */
3944 function NgZone(_a) {
3945 var _b = _a.enableLongStackTrace, enableLongStackTrace = _b === void 0 ? false : _b;
3946 this._hasPendingMicrotasks = false;
3947 this._hasPendingMacrotasks = false;
3948 this._isStable = true;
3949 this._nesting = 0;
3950 this._onUnstable = new EventEmitter(false);
3951 this._onMicrotaskEmpty = new EventEmitter(false);
3952 this._onStable = new EventEmitter(false);
3953 this._onErrorEvents = new EventEmitter(false);
3954 if (typeof Zone == 'undefined') {
3955 throw new Error('Angular requires Zone.js prolyfill.');
3956 }
3957 Zone.assertZonePatched();
3958 this.outer = this.inner = Zone.current;
3959 if (Zone['wtfZoneSpec']) {
3960 this.inner = this.inner.fork(Zone['wtfZoneSpec']);
3961 }
3962 if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
3963 this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']);
3964 }
3965 this.forkInnerZoneWithAngularBehavior();
3966 }
3967 /**
3968 * @return {?}
3969 */
3970 NgZone.isInAngularZone = function () { return Zone.current.get('isAngularZone') === true; };
3971 /**
3972 * @return {?}
3973 */
3974 NgZone.assertInAngularZone = function () {
3975 if (!NgZone.isInAngularZone()) {
3976 throw new Error('Expected to be in Angular Zone, but it is not!');
3977 }
3978 };
3979 /**
3980 * @return {?}
3981 */
3982 NgZone.assertNotInAngularZone = function () {
3983 if (NgZone.isInAngularZone()) {
3984 throw new Error('Expected to not be in Angular Zone, but it is!');
3985 }
3986 };
3987 /**
3988 * Executes the `fn` function synchronously within the Angular zone and returns value returned by
3989 * the function.
3990 *
3991 * Running functions via `run` allows you to reenter Angular zone from a task that was executed
3992 * outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
3993 *
3994 * Any future tasks or microtasks scheduled from within this function will continue executing from
3995 * within the Angular zone.
3996 *
3997 * If a synchronous error happens it will be rethrown and not reported via `onError`.
3998 * @param {?} fn
3999 * @return {?}
4000 */
4001 NgZone.prototype.run = function (fn) { return this.inner.run(fn); };
4002 /**
4003 * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
4004 * rethrown.
4005 * @param {?} fn
4006 * @return {?}
4007 */
4008 NgZone.prototype.runGuarded = function (fn) { return this.inner.runGuarded(fn); };
4009 /**
4010 * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
4011 * the function.
4012 *
4013 * Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
4014 * work that
4015 * doesn't trigger Angular change-detection or is subject to Angular's error handling.
4016 *
4017 * Any future tasks or microtasks scheduled from within this function will continue executing from
4018 * outside of the Angular zone.
4019 *
4020 * Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
4021 * @param {?} fn
4022 * @return {?}
4023 */
4024 NgZone.prototype.runOutsideAngular = function (fn) { return this.outer.run(fn); };
4025 Object.defineProperty(NgZone.prototype, "onUnstable", {
4026 /**
4027 * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
4028 * @return {?}
4029 */
4030 get: function () { return this._onUnstable; },
4031 enumerable: true,
4032 configurable: true
4033 });
4034 Object.defineProperty(NgZone.prototype, "onMicrotaskEmpty", {
4035 /**
4036 * Notifies when there is no more microtasks enqueue in the current VM Turn.
4037 * This is a hint for Angular to do change detection, which may enqueue more microtasks.
4038 * For this reason this event can fire multiple times per VM Turn.
4039 * @return {?}
4040 */
4041 get: function () { return this._onMicrotaskEmpty; },
4042 enumerable: true,
4043 configurable: true
4044 });
4045 Object.defineProperty(NgZone.prototype, "onStable", {
4046 /**
4047 * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
4048 * implies we are about to relinquish VM turn.
4049 * This event gets called just once.
4050 * @return {?}
4051 */
4052 get: function () { return this._onStable; },
4053 enumerable: true,
4054 configurable: true
4055 });
4056 Object.defineProperty(NgZone.prototype, "onError", {
4057 /**
4058 * Notify that an error has been delivered.
4059 * @return {?}
4060 */
4061 get: function () { return this._onErrorEvents; },
4062 enumerable: true,
4063 configurable: true
4064 });
4065 Object.defineProperty(NgZone.prototype, "isStable", {
4066 /**
4067 * Whether there are no outstanding microtasks or macrotasks.
4068 * @return {?}
4069 */
4070 get: function () { return this._isStable; },
4071 enumerable: true,
4072 configurable: true
4073 });
4074 Object.defineProperty(NgZone.prototype, "hasPendingMicrotasks", {
4075 /**
4076 * @return {?}
4077 */
4078 get: function () { return this._hasPendingMicrotasks; },
4079 enumerable: true,
4080 configurable: true
4081 });
4082 Object.defineProperty(NgZone.prototype, "hasPendingMacrotasks", {
4083 /**
4084 * @return {?}
4085 */
4086 get: function () { return this._hasPendingMacrotasks; },
4087 enumerable: true,
4088 configurable: true
4089 });
4090 /**
4091 * @return {?}
4092 */
4093 NgZone.prototype.checkStable = function () {
4094 var _this = this;
4095 if (this._nesting == 0 && !this._hasPendingMicrotasks && !this._isStable) {
4096 try {
4097 this._nesting++;
4098 this._onMicrotaskEmpty.emit(null);
4099 }
4100 finally {
4101 this._nesting--;
4102 if (!this._hasPendingMicrotasks) {
4103 try {
4104 this.runOutsideAngular(function () { return _this._onStable.emit(null); });
4105 }
4106 finally {
4107 this._isStable = true;
4108 }
4109 }
4110 }
4111 }
4112 };
4113 /**
4114 * @return {?}
4115 */
4116 NgZone.prototype.forkInnerZoneWithAngularBehavior = function () {
4117 var _this = this;
4118 this.inner = this.inner.fork({
4119 name: 'angular',
4120 properties: /** @type {?} */ ({ 'isAngularZone': true }),
4121 onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
4122 try {
4123 _this.onEnter();
4124 return delegate.invokeTask(target, task, applyThis, applyArgs);
4125 }
4126 finally {
4127 _this.onLeave();
4128 }
4129 },
4130 onInvoke: function (delegate, current, target, callback, applyThis, applyArgs, source) {
4131 try {
4132 _this.onEnter();
4133 return delegate.invoke(target, callback, applyThis, applyArgs, source);
4134 }
4135 finally {
4136 _this.onLeave();
4137 }
4138 },
4139 onHasTask: function (delegate, current, target, hasTaskState) {
4140 delegate.hasTask(target, hasTaskState);
4141 if (current === target) {
4142 // We are only interested in hasTask events which originate from our zone
4143 // (A child hasTask event is not interesting to us)
4144 if (hasTaskState.change == 'microTask') {
4145 _this.setHasMicrotask(hasTaskState.microTask);
4146 }
4147 else if (hasTaskState.change == 'macroTask') {
4148 _this.setHasMacrotask(hasTaskState.macroTask);
4149 }
4150 }
4151 },
4152 onHandleError: function (delegate, current, target, error) {
4153 delegate.handleError(target, error);
4154 _this.triggerError(error);
4155 return false;
4156 }
4157 });
4158 };
4159 /**
4160 * @return {?}
4161 */
4162 NgZone.prototype.onEnter = function () {
4163 this._nesting++;
4164 if (this._isStable) {
4165 this._isStable = false;
4166 this._onUnstable.emit(null);
4167 }
4168 };
4169 /**
4170 * @return {?}
4171 */
4172 NgZone.prototype.onLeave = function () {
4173 this._nesting--;
4174 this.checkStable();
4175 };
4176 /**
4177 * @param {?} hasMicrotasks
4178 * @return {?}
4179 */
4180 NgZone.prototype.setHasMicrotask = function (hasMicrotasks) {
4181 this._hasPendingMicrotasks = hasMicrotasks;
4182 this.checkStable();
4183 };
4184 /**
4185 * @param {?} hasMacrotasks
4186 * @return {?}
4187 */
4188 NgZone.prototype.setHasMacrotask = function (hasMacrotasks) { this._hasPendingMacrotasks = hasMacrotasks; };
4189 /**
4190 * @param {?} error
4191 * @return {?}
4192 */
4193 NgZone.prototype.triggerError = function (error) { this._onErrorEvents.emit(error); };
4194 return NgZone;
4195}());
4196/**
4197 * @license
4198 * Copyright Google Inc. All Rights Reserved.
4199 *
4200 * Use of this source code is governed by an MIT-style license that can be
4201 * found in the LICENSE file at https://angular.io/license
4202 */
4203/**
4204 * The Testability service provides testing hooks that can be accessed from
4205 * the browser and by services such as Protractor. Each bootstrapped Angular
4206 * application on the page will have an instance of Testability.
4207 * \@experimental
4208 */
4209var Testability = (function () {
4210 /**
4211 * @param {?} _ngZone
4212 */
4213 function Testability(_ngZone) {
4214 this._ngZone = _ngZone;
4215 /**
4216 * \@internal
4217 */
4218 this._pendingCount = 0;
4219 /**
4220 * \@internal
4221 */
4222 this._isZoneStable = true;
4223 /**
4224 * Whether any work was done since the last 'whenStable' callback. This is
4225 * useful to detect if this could have potentially destabilized another
4226 * component while it is stabilizing.
4227 * \@internal
4228 */
4229 this._didWork = false;
4230 /**
4231 * \@internal
4232 */
4233 this._callbacks = [];
4234 this._watchAngularEvents();
4235 }
4236 /**
4237 * \@internal
4238 * @return {?}
4239 */
4240 Testability.prototype._watchAngularEvents = function () {
4241 var _this = this;
4242 this._ngZone.onUnstable.subscribe({
4243 next: function () {
4244 _this._didWork = true;
4245 _this._isZoneStable = false;
4246 }
4247 });
4248 this._ngZone.runOutsideAngular(function () {
4249 _this._ngZone.onStable.subscribe({
4250 next: function () {
4251 NgZone.assertNotInAngularZone();
4252 scheduleMicroTask(function () {
4253 _this._isZoneStable = true;
4254 _this._runCallbacksIfReady();
4255 });
4256 }
4257 });
4258 });
4259 };
4260 /**
4261 * @return {?}
4262 */
4263 Testability.prototype.increasePendingRequestCount = function () {
4264 this._pendingCount += 1;
4265 this._didWork = true;
4266 return this._pendingCount;
4267 };
4268 /**
4269 * @return {?}
4270 */
4271 Testability.prototype.decreasePendingRequestCount = function () {
4272 this._pendingCount -= 1;
4273 if (this._pendingCount < 0) {
4274 throw new Error('pending async requests below zero');
4275 }
4276 this._runCallbacksIfReady();
4277 return this._pendingCount;
4278 };
4279 /**
4280 * @return {?}
4281 */
4282 Testability.prototype.isStable = function () {
4283 return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
4284 };
4285 /**
4286 * \@internal
4287 * @return {?}
4288 */
4289 Testability.prototype._runCallbacksIfReady = function () {
4290 var _this = this;
4291 if (this.isStable()) {
4292 // Schedules the call backs in a new frame so that it is always async.
4293 scheduleMicroTask(function () {
4294 while (_this._callbacks.length !== 0) {
4295 (((_this._callbacks.pop())))(_this._didWork);
4296 }
4297 _this._didWork = false;
4298 });
4299 }
4300 else {
4301 // Not Ready
4302 this._didWork = true;
4303 }
4304 };
4305 /**
4306 * @param {?} callback
4307 * @return {?}
4308 */
4309 Testability.prototype.whenStable = function (callback) {
4310 this._callbacks.push(callback);
4311 this._runCallbacksIfReady();
4312 };
4313 /**
4314 * @return {?}
4315 */
4316 Testability.prototype.getPendingRequestCount = function () { return this._pendingCount; };
4317 /**
4318 * @deprecated use findProviders
4319 * @param {?} using
4320 * @param {?} provider
4321 * @param {?} exactMatch
4322 * @return {?}
4323 */
4324 Testability.prototype.findBindings = function (using, provider, exactMatch) {
4325 // TODO(juliemr): implement.
4326 return [];
4327 };
4328 /**
4329 * @param {?} using
4330 * @param {?} provider
4331 * @param {?} exactMatch
4332 * @return {?}
4333 */
4334 Testability.prototype.findProviders = function (using, provider, exactMatch) {
4335 // TODO(juliemr): implement.
4336 return [];
4337 };
4338 return Testability;
4339}());
4340Testability.decorators = [
4341 { type: Injectable },
4342];
4343/**
4344 * @nocollapse
4345 */
4346Testability.ctorParameters = function () { return [
4347 { type: NgZone, },
4348]; };
4349/**
4350 * A global registry of {\@link Testability} instances for specific elements.
4351 * \@experimental
4352 */
4353var TestabilityRegistry = (function () {
4354 function TestabilityRegistry() {
4355 /**
4356 * \@internal
4357 */
4358 this._applications = new Map();
4359 _testabilityGetter.addToWindow(this);
4360 }
4361 /**
4362 * @param {?} token
4363 * @param {?} testability
4364 * @return {?}
4365 */
4366 TestabilityRegistry.prototype.registerApplication = function (token, testability) {
4367 this._applications.set(token, testability);
4368 };
4369 /**
4370 * @param {?} elem
4371 * @return {?}
4372 */
4373 TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem) || null; };
4374 /**
4375 * @return {?}
4376 */
4377 TestabilityRegistry.prototype.getAllTestabilities = function () { return Array.from(this._applications.values()); };
4378 /**
4379 * @return {?}
4380 */
4381 TestabilityRegistry.prototype.getAllRootElements = function () { return Array.from(this._applications.keys()); };
4382 /**
4383 * @param {?} elem
4384 * @param {?=} findInAncestors
4385 * @return {?}
4386 */
4387 TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
4388 if (findInAncestors === void 0) { findInAncestors = true; }
4389 return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
4390 };
4391 return TestabilityRegistry;
4392}());
4393TestabilityRegistry.decorators = [
4394 { type: Injectable },
4395];
4396/**
4397 * @nocollapse
4398 */
4399TestabilityRegistry.ctorParameters = function () { return []; };
4400var _NoopGetTestability = (function () {
4401 function _NoopGetTestability() {
4402 }
4403 /**
4404 * @param {?} registry
4405 * @return {?}
4406 */
4407 _NoopGetTestability.prototype.addToWindow = function (registry) { };
4408 /**
4409 * @param {?} registry
4410 * @param {?} elem
4411 * @param {?} findInAncestors
4412 * @return {?}
4413 */
4414 _NoopGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
4415 return null;
4416 };
4417 return _NoopGetTestability;
4418}());
4419/**
4420 * Set the {\@link GetTestability} implementation used by the Angular testing framework.
4421 * \@experimental
4422 * @param {?} getter
4423 * @return {?}
4424 */
4425function setTestabilityGetter(getter) {
4426 _testabilityGetter = getter;
4427}
4428var _testabilityGetter = new _NoopGetTestability();
4429/**
4430 * @license
4431 * Copyright Google Inc. All Rights Reserved.
4432 *
4433 * Use of this source code is governed by an MIT-style license that can be
4434 * found in the LICENSE file at https://angular.io/license
4435 */
4436var _devMode = true;
4437var _runModeLocked = false;
4438var _platform;
4439var ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
4440/**
4441 * Disable Angular's development mode, which turns off assertions and other
4442 * checks within the framework.
4443 *
4444 * One important assertion this disables verifies that a change detection pass
4445 * does not result in additional changes to any bindings (also known as
4446 * unidirectional data flow).
4447 *
4448 * \@stable
4449 * @return {?}
4450 */
4451function enableProdMode() {
4452 if (_runModeLocked) {
4453 throw new Error('Cannot enable prod mode after platform setup.');
4454 }
4455 _devMode = false;
4456}
4457/**
4458 * Returns whether Angular is in development mode. After called once,
4459 * the value is locked and won't change any more.
4460 *
4461 * By default, this is true, unless a user calls `enableProdMode` before calling this.
4462 *
4463 * \@experimental APIs related to application bootstrap are currently under review.
4464 * @return {?}
4465 */
4466function isDevMode() {
4467 _runModeLocked = true;
4468 return _devMode;
4469}
4470/**
4471 * A token for third-party components that can register themselves with NgProbe.
4472 *
4473 * \@experimental
4474 */
4475var NgProbeToken = (function () {
4476 /**
4477 * @param {?} name
4478 * @param {?} token
4479 */
4480 function NgProbeToken(name, token) {
4481 this.name = name;
4482 this.token = token;
4483 }
4484 return NgProbeToken;
4485}());
4486/**
4487 * Creates a platform.
4488 * Platforms have to be eagerly created via this function.
4489 *
4490 * \@experimental APIs related to application bootstrap are currently under review.
4491 * @param {?} injector
4492 * @return {?}
4493 */
4494function createPlatform(injector) {
4495 if (_platform && !_platform.destroyed &&
4496 !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4497 throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
4498 }
4499 _platform = injector.get(PlatformRef);
4500 var /** @type {?} */ inits = injector.get(PLATFORM_INITIALIZER, null);
4501 if (inits)
4502 inits.forEach(function (init) { return init(); });
4503 return _platform;
4504}
4505/**
4506 * Creates a factory for a platform
4507 *
4508 * \@experimental APIs related to application bootstrap are currently under review.
4509 * @param {?} parentPlatformFactory
4510 * @param {?} name
4511 * @param {?=} providers
4512 * @return {?}
4513 */
4514function createPlatformFactory(parentPlatformFactory, name, providers) {
4515 if (providers === void 0) { providers = []; }
4516 var /** @type {?} */ marker = new InjectionToken("Platform: " + name);
4517 return function (extraProviders) {
4518 if (extraProviders === void 0) { extraProviders = []; }
4519 var /** @type {?} */ platform = getPlatform();
4520 if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4521 if (parentPlatformFactory) {
4522 parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
4523 }
4524 else {
4525 createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
4526 }
4527 }
4528 return assertPlatform(marker);
4529 };
4530}
4531/**
4532 * Checks that there currently is a platform which contains the given token as a provider.
4533 *
4534 * \@experimental APIs related to application bootstrap are currently under review.
4535 * @param {?} requiredToken
4536 * @return {?}
4537 */
4538function assertPlatform(requiredToken) {
4539 var /** @type {?} */ platform = getPlatform();
4540 if (!platform) {
4541 throw new Error('No platform exists!');
4542 }
4543 if (!platform.injector.get(requiredToken, null)) {
4544 throw new Error('A platform with a different configuration has been created. Please destroy it first.');
4545 }
4546 return platform;
4547}
4548/**
4549 * Destroy the existing platform.
4550 *
4551 * \@experimental APIs related to application bootstrap are currently under review.
4552 * @return {?}
4553 */
4554function destroyPlatform() {
4555 if (_platform && !_platform.destroyed) {
4556 _platform.destroy();
4557 }
4558}
4559/**
4560 * Returns the current platform.
4561 *
4562 * \@experimental APIs related to application bootstrap are currently under review.
4563 * @return {?}
4564 */
4565function getPlatform() {
4566 return _platform && !_platform.destroyed ? _platform : null;
4567}
4568/**
4569 * The Angular platform is the entry point for Angular on a web page. Each page
4570 * has exactly one platform, and services (such as reflection) which are common
4571 * to every Angular application running on the page are bound in its scope.
4572 *
4573 * A page's platform is initialized implicitly when a platform is created via a platform factory
4574 * (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
4575 *
4576 * \@stable
4577 * @abstract
4578 */
4579var PlatformRef = (function () {
4580 function PlatformRef() {
4581 }
4582 /**
4583 * Creates an instance of an `\@NgModule` for the given platform
4584 * for offline compilation.
4585 *
4586 * ## Simple Example
4587 *
4588 * ```typescript
4589 * my_module.ts:
4590 *
4591 * \@NgModule({
4592 * imports: [BrowserModule]
4593 * })
4594 * class MyModule {}
4595 *
4596 * main.ts:
4597 * import {MyModuleNgFactory} from './my_module.ngfactory';
4598 * import {platformBrowser} from '\@angular/platform-browser';
4599 *
4600 * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
4601 * ```
4602 *
4603 * \@experimental APIs related to application bootstrap are currently under review.
4604 * @abstract
4605 * @template M
4606 * @param {?} moduleFactory
4607 * @return {?}
4608 */
4609 PlatformRef.prototype.bootstrapModuleFactory = function (moduleFactory) { };
4610 /**
4611 * Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
4612 *
4613 * ## Simple Example
4614 *
4615 * ```typescript
4616 * \@NgModule({
4617 * imports: [BrowserModule]
4618 * })
4619 * class MyModule {}
4620 *
4621 * let moduleRef = platformBrowser().bootstrapModule(MyModule);
4622 * ```
4623 * \@stable
4624 * @abstract
4625 * @template M
4626 * @param {?} moduleType
4627 * @param {?=} compilerOptions
4628 * @return {?}
4629 */
4630 PlatformRef.prototype.bootstrapModule = function (moduleType, compilerOptions) { };
4631 /**
4632 * Register a listener to be called when the platform is disposed.
4633 * @abstract
4634 * @param {?} callback
4635 * @return {?}
4636 */
4637 PlatformRef.prototype.onDestroy = function (callback) { };
4638 /**
4639 * Retrieve the platform {\@link Injector}, which is the parent injector for
4640 * every Angular application on the page and provides singleton providers.
4641 * @abstract
4642 * @return {?}
4643 */
4644 PlatformRef.prototype.injector = function () { };
4645 /**
4646 * Destroy the Angular platform and all Angular applications on the page.
4647 * @abstract
4648 * @return {?}
4649 */
4650 PlatformRef.prototype.destroy = function () { };
4651 /**
4652 * @abstract
4653 * @return {?}
4654 */
4655 PlatformRef.prototype.destroyed = function () { };
4656 return PlatformRef;
4657}());
4658/**
4659 * @param {?} errorHandler
4660 * @param {?} callback
4661 * @return {?}
4662 */
4663function _callAndReportToErrorHandler(errorHandler, callback) {
4664 try {
4665 var /** @type {?} */ result = callback();
4666 if (isPromise(result)) {
4667 return result.catch(function (e) {
4668 errorHandler.handleError(e);
4669 // rethrow as the exception handler might not do it
4670 throw e;
4671 });
4672 }
4673 return result;
4674 }
4675 catch (e) {
4676 errorHandler.handleError(e);
4677 // rethrow as the exception handler might not do it
4678 throw e;
4679 }
4680}
4681/**
4682 * workaround https://github.com/angular/tsickle/issues/350
4683 * @suppress {checkTypes}
4684 */
4685var PlatformRef_ = (function (_super) {
4686 __extends(PlatformRef_, _super);
4687 /**
4688 * @param {?} _injector
4689 */
4690 function PlatformRef_(_injector) {
4691 var _this = _super.call(this) || this;
4692 _this._injector = _injector;
4693 _this._modules = [];
4694 _this._destroyListeners = [];
4695 _this._destroyed = false;
4696 return _this;
4697 }
4698 /**
4699 * @param {?} callback
4700 * @return {?}
4701 */
4702 PlatformRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
4703 Object.defineProperty(PlatformRef_.prototype, "injector", {
4704 /**
4705 * @return {?}
4706 */
4707 get: function () { return this._injector; },
4708 enumerable: true,
4709 configurable: true
4710 });
4711 Object.defineProperty(PlatformRef_.prototype, "destroyed", {
4712 /**
4713 * @return {?}
4714 */
4715 get: function () { return this._destroyed; },
4716 enumerable: true,
4717 configurable: true
4718 });
4719 /**
4720 * @return {?}
4721 */
4722 PlatformRef_.prototype.destroy = function () {
4723 if (this._destroyed) {
4724 throw new Error('The platform has already been destroyed!');
4725 }
4726 this._modules.slice().forEach(function (module) { return module.destroy(); });
4727 this._destroyListeners.forEach(function (listener) { return listener(); });
4728 this._destroyed = true;
4729 };
4730 /**
4731 * @template M
4732 * @param {?} moduleFactory
4733 * @return {?}
4734 */
4735 PlatformRef_.prototype.bootstrapModuleFactory = function (moduleFactory) {
4736 return this._bootstrapModuleFactoryWithZone(moduleFactory);
4737 };
4738 /**
4739 * @template M
4740 * @param {?} moduleFactory
4741 * @param {?=} ngZone
4742 * @return {?}
4743 */
4744 PlatformRef_.prototype._bootstrapModuleFactoryWithZone = function (moduleFactory, ngZone) {
4745 var _this = this;
4746 // Note: We need to create the NgZone _before_ we instantiate the module,
4747 // as instantiating the module creates some providers eagerly.
4748 // So we create a mini parent injector that just contains the new NgZone and
4749 // pass that as parent to the NgModuleFactory.
4750 if (!ngZone)
4751 ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
4752 // Attention: Don't use ApplicationRef.run here,
4753 // as we want to be sure that all possible constructor calls are inside `ngZone.run`!
4754 return ngZone.run(function () {
4755 var /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], _this.injector);
4756 var /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
4757 var /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
4758 if (!exceptionHandler) {
4759 throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
4760 }
4761 moduleRef.onDestroy(function () { return remove(_this._modules, moduleRef); }); /** @type {?} */
4762 ((ngZone)).onError.subscribe({ next: function (error) { exceptionHandler.handleError(error); } });
4763 return _callAndReportToErrorHandler(exceptionHandler, function () {
4764 var /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
4765 return initStatus.donePromise.then(function () {
4766 _this._moduleDoBootstrap(moduleRef);
4767 return moduleRef;
4768 });
4769 });
4770 });
4771 };
4772 /**
4773 * @template M
4774 * @param {?} moduleType
4775 * @param {?=} compilerOptions
4776 * @return {?}
4777 */
4778 PlatformRef_.prototype.bootstrapModule = function (moduleType, compilerOptions) {
4779 if (compilerOptions === void 0) { compilerOptions = []; }
4780 return this._bootstrapModuleWithZone(moduleType, compilerOptions);
4781 };
4782 /**
4783 * @template M
4784 * @param {?} moduleType
4785 * @param {?=} compilerOptions
4786 * @param {?=} ngZone
4787 * @return {?}
4788 */
4789 PlatformRef_.prototype._bootstrapModuleWithZone = function (moduleType, compilerOptions, ngZone) {
4790 var _this = this;
4791 if (compilerOptions === void 0) { compilerOptions = []; }
4792 var /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
4793 var /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
4794 return compiler.compileModuleAsync(moduleType)
4795 .then(function (moduleFactory) { return _this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone); });
4796 };
4797 /**
4798 * @param {?} moduleRef
4799 * @return {?}
4800 */
4801 PlatformRef_.prototype._moduleDoBootstrap = function (moduleRef) {
4802 var /** @type {?} */ appRef = moduleRef.injector.get(ApplicationRef);
4803 if (moduleRef.bootstrapFactories.length > 0) {
4804 moduleRef.bootstrapFactories.forEach(function (f) { return appRef.bootstrap(f); });
4805 }
4806 else if (moduleRef.instance.ngDoBootstrap) {
4807 moduleRef.instance.ngDoBootstrap(appRef);
4808 }
4809 else {
4810 throw new Error("The module " + stringify(moduleRef.instance.constructor) + " was bootstrapped, but it does not declare \"@NgModule.bootstrap\" components nor a \"ngDoBootstrap\" method. " +
4811 "Please define one of these.");
4812 }
4813 this._modules.push(moduleRef);
4814 };
4815 return PlatformRef_;
4816}(PlatformRef));
4817PlatformRef_.decorators = [
4818 { type: Injectable },
4819];
4820/**
4821 * @nocollapse
4822 */
4823PlatformRef_.ctorParameters = function () { return [
4824 { type: Injector, },
4825]; };
4826/**
4827 * A reference to an Angular application running on a page.
4828 *
4829 * \@stable
4830 * @abstract
4831 */
4832var ApplicationRef = (function () {
4833 function ApplicationRef() {
4834 }
4835 /**
4836 * Bootstrap a new component at the root level of the application.
4837 *
4838 * ### Bootstrap process
4839 *
4840 * When bootstrapping a new root component into an application, Angular mounts the
4841 * specified application component onto DOM elements identified by the [componentType]'s
4842 * selector and kicks off automatic change detection to finish initializing the component.
4843 *
4844 * ### Example
4845 * {\@example core/ts/platform/platform.ts region='longform'}
4846 * @abstract
4847 * @template C
4848 * @param {?} componentFactory
4849 * @return {?}
4850 */
4851 ApplicationRef.prototype.bootstrap = function (componentFactory) { };
4852 /**
4853 * Invoke this method to explicitly process change detection and its side-effects.
4854 *
4855 * In development mode, `tick()` also performs a second change detection cycle to ensure that no
4856 * further changes are detected. If additional changes are picked up during this second cycle,
4857 * bindings in the app have side-effects that cannot be resolved in a single change detection
4858 * pass.
4859 * In this case, Angular throws an error, since an Angular application can only have one change
4860 * detection pass during which all change detection must complete.
4861 * @abstract
4862 * @return {?}
4863 */
4864 ApplicationRef.prototype.tick = function () { };
4865 /**
4866 * Get a list of component types registered to this application.
4867 * This list is populated even before the component is created.
4868 * @abstract
4869 * @return {?}
4870 */
4871 ApplicationRef.prototype.componentTypes = function () { };
4872 /**
4873 * Get a list of components registered to this application.
4874 * @abstract
4875 * @return {?}
4876 */
4877 ApplicationRef.prototype.components = function () { };
4878 /**
4879 * Attaches a view so that it will be dirty checked.
4880 * The view will be automatically detached when it is destroyed.
4881 * This will throw if the view is already attached to a ViewContainer.
4882 * @abstract
4883 * @param {?} view
4884 * @return {?}
4885 */
4886 ApplicationRef.prototype.attachView = function (view) { };
4887 /**
4888 * Detaches a view from dirty checking again.
4889 * @abstract
4890 * @param {?} view
4891 * @return {?}
4892 */
4893 ApplicationRef.prototype.detachView = function (view) { };
4894 /**
4895 * Returns the number of attached views.
4896 * @abstract
4897 * @return {?}
4898 */
4899 ApplicationRef.prototype.viewCount = function () { };
4900 /**
4901 * Returns an Observable that indicates when the application is stable or unstable.
4902 * @abstract
4903 * @return {?}
4904 */
4905 ApplicationRef.prototype.isStable = function () { };
4906 return ApplicationRef;
4907}());
4908/**
4909 * workaround https://github.com/angular/tsickle/issues/350
4910 * @suppress {checkTypes}
4911 */
4912var ApplicationRef_ = (function (_super) {
4913 __extends(ApplicationRef_, _super);
4914 /**
4915 * @param {?} _zone
4916 * @param {?} _console
4917 * @param {?} _injector
4918 * @param {?} _exceptionHandler
4919 * @param {?} _componentFactoryResolver
4920 * @param {?} _initStatus
4921 */
4922 function ApplicationRef_(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
4923 var _this = _super.call(this) || this;
4924 _this._zone = _zone;
4925 _this._console = _console;
4926 _this._injector = _injector;
4927 _this._exceptionHandler = _exceptionHandler;
4928 _this._componentFactoryResolver = _componentFactoryResolver;
4929 _this._initStatus = _initStatus;
4930 _this._bootstrapListeners = [];
4931 _this._rootComponents = [];
4932 _this._rootComponentTypes = [];
4933 _this._views = [];
4934 _this._runningTick = false;
4935 _this._enforceNoNewChanges = false;
4936 _this._stable = true;
4937 _this._enforceNoNewChanges = isDevMode();
4938 _this._zone.onMicrotaskEmpty.subscribe({ next: function () { _this._zone.run(function () { _this.tick(); }); } });
4939 var isCurrentlyStable = new rxjs_Observable.Observable(function (observer) {
4940 _this._stable = _this._zone.isStable && !_this._zone.hasPendingMacrotasks &&
4941 !_this._zone.hasPendingMicrotasks;
4942 _this._zone.runOutsideAngular(function () {
4943 observer.next(_this._stable);
4944 observer.complete();
4945 });
4946 });
4947 var isStable = new rxjs_Observable.Observable(function (observer) {
4948 var stableSub = _this._zone.onStable.subscribe(function () {
4949 NgZone.assertNotInAngularZone();
4950 // Check whether there are no pending macro/micro tasks in the next tick
4951 // to allow for NgZone to update the state.
4952 scheduleMicroTask(function () {
4953 if (!_this._stable && !_this._zone.hasPendingMacrotasks &&
4954 !_this._zone.hasPendingMicrotasks) {
4955 _this._stable = true;
4956 observer.next(true);
4957 }
4958 });
4959 });
4960 var unstableSub = _this._zone.onUnstable.subscribe(function () {
4961 NgZone.assertInAngularZone();
4962 if (_this._stable) {
4963 _this._stable = false;
4964 _this._zone.runOutsideAngular(function () { observer.next(false); });
4965 }
4966 });
4967 return function () {
4968 stableSub.unsubscribe();
4969 unstableSub.unsubscribe();
4970 };
4971 });
4972 _this._isStable = rxjs_observable_merge.merge(isCurrentlyStable, rxjs_operator_share.share.call(isStable));
4973 return _this;
4974 }
4975 /**
4976 * @param {?} viewRef
4977 * @return {?}
4978 */
4979 ApplicationRef_.prototype.attachView = function (viewRef) {
4980 var /** @type {?} */ view = ((viewRef));
4981 this._views.push(view);
4982 view.attachToAppRef(this);
4983 };
4984 /**
4985 * @param {?} viewRef
4986 * @return {?}
4987 */
4988 ApplicationRef_.prototype.detachView = function (viewRef) {
4989 var /** @type {?} */ view = ((viewRef));
4990 remove(this._views, view);
4991 view.detachFromAppRef();
4992 };
4993 /**
4994 * @template C
4995 * @param {?} componentOrFactory
4996 * @return {?}
4997 */
4998 ApplicationRef_.prototype.bootstrap = function (componentOrFactory) {
4999 var _this = this;
5000 if (!this._initStatus.done) {
5001 throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
5002 }
5003 var /** @type {?} */ componentFactory;
5004 if (componentOrFactory instanceof ComponentFactory) {
5005 componentFactory = componentOrFactory;
5006 }
5007 else {
5008 componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
5009 }
5010 this._rootComponentTypes.push(componentFactory.componentType);
5011 // Create a factory associated with the current module if it's not bound to some other
5012 var /** @type {?} */ ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
5013 null :
5014 this._injector.get(NgModuleRef);
5015 var /** @type {?} */ compRef = componentFactory.create(Injector.NULL, [], componentFactory.selector, ngModule);
5016 compRef.onDestroy(function () { _this._unloadComponent(compRef); });
5017 var /** @type {?} */ testability = compRef.injector.get(Testability, null);
5018 if (testability) {
5019 compRef.injector.get(TestabilityRegistry)
5020 .registerApplication(compRef.location.nativeElement, testability);
5021 }
5022 this._loadComponent(compRef);
5023 if (isDevMode()) {
5024 this._console.log("Angular is running in the development mode. Call enableProdMode() to enable the production mode.");
5025 }
5026 return compRef;
5027 };
5028 /**
5029 * @param {?} componentRef
5030 * @return {?}
5031 */
5032 ApplicationRef_.prototype._loadComponent = function (componentRef) {
5033 this.attachView(componentRef.hostView);
5034 this.tick();
5035 this._rootComponents.push(componentRef);
5036 // Get the listeners lazily to prevent DI cycles.
5037 var /** @type {?} */ listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
5038 listeners.forEach(function (listener) { return listener(componentRef); });
5039 };
5040 /**
5041 * @param {?} componentRef
5042 * @return {?}
5043 */
5044 ApplicationRef_.prototype._unloadComponent = function (componentRef) {
5045 this.detachView(componentRef.hostView);
5046 remove(this._rootComponents, componentRef);
5047 };
5048 /**
5049 * @return {?}
5050 */
5051 ApplicationRef_.prototype.tick = function () {
5052 if (this._runningTick) {
5053 throw new Error('ApplicationRef.tick is called recursively');
5054 }
5055 var /** @type {?} */ scope = ApplicationRef_._tickScope();
5056 try {
5057 this._runningTick = true;
5058 this._views.forEach(function (view) { return view.detectChanges(); });
5059 if (this._enforceNoNewChanges) {
5060 this._views.forEach(function (view) { return view.checkNoChanges(); });
5061 }
5062 }
5063 catch (e) {
5064 // Attention: Don't rethrow as it could cancel subscriptions to Observables!
5065 this._exceptionHandler.handleError(e);
5066 }
5067 finally {
5068 this._runningTick = false;
5069 wtfLeave(scope);
5070 }
5071 };
5072 /**
5073 * @return {?}
5074 */
5075 ApplicationRef_.prototype.ngOnDestroy = function () {
5076 // TODO(alxhub): Dispose of the NgZone.
5077 this._views.slice().forEach(function (view) { return view.destroy(); });
5078 };
5079 Object.defineProperty(ApplicationRef_.prototype, "viewCount", {
5080 /**
5081 * @return {?}
5082 */
5083 get: function () { return this._views.length; },
5084 enumerable: true,
5085 configurable: true
5086 });
5087 Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
5088 /**
5089 * @return {?}
5090 */
5091 get: function () { return this._rootComponentTypes; },
5092 enumerable: true,
5093 configurable: true
5094 });
5095 Object.defineProperty(ApplicationRef_.prototype, "components", {
5096 /**
5097 * @return {?}
5098 */
5099 get: function () { return this._rootComponents; },
5100 enumerable: true,
5101 configurable: true
5102 });
5103 Object.defineProperty(ApplicationRef_.prototype, "isStable", {
5104 /**
5105 * @return {?}
5106 */
5107 get: function () { return this._isStable; },
5108 enumerable: true,
5109 configurable: true
5110 });
5111 return ApplicationRef_;
5112}(ApplicationRef));
5113/**
5114 * \@internal
5115 */
5116ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
5117ApplicationRef_.decorators = [
5118 { type: Injectable },
5119];
5120/**
5121 * @nocollapse
5122 */
5123ApplicationRef_.ctorParameters = function () { return [
5124 { type: NgZone, },
5125 { type: Console, },
5126 { type: Injector, },
5127 { type: ErrorHandler, },
5128 { type: ComponentFactoryResolver, },
5129 { type: ApplicationInitStatus, },
5130]; };
5131/**
5132 * @template T
5133 * @param {?} list
5134 * @param {?} el
5135 * @return {?}
5136 */
5137function remove(list, el) {
5138 var /** @type {?} */ index = list.indexOf(el);
5139 if (index > -1) {
5140 list.splice(index, 1);
5141 }
5142}
5143/**
5144 * @license
5145 * Copyright Google Inc. All Rights Reserved.
5146 *
5147 * Use of this source code is governed by an MIT-style license that can be
5148 * found in the LICENSE file at https://angular.io/license
5149 */
5150// Public API for Zone
5151/**
5152 * @license
5153 * Copyright Google Inc. All Rights Reserved.
5154 *
5155 * Use of this source code is governed by an MIT-style license that can be
5156 * found in the LICENSE file at https://angular.io/license
5157 */
5158/**
5159 * @deprecated Use `RendererType2` (and `Renderer2`) instead.
5160 */
5161var RenderComponentType = (function () {
5162 /**
5163 * @param {?} id
5164 * @param {?} templateUrl
5165 * @param {?} slotCount
5166 * @param {?} encapsulation
5167 * @param {?} styles
5168 * @param {?} animations
5169 */
5170 function RenderComponentType(id, templateUrl, slotCount, encapsulation, styles, animations) {
5171 this.id = id;
5172 this.templateUrl = templateUrl;
5173 this.slotCount = slotCount;
5174 this.encapsulation = encapsulation;
5175 this.styles = styles;
5176 this.animations = animations;
5177 }
5178 return RenderComponentType;
5179}());
5180/**
5181 * @deprecated Debug info is handeled internally in the view engine now.
5182 * @abstract
5183 */
5184var RenderDebugInfo = (function () {
5185 function RenderDebugInfo() {
5186 }
5187 /**
5188 * @abstract
5189 * @return {?}
5190 */
5191 RenderDebugInfo.prototype.injector = function () { };
5192 /**
5193 * @abstract
5194 * @return {?}
5195 */
5196 RenderDebugInfo.prototype.component = function () { };
5197 /**
5198 * @abstract
5199 * @return {?}
5200 */
5201 RenderDebugInfo.prototype.providerTokens = function () { };
5202 /**
5203 * @abstract
5204 * @return {?}
5205 */
5206 RenderDebugInfo.prototype.references = function () { };
5207 /**
5208 * @abstract
5209 * @return {?}
5210 */
5211 RenderDebugInfo.prototype.context = function () { };
5212 /**
5213 * @abstract
5214 * @return {?}
5215 */
5216 RenderDebugInfo.prototype.source = function () { };
5217 return RenderDebugInfo;
5218}());
5219/**
5220 * @deprecated Use the `Renderer2` instead.
5221 * @abstract
5222 */
5223var Renderer = (function () {
5224 function Renderer() {
5225 }
5226 /**
5227 * @abstract
5228 * @param {?} selectorOrNode
5229 * @param {?=} debugInfo
5230 * @return {?}
5231 */
5232 Renderer.prototype.selectRootElement = function (selectorOrNode, debugInfo) { };
5233 /**
5234 * @abstract
5235 * @param {?} parentElement
5236 * @param {?} name
5237 * @param {?=} debugInfo
5238 * @return {?}
5239 */
5240 Renderer.prototype.createElement = function (parentElement, name, debugInfo) { };
5241 /**
5242 * @abstract
5243 * @param {?} hostElement
5244 * @return {?}
5245 */
5246 Renderer.prototype.createViewRoot = function (hostElement) { };
5247 /**
5248 * @abstract
5249 * @param {?} parentElement
5250 * @param {?=} debugInfo
5251 * @return {?}
5252 */
5253 Renderer.prototype.createTemplateAnchor = function (parentElement, debugInfo) { };
5254 /**
5255 * @abstract
5256 * @param {?} parentElement
5257 * @param {?} value
5258 * @param {?=} debugInfo
5259 * @return {?}
5260 */
5261 Renderer.prototype.createText = function (parentElement, value, debugInfo) { };
5262 /**
5263 * @abstract
5264 * @param {?} parentElement
5265 * @param {?} nodes
5266 * @return {?}
5267 */
5268 Renderer.prototype.projectNodes = function (parentElement, nodes) { };
5269 /**
5270 * @abstract
5271 * @param {?} node
5272 * @param {?} viewRootNodes
5273 * @return {?}
5274 */
5275 Renderer.prototype.attachViewAfter = function (node, viewRootNodes) { };
5276 /**
5277 * @abstract
5278 * @param {?} viewRootNodes
5279 * @return {?}
5280 */
5281 Renderer.prototype.detachView = function (viewRootNodes) { };
5282 /**
5283 * @abstract
5284 * @param {?} hostElement
5285 * @param {?} viewAllNodes
5286 * @return {?}
5287 */
5288 Renderer.prototype.destroyView = function (hostElement, viewAllNodes) { };
5289 /**
5290 * @abstract
5291 * @param {?} renderElement
5292 * @param {?} name
5293 * @param {?} callback
5294 * @return {?}
5295 */
5296 Renderer.prototype.listen = function (renderElement, name, callback) { };
5297 /**
5298 * @abstract
5299 * @param {?} target
5300 * @param {?} name
5301 * @param {?} callback
5302 * @return {?}
5303 */
5304 Renderer.prototype.listenGlobal = function (target, name, callback) { };
5305 /**
5306 * @abstract
5307 * @param {?} renderElement
5308 * @param {?} propertyName
5309 * @param {?} propertyValue
5310 * @return {?}
5311 */
5312 Renderer.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) { };
5313 /**
5314 * @abstract
5315 * @param {?} renderElement
5316 * @param {?} attributeName
5317 * @param {?} attributeValue
5318 * @return {?}
5319 */
5320 Renderer.prototype.setElementAttribute = function (renderElement, attributeName, attributeValue) { };
5321 /**
5322 * Used only in debug mode to serialize property changes to dom nodes as attributes.
5323 * @abstract
5324 * @param {?} renderElement
5325 * @param {?} propertyName
5326 * @param {?} propertyValue
5327 * @return {?}
5328 */
5329 Renderer.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
5330 /**
5331 * @abstract
5332 * @param {?} renderElement
5333 * @param {?} className
5334 * @param {?} isAdd
5335 * @return {?}
5336 */
5337 Renderer.prototype.setElementClass = function (renderElement, className, isAdd) { };
5338 /**
5339 * @abstract
5340 * @param {?} renderElement
5341 * @param {?} styleName
5342 * @param {?} styleValue
5343 * @return {?}
5344 */
5345 Renderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) { };
5346 /**
5347 * @abstract
5348 * @param {?} renderElement
5349 * @param {?} methodName
5350 * @param {?=} args
5351 * @return {?}
5352 */
5353 Renderer.prototype.invokeElementMethod = function (renderElement, methodName, args) { };
5354 /**
5355 * @abstract
5356 * @param {?} renderNode
5357 * @param {?} text
5358 * @return {?}
5359 */
5360 Renderer.prototype.setText = function (renderNode, text) { };
5361 /**
5362 * @abstract
5363 * @param {?} element
5364 * @param {?} startingStyles
5365 * @param {?} keyframes
5366 * @param {?} duration
5367 * @param {?} delay
5368 * @param {?} easing
5369 * @param {?=} previousPlayers
5370 * @return {?}
5371 */
5372 Renderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { };
5373 return Renderer;
5374}());
5375var Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
5376/**
5377 * Injectable service that provides a low-level interface for modifying the UI.
5378 *
5379 * Use this service to bypass Angular's templating and make custom UI changes that can't be
5380 * expressed declaratively. For example if you need to set a property or an attribute whose name is
5381 * not statically known, use {\@link #setElementProperty} or {\@link #setElementAttribute}
5382 * respectively.
5383 *
5384 * If you are implementing a custom renderer, you must implement this interface.
5385 *
5386 * The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
5387 *
5388 * @deprecated Use `RendererFactory2` instead.
5389 * @abstract
5390 */
5391var RootRenderer = (function () {
5392 function RootRenderer() {
5393 }
5394 /**
5395 * @abstract
5396 * @param {?} componentType
5397 * @return {?}
5398 */
5399 RootRenderer.prototype.renderComponent = function (componentType) { };
5400 return RootRenderer;
5401}());
5402/**
5403 * \@experimental
5404 * @abstract
5405 */
5406var RendererFactory2 = (function () {
5407 function RendererFactory2() {
5408 }
5409 /**
5410 * @abstract
5411 * @param {?} hostElement
5412 * @param {?} type
5413 * @return {?}
5414 */
5415 RendererFactory2.prototype.createRenderer = function (hostElement, type) { };
5416 return RendererFactory2;
5417}());
5418var RendererStyleFlags2 = {};
5419RendererStyleFlags2.Important = 1;
5420RendererStyleFlags2.DashCase = 2;
5421RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
5422RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
5423/**
5424 * \@experimental
5425 * @abstract
5426 */
5427var Renderer2 = (function () {
5428 function Renderer2() {
5429 }
5430 /**
5431 * This field can be used to store arbitrary data on this renderer instance.
5432 * This is useful for renderers that delegate to other renderers.
5433 * @abstract
5434 * @return {?}
5435 */
5436 Renderer2.prototype.data = function () { };
5437 /**
5438 * @abstract
5439 * @return {?}
5440 */
5441 Renderer2.prototype.destroy = function () { };
5442 /**
5443 * @abstract
5444 * @param {?} name
5445 * @param {?=} namespace
5446 * @return {?}
5447 */
5448 Renderer2.prototype.createElement = function (name, namespace) { };
5449 /**
5450 * @abstract
5451 * @param {?} value
5452 * @return {?}
5453 */
5454 Renderer2.prototype.createComment = function (value) { };
5455 /**
5456 * @abstract
5457 * @param {?} value
5458 * @return {?}
5459 */
5460 Renderer2.prototype.createText = function (value) { };
5461 /**
5462 * @abstract
5463 * @param {?} parent
5464 * @param {?} newChild
5465 * @return {?}
5466 */
5467 Renderer2.prototype.appendChild = function (parent, newChild) { };
5468 /**
5469 * @abstract
5470 * @param {?} parent
5471 * @param {?} newChild
5472 * @param {?} refChild
5473 * @return {?}
5474 */
5475 Renderer2.prototype.insertBefore = function (parent, newChild, refChild) { };
5476 /**
5477 * @abstract
5478 * @param {?} parent
5479 * @param {?} oldChild
5480 * @return {?}
5481 */
5482 Renderer2.prototype.removeChild = function (parent, oldChild) { };
5483 /**
5484 * @abstract
5485 * @param {?} selectorOrNode
5486 * @return {?}
5487 */
5488 Renderer2.prototype.selectRootElement = function (selectorOrNode) { };
5489 /**
5490 * Attention: On WebWorkers, this will always return a value,
5491 * as we are asking for a result synchronously. I.e.
5492 * the caller can't rely on checking whether this is null or not.
5493 * @abstract
5494 * @param {?} node
5495 * @return {?}
5496 */
5497 Renderer2.prototype.parentNode = function (node) { };
5498 /**
5499 * Attention: On WebWorkers, this will always return a value,
5500 * as we are asking for a result synchronously. I.e.
5501 * the caller can't rely on checking whether this is null or not.
5502 * @abstract
5503 * @param {?} node
5504 * @return {?}
5505 */
5506 Renderer2.prototype.nextSibling = function (node) { };
5507 /**
5508 * @abstract
5509 * @param {?} el
5510 * @param {?} name
5511 * @param {?} value
5512 * @param {?=} namespace
5513 * @return {?}
5514 */
5515 Renderer2.prototype.setAttribute = function (el, name, value, namespace) { };
5516 /**
5517 * @abstract
5518 * @param {?} el
5519 * @param {?} name
5520 * @param {?=} namespace
5521 * @return {?}
5522 */
5523 Renderer2.prototype.removeAttribute = function (el, name, namespace) { };
5524 /**
5525 * @abstract
5526 * @param {?} el
5527 * @param {?} name
5528 * @return {?}
5529 */
5530 Renderer2.prototype.addClass = function (el, name) { };
5531 /**
5532 * @abstract
5533 * @param {?} el
5534 * @param {?} name
5535 * @return {?}
5536 */
5537 Renderer2.prototype.removeClass = function (el, name) { };
5538 /**
5539 * @abstract
5540 * @param {?} el
5541 * @param {?} style
5542 * @param {?} value
5543 * @param {?=} flags
5544 * @return {?}
5545 */
5546 Renderer2.prototype.setStyle = function (el, style, value, flags) { };
5547 /**
5548 * @abstract
5549 * @param {?} el
5550 * @param {?} style
5551 * @param {?=} flags
5552 * @return {?}
5553 */
5554 Renderer2.prototype.removeStyle = function (el, style, flags) { };
5555 /**
5556 * @abstract
5557 * @param {?} el
5558 * @param {?} name
5559 * @param {?} value
5560 * @return {?}
5561 */
5562 Renderer2.prototype.setProperty = function (el, name, value) { };
5563 /**
5564 * @abstract
5565 * @param {?} node
5566 * @param {?} value
5567 * @return {?}
5568 */
5569 Renderer2.prototype.setValue = function (node, value) { };
5570 /**
5571 * @abstract
5572 * @param {?} target
5573 * @param {?} eventName
5574 * @param {?} callback
5575 * @return {?}
5576 */
5577 Renderer2.prototype.listen = function (target, eventName, callback) { };
5578 return Renderer2;
5579}());
5580/**
5581 * @license
5582 * Copyright Google Inc. All Rights Reserved.
5583 *
5584 * Use of this source code is governed by an MIT-style license that can be
5585 * found in the LICENSE file at https://angular.io/license
5586 */
5587// Public API for render
5588var ElementRef = (function () {
5589 /**
5590 * @param {?} nativeElement
5591 */
5592 function ElementRef(nativeElement) {
5593 this.nativeElement = nativeElement;
5594 }
5595 return ElementRef;
5596}());
5597/**
5598 * @license
5599 * Copyright Google Inc. All Rights Reserved.
5600 *
5601 * Use of this source code is governed by an MIT-style license that can be
5602 * found in the LICENSE file at https://angular.io/license
5603 */
5604/**
5605 * Used to load ng module factories.
5606 * \@stable
5607 * @abstract
5608 */
5609var NgModuleFactoryLoader = (function () {
5610 function NgModuleFactoryLoader() {
5611 }
5612 /**
5613 * @abstract
5614 * @param {?} path
5615 * @return {?}
5616 */
5617 NgModuleFactoryLoader.prototype.load = function (path) { };
5618 return NgModuleFactoryLoader;
5619}());
5620var moduleFactories = new Map();
5621/**
5622 * Registers a loaded module. Should only be called from generated NgModuleFactory code.
5623 * \@experimental
5624 * @param {?} id
5625 * @param {?} factory
5626 * @return {?}
5627 */
5628function registerModuleFactory(id, factory) {
5629 var /** @type {?} */ existing = moduleFactories.get(id);
5630 if (existing) {
5631 throw new Error("Duplicate module registered for " + id + " - " + existing.moduleType.name + " vs " + factory.moduleType.name);
5632 }
5633 moduleFactories.set(id, factory);
5634}
5635/**
5636 * @return {?}
5637 */
5638/**
5639 * Returns the NgModuleFactory with the given id, if it exists and has been loaded.
5640 * Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
5641 * cannot be found.
5642 * \@experimental
5643 * @param {?} id
5644 * @return {?}
5645 */
5646function getModuleFactory(id) {
5647 var /** @type {?} */ factory = moduleFactories.get(id);
5648 if (!factory)
5649 throw new Error("No module with ID " + id + " loaded");
5650 return factory;
5651}
5652/**
5653 * @license
5654 * Copyright Google Inc. All Rights Reserved.
5655 *
5656 * Use of this source code is governed by an MIT-style license that can be
5657 * found in the LICENSE file at https://angular.io/license
5658 */
5659/**
5660 * An unmodifiable list of items that Angular keeps up to date when the state
5661 * of the application changes.
5662 *
5663 * The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
5664 * provide.
5665 *
5666 * Implements an iterable interface, therefore it can be used in both ES6
5667 * javascript `for (var i of items)` loops as well as in Angular templates with
5668 * `*ngFor="let i of myList"`.
5669 *
5670 * Changes can be observed by subscribing to the changes `Observable`.
5671 *
5672 * NOTE: In the future this class will implement an `Observable` interface.
5673 *
5674 * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
5675 * ```typescript
5676 * \@Component({...})
5677 * class Container {
5678 * \@ViewChildren(Item) items:QueryList<Item>;
5679 * }
5680 * ```
5681 * \@stable
5682 */
5683var QueryList = (function () {
5684 function QueryList() {
5685 this._dirty = true;
5686 this._results = [];
5687 this._emitter = new EventEmitter();
5688 }
5689 Object.defineProperty(QueryList.prototype, "changes", {
5690 /**
5691 * @return {?}
5692 */
5693 get: function () { return this._emitter; },
5694 enumerable: true,
5695 configurable: true
5696 });
5697 Object.defineProperty(QueryList.prototype, "length", {
5698 /**
5699 * @return {?}
5700 */
5701 get: function () { return this._results.length; },
5702 enumerable: true,
5703 configurable: true
5704 });
5705 Object.defineProperty(QueryList.prototype, "first", {
5706 /**
5707 * @return {?}
5708 */
5709 get: function () { return this._results[0]; },
5710 enumerable: true,
5711 configurable: true
5712 });
5713 Object.defineProperty(QueryList.prototype, "last", {
5714 /**
5715 * @return {?}
5716 */
5717 get: function () { return this._results[this.length - 1]; },
5718 enumerable: true,
5719 configurable: true
5720 });
5721 /**
5722 * See
5723 * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
5724 * @template U
5725 * @param {?} fn
5726 * @return {?}
5727 */
5728 QueryList.prototype.map = function (fn) { return this._results.map(fn); };
5729 /**
5730 * See
5731 * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
5732 * @param {?} fn
5733 * @return {?}
5734 */
5735 QueryList.prototype.filter = function (fn) {
5736 return this._results.filter(fn);
5737 };
5738 /**
5739 * See
5740 * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
5741 * @param {?} fn
5742 * @return {?}
5743 */
5744 QueryList.prototype.find = function (fn) {
5745 return this._results.find(fn);
5746 };
5747 /**
5748 * See
5749 * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
5750 * @template U
5751 * @param {?} fn
5752 * @param {?} init
5753 * @return {?}
5754 */
5755 QueryList.prototype.reduce = function (fn, init) {
5756 return this._results.reduce(fn, init);
5757 };
5758 /**
5759 * See
5760 * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
5761 * @param {?} fn
5762 * @return {?}
5763 */
5764 QueryList.prototype.forEach = function (fn) { this._results.forEach(fn); };
5765 /**
5766 * See
5767 * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
5768 * @param {?} fn
5769 * @return {?}
5770 */
5771 QueryList.prototype.some = function (fn) {
5772 return this._results.some(fn);
5773 };
5774 /**
5775 * @return {?}
5776 */
5777 QueryList.prototype.toArray = function () { return this._results.slice(); };
5778 /**
5779 * @return {?}
5780 */
5781 QueryList.prototype[getSymbolIterator()] = function () { return ((this._results))[getSymbolIterator()](); };
5782 /**
5783 * @return {?}
5784 */
5785 QueryList.prototype.toString = function () { return this._results.toString(); };
5786 /**
5787 * @param {?} res
5788 * @return {?}
5789 */
5790 QueryList.prototype.reset = function (res) {
5791 this._results = flatten(res);
5792 this._dirty = false;
5793 };
5794 /**
5795 * @return {?}
5796 */
5797 QueryList.prototype.notifyOnChanges = function () { this._emitter.emit(this); };
5798 /**
5799 * internal
5800 * @return {?}
5801 */
5802 QueryList.prototype.setDirty = function () { this._dirty = true; };
5803 Object.defineProperty(QueryList.prototype, "dirty", {
5804 /**
5805 * internal
5806 * @return {?}
5807 */
5808 get: function () { return this._dirty; },
5809 enumerable: true,
5810 configurable: true
5811 });
5812 return QueryList;
5813}());
5814/**
5815 * @template T
5816 * @param {?} list
5817 * @return {?}
5818 */
5819function flatten(list) {
5820 return list.reduce(function (flat, item) {
5821 var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
5822 return ((flat)).concat(flatItem);
5823 }, []);
5824}
5825/**
5826 * @license
5827 * Copyright Google Inc. All Rights Reserved.
5828 *
5829 * Use of this source code is governed by an MIT-style license that can be
5830 * found in the LICENSE file at https://angular.io/license
5831 */
5832var _SEPARATOR = '#';
5833var FACTORY_CLASS_SUFFIX = 'NgFactory';
5834/**
5835 * Configuration for SystemJsNgModuleLoader.
5836 * token.
5837 *
5838 * \@experimental
5839 * @abstract
5840 */
5841var SystemJsNgModuleLoaderConfig = (function () {
5842 function SystemJsNgModuleLoaderConfig() {
5843 }
5844 return SystemJsNgModuleLoaderConfig;
5845}());
5846var DEFAULT_CONFIG = {
5847 factoryPathPrefix: '',
5848 factoryPathSuffix: '.ngfactory',
5849};
5850/**
5851 * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
5852 * \@experimental
5853 */
5854var SystemJsNgModuleLoader = (function () {
5855 /**
5856 * @param {?} _compiler
5857 * @param {?=} config
5858 */
5859 function SystemJsNgModuleLoader(_compiler, config) {
5860 this._compiler = _compiler;
5861 this._config = config || DEFAULT_CONFIG;
5862 }
5863 /**
5864 * @param {?} path
5865 * @return {?}
5866 */
5867 SystemJsNgModuleLoader.prototype.load = function (path) {
5868 var /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
5869 return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
5870 };
5871 /**
5872 * @param {?} path
5873 * @return {?}
5874 */
5875 SystemJsNgModuleLoader.prototype.loadAndCompile = function (path) {
5876 var _this = this;
5877 var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
5878 if (exportName === undefined) {
5879 exportName = 'default';
5880 }
5881 return System.import(module)
5882 .then(function (module) { return module[exportName]; })
5883 .then(function (type) { return checkNotEmpty(type, module, exportName); })
5884 .then(function (type) { return _this._compiler.compileModuleAsync(type); });
5885 };
5886 /**
5887 * @param {?} path
5888 * @return {?}
5889 */
5890 SystemJsNgModuleLoader.prototype.loadFactory = function (path) {
5891 var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
5892 var /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
5893 if (exportName === undefined) {
5894 exportName = 'default';
5895 factoryClassSuffix = '';
5896 }
5897 return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
5898 .then(function (module) { return module[exportName + factoryClassSuffix]; })
5899 .then(function (factory) { return checkNotEmpty(factory, module, exportName); });
5900 };
5901 return SystemJsNgModuleLoader;
5902}());
5903SystemJsNgModuleLoader.decorators = [
5904 { type: Injectable },
5905];
5906/**
5907 * @nocollapse
5908 */
5909SystemJsNgModuleLoader.ctorParameters = function () { return [
5910 { type: Compiler, },
5911 { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
5912]; };
5913/**
5914 * @param {?} value
5915 * @param {?} modulePath
5916 * @param {?} exportName
5917 * @return {?}
5918 */
5919function checkNotEmpty(value, modulePath, exportName) {
5920 if (!value) {
5921 throw new Error("Cannot find '" + exportName + "' in '" + modulePath + "'");
5922 }
5923 return value;
5924}
5925/**
5926 * @license
5927 * Copyright Google Inc. All Rights Reserved.
5928 *
5929 * Use of this source code is governed by an MIT-style license that can be
5930 * found in the LICENSE file at https://angular.io/license
5931 */
5932/**
5933 * Represents an Embedded Template that can be used to instantiate Embedded Views.
5934 *
5935 * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
5936 * (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
5937 * the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
5938 * the `TemplateRef` from a Component or a Directive via {\@link Query}.
5939 *
5940 * To instantiate Embedded Views based on a Template, use
5941 * {\@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
5942 * View Container.
5943 * \@stable
5944 * @abstract
5945 */
5946var TemplateRef = (function () {
5947 function TemplateRef() {
5948 }
5949 /**
5950 * @abstract
5951 * @return {?}
5952 */
5953 TemplateRef.prototype.elementRef = function () { };
5954 /**
5955 * @abstract
5956 * @param {?} context
5957 * @return {?}
5958 */
5959 TemplateRef.prototype.createEmbeddedView = function (context) { };
5960 return TemplateRef;
5961}());
5962/**
5963 * @license
5964 * Copyright Google Inc. All Rights Reserved.
5965 *
5966 * Use of this source code is governed by an MIT-style license that can be
5967 * found in the LICENSE file at https://angular.io/license
5968 */
5969/**
5970 * Represents a container where one or more Views can be attached.
5971 *
5972 * The container can contain two kinds of Views. Host Views, created by instantiating a
5973 * {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
5974 * {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
5975 *
5976 * The location of the View Container within the containing View is specified by the Anchor
5977 * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
5978 * have a single View Container.
5979 *
5980 * Root elements of Views attached to this container become siblings of the Anchor Element in
5981 * the Rendered View.
5982 *
5983 * To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
5984 * with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
5985 * \@stable
5986 * @abstract
5987 */
5988var ViewContainerRef = (function () {
5989 function ViewContainerRef() {
5990 }
5991 /**
5992 * Anchor element that specifies the location of this container in the containing View.
5993 * <!-- TODO: rename to anchorElement -->
5994 * @abstract
5995 * @return {?}
5996 */
5997 ViewContainerRef.prototype.element = function () { };
5998 /**
5999 * @abstract
6000 * @return {?}
6001 */
6002 ViewContainerRef.prototype.injector = function () { };
6003 /**
6004 * @abstract
6005 * @return {?}
6006 */
6007 ViewContainerRef.prototype.parentInjector = function () { };
6008 /**
6009 * Destroys all Views in this container.
6010 * @abstract
6011 * @return {?}
6012 */
6013 ViewContainerRef.prototype.clear = function () { };
6014 /**
6015 * Returns the {\@link ViewRef} for the View located in this container at the specified index.
6016 * @abstract
6017 * @param {?} index
6018 * @return {?}
6019 */
6020 ViewContainerRef.prototype.get = function (index) { };
6021 /**
6022 * Returns the number of Views currently attached to this container.
6023 * @abstract
6024 * @return {?}
6025 */
6026 ViewContainerRef.prototype.length = function () { };
6027 /**
6028 * Instantiates an Embedded View based on the {\@link TemplateRef `templateRef`} and inserts it
6029 * into this container at the specified `index`.
6030 *
6031 * If `index` is not specified, the new View will be inserted as the last View in the container.
6032 *
6033 * Returns the {\@link ViewRef} for the newly created View.
6034 * @abstract
6035 * @template C
6036 * @param {?} templateRef
6037 * @param {?=} context
6038 * @param {?=} index
6039 * @return {?}
6040 */
6041 ViewContainerRef.prototype.createEmbeddedView = function (templateRef, context, index) { };
6042 /**
6043 * Instantiates a single {\@link Component} and inserts its Host View into this container at the
6044 * specified `index`.
6045 *
6046 * The component is instantiated using its {\@link ComponentFactory} which can be
6047 * obtained via {\@link ComponentFactoryResolver#resolveComponentFactory}.
6048 *
6049 * If `index` is not specified, the new View will be inserted as the last View in the container.
6050 *
6051 * You can optionally specify the {\@link Injector} that will be used as parent for the Component.
6052 *
6053 * Returns the {\@link ComponentRef} of the Host View created for the newly instantiated Component.
6054 * @abstract
6055 * @template C
6056 * @param {?} componentFactory
6057 * @param {?=} index
6058 * @param {?=} injector
6059 * @param {?=} projectableNodes
6060 * @param {?=} ngModule
6061 * @return {?}
6062 */
6063 ViewContainerRef.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModule) { };
6064 /**
6065 * Inserts a View identified by a {\@link ViewRef} into the container at the specified `index`.
6066 *
6067 * If `index` is not specified, the new View will be inserted as the last View in the container.
6068 *
6069 * Returns the inserted {\@link ViewRef}.
6070 * @abstract
6071 * @param {?} viewRef
6072 * @param {?=} index
6073 * @return {?}
6074 */
6075 ViewContainerRef.prototype.insert = function (viewRef, index) { };
6076 /**
6077 * Moves a View identified by a {\@link ViewRef} into the container at the specified `index`.
6078 *
6079 * Returns the inserted {\@link ViewRef}.
6080 * @abstract
6081 * @param {?} viewRef
6082 * @param {?} currentIndex
6083 * @return {?}
6084 */
6085 ViewContainerRef.prototype.move = function (viewRef, currentIndex) { };
6086 /**
6087 * Returns the index of the View, specified via {\@link ViewRef}, within the current container or
6088 * `-1` if this container doesn't contain the View.
6089 * @abstract
6090 * @param {?} viewRef
6091 * @return {?}
6092 */
6093 ViewContainerRef.prototype.indexOf = function (viewRef) { };
6094 /**
6095 * Destroys a View attached to this container at the specified `index`.
6096 *
6097 * If `index` is not specified, the last View in the container will be removed.
6098 * @abstract
6099 * @param {?=} index
6100 * @return {?}
6101 */
6102 ViewContainerRef.prototype.remove = function (index) { };
6103 /**
6104 * Use along with {\@link #insert} to move a View within the current container.
6105 *
6106 * If the `index` param is omitted, the last {\@link ViewRef} is detached.
6107 * @abstract
6108 * @param {?=} index
6109 * @return {?}
6110 */
6111 ViewContainerRef.prototype.detach = function (index) { };
6112 return ViewContainerRef;
6113}());
6114/**
6115 * \@stable
6116 * @abstract
6117 */
6118var ChangeDetectorRef = (function () {
6119 function ChangeDetectorRef() {
6120 }
6121 /**
6122 * Marks all {\@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
6123 *
6124 * <!-- TODO: Add a link to a chapter on OnPush components -->
6125 *
6126 * ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
6127 *
6128 * ```typescript
6129 * \@Component({
6130 * selector: 'cmp',
6131 * changeDetection: ChangeDetectionStrategy.OnPush,
6132 * template: `Number of ticks: {{numberOfTicks}}`
6133 * })
6134 * class Cmp {
6135 * numberOfTicks = 0;
6136 *
6137 * constructor(ref: ChangeDetectorRef) {
6138 * setInterval(() => {
6139 * this.numberOfTicks ++
6140 * // the following is required, otherwise the view will not be updated
6141 * this.ref.markForCheck();
6142 * }, 1000);
6143 * }
6144 * }
6145 *
6146 * \@Component({
6147 * selector: 'app',
6148 * changeDetection: ChangeDetectionStrategy.OnPush,
6149 * template: `
6150 * <cmp><cmp>
6151 * `,
6152 * })
6153 * class App {
6154 * }
6155 * ```
6156 * @abstract
6157 * @return {?}
6158 */
6159 ChangeDetectorRef.prototype.markForCheck = function () { };
6160 /**
6161 * Detaches the change detector from the change detector tree.
6162 *
6163 * The detached change detector will not be checked until it is reattached.
6164 *
6165 * This can also be used in combination with {\@link ChangeDetectorRef#detectChanges} to implement
6166 * local change
6167 * detection checks.
6168 *
6169 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
6170 * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
6171 *
6172 * ### Example
6173 *
6174 * The following example defines a component with a large list of readonly data.
6175 * Imagine the data changes constantly, many times per second. For performance reasons,
6176 * we want to check and update the list every five seconds. We can do that by detaching
6177 * the component's change detector and doing a local check every five seconds.
6178 *
6179 * ```typescript
6180 * class DataProvider {
6181 * // in a real application the returned data will be different every time
6182 * get data() {
6183 * return [1,2,3,4,5];
6184 * }
6185 * }
6186 *
6187 * \@Component({
6188 * selector: 'giant-list',
6189 * template: `
6190 * <li *ngFor="let d of dataProvider.data">Data {{d}}</lig>
6191 * `,
6192 * })
6193 * class GiantList {
6194 * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {
6195 * ref.detach();
6196 * setInterval(() => {
6197 * this.ref.detectChanges();
6198 * }, 5000);
6199 * }
6200 * }
6201 *
6202 * \@Component({
6203 * selector: 'app',
6204 * providers: [DataProvider],
6205 * template: `
6206 * <giant-list><giant-list>
6207 * `,
6208 * })
6209 * class App {
6210 * }
6211 * ```
6212 * @abstract
6213 * @return {?}
6214 */
6215 ChangeDetectorRef.prototype.detach = function () { };
6216 /**
6217 * Checks the change detector and its children.
6218 *
6219 * This can also be used in combination with {\@link ChangeDetectorRef#detach} to implement local
6220 * change detection
6221 * checks.
6222 *
6223 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
6224 * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
6225 *
6226 * ### Example
6227 *
6228 * The following example defines a component with a large list of readonly data.
6229 * Imagine, the data changes constantly, many times per second. For performance reasons,
6230 * we want to check and update the list every five seconds.
6231 *
6232 * We can do that by detaching the component's change detector and doing a local change detection
6233 * check
6234 * every five seconds.
6235 *
6236 * See {\@link ChangeDetectorRef#detach} for more information.
6237 * @abstract
6238 * @return {?}
6239 */
6240 ChangeDetectorRef.prototype.detectChanges = function () { };
6241 /**
6242 * Checks the change detector and its children, and throws if any changes are detected.
6243 *
6244 * This is used in development mode to verify that running change detection doesn't introduce
6245 * other changes.
6246 * @abstract
6247 * @return {?}
6248 */
6249 ChangeDetectorRef.prototype.checkNoChanges = function () { };
6250 /**
6251 * Reattach the change detector to the change detector tree.
6252 *
6253 * This also marks OnPush ancestors as to be checked. This reattached change detector will be
6254 * checked during the next change detection run.
6255 *
6256 * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
6257 *
6258 * ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
6259 *
6260 * The following example creates a component displaying `live` data. The component will detach
6261 * its change detector from the main change detector tree when the component's live property
6262 * is set to false.
6263 *
6264 * ```typescript
6265 * class DataProvider {
6266 * data = 1;
6267 *
6268 * constructor() {
6269 * setInterval(() => {
6270 * this.data = this.data * 2;
6271 * }, 500);
6272 * }
6273 * }
6274 *
6275 * \@Component({
6276 * selector: 'live-data',
6277 * inputs: ['live'],
6278 * template: 'Data: {{dataProvider.data}}'
6279 * })
6280 * class LiveData {
6281 * constructor(private ref: ChangeDetectorRef, private dataProvider:DataProvider) {}
6282 *
6283 * set live(value) {
6284 * if (value)
6285 * this.ref.reattach();
6286 * else
6287 * this.ref.detach();
6288 * }
6289 * }
6290 *
6291 * \@Component({
6292 * selector: 'app',
6293 * providers: [DataProvider],
6294 * template: `
6295 * Live Update: <input type="checkbox" [(ngModel)]="live">
6296 * <live-data [live]="live"><live-data>
6297 * `,
6298 * })
6299 * class App {
6300 * live = true;
6301 * }
6302 * ```
6303 * @abstract
6304 * @return {?}
6305 */
6306 ChangeDetectorRef.prototype.reattach = function () { };
6307 return ChangeDetectorRef;
6308}());
6309/**
6310 * @license
6311 * Copyright Google Inc. All Rights Reserved.
6312 *
6313 * Use of this source code is governed by an MIT-style license that can be
6314 * found in the LICENSE file at https://angular.io/license
6315 */
6316/**
6317 * \@stable
6318 * @abstract
6319 */
6320var ViewRef = (function (_super) {
6321 __extends(ViewRef, _super);
6322 function ViewRef() {
6323 return _super !== null && _super.apply(this, arguments) || this;
6324 }
6325 /**
6326 * Destroys the view and all of the data structures associated with it.
6327 * @abstract
6328 * @return {?}
6329 */
6330 ViewRef.prototype.destroy = function () { };
6331 /**
6332 * @abstract
6333 * @return {?}
6334 */
6335 ViewRef.prototype.destroyed = function () { };
6336 /**
6337 * @abstract
6338 * @param {?} callback
6339 * @return {?}
6340 */
6341 ViewRef.prototype.onDestroy = function (callback) { };
6342 return ViewRef;
6343}(ChangeDetectorRef));
6344/**
6345 * Represents an Angular View.
6346 *
6347 * <!-- TODO: move the next two paragraphs to the dev guide -->
6348 * A View is a fundamental building block of the application UI. It is the smallest grouping of
6349 * Elements which are created and destroyed together.
6350 *
6351 * Properties of elements in a View can change, but the structure (number and order) of elements in
6352 * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
6353 * removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
6354 * <!-- /TODO -->
6355 *
6356 * ### Example
6357 *
6358 * Given this template...
6359 *
6360 * ```
6361 * Count: {{items.length}}
6362 * <ul>
6363 * <li *ngFor="let item of items">{{item}}</li>
6364 * </ul>
6365 * ```
6366 *
6367 * We have two {\@link TemplateRef}s:
6368 *
6369 * Outer {\@link TemplateRef}:
6370 * ```
6371 * Count: {{items.length}}
6372 * <ul>
6373 * <ng-template ngFor let-item [ngForOf]="items"></ng-template>
6374 * </ul>
6375 * ```
6376 *
6377 * Inner {\@link TemplateRef}:
6378 * ```
6379 * <li>{{item}}</li>
6380 * ```
6381 *
6382 * Notice that the original template is broken down into two separate {\@link TemplateRef}s.
6383 *
6384 * The outer/inner {\@link TemplateRef}s are then assembled into views like so:
6385 *
6386 * ```
6387 * <!-- ViewRef: outer-0 -->
6388 * Count: 2
6389 * <ul>
6390 * <ng-template view-container-ref></ng-template>
6391 * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
6392 * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
6393 * </ul>
6394 * <!-- /ViewRef: outer-0 -->
6395 * ```
6396 * \@experimental
6397 * @abstract
6398 */
6399var EmbeddedViewRef = (function (_super) {
6400 __extends(EmbeddedViewRef, _super);
6401 function EmbeddedViewRef() {
6402 return _super !== null && _super.apply(this, arguments) || this;
6403 }
6404 /**
6405 * @abstract
6406 * @return {?}
6407 */
6408 EmbeddedViewRef.prototype.context = function () { };
6409 /**
6410 * @abstract
6411 * @return {?}
6412 */
6413 EmbeddedViewRef.prototype.rootNodes = function () { };
6414 return EmbeddedViewRef;
6415}(ViewRef));
6416/**
6417 * @license
6418 * Copyright Google Inc. All Rights Reserved.
6419 *
6420 * Use of this source code is governed by an MIT-style license that can be
6421 * found in the LICENSE file at https://angular.io/license
6422 */
6423// Public API for compiler
6424/**
6425 * @license
6426 * Copyright Google Inc. All Rights Reserved.
6427 *
6428 * Use of this source code is governed by an MIT-style license that can be
6429 * found in the LICENSE file at https://angular.io/license
6430 */
6431var EventListener = (function () {
6432 /**
6433 * @param {?} name
6434 * @param {?} callback
6435 */
6436 function EventListener(name, callback) {
6437 this.name = name;
6438 this.callback = callback;
6439 }
6440
6441 return EventListener;
6442}());
6443/**
6444 * \@experimental All debugging apis are currently experimental.
6445 */
6446var DebugNode = (function () {
6447 /**
6448 * @param {?} nativeNode
6449 * @param {?} parent
6450 * @param {?} _debugContext
6451 */
6452 function DebugNode(nativeNode, parent, _debugContext) {
6453 this._debugContext = _debugContext;
6454 this.nativeNode = nativeNode;
6455 if (parent && parent instanceof DebugElement) {
6456 parent.addChild(this);
6457 }
6458 else {
6459 this.parent = null;
6460 }
6461 this.listeners = [];
6462 }
6463 Object.defineProperty(DebugNode.prototype, "injector", {
6464 /**
6465 * @return {?}
6466 */
6467 get: function () { return this._debugContext.injector; },
6468 enumerable: true,
6469 configurable: true
6470 });
6471 Object.defineProperty(DebugNode.prototype, "componentInstance", {
6472 /**
6473 * @return {?}
6474 */
6475 get: function () { return this._debugContext.component; },
6476 enumerable: true,
6477 configurable: true
6478 });
6479 Object.defineProperty(DebugNode.prototype, "context", {
6480 /**
6481 * @return {?}
6482 */
6483 get: function () { return this._debugContext.context; },
6484 enumerable: true,
6485 configurable: true
6486 });
6487 Object.defineProperty(DebugNode.prototype, "references", {
6488 /**
6489 * @return {?}
6490 */
6491 get: function () { return this._debugContext.references; },
6492 enumerable: true,
6493 configurable: true
6494 });
6495 Object.defineProperty(DebugNode.prototype, "providerTokens", {
6496 /**
6497 * @return {?}
6498 */
6499 get: function () { return this._debugContext.providerTokens; },
6500 enumerable: true,
6501 configurable: true
6502 });
6503 Object.defineProperty(DebugNode.prototype, "source", {
6504 /**
6505 * @deprecated since v4
6506 * @return {?}
6507 */
6508 get: function () { return 'Deprecated since v4'; },
6509 enumerable: true,
6510 configurable: true
6511 });
6512 return DebugNode;
6513}());
6514/**
6515 * \@experimental All debugging apis are currently experimental.
6516 */
6517var DebugElement = (function (_super) {
6518 __extends(DebugElement, _super);
6519 /**
6520 * @param {?} nativeNode
6521 * @param {?} parent
6522 * @param {?} _debugContext
6523 */
6524 function DebugElement(nativeNode, parent, _debugContext) {
6525 var _this = _super.call(this, nativeNode, parent, _debugContext) || this;
6526 _this.properties = {};
6527 _this.attributes = {};
6528 _this.classes = {};
6529 _this.styles = {};
6530 _this.childNodes = [];
6531 _this.nativeElement = nativeNode;
6532 return _this;
6533 }
6534 /**
6535 * @param {?} child
6536 * @return {?}
6537 */
6538 DebugElement.prototype.addChild = function (child) {
6539 if (child) {
6540 this.childNodes.push(child);
6541 child.parent = this;
6542 }
6543 };
6544 /**
6545 * @param {?} child
6546 * @return {?}
6547 */
6548 DebugElement.prototype.removeChild = function (child) {
6549 var /** @type {?} */ childIndex = this.childNodes.indexOf(child);
6550 if (childIndex !== -1) {
6551 child.parent = null;
6552 this.childNodes.splice(childIndex, 1);
6553 }
6554 };
6555 /**
6556 * @param {?} child
6557 * @param {?} newChildren
6558 * @return {?}
6559 */
6560 DebugElement.prototype.insertChildrenAfter = function (child, newChildren) {
6561 var _this = this;
6562 var /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
6563 if (siblingIndex !== -1) {
6564 (_a = this.childNodes).splice.apply(_a, [siblingIndex + 1, 0].concat(newChildren));
6565 newChildren.forEach(function (c) {
6566 if (c.parent) {
6567 c.parent.removeChild(c);
6568 }
6569 c.parent = _this;
6570 });
6571 }
6572 var _a;
6573 };
6574 /**
6575 * @param {?} refChild
6576 * @param {?} newChild
6577 * @return {?}
6578 */
6579 DebugElement.prototype.insertBefore = function (refChild, newChild) {
6580 var /** @type {?} */ refIndex = this.childNodes.indexOf(refChild);
6581 if (refIndex === -1) {
6582 this.addChild(newChild);
6583 }
6584 else {
6585 if (newChild.parent) {
6586 newChild.parent.removeChild(newChild);
6587 }
6588 newChild.parent = this;
6589 this.childNodes.splice(refIndex, 0, newChild);
6590 }
6591 };
6592 /**
6593 * @param {?} predicate
6594 * @return {?}
6595 */
6596 DebugElement.prototype.query = function (predicate) {
6597 var /** @type {?} */ results = this.queryAll(predicate);
6598 return results[0] || null;
6599 };
6600 /**
6601 * @param {?} predicate
6602 * @return {?}
6603 */
6604 DebugElement.prototype.queryAll = function (predicate) {
6605 var /** @type {?} */ matches = [];
6606 _queryElementChildren(this, predicate, matches);
6607 return matches;
6608 };
6609 /**
6610 * @param {?} predicate
6611 * @return {?}
6612 */
6613 DebugElement.prototype.queryAllNodes = function (predicate) {
6614 var /** @type {?} */ matches = [];
6615 _queryNodeChildren(this, predicate, matches);
6616 return matches;
6617 };
6618 Object.defineProperty(DebugElement.prototype, "children", {
6619 /**
6620 * @return {?}
6621 */
6622 get: function () {
6623 return (this.childNodes.filter(function (node) { return node instanceof DebugElement; }));
6624 },
6625 enumerable: true,
6626 configurable: true
6627 });
6628 /**
6629 * @param {?} eventName
6630 * @param {?} eventObj
6631 * @return {?}
6632 */
6633 DebugElement.prototype.triggerEventHandler = function (eventName, eventObj) {
6634 this.listeners.forEach(function (listener) {
6635 if (listener.name == eventName) {
6636 listener.callback(eventObj);
6637 }
6638 });
6639 };
6640 return DebugElement;
6641}(DebugNode));
6642/**
6643 * \@experimental
6644 * @param {?} debugEls
6645 * @return {?}
6646 */
6647function asNativeElements(debugEls) {
6648 return debugEls.map(function (el) { return el.nativeElement; });
6649}
6650/**
6651 * @param {?} element
6652 * @param {?} predicate
6653 * @param {?} matches
6654 * @return {?}
6655 */
6656function _queryElementChildren(element, predicate, matches) {
6657 element.childNodes.forEach(function (node) {
6658 if (node instanceof DebugElement) {
6659 if (predicate(node)) {
6660 matches.push(node);
6661 }
6662 _queryElementChildren(node, predicate, matches);
6663 }
6664 });
6665}
6666/**
6667 * @param {?} parentNode
6668 * @param {?} predicate
6669 * @param {?} matches
6670 * @return {?}
6671 */
6672function _queryNodeChildren(parentNode, predicate, matches) {
6673 if (parentNode instanceof DebugElement) {
6674 parentNode.childNodes.forEach(function (node) {
6675 if (predicate(node)) {
6676 matches.push(node);
6677 }
6678 if (node instanceof DebugElement) {
6679 _queryNodeChildren(node, predicate, matches);
6680 }
6681 });
6682 }
6683}
6684// Need to keep the nodes in a global Map so that multiple angular apps are supported.
6685var _nativeNodeToDebugNode = new Map();
6686/**
6687 * \@experimental
6688 * @param {?} nativeNode
6689 * @return {?}
6690 */
6691function getDebugNode(nativeNode) {
6692 return _nativeNodeToDebugNode.get(nativeNode) || null;
6693}
6694/**
6695 * @return {?}
6696 */
6697/**
6698 * @param {?} node
6699 * @return {?}
6700 */
6701function indexDebugNode(node) {
6702 _nativeNodeToDebugNode.set(node.nativeNode, node);
6703}
6704/**
6705 * @param {?} node
6706 * @return {?}
6707 */
6708function removeDebugNodeFromIndex(node) {
6709 _nativeNodeToDebugNode.delete(node.nativeNode);
6710}
6711/**
6712 * @license
6713 * Copyright Google Inc. All Rights Reserved.
6714 *
6715 * Use of this source code is governed by an MIT-style license that can be
6716 * found in the LICENSE file at https://angular.io/license
6717 */
6718/**
6719 * @param {?} a
6720 * @param {?} b
6721 * @return {?}
6722 */
6723function devModeEqual(a, b) {
6724 var /** @type {?} */ isListLikeIterableA = isListLikeIterable(a);
6725 var /** @type {?} */ isListLikeIterableB = isListLikeIterable(b);
6726 if (isListLikeIterableA && isListLikeIterableB) {
6727 return areIterablesEqual(a, b, devModeEqual);
6728 }
6729 else {
6730 var /** @type {?} */ isAObject = a && (typeof a === 'object' || typeof a === 'function');
6731 var /** @type {?} */ isBObject = b && (typeof b === 'object' || typeof b === 'function');
6732 if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
6733 return true;
6734 }
6735 else {
6736 return looseIdentical(a, b);
6737 }
6738 }
6739}
6740/**
6741 * Indicates that the result of a {\@link Pipe} transformation has changed even though the
6742 * reference
6743 * has not changed.
6744 *
6745 * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
6746 *
6747 * Example:
6748 *
6749 * ```
6750 * if (this._latestValue === this._latestReturnedValue) {
6751 * return this._latestReturnedValue;
6752 * } else {
6753 * this._latestReturnedValue = this._latestValue;
6754 * return WrappedValue.wrap(this._latestValue); // this will force update
6755 * }
6756 * ```
6757 * \@stable
6758 */
6759var WrappedValue = (function () {
6760 /**
6761 * @param {?} wrapped
6762 */
6763 function WrappedValue(wrapped) {
6764 this.wrapped = wrapped;
6765 }
6766 /**
6767 * @param {?} value
6768 * @return {?}
6769 */
6770 WrappedValue.wrap = function (value) { return new WrappedValue(value); };
6771 return WrappedValue;
6772}());
6773/**
6774 * Helper class for unwrapping WrappedValue s
6775 */
6776var ValueUnwrapper = (function () {
6777 function ValueUnwrapper() {
6778 this.hasWrappedValue = false;
6779 }
6780 /**
6781 * @param {?} value
6782 * @return {?}
6783 */
6784 ValueUnwrapper.prototype.unwrap = function (value) {
6785 if (value instanceof WrappedValue) {
6786 this.hasWrappedValue = true;
6787 return value.wrapped;
6788 }
6789 return value;
6790 };
6791 /**
6792 * @return {?}
6793 */
6794 ValueUnwrapper.prototype.reset = function () { this.hasWrappedValue = false; };
6795 return ValueUnwrapper;
6796}());
6797/**
6798 * Represents a basic change from a previous to a new value.
6799 * \@stable
6800 */
6801var SimpleChange = (function () {
6802 /**
6803 * @param {?} previousValue
6804 * @param {?} currentValue
6805 * @param {?} firstChange
6806 */
6807 function SimpleChange(previousValue, currentValue, firstChange) {
6808 this.previousValue = previousValue;
6809 this.currentValue = currentValue;
6810 this.firstChange = firstChange;
6811 }
6812 /**
6813 * Check whether the new value is the first value assigned.
6814 * @return {?}
6815 */
6816 SimpleChange.prototype.isFirstChange = function () { return this.firstChange; };
6817 return SimpleChange;
6818}());
6819/**
6820 * @param {?} obj
6821 * @return {?}
6822 */
6823function isListLikeIterable(obj) {
6824 if (!isJsObject(obj))
6825 return false;
6826 return Array.isArray(obj) ||
6827 (!(obj instanceof Map) &&
6828 getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
6829}
6830/**
6831 * @param {?} a
6832 * @param {?} b
6833 * @param {?} comparator
6834 * @return {?}
6835 */
6836function areIterablesEqual(a, b, comparator) {
6837 var /** @type {?} */ iterator1 = a[getSymbolIterator()]();
6838 var /** @type {?} */ iterator2 = b[getSymbolIterator()]();
6839 while (true) {
6840 var /** @type {?} */ item1 = iterator1.next();
6841 var /** @type {?} */ item2 = iterator2.next();
6842 if (item1.done && item2.done)
6843 return true;
6844 if (item1.done || item2.done)
6845 return false;
6846 if (!comparator(item1.value, item2.value))
6847 return false;
6848 }
6849}
6850/**
6851 * @param {?} obj
6852 * @param {?} fn
6853 * @return {?}
6854 */
6855function iterateListLike(obj, fn) {
6856 if (Array.isArray(obj)) {
6857 for (var /** @type {?} */ i = 0; i < obj.length; i++) {
6858 fn(obj[i]);
6859 }
6860 }
6861 else {
6862 var /** @type {?} */ iterator = obj[getSymbolIterator()]();
6863 var /** @type {?} */ item = void 0;
6864 while (!((item = iterator.next()).done)) {
6865 fn(item.value);
6866 }
6867 }
6868}
6869/**
6870 * @param {?} o
6871 * @return {?}
6872 */
6873function isJsObject(o) {
6874 return o !== null && (typeof o === 'function' || typeof o === 'object');
6875}
6876/**
6877 * @license
6878 * Copyright Google Inc. All Rights Reserved.
6879 *
6880 * Use of this source code is governed by an MIT-style license that can be
6881 * found in the LICENSE file at https://angular.io/license
6882 */
6883var DefaultIterableDifferFactory = (function () {
6884 function DefaultIterableDifferFactory() {
6885 }
6886 /**
6887 * @param {?} obj
6888 * @return {?}
6889 */
6890 DefaultIterableDifferFactory.prototype.supports = function (obj) { return isListLikeIterable(obj); };
6891 /**
6892 * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
6893 * @template V
6894 * @param {?=} cdRefOrTrackBy
6895 * @param {?=} trackByFn
6896 * @return {?}
6897 */
6898 DefaultIterableDifferFactory.prototype.create = function (cdRefOrTrackBy, trackByFn) {
6899 return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
6900 };
6901 return DefaultIterableDifferFactory;
6902}());
6903var trackByIdentity = function (index, item) { return item; };
6904/**
6905 * @deprecated v4.0.0 - Should not be part of public API.
6906 */
6907var DefaultIterableDiffer = (function () {
6908 /**
6909 * @param {?=} trackByFn
6910 */
6911 function DefaultIterableDiffer(trackByFn) {
6912 this._length = 0;
6913 this._collection = null;
6914 this._linkedRecords = null;
6915 this._unlinkedRecords = null;
6916 this._previousItHead = null;
6917 this._itHead = null;
6918 this._itTail = null;
6919 this._additionsHead = null;
6920 this._additionsTail = null;
6921 this._movesHead = null;
6922 this._movesTail = null;
6923 this._removalsHead = null;
6924 this._removalsTail = null;
6925 this._identityChangesHead = null;
6926 this._identityChangesTail = null;
6927 this._trackByFn = trackByFn || trackByIdentity;
6928 }
6929 Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
6930 /**
6931 * @return {?}
6932 */
6933 get: function () { return this._collection; },
6934 enumerable: true,
6935 configurable: true
6936 });
6937 Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
6938 /**
6939 * @return {?}
6940 */
6941 get: function () { return this._length; },
6942 enumerable: true,
6943 configurable: true
6944 });
6945 /**
6946 * @param {?} fn
6947 * @return {?}
6948 */
6949 DefaultIterableDiffer.prototype.forEachItem = function (fn) {
6950 var /** @type {?} */ record;
6951 for (record = this._itHead; record !== null; record = record._next) {
6952 fn(record);
6953 }
6954 };
6955 /**
6956 * @param {?} fn
6957 * @return {?}
6958 */
6959 DefaultIterableDiffer.prototype.forEachOperation = function (fn) {
6960 var /** @type {?} */ nextIt = this._itHead;
6961 var /** @type {?} */ nextRemove = this._removalsHead;
6962 var /** @type {?} */ addRemoveOffset = 0;
6963 var /** @type {?} */ moveOffsets = null;
6964 while (nextIt || nextRemove) {
6965 // Figure out which is the next record to process
6966 // Order: remove, add, move
6967 var /** @type {?} */ record = !nextRemove ||
6968 nextIt && ((nextIt.currentIndex)) <
6969 getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
6970 nextRemove;
6971 var /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
6972 var /** @type {?} */ currentIndex = record.currentIndex;
6973 // consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
6974 if (record === nextRemove) {
6975 addRemoveOffset--;
6976 nextRemove = nextRemove._nextRemoved;
6977 }
6978 else {
6979 nextIt = ((nextIt))._next;
6980 if (record.previousIndex == null) {
6981 addRemoveOffset++;
6982 }
6983 else {
6984 // INVARIANT: currentIndex < previousIndex
6985 if (!moveOffsets)
6986 moveOffsets = [];
6987 var /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
6988 var /** @type {?} */ localCurrentIndex = ((currentIndex)) - addRemoveOffset;
6989 if (localMovePreviousIndex != localCurrentIndex) {
6990 for (var /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
6991 var /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
6992 var /** @type {?} */ index = offset + i;
6993 if (localCurrentIndex <= index && index < localMovePreviousIndex) {
6994 moveOffsets[i] = offset + 1;
6995 }
6996 }
6997 var /** @type {?} */ previousIndex = record.previousIndex;
6998 moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
6999 }
7000 }
7001 }
7002 if (adjPreviousIndex !== currentIndex) {
7003 fn(record, adjPreviousIndex, currentIndex);
7004 }
7005 }
7006 };
7007 /**
7008 * @param {?} fn
7009 * @return {?}
7010 */
7011 DefaultIterableDiffer.prototype.forEachPreviousItem = function (fn) {
7012 var /** @type {?} */ record;
7013 for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
7014 fn(record);
7015 }
7016 };
7017 /**
7018 * @param {?} fn
7019 * @return {?}
7020 */
7021 DefaultIterableDiffer.prototype.forEachAddedItem = function (fn) {
7022 var /** @type {?} */ record;
7023 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
7024 fn(record);
7025 }
7026 };
7027 /**
7028 * @param {?} fn
7029 * @return {?}
7030 */
7031 DefaultIterableDiffer.prototype.forEachMovedItem = function (fn) {
7032 var /** @type {?} */ record;
7033 for (record = this._movesHead; record !== null; record = record._nextMoved) {
7034 fn(record);
7035 }
7036 };
7037 /**
7038 * @param {?} fn
7039 * @return {?}
7040 */
7041 DefaultIterableDiffer.prototype.forEachRemovedItem = function (fn) {
7042 var /** @type {?} */ record;
7043 for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
7044 fn(record);
7045 }
7046 };
7047 /**
7048 * @param {?} fn
7049 * @return {?}
7050 */
7051 DefaultIterableDiffer.prototype.forEachIdentityChange = function (fn) {
7052 var /** @type {?} */ record;
7053 for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
7054 fn(record);
7055 }
7056 };
7057 /**
7058 * @param {?} collection
7059 * @return {?}
7060 */
7061 DefaultIterableDiffer.prototype.diff = function (collection) {
7062 if (collection == null)
7063 collection = [];
7064 if (!isListLikeIterable(collection)) {
7065 throw new Error("Error trying to diff '" + stringify(collection) + "'. Only arrays and iterables are allowed");
7066 }
7067 if (this.check(collection)) {
7068 return this;
7069 }
7070 else {
7071 return null;
7072 }
7073 };
7074 /**
7075 * @return {?}
7076 */
7077 DefaultIterableDiffer.prototype.onDestroy = function () { };
7078 /**
7079 * @param {?} collection
7080 * @return {?}
7081 */
7082 DefaultIterableDiffer.prototype.check = function (collection) {
7083 var _this = this;
7084 this._reset();
7085 var /** @type {?} */ record = this._itHead;
7086 var /** @type {?} */ mayBeDirty = false;
7087 var /** @type {?} */ index;
7088 var /** @type {?} */ item;
7089 var /** @type {?} */ itemTrackBy;
7090 if (Array.isArray(collection)) {
7091 this._length = collection.length;
7092 for (var /** @type {?} */ index_1 = 0; index_1 < this._length; index_1++) {
7093 item = collection[index_1];
7094 itemTrackBy = this._trackByFn(index_1, item);
7095 if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
7096 record = this._mismatch(record, item, itemTrackBy, index_1);
7097 mayBeDirty = true;
7098 }
7099 else {
7100 if (mayBeDirty) {
7101 // TODO(misko): can we limit this to duplicates only?
7102 record = this._verifyReinsertion(record, item, itemTrackBy, index_1);
7103 }
7104 if (!looseIdentical(record.item, item))
7105 this._addIdentityChange(record, item);
7106 }
7107 record = record._next;
7108 }
7109 }
7110 else {
7111 index = 0;
7112 iterateListLike(collection, function (item) {
7113 itemTrackBy = _this._trackByFn(index, item);
7114 if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
7115 record = _this._mismatch(record, item, itemTrackBy, index);
7116 mayBeDirty = true;
7117 }
7118 else {
7119 if (mayBeDirty) {
7120 // TODO(misko): can we limit this to duplicates only?
7121 record = _this._verifyReinsertion(record, item, itemTrackBy, index);
7122 }
7123 if (!looseIdentical(record.item, item))
7124 _this._addIdentityChange(record, item);
7125 }
7126 record = record._next;
7127 index++;
7128 });
7129 this._length = index;
7130 }
7131 this._truncate(record);
7132 this._collection = collection;
7133 return this.isDirty;
7134 };
7135 Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
7136 /**
7137 * @return {?}
7138 */
7139 get: function () {
7140 return this._additionsHead !== null || this._movesHead !== null ||
7141 this._removalsHead !== null || this._identityChangesHead !== null;
7142 },
7143 enumerable: true,
7144 configurable: true
7145 });
7146 /**
7147 * Reset the state of the change objects to show no changes. This means set previousKey to
7148 * currentKey, and clear all of the queues (additions, moves, removals).
7149 * Set the previousIndexes of moved and added items to their currentIndexes
7150 * Reset the list of additions, moves and removals
7151 *
7152 * \@internal
7153 * @return {?}
7154 */
7155 DefaultIterableDiffer.prototype._reset = function () {
7156 if (this.isDirty) {
7157 var /** @type {?} */ record = void 0;
7158 var /** @type {?} */ nextRecord = void 0;
7159 for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
7160 record._nextPrevious = record._next;
7161 }
7162 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
7163 record.previousIndex = record.currentIndex;
7164 }
7165 this._additionsHead = this._additionsTail = null;
7166 for (record = this._movesHead; record !== null; record = nextRecord) {
7167 record.previousIndex = record.currentIndex;
7168 nextRecord = record._nextMoved;
7169 }
7170 this._movesHead = this._movesTail = null;
7171 this._removalsHead = this._removalsTail = null;
7172 this._identityChangesHead = this._identityChangesTail = null;
7173 }
7174 };
7175 /**
7176 * This is the core function which handles differences between collections.
7177 *
7178 * - `record` is the record which we saw at this position last time. If null then it is a new
7179 * item.
7180 * - `item` is the current item in the collection
7181 * - `index` is the position of the item in the collection
7182 *
7183 * \@internal
7184 * @param {?} record
7185 * @param {?} item
7186 * @param {?} itemTrackBy
7187 * @param {?} index
7188 * @return {?}
7189 */
7190 DefaultIterableDiffer.prototype._mismatch = function (record, item, itemTrackBy, index) {
7191 // The previous record after which we will append the current one.
7192 var /** @type {?} */ previousRecord;
7193 if (record === null) {
7194 previousRecord = ((this._itTail));
7195 }
7196 else {
7197 previousRecord = ((record._prev));
7198 // Remove the record from the collection since we know it does not match the item.
7199 this._remove(record);
7200 }
7201 // Attempt to see if we have seen the item before.
7202 record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
7203 if (record !== null) {
7204 // We have seen this before, we need to move it forward in the collection.
7205 // But first we need to check if identity changed, so we can update in view if necessary
7206 if (!looseIdentical(record.item, item))
7207 this._addIdentityChange(record, item);
7208 this._moveAfter(record, previousRecord, index);
7209 }
7210 else {
7211 // Never seen it, check evicted list.
7212 record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
7213 if (record !== null) {
7214 // It is an item which we have evicted earlier: reinsert it back into the list.
7215 // But first we need to check if identity changed, so we can update in view if necessary
7216 if (!looseIdentical(record.item, item))
7217 this._addIdentityChange(record, item);
7218 this._reinsertAfter(record, previousRecord, index);
7219 }
7220 else {
7221 // It is a new item: add it.
7222 record =
7223 this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
7224 }
7225 }
7226 return record;
7227 };
7228 /**
7229 * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
7230 *
7231 * Use case: `[a, a]` => `[b, a, a]`
7232 *
7233 * If we did not have this check then the insertion of `b` would:
7234 * 1) evict first `a`
7235 * 2) insert `b` at `0` index.
7236 * 3) leave `a` at index `1` as is. <-- this is wrong!
7237 * 3) reinsert `a` at index 2. <-- this is wrong!
7238 *
7239 * The correct behavior is:
7240 * 1) evict first `a`
7241 * 2) insert `b` at `0` index.
7242 * 3) reinsert `a` at index 1.
7243 * 3) move `a` at from `1` to `2`.
7244 *
7245 *
7246 * Double check that we have not evicted a duplicate item. We need to check if the item type may
7247 * have already been removed:
7248 * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
7249 * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
7250 * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
7251 * at the end.
7252 *
7253 * \@internal
7254 * @param {?} record
7255 * @param {?} item
7256 * @param {?} itemTrackBy
7257 * @param {?} index
7258 * @return {?}
7259 */
7260 DefaultIterableDiffer.prototype._verifyReinsertion = function (record, item, itemTrackBy, index) {
7261 var /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
7262 if (reinsertRecord !== null) {
7263 record = this._reinsertAfter(reinsertRecord, /** @type {?} */ ((record._prev)), index);
7264 }
7265 else if (record.currentIndex != index) {
7266 record.currentIndex = index;
7267 this._addToMoves(record, index);
7268 }
7269 return record;
7270 };
7271 /**
7272 * Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
7273 *
7274 * - `record` The first excess {\@link IterableChangeRecord_}.
7275 *
7276 * \@internal
7277 * @param {?} record
7278 * @return {?}
7279 */
7280 DefaultIterableDiffer.prototype._truncate = function (record) {
7281 // Anything after that needs to be removed;
7282 while (record !== null) {
7283 var /** @type {?} */ nextRecord = record._next;
7284 this._addToRemovals(this._unlink(record));
7285 record = nextRecord;
7286 }
7287 if (this._unlinkedRecords !== null) {
7288 this._unlinkedRecords.clear();
7289 }
7290 if (this._additionsTail !== null) {
7291 this._additionsTail._nextAdded = null;
7292 }
7293 if (this._movesTail !== null) {
7294 this._movesTail._nextMoved = null;
7295 }
7296 if (this._itTail !== null) {
7297 this._itTail._next = null;
7298 }
7299 if (this._removalsTail !== null) {
7300 this._removalsTail._nextRemoved = null;
7301 }
7302 if (this._identityChangesTail !== null) {
7303 this._identityChangesTail._nextIdentityChange = null;
7304 }
7305 };
7306 /**
7307 * \@internal
7308 * @param {?} record
7309 * @param {?} prevRecord
7310 * @param {?} index
7311 * @return {?}
7312 */
7313 DefaultIterableDiffer.prototype._reinsertAfter = function (record, prevRecord, index) {
7314 if (this._unlinkedRecords !== null) {
7315 this._unlinkedRecords.remove(record);
7316 }
7317 var /** @type {?} */ prev = record._prevRemoved;
7318 var /** @type {?} */ next = record._nextRemoved;
7319 if (prev === null) {
7320 this._removalsHead = next;
7321 }
7322 else {
7323 prev._nextRemoved = next;
7324 }
7325 if (next === null) {
7326 this._removalsTail = prev;
7327 }
7328 else {
7329 next._prevRemoved = prev;
7330 }
7331 this._insertAfter(record, prevRecord, index);
7332 this._addToMoves(record, index);
7333 return record;
7334 };
7335 /**
7336 * \@internal
7337 * @param {?} record
7338 * @param {?} prevRecord
7339 * @param {?} index
7340 * @return {?}
7341 */
7342 DefaultIterableDiffer.prototype._moveAfter = function (record, prevRecord, index) {
7343 this._unlink(record);
7344 this._insertAfter(record, prevRecord, index);
7345 this._addToMoves(record, index);
7346 return record;
7347 };
7348 /**
7349 * \@internal
7350 * @param {?} record
7351 * @param {?} prevRecord
7352 * @param {?} index
7353 * @return {?}
7354 */
7355 DefaultIterableDiffer.prototype._addAfter = function (record, prevRecord, index) {
7356 this._insertAfter(record, prevRecord, index);
7357 if (this._additionsTail === null) {
7358 // todo(vicb)
7359 // assert(this._additionsHead === null);
7360 this._additionsTail = this._additionsHead = record;
7361 }
7362 else {
7363 // todo(vicb)
7364 // assert(_additionsTail._nextAdded === null);
7365 // assert(record._nextAdded === null);
7366 this._additionsTail = this._additionsTail._nextAdded = record;
7367 }
7368 return record;
7369 };
7370 /**
7371 * \@internal
7372 * @param {?} record
7373 * @param {?} prevRecord
7374 * @param {?} index
7375 * @return {?}
7376 */
7377 DefaultIterableDiffer.prototype._insertAfter = function (record, prevRecord, index) {
7378 // todo(vicb)
7379 // assert(record != prevRecord);
7380 // assert(record._next === null);
7381 // assert(record._prev === null);
7382 var /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
7383 // todo(vicb)
7384 // assert(next != record);
7385 // assert(prevRecord != record);
7386 record._next = next;
7387 record._prev = prevRecord;
7388 if (next === null) {
7389 this._itTail = record;
7390 }
7391 else {
7392 next._prev = record;
7393 }
7394 if (prevRecord === null) {
7395 this._itHead = record;
7396 }
7397 else {
7398 prevRecord._next = record;
7399 }
7400 if (this._linkedRecords === null) {
7401 this._linkedRecords = new _DuplicateMap();
7402 }
7403 this._linkedRecords.put(record);
7404 record.currentIndex = index;
7405 return record;
7406 };
7407 /**
7408 * \@internal
7409 * @param {?} record
7410 * @return {?}
7411 */
7412 DefaultIterableDiffer.prototype._remove = function (record) {
7413 return this._addToRemovals(this._unlink(record));
7414 };
7415 /**
7416 * \@internal
7417 * @param {?} record
7418 * @return {?}
7419 */
7420 DefaultIterableDiffer.prototype._unlink = function (record) {
7421 if (this._linkedRecords !== null) {
7422 this._linkedRecords.remove(record);
7423 }
7424 var /** @type {?} */ prev = record._prev;
7425 var /** @type {?} */ next = record._next;
7426 // todo(vicb)
7427 // assert((record._prev = null) === null);
7428 // assert((record._next = null) === null);
7429 if (prev === null) {
7430 this._itHead = next;
7431 }
7432 else {
7433 prev._next = next;
7434 }
7435 if (next === null) {
7436 this._itTail = prev;
7437 }
7438 else {
7439 next._prev = prev;
7440 }
7441 return record;
7442 };
7443 /**
7444 * \@internal
7445 * @param {?} record
7446 * @param {?} toIndex
7447 * @return {?}
7448 */
7449 DefaultIterableDiffer.prototype._addToMoves = function (record, toIndex) {
7450 // todo(vicb)
7451 // assert(record._nextMoved === null);
7452 if (record.previousIndex === toIndex) {
7453 return record;
7454 }
7455 if (this._movesTail === null) {
7456 // todo(vicb)
7457 // assert(_movesHead === null);
7458 this._movesTail = this._movesHead = record;
7459 }
7460 else {
7461 // todo(vicb)
7462 // assert(_movesTail._nextMoved === null);
7463 this._movesTail = this._movesTail._nextMoved = record;
7464 }
7465 return record;
7466 };
7467 /**
7468 * @param {?} record
7469 * @return {?}
7470 */
7471 DefaultIterableDiffer.prototype._addToRemovals = function (record) {
7472 if (this._unlinkedRecords === null) {
7473 this._unlinkedRecords = new _DuplicateMap();
7474 }
7475 this._unlinkedRecords.put(record);
7476 record.currentIndex = null;
7477 record._nextRemoved = null;
7478 if (this._removalsTail === null) {
7479 // todo(vicb)
7480 // assert(_removalsHead === null);
7481 this._removalsTail = this._removalsHead = record;
7482 record._prevRemoved = null;
7483 }
7484 else {
7485 // todo(vicb)
7486 // assert(_removalsTail._nextRemoved === null);
7487 // assert(record._nextRemoved === null);
7488 record._prevRemoved = this._removalsTail;
7489 this._removalsTail = this._removalsTail._nextRemoved = record;
7490 }
7491 return record;
7492 };
7493 /**
7494 * \@internal
7495 * @param {?} record
7496 * @param {?} item
7497 * @return {?}
7498 */
7499 DefaultIterableDiffer.prototype._addIdentityChange = function (record, item) {
7500 record.item = item;
7501 if (this._identityChangesTail === null) {
7502 this._identityChangesTail = this._identityChangesHead = record;
7503 }
7504 else {
7505 this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
7506 }
7507 return record;
7508 };
7509 /**
7510 * @return {?}
7511 */
7512 DefaultIterableDiffer.prototype.toString = function () {
7513 var /** @type {?} */ list = [];
7514 this.forEachItem(function (record) { return list.push(record); });
7515 var /** @type {?} */ previous = [];
7516 this.forEachPreviousItem(function (record) { return previous.push(record); });
7517 var /** @type {?} */ additions = [];
7518 this.forEachAddedItem(function (record) { return additions.push(record); });
7519 var /** @type {?} */ moves = [];
7520 this.forEachMovedItem(function (record) { return moves.push(record); });
7521 var /** @type {?} */ removals = [];
7522 this.forEachRemovedItem(function (record) { return removals.push(record); });
7523 var /** @type {?} */ identityChanges = [];
7524 this.forEachIdentityChange(function (record) { return identityChanges.push(record); });
7525 return 'collection: ' + list.join(', ') + '\n' +
7526 'previous: ' + previous.join(', ') + '\n' +
7527 'additions: ' + additions.join(', ') + '\n' +
7528 'moves: ' + moves.join(', ') + '\n' +
7529 'removals: ' + removals.join(', ') + '\n' +
7530 'identityChanges: ' + identityChanges.join(', ') + '\n';
7531 };
7532 return DefaultIterableDiffer;
7533}());
7534/**
7535 * \@stable
7536 */
7537var IterableChangeRecord_ = (function () {
7538 /**
7539 * @param {?} item
7540 * @param {?} trackById
7541 */
7542 function IterableChangeRecord_(item, trackById) {
7543 this.item = item;
7544 this.trackById = trackById;
7545 this.currentIndex = null;
7546 this.previousIndex = null;
7547 /**
7548 * \@internal
7549 */
7550 this._nextPrevious = null;
7551 /**
7552 * \@internal
7553 */
7554 this._prev = null;
7555 /**
7556 * \@internal
7557 */
7558 this._next = null;
7559 /**
7560 * \@internal
7561 */
7562 this._prevDup = null;
7563 /**
7564 * \@internal
7565 */
7566 this._nextDup = null;
7567 /**
7568 * \@internal
7569 */
7570 this._prevRemoved = null;
7571 /**
7572 * \@internal
7573 */
7574 this._nextRemoved = null;
7575 /**
7576 * \@internal
7577 */
7578 this._nextAdded = null;
7579 /**
7580 * \@internal
7581 */
7582 this._nextMoved = null;
7583 /**
7584 * \@internal
7585 */
7586 this._nextIdentityChange = null;
7587 }
7588 /**
7589 * @return {?}
7590 */
7591 IterableChangeRecord_.prototype.toString = function () {
7592 return this.previousIndex === this.currentIndex ? stringify(this.item) :
7593 stringify(this.item) + '[' +
7594 stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
7595 };
7596 return IterableChangeRecord_;
7597}());
7598var _DuplicateItemRecordList = (function () {
7599 function _DuplicateItemRecordList() {
7600 /**
7601 * \@internal
7602 */
7603 this._head = null;
7604 /**
7605 * \@internal
7606 */
7607 this._tail = null;
7608 }
7609 /**
7610 * Append the record to the list of duplicates.
7611 *
7612 * Note: by design all records in the list of duplicates hold the same value in record.item.
7613 * @param {?} record
7614 * @return {?}
7615 */
7616 _DuplicateItemRecordList.prototype.add = function (record) {
7617 if (this._head === null) {
7618 this._head = this._tail = record;
7619 record._nextDup = null;
7620 record._prevDup = null;
7621 }
7622 else {
7623 ((
7624 // todo(vicb)
7625 // assert(record.item == _head.item ||
7626 // record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
7627 this._tail))._nextDup = record;
7628 record._prevDup = this._tail;
7629 record._nextDup = null;
7630 this._tail = record;
7631 }
7632 };
7633 /**
7634 * @param {?} trackById
7635 * @param {?} afterIndex
7636 * @return {?}
7637 */
7638 _DuplicateItemRecordList.prototype.get = function (trackById, afterIndex) {
7639 var /** @type {?} */ record;
7640 for (record = this._head; record !== null; record = record._nextDup) {
7641 if ((afterIndex === null || afterIndex < record.currentIndex) &&
7642 looseIdentical(record.trackById, trackById)) {
7643 return record;
7644 }
7645 }
7646 return null;
7647 };
7648 /**
7649 * Remove one {\@link IterableChangeRecord_} from the list of duplicates.
7650 *
7651 * Returns whether the list of duplicates is empty.
7652 * @param {?} record
7653 * @return {?}
7654 */
7655 _DuplicateItemRecordList.prototype.remove = function (record) {
7656 // todo(vicb)
7657 // assert(() {
7658 // // verify that the record being removed is in the list.
7659 // for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
7660 // if (identical(cursor, record)) return true;
7661 // }
7662 // return false;
7663 //});
7664 var /** @type {?} */ prev = record._prevDup;
7665 var /** @type {?} */ next = record._nextDup;
7666 if (prev === null) {
7667 this._head = next;
7668 }
7669 else {
7670 prev._nextDup = next;
7671 }
7672 if (next === null) {
7673 this._tail = prev;
7674 }
7675 else {
7676 next._prevDup = prev;
7677 }
7678 return this._head === null;
7679 };
7680 return _DuplicateItemRecordList;
7681}());
7682var _DuplicateMap = (function () {
7683 function _DuplicateMap() {
7684 this.map = new Map();
7685 }
7686 /**
7687 * @param {?} record
7688 * @return {?}
7689 */
7690 _DuplicateMap.prototype.put = function (record) {
7691 var /** @type {?} */ key = record.trackById;
7692 var /** @type {?} */ duplicates = this.map.get(key);
7693 if (!duplicates) {
7694 duplicates = new _DuplicateItemRecordList();
7695 this.map.set(key, duplicates);
7696 }
7697 duplicates.add(record);
7698 };
7699 /**
7700 * Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
7701 * have already iterated over, we use the afterIndex to pretend it is not there.
7702 *
7703 * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
7704 * have any more `a`s needs to return the last `a` not the first or second.
7705 * @param {?} trackById
7706 * @param {?} afterIndex
7707 * @return {?}
7708 */
7709 _DuplicateMap.prototype.get = function (trackById, afterIndex) {
7710 var /** @type {?} */ key = trackById;
7711 var /** @type {?} */ recordList = this.map.get(key);
7712 return recordList ? recordList.get(trackById, afterIndex) : null;
7713 };
7714 /**
7715 * Removes a {\@link IterableChangeRecord_} from the list of duplicates.
7716 *
7717 * The list of duplicates also is removed from the map if it gets empty.
7718 * @param {?} record
7719 * @return {?}
7720 */
7721 _DuplicateMap.prototype.remove = function (record) {
7722 var /** @type {?} */ key = record.trackById;
7723 var /** @type {?} */ recordList = ((this.map.get(key)));
7724 // Remove the list of duplicates when it gets empty
7725 if (recordList.remove(record)) {
7726 this.map.delete(key);
7727 }
7728 return record;
7729 };
7730 Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
7731 /**
7732 * @return {?}
7733 */
7734 get: function () { return this.map.size === 0; },
7735 enumerable: true,
7736 configurable: true
7737 });
7738 /**
7739 * @return {?}
7740 */
7741 _DuplicateMap.prototype.clear = function () { this.map.clear(); };
7742 /**
7743 * @return {?}
7744 */
7745 _DuplicateMap.prototype.toString = function () { return '_DuplicateMap(' + stringify(this.map) + ')'; };
7746 return _DuplicateMap;
7747}());
7748/**
7749 * @param {?} item
7750 * @param {?} addRemoveOffset
7751 * @param {?} moveOffsets
7752 * @return {?}
7753 */
7754function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
7755 var /** @type {?} */ previousIndex = item.previousIndex;
7756 if (previousIndex === null)
7757 return previousIndex;
7758 var /** @type {?} */ moveOffset = 0;
7759 if (moveOffsets && previousIndex < moveOffsets.length) {
7760 moveOffset = moveOffsets[previousIndex];
7761 }
7762 return previousIndex + addRemoveOffset + moveOffset;
7763}
7764/**
7765 * @license
7766 * Copyright Google Inc. All Rights Reserved.
7767 *
7768 * Use of this source code is governed by an MIT-style license that can be
7769 * found in the LICENSE file at https://angular.io/license
7770 */
7771var DefaultKeyValueDifferFactory = (function () {
7772 function DefaultKeyValueDifferFactory() {
7773 }
7774 /**
7775 * @param {?} obj
7776 * @return {?}
7777 */
7778 DefaultKeyValueDifferFactory.prototype.supports = function (obj) { return obj instanceof Map || isJsObject(obj); };
7779 /**
7780 * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
7781 * @template K, V
7782 * @param {?=} cd
7783 * @return {?}
7784 */
7785 DefaultKeyValueDifferFactory.prototype.create = function (cd) {
7786 return new DefaultKeyValueDiffer();
7787 };
7788 return DefaultKeyValueDifferFactory;
7789}());
7790var DefaultKeyValueDiffer = (function () {
7791 function DefaultKeyValueDiffer() {
7792 this._records = new Map();
7793 this._mapHead = null;
7794 this._appendAfter = null;
7795 this._previousMapHead = null;
7796 this._changesHead = null;
7797 this._changesTail = null;
7798 this._additionsHead = null;
7799 this._additionsTail = null;
7800 this._removalsHead = null;
7801 this._removalsTail = null;
7802 }
7803 Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
7804 /**
7805 * @return {?}
7806 */
7807 get: function () {
7808 return this._additionsHead !== null || this._changesHead !== null ||
7809 this._removalsHead !== null;
7810 },
7811 enumerable: true,
7812 configurable: true
7813 });
7814 /**
7815 * @param {?} fn
7816 * @return {?}
7817 */
7818 DefaultKeyValueDiffer.prototype.forEachItem = function (fn) {
7819 var /** @type {?} */ record;
7820 for (record = this._mapHead; record !== null; record = record._next) {
7821 fn(record);
7822 }
7823 };
7824 /**
7825 * @param {?} fn
7826 * @return {?}
7827 */
7828 DefaultKeyValueDiffer.prototype.forEachPreviousItem = function (fn) {
7829 var /** @type {?} */ record;
7830 for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
7831 fn(record);
7832 }
7833 };
7834 /**
7835 * @param {?} fn
7836 * @return {?}
7837 */
7838 DefaultKeyValueDiffer.prototype.forEachChangedItem = function (fn) {
7839 var /** @type {?} */ record;
7840 for (record = this._changesHead; record !== null; record = record._nextChanged) {
7841 fn(record);
7842 }
7843 };
7844 /**
7845 * @param {?} fn
7846 * @return {?}
7847 */
7848 DefaultKeyValueDiffer.prototype.forEachAddedItem = function (fn) {
7849 var /** @type {?} */ record;
7850 for (record = this._additionsHead; record !== null; record = record._nextAdded) {
7851 fn(record);
7852 }
7853 };
7854 /**
7855 * @param {?} fn
7856 * @return {?}
7857 */
7858 DefaultKeyValueDiffer.prototype.forEachRemovedItem = function (fn) {
7859 var /** @type {?} */ record;
7860 for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
7861 fn(record);
7862 }
7863 };
7864 /**
7865 * @param {?=} map
7866 * @return {?}
7867 */
7868 DefaultKeyValueDiffer.prototype.diff = function (map) {
7869 if (!map) {
7870 map = new Map();
7871 }
7872 else if (!(map instanceof Map || isJsObject(map))) {
7873 throw new Error("Error trying to diff '" + stringify(map) + "'. Only maps and objects are allowed");
7874 }
7875 return this.check(map) ? this : null;
7876 };
7877 /**
7878 * @return {?}
7879 */
7880 DefaultKeyValueDiffer.prototype.onDestroy = function () { };
7881 /**
7882 * Check the current state of the map vs the previous.
7883 * The algorithm is optimised for when the keys do no change.
7884 * @param {?} map
7885 * @return {?}
7886 */
7887 DefaultKeyValueDiffer.prototype.check = function (map) {
7888 var _this = this;
7889 this._reset();
7890 var /** @type {?} */ insertBefore = this._mapHead;
7891 this._appendAfter = null;
7892 this._forEach(map, function (value, key) {
7893 if (insertBefore && insertBefore.key === key) {
7894 _this._maybeAddToChanges(insertBefore, value);
7895 _this._appendAfter = insertBefore;
7896 insertBefore = insertBefore._next;
7897 }
7898 else {
7899 var /** @type {?} */ record = _this._getOrCreateRecordForKey(key, value);
7900 insertBefore = _this._insertBeforeOrAppend(insertBefore, record);
7901 }
7902 });
7903 // Items remaining at the end of the list have been deleted
7904 if (insertBefore) {
7905 if (insertBefore._prev) {
7906 insertBefore._prev._next = null;
7907 }
7908 this._removalsHead = insertBefore;
7909 for (var /** @type {?} */ record = insertBefore; record !== null; record = record._nextRemoved) {
7910 if (record === this._mapHead) {
7911 this._mapHead = null;
7912 }
7913 this._records.delete(record.key);
7914 record._nextRemoved = record._next;
7915 record.previousValue = record.currentValue;
7916 record.currentValue = null;
7917 record._prev = null;
7918 record._next = null;
7919 }
7920 }
7921 // Make sure tails have no next records from previous runs
7922 if (this._changesTail)
7923 this._changesTail._nextChanged = null;
7924 if (this._additionsTail)
7925 this._additionsTail._nextAdded = null;
7926 return this.isDirty;
7927 };
7928 /**
7929 * Inserts a record before `before` or append at the end of the list when `before` is null.
7930 *
7931 * Notes:
7932 * - This method appends at `this._appendAfter`,
7933 * - This method updates `this._appendAfter`,
7934 * - The return value is the new value for the insertion pointer.
7935 * @param {?} before
7936 * @param {?} record
7937 * @return {?}
7938 */
7939 DefaultKeyValueDiffer.prototype._insertBeforeOrAppend = function (before, record) {
7940 if (before) {
7941 var /** @type {?} */ prev = before._prev;
7942 record._next = before;
7943 record._prev = prev;
7944 before._prev = record;
7945 if (prev) {
7946 prev._next = record;
7947 }
7948 if (before === this._mapHead) {
7949 this._mapHead = record;
7950 }
7951 this._appendAfter = before;
7952 return before;
7953 }
7954 if (this._appendAfter) {
7955 this._appendAfter._next = record;
7956 record._prev = this._appendAfter;
7957 }
7958 else {
7959 this._mapHead = record;
7960 }
7961 this._appendAfter = record;
7962 return null;
7963 };
7964 /**
7965 * @param {?} key
7966 * @param {?} value
7967 * @return {?}
7968 */
7969 DefaultKeyValueDiffer.prototype._getOrCreateRecordForKey = function (key, value) {
7970 if (this._records.has(key)) {
7971 var /** @type {?} */ record_1 = ((this._records.get(key)));
7972 this._maybeAddToChanges(record_1, value);
7973 var /** @type {?} */ prev = record_1._prev;
7974 var /** @type {?} */ next = record_1._next;
7975 if (prev) {
7976 prev._next = next;
7977 }
7978 if (next) {
7979 next._prev = prev;
7980 }
7981 record_1._next = null;
7982 record_1._prev = null;
7983 return record_1;
7984 }
7985 var /** @type {?} */ record = new KeyValueChangeRecord_(key);
7986 this._records.set(key, record);
7987 record.currentValue = value;
7988 this._addToAdditions(record);
7989 return record;
7990 };
7991 /**
7992 * \@internal
7993 * @return {?}
7994 */
7995 DefaultKeyValueDiffer.prototype._reset = function () {
7996 if (this.isDirty) {
7997 var /** @type {?} */ record = void 0;
7998 // let `_previousMapHead` contain the state of the map before the changes
7999 this._previousMapHead = this._mapHead;
8000 for (record = this._previousMapHead; record !== null; record = record._next) {
8001 record._nextPrevious = record._next;
8002 }
8003 // Update `record.previousValue` with the value of the item before the changes
8004 // We need to update all changed items (that's those which have been added and changed)
8005 for (record = this._changesHead; record !== null; record = record._nextChanged) {
8006 record.previousValue = record.currentValue;
8007 }
8008 for (record = this._additionsHead; record != null; record = record._nextAdded) {
8009 record.previousValue = record.currentValue;
8010 }
8011 this._changesHead = this._changesTail = null;
8012 this._additionsHead = this._additionsTail = null;
8013 this._removalsHead = null;
8014 }
8015 };
8016 /**
8017 * @param {?} record
8018 * @param {?} newValue
8019 * @return {?}
8020 */
8021 DefaultKeyValueDiffer.prototype._maybeAddToChanges = function (record, newValue) {
8022 if (!looseIdentical(newValue, record.currentValue)) {
8023 record.previousValue = record.currentValue;
8024 record.currentValue = newValue;
8025 this._addToChanges(record);
8026 }
8027 };
8028 /**
8029 * @param {?} record
8030 * @return {?}
8031 */
8032 DefaultKeyValueDiffer.prototype._addToAdditions = function (record) {
8033 if (this._additionsHead === null) {
8034 this._additionsHead = this._additionsTail = record;
8035 }
8036 else {
8037 ((this._additionsTail))._nextAdded = record;
8038 this._additionsTail = record;
8039 }
8040 };
8041 /**
8042 * @param {?} record
8043 * @return {?}
8044 */
8045 DefaultKeyValueDiffer.prototype._addToChanges = function (record) {
8046 if (this._changesHead === null) {
8047 this._changesHead = this._changesTail = record;
8048 }
8049 else {
8050 ((this._changesTail))._nextChanged = record;
8051 this._changesTail = record;
8052 }
8053 };
8054 /**
8055 * @return {?}
8056 */
8057 DefaultKeyValueDiffer.prototype.toString = function () {
8058 var /** @type {?} */ items = [];
8059 var /** @type {?} */ previous = [];
8060 var /** @type {?} */ changes = [];
8061 var /** @type {?} */ additions = [];
8062 var /** @type {?} */ removals = [];
8063 this.forEachItem(function (r) { return items.push(stringify(r)); });
8064 this.forEachPreviousItem(function (r) { return previous.push(stringify(r)); });
8065 this.forEachChangedItem(function (r) { return changes.push(stringify(r)); });
8066 this.forEachAddedItem(function (r) { return additions.push(stringify(r)); });
8067 this.forEachRemovedItem(function (r) { return removals.push(stringify(r)); });
8068 return 'map: ' + items.join(', ') + '\n' +
8069 'previous: ' + previous.join(', ') + '\n' +
8070 'additions: ' + additions.join(', ') + '\n' +
8071 'changes: ' + changes.join(', ') + '\n' +
8072 'removals: ' + removals.join(', ') + '\n';
8073 };
8074 /**
8075 * \@internal
8076 * @template K, V
8077 * @param {?} obj
8078 * @param {?} fn
8079 * @return {?}
8080 */
8081 DefaultKeyValueDiffer.prototype._forEach = function (obj, fn) {
8082 if (obj instanceof Map) {
8083 obj.forEach(fn);
8084 }
8085 else {
8086 Object.keys(obj).forEach(function (k) { return fn(obj[k], k); });
8087 }
8088 };
8089 return DefaultKeyValueDiffer;
8090}());
8091/**
8092 * \@stable
8093 */
8094var KeyValueChangeRecord_ = (function () {
8095 /**
8096 * @param {?} key
8097 */
8098 function KeyValueChangeRecord_(key) {
8099 this.key = key;
8100 this.previousValue = null;
8101 this.currentValue = null;
8102 /**
8103 * \@internal
8104 */
8105 this._nextPrevious = null;
8106 /**
8107 * \@internal
8108 */
8109 this._next = null;
8110 /**
8111 * \@internal
8112 */
8113 this._prev = null;
8114 /**
8115 * \@internal
8116 */
8117 this._nextAdded = null;
8118 /**
8119 * \@internal
8120 */
8121 this._nextRemoved = null;
8122 /**
8123 * \@internal
8124 */
8125 this._nextChanged = null;
8126 }
8127 /**
8128 * @return {?}
8129 */
8130 KeyValueChangeRecord_.prototype.toString = function () {
8131 return looseIdentical(this.previousValue, this.currentValue) ?
8132 stringify(this.key) :
8133 (stringify(this.key) + '[' + stringify(this.previousValue) + '->' +
8134 stringify(this.currentValue) + ']');
8135 };
8136 return KeyValueChangeRecord_;
8137}());
8138/**
8139 * @license
8140 * Copyright Google Inc. All Rights Reserved.
8141 *
8142 * Use of this source code is governed by an MIT-style license that can be
8143 * found in the LICENSE file at https://angular.io/license
8144 */
8145/**
8146 * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
8147 * \@stable
8148 */
8149var IterableDiffers = (function () {
8150 /**
8151 * @param {?} factories
8152 */
8153 function IterableDiffers(factories) {
8154 this.factories = factories;
8155 }
8156 /**
8157 * @param {?} factories
8158 * @param {?=} parent
8159 * @return {?}
8160 */
8161 IterableDiffers.create = function (factories, parent) {
8162 if (parent != null) {
8163 var /** @type {?} */ copied = parent.factories.slice();
8164 factories = factories.concat(copied);
8165 return new IterableDiffers(factories);
8166 }
8167 else {
8168 return new IterableDiffers(factories);
8169 }
8170 };
8171 /**
8172 * Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
8173 * inherited {\@link IterableDiffers} instance with the provided factories and return a new
8174 * {\@link IterableDiffers} instance.
8175 *
8176 * The following example shows how to extend an existing list of factories,
8177 * which will only be applied to the injector for this component and its children.
8178 * This step is all that's required to make a new {\@link IterableDiffer} available.
8179 *
8180 * ### Example
8181 *
8182 * ```
8183 * \@Component({
8184 * viewProviders: [
8185 * IterableDiffers.extend([new ImmutableListDiffer()])
8186 * ]
8187 * })
8188 * ```
8189 * @param {?} factories
8190 * @return {?}
8191 */
8192 IterableDiffers.extend = function (factories) {
8193 return {
8194 provide: IterableDiffers,
8195 useFactory: function (parent) {
8196 if (!parent) {
8197 // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
8198 // to
8199 // bootstrap(), which would override default pipes instead of extending them.
8200 throw new Error('Cannot extend IterableDiffers without a parent injector');
8201 }
8202 return IterableDiffers.create(factories, parent);
8203 },
8204 // Dependency technically isn't optional, but we can provide a better error message this way.
8205 deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
8206 };
8207 };
8208 /**
8209 * @param {?} iterable
8210 * @return {?}
8211 */
8212 IterableDiffers.prototype.find = function (iterable) {
8213 var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(iterable); });
8214 if (factory != null) {
8215 return factory;
8216 }
8217 else {
8218 throw new Error("Cannot find a differ supporting object '" + iterable + "' of type '" + getTypeNameForDebugging(iterable) + "'");
8219 }
8220 };
8221 return IterableDiffers;
8222}());
8223/**
8224 * @param {?} type
8225 * @return {?}
8226 */
8227function getTypeNameForDebugging(type) {
8228 return type['name'] || typeof type;
8229}
8230/**
8231 * @license
8232 * Copyright Google Inc. All Rights Reserved.
8233 *
8234 * Use of this source code is governed by an MIT-style license that can be
8235 * found in the LICENSE file at https://angular.io/license
8236 */
8237/**
8238 * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
8239 * \@stable
8240 */
8241var KeyValueDiffers = (function () {
8242 /**
8243 * @param {?} factories
8244 */
8245 function KeyValueDiffers(factories) {
8246 this.factories = factories;
8247 }
8248 /**
8249 * @template S
8250 * @param {?} factories
8251 * @param {?=} parent
8252 * @return {?}
8253 */
8254 KeyValueDiffers.create = function (factories, parent) {
8255 if (parent) {
8256 var /** @type {?} */ copied = parent.factories.slice();
8257 factories = factories.concat(copied);
8258 }
8259 return new KeyValueDiffers(factories);
8260 };
8261 /**
8262 * Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
8263 * inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
8264 * {\@link KeyValueDiffers} instance.
8265 *
8266 * The following example shows how to extend an existing list of factories,
8267 * which will only be applied to the injector for this component and its children.
8268 * This step is all that's required to make a new {\@link KeyValueDiffer} available.
8269 *
8270 * ### Example
8271 *
8272 * ```
8273 * \@Component({
8274 * viewProviders: [
8275 * KeyValueDiffers.extend([new ImmutableMapDiffer()])
8276 * ]
8277 * })
8278 * ```
8279 * @template S
8280 * @param {?} factories
8281 * @return {?}
8282 */
8283 KeyValueDiffers.extend = function (factories) {
8284 return {
8285 provide: KeyValueDiffers,
8286 useFactory: function (parent) {
8287 if (!parent) {
8288 // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
8289 // to bootstrap(), which would override default pipes instead of extending them.
8290 throw new Error('Cannot extend KeyValueDiffers without a parent injector');
8291 }
8292 return KeyValueDiffers.create(factories, parent);
8293 },
8294 // Dependency technically isn't optional, but we can provide a better error message this way.
8295 deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
8296 };
8297 };
8298 /**
8299 * @param {?} kv
8300 * @return {?}
8301 */
8302 KeyValueDiffers.prototype.find = function (kv) {
8303 var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(kv); });
8304 if (factory) {
8305 return factory;
8306 }
8307 throw new Error("Cannot find a differ supporting object '" + kv + "'");
8308 };
8309 return KeyValueDiffers;
8310}());
8311/**
8312 * @license
8313 * Copyright Google Inc. All Rights Reserved.
8314 *
8315 * Use of this source code is governed by an MIT-style license that can be
8316 * found in the LICENSE file at https://angular.io/license
8317 */
8318/**
8319 * Structural diffing for `Object`s and `Map`s.
8320 */
8321var keyValDiff = [new DefaultKeyValueDifferFactory()];
8322/**
8323 * Structural diffing for `Iterable` types such as `Array`s.
8324 */
8325var iterableDiff = [new DefaultIterableDifferFactory()];
8326var defaultIterableDiffers = new IterableDiffers(iterableDiff);
8327var defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
8328/**
8329 * @license
8330 * Copyright Google Inc. All Rights Reserved.
8331 *
8332 * Use of this source code is governed by an MIT-style license that can be
8333 * found in the LICENSE file at https://angular.io/license
8334 */
8335/**
8336 * @module
8337 * @description
8338 * Change detection enables data binding in Angular.
8339 */
8340/**
8341 * @license
8342 * Copyright Google Inc. All Rights Reserved.
8343 *
8344 * Use of this source code is governed by an MIT-style license that can be
8345 * found in the LICENSE file at https://angular.io/license
8346 */
8347/**
8348 * @return {?}
8349 */
8350function _reflector() {
8351 return reflector;
8352}
8353var _CORE_PLATFORM_PROVIDERS = [
8354 // Set a default platform name for platforms that don't set it explicitly.
8355 { provide: PLATFORM_ID, useValue: 'unknown' },
8356 PlatformRef_,
8357 { provide: PlatformRef, useExisting: PlatformRef_ },
8358 { provide: Reflector, useFactory: _reflector, deps: [] },
8359 { provide: ReflectorReader, useExisting: Reflector },
8360 TestabilityRegistry,
8361 Console,
8362];
8363/**
8364 * This platform has to be included in any other platform
8365 *
8366 * \@experimental
8367 */
8368var platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
8369/**
8370 * @license
8371 * Copyright Google Inc. All Rights Reserved.
8372 *
8373 * Use of this source code is governed by an MIT-style license that can be
8374 * found in the LICENSE file at https://angular.io/license
8375 */
8376/**
8377 * \@experimental i18n support is experimental.
8378 */
8379var LOCALE_ID = new InjectionToken('LocaleId');
8380/**
8381 * \@experimental i18n support is experimental.
8382 */
8383var TRANSLATIONS = new InjectionToken('Translations');
8384/**
8385 * \@experimental i18n support is experimental.
8386 */
8387var TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
8388var MissingTranslationStrategy = {};
8389MissingTranslationStrategy.Error = 0;
8390MissingTranslationStrategy.Warning = 1;
8391MissingTranslationStrategy.Ignore = 2;
8392MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
8393MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
8394MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
8395var SecurityContext = {};
8396SecurityContext.NONE = 0;
8397SecurityContext.HTML = 1;
8398SecurityContext.STYLE = 2;
8399SecurityContext.SCRIPT = 3;
8400SecurityContext.URL = 4;
8401SecurityContext.RESOURCE_URL = 5;
8402SecurityContext[SecurityContext.NONE] = "NONE";
8403SecurityContext[SecurityContext.HTML] = "HTML";
8404SecurityContext[SecurityContext.STYLE] = "STYLE";
8405SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
8406SecurityContext[SecurityContext.URL] = "URL";
8407SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
8408/**
8409 * Sanitizer is used by the views to sanitize potentially dangerous values.
8410 *
8411 * \@stable
8412 * @abstract
8413 */
8414var Sanitizer = (function () {
8415 function Sanitizer() {
8416 }
8417 /**
8418 * @abstract
8419 * @param {?} context
8420 * @param {?} value
8421 * @return {?}
8422 */
8423 Sanitizer.prototype.sanitize = function (context, value) { };
8424 return Sanitizer;
8425}());
8426/**
8427 * @license
8428 * Copyright Google Inc. All Rights Reserved.
8429 *
8430 * Use of this source code is governed by an MIT-style license that can be
8431 * found in the LICENSE file at https://angular.io/license
8432 */
8433/**
8434 * Node instance data.
8435 *
8436 * We have a separate type per NodeType to save memory
8437 * (TextData | ElementData | ProviderData | PureExpressionData | QueryList<any>)
8438 *
8439 * To keep our code monomorphic,
8440 * we prohibit using `NodeData` directly but enforce the use of accessors (`asElementData`, ...).
8441 * This way, no usage site can get a `NodeData` from view.nodes and then use it for different
8442 * purposes.
8443 */
8444/**
8445 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8446 * @param {?} view
8447 * @param {?} index
8448 * @return {?}
8449 */
8450function asTextData(view, index) {
8451 return (view.nodes[index]);
8452}
8453/**
8454 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8455 * @param {?} view
8456 * @param {?} index
8457 * @return {?}
8458 */
8459function asElementData(view, index) {
8460 return (view.nodes[index]);
8461}
8462/**
8463 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8464 * @param {?} view
8465 * @param {?} index
8466 * @return {?}
8467 */
8468function asProviderData(view, index) {
8469 return (view.nodes[index]);
8470}
8471/**
8472 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8473 * @param {?} view
8474 * @param {?} index
8475 * @return {?}
8476 */
8477function asPureExpressionData(view, index) {
8478 return (view.nodes[index]);
8479}
8480/**
8481 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8482 * @param {?} view
8483 * @param {?} index
8484 * @return {?}
8485 */
8486function asQueryList(view, index) {
8487 return (view.nodes[index]);
8488}
8489/**
8490 * @abstract
8491 */
8492var DebugContext = (function () {
8493 function DebugContext() {
8494 }
8495 /**
8496 * @abstract
8497 * @return {?}
8498 */
8499 DebugContext.prototype.view = function () { };
8500 /**
8501 * @abstract
8502 * @return {?}
8503 */
8504 DebugContext.prototype.nodeIndex = function () { };
8505 /**
8506 * @abstract
8507 * @return {?}
8508 */
8509 DebugContext.prototype.injector = function () { };
8510 /**
8511 * @abstract
8512 * @return {?}
8513 */
8514 DebugContext.prototype.component = function () { };
8515 /**
8516 * @abstract
8517 * @return {?}
8518 */
8519 DebugContext.prototype.providerTokens = function () { };
8520 /**
8521 * @abstract
8522 * @return {?}
8523 */
8524 DebugContext.prototype.references = function () { };
8525 /**
8526 * @abstract
8527 * @return {?}
8528 */
8529 DebugContext.prototype.context = function () { };
8530 /**
8531 * @abstract
8532 * @return {?}
8533 */
8534 DebugContext.prototype.componentRenderElement = function () { };
8535 /**
8536 * @abstract
8537 * @return {?}
8538 */
8539 DebugContext.prototype.renderNode = function () { };
8540 /**
8541 * @abstract
8542 * @param {?} console
8543 * @param {...?} values
8544 * @return {?}
8545 */
8546 DebugContext.prototype.logError = function (console) {
8547 var values = [];
8548 for (var _i = 1; _i < arguments.length; _i++) {
8549 values[_i - 1] = arguments[_i];
8550 }
8551 };
8552 return DebugContext;
8553}());
8554/**
8555 * This object is used to prevent cycles in the source files and to have a place where
8556 * debug mode can hook it. It is lazily filled when `isDevMode` is known.
8557 */
8558var Services = {
8559 setCurrentNode: /** @type {?} */ ((undefined)),
8560 createRootView: /** @type {?} */ ((undefined)),
8561 createEmbeddedView: /** @type {?} */ ((undefined)),
8562 checkAndUpdateView: /** @type {?} */ ((undefined)),
8563 checkNoChangesView: /** @type {?} */ ((undefined)),
8564 destroyView: /** @type {?} */ ((undefined)),
8565 resolveDep: /** @type {?} */ ((undefined)),
8566 createDebugContext: /** @type {?} */ ((undefined)),
8567 handleEvent: /** @type {?} */ ((undefined)),
8568 updateDirectives: /** @type {?} */ ((undefined)),
8569 updateRenderer: /** @type {?} */ ((undefined)),
8570 dirtyParentQueries: /** @type {?} */ ((undefined)),
8571};
8572/**
8573 * @license
8574 * Copyright Google Inc. All Rights Reserved.
8575 *
8576 * Use of this source code is governed by an MIT-style license that can be
8577 * found in the LICENSE file at https://angular.io/license
8578 */
8579/**
8580 * @param {?} context
8581 * @param {?} oldValue
8582 * @param {?} currValue
8583 * @param {?} isFirstCheck
8584 * @return {?}
8585 */
8586function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
8587 var /** @type {?} */ msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'.";
8588 if (isFirstCheck) {
8589 msg +=
8590 " It seems like the view has been created after its parent and its children have been dirty checked." +
8591 " Has it been created in a change detection hook ?";
8592 }
8593 return viewDebugError(msg, context);
8594}
8595/**
8596 * @param {?} err
8597 * @param {?} context
8598 * @return {?}
8599 */
8600function viewWrappedDebugError(err, context) {
8601 if (!(err instanceof Error)) {
8602 // errors that are not Error instances don't have a stack,
8603 // so it is ok to wrap them into a new Error object...
8604 err = new Error(err.toString());
8605 }
8606 _addDebugContext(err, context);
8607 return err;
8608}
8609/**
8610 * @param {?} msg
8611 * @param {?} context
8612 * @return {?}
8613 */
8614function viewDebugError(msg, context) {
8615 var /** @type {?} */ err = new Error(msg);
8616 _addDebugContext(err, context);
8617 return err;
8618}
8619/**
8620 * @param {?} err
8621 * @param {?} context
8622 * @return {?}
8623 */
8624function _addDebugContext(err, context) {
8625 ((err))[ERROR_DEBUG_CONTEXT] = context;
8626 ((err))[ERROR_LOGGER] = context.logError.bind(context);
8627}
8628/**
8629 * @param {?} err
8630 * @return {?}
8631 */
8632function isViewDebugError(err) {
8633 return !!getDebugContext(err);
8634}
8635/**
8636 * @param {?} action
8637 * @return {?}
8638 */
8639function viewDestroyedError(action) {
8640 return new Error("ViewDestroyedError: Attempt to use a destroyed view: " + action);
8641}
8642/**
8643 * @license
8644 * Copyright Google Inc. All Rights Reserved.
8645 *
8646 * Use of this source code is governed by an MIT-style license that can be
8647 * found in the LICENSE file at https://angular.io/license
8648 */
8649var NOOP = function () { };
8650var _tokenKeyCache = new Map();
8651/**
8652 * @param {?} token
8653 * @return {?}
8654 */
8655function tokenKey(token) {
8656 var /** @type {?} */ key = _tokenKeyCache.get(token);
8657 if (!key) {
8658 key = stringify(token) + '_' + _tokenKeyCache.size;
8659 _tokenKeyCache.set(token, key);
8660 }
8661 return key;
8662}
8663/**
8664 * @param {?} view
8665 * @param {?} nodeIdx
8666 * @param {?} bindingIdx
8667 * @param {?} value
8668 * @return {?}
8669 */
8670function unwrapValue(view, nodeIdx, bindingIdx, value) {
8671 if (value instanceof WrappedValue) {
8672 value = value.wrapped;
8673 var /** @type {?} */ globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
8674 var /** @type {?} */ oldValue = view.oldValues[globalBindingIdx];
8675 if (oldValue instanceof WrappedValue) {
8676 oldValue = oldValue.wrapped;
8677 }
8678 view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
8679 }
8680 return value;
8681}
8682var UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
8683var EMPTY_RENDERER_TYPE_ID = '$$empty';
8684/**
8685 * @param {?} values
8686 * @return {?}
8687 */
8688function createRendererType2(values) {
8689 return {
8690 id: UNDEFINED_RENDERER_TYPE_ID,
8691 styles: values.styles,
8692 encapsulation: values.encapsulation,
8693 data: values.data
8694 };
8695}
8696var _renderCompCount = 0;
8697/**
8698 * @param {?=} type
8699 * @return {?}
8700 */
8701function resolveRendererType2(type) {
8702 if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
8703 // first time we see this RendererType2. Initialize it...
8704 var /** @type {?} */ isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
8705 type.styles.length || Object.keys(type.data).length);
8706 if (isFilled) {
8707 type.id = "c" + _renderCompCount++;
8708 }
8709 else {
8710 type.id = EMPTY_RENDERER_TYPE_ID;
8711 }
8712 }
8713 if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
8714 type = null;
8715 }
8716 return type || null;
8717}
8718/**
8719 * @param {?} view
8720 * @param {?} def
8721 * @param {?} bindingIdx
8722 * @param {?} value
8723 * @return {?}
8724 */
8725function checkBinding(view, def, bindingIdx, value) {
8726 var /** @type {?} */ oldValues = view.oldValues;
8727 if ((view.state & 2 /* FirstCheck */) ||
8728 !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
8729 return true;
8730 }
8731 return false;
8732}
8733/**
8734 * @param {?} view
8735 * @param {?} def
8736 * @param {?} bindingIdx
8737 * @param {?} value
8738 * @return {?}
8739 */
8740function checkAndUpdateBinding(view, def, bindingIdx, value) {
8741 if (checkBinding(view, def, bindingIdx, value)) {
8742 view.oldValues[def.bindingIndex + bindingIdx] = value;
8743 return true;
8744 }
8745 return false;
8746}
8747/**
8748 * @param {?} view
8749 * @param {?} def
8750 * @param {?} bindingIdx
8751 * @param {?} value
8752 * @return {?}
8753 */
8754function checkBindingNoChanges(view, def, bindingIdx, value) {
8755 var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
8756 if ((view.state & 1 /* BeforeFirstCheck */) || !devModeEqual(oldValue, value)) {
8757 throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.index), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
8758 }
8759}
8760/**
8761 * @param {?} view
8762 * @return {?}
8763 */
8764function markParentViewsForCheck(view) {
8765 var /** @type {?} */ currView = view;
8766 while (currView) {
8767 if (currView.def.flags & 2 /* OnPush */) {
8768 currView.state |= 8 /* ChecksEnabled */;
8769 }
8770 currView = currView.viewContainerParent || currView.parent;
8771 }
8772}
8773/**
8774 * @param {?} view
8775 * @param {?} nodeIndex
8776 * @param {?} eventName
8777 * @param {?} event
8778 * @return {?}
8779 */
8780function dispatchEvent(view, nodeIndex, eventName, event) {
8781 var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
8782 var /** @type {?} */ startView = nodeDef.flags & 16777216 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
8783 markParentViewsForCheck(startView);
8784 return Services.handleEvent(view, nodeIndex, eventName, event);
8785}
8786/**
8787 * @param {?} view
8788 * @return {?}
8789 */
8790function declaredViewContainer(view) {
8791 if (view.parent) {
8792 var /** @type {?} */ parentView = view.parent;
8793 return asElementData(parentView, /** @type {?} */ ((view.parentNodeDef)).index);
8794 }
8795 return null;
8796}
8797/**
8798 * for component views, this is the host element.
8799 * for embedded views, this is the index of the parent node
8800 * that contains the view container.
8801 * @param {?} view
8802 * @return {?}
8803 */
8804function viewParentEl(view) {
8805 var /** @type {?} */ parentView = view.parent;
8806 if (parentView) {
8807 return ((view.parentNodeDef)).parent;
8808 }
8809 else {
8810 return null;
8811 }
8812}
8813/**
8814 * @param {?} view
8815 * @param {?} def
8816 * @return {?}
8817 */
8818function renderNode(view, def) {
8819 switch (def.flags & 100673535 /* Types */) {
8820 case 1 /* TypeElement */:
8821 return asElementData(view, def.index).renderElement;
8822 case 2 /* TypeText */:
8823 return asTextData(view, def.index).renderText;
8824 }
8825}
8826/**
8827 * @param {?} target
8828 * @param {?} name
8829 * @return {?}
8830 */
8831function elementEventFullName(target, name) {
8832 return target ? target + ":" + name : name;
8833}
8834/**
8835 * @param {?} view
8836 * @return {?}
8837 */
8838function isComponentView(view) {
8839 return !!view.parent && !!(((view.parentNodeDef)).flags & 16384 /* Component */);
8840}
8841/**
8842 * @param {?} view
8843 * @return {?}
8844 */
8845function isEmbeddedView(view) {
8846 return !!view.parent && !(((view.parentNodeDef)).flags & 16384 /* Component */);
8847}
8848/**
8849 * @param {?} queryId
8850 * @return {?}
8851 */
8852function filterQueryId(queryId) {
8853 return 1 << (queryId % 32);
8854}
8855/**
8856 * @param {?} matchedQueriesDsl
8857 * @return {?}
8858 */
8859function splitMatchedQueriesDsl(matchedQueriesDsl) {
8860 var /** @type {?} */ matchedQueries = {};
8861 var /** @type {?} */ matchedQueryIds = 0;
8862 var /** @type {?} */ references = {};
8863 if (matchedQueriesDsl) {
8864 matchedQueriesDsl.forEach(function (_a) {
8865 var queryId = _a[0], valueType = _a[1];
8866 if (typeof queryId === 'number') {
8867 matchedQueries[queryId] = valueType;
8868 matchedQueryIds |= filterQueryId(queryId);
8869 }
8870 else {
8871 references[queryId] = valueType;
8872 }
8873 });
8874 }
8875 return { matchedQueries: matchedQueries, references: references, matchedQueryIds: matchedQueryIds };
8876}
8877/**
8878 * @param {?} view
8879 * @param {?} renderHost
8880 * @param {?} def
8881 * @return {?}
8882 */
8883function getParentRenderElement(view, renderHost, def) {
8884 var /** @type {?} */ renderParent = def.renderParent;
8885 if (renderParent) {
8886 if ((renderParent.flags & 1 /* TypeElement */) === 0 ||
8887 (renderParent.flags & 16777216 /* ComponentView */) === 0 ||
8888 (((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
8889 ViewEncapsulation.Native)) {
8890 // only children of non components, or children of components with native encapsulation should
8891 // be attached.
8892 return asElementData(view, /** @type {?} */ ((def.renderParent)).index).renderElement;
8893 }
8894 }
8895 else {
8896 return renderHost;
8897 }
8898}
8899var VIEW_DEFINITION_CACHE = new WeakMap();
8900/**
8901 * @param {?} factory
8902 * @return {?}
8903 */
8904function resolveViewDefinition(factory) {
8905 var /** @type {?} */ value = ((VIEW_DEFINITION_CACHE.get(factory)));
8906 if (!value) {
8907 value = factory(function () { return NOOP; });
8908 value.factory = factory;
8909 VIEW_DEFINITION_CACHE.set(factory, value);
8910 }
8911 return value;
8912}
8913/**
8914 * @param {?} view
8915 * @return {?}
8916 */
8917function rootRenderNodes(view) {
8918 var /** @type {?} */ renderNodes = [];
8919 visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
8920 return renderNodes;
8921}
8922/**
8923 * @param {?} view
8924 * @param {?} action
8925 * @param {?} parentNode
8926 * @param {?} nextSibling
8927 * @param {?=} target
8928 * @return {?}
8929 */
8930function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
8931 // We need to re-compute the parent node in case the nodes have been moved around manually
8932 if (action === 3 /* RemoveChild */) {
8933 parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */ ((view.def.lastRenderRootNode))));
8934 }
8935 visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
8936}
8937/**
8938 * @param {?} view
8939 * @param {?} action
8940 * @param {?} startIndex
8941 * @param {?} endIndex
8942 * @param {?} parentNode
8943 * @param {?} nextSibling
8944 * @param {?=} target
8945 * @return {?}
8946 */
8947function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
8948 for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8949 var /** @type {?} */ nodeDef = view.def.nodes[i];
8950 if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 4 /* TypeNgContent */)) {
8951 visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
8952 }
8953 // jump to next sibling
8954 i += nodeDef.childCount;
8955 }
8956}
8957/**
8958 * @param {?} view
8959 * @param {?} ngContentIndex
8960 * @param {?} action
8961 * @param {?} parentNode
8962 * @param {?} nextSibling
8963 * @param {?=} target
8964 * @return {?}
8965 */
8966function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
8967 var /** @type {?} */ compView = view;
8968 while (compView && !isComponentView(compView)) {
8969 compView = compView.parent;
8970 }
8971 var /** @type {?} */ hostView = ((compView)).parent;
8972 var /** @type {?} */ hostElDef = viewParentEl(/** @type {?} */ ((compView)));
8973 var /** @type {?} */ startIndex = ((hostElDef)).index + 1;
8974 var /** @type {?} */ endIndex = ((hostElDef)).index + ((hostElDef)).childCount;
8975 for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8976 var /** @type {?} */ nodeDef = ((hostView)).def.nodes[i];
8977 if (nodeDef.ngContentIndex === ngContentIndex) {
8978 visitRenderNode(/** @type {?} */ ((hostView)), nodeDef, action, parentNode, nextSibling, target);
8979 }
8980 // jump to next sibling
8981 i += nodeDef.childCount;
8982 }
8983 if (!((hostView)).parent) {
8984 // a root view
8985 var /** @type {?} */ projectedNodes = view.root.projectableNodes[ngContentIndex];
8986 if (projectedNodes) {
8987 for (var /** @type {?} */ i = 0; i < projectedNodes.length; i++) {
8988 execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
8989 }
8990 }
8991 }
8992}
8993/**
8994 * @param {?} view
8995 * @param {?} nodeDef
8996 * @param {?} action
8997 * @param {?} parentNode
8998 * @param {?} nextSibling
8999 * @param {?=} target
9000 * @return {?}
9001 */
9002function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
9003 if (nodeDef.flags & 4 /* TypeNgContent */) {
9004 visitProjectedRenderNodes(view, /** @type {?} */ ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
9005 }
9006 else {
9007 var /** @type {?} */ rn = renderNode(view, nodeDef);
9008 if (action === 3 /* RemoveChild */ && (nodeDef.flags & 16777216 /* ComponentView */) &&
9009 (nodeDef.bindingFlags & 48 /* CatSyntheticProperty */)) {
9010 // Note: we might need to do both actions.
9011 if (nodeDef.bindingFlags & (16 /* SyntheticProperty */)) {
9012 execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
9013 }
9014 if (nodeDef.bindingFlags & (32 /* SyntheticHostProperty */)) {
9015 var /** @type {?} */ compView = asElementData(view, nodeDef.index).componentView;
9016 execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
9017 }
9018 }
9019 else {
9020 execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
9021 }
9022 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
9023 var /** @type {?} */ embeddedViews = ((asElementData(view, nodeDef.index).viewContainer))._embeddedViews;
9024 for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
9025 visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
9026 }
9027 }
9028 if (nodeDef.flags & 1 /* TypeElement */ && !((nodeDef.element)).name) {
9029 visitSiblingRenderNodes(view, action, nodeDef.index + 1, nodeDef.index + nodeDef.childCount, parentNode, nextSibling, target);
9030 }
9031 }
9032}
9033/**
9034 * @param {?} view
9035 * @param {?} renderNode
9036 * @param {?} action
9037 * @param {?} parentNode
9038 * @param {?} nextSibling
9039 * @param {?=} target
9040 * @return {?}
9041 */
9042function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
9043 var /** @type {?} */ renderer = view.renderer;
9044 switch (action) {
9045 case 1 /* AppendChild */:
9046 renderer.appendChild(parentNode, renderNode);
9047 break;
9048 case 2 /* InsertBefore */:
9049 renderer.insertBefore(parentNode, renderNode, nextSibling);
9050 break;
9051 case 3 /* RemoveChild */:
9052 renderer.removeChild(parentNode, renderNode);
9053 break;
9054 case 0 /* Collect */:
9055 ((target)).push(renderNode);
9056 break;
9057 }
9058}
9059var NS_PREFIX_RE = /^:([^:]+):(.+)$/;
9060/**
9061 * @param {?} name
9062 * @return {?}
9063 */
9064function splitNamespace(name) {
9065 if (name[0] === ':') {
9066 var /** @type {?} */ match = ((name.match(NS_PREFIX_RE)));
9067 return [match[1], match[2]];
9068 }
9069 return ['', name];
9070}
9071/**
9072 * @param {?} bindings
9073 * @return {?}
9074 */
9075function calcBindingFlags(bindings) {
9076 var /** @type {?} */ flags = 0;
9077 for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
9078 flags |= bindings[i].flags;
9079 }
9080 return flags;
9081}
9082/**
9083 * @param {?} valueCount
9084 * @param {?} constAndInterp
9085 * @return {?}
9086 */
9087function interpolate(valueCount, constAndInterp) {
9088 var /** @type {?} */ result = '';
9089 for (var /** @type {?} */ i = 0; i < valueCount * 2; i = i + 2) {
9090 result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
9091 }
9092 return result + constAndInterp[valueCount * 2];
9093}
9094/**
9095 * @param {?} valueCount
9096 * @param {?} c0
9097 * @param {?} a1
9098 * @param {?} c1
9099 * @param {?=} a2
9100 * @param {?=} c2
9101 * @param {?=} a3
9102 * @param {?=} c3
9103 * @param {?=} a4
9104 * @param {?=} c4
9105 * @param {?=} a5
9106 * @param {?=} c5
9107 * @param {?=} a6
9108 * @param {?=} c6
9109 * @param {?=} a7
9110 * @param {?=} c7
9111 * @param {?=} a8
9112 * @param {?=} c8
9113 * @param {?=} a9
9114 * @param {?=} c9
9115 * @return {?}
9116 */
9117function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
9118 switch (valueCount) {
9119 case 1:
9120 return c0 + _toStringWithNull(a1) + c1;
9121 case 2:
9122 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
9123 case 3:
9124 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9125 c3;
9126 case 4:
9127 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9128 c3 + _toStringWithNull(a4) + c4;
9129 case 5:
9130 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9131 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
9132 case 6:
9133 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9134 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
9135 case 7:
9136 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9137 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
9138 c6 + _toStringWithNull(a7) + c7;
9139 case 8:
9140 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9141 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
9142 c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
9143 case 9:
9144 return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
9145 c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
9146 c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
9147 default:
9148 throw new Error("Does not support more than 9 expressions");
9149 }
9150}
9151/**
9152 * @param {?} v
9153 * @return {?}
9154 */
9155function _toStringWithNull(v) {
9156 return v != null ? v.toString() : '';
9157}
9158var EMPTY_ARRAY = [];
9159var EMPTY_MAP = {};
9160/**
9161 * @license
9162 * Copyright Google Inc. All Rights Reserved.
9163 *
9164 * Use of this source code is governed by an MIT-style license that can be
9165 * found in the LICENSE file at https://angular.io/license
9166 */
9167/**
9168 * @param {?} flags
9169 * @param {?} matchedQueriesDsl
9170 * @param {?} ngContentIndex
9171 * @param {?} childCount
9172 * @param {?=} handleEvent
9173 * @param {?=} templateFactory
9174 * @return {?}
9175 */
9176function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
9177 flags |= 1 /* TypeElement */;
9178 var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
9179 var /** @type {?} */ template = templateFactory ? resolveViewDefinition(templateFactory) : null;
9180 return {
9181 // will bet set by the view definition
9182 index: -1,
9183 parent: null,
9184 renderParent: null,
9185 bindingIndex: -1,
9186 outputIndex: -1,
9187 // regular values
9188 flags: flags,
9189 childFlags: 0,
9190 directChildFlags: 0,
9191 childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
9192 bindings: [],
9193 bindingFlags: 0,
9194 outputs: [],
9195 element: {
9196 ns: null,
9197 name: null,
9198 attrs: null, template: template,
9199 componentProvider: null,
9200 componentView: null,
9201 componentRendererType: null,
9202 publicProviders: null,
9203 allProviders: null,
9204 handleEvent: handleEvent || NOOP
9205 },
9206 provider: null,
9207 text: null,
9208 query: null,
9209 ngContent: null
9210 };
9211}
9212/**
9213 * @param {?} flags
9214 * @param {?} matchedQueriesDsl
9215 * @param {?} ngContentIndex
9216 * @param {?} childCount
9217 * @param {?} namespaceAndName
9218 * @param {?=} fixedAttrs
9219 * @param {?=} bindings
9220 * @param {?=} outputs
9221 * @param {?=} handleEvent
9222 * @param {?=} componentView
9223 * @param {?=} componentRendererType
9224 * @return {?}
9225 */
9226function elementDef(flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs, bindings, outputs, handleEvent, componentView, componentRendererType) {
9227 if (fixedAttrs === void 0) { fixedAttrs = []; }
9228 if (!handleEvent) {
9229 handleEvent = NOOP;
9230 }
9231 var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
9232 var /** @type {?} */ ns = ((null));
9233 var /** @type {?} */ name = ((null));
9234 if (namespaceAndName) {
9235 _b = splitNamespace(namespaceAndName), ns = _b[0], name = _b[1];
9236 }
9237 bindings = bindings || [];
9238 var /** @type {?} */ bindingDefs = new Array(bindings.length);
9239 for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
9240 var _c = bindings[i], bindingFlags = _c[0], namespaceAndName_1 = _c[1], suffixOrSecurityContext = _c[2];
9241 var _d = splitNamespace(namespaceAndName_1), ns_1 = _d[0], name_1 = _d[1];
9242 var /** @type {?} */ securityContext = ((undefined));
9243 var /** @type {?} */ suffix = ((undefined));
9244 switch (bindingFlags & 15 /* Types */) {
9245 case 4 /* TypeElementStyle */:
9246 suffix = (suffixOrSecurityContext);
9247 break;
9248 case 1 /* TypeElementAttribute */:
9249 case 8 /* TypeProperty */:
9250 securityContext = (suffixOrSecurityContext);
9251 break;
9252 }
9253 bindingDefs[i] =
9254 { flags: bindingFlags, ns: ns_1, name: name_1, nonMinifiedName: name_1, securityContext: securityContext, suffix: suffix };
9255 }
9256 outputs = outputs || [];
9257 var /** @type {?} */ outputDefs = new Array(outputs.length);
9258 for (var /** @type {?} */ i = 0; i < outputs.length; i++) {
9259 var _e = outputs[i], target = _e[0], eventName = _e[1];
9260 outputDefs[i] = {
9261 type: 0 /* ElementOutput */,
9262 target: /** @type {?} */ (target), eventName: eventName,
9263 propName: null
9264 };
9265 }
9266 fixedAttrs = fixedAttrs || [];
9267 var /** @type {?} */ attrs = (fixedAttrs.map(function (_a) {
9268 var namespaceAndName = _a[0], value = _a[1];
9269 var _b = splitNamespace(namespaceAndName), ns = _b[0], name = _b[1];
9270 return [ns, name, value];
9271 }));
9272 componentRendererType = resolveRendererType2(componentRendererType);
9273 if (componentView) {
9274 flags |= 16777216 /* ComponentView */;
9275 }
9276 flags |= 1 /* TypeElement */;
9277 return {
9278 // will bet set by the view definition
9279 index: -1,
9280 parent: null,
9281 renderParent: null,
9282 bindingIndex: -1,
9283 outputIndex: -1,
9284 // regular values
9285 flags: flags,
9286 childFlags: 0,
9287 directChildFlags: 0,
9288 childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
9289 bindings: bindingDefs,
9290 bindingFlags: calcBindingFlags(bindingDefs),
9291 outputs: outputDefs,
9292 element: {
9293 ns: ns,
9294 name: name,
9295 attrs: attrs,
9296 template: null,
9297 // will bet set by the view definition
9298 componentProvider: null,
9299 componentView: componentView || null,
9300 componentRendererType: componentRendererType,
9301 publicProviders: null,
9302 allProviders: null,
9303 handleEvent: handleEvent || NOOP,
9304 },
9305 provider: null,
9306 text: null,
9307 query: null,
9308 ngContent: null
9309 };
9310 var _b;
9311}
9312/**
9313 * @param {?} view
9314 * @param {?} renderHost
9315 * @param {?} def
9316 * @return {?}
9317 */
9318function createElement(view, renderHost, def) {
9319 var /** @type {?} */ elDef = ((def.element));
9320 var /** @type {?} */ rootSelectorOrNode = view.root.selectorOrNode;
9321 var /** @type {?} */ renderer = view.renderer;
9322 var /** @type {?} */ el;
9323 if (view.parent || !rootSelectorOrNode) {
9324 if (elDef.name) {
9325 el = renderer.createElement(elDef.name, elDef.ns);
9326 }
9327 else {
9328 el = renderer.createComment('');
9329 }
9330 var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
9331 if (parentEl) {
9332 renderer.appendChild(parentEl, el);
9333 }
9334 }
9335 else {
9336 el = renderer.selectRootElement(rootSelectorOrNode);
9337 }
9338 if (elDef.attrs) {
9339 for (var /** @type {?} */ i = 0; i < elDef.attrs.length; i++) {
9340 var _a = elDef.attrs[i], ns = _a[0], name = _a[1], value = _a[2];
9341 renderer.setAttribute(el, name, value, ns);
9342 }
9343 }
9344 return el;
9345}
9346/**
9347 * @param {?} view
9348 * @param {?} compView
9349 * @param {?} def
9350 * @param {?} el
9351 * @return {?}
9352 */
9353function listenToElementOutputs(view, compView, def, el) {
9354 for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
9355 var /** @type {?} */ output = def.outputs[i];
9356 var /** @type {?} */ handleEventClosure = renderEventHandlerClosure(view, def.index, elementEventFullName(output.target, output.eventName));
9357 var /** @type {?} */ listenTarget = output.target;
9358 var /** @type {?} */ listenerView = view;
9359 if (output.target === 'component') {
9360 listenTarget = null;
9361 listenerView = compView;
9362 }
9363 var /** @type {?} */ disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure)); /** @type {?} */
9364 ((view.disposables))[def.outputIndex + i] = disposable;
9365 }
9366}
9367/**
9368 * @param {?} view
9369 * @param {?} index
9370 * @param {?} eventName
9371 * @return {?}
9372 */
9373function renderEventHandlerClosure(view, index, eventName) {
9374 return function (event) {
9375 try {
9376 return dispatchEvent(view, index, eventName, event);
9377 }
9378 catch (e) {
9379 // Attention: Don't rethrow, to keep in sync with directive events.
9380 view.root.errorHandler.handleError(e);
9381 }
9382 };
9383}
9384/**
9385 * @param {?} view
9386 * @param {?} def
9387 * @param {?} v0
9388 * @param {?} v1
9389 * @param {?} v2
9390 * @param {?} v3
9391 * @param {?} v4
9392 * @param {?} v5
9393 * @param {?} v6
9394 * @param {?} v7
9395 * @param {?} v8
9396 * @param {?} v9
9397 * @return {?}
9398 */
9399function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
9400 var /** @type {?} */ bindLen = def.bindings.length;
9401 var /** @type {?} */ changed = false;
9402 if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
9403 changed = true;
9404 if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
9405 changed = true;
9406 if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
9407 changed = true;
9408 if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
9409 changed = true;
9410 if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
9411 changed = true;
9412 if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
9413 changed = true;
9414 if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
9415 changed = true;
9416 if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
9417 changed = true;
9418 if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
9419 changed = true;
9420 if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
9421 changed = true;
9422 return changed;
9423}
9424/**
9425 * @param {?} view
9426 * @param {?} def
9427 * @param {?} values
9428 * @return {?}
9429 */
9430function checkAndUpdateElementDynamic(view, def, values) {
9431 var /** @type {?} */ changed = false;
9432 for (var /** @type {?} */ i = 0; i < values.length; i++) {
9433 if (checkAndUpdateElementValue(view, def, i, values[i]))
9434 changed = true;
9435 }
9436 return changed;
9437}
9438/**
9439 * @param {?} view
9440 * @param {?} def
9441 * @param {?} bindingIdx
9442 * @param {?} value
9443 * @return {?}
9444 */
9445function checkAndUpdateElementValue(view, def, bindingIdx, value) {
9446 if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
9447 return false;
9448 }
9449 var /** @type {?} */ binding = def.bindings[bindingIdx];
9450 var /** @type {?} */ elData = asElementData(view, def.index);
9451 var /** @type {?} */ renderNode$$1 = elData.renderElement;
9452 var /** @type {?} */ name = ((binding.name));
9453 switch (binding.flags & 15 /* Types */) {
9454 case 1 /* TypeElementAttribute */:
9455 setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
9456 break;
9457 case 2 /* TypeElementClass */:
9458 setElementClass(view, renderNode$$1, name, value);
9459 break;
9460 case 4 /* TypeElementStyle */:
9461 setElementStyle(view, binding, renderNode$$1, name, value);
9462 break;
9463 case 8 /* TypeProperty */:
9464 var /** @type {?} */ bindView = (def.flags & 16777216 /* ComponentView */ &&
9465 binding.flags & 32 /* SyntheticHostProperty */) ?
9466 elData.componentView :
9467 view;
9468 setElementProperty(bindView, binding, renderNode$$1, name, value);
9469 break;
9470 }
9471 return true;
9472}
9473/**
9474 * @param {?} view
9475 * @param {?} binding
9476 * @param {?} renderNode
9477 * @param {?} ns
9478 * @param {?} name
9479 * @param {?} value
9480 * @return {?}
9481 */
9482function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
9483 var /** @type {?} */ securityContext = binding.securityContext;
9484 var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9485 renderValue = renderValue != null ? renderValue.toString() : null;
9486 var /** @type {?} */ renderer = view.renderer;
9487 if (value != null) {
9488 renderer.setAttribute(renderNode$$1, name, renderValue, ns);
9489 }
9490 else {
9491 renderer.removeAttribute(renderNode$$1, name, ns);
9492 }
9493}
9494/**
9495 * @param {?} view
9496 * @param {?} renderNode
9497 * @param {?} name
9498 * @param {?} value
9499 * @return {?}
9500 */
9501function setElementClass(view, renderNode$$1, name, value) {
9502 var /** @type {?} */ renderer = view.renderer;
9503 if (value) {
9504 renderer.addClass(renderNode$$1, name);
9505 }
9506 else {
9507 renderer.removeClass(renderNode$$1, name);
9508 }
9509}
9510/**
9511 * @param {?} view
9512 * @param {?} binding
9513 * @param {?} renderNode
9514 * @param {?} name
9515 * @param {?} value
9516 * @return {?}
9517 */
9518function setElementStyle(view, binding, renderNode$$1, name, value) {
9519 var /** @type {?} */ renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */ (value));
9520 if (renderValue != null) {
9521 renderValue = renderValue.toString();
9522 var /** @type {?} */ unit = binding.suffix;
9523 if (unit != null) {
9524 renderValue = renderValue + unit;
9525 }
9526 }
9527 else {
9528 renderValue = null;
9529 }
9530 var /** @type {?} */ renderer = view.renderer;
9531 if (renderValue != null) {
9532 renderer.setStyle(renderNode$$1, name, renderValue);
9533 }
9534 else {
9535 renderer.removeStyle(renderNode$$1, name);
9536 }
9537}
9538/**
9539 * @param {?} view
9540 * @param {?} binding
9541 * @param {?} renderNode
9542 * @param {?} name
9543 * @param {?} value
9544 * @return {?}
9545 */
9546function setElementProperty(view, binding, renderNode$$1, name, value) {
9547 var /** @type {?} */ securityContext = binding.securityContext;
9548 var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9549 view.renderer.setProperty(renderNode$$1, name, renderValue);
9550}
9551/**
9552 * @license
9553 * Copyright Google Inc. All Rights Reserved.
9554 *
9555 * Use of this source code is governed by an MIT-style license that can be
9556 * found in the LICENSE file at https://angular.io/license
9557 */
9558/**
9559 * @param {?} ngContentIndex
9560 * @param {?} index
9561 * @return {?}
9562 */
9563function ngContentDef(ngContentIndex, index) {
9564 return {
9565 // will bet set by the view definition
9566 index: -1,
9567 parent: null,
9568 renderParent: null,
9569 bindingIndex: -1,
9570 outputIndex: -1,
9571 // regular values
9572 flags: 4 /* TypeNgContent */,
9573 childFlags: 0,
9574 directChildFlags: 0,
9575 childMatchedQueries: 0,
9576 matchedQueries: {},
9577 matchedQueryIds: 0,
9578 references: {}, ngContentIndex: ngContentIndex,
9579 childCount: 0,
9580 bindings: [],
9581 bindingFlags: 0,
9582 outputs: [],
9583 element: null,
9584 provider: null,
9585 text: null,
9586 query: null,
9587 ngContent: { index: index }
9588 };
9589}
9590/**
9591 * @param {?} view
9592 * @param {?} renderHost
9593 * @param {?} def
9594 * @return {?}
9595 */
9596function appendNgContent(view, renderHost, def) {
9597 var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
9598 if (!parentEl) {
9599 // Nothing to do if there is no parent element.
9600 return;
9601 }
9602 var /** @type {?} */ ngContentIndex = ((def.ngContent)).index;
9603 visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
9604}
9605/**
9606 * @license
9607 * Copyright Google Inc. All Rights Reserved.
9608 *
9609 * Use of this source code is governed by an MIT-style license that can be
9610 * found in the LICENSE file at https://angular.io/license
9611 */
9612/**
9613 * @param {?} parentView
9614 * @param {?} elementData
9615 * @param {?} viewIndex
9616 * @param {?} view
9617 * @return {?}
9618 */
9619function attachEmbeddedView(parentView, elementData, viewIndex, view) {
9620 var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9621 if (viewIndex === null || viewIndex === undefined) {
9622 viewIndex = embeddedViews.length;
9623 }
9624 view.viewContainerParent = parentView;
9625 addToArray(embeddedViews, /** @type {?} */ ((viewIndex)), view);
9626 var /** @type {?} */ dvcElementData = declaredViewContainer(view);
9627 if (dvcElementData && dvcElementData !== elementData) {
9628 var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9629 if (!projectedViews) {
9630 projectedViews = dvcElementData.template._projectedViews = [];
9631 }
9632 projectedViews.push(view);
9633 }
9634 Services.dirtyParentQueries(view);
9635 var /** @type {?} */ prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
9636 renderAttachEmbeddedView(elementData, prevView, view);
9637}
9638/**
9639 * @param {?} elementData
9640 * @param {?=} viewIndex
9641 * @return {?}
9642 */
9643function detachEmbeddedView(elementData, viewIndex) {
9644 var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9645 if (viewIndex == null || viewIndex >= embeddedViews.length) {
9646 viewIndex = embeddedViews.length - 1;
9647 }
9648 if (viewIndex < 0) {
9649 return null;
9650 }
9651 var /** @type {?} */ view = embeddedViews[viewIndex];
9652 view.viewContainerParent = null;
9653 removeFromArray(embeddedViews, viewIndex);
9654 var /** @type {?} */ dvcElementData = declaredViewContainer(view);
9655 if (dvcElementData && dvcElementData !== elementData) {
9656 var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9657 removeFromArray(projectedViews, projectedViews.indexOf(view));
9658 }
9659 Services.dirtyParentQueries(view);
9660 renderDetachView(view);
9661 return view;
9662}
9663/**
9664 * @param {?} elementData
9665 * @param {?} oldViewIndex
9666 * @param {?} newViewIndex
9667 * @return {?}
9668 */
9669function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
9670 var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9671 var /** @type {?} */ view = embeddedViews[oldViewIndex];
9672 removeFromArray(embeddedViews, oldViewIndex);
9673 if (newViewIndex == null) {
9674 newViewIndex = embeddedViews.length;
9675 }
9676 addToArray(embeddedViews, newViewIndex, view);
9677 // Note: Don't need to change projectedViews as the order in there
9678 // as always invalid...
9679 Services.dirtyParentQueries(view);
9680 renderDetachView(view);
9681 var /** @type {?} */ prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
9682 renderAttachEmbeddedView(elementData, prevView, view);
9683 return view;
9684}
9685/**
9686 * @param {?} elementData
9687 * @param {?} prevView
9688 * @param {?} view
9689 * @return {?}
9690 */
9691function renderAttachEmbeddedView(elementData, prevView, view) {
9692 var /** @type {?} */ prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */ ((prevView.def.lastRenderRootNode))) :
9693 elementData.renderElement;
9694 var /** @type {?} */ parentNode = view.renderer.parentNode(prevRenderNode);
9695 var /** @type {?} */ nextSibling = view.renderer.nextSibling(prevRenderNode);
9696 // Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
9697 // However, browsers automatically do `appendChild` when there is no `nextSibling`.
9698 visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
9699}
9700/**
9701 * @param {?} view
9702 * @return {?}
9703 */
9704function renderDetachView(view) {
9705 visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
9706}
9707/**
9708 * @param {?} arr
9709 * @param {?} index
9710 * @param {?} value
9711 * @return {?}
9712 */
9713function addToArray(arr, index, value) {
9714 // perf: array.push is faster than array.splice!
9715 if (index >= arr.length) {
9716 arr.push(value);
9717 }
9718 else {
9719 arr.splice(index, 0, value);
9720 }
9721}
9722/**
9723 * @param {?} arr
9724 * @param {?} index
9725 * @return {?}
9726 */
9727function removeFromArray(arr, index) {
9728 // perf: array.pop is faster than array.splice!
9729 if (index >= arr.length - 1) {
9730 arr.pop();
9731 }
9732 else {
9733 arr.splice(index, 1);
9734 }
9735}
9736/**
9737 * @license
9738 * Copyright Google Inc. All Rights Reserved.
9739 *
9740 * Use of this source code is governed by an MIT-style license that can be
9741 * found in the LICENSE file at https://angular.io/license
9742 */
9743var EMPTY_CONTEXT = new Object();
9744/**
9745 * @param {?} selector
9746 * @param {?} componentType
9747 * @param {?} viewDefFactory
9748 * @param {?} inputs
9749 * @param {?} outputs
9750 * @param {?} ngContentSelectors
9751 * @return {?}
9752 */
9753function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
9754 return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
9755}
9756/**
9757 * @param {?} componentFactory
9758 * @return {?}
9759 */
9760function getComponentViewDefinitionFactory(componentFactory) {
9761 return ((componentFactory)).viewDefFactory;
9762}
9763var ComponentFactory_ = (function (_super) {
9764 __extends(ComponentFactory_, _super);
9765 /**
9766 * @param {?} selector
9767 * @param {?} componentType
9768 * @param {?} viewDefFactory
9769 * @param {?} _inputs
9770 * @param {?} _outputs
9771 * @param {?} ngContentSelectors
9772 */
9773 function ComponentFactory_(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
9774 var _this =
9775 // Attention: this ctor is called as top level function.
9776 // Putting any logic in here will destroy closure tree shaking!
9777 _super.call(this) || this;
9778 _this.selector = selector;
9779 _this.componentType = componentType;
9780 _this._inputs = _inputs;
9781 _this._outputs = _outputs;
9782 _this.ngContentSelectors = ngContentSelectors;
9783 _this.viewDefFactory = viewDefFactory;
9784 return _this;
9785 }
9786 Object.defineProperty(ComponentFactory_.prototype, "inputs", {
9787 /**
9788 * @return {?}
9789 */
9790 get: function () {
9791 var /** @type {?} */ inputsArr = [];
9792 var /** @type {?} */ inputs = ((this._inputs));
9793 for (var /** @type {?} */ propName in inputs) {
9794 var /** @type {?} */ templateName = inputs[propName];
9795 inputsArr.push({ propName: propName, templateName: templateName });
9796 }
9797 return inputsArr;
9798 },
9799 enumerable: true,
9800 configurable: true
9801 });
9802 Object.defineProperty(ComponentFactory_.prototype, "outputs", {
9803 /**
9804 * @return {?}
9805 */
9806 get: function () {
9807 var /** @type {?} */ outputsArr = [];
9808 for (var /** @type {?} */ propName in this._outputs) {
9809 var /** @type {?} */ templateName = this._outputs[propName];
9810 outputsArr.push({ propName: propName, templateName: templateName });
9811 }
9812 return outputsArr;
9813 },
9814 enumerable: true,
9815 configurable: true
9816 });
9817 /**
9818 * Creates a new component.
9819 * @param {?} injector
9820 * @param {?=} projectableNodes
9821 * @param {?=} rootSelectorOrNode
9822 * @param {?=} ngModule
9823 * @return {?}
9824 */
9825 ComponentFactory_.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
9826 if (!ngModule) {
9827 throw new Error('ngModule should be provided');
9828 }
9829 var /** @type {?} */ viewDef = resolveViewDefinition(this.viewDefFactory);
9830 var /** @type {?} */ componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).index;
9831 var /** @type {?} */ view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
9832 var /** @type {?} */ component = asProviderData(view, componentNodeIndex).instance;
9833 if (rootSelectorOrNode) {
9834 view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
9835 }
9836 return new ComponentRef_(view, new ViewRef_(view), component);
9837 };
9838 return ComponentFactory_;
9839}(ComponentFactory));
9840var ComponentRef_ = (function (_super) {
9841 __extends(ComponentRef_, _super);
9842 /**
9843 * @param {?} _view
9844 * @param {?} _viewRef
9845 * @param {?} _component
9846 */
9847 function ComponentRef_(_view, _viewRef, _component) {
9848 var _this = _super.call(this) || this;
9849 _this._view = _view;
9850 _this._viewRef = _viewRef;
9851 _this._component = _component;
9852 _this._elDef = _this._view.def.nodes[0];
9853 return _this;
9854 }
9855 Object.defineProperty(ComponentRef_.prototype, "location", {
9856 /**
9857 * @return {?}
9858 */
9859 get: function () {
9860 return new ElementRef(asElementData(this._view, this._elDef.index).renderElement);
9861 },
9862 enumerable: true,
9863 configurable: true
9864 });
9865 Object.defineProperty(ComponentRef_.prototype, "injector", {
9866 /**
9867 * @return {?}
9868 */
9869 get: function () { return new Injector_(this._view, this._elDef); },
9870 enumerable: true,
9871 configurable: true
9872 });
9873 Object.defineProperty(ComponentRef_.prototype, "instance", {
9874 /**
9875 * @return {?}
9876 */
9877 get: function () { return this._component; },
9878 enumerable: true,
9879 configurable: true
9880 });
9881
9882 Object.defineProperty(ComponentRef_.prototype, "hostView", {
9883 /**
9884 * @return {?}
9885 */
9886 get: function () { return this._viewRef; },
9887 enumerable: true,
9888 configurable: true
9889 });
9890
9891 Object.defineProperty(ComponentRef_.prototype, "changeDetectorRef", {
9892 /**
9893 * @return {?}
9894 */
9895 get: function () { return this._viewRef; },
9896 enumerable: true,
9897 configurable: true
9898 });
9899
9900 Object.defineProperty(ComponentRef_.prototype, "componentType", {
9901 /**
9902 * @return {?}
9903 */
9904 get: function () { return (this._component.constructor); },
9905 enumerable: true,
9906 configurable: true
9907 });
9908 /**
9909 * @return {?}
9910 */
9911 ComponentRef_.prototype.destroy = function () { this._viewRef.destroy(); };
9912 /**
9913 * @param {?} callback
9914 * @return {?}
9915 */
9916 ComponentRef_.prototype.onDestroy = function (callback) { this._viewRef.onDestroy(callback); };
9917 return ComponentRef_;
9918}(ComponentRef));
9919/**
9920 * @param {?} view
9921 * @param {?} elDef
9922 * @param {?} elData
9923 * @return {?}
9924 */
9925function createViewContainerData(view, elDef, elData) {
9926 return new ViewContainerRef_(view, elDef, elData);
9927}
9928var ViewContainerRef_ = (function () {
9929 /**
9930 * @param {?} _view
9931 * @param {?} _elDef
9932 * @param {?} _data
9933 */
9934 function ViewContainerRef_(_view, _elDef, _data) {
9935 this._view = _view;
9936 this._elDef = _elDef;
9937 this._data = _data;
9938 /**
9939 * \@internal
9940 */
9941 this._embeddedViews = [];
9942 }
9943 Object.defineProperty(ViewContainerRef_.prototype, "element", {
9944 /**
9945 * @return {?}
9946 */
9947 get: function () { return new ElementRef(this._data.renderElement); },
9948 enumerable: true,
9949 configurable: true
9950 });
9951 Object.defineProperty(ViewContainerRef_.prototype, "injector", {
9952 /**
9953 * @return {?}
9954 */
9955 get: function () { return new Injector_(this._view, this._elDef); },
9956 enumerable: true,
9957 configurable: true
9958 });
9959 Object.defineProperty(ViewContainerRef_.prototype, "parentInjector", {
9960 /**
9961 * @return {?}
9962 */
9963 get: function () {
9964 var /** @type {?} */ view = this._view;
9965 var /** @type {?} */ elDef = this._elDef.parent;
9966 while (!elDef && view) {
9967 elDef = viewParentEl(view);
9968 view = ((view.parent));
9969 }
9970 return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
9971 },
9972 enumerable: true,
9973 configurable: true
9974 });
9975 /**
9976 * @return {?}
9977 */
9978 ViewContainerRef_.prototype.clear = function () {
9979 var /** @type {?} */ len = this._embeddedViews.length;
9980 for (var /** @type {?} */ i = len - 1; i >= 0; i--) {
9981 var /** @type {?} */ view = ((detachEmbeddedView(this._data, i)));
9982 Services.destroyView(view);
9983 }
9984 };
9985 /**
9986 * @param {?} index
9987 * @return {?}
9988 */
9989 ViewContainerRef_.prototype.get = function (index) {
9990 var /** @type {?} */ view = this._embeddedViews[index];
9991 if (view) {
9992 var /** @type {?} */ ref = new ViewRef_(view);
9993 ref.attachToViewContainerRef(this);
9994 return ref;
9995 }
9996 return null;
9997 };
9998 Object.defineProperty(ViewContainerRef_.prototype, "length", {
9999 /**
10000 * @return {?}
10001 */
10002 get: function () { return this._embeddedViews.length; },
10003 enumerable: true,
10004 configurable: true
10005 });
10006
10007 /**
10008 * @template C
10009 * @param {?} templateRef
10010 * @param {?=} context
10011 * @param {?=} index
10012 * @return {?}
10013 */
10014 ViewContainerRef_.prototype.createEmbeddedView = function (templateRef, context, index) {
10015 var /** @type {?} */ viewRef = templateRef.createEmbeddedView(context || ({}));
10016 this.insert(viewRef, index);
10017 return viewRef;
10018 };
10019 /**
10020 * @template C
10021 * @param {?} componentFactory
10022 * @param {?=} index
10023 * @param {?=} injector
10024 * @param {?=} projectableNodes
10025 * @param {?=} ngModuleRef
10026 * @return {?}
10027 */
10028 ViewContainerRef_.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModuleRef) {
10029 var /** @type {?} */ contextInjector = injector || this.parentInjector;
10030 if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
10031 ngModuleRef = contextInjector.get(NgModuleRef);
10032 }
10033 var /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
10034 this.insert(componentRef.hostView, index);
10035 return componentRef;
10036 };
10037 /**
10038 * @param {?} viewRef
10039 * @param {?=} index
10040 * @return {?}
10041 */
10042 ViewContainerRef_.prototype.insert = function (viewRef, index) {
10043 var /** @type {?} */ viewRef_ = (viewRef);
10044 var /** @type {?} */ viewData = viewRef_._view;
10045 attachEmbeddedView(this._view, this._data, index, viewData);
10046 viewRef_.attachToViewContainerRef(this);
10047 return viewRef;
10048 };
10049 /**
10050 * @param {?} viewRef
10051 * @param {?} currentIndex
10052 * @return {?}
10053 */
10054 ViewContainerRef_.prototype.move = function (viewRef, currentIndex) {
10055 var /** @type {?} */ previousIndex = this._embeddedViews.indexOf(viewRef._view);
10056 moveEmbeddedView(this._data, previousIndex, currentIndex);
10057 return viewRef;
10058 };
10059 /**
10060 * @param {?} viewRef
10061 * @return {?}
10062 */
10063 ViewContainerRef_.prototype.indexOf = function (viewRef) {
10064 return this._embeddedViews.indexOf(((viewRef))._view);
10065 };
10066 /**
10067 * @param {?=} index
10068 * @return {?}
10069 */
10070 ViewContainerRef_.prototype.remove = function (index) {
10071 var /** @type {?} */ viewData = detachEmbeddedView(this._data, index);
10072 if (viewData) {
10073 Services.destroyView(viewData);
10074 }
10075 };
10076 /**
10077 * @param {?=} index
10078 * @return {?}
10079 */
10080 ViewContainerRef_.prototype.detach = function (index) {
10081 var /** @type {?} */ view = detachEmbeddedView(this._data, index);
10082 return view ? new ViewRef_(view) : null;
10083 };
10084 return ViewContainerRef_;
10085}());
10086/**
10087 * @param {?} view
10088 * @return {?}
10089 */
10090function createChangeDetectorRef(view) {
10091 return new ViewRef_(view);
10092}
10093var ViewRef_ = (function () {
10094 /**
10095 * @param {?} _view
10096 */
10097 function ViewRef_(_view) {
10098 this._view = _view;
10099 this._viewContainerRef = null;
10100 this._appRef = null;
10101 }
10102 Object.defineProperty(ViewRef_.prototype, "rootNodes", {
10103 /**
10104 * @return {?}
10105 */
10106 get: function () { return rootRenderNodes(this._view); },
10107 enumerable: true,
10108 configurable: true
10109 });
10110 Object.defineProperty(ViewRef_.prototype, "context", {
10111 /**
10112 * @return {?}
10113 */
10114 get: function () { return this._view.context; },
10115 enumerable: true,
10116 configurable: true
10117 });
10118 Object.defineProperty(ViewRef_.prototype, "destroyed", {
10119 /**
10120 * @return {?}
10121 */
10122 get: function () { return (this._view.state & 16 /* Destroyed */) !== 0; },
10123 enumerable: true,
10124 configurable: true
10125 });
10126 /**
10127 * @return {?}
10128 */
10129 ViewRef_.prototype.markForCheck = function () { markParentViewsForCheck(this._view); };
10130 /**
10131 * @return {?}
10132 */
10133 ViewRef_.prototype.detach = function () { this._view.state &= ~4 /* Attached */; };
10134 /**
10135 * @return {?}
10136 */
10137 ViewRef_.prototype.detectChanges = function () { Services.checkAndUpdateView(this._view); };
10138 /**
10139 * @return {?}
10140 */
10141 ViewRef_.prototype.checkNoChanges = function () { Services.checkNoChangesView(this._view); };
10142 /**
10143 * @return {?}
10144 */
10145 ViewRef_.prototype.reattach = function () { this._view.state |= 4 /* Attached */; };
10146 /**
10147 * @param {?} callback
10148 * @return {?}
10149 */
10150 ViewRef_.prototype.onDestroy = function (callback) {
10151 if (!this._view.disposables) {
10152 this._view.disposables = [];
10153 }
10154 this._view.disposables.push(/** @type {?} */ (callback));
10155 };
10156 /**
10157 * @return {?}
10158 */
10159 ViewRef_.prototype.destroy = function () {
10160 if (this._appRef) {
10161 this._appRef.detachView(this);
10162 }
10163 else if (this._viewContainerRef) {
10164 this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
10165 }
10166 Services.destroyView(this._view);
10167 };
10168 /**
10169 * @return {?}
10170 */
10171 ViewRef_.prototype.detachFromAppRef = function () {
10172 this._appRef = null;
10173 renderDetachView(this._view);
10174 Services.dirtyParentQueries(this._view);
10175 };
10176 /**
10177 * @param {?} appRef
10178 * @return {?}
10179 */
10180 ViewRef_.prototype.attachToAppRef = function (appRef) {
10181 if (this._viewContainerRef) {
10182 throw new Error('This view is already attached to a ViewContainer!');
10183 }
10184 this._appRef = appRef;
10185 };
10186 /**
10187 * @param {?} vcRef
10188 * @return {?}
10189 */
10190 ViewRef_.prototype.attachToViewContainerRef = function (vcRef) {
10191 if (this._appRef) {
10192 throw new Error('This view is already attached directly to the ApplicationRef!');
10193 }
10194 this._viewContainerRef = vcRef;
10195 };
10196 return ViewRef_;
10197}());
10198/**
10199 * @param {?} view
10200 * @param {?} def
10201 * @return {?}
10202 */
10203function createTemplateData(view, def) {
10204 return new TemplateRef_(view, def);
10205}
10206var TemplateRef_ = (function (_super) {
10207 __extends(TemplateRef_, _super);
10208 /**
10209 * @param {?} _parentView
10210 * @param {?} _def
10211 */
10212 function TemplateRef_(_parentView, _def) {
10213 var _this = _super.call(this) || this;
10214 _this._parentView = _parentView;
10215 _this._def = _def;
10216 return _this;
10217 }
10218 /**
10219 * @param {?} context
10220 * @return {?}
10221 */
10222 TemplateRef_.prototype.createEmbeddedView = function (context) {
10223 return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, context));
10224 };
10225 Object.defineProperty(TemplateRef_.prototype, "elementRef", {
10226 /**
10227 * @return {?}
10228 */
10229 get: function () {
10230 return new ElementRef(asElementData(this._parentView, this._def.index).renderElement);
10231 },
10232 enumerable: true,
10233 configurable: true
10234 });
10235 return TemplateRef_;
10236}(TemplateRef));
10237/**
10238 * @param {?} view
10239 * @param {?} elDef
10240 * @return {?}
10241 */
10242function createInjector(view, elDef) {
10243 return new Injector_(view, elDef);
10244}
10245var Injector_ = (function () {
10246 /**
10247 * @param {?} view
10248 * @param {?} elDef
10249 */
10250 function Injector_(view, elDef) {
10251 this.view = view;
10252 this.elDef = elDef;
10253 }
10254 /**
10255 * @param {?} token
10256 * @param {?=} notFoundValue
10257 * @return {?}
10258 */
10259 Injector_.prototype.get = function (token, notFoundValue) {
10260 if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
10261 var /** @type {?} */ allowPrivateServices = this.elDef ? (this.elDef.flags & 16777216 /* ComponentView */) !== 0 : false;
10262 return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token: token, tokenKey: tokenKey(token) }, notFoundValue);
10263 };
10264 return Injector_;
10265}());
10266/**
10267 * @param {?} view
10268 * @param {?} index
10269 * @return {?}
10270 */
10271function nodeValue(view, index) {
10272 var /** @type {?} */ def = view.def.nodes[index];
10273 if (def.flags & 1 /* TypeElement */) {
10274 var /** @type {?} */ elData = asElementData(view, def.index);
10275 return ((def.element)).template ? elData.template : elData.renderElement;
10276 }
10277 else if (def.flags & 2 /* TypeText */) {
10278 return asTextData(view, def.index).renderText;
10279 }
10280 else if (def.flags & (10112 /* CatProvider */ | 8 /* TypePipe */)) {
10281 return asProviderData(view, def.index).instance;
10282 }
10283 throw new Error("Illegal state: read nodeValue for node index " + index);
10284}
10285/**
10286 * @param {?} view
10287 * @return {?}
10288 */
10289function createRendererV1(view) {
10290 return new RendererAdapter(view.renderer);
10291}
10292var RendererAdapter = (function () {
10293 /**
10294 * @param {?} delegate
10295 */
10296 function RendererAdapter(delegate) {
10297 this.delegate = delegate;
10298 }
10299 /**
10300 * @param {?} selectorOrNode
10301 * @return {?}
10302 */
10303 RendererAdapter.prototype.selectRootElement = function (selectorOrNode) {
10304 return this.delegate.selectRootElement(selectorOrNode);
10305 };
10306 /**
10307 * @param {?} parent
10308 * @param {?} namespaceAndName
10309 * @return {?}
10310 */
10311 RendererAdapter.prototype.createElement = function (parent, namespaceAndName) {
10312 var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
10313 var /** @type {?} */ el = this.delegate.createElement(name, ns);
10314 if (parent) {
10315 this.delegate.appendChild(parent, el);
10316 }
10317 return el;
10318 };
10319 /**
10320 * @param {?} hostElement
10321 * @return {?}
10322 */
10323 RendererAdapter.prototype.createViewRoot = function (hostElement) { return hostElement; };
10324 /**
10325 * @param {?} parentElement
10326 * @return {?}
10327 */
10328 RendererAdapter.prototype.createTemplateAnchor = function (parentElement) {
10329 var /** @type {?} */ comment = this.delegate.createComment('');
10330 if (parentElement) {
10331 this.delegate.appendChild(parentElement, comment);
10332 }
10333 return comment;
10334 };
10335 /**
10336 * @param {?} parentElement
10337 * @param {?} value
10338 * @return {?}
10339 */
10340 RendererAdapter.prototype.createText = function (parentElement, value) {
10341 var /** @type {?} */ node = this.delegate.createText(value);
10342 if (parentElement) {
10343 this.delegate.appendChild(parentElement, node);
10344 }
10345 return node;
10346 };
10347 /**
10348 * @param {?} parentElement
10349 * @param {?} nodes
10350 * @return {?}
10351 */
10352 RendererAdapter.prototype.projectNodes = function (parentElement, nodes) {
10353 for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
10354 this.delegate.appendChild(parentElement, nodes[i]);
10355 }
10356 };
10357 /**
10358 * @param {?} node
10359 * @param {?} viewRootNodes
10360 * @return {?}
10361 */
10362 RendererAdapter.prototype.attachViewAfter = function (node, viewRootNodes) {
10363 var /** @type {?} */ parentElement = this.delegate.parentNode(node);
10364 var /** @type {?} */ nextSibling = this.delegate.nextSibling(node);
10365 for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
10366 this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
10367 }
10368 };
10369 /**
10370 * @param {?} viewRootNodes
10371 * @return {?}
10372 */
10373 RendererAdapter.prototype.detachView = function (viewRootNodes) {
10374 for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
10375 var /** @type {?} */ node = viewRootNodes[i];
10376 var /** @type {?} */ parentElement = this.delegate.parentNode(node);
10377 this.delegate.removeChild(parentElement, node);
10378 }
10379 };
10380 /**
10381 * @param {?} hostElement
10382 * @param {?} viewAllNodes
10383 * @return {?}
10384 */
10385 RendererAdapter.prototype.destroyView = function (hostElement, viewAllNodes) {
10386 for (var /** @type {?} */ i = 0; i < viewAllNodes.length; i++) {
10387 ((this.delegate.destroyNode))(viewAllNodes[i]);
10388 }
10389 };
10390 /**
10391 * @param {?} renderElement
10392 * @param {?} name
10393 * @param {?} callback
10394 * @return {?}
10395 */
10396 RendererAdapter.prototype.listen = function (renderElement, name, callback) {
10397 return this.delegate.listen(renderElement, name, /** @type {?} */ (callback));
10398 };
10399 /**
10400 * @param {?} target
10401 * @param {?} name
10402 * @param {?} callback
10403 * @return {?}
10404 */
10405 RendererAdapter.prototype.listenGlobal = function (target, name, callback) {
10406 return this.delegate.listen(target, name, /** @type {?} */ (callback));
10407 };
10408 /**
10409 * @param {?} renderElement
10410 * @param {?} propertyName
10411 * @param {?} propertyValue
10412 * @return {?}
10413 */
10414 RendererAdapter.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) {
10415 this.delegate.setProperty(renderElement, propertyName, propertyValue);
10416 };
10417 /**
10418 * @param {?} renderElement
10419 * @param {?} namespaceAndName
10420 * @param {?} attributeValue
10421 * @return {?}
10422 */
10423 RendererAdapter.prototype.setElementAttribute = function (renderElement, namespaceAndName, attributeValue) {
10424 var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
10425 if (attributeValue != null) {
10426 this.delegate.setAttribute(renderElement, name, attributeValue, ns);
10427 }
10428 else {
10429 this.delegate.removeAttribute(renderElement, name, ns);
10430 }
10431 };
10432 /**
10433 * @param {?} renderElement
10434 * @param {?} propertyName
10435 * @param {?} propertyValue
10436 * @return {?}
10437 */
10438 RendererAdapter.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
10439 /**
10440 * @param {?} renderElement
10441 * @param {?} className
10442 * @param {?} isAdd
10443 * @return {?}
10444 */
10445 RendererAdapter.prototype.setElementClass = function (renderElement, className, isAdd) {
10446 if (isAdd) {
10447 this.delegate.addClass(renderElement, className);
10448 }
10449 else {
10450 this.delegate.removeClass(renderElement, className);
10451 }
10452 };
10453 /**
10454 * @param {?} renderElement
10455 * @param {?} styleName
10456 * @param {?} styleValue
10457 * @return {?}
10458 */
10459 RendererAdapter.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
10460 if (styleValue != null) {
10461 this.delegate.setStyle(renderElement, styleName, styleValue);
10462 }
10463 else {
10464 this.delegate.removeStyle(renderElement, styleName);
10465 }
10466 };
10467 /**
10468 * @param {?} renderElement
10469 * @param {?} methodName
10470 * @param {?} args
10471 * @return {?}
10472 */
10473 RendererAdapter.prototype.invokeElementMethod = function (renderElement, methodName, args) {
10474 ((renderElement))[methodName].apply(renderElement, args);
10475 };
10476 /**
10477 * @param {?} renderNode
10478 * @param {?} text
10479 * @return {?}
10480 */
10481 RendererAdapter.prototype.setText = function (renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); };
10482 /**
10483 * @return {?}
10484 */
10485 RendererAdapter.prototype.animate = function () { throw new Error('Renderer.animate is no longer supported!'); };
10486 return RendererAdapter;
10487}());
10488/**
10489 * @license
10490 * Copyright Google Inc. All Rights Reserved.
10491 *
10492 * Use of this source code is governed by an MIT-style license that can be
10493 * found in the LICENSE file at https://angular.io/license
10494 */
10495var RendererV1TokenKey = tokenKey(Renderer);
10496var Renderer2TokenKey = tokenKey(Renderer2);
10497var ElementRefTokenKey = tokenKey(ElementRef);
10498var ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
10499var TemplateRefTokenKey = tokenKey(TemplateRef);
10500var ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
10501var InjectorRefTokenKey = tokenKey(Injector);
10502var NOT_CREATED = new Object();
10503/**
10504 * @param {?} flags
10505 * @param {?} matchedQueries
10506 * @param {?} childCount
10507 * @param {?} ctor
10508 * @param {?} deps
10509 * @param {?=} props
10510 * @param {?=} outputs
10511 * @return {?}
10512 */
10513function directiveDef(flags, matchedQueries, childCount, ctor, deps, props, outputs) {
10514 var /** @type {?} */ bindings = [];
10515 if (props) {
10516 for (var /** @type {?} */ prop in props) {
10517 var _a = props[prop], bindingIndex = _a[0], nonMinifiedName = _a[1];
10518 bindings[bindingIndex] = {
10519 flags: 8 /* TypeProperty */,
10520 name: prop, nonMinifiedName: nonMinifiedName,
10521 ns: null,
10522 securityContext: null,
10523 suffix: null
10524 };
10525 }
10526 }
10527 var /** @type {?} */ outputDefs = [];
10528 if (outputs) {
10529 for (var /** @type {?} */ propName in outputs) {
10530 outputDefs.push({ type: 1 /* DirectiveOutput */, propName: propName, target: null, eventName: outputs[propName] });
10531 }
10532 }
10533 flags |= 8192 /* TypeDirective */;
10534 return _def(flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
10535}
10536/**
10537 * @param {?} flags
10538 * @param {?} ctor
10539 * @param {?} deps
10540 * @return {?}
10541 */
10542function pipeDef(flags, ctor, deps) {
10543 flags |= 8 /* TypePipe */;
10544 return _def(flags, null, 0, ctor, ctor, deps);
10545}
10546/**
10547 * @param {?} flags
10548 * @param {?} matchedQueries
10549 * @param {?} token
10550 * @param {?} value
10551 * @param {?} deps
10552 * @return {?}
10553 */
10554function providerDef(flags, matchedQueries, token, value, deps) {
10555 return _def(flags, matchedQueries, 0, token, value, deps);
10556}
10557/**
10558 * @param {?} flags
10559 * @param {?} matchedQueriesDsl
10560 * @param {?} childCount
10561 * @param {?} token
10562 * @param {?} value
10563 * @param {?} deps
10564 * @param {?=} bindings
10565 * @param {?=} outputs
10566 * @return {?}
10567 */
10568function _def(flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
10569 var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
10570 if (!outputs) {
10571 outputs = [];
10572 }
10573 if (!bindings) {
10574 bindings = [];
10575 }
10576 var /** @type {?} */ depDefs = deps.map(function (value) {
10577 var /** @type {?} */ token;
10578 var /** @type {?} */ flags;
10579 if (Array.isArray(value)) {
10580 flags = value[0], token = value[1];
10581 }
10582 else {
10583 flags = 0 /* None */;
10584 token = value;
10585 }
10586 return { flags: flags, token: token, tokenKey: tokenKey(token) };
10587 });
10588 return {
10589 // will bet set by the view definition
10590 index: -1,
10591 parent: null,
10592 renderParent: null,
10593 bindingIndex: -1,
10594 outputIndex: -1,
10595 // regular values
10596 flags: flags,
10597 childFlags: 0,
10598 directChildFlags: 0,
10599 childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references,
10600 ngContentIndex: -1, childCount: childCount, bindings: bindings,
10601 bindingFlags: calcBindingFlags(bindings), outputs: outputs,
10602 element: null,
10603 provider: { token: token, tokenKey: tokenKey(token), value: value, deps: depDefs },
10604 text: null,
10605 query: null,
10606 ngContent: null
10607 };
10608}
10609/**
10610 * @param {?} view
10611 * @param {?} def
10612 * @return {?}
10613 */
10614function createProviderInstance(view, def) {
10615 return def.flags & 2048 /* LazyProvider */ ? NOT_CREATED : _createProviderInstance(view, def);
10616}
10617/**
10618 * @param {?} view
10619 * @param {?} def
10620 * @return {?}
10621 */
10622function createPipeInstance(view, def) {
10623 // deps are looked up from component.
10624 var /** @type {?} */ compView = view;
10625 while (compView.parent && !isComponentView(compView)) {
10626 compView = compView.parent;
10627 }
10628 // pipes can see the private services of the component
10629 var /** @type {?} */ allowPrivateServices = true;
10630 // pipes are always eager and classes!
10631 return createClass(/** @type {?} */ ((compView.parent)), /** @type {?} */ ((viewParentEl(compView))), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10632}
10633/**
10634 * @param {?} view
10635 * @param {?} def
10636 * @return {?}
10637 */
10638function createDirectiveInstance(view, def) {
10639 // components can see other private services, other directives can't.
10640 var /** @type {?} */ allowPrivateServices = (def.flags & 16384 /* Component */) > 0;
10641 // directives are always eager and classes!
10642 var /** @type {?} */ instance = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10643 if (def.outputs.length) {
10644 for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
10645 var /** @type {?} */ output = def.outputs[i];
10646 var /** @type {?} */ subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, /** @type {?} */ ((def.parent)).index, output.eventName)); /** @type {?} */
10647 ((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
10648 }
10649 }
10650 return instance;
10651}
10652/**
10653 * @param {?} view
10654 * @param {?} index
10655 * @param {?} eventName
10656 * @return {?}
10657 */
10658function eventHandlerClosure(view, index, eventName) {
10659 return function (event) {
10660 try {
10661 return dispatchEvent(view, index, eventName, event);
10662 }
10663 catch (e) {
10664 // Attention: Don't rethrow, as it would cancel Observable subscriptions!
10665 view.root.errorHandler.handleError(e);
10666 }
10667 };
10668}
10669/**
10670 * @param {?} view
10671 * @param {?} def
10672 * @param {?} v0
10673 * @param {?} v1
10674 * @param {?} v2
10675 * @param {?} v3
10676 * @param {?} v4
10677 * @param {?} v5
10678 * @param {?} v6
10679 * @param {?} v7
10680 * @param {?} v8
10681 * @param {?} v9
10682 * @return {?}
10683 */
10684function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
10685 var /** @type {?} */ providerData = asProviderData(view, def.index);
10686 var /** @type {?} */ directive = providerData.instance;
10687 var /** @type {?} */ changed = false;
10688 var /** @type {?} */ changes = ((undefined));
10689 var /** @type {?} */ bindLen = def.bindings.length;
10690 if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
10691 changed = true;
10692 changes = updateProp(view, providerData, def, 0, v0, changes);
10693 }
10694 if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
10695 changed = true;
10696 changes = updateProp(view, providerData, def, 1, v1, changes);
10697 }
10698 if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
10699 changed = true;
10700 changes = updateProp(view, providerData, def, 2, v2, changes);
10701 }
10702 if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
10703 changed = true;
10704 changes = updateProp(view, providerData, def, 3, v3, changes);
10705 }
10706 if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
10707 changed = true;
10708 changes = updateProp(view, providerData, def, 4, v4, changes);
10709 }
10710 if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
10711 changed = true;
10712 changes = updateProp(view, providerData, def, 5, v5, changes);
10713 }
10714 if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
10715 changed = true;
10716 changes = updateProp(view, providerData, def, 6, v6, changes);
10717 }
10718 if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
10719 changed = true;
10720 changes = updateProp(view, providerData, def, 7, v7, changes);
10721 }
10722 if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
10723 changed = true;
10724 changes = updateProp(view, providerData, def, 8, v8, changes);
10725 }
10726 if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
10727 changed = true;
10728 changes = updateProp(view, providerData, def, 9, v9, changes);
10729 }
10730 if (changes) {
10731 directive.ngOnChanges(changes);
10732 }
10733 if ((view.state & 2 /* FirstCheck */) && (def.flags & 32768 /* OnInit */)) {
10734 directive.ngOnInit();
10735 }
10736 if (def.flags & 131072 /* DoCheck */) {
10737 directive.ngDoCheck();
10738 }
10739 return changed;
10740}
10741/**
10742 * @param {?} view
10743 * @param {?} def
10744 * @param {?} values
10745 * @return {?}
10746 */
10747function checkAndUpdateDirectiveDynamic(view, def, values) {
10748 var /** @type {?} */ providerData = asProviderData(view, def.index);
10749 var /** @type {?} */ directive = providerData.instance;
10750 var /** @type {?} */ changed = false;
10751 var /** @type {?} */ changes = ((undefined));
10752 for (var /** @type {?} */ i = 0; i < values.length; i++) {
10753 if (checkBinding(view, def, i, values[i])) {
10754 changed = true;
10755 changes = updateProp(view, providerData, def, i, values[i], changes);
10756 }
10757 }
10758 if (changes) {
10759 directive.ngOnChanges(changes);
10760 }
10761 if ((view.state & 2 /* FirstCheck */) && (def.flags & 32768 /* OnInit */)) {
10762 directive.ngOnInit();
10763 }
10764 if (def.flags & 131072 /* DoCheck */) {
10765 directive.ngDoCheck();
10766 }
10767 return changed;
10768}
10769/**
10770 * @param {?} view
10771 * @param {?} def
10772 * @return {?}
10773 */
10774function _createProviderInstance(view, def) {
10775 // private services can see other private services
10776 var /** @type {?} */ allowPrivateServices = (def.flags & 4096 /* PrivateProvider */) > 0;
10777 var /** @type {?} */ providerDef = def.provider;
10778 var /** @type {?} */ injectable;
10779 switch (def.flags & 100673535 /* Types */) {
10780 case 256 /* TypeClassProvider */:
10781 injectable = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10782 break;
10783 case 512 /* TypeFactoryProvider */:
10784 injectable = callFactory(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10785 break;
10786 case 1024 /* TypeUseExistingProvider */:
10787 injectable = resolveDep(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).deps[0]);
10788 break;
10789 case 128 /* TypeValueProvider */:
10790 injectable = ((providerDef)).value;
10791 break;
10792 }
10793 return injectable;
10794}
10795/**
10796 * @param {?} view
10797 * @param {?} elDef
10798 * @param {?} allowPrivateServices
10799 * @param {?} ctor
10800 * @param {?} deps
10801 * @return {?}
10802 */
10803function createClass(view, elDef, allowPrivateServices, ctor, deps) {
10804 var /** @type {?} */ len = deps.length;
10805 var /** @type {?} */ injectable;
10806 switch (len) {
10807 case 0:
10808 injectable = new ctor();
10809 break;
10810 case 1:
10811 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10812 break;
10813 case 2:
10814 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10815 break;
10816 case 3:
10817 injectable = new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10818 break;
10819 default:
10820 var /** @type {?} */ depValues = new Array(len);
10821 for (var /** @type {?} */ i = 0; i < len; i++) {
10822 depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10823 }
10824 injectable = new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
10825 }
10826 return injectable;
10827}
10828/**
10829 * @param {?} view
10830 * @param {?} elDef
10831 * @param {?} allowPrivateServices
10832 * @param {?} factory
10833 * @param {?} deps
10834 * @return {?}
10835 */
10836function callFactory(view, elDef, allowPrivateServices, factory, deps) {
10837 var /** @type {?} */ len = deps.length;
10838 var /** @type {?} */ injectable;
10839 switch (len) {
10840 case 0:
10841 injectable = factory();
10842 break;
10843 case 1:
10844 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10845 break;
10846 case 2:
10847 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10848 break;
10849 case 3:
10850 injectable = factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10851 break;
10852 default:
10853 var /** @type {?} */ depValues = Array(len);
10854 for (var /** @type {?} */ i = 0; i < len; i++) {
10855 depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10856 }
10857 injectable = factory.apply(void 0, depValues);
10858 }
10859 return injectable;
10860}
10861// This default value is when checking the hierarchy for a token.
10862//
10863// It means both:
10864// - the token is not provided by the current injector,
10865// - only the element injectors should be checked (ie do not check module injectors
10866//
10867// mod1
10868// /
10869// el1 mod2
10870// \ /
10871// el2
10872//
10873// When requesting el2.injector.get(token), we should check in the following order and return the
10874// first found value:
10875// - el2.injector.get(token, default)
10876// - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
10877// - mod2.injector.get(token, default)
10878var NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
10879/**
10880 * @param {?} view
10881 * @param {?} elDef
10882 * @param {?} allowPrivateServices
10883 * @param {?} depDef
10884 * @param {?=} notFoundValue
10885 * @return {?}
10886 */
10887function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue) {
10888 if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
10889 if (depDef.flags & 8 /* Value */) {
10890 return depDef.token;
10891 }
10892 var /** @type {?} */ startView = view;
10893 if (depDef.flags & 2 /* Optional */) {
10894 notFoundValue = null;
10895 }
10896 var /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
10897 if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
10898 // directives on the same element as a component should be able to control the change detector
10899 // of that component as well.
10900 allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
10901 }
10902 if (elDef && (depDef.flags & 1 /* SkipSelf */)) {
10903 allowPrivateServices = false;
10904 elDef = ((elDef.parent));
10905 }
10906 while (view) {
10907 if (elDef) {
10908 switch (tokenKey$$1) {
10909 case RendererV1TokenKey: {
10910 var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
10911 return createRendererV1(compView);
10912 }
10913 case Renderer2TokenKey: {
10914 var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
10915 return compView.renderer;
10916 }
10917 case ElementRefTokenKey:
10918 return new ElementRef(asElementData(view, elDef.index).renderElement);
10919 case ViewContainerRefTokenKey:
10920 return asElementData(view, elDef.index).viewContainer;
10921 case TemplateRefTokenKey: {
10922 if (((elDef.element)).template) {
10923 return asElementData(view, elDef.index).template;
10924 }
10925 break;
10926 }
10927 case ChangeDetectorRefTokenKey: {
10928 var /** @type {?} */ cdView = findCompView(view, elDef, allowPrivateServices);
10929 return createChangeDetectorRef(cdView);
10930 }
10931 case InjectorRefTokenKey:
10932 return createInjector(view, elDef);
10933 default:
10934 var /** @type {?} */ providerDef_1 = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
10935 if (providerDef_1) {
10936 var /** @type {?} */ providerData = asProviderData(view, providerDef_1.index);
10937 if (providerData.instance === NOT_CREATED) {
10938 providerData.instance = _createProviderInstance(view, providerDef_1);
10939 }
10940 return providerData.instance;
10941 }
10942 }
10943 }
10944 allowPrivateServices = isComponentView(view);
10945 elDef = ((viewParentEl(view)));
10946 view = ((view.parent));
10947 }
10948 var /** @type {?} */ value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
10949 if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
10950 notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
10951 // Return the value from the root element injector when
10952 // - it provides it
10953 // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
10954 // - the module injector should not be checked
10955 // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
10956 return value;
10957 }
10958 return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
10959}
10960/**
10961 * @param {?} view
10962 * @param {?} elDef
10963 * @param {?} allowPrivateServices
10964 * @return {?}
10965 */
10966function findCompView(view, elDef, allowPrivateServices) {
10967 var /** @type {?} */ compView;
10968 if (allowPrivateServices) {
10969 compView = asElementData(view, elDef.index).componentView;
10970 }
10971 else {
10972 compView = view;
10973 while (compView.parent && !isComponentView(compView)) {
10974 compView = compView.parent;
10975 }
10976 }
10977 return compView;
10978}
10979/**
10980 * @param {?} view
10981 * @param {?} providerData
10982 * @param {?} def
10983 * @param {?} bindingIdx
10984 * @param {?} value
10985 * @param {?} changes
10986 * @return {?}
10987 */
10988function updateProp(view, providerData, def, bindingIdx, value, changes) {
10989 if (def.flags & 16384 /* Component */) {
10990 var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((def.parent)).index).componentView;
10991 if (compView.def.flags & 2 /* OnPush */) {
10992 compView.state |= 8 /* ChecksEnabled */;
10993 }
10994 }
10995 var /** @type {?} */ binding = def.bindings[bindingIdx];
10996 var /** @type {?} */ propName = ((binding.name));
10997 // Note: This is still safe with Closure Compiler as
10998 // the user passed in the property name as an object has to `providerDef`,
10999 // so Closure Compiler will have renamed the property correctly already.
11000 providerData.instance[propName] = value;
11001 if (def.flags & 262144 /* OnChanges */) {
11002 changes = changes || {};
11003 var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
11004 if (oldValue instanceof WrappedValue) {
11005 oldValue = oldValue.wrapped;
11006 }
11007 var /** @type {?} */ binding_1 = def.bindings[bindingIdx];
11008 changes[((binding_1.nonMinifiedName))] =
11009 new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
11010 }
11011 view.oldValues[def.bindingIndex + bindingIdx] = value;
11012 return changes;
11013}
11014/**
11015 * @param {?} view
11016 * @param {?} lifecycles
11017 * @return {?}
11018 */
11019function callLifecycleHooksChildrenFirst(view, lifecycles) {
11020 if (!(view.def.nodeFlags & lifecycles)) {
11021 return;
11022 }
11023 var /** @type {?} */ nodes = view.def.nodes;
11024 for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
11025 var /** @type {?} */ nodeDef = nodes[i];
11026 var /** @type {?} */ parent = nodeDef.parent;
11027 if (!parent && nodeDef.flags & lifecycles) {
11028 // matching root node (e.g. a pipe)
11029 callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
11030 }
11031 if ((nodeDef.childFlags & lifecycles) === 0) {
11032 // no child matches one of the lifecycles
11033 i += nodeDef.childCount;
11034 }
11035 while (parent && (parent.flags & 1 /* TypeElement */) &&
11036 i === parent.index + parent.childCount) {
11037 // last child of an element
11038 if (parent.directChildFlags & lifecycles) {
11039 callElementProvidersLifecycles(view, parent, lifecycles);
11040 }
11041 parent = parent.parent;
11042 }
11043 }
11044}
11045/**
11046 * @param {?} view
11047 * @param {?} elDef
11048 * @param {?} lifecycles
11049 * @return {?}
11050 */
11051function callElementProvidersLifecycles(view, elDef, lifecycles) {
11052 for (var /** @type {?} */ i = elDef.index + 1; i <= elDef.index + elDef.childCount; i++) {
11053 var /** @type {?} */ nodeDef = view.def.nodes[i];
11054 if (nodeDef.flags & lifecycles) {
11055 callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
11056 }
11057 // only visit direct children
11058 i += nodeDef.childCount;
11059 }
11060}
11061/**
11062 * @param {?} view
11063 * @param {?} index
11064 * @param {?} lifecycles
11065 * @return {?}
11066 */
11067function callProviderLifecycles(view, index, lifecycles) {
11068 var /** @type {?} */ provider = asProviderData(view, index).instance;
11069 if (provider === NOT_CREATED) {
11070 return;
11071 }
11072 Services.setCurrentNode(view, index);
11073 if (lifecycles & 524288 /* AfterContentInit */) {
11074 provider.ngAfterContentInit();
11075 }
11076 if (lifecycles & 1048576 /* AfterContentChecked */) {
11077 provider.ngAfterContentChecked();
11078 }
11079 if (lifecycles & 2097152 /* AfterViewInit */) {
11080 provider.ngAfterViewInit();
11081 }
11082 if (lifecycles & 4194304 /* AfterViewChecked */) {
11083 provider.ngAfterViewChecked();
11084 }
11085 if (lifecycles & 65536 /* OnDestroy */) {
11086 provider.ngOnDestroy();
11087 }
11088}
11089/**
11090 * @license
11091 * Copyright Google Inc. All Rights Reserved.
11092 *
11093 * Use of this source code is governed by an MIT-style license that can be
11094 * found in the LICENSE file at https://angular.io/license
11095 */
11096/**
11097 * @param {?} argCount
11098 * @return {?}
11099 */
11100function purePipeDef(argCount) {
11101 // argCount + 1 to include the pipe as first arg
11102 return _pureExpressionDef(64 /* TypePurePipe */, new Array(argCount + 1));
11103}
11104/**
11105 * @param {?} argCount
11106 * @return {?}
11107 */
11108function pureArrayDef(argCount) {
11109 return _pureExpressionDef(16 /* TypePureArray */, new Array(argCount));
11110}
11111/**
11112 * @param {?} propertyNames
11113 * @return {?}
11114 */
11115function pureObjectDef(propertyNames) {
11116 return _pureExpressionDef(32 /* TypePureObject */, propertyNames);
11117}
11118/**
11119 * @param {?} flags
11120 * @param {?} propertyNames
11121 * @return {?}
11122 */
11123function _pureExpressionDef(flags, propertyNames) {
11124 var /** @type {?} */ bindings = new Array(propertyNames.length);
11125 for (var /** @type {?} */ i = 0; i < propertyNames.length; i++) {
11126 var /** @type {?} */ prop = propertyNames[i];
11127 bindings[i] = {
11128 flags: 8 /* TypeProperty */,
11129 name: prop,
11130 ns: null,
11131 nonMinifiedName: prop,
11132 securityContext: null,
11133 suffix: null
11134 };
11135 }
11136 return {
11137 // will bet set by the view definition
11138 index: -1,
11139 parent: null,
11140 renderParent: null,
11141 bindingIndex: -1,
11142 outputIndex: -1,
11143 // regular values
11144 flags: flags,
11145 childFlags: 0,
11146 directChildFlags: 0,
11147 childMatchedQueries: 0,
11148 matchedQueries: {},
11149 matchedQueryIds: 0,
11150 references: {},
11151 ngContentIndex: -1,
11152 childCount: 0, bindings: bindings,
11153 bindingFlags: calcBindingFlags(bindings),
11154 outputs: [],
11155 element: null,
11156 provider: null,
11157 text: null,
11158 query: null,
11159 ngContent: null
11160 };
11161}
11162/**
11163 * @param {?} view
11164 * @param {?} def
11165 * @return {?}
11166 */
11167function createPureExpression(view, def) {
11168 return { value: undefined };
11169}
11170/**
11171 * @param {?} view
11172 * @param {?} def
11173 * @param {?} v0
11174 * @param {?} v1
11175 * @param {?} v2
11176 * @param {?} v3
11177 * @param {?} v4
11178 * @param {?} v5
11179 * @param {?} v6
11180 * @param {?} v7
11181 * @param {?} v8
11182 * @param {?} v9
11183 * @return {?}
11184 */
11185function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11186 var /** @type {?} */ bindings = def.bindings;
11187 var /** @type {?} */ changed = false;
11188 var /** @type {?} */ bindLen = bindings.length;
11189 if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
11190 changed = true;
11191 if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
11192 changed = true;
11193 if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
11194 changed = true;
11195 if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
11196 changed = true;
11197 if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
11198 changed = true;
11199 if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
11200 changed = true;
11201 if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
11202 changed = true;
11203 if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
11204 changed = true;
11205 if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
11206 changed = true;
11207 if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
11208 changed = true;
11209 if (changed) {
11210 var /** @type {?} */ data = asPureExpressionData(view, def.index);
11211 var /** @type {?} */ value = void 0;
11212 switch (def.flags & 100673535 /* Types */) {
11213 case 16 /* TypePureArray */:
11214 value = new Array(bindings.length);
11215 if (bindLen > 0)
11216 value[0] = v0;
11217 if (bindLen > 1)
11218 value[1] = v1;
11219 if (bindLen > 2)
11220 value[2] = v2;
11221 if (bindLen > 3)
11222 value[3] = v3;
11223 if (bindLen > 4)
11224 value[4] = v4;
11225 if (bindLen > 5)
11226 value[5] = v5;
11227 if (bindLen > 6)
11228 value[6] = v6;
11229 if (bindLen > 7)
11230 value[7] = v7;
11231 if (bindLen > 8)
11232 value[8] = v8;
11233 if (bindLen > 9)
11234 value[9] = v9;
11235 break;
11236 case 32 /* TypePureObject */:
11237 value = {};
11238 if (bindLen > 0)
11239 value[((bindings[0].name))] = v0;
11240 if (bindLen > 1)
11241 value[((bindings[1].name))] = v1;
11242 if (bindLen > 2)
11243 value[((bindings[2].name))] = v2;
11244 if (bindLen > 3)
11245 value[((bindings[3].name))] = v3;
11246 if (bindLen > 4)
11247 value[((bindings[4].name))] = v4;
11248 if (bindLen > 5)
11249 value[((bindings[5].name))] = v5;
11250 if (bindLen > 6)
11251 value[((bindings[6].name))] = v6;
11252 if (bindLen > 7)
11253 value[((bindings[7].name))] = v7;
11254 if (bindLen > 8)
11255 value[((bindings[8].name))] = v8;
11256 if (bindLen > 9)
11257 value[((bindings[9].name))] = v9;
11258 break;
11259 case 64 /* TypePurePipe */:
11260 var /** @type {?} */ pipe = v0;
11261 switch (bindLen) {
11262 case 1:
11263 value = pipe.transform(v0);
11264 break;
11265 case 2:
11266 value = pipe.transform(v1);
11267 break;
11268 case 3:
11269 value = pipe.transform(v1, v2);
11270 break;
11271 case 4:
11272 value = pipe.transform(v1, v2, v3);
11273 break;
11274 case 5:
11275 value = pipe.transform(v1, v2, v3, v4);
11276 break;
11277 case 6:
11278 value = pipe.transform(v1, v2, v3, v4, v5);
11279 break;
11280 case 7:
11281 value = pipe.transform(v1, v2, v3, v4, v5, v6);
11282 break;
11283 case 8:
11284 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
11285 break;
11286 case 9:
11287 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
11288 break;
11289 case 10:
11290 value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
11291 break;
11292 }
11293 break;
11294 }
11295 data.value = value;
11296 }
11297 return changed;
11298}
11299/**
11300 * @param {?} view
11301 * @param {?} def
11302 * @param {?} values
11303 * @return {?}
11304 */
11305function checkAndUpdatePureExpressionDynamic(view, def, values) {
11306 var /** @type {?} */ bindings = def.bindings;
11307 var /** @type {?} */ changed = false;
11308 for (var /** @type {?} */ i = 0; i < values.length; i++) {
11309 // Note: We need to loop over all values, so that
11310 // the old values are updates as well!
11311 if (checkAndUpdateBinding(view, def, i, values[i])) {
11312 changed = true;
11313 }
11314 }
11315 if (changed) {
11316 var /** @type {?} */ data = asPureExpressionData(view, def.index);
11317 var /** @type {?} */ value = void 0;
11318 switch (def.flags & 100673535 /* Types */) {
11319 case 16 /* TypePureArray */:
11320 value = values;
11321 break;
11322 case 32 /* TypePureObject */:
11323 value = {};
11324 for (var /** @type {?} */ i = 0; i < values.length; i++) {
11325 value[((bindings[i].name))] = values[i];
11326 }
11327 break;
11328 case 64 /* TypePurePipe */:
11329 var /** @type {?} */ pipe = values[0];
11330 var /** @type {?} */ params = values.slice(1);
11331 value = pipe.transform.apply(pipe, params);
11332 break;
11333 }
11334 data.value = value;
11335 }
11336 return changed;
11337}
11338/**
11339 * @license
11340 * Copyright Google Inc. All Rights Reserved.
11341 *
11342 * Use of this source code is governed by an MIT-style license that can be
11343 * found in the LICENSE file at https://angular.io/license
11344 */
11345/**
11346 * @param {?} flags
11347 * @param {?} id
11348 * @param {?} bindings
11349 * @return {?}
11350 */
11351function queryDef(flags, id, bindings) {
11352 var /** @type {?} */ bindingDefs = [];
11353 for (var /** @type {?} */ propName in bindings) {
11354 var /** @type {?} */ bindingType = bindings[propName];
11355 bindingDefs.push({ propName: propName, bindingType: bindingType });
11356 }
11357 return {
11358 // will bet set by the view definition
11359 index: -1,
11360 parent: null,
11361 renderParent: null,
11362 bindingIndex: -1,
11363 outputIndex: -1,
11364 // regular values
11365 flags: flags,
11366 childFlags: 0,
11367 directChildFlags: 0,
11368 childMatchedQueries: 0,
11369 ngContentIndex: -1,
11370 matchedQueries: {},
11371 matchedQueryIds: 0,
11372 references: {},
11373 childCount: 0,
11374 bindings: [],
11375 bindingFlags: 0,
11376 outputs: [],
11377 element: null,
11378 provider: null,
11379 text: null,
11380 query: { id: id, filterId: filterQueryId(id), bindings: bindingDefs },
11381 ngContent: null
11382 };
11383}
11384/**
11385 * @return {?}
11386 */
11387function createQuery() {
11388 return new QueryList();
11389}
11390/**
11391 * @param {?} view
11392 * @return {?}
11393 */
11394function dirtyParentQueries(view) {
11395 var /** @type {?} */ queryIds = view.def.nodeMatchedQueries;
11396 while (view.parent && isEmbeddedView(view)) {
11397 var /** @type {?} */ tplDef = ((view.parentNodeDef));
11398 view = view.parent;
11399 // content queries
11400 var /** @type {?} */ end = tplDef.index + tplDef.childCount;
11401 for (var /** @type {?} */ i = 0; i <= end; i++) {
11402 var /** @type {?} */ nodeDef = view.def.nodes[i];
11403 if ((nodeDef.flags & 33554432 /* TypeContentQuery */) &&
11404 (nodeDef.flags & 268435456 /* DynamicQuery */) &&
11405 (((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
11406 asQueryList(view, i).setDirty();
11407 }
11408 if ((nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.index) ||
11409 !(nodeDef.childFlags & 33554432 /* TypeContentQuery */) ||
11410 !(nodeDef.childFlags & 268435456 /* DynamicQuery */)) {
11411 // skip elements that don't contain the template element or no query.
11412 i += nodeDef.childCount;
11413 }
11414 }
11415 }
11416 // view queries
11417 if (view.def.nodeFlags & 67108864 /* TypeViewQuery */) {
11418 for (var /** @type {?} */ i = 0; i < view.def.nodes.length; i++) {
11419 var /** @type {?} */ nodeDef = view.def.nodes[i];
11420 if ((nodeDef.flags & 67108864 /* TypeViewQuery */) && (nodeDef.flags & 268435456 /* DynamicQuery */)) {
11421 asQueryList(view, i).setDirty();
11422 }
11423 // only visit the root nodes
11424 i += nodeDef.childCount;
11425 }
11426 }
11427}
11428/**
11429 * @param {?} view
11430 * @param {?} nodeDef
11431 * @return {?}
11432 */
11433function checkAndUpdateQuery(view, nodeDef) {
11434 var /** @type {?} */ queryList = asQueryList(view, nodeDef.index);
11435 if (!queryList.dirty) {
11436 return;
11437 }
11438 var /** @type {?} */ directiveInstance;
11439 var /** @type {?} */ newValues = ((undefined));
11440 if (nodeDef.flags & 33554432 /* TypeContentQuery */) {
11441 var /** @type {?} */ elementDef_1 = ((((nodeDef.parent)).parent));
11442 newValues = calcQueryValues(view, elementDef_1.index, elementDef_1.index + elementDef_1.childCount, /** @type {?} */ ((nodeDef.query)), []);
11443 directiveInstance = asProviderData(view, /** @type {?} */ ((nodeDef.parent)).index).instance;
11444 }
11445 else if (nodeDef.flags & 67108864 /* TypeViewQuery */) {
11446 newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */ ((nodeDef.query)), []);
11447 directiveInstance = view.component;
11448 }
11449 queryList.reset(newValues);
11450 var /** @type {?} */ bindings = ((nodeDef.query)).bindings;
11451 var /** @type {?} */ notify = false;
11452 for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
11453 var /** @type {?} */ binding = bindings[i];
11454 var /** @type {?} */ boundValue = void 0;
11455 switch (binding.bindingType) {
11456 case 0 /* First */:
11457 boundValue = queryList.first;
11458 break;
11459 case 1 /* All */:
11460 boundValue = queryList;
11461 notify = true;
11462 break;
11463 }
11464 directiveInstance[binding.propName] = boundValue;
11465 }
11466 if (notify) {
11467 queryList.notifyOnChanges();
11468 }
11469}
11470/**
11471 * @param {?} view
11472 * @param {?} startIndex
11473 * @param {?} endIndex
11474 * @param {?} queryDef
11475 * @param {?} values
11476 * @return {?}
11477 */
11478function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
11479 for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
11480 var /** @type {?} */ nodeDef = view.def.nodes[i];
11481 var /** @type {?} */ valueType = nodeDef.matchedQueries[queryDef.id];
11482 if (valueType != null) {
11483 values.push(getQueryValue(view, nodeDef, valueType));
11484 }
11485 if (nodeDef.flags & 1 /* TypeElement */ && ((nodeDef.element)).template &&
11486 (((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
11487 queryDef.filterId) {
11488 // check embedded views that were attached at the place of their template.
11489 var /** @type {?} */ elementData = asElementData(view, i);
11490 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
11491 var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
11492 for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
11493 var /** @type {?} */ embeddedView = embeddedViews[k];
11494 var /** @type {?} */ dvc = declaredViewContainer(embeddedView);
11495 if (dvc && dvc === elementData) {
11496 calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
11497 }
11498 }
11499 }
11500 var /** @type {?} */ projectedViews = elementData.template._projectedViews;
11501 if (projectedViews) {
11502 for (var /** @type {?} */ k = 0; k < projectedViews.length; k++) {
11503 var /** @type {?} */ projectedView = projectedViews[k];
11504 calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
11505 }
11506 }
11507 }
11508 if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
11509 // if no child matches the query, skip the children.
11510 i += nodeDef.childCount;
11511 }
11512 }
11513 return values;
11514}
11515/**
11516 * @param {?} view
11517 * @param {?} nodeDef
11518 * @param {?} queryValueType
11519 * @return {?}
11520 */
11521function getQueryValue(view, nodeDef, queryValueType) {
11522 if (queryValueType != null) {
11523 // a match
11524 var /** @type {?} */ value = void 0;
11525 switch (queryValueType) {
11526 case 1 /* RenderElement */:
11527 value = asElementData(view, nodeDef.index).renderElement;
11528 break;
11529 case 0 /* ElementRef */:
11530 value = new ElementRef(asElementData(view, nodeDef.index).renderElement);
11531 break;
11532 case 2 /* TemplateRef */:
11533 value = asElementData(view, nodeDef.index).template;
11534 break;
11535 case 3 /* ViewContainerRef */:
11536 value = asElementData(view, nodeDef.index).viewContainer;
11537 break;
11538 case 4 /* Provider */:
11539 value = asProviderData(view, nodeDef.index).instance;
11540 break;
11541 }
11542 return value;
11543 }
11544}
11545/**
11546 * @license
11547 * Copyright Google Inc. All Rights Reserved.
11548 *
11549 * Use of this source code is governed by an MIT-style license that can be
11550 * found in the LICENSE file at https://angular.io/license
11551 */
11552/**
11553 * @param {?} ngContentIndex
11554 * @param {?} constants
11555 * @return {?}
11556 */
11557function textDef(ngContentIndex, constants) {
11558 var /** @type {?} */ bindings = new Array(constants.length - 1);
11559 for (var /** @type {?} */ i = 1; i < constants.length; i++) {
11560 bindings[i - 1] = {
11561 flags: 8 /* TypeProperty */,
11562 name: null,
11563 ns: null,
11564 nonMinifiedName: null,
11565 securityContext: null,
11566 suffix: constants[i]
11567 };
11568 }
11569 var /** @type {?} */ flags = 2;
11570 return {
11571 // will bet set by the view definition
11572 index: -1,
11573 parent: null,
11574 renderParent: null,
11575 bindingIndex: -1,
11576 outputIndex: -1,
11577 // regular values
11578 flags: flags,
11579 childFlags: 0,
11580 directChildFlags: 0,
11581 childMatchedQueries: 0,
11582 matchedQueries: {},
11583 matchedQueryIds: 0,
11584 references: {}, ngContentIndex: ngContentIndex,
11585 childCount: 0, bindings: bindings,
11586 bindingFlags: calcBindingFlags(bindings),
11587 outputs: [],
11588 element: null,
11589 provider: null,
11590 text: { prefix: constants[0] },
11591 query: null,
11592 ngContent: null
11593 };
11594}
11595/**
11596 * @param {?} view
11597 * @param {?} renderHost
11598 * @param {?} def
11599 * @return {?}
11600 */
11601function createText(view, renderHost, def) {
11602 var /** @type {?} */ renderNode$$1;
11603 var /** @type {?} */ renderer = view.renderer;
11604 renderNode$$1 = renderer.createText(/** @type {?} */ ((def.text)).prefix);
11605 var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
11606 if (parentEl) {
11607 renderer.appendChild(parentEl, renderNode$$1);
11608 }
11609 return { renderText: renderNode$$1 };
11610}
11611/**
11612 * @param {?} view
11613 * @param {?} def
11614 * @param {?} v0
11615 * @param {?} v1
11616 * @param {?} v2
11617 * @param {?} v3
11618 * @param {?} v4
11619 * @param {?} v5
11620 * @param {?} v6
11621 * @param {?} v7
11622 * @param {?} v8
11623 * @param {?} v9
11624 * @return {?}
11625 */
11626function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11627 var /** @type {?} */ changed = false;
11628 var /** @type {?} */ bindings = def.bindings;
11629 var /** @type {?} */ bindLen = bindings.length;
11630 if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
11631 changed = true;
11632 if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
11633 changed = true;
11634 if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
11635 changed = true;
11636 if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
11637 changed = true;
11638 if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
11639 changed = true;
11640 if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
11641 changed = true;
11642 if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
11643 changed = true;
11644 if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
11645 changed = true;
11646 if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
11647 changed = true;
11648 if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
11649 changed = true;
11650 if (changed) {
11651 var /** @type {?} */ value = ((def.text)).prefix;
11652 if (bindLen > 0)
11653 value += _addInterpolationPart(v0, bindings[0]);
11654 if (bindLen > 1)
11655 value += _addInterpolationPart(v1, bindings[1]);
11656 if (bindLen > 2)
11657 value += _addInterpolationPart(v2, bindings[2]);
11658 if (bindLen > 3)
11659 value += _addInterpolationPart(v3, bindings[3]);
11660 if (bindLen > 4)
11661 value += _addInterpolationPart(v4, bindings[4]);
11662 if (bindLen > 5)
11663 value += _addInterpolationPart(v5, bindings[5]);
11664 if (bindLen > 6)
11665 value += _addInterpolationPart(v6, bindings[6]);
11666 if (bindLen > 7)
11667 value += _addInterpolationPart(v7, bindings[7]);
11668 if (bindLen > 8)
11669 value += _addInterpolationPart(v8, bindings[8]);
11670 if (bindLen > 9)
11671 value += _addInterpolationPart(v9, bindings[9]);
11672 var /** @type {?} */ renderNode$$1 = asTextData(view, def.index).renderText;
11673 view.renderer.setValue(renderNode$$1, value);
11674 }
11675 return changed;
11676}
11677/**
11678 * @param {?} view
11679 * @param {?} def
11680 * @param {?} values
11681 * @return {?}
11682 */
11683function checkAndUpdateTextDynamic(view, def, values) {
11684 var /** @type {?} */ bindings = def.bindings;
11685 var /** @type {?} */ changed = false;
11686 for (var /** @type {?} */ i = 0; i < values.length; i++) {
11687 // Note: We need to loop over all values, so that
11688 // the old values are updates as well!
11689 if (checkAndUpdateBinding(view, def, i, values[i])) {
11690 changed = true;
11691 }
11692 }
11693 if (changed) {
11694 var /** @type {?} */ value = '';
11695 for (var /** @type {?} */ i = 0; i < values.length; i++) {
11696 value = value + _addInterpolationPart(values[i], bindings[i]);
11697 }
11698 value = ((def.text)).prefix + value;
11699 var /** @type {?} */ renderNode$$1 = asTextData(view, def.index).renderText;
11700 view.renderer.setValue(renderNode$$1, value);
11701 }
11702 return changed;
11703}
11704/**
11705 * @param {?} value
11706 * @param {?} binding
11707 * @return {?}
11708 */
11709function _addInterpolationPart(value, binding) {
11710 var /** @type {?} */ valueStr = value != null ? value.toString() : '';
11711 return valueStr + binding.suffix;
11712}
11713/**
11714 * @license
11715 * Copyright Google Inc. All Rights Reserved.
11716 *
11717 * Use of this source code is governed by an MIT-style license that can be
11718 * found in the LICENSE file at https://angular.io/license
11719 */
11720/**
11721 * @param {?} flags
11722 * @param {?} nodes
11723 * @param {?=} updateDirectives
11724 * @param {?=} updateRenderer
11725 * @return {?}
11726 */
11727function viewDef(flags, nodes, updateDirectives, updateRenderer) {
11728 // clone nodes and set auto calculated values
11729 var /** @type {?} */ viewBindingCount = 0;
11730 var /** @type {?} */ viewDisposableCount = 0;
11731 var /** @type {?} */ viewNodeFlags = 0;
11732 var /** @type {?} */ viewRootNodeFlags = 0;
11733 var /** @type {?} */ viewMatchedQueries = 0;
11734 var /** @type {?} */ currentParent = null;
11735 var /** @type {?} */ currentElementHasPublicProviders = false;
11736 var /** @type {?} */ currentElementHasPrivateProviders = false;
11737 var /** @type {?} */ lastRenderRootNode = null;
11738 for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
11739 while (currentParent && i > currentParent.index + currentParent.childCount) {
11740 var /** @type {?} */ newParent = currentParent.parent;
11741 if (newParent) {
11742 newParent.childFlags |= ((currentParent.childFlags));
11743 newParent.childMatchedQueries |= currentParent.childMatchedQueries;
11744 }
11745 currentParent = newParent;
11746 }
11747 var /** @type {?} */ node = nodes[i];
11748 node.index = i;
11749 node.parent = currentParent;
11750 node.bindingIndex = viewBindingCount;
11751 node.outputIndex = viewDisposableCount;
11752 // renderParent needs to account for ng-container!
11753 var /** @type {?} */ currentRenderParent = void 0;
11754 if (currentParent && currentParent.flags & 1 /* TypeElement */ &&
11755 !((currentParent.element)).name) {
11756 currentRenderParent = currentParent.renderParent;
11757 }
11758 else {
11759 currentRenderParent = currentParent;
11760 }
11761 node.renderParent = currentRenderParent;
11762 if (node.element) {
11763 var /** @type {?} */ elDef = node.element;
11764 elDef.publicProviders =
11765 currentParent ? ((currentParent.element)).publicProviders : Object.create(null);
11766 elDef.allProviders = elDef.publicProviders;
11767 // Note: We assume that all providers of an element are before any child element!
11768 currentElementHasPublicProviders = false;
11769 currentElementHasPrivateProviders = false;
11770 }
11771 validateNode(currentParent, node, nodes.length);
11772 viewNodeFlags |= node.flags;
11773 viewMatchedQueries |= node.matchedQueryIds;
11774 if (node.element && node.element.template) {
11775 viewMatchedQueries |= node.element.template.nodeMatchedQueries;
11776 }
11777 if (currentParent) {
11778 currentParent.childFlags |= node.flags;
11779 currentParent.directChildFlags |= node.flags;
11780 currentParent.childMatchedQueries |= node.matchedQueryIds;
11781 if (node.element && node.element.template) {
11782 currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
11783 }
11784 }
11785 else {
11786 viewRootNodeFlags |= node.flags;
11787 }
11788 viewBindingCount += node.bindings.length;
11789 viewDisposableCount += node.outputs.length;
11790 if (!currentRenderParent && (node.flags & 3 /* CatRenderNode */)) {
11791 lastRenderRootNode = node;
11792 }
11793 if (node.flags & 10112 /* CatProvider */) {
11794 if (!currentElementHasPublicProviders) {
11795 currentElementHasPublicProviders = true; /** @type {?} */
11796 ((((
11797 // Use prototypical inheritance to not get O(n^2) complexity...
11798 currentParent)).element)).publicProviders =
11799 Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders); /** @type {?} */
11800 ((((currentParent)).element)).allProviders = ((((currentParent)).element)).publicProviders;
11801 }
11802 var /** @type {?} */ isPrivateService = (node.flags & 4096 /* PrivateProvider */) !== 0;
11803 var /** @type {?} */ isComponent = (node.flags & 16384 /* Component */) !== 0;
11804 if (!isPrivateService || isComponent) {
11805 ((((((currentParent)).element)).publicProviders))[((node.provider)).tokenKey] = node;
11806 }
11807 else {
11808 if (!currentElementHasPrivateProviders) {
11809 currentElementHasPrivateProviders = true; /** @type {?} */
11810 ((((
11811 // Use protoyypical inheritance to not get O(n^2) complexity...
11812 currentParent)).element)).allProviders =
11813 Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders);
11814 } /** @type {?} */
11815 ((((((currentParent)).element)).allProviders))[((node.provider)).tokenKey] = node;
11816 }
11817 if (isComponent) {
11818 ((((currentParent)).element)).componentProvider = node;
11819 }
11820 }
11821 if (node.childCount) {
11822 currentParent = node;
11823 }
11824 }
11825 while (currentParent) {
11826 var /** @type {?} */ newParent = currentParent.parent;
11827 if (newParent) {
11828 newParent.childFlags |= currentParent.childFlags;
11829 newParent.childMatchedQueries |= currentParent.childMatchedQueries;
11830 }
11831 currentParent = newParent;
11832 }
11833 var /** @type {?} */ handleEvent = function (view, nodeIndex, eventName, event) { return ((((nodes[nodeIndex].element)).handleEvent))(view, eventName, event); };
11834 return {
11835 // Will be filled later...
11836 factory: null,
11837 nodeFlags: viewNodeFlags,
11838 rootNodeFlags: viewRootNodeFlags,
11839 nodeMatchedQueries: viewMatchedQueries, flags: flags,
11840 nodes: nodes,
11841 updateDirectives: updateDirectives || NOOP,
11842 updateRenderer: updateRenderer || NOOP,
11843 handleEvent: handleEvent || NOOP,
11844 bindingCount: viewBindingCount,
11845 outputCount: viewDisposableCount, lastRenderRootNode: lastRenderRootNode
11846 };
11847}
11848/**
11849 * @param {?} parent
11850 * @param {?} node
11851 * @param {?} nodeCount
11852 * @return {?}
11853 */
11854function validateNode(parent, node, nodeCount) {
11855 var /** @type {?} */ template = node.element && node.element.template;
11856 if (template) {
11857 if (!template.lastRenderRootNode) {
11858 throw new Error("Illegal State: Embedded templates without nodes are not allowed!");
11859 }
11860 if (template.lastRenderRootNode &&
11861 template.lastRenderRootNode.flags & 8388608 /* EmbeddedViews */) {
11862 throw new Error("Illegal State: Last root node of a template can't have embedded views, at index " + node.index + "!");
11863 }
11864 }
11865 if (node.flags & 10112 /* CatProvider */) {
11866 var /** @type {?} */ parentFlags = parent ? parent.flags : 0;
11867 if ((parentFlags & 1 /* TypeElement */) === 0) {
11868 throw new Error("Illegal State: Provider/Directive nodes need to be children of elements or anchors, at index " + node.index + "!");
11869 }
11870 }
11871 if (node.query) {
11872 if (node.flags & 33554432 /* TypeContentQuery */ &&
11873 (!parent || (parent.flags & 8192 /* TypeDirective */) === 0)) {
11874 throw new Error("Illegal State: Content Query nodes need to be children of directives, at index " + node.index + "!");
11875 }
11876 if (node.flags & 67108864 /* TypeViewQuery */ && parent) {
11877 throw new Error("Illegal State: View Query nodes have to be top level nodes, at index " + node.index + "!");
11878 }
11879 }
11880 if (node.childCount) {
11881 var /** @type {?} */ parentEnd = parent ? parent.index + parent.childCount : nodeCount - 1;
11882 if (node.index <= parentEnd && node.index + node.childCount > parentEnd) {
11883 throw new Error("Illegal State: childCount of node leads outside of parent, at index " + node.index + "!");
11884 }
11885 }
11886}
11887/**
11888 * @param {?} parent
11889 * @param {?} anchorDef
11890 * @param {?=} context
11891 * @return {?}
11892 */
11893function createEmbeddedView(parent, anchorDef$$1, context) {
11894 // embedded views are seen as siblings to the anchor, so we need
11895 // to get the parent of the anchor and use it as parentIndex.
11896 var /** @type {?} */ view = createView(parent.root, parent.renderer, parent, anchorDef$$1, /** @type {?} */ ((((anchorDef$$1.element)).template)));
11897 initView(view, parent.component, context);
11898 createViewNodes(view);
11899 return view;
11900}
11901/**
11902 * @param {?} root
11903 * @param {?} def
11904 * @param {?=} context
11905 * @return {?}
11906 */
11907function createRootView(root, def, context) {
11908 var /** @type {?} */ view = createView(root, root.renderer, null, null, def);
11909 initView(view, context, context);
11910 createViewNodes(view);
11911 return view;
11912}
11913/**
11914 * @param {?} root
11915 * @param {?} renderer
11916 * @param {?} parent
11917 * @param {?} parentNodeDef
11918 * @param {?} def
11919 * @return {?}
11920 */
11921function createView(root, renderer, parent, parentNodeDef, def) {
11922 var /** @type {?} */ nodes = new Array(def.nodes.length);
11923 var /** @type {?} */ disposables = def.outputCount ? new Array(def.outputCount) : null;
11924 var /** @type {?} */ view = {
11925 def: def,
11926 parent: parent,
11927 viewContainerParent: null, parentNodeDef: parentNodeDef,
11928 context: null,
11929 component: null, nodes: nodes,
11930 state: 13 /* CatInit */, root: root, renderer: renderer,
11931 oldValues: new Array(def.bindingCount), disposables: disposables
11932 };
11933 return view;
11934}
11935/**
11936 * @param {?} view
11937 * @param {?} component
11938 * @param {?} context
11939 * @return {?}
11940 */
11941function initView(view, component, context) {
11942 view.component = component;
11943 view.context = context;
11944}
11945/**
11946 * @param {?} view
11947 * @return {?}
11948 */
11949function createViewNodes(view) {
11950 var /** @type {?} */ renderHost;
11951 if (isComponentView(view)) {
11952 var /** @type {?} */ hostDef = view.parentNodeDef;
11953 renderHost = asElementData(/** @type {?} */ ((view.parent)), /** @type {?} */ ((((hostDef)).parent)).index).renderElement;
11954 }
11955 var /** @type {?} */ def = view.def;
11956 var /** @type {?} */ nodes = view.nodes;
11957 for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
11958 var /** @type {?} */ nodeDef = def.nodes[i];
11959 Services.setCurrentNode(view, i);
11960 var /** @type {?} */ nodeData = void 0;
11961 switch (nodeDef.flags & 100673535 /* Types */) {
11962 case 1 /* TypeElement */:
11963 var /** @type {?} */ el = (createElement(view, renderHost, nodeDef));
11964 var /** @type {?} */ componentView = ((undefined));
11965 if (nodeDef.flags & 16777216 /* ComponentView */) {
11966 var /** @type {?} */ compViewDef = resolveViewDefinition(/** @type {?} */ ((((nodeDef.element)).componentView)));
11967 var /** @type {?} */ rendererType = ((nodeDef.element)).componentRendererType;
11968 var /** @type {?} */ compRenderer = void 0;
11969 if (!rendererType) {
11970 compRenderer = view.root.renderer;
11971 }
11972 else {
11973 compRenderer = view.root.rendererFactory.createRenderer(el, rendererType);
11974 }
11975 componentView = createView(view.root, compRenderer, view, /** @type {?} */ ((nodeDef.element)).componentProvider, compViewDef);
11976 }
11977 listenToElementOutputs(view, componentView, nodeDef, el);
11978 nodeData = ({
11979 renderElement: el,
11980 componentView: componentView,
11981 viewContainer: null,
11982 template: /** @type {?} */ ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
11983 });
11984 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
11985 nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
11986 }
11987 break;
11988 case 2 /* TypeText */:
11989 nodeData = (createText(view, renderHost, nodeDef));
11990 break;
11991 case 256 /* TypeClassProvider */:
11992 case 512 /* TypeFactoryProvider */:
11993 case 1024 /* TypeUseExistingProvider */:
11994 case 128 /* TypeValueProvider */: {
11995 var /** @type {?} */ instance = createProviderInstance(view, nodeDef);
11996 nodeData = ({ instance: instance });
11997 break;
11998 }
11999 case 8 /* TypePipe */: {
12000 var /** @type {?} */ instance = createPipeInstance(view, nodeDef);
12001 nodeData = ({ instance: instance });
12002 break;
12003 }
12004 case 8192 /* TypeDirective */: {
12005 var /** @type {?} */ instance = createDirectiveInstance(view, nodeDef);
12006 nodeData = ({ instance: instance });
12007 if (nodeDef.flags & 16384 /* Component */) {
12008 var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((nodeDef.parent)).index).componentView;
12009 initView(compView, instance, instance);
12010 }
12011 break;
12012 }
12013 case 16 /* TypePureArray */:
12014 case 32 /* TypePureObject */:
12015 case 64 /* TypePurePipe */:
12016 nodeData = (createPureExpression(view, nodeDef));
12017 break;
12018 case 33554432 /* TypeContentQuery */:
12019 case 67108864 /* TypeViewQuery */:
12020 nodeData = (createQuery());
12021 break;
12022 case 4 /* TypeNgContent */:
12023 appendNgContent(view, renderHost, nodeDef);
12024 // no runtime data needed for NgContent...
12025 nodeData = undefined;
12026 break;
12027 }
12028 nodes[i] = nodeData;
12029 }
12030 // Create the ViewData.nodes of component views after we created everything else,
12031 // so that e.g. ng-content works
12032 execComponentViewsAction(view, ViewAction.CreateViewNodes);
12033 // fill static content and view queries
12034 execQueriesAction(view, 33554432 /* TypeContentQuery */ | 67108864 /* TypeViewQuery */, 134217728 /* StaticQuery */, 0 /* CheckAndUpdate */);
12035}
12036/**
12037 * @param {?} view
12038 * @return {?}
12039 */
12040function checkNoChangesView(view) {
12041 Services.updateDirectives(view, 1 /* CheckNoChanges */);
12042 execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
12043 Services.updateRenderer(view, 1 /* CheckNoChanges */);
12044 execComponentViewsAction(view, ViewAction.CheckNoChanges);
12045 // Note: We don't check queries for changes as we didn't do this in v2.x.
12046 // TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
12047}
12048/**
12049 * @param {?} view
12050 * @return {?}
12051 */
12052function checkAndUpdateView(view) {
12053 if (view.state & 1 /* BeforeFirstCheck */) {
12054 view.state &= ~1 /* BeforeFirstCheck */;
12055 view.state |= 2 /* FirstCheck */;
12056 }
12057 else {
12058 view.state &= ~2 /* FirstCheck */;
12059 }
12060 Services.updateDirectives(view, 0 /* CheckAndUpdate */);
12061 execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
12062 execQueriesAction(view, 33554432 /* TypeContentQuery */, 268435456 /* DynamicQuery */, 0 /* CheckAndUpdate */);
12063 callLifecycleHooksChildrenFirst(view, 1048576 /* AfterContentChecked */ |
12064 (view.state & 2 /* FirstCheck */ ? 524288 /* AfterContentInit */ : 0));
12065 Services.updateRenderer(view, 0 /* CheckAndUpdate */);
12066 execComponentViewsAction(view, ViewAction.CheckAndUpdate);
12067 execQueriesAction(view, 67108864 /* TypeViewQuery */, 268435456 /* DynamicQuery */, 0 /* CheckAndUpdate */);
12068 callLifecycleHooksChildrenFirst(view, 4194304 /* AfterViewChecked */ |
12069 (view.state & 2 /* FirstCheck */ ? 2097152 /* AfterViewInit */ : 0));
12070 if (view.def.flags & 2 /* OnPush */) {
12071 view.state &= ~8 /* ChecksEnabled */;
12072 }
12073}
12074/**
12075 * @param {?} view
12076 * @param {?} nodeDef
12077 * @param {?} argStyle
12078 * @param {?=} v0
12079 * @param {?=} v1
12080 * @param {?=} v2
12081 * @param {?=} v3
12082 * @param {?=} v4
12083 * @param {?=} v5
12084 * @param {?=} v6
12085 * @param {?=} v7
12086 * @param {?=} v8
12087 * @param {?=} v9
12088 * @return {?}
12089 */
12090function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12091 if (argStyle === 0 /* Inline */) {
12092 return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12093 }
12094 else {
12095 return checkAndUpdateNodeDynamic(view, nodeDef, v0);
12096 }
12097}
12098/**
12099 * @param {?} view
12100 * @param {?} nodeDef
12101 * @param {?=} v0
12102 * @param {?=} v1
12103 * @param {?=} v2
12104 * @param {?=} v3
12105 * @param {?=} v4
12106 * @param {?=} v5
12107 * @param {?=} v6
12108 * @param {?=} v7
12109 * @param {?=} v8
12110 * @param {?=} v9
12111 * @return {?}
12112 */
12113function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12114 var /** @type {?} */ changed = false;
12115 switch (nodeDef.flags & 100673535 /* Types */) {
12116 case 1 /* TypeElement */:
12117 changed = checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12118 break;
12119 case 2 /* TypeText */:
12120 changed = checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12121 break;
12122 case 8192 /* TypeDirective */:
12123 changed =
12124 checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12125 break;
12126 case 16 /* TypePureArray */:
12127 case 32 /* TypePureObject */:
12128 case 64 /* TypePurePipe */:
12129 changed =
12130 checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12131 break;
12132 }
12133 return changed;
12134}
12135/**
12136 * @param {?} view
12137 * @param {?} nodeDef
12138 * @param {?} values
12139 * @return {?}
12140 */
12141function checkAndUpdateNodeDynamic(view, nodeDef, values) {
12142 var /** @type {?} */ changed = false;
12143 switch (nodeDef.flags & 100673535 /* Types */) {
12144 case 1 /* TypeElement */:
12145 changed = checkAndUpdateElementDynamic(view, nodeDef, values);
12146 break;
12147 case 2 /* TypeText */:
12148 changed = checkAndUpdateTextDynamic(view, nodeDef, values);
12149 break;
12150 case 8192 /* TypeDirective */:
12151 changed = checkAndUpdateDirectiveDynamic(view, nodeDef, values);
12152 break;
12153 case 16 /* TypePureArray */:
12154 case 32 /* TypePureObject */:
12155 case 64 /* TypePurePipe */:
12156 changed = checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
12157 break;
12158 }
12159 if (changed) {
12160 // Update oldValues after all bindings have been updated,
12161 // as a setter for a property might update other properties.
12162 var /** @type {?} */ bindLen = nodeDef.bindings.length;
12163 var /** @type {?} */ bindingStart = nodeDef.bindingIndex;
12164 var /** @type {?} */ oldValues = view.oldValues;
12165 for (var /** @type {?} */ i = 0; i < bindLen; i++) {
12166 oldValues[bindingStart + i] = values[i];
12167 }
12168 }
12169 return changed;
12170}
12171/**
12172 * @param {?} view
12173 * @param {?} nodeDef
12174 * @param {?} argStyle
12175 * @param {?=} v0
12176 * @param {?=} v1
12177 * @param {?=} v2
12178 * @param {?=} v3
12179 * @param {?=} v4
12180 * @param {?=} v5
12181 * @param {?=} v6
12182 * @param {?=} v7
12183 * @param {?=} v8
12184 * @param {?=} v9
12185 * @return {?}
12186 */
12187function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12188 if (argStyle === 0 /* Inline */) {
12189 checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12190 }
12191 else {
12192 checkNoChangesNodeDynamic(view, nodeDef, v0);
12193 }
12194 // Returning false is ok here as we would have thrown in case of a change.
12195 return false;
12196}
12197/**
12198 * @param {?} view
12199 * @param {?} nodeDef
12200 * @param {?} v0
12201 * @param {?} v1
12202 * @param {?} v2
12203 * @param {?} v3
12204 * @param {?} v4
12205 * @param {?} v5
12206 * @param {?} v6
12207 * @param {?} v7
12208 * @param {?} v8
12209 * @param {?} v9
12210 * @return {?}
12211 */
12212function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12213 var /** @type {?} */ bindLen = nodeDef.bindings.length;
12214 if (bindLen > 0)
12215 checkBindingNoChanges(view, nodeDef, 0, v0);
12216 if (bindLen > 1)
12217 checkBindingNoChanges(view, nodeDef, 1, v1);
12218 if (bindLen > 2)
12219 checkBindingNoChanges(view, nodeDef, 2, v2);
12220 if (bindLen > 3)
12221 checkBindingNoChanges(view, nodeDef, 3, v3);
12222 if (bindLen > 4)
12223 checkBindingNoChanges(view, nodeDef, 4, v4);
12224 if (bindLen > 5)
12225 checkBindingNoChanges(view, nodeDef, 5, v5);
12226 if (bindLen > 6)
12227 checkBindingNoChanges(view, nodeDef, 6, v6);
12228 if (bindLen > 7)
12229 checkBindingNoChanges(view, nodeDef, 7, v7);
12230 if (bindLen > 8)
12231 checkBindingNoChanges(view, nodeDef, 8, v8);
12232 if (bindLen > 9)
12233 checkBindingNoChanges(view, nodeDef, 9, v9);
12234}
12235/**
12236 * @param {?} view
12237 * @param {?} nodeDef
12238 * @param {?} values
12239 * @return {?}
12240 */
12241function checkNoChangesNodeDynamic(view, nodeDef, values) {
12242 for (var /** @type {?} */ i = 0; i < values.length; i++) {
12243 checkBindingNoChanges(view, nodeDef, i, values[i]);
12244 }
12245}
12246/**
12247 * @param {?} view
12248 * @param {?} nodeDef
12249 * @return {?}
12250 */
12251function checkNoChangesQuery(view, nodeDef) {
12252 var /** @type {?} */ queryList = asQueryList(view, nodeDef.index);
12253 if (queryList.dirty) {
12254 throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.index), "Query " + ((nodeDef.query)).id + " not dirty", "Query " + ((nodeDef.query)).id + " dirty", (view.state & 1 /* BeforeFirstCheck */) !== 0);
12255 }
12256}
12257/**
12258 * @param {?} view
12259 * @return {?}
12260 */
12261function destroyView(view) {
12262 if (view.state & 16 /* Destroyed */) {
12263 return;
12264 }
12265 execEmbeddedViewsAction(view, ViewAction.Destroy);
12266 execComponentViewsAction(view, ViewAction.Destroy);
12267 callLifecycleHooksChildrenFirst(view, 65536 /* OnDestroy */);
12268 if (view.disposables) {
12269 for (var /** @type {?} */ i = 0; i < view.disposables.length; i++) {
12270 view.disposables[i]();
12271 }
12272 }
12273 if (view.renderer.destroyNode) {
12274 destroyViewNodes(view);
12275 }
12276 if (isComponentView(view)) {
12277 view.renderer.destroy();
12278 }
12279 view.state |= 16 /* Destroyed */;
12280}
12281/**
12282 * @param {?} view
12283 * @return {?}
12284 */
12285function destroyViewNodes(view) {
12286 var /** @type {?} */ len = view.def.nodes.length;
12287 for (var /** @type {?} */ i = 0; i < len; i++) {
12288 var /** @type {?} */ def = view.def.nodes[i];
12289 if (def.flags & 1 /* TypeElement */) {
12290 ((view.renderer.destroyNode))(asElementData(view, i).renderElement);
12291 }
12292 else if (def.flags & 2 /* TypeText */) {
12293 ((view.renderer.destroyNode))(asTextData(view, i).renderText);
12294 }
12295 }
12296}
12297var ViewAction = {};
12298ViewAction.CreateViewNodes = 0;
12299ViewAction.CheckNoChanges = 1;
12300ViewAction.CheckAndUpdate = 2;
12301ViewAction.Destroy = 3;
12302ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
12303ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
12304ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
12305ViewAction[ViewAction.Destroy] = "Destroy";
12306/**
12307 * @param {?} view
12308 * @param {?} action
12309 * @return {?}
12310 */
12311function execComponentViewsAction(view, action) {
12312 var /** @type {?} */ def = view.def;
12313 if (!(def.nodeFlags & 16777216 /* ComponentView */)) {
12314 return;
12315 }
12316 for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12317 var /** @type {?} */ nodeDef = def.nodes[i];
12318 if (nodeDef.flags & 16777216 /* ComponentView */) {
12319 // a leaf
12320 callViewAction(asElementData(view, i).componentView, action);
12321 }
12322 else if ((nodeDef.childFlags & 16777216 /* ComponentView */) === 0) {
12323 // a parent with leafs
12324 // no child is a component,
12325 // then skip the children
12326 i += nodeDef.childCount;
12327 }
12328 }
12329}
12330/**
12331 * @param {?} view
12332 * @param {?} action
12333 * @return {?}
12334 */
12335function execEmbeddedViewsAction(view, action) {
12336 var /** @type {?} */ def = view.def;
12337 if (!(def.nodeFlags & 8388608 /* EmbeddedViews */)) {
12338 return;
12339 }
12340 for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12341 var /** @type {?} */ nodeDef = def.nodes[i];
12342 if (nodeDef.flags & 8388608 /* EmbeddedViews */) {
12343 // a leaf
12344 var /** @type {?} */ embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
12345 for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
12346 callViewAction(embeddedViews[k], action);
12347 }
12348 }
12349 else if ((nodeDef.childFlags & 8388608 /* EmbeddedViews */) === 0) {
12350 // a parent with leafs
12351 // no child is a component,
12352 // then skip the children
12353 i += nodeDef.childCount;
12354 }
12355 }
12356}
12357/**
12358 * @param {?} view
12359 * @param {?} action
12360 * @return {?}
12361 */
12362function callViewAction(view, action) {
12363 var /** @type {?} */ viewState = view.state;
12364 switch (action) {
12365 case ViewAction.CheckNoChanges:
12366 if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */ &&
12367 (viewState & 16 /* Destroyed */) === 0) {
12368 checkNoChangesView(view);
12369 }
12370 break;
12371 case ViewAction.CheckAndUpdate:
12372 if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */ &&
12373 (viewState & 16 /* Destroyed */) === 0) {
12374 checkAndUpdateView(view);
12375 }
12376 break;
12377 case ViewAction.Destroy:
12378 destroyView(view);
12379 break;
12380 case ViewAction.CreateViewNodes:
12381 createViewNodes(view);
12382 break;
12383 }
12384}
12385/**
12386 * @param {?} view
12387 * @param {?} queryFlags
12388 * @param {?} staticDynamicQueryFlag
12389 * @param {?} checkType
12390 * @return {?}
12391 */
12392function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
12393 if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
12394 return;
12395 }
12396 var /** @type {?} */ nodeCount = view.def.nodes.length;
12397 for (var /** @type {?} */ i = 0; i < nodeCount; i++) {
12398 var /** @type {?} */ nodeDef = view.def.nodes[i];
12399 if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
12400 Services.setCurrentNode(view, nodeDef.index);
12401 switch (checkType) {
12402 case 0 /* CheckAndUpdate */:
12403 checkAndUpdateQuery(view, nodeDef);
12404 break;
12405 case 1 /* CheckNoChanges */:
12406 checkNoChangesQuery(view, nodeDef);
12407 break;
12408 }
12409 }
12410 if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
12411 // no child has a matching query
12412 // then skip the children
12413 i += nodeDef.childCount;
12414 }
12415 }
12416}
12417/**
12418 * @license
12419 * Copyright Google Inc. All Rights Reserved.
12420 *
12421 * Use of this source code is governed by an MIT-style license that can be
12422 * found in the LICENSE file at https://angular.io/license
12423 */
12424var initialized = false;
12425/**
12426 * @return {?}
12427 */
12428function initServicesIfNeeded() {
12429 if (initialized) {
12430 return;
12431 }
12432 initialized = true;
12433 var /** @type {?} */ services = isDevMode() ? createDebugServices() : createProdServices();
12434 Services.setCurrentNode = services.setCurrentNode;
12435 Services.createRootView = services.createRootView;
12436 Services.createEmbeddedView = services.createEmbeddedView;
12437 Services.checkAndUpdateView = services.checkAndUpdateView;
12438 Services.checkNoChangesView = services.checkNoChangesView;
12439 Services.destroyView = services.destroyView;
12440 Services.resolveDep = resolveDep;
12441 Services.createDebugContext = services.createDebugContext;
12442 Services.handleEvent = services.handleEvent;
12443 Services.updateDirectives = services.updateDirectives;
12444 Services.updateRenderer = services.updateRenderer;
12445 Services.dirtyParentQueries = dirtyParentQueries;
12446}
12447/**
12448 * @return {?}
12449 */
12450function createProdServices() {
12451 return {
12452 setCurrentNode: function () { },
12453 createRootView: createProdRootView,
12454 createEmbeddedView: createEmbeddedView,
12455 checkAndUpdateView: checkAndUpdateView,
12456 checkNoChangesView: checkNoChangesView,
12457 destroyView: destroyView,
12458 createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
12459 handleEvent: function (view, nodeIndex, eventName, event) { return view.def.handleEvent(view, nodeIndex, eventName, event); },
12460 updateDirectives: function (view, checkType) { return view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12461 prodCheckNoChangesNode, view); },
12462 updateRenderer: function (view, checkType) { return view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12463 prodCheckNoChangesNode, view); },
12464 };
12465}
12466/**
12467 * @return {?}
12468 */
12469function createDebugServices() {
12470 return {
12471 setCurrentNode: debugSetCurrentNode,
12472 createRootView: debugCreateRootView,
12473 createEmbeddedView: debugCreateEmbeddedView,
12474 checkAndUpdateView: debugCheckAndUpdateView,
12475 checkNoChangesView: debugCheckNoChangesView,
12476 destroyView: debugDestroyView,
12477 createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
12478 handleEvent: debugHandleEvent,
12479 updateDirectives: debugUpdateDirectives,
12480 updateRenderer: debugUpdateRenderer
12481 };
12482}
12483/**
12484 * @param {?} elInjector
12485 * @param {?} projectableNodes
12486 * @param {?} rootSelectorOrNode
12487 * @param {?} def
12488 * @param {?} ngModule
12489 * @param {?=} context
12490 * @return {?}
12491 */
12492function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12493 var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12494 return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
12495}
12496/**
12497 * @param {?} elInjector
12498 * @param {?} projectableNodes
12499 * @param {?} rootSelectorOrNode
12500 * @param {?} def
12501 * @param {?} ngModule
12502 * @param {?=} context
12503 * @return {?}
12504 */
12505function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12506 var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12507 var /** @type {?} */ root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
12508 return callWithDebugContext(DebugAction.create, createRootView, null, [root, def, context]);
12509}
12510/**
12511 * @param {?} elInjector
12512 * @param {?} ngModule
12513 * @param {?} rendererFactory
12514 * @param {?} projectableNodes
12515 * @param {?} rootSelectorOrNode
12516 * @return {?}
12517 */
12518function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
12519 var /** @type {?} */ sanitizer = ngModule.injector.get(Sanitizer);
12520 var /** @type {?} */ errorHandler = ngModule.injector.get(ErrorHandler);
12521 var /** @type {?} */ renderer = rendererFactory.createRenderer(null, null);
12522 return {
12523 ngModule: ngModule,
12524 injector: elInjector, projectableNodes: projectableNodes,
12525 selectorOrNode: rootSelectorOrNode, sanitizer: sanitizer, rendererFactory: rendererFactory, renderer: renderer, errorHandler: errorHandler
12526 };
12527}
12528/**
12529 * @param {?} view
12530 * @param {?} nodeIndex
12531 * @param {?} argStyle
12532 * @param {?=} v0
12533 * @param {?=} v1
12534 * @param {?=} v2
12535 * @param {?=} v3
12536 * @param {?=} v4
12537 * @param {?=} v5
12538 * @param {?=} v6
12539 * @param {?=} v7
12540 * @param {?=} v8
12541 * @param {?=} v9
12542 * @return {?}
12543 */
12544function prodCheckAndUpdateNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12545 var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12546 checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12547 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12548 asPureExpressionData(view, nodeIndex).value :
12549 undefined;
12550}
12551/**
12552 * @param {?} view
12553 * @param {?} nodeIndex
12554 * @param {?} argStyle
12555 * @param {?=} v0
12556 * @param {?=} v1
12557 * @param {?=} v2
12558 * @param {?=} v3
12559 * @param {?=} v4
12560 * @param {?=} v5
12561 * @param {?=} v6
12562 * @param {?=} v7
12563 * @param {?=} v8
12564 * @param {?=} v9
12565 * @return {?}
12566 */
12567function prodCheckNoChangesNode(view, nodeIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12568 var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12569 checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12570 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12571 asPureExpressionData(view, nodeIndex).value :
12572 undefined;
12573}
12574/**
12575 * @param {?} parent
12576 * @param {?} anchorDef
12577 * @param {?=} context
12578 * @return {?}
12579 */
12580function debugCreateEmbeddedView(parent, anchorDef, context) {
12581 return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parent, anchorDef, context]);
12582}
12583/**
12584 * @param {?} view
12585 * @return {?}
12586 */
12587function debugCheckAndUpdateView(view) {
12588 return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
12589}
12590/**
12591 * @param {?} view
12592 * @return {?}
12593 */
12594function debugCheckNoChangesView(view) {
12595 return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
12596}
12597/**
12598 * @param {?} view
12599 * @return {?}
12600 */
12601function debugDestroyView(view) {
12602 return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
12603}
12604var DebugAction = {};
12605DebugAction.create = 0;
12606DebugAction.detectChanges = 1;
12607DebugAction.checkNoChanges = 2;
12608DebugAction.destroy = 3;
12609DebugAction.handleEvent = 4;
12610DebugAction[DebugAction.create] = "create";
12611DebugAction[DebugAction.detectChanges] = "detectChanges";
12612DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
12613DebugAction[DebugAction.destroy] = "destroy";
12614DebugAction[DebugAction.handleEvent] = "handleEvent";
12615var _currentAction;
12616var _currentView;
12617var _currentNodeIndex;
12618/**
12619 * @param {?} view
12620 * @param {?} nodeIndex
12621 * @return {?}
12622 */
12623function debugSetCurrentNode(view, nodeIndex) {
12624 _currentView = view;
12625 _currentNodeIndex = nodeIndex;
12626}
12627/**
12628 * @param {?} view
12629 * @param {?} nodeIndex
12630 * @param {?} eventName
12631 * @param {?} event
12632 * @return {?}
12633 */
12634function debugHandleEvent(view, nodeIndex, eventName, event) {
12635 debugSetCurrentNode(view, nodeIndex);
12636 return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
12637}
12638/**
12639 * @param {?} view
12640 * @param {?} checkType
12641 * @return {?}
12642 */
12643function debugUpdateDirectives(view, checkType) {
12644 if (view.state & 16 /* Destroyed */) {
12645 throw viewDestroyedError(DebugAction[_currentAction]);
12646 }
12647 debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
12648 return view.def.updateDirectives(debugCheckDirectivesFn, view);
12649 /**
12650 * @param {?} view
12651 * @param {?} nodeIndex
12652 * @param {?} argStyle
12653 * @param {...?} values
12654 * @return {?}
12655 */
12656 function debugCheckDirectivesFn(view, nodeIndex, argStyle) {
12657 var values = [];
12658 for (var _i = 3; _i < arguments.length; _i++) {
12659 values[_i - 3] = arguments[_i];
12660 }
12661 var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12662 if (checkType === 0 /* CheckAndUpdate */) {
12663 debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
12664 }
12665 else {
12666 debugCheckNoChangesNode(view, nodeDef, argStyle, values);
12667 }
12668 if (nodeDef.flags & 8192 /* TypeDirective */) {
12669 debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
12670 }
12671 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12672 asPureExpressionData(view, nodeDef.index).value :
12673 undefined;
12674 }
12675}
12676/**
12677 * @param {?} view
12678 * @param {?} checkType
12679 * @return {?}
12680 */
12681function debugUpdateRenderer(view, checkType) {
12682 if (view.state & 16 /* Destroyed */) {
12683 throw viewDestroyedError(DebugAction[_currentAction]);
12684 }
12685 debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
12686 return view.def.updateRenderer(debugCheckRenderNodeFn, view);
12687 /**
12688 * @param {?} view
12689 * @param {?} nodeIndex
12690 * @param {?} argStyle
12691 * @param {...?} values
12692 * @return {?}
12693 */
12694 function debugCheckRenderNodeFn(view, nodeIndex, argStyle) {
12695 var values = [];
12696 for (var _i = 3; _i < arguments.length; _i++) {
12697 values[_i - 3] = arguments[_i];
12698 }
12699 var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
12700 if (checkType === 0 /* CheckAndUpdate */) {
12701 debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
12702 }
12703 else {
12704 debugCheckNoChangesNode(view, nodeDef, argStyle, values);
12705 }
12706 if (nodeDef.flags & 3 /* CatRenderNode */) {
12707 debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
12708 }
12709 return (nodeDef.flags & 112 /* CatPureExpression */) ?
12710 asPureExpressionData(view, nodeDef.index).value :
12711 undefined;
12712 }
12713}
12714/**
12715 * @param {?} view
12716 * @param {?} nodeDef
12717 * @param {?} argStyle
12718 * @param {?} givenValues
12719 * @return {?}
12720 */
12721function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
12722 var /** @type {?} */ changed = ((checkAndUpdateNode)).apply(void 0, [view, nodeDef, argStyle].concat(givenValues));
12723 if (changed) {
12724 var /** @type {?} */ values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
12725 if (nodeDef.flags & 8192 /* TypeDirective */) {
12726 var /** @type {?} */ bindingValues = {};
12727 for (var /** @type {?} */ i = 0; i < nodeDef.bindings.length; i++) {
12728 var /** @type {?} */ binding = nodeDef.bindings[i];
12729 var /** @type {?} */ value = values[i];
12730 if (binding.flags & 8 /* TypeProperty */) {
12731 bindingValues[normalizeDebugBindingName(/** @type {?} */ ((binding.nonMinifiedName)))] =
12732 normalizeDebugBindingValue(value);
12733 }
12734 }
12735 var /** @type {?} */ elDef = ((nodeDef.parent));
12736 var /** @type {?} */ el = asElementData(view, elDef.index).renderElement;
12737 if (!((elDef.element)).name) {
12738 // a comment.
12739 view.renderer.setValue(el, "bindings=" + JSON.stringify(bindingValues, null, 2));
12740 }
12741 else {
12742 // a regular element.
12743 for (var /** @type {?} */ attr in bindingValues) {
12744 var /** @type {?} */ value = bindingValues[attr];
12745 if (value != null) {
12746 view.renderer.setAttribute(el, attr, value);
12747 }
12748 else {
12749 view.renderer.removeAttribute(el, attr);
12750 }
12751 }
12752 }
12753 }
12754 }
12755}
12756/**
12757 * @param {?} view
12758 * @param {?} nodeDef
12759 * @param {?} argStyle
12760 * @param {?} values
12761 * @return {?}
12762 */
12763function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
12764 ((checkNoChangesNode)).apply(void 0, [view, nodeDef, argStyle].concat(values));
12765}
12766/**
12767 * @param {?} name
12768 * @return {?}
12769 */
12770function normalizeDebugBindingName(name) {
12771 // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
12772 name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
12773 return "ng-reflect-" + name;
12774}
12775var CAMEL_CASE_REGEXP = /([A-Z])/g;
12776/**
12777 * @param {?} input
12778 * @return {?}
12779 */
12780function camelCaseToDashCase(input) {
12781 return input.replace(CAMEL_CASE_REGEXP, function () {
12782 var m = [];
12783 for (var _i = 0; _i < arguments.length; _i++) {
12784 m[_i] = arguments[_i];
12785 }
12786 return '-' + m[1].toLowerCase();
12787 });
12788}
12789/**
12790 * @param {?} value
12791 * @return {?}
12792 */
12793function normalizeDebugBindingValue(value) {
12794 try {
12795 // Limit the size of the value as otherwise the DOM just gets polluted.
12796 return value != null ? value.toString().slice(0, 30) : value;
12797 }
12798 catch (e) {
12799 return '[ERROR] Exception while trying to serialize the value';
12800 }
12801}
12802/**
12803 * @param {?} view
12804 * @param {?} nodeIndex
12805 * @return {?}
12806 */
12807function nextDirectiveWithBinding(view, nodeIndex) {
12808 for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
12809 var /** @type {?} */ nodeDef = view.def.nodes[i];
12810 if (nodeDef.flags & 8192 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
12811 return i;
12812 }
12813 }
12814 return null;
12815}
12816/**
12817 * @param {?} view
12818 * @param {?} nodeIndex
12819 * @return {?}
12820 */
12821function nextRenderNodeWithBinding(view, nodeIndex) {
12822 for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
12823 var /** @type {?} */ nodeDef = view.def.nodes[i];
12824 if ((nodeDef.flags & 3 /* CatRenderNode */) && nodeDef.bindings && nodeDef.bindings.length) {
12825 return i;
12826 }
12827 }
12828 return null;
12829}
12830var DebugContext_ = (function () {
12831 /**
12832 * @param {?} view
12833 * @param {?} nodeIndex
12834 */
12835 function DebugContext_(view, nodeIndex) {
12836 this.view = view;
12837 this.nodeIndex = nodeIndex;
12838 if (nodeIndex == null) {
12839 this.nodeIndex = nodeIndex = 0;
12840 }
12841 this.nodeDef = view.def.nodes[nodeIndex];
12842 var elDef = this.nodeDef;
12843 var elView = view;
12844 while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
12845 elDef = elDef.parent;
12846 }
12847 if (!elDef) {
12848 while (!elDef && elView) {
12849 elDef = viewParentEl(elView);
12850 elView = elView.parent;
12851 }
12852 }
12853 this.elDef = elDef;
12854 this.elView = elView;
12855 }
12856 Object.defineProperty(DebugContext_.prototype, "elOrCompView", {
12857 /**
12858 * @return {?}
12859 */
12860 get: function () {
12861 // Has to be done lazily as we use the DebugContext also during creation of elements...
12862 return asElementData(this.elView, this.elDef.index).componentView || this.view;
12863 },
12864 enumerable: true,
12865 configurable: true
12866 });
12867 Object.defineProperty(DebugContext_.prototype, "injector", {
12868 /**
12869 * @return {?}
12870 */
12871 get: function () { return createInjector(this.elView, this.elDef); },
12872 enumerable: true,
12873 configurable: true
12874 });
12875 Object.defineProperty(DebugContext_.prototype, "component", {
12876 /**
12877 * @return {?}
12878 */
12879 get: function () { return this.elOrCompView.component; },
12880 enumerable: true,
12881 configurable: true
12882 });
12883 Object.defineProperty(DebugContext_.prototype, "context", {
12884 /**
12885 * @return {?}
12886 */
12887 get: function () { return this.elOrCompView.context; },
12888 enumerable: true,
12889 configurable: true
12890 });
12891 Object.defineProperty(DebugContext_.prototype, "providerTokens", {
12892 /**
12893 * @return {?}
12894 */
12895 get: function () {
12896 var /** @type {?} */ tokens = [];
12897 if (this.elDef) {
12898 for (var /** @type {?} */ i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
12899 var /** @type {?} */ childDef = this.elView.def.nodes[i];
12900 if (childDef.flags & 10112 /* CatProvider */) {
12901 tokens.push(/** @type {?} */ ((childDef.provider)).token);
12902 }
12903 i += childDef.childCount;
12904 }
12905 }
12906 return tokens;
12907 },
12908 enumerable: true,
12909 configurable: true
12910 });
12911 Object.defineProperty(DebugContext_.prototype, "references", {
12912 /**
12913 * @return {?}
12914 */
12915 get: function () {
12916 var /** @type {?} */ references = {};
12917 if (this.elDef) {
12918 collectReferences(this.elView, this.elDef, references);
12919 for (var /** @type {?} */ i = this.elDef.index + 1; i <= this.elDef.index + this.elDef.childCount; i++) {
12920 var /** @type {?} */ childDef = this.elView.def.nodes[i];
12921 if (childDef.flags & 10112 /* CatProvider */) {
12922 collectReferences(this.elView, childDef, references);
12923 }
12924 i += childDef.childCount;
12925 }
12926 }
12927 return references;
12928 },
12929 enumerable: true,
12930 configurable: true
12931 });
12932 Object.defineProperty(DebugContext_.prototype, "componentRenderElement", {
12933 /**
12934 * @return {?}
12935 */
12936 get: function () {
12937 var /** @type {?} */ elData = findHostElement(this.elOrCompView);
12938 return elData ? elData.renderElement : undefined;
12939 },
12940 enumerable: true,
12941 configurable: true
12942 });
12943 Object.defineProperty(DebugContext_.prototype, "renderNode", {
12944 /**
12945 * @return {?}
12946 */
12947 get: function () {
12948 return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) :
12949 renderNode(this.elView, this.elDef);
12950 },
12951 enumerable: true,
12952 configurable: true
12953 });
12954 /**
12955 * @param {?} console
12956 * @param {...?} values
12957 * @return {?}
12958 */
12959 DebugContext_.prototype.logError = function (console) {
12960 var values = [];
12961 for (var _i = 1; _i < arguments.length; _i++) {
12962 values[_i - 1] = arguments[_i];
12963 }
12964 var /** @type {?} */ logViewDef;
12965 var /** @type {?} */ logNodeIndex;
12966 if (this.nodeDef.flags & 2 /* TypeText */) {
12967 logViewDef = this.view.def;
12968 logNodeIndex = this.nodeDef.index;
12969 }
12970 else {
12971 logViewDef = this.elView.def;
12972 logNodeIndex = this.elDef.index;
12973 }
12974 // Note: we only generate a log function for text and element nodes
12975 // to make the generated code as small as possible.
12976 var /** @type {?} */ renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
12977 var /** @type {?} */ currRenderNodeIndex = -1;
12978 var /** @type {?} */ nodeLogger = function () {
12979 currRenderNodeIndex++;
12980 if (currRenderNodeIndex === renderNodeIndex) {
12981 return (_a = console.error).bind.apply(_a, [console].concat(values));
12982 }
12983 else {
12984 return NOOP;
12985 }
12986 var _a;
12987 }; /** @type {?} */
12988 ((logViewDef.factory))(nodeLogger);
12989 if (currRenderNodeIndex < renderNodeIndex) {
12990 console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
12991 console.error.apply(console, values);
12992 }
12993 };
12994 return DebugContext_;
12995}());
12996/**
12997 * @param {?} viewDef
12998 * @param {?} nodeIndex
12999 * @return {?}
13000 */
13001function getRenderNodeIndex(viewDef$$1, nodeIndex) {
13002 var /** @type {?} */ renderNodeIndex = -1;
13003 for (var /** @type {?} */ i = 0; i <= nodeIndex; i++) {
13004 var /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
13005 if (nodeDef.flags & 3 /* CatRenderNode */) {
13006 renderNodeIndex++;
13007 }
13008 }
13009 return renderNodeIndex;
13010}
13011/**
13012 * @param {?} view
13013 * @return {?}
13014 */
13015function findHostElement(view) {
13016 while (view && !isComponentView(view)) {
13017 view = ((view.parent));
13018 }
13019 if (view.parent) {
13020 return asElementData(view.parent, /** @type {?} */ ((viewParentEl(view))).index);
13021 }
13022 return null;
13023}
13024/**
13025 * @param {?} view
13026 * @param {?} nodeDef
13027 * @param {?} references
13028 * @return {?}
13029 */
13030function collectReferences(view, nodeDef, references) {
13031 for (var /** @type {?} */ refName in nodeDef.references) {
13032 references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
13033 }
13034}
13035/**
13036 * @param {?} action
13037 * @param {?} fn
13038 * @param {?} self
13039 * @param {?} args
13040 * @return {?}
13041 */
13042function callWithDebugContext(action, fn, self, args) {
13043 var /** @type {?} */ oldAction = _currentAction;
13044 var /** @type {?} */ oldView = _currentView;
13045 var /** @type {?} */ oldNodeIndex = _currentNodeIndex;
13046 try {
13047 _currentAction = action;
13048 var /** @type {?} */ result = fn.apply(self, args);
13049 _currentView = oldView;
13050 _currentNodeIndex = oldNodeIndex;
13051 _currentAction = oldAction;
13052 return result;
13053 }
13054 catch (e) {
13055 if (isViewDebugError(e) || !_currentView) {
13056 throw e;
13057 }
13058 throw viewWrappedDebugError(e, /** @type {?} */ ((getCurrentDebugContext())));
13059 }
13060}
13061/**
13062 * @return {?}
13063 */
13064function getCurrentDebugContext() {
13065 return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
13066}
13067var DebugRendererFactory2 = (function () {
13068 /**
13069 * @param {?} delegate
13070 */
13071 function DebugRendererFactory2(delegate) {
13072 this.delegate = delegate;
13073 }
13074 /**
13075 * @param {?} element
13076 * @param {?} renderData
13077 * @return {?}
13078 */
13079 DebugRendererFactory2.prototype.createRenderer = function (element, renderData) {
13080 return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
13081 };
13082 return DebugRendererFactory2;
13083}());
13084var DebugRenderer2 = (function () {
13085 /**
13086 * @param {?} delegate
13087 */
13088 function DebugRenderer2(delegate) {
13089 this.delegate = delegate;
13090 }
13091 Object.defineProperty(DebugRenderer2.prototype, "data", {
13092 /**
13093 * @return {?}
13094 */
13095 get: function () { return this.delegate.data; },
13096 enumerable: true,
13097 configurable: true
13098 });
13099 /**
13100 * @param {?} node
13101 * @return {?}
13102 */
13103 DebugRenderer2.prototype.destroyNode = function (node) {
13104 removeDebugNodeFromIndex(/** @type {?} */ ((getDebugNode(node))));
13105 if (this.delegate.destroyNode) {
13106 this.delegate.destroyNode(node);
13107 }
13108 };
13109 /**
13110 * @return {?}
13111 */
13112 DebugRenderer2.prototype.destroy = function () { this.delegate.destroy(); };
13113 /**
13114 * @param {?} name
13115 * @param {?=} namespace
13116 * @return {?}
13117 */
13118 DebugRenderer2.prototype.createElement = function (name, namespace) {
13119 var /** @type {?} */ el = this.delegate.createElement(name, namespace);
13120 var /** @type {?} */ debugCtx = getCurrentDebugContext();
13121 if (debugCtx) {
13122 var /** @type {?} */ debugEl = new DebugElement(el, null, debugCtx);
13123 debugEl.name = name;
13124 indexDebugNode(debugEl);
13125 }
13126 return el;
13127 };
13128 /**
13129 * @param {?} value
13130 * @return {?}
13131 */
13132 DebugRenderer2.prototype.createComment = function (value) {
13133 var /** @type {?} */ comment = this.delegate.createComment(value);
13134 var /** @type {?} */ debugCtx = getCurrentDebugContext();
13135 if (debugCtx) {
13136 indexDebugNode(new DebugNode(comment, null, debugCtx));
13137 }
13138 return comment;
13139 };
13140 /**
13141 * @param {?} value
13142 * @return {?}
13143 */
13144 DebugRenderer2.prototype.createText = function (value) {
13145 var /** @type {?} */ text = this.delegate.createText(value);
13146 var /** @type {?} */ debugCtx = getCurrentDebugContext();
13147 if (debugCtx) {
13148 indexDebugNode(new DebugNode(text, null, debugCtx));
13149 }
13150 return text;
13151 };
13152 /**
13153 * @param {?} parent
13154 * @param {?} newChild
13155 * @return {?}
13156 */
13157 DebugRenderer2.prototype.appendChild = function (parent, newChild) {
13158 var /** @type {?} */ debugEl = getDebugNode(parent);
13159 var /** @type {?} */ debugChildEl = getDebugNode(newChild);
13160 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13161 debugEl.addChild(debugChildEl);
13162 }
13163 this.delegate.appendChild(parent, newChild);
13164 };
13165 /**
13166 * @param {?} parent
13167 * @param {?} newChild
13168 * @param {?} refChild
13169 * @return {?}
13170 */
13171 DebugRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
13172 var /** @type {?} */ debugEl = getDebugNode(parent);
13173 var /** @type {?} */ debugChildEl = getDebugNode(newChild);
13174 var /** @type {?} */ debugRefEl = ((getDebugNode(refChild)));
13175 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13176 debugEl.insertBefore(debugRefEl, debugChildEl);
13177 }
13178 this.delegate.insertBefore(parent, newChild, refChild);
13179 };
13180 /**
13181 * @param {?} parent
13182 * @param {?} oldChild
13183 * @return {?}
13184 */
13185 DebugRenderer2.prototype.removeChild = function (parent, oldChild) {
13186 var /** @type {?} */ debugEl = getDebugNode(parent);
13187 var /** @type {?} */ debugChildEl = getDebugNode(oldChild);
13188 if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13189 debugEl.removeChild(debugChildEl);
13190 }
13191 this.delegate.removeChild(parent, oldChild);
13192 };
13193 /**
13194 * @param {?} selectorOrNode
13195 * @return {?}
13196 */
13197 DebugRenderer2.prototype.selectRootElement = function (selectorOrNode) {
13198 var /** @type {?} */ el = this.delegate.selectRootElement(selectorOrNode);
13199 var /** @type {?} */ debugCtx = getCurrentDebugContext();
13200 if (debugCtx) {
13201 indexDebugNode(new DebugElement(el, null, debugCtx));
13202 }
13203 return el;
13204 };
13205 /**
13206 * @param {?} el
13207 * @param {?} name
13208 * @param {?} value
13209 * @param {?=} namespace
13210 * @return {?}
13211 */
13212 DebugRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
13213 var /** @type {?} */ debugEl = getDebugNode(el);
13214 if (debugEl && debugEl instanceof DebugElement) {
13215 var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
13216 debugEl.attributes[fullName] = value;
13217 }
13218 this.delegate.setAttribute(el, name, value, namespace);
13219 };
13220 /**
13221 * @param {?} el
13222 * @param {?} name
13223 * @param {?=} namespace
13224 * @return {?}
13225 */
13226 DebugRenderer2.prototype.removeAttribute = function (el, name, namespace) {
13227 var /** @type {?} */ debugEl = getDebugNode(el);
13228 if (debugEl && debugEl instanceof DebugElement) {
13229 var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
13230 debugEl.attributes[fullName] = null;
13231 }
13232 this.delegate.removeAttribute(el, name, namespace);
13233 };
13234 /**
13235 * @param {?} el
13236 * @param {?} name
13237 * @return {?}
13238 */
13239 DebugRenderer2.prototype.addClass = function (el, name) {
13240 var /** @type {?} */ debugEl = getDebugNode(el);
13241 if (debugEl && debugEl instanceof DebugElement) {
13242 debugEl.classes[name] = true;
13243 }
13244 this.delegate.addClass(el, name);
13245 };
13246 /**
13247 * @param {?} el
13248 * @param {?} name
13249 * @return {?}
13250 */
13251 DebugRenderer2.prototype.removeClass = function (el, name) {
13252 var /** @type {?} */ debugEl = getDebugNode(el);
13253 if (debugEl && debugEl instanceof DebugElement) {
13254 debugEl.classes[name] = false;
13255 }
13256 this.delegate.removeClass(el, name);
13257 };
13258 /**
13259 * @param {?} el
13260 * @param {?} style
13261 * @param {?} value
13262 * @param {?} flags
13263 * @return {?}
13264 */
13265 DebugRenderer2.prototype.setStyle = function (el, style, value, flags) {
13266 var /** @type {?} */ debugEl = getDebugNode(el);
13267 if (debugEl && debugEl instanceof DebugElement) {
13268 debugEl.styles[style] = value;
13269 }
13270 this.delegate.setStyle(el, style, value, flags);
13271 };
13272 /**
13273 * @param {?} el
13274 * @param {?} style
13275 * @param {?} flags
13276 * @return {?}
13277 */
13278 DebugRenderer2.prototype.removeStyle = function (el, style, flags) {
13279 var /** @type {?} */ debugEl = getDebugNode(el);
13280 if (debugEl && debugEl instanceof DebugElement) {
13281 debugEl.styles[style] = null;
13282 }
13283 this.delegate.removeStyle(el, style, flags);
13284 };
13285 /**
13286 * @param {?} el
13287 * @param {?} name
13288 * @param {?} value
13289 * @return {?}
13290 */
13291 DebugRenderer2.prototype.setProperty = function (el, name, value) {
13292 var /** @type {?} */ debugEl = getDebugNode(el);
13293 if (debugEl && debugEl instanceof DebugElement) {
13294 debugEl.properties[name] = value;
13295 }
13296 this.delegate.setProperty(el, name, value);
13297 };
13298 /**
13299 * @param {?} target
13300 * @param {?} eventName
13301 * @param {?} callback
13302 * @return {?}
13303 */
13304 DebugRenderer2.prototype.listen = function (target, eventName, callback) {
13305 if (typeof target !== 'string') {
13306 var /** @type {?} */ debugEl = getDebugNode(target);
13307 if (debugEl) {
13308 debugEl.listeners.push(new EventListener(eventName, callback));
13309 }
13310 }
13311 return this.delegate.listen(target, eventName, callback);
13312 };
13313 /**
13314 * @param {?} node
13315 * @return {?}
13316 */
13317 DebugRenderer2.prototype.parentNode = function (node) { return this.delegate.parentNode(node); };
13318 /**
13319 * @param {?} node
13320 * @return {?}
13321 */
13322 DebugRenderer2.prototype.nextSibling = function (node) { return this.delegate.nextSibling(node); };
13323 /**
13324 * @param {?} node
13325 * @param {?} value
13326 * @return {?}
13327 */
13328 DebugRenderer2.prototype.setValue = function (node, value) { return this.delegate.setValue(node, value); };
13329 return DebugRenderer2;
13330}());
13331/**
13332 * @license
13333 * Copyright Google Inc. All Rights Reserved.
13334 *
13335 * Use of this source code is governed by an MIT-style license that can be
13336 * found in the LICENSE file at https://angular.io/license
13337 */
13338/**
13339 * @license
13340 * Copyright Google Inc. All Rights Reserved.
13341 *
13342 * Use of this source code is governed by an MIT-style license that can be
13343 * found in the LICENSE file at https://angular.io/license
13344 */
13345/**
13346 * @return {?}
13347 */
13348function _iterableDiffersFactory() {
13349 return defaultIterableDiffers;
13350}
13351/**
13352 * @return {?}
13353 */
13354function _keyValueDiffersFactory() {
13355 return defaultKeyValueDiffers;
13356}
13357/**
13358 * @param {?=} locale
13359 * @return {?}
13360 */
13361function _localeFactory(locale) {
13362 return locale || 'en-US';
13363}
13364/**
13365 * @return {?}
13366 */
13367function _initViewEngine() {
13368 initServicesIfNeeded();
13369}
13370/**
13371 * This module includes the providers of \@angular/core that are needed
13372 * to bootstrap components via `ApplicationRef`.
13373 *
13374 * \@experimental
13375 */
13376var ApplicationModule = (function () {
13377 /**
13378 * @param {?} appRef
13379 */
13380 function ApplicationModule(appRef) {
13381 }
13382 return ApplicationModule;
13383}());
13384ApplicationModule.decorators = [
13385 { type: NgModule, args: [{
13386 providers: [
13387 ApplicationRef_,
13388 { provide: ApplicationRef, useExisting: ApplicationRef_ },
13389 ApplicationInitStatus,
13390 Compiler,
13391 APP_ID_RANDOM_PROVIDER,
13392 { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
13393 { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
13394 {
13395 provide: LOCALE_ID,
13396 useFactory: _localeFactory,
13397 deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
13398 },
13399 { provide: APP_INITIALIZER, useValue: _initViewEngine, multi: true },
13400 ]
13401 },] },
13402];
13403/**
13404 * @nocollapse
13405 */
13406ApplicationModule.ctorParameters = function () { return [
13407 { type: ApplicationRef, },
13408]; };
13409/**
13410 * @license
13411 * Copyright Google Inc. All Rights Reserved.
13412 *
13413 * Use of this source code is governed by an MIT-style license that can be
13414 * found in the LICENSE file at https://angular.io/license
13415 */
13416var LifecycleHooks = {};
13417LifecycleHooks.OnInit = 0;
13418LifecycleHooks.OnDestroy = 1;
13419LifecycleHooks.DoCheck = 2;
13420LifecycleHooks.OnChanges = 3;
13421LifecycleHooks.AfterContentInit = 4;
13422LifecycleHooks.AfterContentChecked = 5;
13423LifecycleHooks.AfterViewInit = 6;
13424LifecycleHooks.AfterViewChecked = 7;
13425LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
13426LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
13427LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
13428LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
13429LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
13430LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
13431LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
13432LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
13433var LIFECYCLE_HOOKS_VALUES = [
13434 LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
13435 LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
13436 LifecycleHooks.AfterViewChecked
13437];
13438/**
13439 * @license
13440 * Copyright Google Inc. All Rights Reserved.
13441 *
13442 * Use of this source code is governed by an MIT-style license that can be
13443 * found in the LICENSE file at https://angular.io/license
13444 */
13445/**
13446 * @license
13447 * Copyright Google Inc. All Rights Reserved.
13448 *
13449 * Use of this source code is governed by an MIT-style license that can be
13450 * found in the LICENSE file at https://angular.io/license
13451 */
13452/**
13453 * \@experimental Animation support is experimental.
13454 */
13455/**
13456 * `trigger` is an animation-specific function that is designed to be used inside of Angular's
13457 * animation DSL language. If this information is new, please navigate to the {\@link
13458 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13459 * how animations in Angular are used.
13460 *
13461 * `trigger` Creates an animation trigger which will a list of {\@link state state} and {\@link
13462 * transition transition} entries that will be evaluated when the expression bound to the trigger
13463 * changes.
13464 *
13465 * Triggers are registered within the component annotation data under the {\@link
13466 * Component#animations-anchor animations section}. An animation trigger can be placed on an element
13467 * within a template by referencing the name of the trigger followed by the expression value that the
13468 * trigger is bound to (in the form of `[\@triggerName]="expression"`.
13469 *
13470 * ### Usage
13471 *
13472 * `trigger` will create an animation trigger reference based on the provided `name` value. The
13473 * provided `animation` value is expected to be an array consisting of {\@link state state} and {\@link
13474 * transition transition} declarations.
13475 *
13476 * ```typescript
13477 * \@Component({
13478 * selector: 'my-component',
13479 * templateUrl: 'my-component-tpl.html',
13480 * animations: [
13481 * trigger("myAnimationTrigger", [
13482 * state(...),
13483 * state(...),
13484 * transition(...),
13485 * transition(...)
13486 * ])
13487 * ]
13488 * })
13489 * class MyComponent {
13490 * myStatusExp = "something";
13491 * }
13492 * ```
13493 *
13494 * The template associated with this component will make use of the `myAnimationTrigger` animation
13495 * trigger by binding to an element within its template code.
13496 *
13497 * ```html
13498 * <!-- somewhere inside of my-component-tpl.html -->
13499 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
13500 * tools/gulp-tasks/validate-commit-message.js ```
13501 *
13502 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13503 *
13504 * \@experimental Animation support is experimental.
13505 * @param {?} name
13506 * @param {?} definitions
13507 * @return {?}
13508 */
13509function trigger$1(name, definitions) {
13510 return { name: name, definitions: definitions };
13511}
13512/**
13513 * `animate` is an animation-specific function that is designed to be used inside of Angular's
13514 * animation DSL language. If this information is new, please navigate to the {\@link
13515 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13516 * how animations in Angular are used.
13517 *
13518 * `animate` specifies an animation step that will apply the provided `styles` data for a given
13519 * amount of time based on the provided `timing` expression value. Calls to `animate` are expected
13520 * to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
13521 * transition transition}.
13522 *
13523 * ### Usage
13524 *
13525 * The `animate` function accepts two input parameters: `timing` and `styles`:
13526 *
13527 * - `timing` is a string based value that can be a combination of a duration with optional delay
13528 * and easing values. The format for the expression breaks down to `duration delay easing`
13529 * (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
13530 * delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
13531 * `duration` value in millisecond form.
13532 * - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
13533 * keyframes keyframes}. If left empty then the styles from the destination state will be collected
13534 * and used (this is useful when describing an animation step that will complete an animation by
13535 * {\@link transition#the-final-animate-call animating to the final state}).
13536 *
13537 * ```typescript
13538 * // various functions for specifying timing data
13539 * animate(500, style(...))
13540 * animate("1s", style(...))
13541 * animate("100ms 0.5s", style(...))
13542 * animate("5s ease", style(...))
13543 * animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
13544 *
13545 * // either style() of keyframes() can be used
13546 * animate(500, style({ background: "red" }))
13547 * animate(500, keyframes([
13548 * style({ background: "blue" })),
13549 * style({ background: "red" }))
13550 * ])
13551 * ```
13552 *
13553 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13554 *
13555 * \@experimental Animation support is experimental.
13556 * @param {?} timings
13557 * @param {?=} styles
13558 * @return {?}
13559 */
13560function animate$1(timings, styles) {
13561 if (styles === void 0) { styles = null; }
13562 return { type: 4 /* Animate */, styles: styles, timings: timings };
13563}
13564/**
13565 * `group` is an animation-specific function that is designed to be used inside of Angular's
13566 * animation DSL language. If this information is new, please navigate to the {\@link
13567 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13568 * how animations in Angular are used.
13569 *
13570 * `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
13571 * useful when a series of styles must be animated/closed off at different statrting/ending times.
13572 *
13573 * The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
13574 * transition} and it will only continue to the next instruction once all of the inner animation
13575 * steps have completed.
13576 *
13577 * ### Usage
13578 *
13579 * The `steps` data that is passed into the `group` animation function can either consist of {\@link
13580 * style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
13581 * within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
13582 * animate#usage animate() with a delay value} to offset styles to be applied at a later time).
13583 *
13584 * ```typescript
13585 * group([
13586 * animate("1s", { background: "black" }))
13587 * animate("2s", { color: "white" }))
13588 * ])
13589 * ```
13590 *
13591 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13592 *
13593 * \@experimental Animation support is experimental.
13594 * @param {?} steps
13595 * @return {?}
13596 */
13597function group$1(steps) {
13598 return { type: 3 /* Group */, steps: steps };
13599}
13600/**
13601 * `sequence` is an animation-specific function that is designed to be used inside of Angular's
13602 * animation DSL language. If this information is new, please navigate to the {\@link
13603 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13604 * how animations in Angular are used.
13605 *
13606 * `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
13607 * default when an array is passed as animation data into {\@link transition transition}.)
13608 *
13609 * The `sequence` function can either be used within a {\@link group group} or a {\@link transition
13610 * transition} and it will only continue to the next instruction once each of the inner animation
13611 * steps have completed.
13612 *
13613 * To perform animation styling in parallel with other animation steps then have a look at the
13614 * {\@link group group} animation function.
13615 *
13616 * ### Usage
13617 *
13618 * The `steps` data that is passed into the `sequence` animation function can either consist of
13619 * {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
13620 * provided styling data immediately while a call to `animate()` will apply its styling data over a
13621 * given time depending on its timing data.
13622 *
13623 * ```typescript
13624 * sequence([
13625 * style({ opacity: 0 })),
13626 * animate("1s", { opacity: 1 }))
13627 * ])
13628 * ```
13629 *
13630 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13631 *
13632 * \@experimental Animation support is experimental.
13633 * @param {?} steps
13634 * @return {?}
13635 */
13636function sequence$1(steps) {
13637 return { type: 2 /* Sequence */, steps: steps };
13638}
13639/**
13640 * `style` is an animation-specific function that is designed to be used inside of Angular's
13641 * animation DSL language. If this information is new, please navigate to the {\@link
13642 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13643 * how animations in Angular are used.
13644 *
13645 * `style` declares a key/value object containing CSS properties/styles that can then be used for
13646 * {\@link state animation states}, within an {\@link sequence animation sequence}, or as styling data
13647 * for both {\@link animate animate} and {\@link keyframes keyframes}.
13648 *
13649 * ### Usage
13650 *
13651 * `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
13652 * to be defined.
13653 *
13654 * ```typescript
13655 * // string values are used for css properties
13656 * style({ background: "red", color: "blue" })
13657 *
13658 * // numerical (pixel) values are also supported
13659 * style({ width: 100, height: 0 })
13660 * ```
13661 *
13662 * #### Auto-styles (using `*`)
13663 *
13664 * When an asterix (`*`) character is used as a value then it will be detected from the element
13665 * being animated and applied as animation data when the animation starts.
13666 *
13667 * This feature proves useful for a state depending on layout and/or environment factors; in such
13668 * cases the styles are calculated just before the animation starts.
13669 *
13670 * ```typescript
13671 * // the steps below will animate from 0 to the
13672 * // actual height of the element
13673 * style({ height: 0 }),
13674 * animate("1s", style({ height: "*" }))
13675 * ```
13676 *
13677 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13678 *
13679 * \@experimental Animation support is experimental.
13680 * @param {?} tokens
13681 * @return {?}
13682 */
13683function style$1(tokens) {
13684 return { type: 6 /* Style */, styles: tokens };
13685}
13686/**
13687 * `state` is an animation-specific function that is designed to be used inside of Angular's
13688 * animation DSL language. If this information is new, please navigate to the {\@link
13689 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13690 * how animations in Angular are used.
13691 *
13692 * `state` declares an animation state within the given trigger. When a state is active within a
13693 * component then its associated styles will persist on the element that the trigger is attached to
13694 * (even when the animation ends).
13695 *
13696 * To animate between states, have a look at the animation {\@link transition transition} DSL
13697 * function. To register states to an animation trigger please have a look at the {\@link trigger
13698 * trigger} function.
13699 *
13700 * #### The `void` state
13701 *
13702 * The `void` state value is a reserved word that angular uses to determine when the element is not
13703 * apart of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
13704 * associated element is void).
13705 *
13706 * #### The `*` (default) state
13707 *
13708 * The `*` state (when styled) is a fallback state that will be used if the state that is being
13709 * animated is not declared within the trigger.
13710 *
13711 * ### Usage
13712 *
13713 * `state` will declare an animation state with its associated styles
13714 * within the given trigger.
13715 *
13716 * - `stateNameExpr` can be one or more state names separated by commas.
13717 * - `styles` refers to the {\@link style styling data} that will be persisted on the element once
13718 * the state has been reached.
13719 *
13720 * ```typescript
13721 * // "void" is a reserved name for a state and is used to represent
13722 * // the state in which an element is detached from from the application.
13723 * state("void", style({ height: 0 }))
13724 *
13725 * // user-defined states
13726 * state("closed", style({ height: 0 }))
13727 * state("open, visible", style({ height: "*" }))
13728 * ```
13729 *
13730 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13731 *
13732 * \@experimental Animation support is experimental.
13733 * @param {?} name
13734 * @param {?} styles
13735 * @return {?}
13736 */
13737function state$1(name, styles) {
13738 return { type: 0 /* State */, name: name, styles: styles };
13739}
13740/**
13741 * `keyframes` is an animation-specific function that is designed to be used inside of Angular's
13742 * animation DSL language. If this information is new, please navigate to the {\@link
13743 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13744 * how animations in Angular are used.
13745 *
13746 * `keyframes` specifies a collection of {\@link style style} entries each optionally characterized
13747 * by an `offset` value.
13748 *
13749 * ### Usage
13750 *
13751 * The `keyframes` animation function is designed to be used alongside the {\@link animate animate}
13752 * animation function. Instead of applying animations from where they are currently to their
13753 * destination, keyframes can describe how each style entry is applied and at what point within the
13754 * animation arc (much like CSS Keyframe Animations do).
13755 *
13756 * For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at what
13757 * percentage of the animate time the styles will be applied.
13758 *
13759 * ```typescript
13760 * // the provided offset values describe when each backgroundColor value is applied.
13761 * animate("5s", keyframes([
13762 * style({ backgroundColor: "red", offset: 0 }),
13763 * style({ backgroundColor: "blue", offset: 0.2 }),
13764 * style({ backgroundColor: "orange", offset: 0.3 }),
13765 * style({ backgroundColor: "black", offset: 1 })
13766 * ]))
13767 * ```
13768 *
13769 * Alternatively, if there are no `offset` values used within the style entries then the offsets
13770 * will be calculated automatically.
13771 *
13772 * ```typescript
13773 * animate("5s", keyframes([
13774 * style({ backgroundColor: "red" }) // offset = 0
13775 * style({ backgroundColor: "blue" }) // offset = 0.33
13776 * style({ backgroundColor: "orange" }) // offset = 0.66
13777 * style({ backgroundColor: "black" }) // offset = 1
13778 * ]))
13779 * ```
13780 *
13781 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13782 *
13783 * \@experimental Animation support is experimental.
13784 * @param {?} steps
13785 * @return {?}
13786 */
13787function keyframes$1(steps) {
13788 return { type: 5 /* KeyframeSequence */, steps: steps };
13789}
13790/**
13791 * `transition` is an animation-specific function that is designed to be used inside of Angular's
13792 * animation DSL language. If this information is new, please navigate to the {\@link
13793 * Component#animations-anchor component animations metadata page} to gain a better understanding of
13794 * how animations in Angular are used.
13795 *
13796 * `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
13797 * provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
13798 * state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
13799 * and/or ending state).
13800 *
13801 * A function can also be provided as the `stateChangeExpr` argument for a transition and this
13802 * function will be executed each time a state change occurs. If the value returned within the
13803 * function is true then the associated animation will be run.
13804 *
13805 * Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
13806 * to animate to a state value and persist its styles then one or more {\@link state animation
13807 * states} is expected to be defined.
13808 *
13809 * ### Usage
13810 *
13811 * An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
13812 * what the previous state is and what the current state has become. In other words, if a transition
13813 * is defined that matches the old/current state criteria then the associated animation will be
13814 * triggered.
13815 *
13816 * ```typescript
13817 * // all transition/state changes are defined within an animation trigger
13818 * trigger("myAnimationTrigger", [
13819 * // if a state is defined then its styles will be persisted when the
13820 * // animation has fully completed itself
13821 * state("on", style({ background: "green" })),
13822 * state("off", style({ background: "grey" })),
13823 *
13824 * // a transition animation that will be kicked off when the state value
13825 * // bound to "myAnimationTrigger" changes from "on" to "off"
13826 * transition("on => off", animate(500)),
13827 *
13828 * // it is also possible to do run the same animation for both directions
13829 * transition("on <=> off", animate(500)),
13830 *
13831 * // or to define multiple states pairs separated by commas
13832 * transition("on => off, off => void", animate(500)),
13833 *
13834 * // this is a catch-all state change for when an element is inserted into
13835 * // the page and the destination state is unknown
13836 * transition("void => *", [
13837 * style({ opacity: 0 }),
13838 * animate(500)
13839 * ]),
13840 *
13841 * // this will capture a state change between any states
13842 * transition("* => *", animate("1s 0s")),
13843 *
13844 * // you can also go full out and include a function
13845 * transition((fromState, toState) => {
13846 * // when `true` then it will allow the animation below to be invoked
13847 * return fromState == "off" && toState == "on";
13848 * }, animate("1s 0s"))
13849 * ])
13850 * ```
13851 *
13852 * The template associated with this component will make use of the `myAnimationTrigger` animation
13853 * trigger by binding to an element within its template code.
13854 *
13855 * ```html
13856 * <!-- somewhere inside of my-component-tpl.html -->
13857 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
13858 * ```
13859 *
13860 * #### The final `animate` call
13861 *
13862 * If the final step within the transition steps is a call to `animate()` that **only** uses a
13863 * timing value with **no style data** then it will be automatically used as the final animation arc
13864 * for the element to animate itself to the final state. This involves an automatic mix of
13865 * adding/removing CSS styles so that the element will be in the exact state it should be for the
13866 * applied state to be presented correctly.
13867 *
13868 * ```
13869 * // start off by hiding the element, but make sure that it animates properly to whatever state
13870 * // is currently active for "myAnimationTrigger"
13871 * transition("void => *", [
13872 * style({ opacity: 0 }),
13873 * animate(500)
13874 * ])
13875 * ```
13876 *
13877 * ### Transition Aliases (`:enter` and `:leave`)
13878 *
13879 * Given that enter (insertion) and leave (removal) animations are so common, the `transition`
13880 * function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
13881 * => void` state changes.
13882 *
13883 * ```
13884 * transition(":enter", [
13885 * style({ opacity: 0 }),
13886 * animate(500, style({ opacity: 1 }))
13887 * ])
13888 * transition(":leave", [
13889 * animate(500, style({ opacity: 0 }))
13890 * ])
13891 * ```
13892 *
13893 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
13894 *
13895 * \@experimental Animation support is experimental.
13896 * @param {?} stateChangeExpr
13897 * @param {?} steps
13898 * @return {?}
13899 */
13900function transition$1(stateChangeExpr, steps) {
13901 return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps };
13902}
13903/**
13904 * @license
13905 * Copyright Google Inc. All Rights Reserved.
13906 *
13907 * Use of this source code is governed by an MIT-style license that can be
13908 * found in the LICENSE file at https://angular.io/license
13909 */
13910/**
13911 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13912 */
13913var AUTO_STYLE$$1 = '*';
13914/**
13915 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13916 * @param {?} name
13917 * @param {?} definitions
13918 * @return {?}
13919 */
13920function trigger$$1(name, definitions) {
13921 return trigger$1(name, definitions);
13922}
13923/**
13924 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13925 * @param {?} timings
13926 * @param {?=} styles
13927 * @return {?}
13928 */
13929function animate$$1(timings, styles) {
13930 return animate$1(timings, styles);
13931}
13932/**
13933 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13934 * @param {?} steps
13935 * @return {?}
13936 */
13937function group$$1(steps) {
13938 return group$1(steps);
13939}
13940/**
13941 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13942 * @param {?} steps
13943 * @return {?}
13944 */
13945function sequence$$1(steps) {
13946 return sequence$1(steps);
13947}
13948/**
13949 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13950 * @param {?} tokens
13951 * @return {?}
13952 */
13953function style$$1(tokens) {
13954 return style$1(tokens);
13955}
13956/**
13957 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13958 * @param {?} name
13959 * @param {?} styles
13960 * @return {?}
13961 */
13962function state$$1(name, styles) {
13963 return state$1(name, styles);
13964}
13965/**
13966 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13967 * @param {?} steps
13968 * @return {?}
13969 */
13970function keyframes$$1(steps) {
13971 return keyframes$1(steps);
13972}
13973/**
13974 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
13975 * @param {?} stateChangeExpr
13976 * @param {?} steps
13977 * @return {?}
13978 */
13979function transition$$1(stateChangeExpr, steps) {
13980 return transition$1(stateChangeExpr, steps);
13981}
13982
13983exports.Class = Class;
13984exports.createPlatform = createPlatform;
13985exports.assertPlatform = assertPlatform;
13986exports.destroyPlatform = destroyPlatform;
13987exports.getPlatform = getPlatform;
13988exports.PlatformRef = PlatformRef;
13989exports.ApplicationRef = ApplicationRef;
13990exports.enableProdMode = enableProdMode;
13991exports.isDevMode = isDevMode;
13992exports.createPlatformFactory = createPlatformFactory;
13993exports.NgProbeToken = NgProbeToken;
13994exports.APP_ID = APP_ID;
13995exports.PACKAGE_ROOT_URL = PACKAGE_ROOT_URL;
13996exports.PLATFORM_INITIALIZER = PLATFORM_INITIALIZER;
13997exports.PLATFORM_ID = PLATFORM_ID;
13998exports.APP_BOOTSTRAP_LISTENER = APP_BOOTSTRAP_LISTENER;
13999exports.APP_INITIALIZER = APP_INITIALIZER;
14000exports.ApplicationInitStatus = ApplicationInitStatus;
14001exports.DebugElement = DebugElement;
14002exports.DebugNode = DebugNode;
14003exports.asNativeElements = asNativeElements;
14004exports.getDebugNode = getDebugNode;
14005exports.Testability = Testability;
14006exports.TestabilityRegistry = TestabilityRegistry;
14007exports.setTestabilityGetter = setTestabilityGetter;
14008exports.TRANSLATIONS = TRANSLATIONS;
14009exports.TRANSLATIONS_FORMAT = TRANSLATIONS_FORMAT;
14010exports.LOCALE_ID = LOCALE_ID;
14011exports.MissingTranslationStrategy = MissingTranslationStrategy;
14012exports.ApplicationModule = ApplicationModule;
14013exports.wtfCreateScope = wtfCreateScope;
14014exports.wtfLeave = wtfLeave;
14015exports.wtfStartTimeRange = wtfStartTimeRange;
14016exports.wtfEndTimeRange = wtfEndTimeRange;
14017exports.Type = Type;
14018exports.EventEmitter = EventEmitter;
14019exports.ErrorHandler = ErrorHandler;
14020exports.Sanitizer = Sanitizer;
14021exports.SecurityContext = SecurityContext;
14022exports.ANALYZE_FOR_ENTRY_COMPONENTS = ANALYZE_FOR_ENTRY_COMPONENTS;
14023exports.Attribute = Attribute;
14024exports.ContentChild = ContentChild;
14025exports.ContentChildren = ContentChildren;
14026exports.Query = Query;
14027exports.ViewChild = ViewChild;
14028exports.ViewChildren = ViewChildren;
14029exports.Component = Component;
14030exports.Directive = Directive;
14031exports.HostBinding = HostBinding;
14032exports.HostListener = HostListener;
14033exports.Input = Input;
14034exports.Output = Output;
14035exports.Pipe = Pipe;
14036exports.CUSTOM_ELEMENTS_SCHEMA = CUSTOM_ELEMENTS_SCHEMA;
14037exports.NO_ERRORS_SCHEMA = NO_ERRORS_SCHEMA;
14038exports.NgModule = NgModule;
14039exports.ViewEncapsulation = ViewEncapsulation;
14040exports.Version = Version;
14041exports.VERSION = VERSION;
14042exports.forwardRef = forwardRef;
14043exports.resolveForwardRef = resolveForwardRef;
14044exports.Injector = Injector;
14045exports.ReflectiveInjector = ReflectiveInjector;
14046exports.ResolvedReflectiveFactory = ResolvedReflectiveFactory;
14047exports.ReflectiveKey = ReflectiveKey;
14048exports.InjectionToken = InjectionToken;
14049exports.OpaqueToken = OpaqueToken;
14050exports.Inject = Inject;
14051exports.Optional = Optional;
14052exports.Injectable = Injectable;
14053exports.Self = Self;
14054exports.SkipSelf = SkipSelf;
14055exports.Host = Host;
14056exports.NgZone = NgZone;
14057exports.RenderComponentType = RenderComponentType;
14058exports.Renderer = Renderer;
14059exports.Renderer2 = Renderer2;
14060exports.RendererFactory2 = RendererFactory2;
14061exports.RendererStyleFlags2 = RendererStyleFlags2;
14062exports.RootRenderer = RootRenderer;
14063exports.COMPILER_OPTIONS = COMPILER_OPTIONS;
14064exports.Compiler = Compiler;
14065exports.CompilerFactory = CompilerFactory;
14066exports.ModuleWithComponentFactories = ModuleWithComponentFactories;
14067exports.ComponentFactory = ComponentFactory;
14068exports.ComponentRef = ComponentRef;
14069exports.ComponentFactoryResolver = ComponentFactoryResolver;
14070exports.ElementRef = ElementRef;
14071exports.NgModuleFactory = NgModuleFactory;
14072exports.NgModuleRef = NgModuleRef;
14073exports.NgModuleFactoryLoader = NgModuleFactoryLoader;
14074exports.getModuleFactory = getModuleFactory;
14075exports.QueryList = QueryList;
14076exports.SystemJsNgModuleLoader = SystemJsNgModuleLoader;
14077exports.SystemJsNgModuleLoaderConfig = SystemJsNgModuleLoaderConfig;
14078exports.TemplateRef = TemplateRef;
14079exports.ViewContainerRef = ViewContainerRef;
14080exports.EmbeddedViewRef = EmbeddedViewRef;
14081exports.ViewRef = ViewRef;
14082exports.ChangeDetectionStrategy = ChangeDetectionStrategy;
14083exports.ChangeDetectorRef = ChangeDetectorRef;
14084exports.DefaultIterableDiffer = DefaultIterableDiffer;
14085exports.IterableDiffers = IterableDiffers;
14086exports.KeyValueDiffers = KeyValueDiffers;
14087exports.SimpleChange = SimpleChange;
14088exports.WrappedValue = WrappedValue;
14089exports.platformCore = platformCore;
14090exports.ɵALLOW_MULTIPLE_PLATFORMS = ALLOW_MULTIPLE_PLATFORMS;
14091exports.ɵAPP_ID_RANDOM_PROVIDER = APP_ID_RANDOM_PROVIDER;
14092exports.ɵValueUnwrapper = ValueUnwrapper;
14093exports.ɵdevModeEqual = devModeEqual;
14094exports.ɵisListLikeIterable = isListLikeIterable;
14095exports.ɵChangeDetectorStatus = ChangeDetectorStatus;
14096exports.ɵisDefaultChangeDetectionStrategy = isDefaultChangeDetectionStrategy;
14097exports.ɵConsole = Console;
14098exports.ɵERROR_COMPONENT_TYPE = ERROR_COMPONENT_TYPE;
14099exports.ɵComponentFactory = ComponentFactory;
14100exports.ɵCodegenComponentFactoryResolver = CodegenComponentFactoryResolver;
14101exports.ɵLIFECYCLE_HOOKS_VALUES = LIFECYCLE_HOOKS_VALUES;
14102exports.ɵLifecycleHooks = LifecycleHooks;
14103exports.ɵViewMetadata = ViewMetadata;
14104exports.ɵReflector = Reflector;
14105exports.ɵreflector = reflector;
14106exports.ɵReflectionCapabilities = ReflectionCapabilities;
14107exports.ɵReflectorReader = ReflectorReader;
14108exports.ɵRenderDebugInfo = RenderDebugInfo;
14109exports.ɵglobal = _global;
14110exports.ɵlooseIdentical = looseIdentical;
14111exports.ɵstringify = stringify;
14112exports.ɵmakeDecorator = makeDecorator;
14113exports.ɵisObservable = isObservable;
14114exports.ɵisPromise = isPromise;
14115exports.ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR;
14116exports.ɵNgModuleInjector = NgModuleInjector;
14117exports.ɵregisterModuleFactory = registerModuleFactory;
14118exports.ɵEMPTY_ARRAY = EMPTY_ARRAY;
14119exports.ɵEMPTY_MAP = EMPTY_MAP;
14120exports.ɵand = anchorDef;
14121exports.ɵccf = createComponentFactory;
14122exports.ɵcrt = createRendererType2;
14123exports.ɵdid = directiveDef;
14124exports.ɵeld = elementDef;
14125exports.ɵelementEventFullName = elementEventFullName;
14126exports.ɵgetComponentViewDefinitionFactory = getComponentViewDefinitionFactory;
14127exports.ɵinlineInterpolate = inlineInterpolate;
14128exports.ɵinterpolate = interpolate;
14129exports.ɵncd = ngContentDef;
14130exports.ɵnov = nodeValue;
14131exports.ɵpid = pipeDef;
14132exports.ɵprd = providerDef;
14133exports.ɵpad = pureArrayDef;
14134exports.ɵpod = pureObjectDef;
14135exports.ɵppd = purePipeDef;
14136exports.ɵqud = queryDef;
14137exports.ɵted = textDef;
14138exports.ɵunv = unwrapValue;
14139exports.ɵvid = viewDef;
14140exports.AUTO_STYLE = AUTO_STYLE$$1;
14141exports.trigger = trigger$$1;
14142exports.animate = animate$$1;
14143exports.group = group$$1;
14144exports.sequence = sequence$$1;
14145exports.style = style$$1;
14146exports.state = state$$1;
14147exports.keyframes = keyframes$$1;
14148exports.transition = transition$$1;
14149exports.ɵba = animate$1;
14150exports.ɵbb = group$1;
14151exports.ɵbf = keyframes$1;
14152exports.ɵbc = sequence$1;
14153exports.ɵbe = state$1;
14154exports.ɵbd = style$1;
14155exports.ɵbg = transition$1;
14156exports.ɵz = trigger$1;
14157exports.ɵo = _initViewEngine;
14158exports.ɵl = _iterableDiffersFactory;
14159exports.ɵm = _keyValueDiffersFactory;
14160exports.ɵn = _localeFactory;
14161exports.ɵf = ApplicationRef_;
14162exports.ɵg = _appIdRandomProviderFactory;
14163exports.ɵh = defaultIterableDiffers;
14164exports.ɵi = defaultKeyValueDiffers;
14165exports.ɵj = DefaultIterableDifferFactory;
14166exports.ɵk = DefaultKeyValueDifferFactory;
14167exports.ɵc = ReflectiveInjector_;
14168exports.ɵd = ReflectiveDependency;
14169exports.ɵe = resolveReflectiveProviders;
14170exports.ɵp = wtfEnabled;
14171exports.ɵr = createScope$1;
14172exports.ɵq = detectWTF;
14173exports.ɵu = endTimeRange;
14174exports.ɵs = leave;
14175exports.ɵt = startTimeRange;
14176exports.ɵa = makeParamDecorator;
14177exports.ɵb = makePropDecorator;
14178exports.ɵw = _def;
14179exports.ɵx = DebugContext;
14180
14181Object.defineProperty(exports, '__esModule', { value: true });
14182
14183})));
14184//# sourceMappingURL=core.umd.js.map