Project

General

Profile

1 49598 stefanos.g
import * as tslib_1 from "tslib";
2
/**
3
 * @license Angular v4.4.6
4
 * (c) 2010-2017 Google, Inc. https://angular.io/
5
 * License: MIT
6
 */
7
import { Observable } from 'rxjs/Observable';
8
import { merge } from 'rxjs/observable/merge';
9
import { share } from 'rxjs/operator/share';
10
import { Subject } from 'rxjs/Subject';
11
/**
12
 * Creates a token that can be used in a DI Provider.
13
 *
14
 * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
15
 *
16
 * ```typescript
17
 * var t = new OpaqueToken("value");
18
 *
19
 * var injector = Injector.resolveAndCreate([
20
 *   {provide: t, useValue: "bindingValue"}
21
 * ]);
22
 *
23
 * expect(injector.get(t)).toEqual("bindingValue");
24
 * ```
25
 *
26
 * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
27
 * caused by multiple providers using the same string as two different tokens.
28
 *
29
 * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
30
 * error messages.
31
 * @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>`
32
 * instead.
33
 */
34
var OpaqueToken = (function () {
35
    /**
36
     * @param {?} _desc
37
     */
38
    function OpaqueToken(_desc) {
39
        this._desc = _desc;
40
    }
41
    /**
42
     * @return {?}
43
     */
44
    OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
45
    return OpaqueToken;
46
}());
47
/**
48
 * Creates a token that can be used in a DI Provider.
49
 *
50
 * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
51
 * runtime representation) such as when injecting an interface, callable type, array or
52
 * parametrized type.
53
 *
54
 * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
55
 * the `Injector`. This provides additional level of type safety.
56
 *
57
 * ```
58
 * interface MyInterface {...}
59
 * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
60
 * // myInterface is inferred to be MyInterface.
61
 * ```
62
 *
63
 * ### Example
64
 *
65
 * {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
66
 *
67
 * \@stable
68
 */
69
var InjectionToken = (function (_super) {
70
    tslib_1.__extends(InjectionToken, _super);
71
    /**
72
     * @param {?} desc
73
     */
74
    function InjectionToken(desc) {
75
        return _super.call(this, desc) || this;
76
    }
77
    /**
78
     * @return {?}
79
     */
80
    InjectionToken.prototype.toString = function () { return "InjectionToken " + this._desc; };
81
    return InjectionToken;
82
}(OpaqueToken));
83
/**
84
 * @license
85
 * Copyright Google Inc. All Rights Reserved.
86
 *
87
 * Use of this source code is governed by an MIT-style license that can be
88
 * found in the LICENSE file at https://angular.io/license
89
 */
90
var __window = typeof window !== 'undefined' && window;
91
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
92
    self instanceof WorkerGlobalScope && self;
93
var __global = typeof global !== 'undefined' && global;
94
var _global = __window || __global || __self;
95
var _symbolIterator = null;
96
/**
97
 * @return {?}
98
 */
99
function getSymbolIterator() {
100
    if (!_symbolIterator) {
101
        var /** @type {?} */ Symbol = _global['Symbol'];
102
        if (Symbol && Symbol.iterator) {
103
            _symbolIterator = Symbol.iterator;
104
        }
105
        else {
106
            // es6-shim specific logic
107
            var /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
108
            for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
109
                var /** @type {?} */ key = keys[i];
110
                if (key !== 'entries' && key !== 'size' &&
111
                    ((Map)).prototype[key] === Map.prototype['entries']) {
112
                    _symbolIterator = key;
113
                }
114
            }
115
        }
116
    }
117
    return _symbolIterator;
118
}
119
/**
120
 * @param {?} fn
121
 * @return {?}
122
 */
123
function scheduleMicroTask(fn) {
124
    Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
125
}
126
/**
127
 * @param {?} a
128
 * @param {?} b
129
 * @return {?}
130
 */
131
function looseIdentical(a, b) {
132
    return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
133
}
134
/**
135
 * @param {?} token
136
 * @return {?}
137
 */
138
function stringify(token) {
139
    if (typeof token === 'string') {
140
        return token;
141
    }
142
    if (token == null) {
143
        return '' + token;
144
    }
145
    if (token.overriddenName) {
146
        return "" + token.overriddenName;
147
    }
148
    if (token.name) {
149
        return "" + token.name;
150
    }
151
    var /** @type {?} */ res = token.toString();
152
    if (res == null) {
153
        return '' + res;
154
    }
155
    var /** @type {?} */ newLineIndex = res.indexOf('\n');
156
    return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
157
}
158
/**
159
 * @license
160
 * Copyright Google Inc. All Rights Reserved.
161
 *
162
 * Use of this source code is governed by an MIT-style license that can be
163
 * found in the LICENSE file at https://angular.io/license
164
 */
165
var _nextClassId = 0;
166
var Reflect = _global['Reflect'];
167
/**
168
 * @param {?} annotation
169
 * @return {?}
170
 */
171
function extractAnnotation(annotation) {
172
    if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
173
        // it is a decorator, extract annotation
174
        annotation = annotation.annotation;
175
    }
176
    return annotation;
177
}
178
/**
179
 * @param {?} fnOrArray
180
 * @param {?} key
181
 * @return {?}
182
 */
183
function applyParams(fnOrArray, key) {
184
    if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
185
        fnOrArray === Number || fnOrArray === Array) {
186
        throw new Error("Can not use native " + stringify(fnOrArray) + " as constructor");
187
    }
188
    if (typeof fnOrArray === 'function') {
189
        return fnOrArray;
190
    }
191
    if (Array.isArray(fnOrArray)) {
192
        var /** @type {?} */ annotations = (fnOrArray);
193
        var /** @type {?} */ annoLength = annotations.length - 1;
194
        var /** @type {?} */ fn = fnOrArray[annoLength];
195
        if (typeof fn !== 'function') {
196
            throw new Error("Last position of Class method array must be Function in key " + key + " was '" + stringify(fn) + "'");
197
        }
198
        if (annoLength != fn.length) {
199
            throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + stringify(fn));
200
        }
201
        var /** @type {?} */ paramsAnnotations = [];
202
        for (var /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
203
            var /** @type {?} */ paramAnnotations = [];
204
            paramsAnnotations.push(paramAnnotations);
205
            var /** @type {?} */ annotation = annotations[i];
206
            if (Array.isArray(annotation)) {
207
                for (var /** @type {?} */ j = 0; j < annotation.length; j++) {
208
                    paramAnnotations.push(extractAnnotation(annotation[j]));
209
                }
210
            }
211
            else if (typeof annotation === 'function') {
212
                paramAnnotations.push(extractAnnotation(annotation));
213
            }
214
            else {
215
                paramAnnotations.push(annotation);
216
            }
217
        }
218
        Reflect.defineMetadata('parameters', paramsAnnotations, fn);
219
        return fn;
220
    }
221
    throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + stringify(fnOrArray) + "'");
222
}
223
/**
224
 * Provides a way for expressing ES6 classes with parameter annotations in ES5.
225
 *
226
 * ## Basic Example
227
 *
228
 * ```
229
 * var Greeter = ng.Class({
230
 *   constructor: function(name) {
231
 *     this.name = name;
232
 *   },
233
 *
234
 *   greet: function() {
235
 *     alert('Hello ' + this.name + '!');
236
 *   }
237
 * });
238
 * ```
239
 *
240
 * is equivalent to ES6:
241
 *
242
 * ```
243
 * class Greeter {
244
 *   constructor(name) {
245
 *     this.name = name;
246
 *   }
247
 *
248
 *   greet() {
249
 *     alert('Hello ' + this.name + '!');
250
 *   }
251
 * }
252
 * ```
253
 *
254
 * or equivalent to ES5:
255
 *
256
 * ```
257
 * var Greeter = function (name) {
258
 *   this.name = name;
259
 * }
260
 *
261
 * Greeter.prototype.greet = function () {
262
 *   alert('Hello ' + this.name + '!');
263
 * }
264
 * ```
265
 *
266
 * ### Example with parameter annotations
267
 *
268
 * ```
269
 * var MyService = ng.Class({
270
 *   constructor: [String, [new Optional(), Service], function(name, myService) {
271
 *     ...
272
 *   }]
273
 * });
274
 * ```
275
 *
276
 * is equivalent to ES6:
277
 *
278
 * ```
279
 * class MyService {
280
 *   constructor(name: string, \@Optional() myService: Service) {
281
 *     ...
282
 *   }
283
 * }
284
 * ```
285
 *
286
 * ### Example with inheritance
287
 *
288
 * ```
289
 * var Shape = ng.Class({
290
 *   constructor: (color) {
291
 *     this.color = color;
292
 *   }
293
 * });
294
 *
295
 * var Square = ng.Class({
296
 *   extends: Shape,
297
 *   constructor: function(color, size) {
298
 *     Shape.call(this, color);
299
 *     this.size = size;
300
 *   }
301
 * });
302
 * ```
303
 * @suppress {globalThis}
304
 * \@stable
305
 * @param {?} clsDef
306
 * @return {?}
307
 */
308
function Class(clsDef) {
309
    var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
310
    var /** @type {?} */ proto = constructor.prototype;
311
    if (clsDef.hasOwnProperty('extends')) {
312
        if (typeof clsDef.extends === 'function') {
313
            ((constructor)).prototype = proto =
314
                Object.create(((clsDef.extends)).prototype);
315
        }
316
        else {
317
            throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
318
        }
319
    }
320
    for (var /** @type {?} */ key in clsDef) {
321
        if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
322
            proto[key] = applyParams(clsDef[key], key);
323
        }
324
    }
325
    if (this && this.annotations instanceof Array) {
326
        Reflect.defineMetadata('annotations', this.annotations, constructor);
327
    }
328
    var /** @type {?} */ constructorName = constructor['name'];
329
    if (!constructorName || constructorName === 'constructor') {
330
        ((constructor))['overriddenName'] = "class" + _nextClassId++;
331
    }
332
    return (constructor);
333
}
334
/**
335
 * @suppress {globalThis}
336
 * @param {?} name
337
 * @param {?=} props
338
 * @param {?=} parentClass
339
 * @param {?=} chainFn
340
 * @return {?}
341
 */
342
function makeDecorator(name, props, parentClass, chainFn) {
343
    var /** @type {?} */ metaCtor = makeMetadataCtor(props);
344
    /**
345
     * @param {?} objOrType
346
     * @return {?}
347
     */
348
    function DecoratorFactory(objOrType) {
349
        if (!(Reflect && Reflect.getOwnMetadata)) {
350
            throw 'reflect-metadata shim is required when using class decorators';
351
        }
352
        if (this instanceof DecoratorFactory) {
353
            metaCtor.call(this, objOrType);
354
            return this;
355
        }
356
        var /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
357
        var /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
358
        chainAnnotation.push(annotationInstance);
359
        var /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
360
            var /** @type {?} */ annotations = Reflect.getOwnMetadata('annotations', cls) || [];
361
            annotations.push(annotationInstance);
362
            Reflect.defineMetadata('annotations', annotations, cls);
363
            return cls;
364
        });
365
        TypeDecorator.annotations = chainAnnotation;
366
        TypeDecorator.Class = Class;
367
        if (chainFn)
368
            chainFn(TypeDecorator);
369
        return TypeDecorator;
370
    }
371
    if (parentClass) {
372
        DecoratorFactory.prototype = Object.create(parentClass.prototype);
373
    }
374
    DecoratorFactory.prototype.toString = function () { return "@" + name; };
375
    ((DecoratorFactory)).annotationCls = DecoratorFactory;
376
    return DecoratorFactory;
377
}
378
/**
379
 * @param {?=} props
380
 * @return {?}
381
 */
382
function makeMetadataCtor(props) {
383
    return function ctor() {
384
        var args = [];
385
        for (var _i = 0; _i < arguments.length; _i++) {
386
            args[_i] = arguments[_i];
387
        }
388
        if (props) {
389
            var /** @type {?} */ values = props.apply(void 0, args);
390
            for (var /** @type {?} */ propName in values) {
391
                this[propName] = values[propName];
392
            }
393
        }
394
    };
395
}
396
/**
397
 * @param {?} name
398
 * @param {?=} props
399
 * @param {?=} parentClass
400
 * @return {?}
401
 */
402
function makeParamDecorator(name, props, parentClass) {
403
    var /** @type {?} */ metaCtor = makeMetadataCtor(props);
404
    /**
405
     * @param {...?} args
406
     * @return {?}
407
     */
408
    function ParamDecoratorFactory() {
409
        var args = [];
410
        for (var _i = 0; _i < arguments.length; _i++) {
411
            args[_i] = arguments[_i];
412
        }
413
        if (this instanceof ParamDecoratorFactory) {
414
            metaCtor.apply(this, args);
415
            return this;
416
        }
417
        var /** @type {?} */ annotationInstance = new (((ParamDecoratorFactory)).bind.apply(((ParamDecoratorFactory)), [void 0].concat(args)))();
418
        ((ParamDecorator)).annotation = annotationInstance;
419
        return ParamDecorator;
420
        /**
421
         * @param {?} cls
422
         * @param {?} unusedKey
423
         * @param {?} index
424
         * @return {?}
425
         */
426
        function ParamDecorator(cls, unusedKey, index) {
427
            var /** @type {?} */ parameters = Reflect.getOwnMetadata('parameters', cls) || [];
428
            // there might be gaps if some in between parameters do not have annotations.
429
            // we pad with nulls.
430
            while (parameters.length <= index) {
431
                parameters.push(null);
432
            }
433
            parameters[index] = parameters[index] || []; /** @type {?} */
434
            ((parameters[index])).push(annotationInstance);
435
            Reflect.defineMetadata('parameters', parameters, cls);
436
            return cls;
437
        }
438
    }
439
    if (parentClass) {
440
        ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
441
    }
442
    ParamDecoratorFactory.prototype.toString = function () { return "@" + name; };
443
    ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
444
    return ParamDecoratorFactory;
445
}
446
/**
447
 * @param {?} name
448
 * @param {?=} props
449
 * @param {?=} parentClass
450
 * @return {?}
451
 */
452
function makePropDecorator(name, props, parentClass) {
453
    var /** @type {?} */ metaCtor = makeMetadataCtor(props);
454
    /**
455
     * @param {...?} args
456
     * @return {?}
457
     */
458
    function PropDecoratorFactory() {
459
        var args = [];
460
        for (var _i = 0; _i < arguments.length; _i++) {
461
            args[_i] = arguments[_i];
462
        }
463
        if (this instanceof PropDecoratorFactory) {
464
            metaCtor.apply(this, args);
465
            return this;
466
        }
467
        var /** @type {?} */ decoratorInstance = new (((PropDecoratorFactory)).bind.apply(((PropDecoratorFactory)), [void 0].concat(args)))();
468
        return function PropDecorator(target, name) {
469
            var /** @type {?} */ meta = Reflect.getOwnMetadata('propMetadata', target.constructor) || {};
470
            meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
471
            meta[name].unshift(decoratorInstance);
472
            Reflect.defineMetadata('propMetadata', meta, target.constructor);
473
        };
474
    }
475
    if (parentClass) {
476
        PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
477
    }
478
    PropDecoratorFactory.prototype.toString = function () { return "@" + name; };
479
    ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
480
    return PropDecoratorFactory;
481
}
482
/**
483
 * @license
484
 * Copyright Google Inc. All Rights Reserved.
485
 *
486
 * Use of this source code is governed by an MIT-style license that can be
487
 * found in the LICENSE file at https://angular.io/license
488
 */
489
/**
490
 * This token can be used to create a virtual provider that will populate the
491
 * `entryComponents` fields of components and ng modules based on its `useValue`.
492
 * All components that are referenced in the `useValue` value (either directly
493
 * or in a nested array or map) will be added to the `entryComponents` property.
494
 *
495
 * ### Example
496
 * The following example shows how the router can populate the `entryComponents`
497
 * field of an NgModule based on the router configuration which refers
498
 * to components.
499
 *
500
 * ```typescript
501
 * // helper function inside the router
502
 * function provideRoutes(routes) {
503
 *   return [
504
 *     {provide: ROUTES, useValue: routes},
505
 *     {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
506
 *   ];
507
 * }
508
 *
509
 * // user code
510
 * let routes = [
511
 *   {path: '/root', component: RootComp},
512
 *   {path: '/teams', component: TeamsComp}
513
 * ];
514
 *
515
 * \@NgModule({
516
 *   providers: [provideRoutes(routes)]
517
 * })
518
 * class ModuleWithRoutes {}
519
 * ```
520
 *
521
 * \@experimental
522
 */
523
var ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
524
/**
525
 * Attribute decorator and metadata.
526
 *
527
 * \@stable
528
 * \@Annotation
529
 */
530
var Attribute = makeParamDecorator('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
531
/**
532
 * Base class for query metadata.
533
 *
534
 * See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
535
 * more information.
536
 *
537
 * \@stable
538
 * @abstract
539
 */
540
var Query = (function () {
541
    function Query() {
542
    }
543
    return Query;
544
}());
545
/**
546
 * ContentChildren decorator and metadata.
547
 *
548
 *  \@stable
549
 *  \@Annotation
550
 */
551
var ContentChildren = makePropDecorator('ContentChildren', function (selector, data) {
552
    if (data === void 0) { data = {}; }
553
    return (Object.assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
554
}, Query);
555
/**
556
 * ContentChild decorator and metadata.
557
 *
558
 * \@stable
559
 * \@Annotation
560
 */
561
var ContentChild = makePropDecorator('ContentChild', function (selector, data) {
562
    if (data === void 0) { data = {}; }
563
    return (Object.assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
564
}, Query);
565
/**
566
 * ViewChildren decorator and metadata.
567
 *
568
 * \@stable
569
 * \@Annotation
570
 */
571
var ViewChildren = makePropDecorator('ViewChildren', function (selector, data) {
572
    if (data === void 0) { data = {}; }
573
    return (Object.assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
574
}, Query);
575
/**
576
 * ViewChild decorator and metadata.
577
 *
578
 * \@stable
579
 * \@Annotation
580
 */
581
var ViewChild = makePropDecorator('ViewChild', function (selector, data) { return (Object.assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data)); }, Query);
582
var ChangeDetectionStrategy = {};
583
ChangeDetectionStrategy.OnPush = 0;
584
ChangeDetectionStrategy.Default = 1;
585
ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
586
ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
587
var ChangeDetectorStatus = {};
588
ChangeDetectorStatus.CheckOnce = 0;
589
ChangeDetectorStatus.Checked = 1;
590
ChangeDetectorStatus.CheckAlways = 2;
591
ChangeDetectorStatus.Detached = 3;
592
ChangeDetectorStatus.Errored = 4;
593
ChangeDetectorStatus.Destroyed = 5;
594
ChangeDetectorStatus[ChangeDetectorStatus.CheckOnce] = "CheckOnce";
595
ChangeDetectorStatus[ChangeDetectorStatus.Checked] = "Checked";
596
ChangeDetectorStatus[ChangeDetectorStatus.CheckAlways] = "CheckAlways";
597
ChangeDetectorStatus[ChangeDetectorStatus.Detached] = "Detached";
598
ChangeDetectorStatus[ChangeDetectorStatus.Errored] = "Errored";
599
ChangeDetectorStatus[ChangeDetectorStatus.Destroyed] = "Destroyed";
600
/**
601
 * @param {?} changeDetectionStrategy
602
 * @return {?}
603
 */
604
function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
605
    return changeDetectionStrategy == null ||
606
        changeDetectionStrategy === ChangeDetectionStrategy.Default;
607
}
608
/**
609
 * @license
610
 * Copyright Google Inc. All Rights Reserved.
611
 *
612
 * Use of this source code is governed by an MIT-style license that can be
613
 * found in the LICENSE file at https://angular.io/license
614
 */
615
/**
616
 * Directive decorator and metadata.
617
 *
618
 * \@stable
619
 * \@Annotation
620
 */
621
var Directive = makeDecorator('Directive', function (dir) {
622
    if (dir === void 0) { dir = {}; }
623
    return dir;
624
});
625
/**
626
 * Component decorator and metadata.
627
 *
628
 * \@stable
629
 * \@Annotation
630
 */
631
var Component = makeDecorator('Component', function (c) {
632
    if (c === void 0) { c = {}; }
633
    return (Object.assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
634
}, Directive);
635
/**
636
 * Pipe decorator and metadata.
637
 *
638
 * \@stable
639
 * \@Annotation
640
 */
641
var Pipe = makeDecorator('Pipe', function (p) { return (Object.assign({ pure: true }, p)); });
642
/**
643
 * Input decorator and metadata.
644
 *
645
 * \@stable
646
 * \@Annotation
647
 */
648
var Input = makePropDecorator('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
649
/**
650
 * Output decorator and metadata.
651
 *
652
 * \@stable
653
 * \@Annotation
654
 */
655
var Output = makePropDecorator('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
656
/**
657
 * HostBinding decorator and metadata.
658
 *
659
 * \@stable
660
 * \@Annotation
661
 */
662
var HostBinding = makePropDecorator('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
663
/**
664
 * HostListener decorator and metadata.
665
 *
666
 * \@stable
667
 * \@Annotation
668
 */
669
var HostListener = makePropDecorator('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
670
/**
671
 * @license
672
 * Copyright Google Inc. All Rights Reserved.
673
 *
674
 * Use of this source code is governed by an MIT-style license that can be
675
 * found in the LICENSE file at https://angular.io/license
676
 */
677
/**
678
 * Defines a schema that will allow:
679
 * - any non-Angular elements with a `-` in their name,
680
 * - any properties on elements with a `-` in their name which is the common rule for custom
681
 * elements.
682
 *
683
 * \@stable
684
 */
685
var CUSTOM_ELEMENTS_SCHEMA = {
686
    name: 'custom-elements'
687
};
688
/**
689
 * Defines a schema that will allow any property on any element.
690
 *
691
 * \@experimental
692
 */
693
var NO_ERRORS_SCHEMA = {
694
    name: 'no-errors-schema'
695
};
696
/**
697
 * NgModule decorator and metadata.
698
 *
699
 * \@stable
700
 * \@Annotation
701
 */
702
var NgModule = makeDecorator('NgModule', function (ngModule) { return ngModule; });
703
var ViewEncapsulation = {};
704
ViewEncapsulation.Emulated = 0;
705
ViewEncapsulation.Native = 1;
706
ViewEncapsulation.None = 2;
707
ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
708
ViewEncapsulation[ViewEncapsulation.Native] = "Native";
709
ViewEncapsulation[ViewEncapsulation.None] = "None";
710
/**
711
 * Metadata properties available for configuring Views.
712
 *
713
 * For details on the `\@Component` annotation, see {\@link Component}.
714
 *
715
 * ### Example
716
 *
717
 * ```
718
 * \@Component({
719
 *   selector: 'greet',
720
 *   template: 'Hello {{name}}!',
721
 * })
722
 * class Greet {
723
 *   name: string;
724
 *
725
 *   constructor() {
726
 *     this.name = 'World';
727
 *   }
728
 * }
729
 * ```
730
 *
731
 * @deprecated Use Component instead.
732
 *
733
 * {\@link Component}
734
 */
735
var ViewMetadata = (function () {
736
    /**
737
     * @param {?=} opts
738
     */
739
    function ViewMetadata(opts) {
740
        if (opts === void 0) { opts = {}; }
741
        this.templateUrl = opts.templateUrl;
742
        this.template = opts.template;
743
        this.styleUrls = opts.styleUrls;
744
        this.styles = opts.styles;
745
        this.encapsulation = opts.encapsulation;
746
        this.animations = opts.animations;
747
        this.interpolation = opts.interpolation;
748
    }
749
    return ViewMetadata;
750
}());
751
/**
752
 * @license
753
 * Copyright Google Inc. All Rights Reserved.
754
 *
755
 * Use of this source code is governed by an MIT-style license that can be
756
 * found in the LICENSE file at https://angular.io/license
757
 */
758
/**
759
 * \@whatItDoes Represents the version of Angular
760
 *
761
 * \@stable
762
 */
763
var Version = (function () {
764
    /**
765
     * @param {?} full
766
     */
767
    function Version(full) {
768
        this.full = full;
769
    }
770
    Object.defineProperty(Version.prototype, "major", {
771
        /**
772
         * @return {?}
773
         */
774
        get: function () { return this.full.split('.')[0]; },
775
        enumerable: true,
776
        configurable: true
777
    });
778
    Object.defineProperty(Version.prototype, "minor", {
779
        /**
780
         * @return {?}
781
         */
782
        get: function () { return this.full.split('.')[1]; },
783
        enumerable: true,
784
        configurable: true
785
    });
786
    Object.defineProperty(Version.prototype, "patch", {
787
        /**
788
         * @return {?}
789
         */
790
        get: function () { return this.full.split('.').slice(2).join('.'); },
791
        enumerable: true,
792
        configurable: true
793
    });
794
    return Version;
795
}());
796
/**
797
 * \@stable
798
 */
799
var VERSION = new Version('4.4.6');
800
/**
801
 * @license
802
 * Copyright Google Inc. All Rights Reserved.
803
 *
804
 * Use of this source code is governed by an MIT-style license that can be
805
 * found in the LICENSE file at https://angular.io/license
806
 */
807
/**
808
 * Inject decorator and metadata.
809
 *
810
 * \@stable
811
 * \@Annotation
812
 */
813
var Inject = makeParamDecorator('Inject', function (token) { return ({ token: token }); });
814
/**
815
 * Optional decorator and metadata.
816
 *
817
 * \@stable
818
 * \@Annotation
819
 */
820
var Optional = makeParamDecorator('Optional');
821
/**
822
 * Injectable decorator and metadata.
823
 *
824
 * \@stable
825
 * \@Annotation
826
 */
827
var Injectable = makeDecorator('Injectable');
828
/**
829
 * Self decorator and metadata.
830
 *
831
 * \@stable
832
 * \@Annotation
833
 */
834
var Self = makeParamDecorator('Self');
835
/**
836
 * SkipSelf decorator and metadata.
837
 *
838
 * \@stable
839
 * \@Annotation
840
 */
841
var SkipSelf = makeParamDecorator('SkipSelf');
842
/**
843
 * Host decorator and metadata.
844
 *
845
 * \@stable
846
 * \@Annotation
847
 */
848
var Host = makeParamDecorator('Host');
849
/**
850
 * @license
851
 * Copyright Google Inc. All Rights Reserved.
852
 *
853
 * Use of this source code is governed by an MIT-style license that can be
854
 * found in the LICENSE file at https://angular.io/license
855
 */
856
/**
857
 * Allows to refer to references which are not yet defined.
858
 *
859
 * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
860
 * DI is declared,
861
 * but not yet defined. It is also used when the `token` which we use when creating a query is not
862
 * yet defined.
863
 *
864
 * ### Example
865
 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
866
 * \@experimental
867
 * @param {?} forwardRefFn
868
 * @return {?}
869
 */
870
function forwardRef(forwardRefFn) {
871
    ((forwardRefFn)).__forward_ref__ = forwardRef;
872
    ((forwardRefFn)).toString = function () { return stringify(this()); };
873
    return (((forwardRefFn)));
874
}
875
/**
876
 * Lazily retrieves the reference value from a forwardRef.
877
 *
878
 * Acts as the identity function when given a non-forward-ref value.
879
 *
880
 * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
881
 *
882
 * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
883
 *
884
 * See: {\@link forwardRef}
885
 * \@experimental
886
 * @param {?} type
887
 * @return {?}
888
 */
889
function resolveForwardRef(type) {
890
    if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
891
        type.__forward_ref__ === forwardRef) {
892
        return ((type))();
893
    }
894
    else {
895
        return type;
896
    }
897
}
898
/**
899
 * @license
900
 * Copyright Google Inc. All Rights Reserved.
901
 *
902
 * Use of this source code is governed by an MIT-style license that can be
903
 * found in the LICENSE file at https://angular.io/license
904
 */
905
var _THROW_IF_NOT_FOUND = new Object();
906
var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
907
var _NullInjector = (function () {
908
    function _NullInjector() {
909
    }
910
    /**
911
     * @param {?} token
912
     * @param {?=} notFoundValue
913
     * @return {?}
914
     */
915
    _NullInjector.prototype.get = function (token, notFoundValue) {
916
        if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
917
        if (notFoundValue === _THROW_IF_NOT_FOUND) {
918
            throw new Error("No provider for " + stringify(token) + "!");
919
        }
920
        return notFoundValue;
921
    };
922
    return _NullInjector;
923
}());
924
/**
925
 * \@whatItDoes Injector interface
926
 * \@howToUse
927
 * ```
928
 * const injector: Injector = ...;
929
 * injector.get(...);
930
 * ```
931
 *
932
 * \@description
933
 * For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
934
 *
935
 * ### Example
936
 *
937
 * {\@example core/di/ts/injector_spec.ts region='Injector'}
938
 *
939
 * `Injector` returns itself when given `Injector` as a token:
940
 * {\@example core/di/ts/injector_spec.ts region='injectInjector'}
941
 *
942
 * \@stable
943
 * @abstract
944
 */
945
var Injector = (function () {
946
    function Injector() {
947
    }
948
    /**
949
     * Retrieves an instance from the injector based on the provided token.
950
     * If not found:
951
     * - Throws an error if no `notFoundValue` that is not equal to
952
     * Injector.THROW_IF_NOT_FOUND is given
953
     * - Returns the `notFoundValue` otherwise
954
     * @abstract
955
     * @template T
956
     * @param {?} token
957
     * @param {?=} notFoundValue
958
     * @return {?}
959
     */
960
    Injector.prototype.get = function (token, notFoundValue) { };
961
    /**
962
     * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
963
     * @suppress {duplicate}
964
     * @abstract
965
     * @param {?} token
966
     * @param {?=} notFoundValue
967
     * @return {?}
968
     */
969
    Injector.prototype.get = function (token, notFoundValue) { };
970
    return Injector;
971
}());
972
Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
973
Injector.NULL = new _NullInjector();
974
/**
975
 * @license
976
 * Copyright Google Inc. All Rights Reserved.
977
 *
978
 * Use of this source code is governed by an MIT-style license that can be
979
 * found in the LICENSE file at https://angular.io/license
980
 */
981
var ERROR_COMPONENT_TYPE = 'ngComponentType';
982
var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
983
var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
984
var ERROR_LOGGER = 'ngErrorLogger';
985
/**
986
 * @param {?} error
987
 * @return {?}
988
 */
989
/**
990
 * @param {?} error
991
 * @return {?}
992
 */
993
function getDebugContext(error) {
994
    return ((error))[ERROR_DEBUG_CONTEXT];
995
}
996
/**
997
 * @param {?} error
998
 * @return {?}
999
 */
1000
function getOriginalError(error) {
1001
    return ((error))[ERROR_ORIGINAL_ERROR];
1002
}
1003
/**
1004
 * @param {?} error
1005
 * @return {?}
1006
 */
1007
function getErrorLogger(error) {
1008
    return ((error))[ERROR_LOGGER] || defaultErrorLogger;
1009
}
1010
/**
1011
 * @param {?} console
1012
 * @param {...?} values
1013
 * @return {?}
1014
 */
1015
function defaultErrorLogger(console) {
1016
    var values = [];
1017
    for (var _i = 1; _i < arguments.length; _i++) {
1018
        values[_i - 1] = arguments[_i];
1019
    }
1020
    console.error.apply(console, values);
1021
}
1022
/**
1023
 * @license
1024
 * Copyright Google Inc. All Rights Reserved.
1025
 *
1026
 * Use of this source code is governed by an MIT-style license that can be
1027
 * found in the LICENSE file at https://angular.io/license
1028
 */
1029
/**
1030
 * \@whatItDoes Provides a hook for centralized exception handling.
1031
 *
1032
 * \@description
1033
 *
1034
 * The default implementation of `ErrorHandler` prints error messages to the `console`. To
1035
 * intercept error handling, write a custom exception handler that replaces this default as
1036
 * appropriate for your app.
1037
 *
1038
 * ### Example
1039
 *
1040
 * ```
1041
 * class MyErrorHandler implements ErrorHandler {
1042
 *   handleError(error) {
1043
 *     // do something with the exception
1044
 *   }
1045
 * }
1046
 *
1047
 * \@NgModule({
1048
 *   providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
1049
 * })
1050
 * class MyModule {}
1051
 * ```
1052
 *
1053
 * \@stable
1054
 */
1055
var ErrorHandler = (function () {
1056
    /**
1057
     * @param {?=} deprecatedParameter
1058
     */
1059
    function ErrorHandler(
1060
        /**
1061
         * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
1062
         * rethrow.
1063
         */
1064
        deprecatedParameter) {
1065
        /**
1066
         * \@internal
1067
         */
1068
        this._console = console;
1069
    }
1070
    /**
1071
     * @param {?} error
1072
     * @return {?}
1073
     */
1074
    ErrorHandler.prototype.handleError = function (error) {
1075
        var /** @type {?} */ originalError = this._findOriginalError(error);
1076
        var /** @type {?} */ context = this._findContext(error);
1077
        // Note: Browser consoles show the place from where console.error was called.
1078
        // We can use this to give users additional information about the error.
1079
        var /** @type {?} */ errorLogger = getErrorLogger(error);
1080
        errorLogger(this._console, "ERROR", error);
1081
        if (originalError) {
1082
            errorLogger(this._console, "ORIGINAL ERROR", originalError);
1083
        }
1084
        if (context) {
1085
            errorLogger(this._console, 'ERROR CONTEXT', context);
1086
        }
1087
    };
1088
    /**
1089
     * \@internal
1090
     * @param {?} error
1091
     * @return {?}
1092
     */
1093
    ErrorHandler.prototype._findContext = function (error) {
1094
        if (error) {
1095
            return getDebugContext(error) ? getDebugContext(error) :
1096
                this._findContext(getOriginalError(error));
1097
        }
1098
        return null;
1099
    };
1100
    /**
1101
     * \@internal
1102
     * @param {?} error
1103
     * @return {?}
1104
     */
1105
    ErrorHandler.prototype._findOriginalError = function (error) {
1106
        var /** @type {?} */ e = getOriginalError(error);
1107
        while (e && getOriginalError(e)) {
1108
            e = getOriginalError(e);
1109
        }
1110
        return e;
1111
    };
1112
    return ErrorHandler;
1113
}());
1114
/**
1115
 * @param {?} message
1116
 * @param {?} originalError
1117
 * @return {?}
1118
 */
1119
function wrappedError(message, originalError) {
1120
    var /** @type {?} */ msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
1121
    var /** @type {?} */ error = Error(msg);
1122
    ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1123
    return error;
1124
}
1125
/**
1126
 * @license
1127
 * Copyright Google Inc. All Rights Reserved.
1128
 *
1129
 * Use of this source code is governed by an MIT-style license that can be
1130
 * found in the LICENSE file at https://angular.io/license
1131
 */
1132
/**
1133
 * @param {?} keys
1134
 * @return {?}
1135
 */
1136
function findFirstClosedCycle(keys) {
1137
    var /** @type {?} */ res = [];
1138
    for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
1139
        if (res.indexOf(keys[i]) > -1) {
1140
            res.push(keys[i]);
1141
            return res;
1142
        }
1143
        res.push(keys[i]);
1144
    }
1145
    return res;
1146
}
1147
/**
1148
 * @param {?} keys
1149
 * @return {?}
1150
 */
1151
function constructResolvingPath(keys) {
1152
    if (keys.length > 1) {
1153
        var /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
1154
        var /** @type {?} */ tokenStrs = reversed.map(function (k) { return stringify(k.token); });
1155
        return ' (' + tokenStrs.join(' -> ') + ')';
1156
    }
1157
    return '';
1158
}
1159
/**
1160
 * @param {?} injector
1161
 * @param {?} key
1162
 * @param {?} constructResolvingMessage
1163
 * @param {?=} originalError
1164
 * @return {?}
1165
 */
1166
function injectionError(injector, key, constructResolvingMessage, originalError) {
1167
    var /** @type {?} */ keys = [key];
1168
    var /** @type {?} */ errMsg = constructResolvingMessage(keys);
1169
    var /** @type {?} */ error = ((originalError ? wrappedError(errMsg, originalError) : Error(errMsg)));
1170
    error.addKey = addKey;
1171
    error.keys = keys;
1172
    error.injectors = [injector];
1173
    error.constructResolvingMessage = constructResolvingMessage;
1174
    ((error))[ERROR_ORIGINAL_ERROR] = originalError;
1175
    return error;
1176
}
1177
/**
1178
 * @this {?}
1179
 * @param {?} injector
1180
 * @param {?} key
1181
 * @return {?}
1182
 */
1183
function addKey(injector, key) {
1184
    this.injectors.push(injector);
1185
    this.keys.push(key);
1186
    // Note: This updated message won't be reflected in the `.stack` property
1187
    this.message = this.constructResolvingMessage(this.keys);
1188
}
1189
/**
1190
 * Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
1191
 * {\@link Injector} does not have a {\@link Provider} for the given key.
1192
 *
1193
 * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
1194
 *
1195
 * ```typescript
1196
 * class A {
1197
 *   constructor(b:B) {}
1198
 * }
1199
 *
1200
 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1201
 * ```
1202
 * @param {?} injector
1203
 * @param {?} key
1204
 * @return {?}
1205
 */
1206
function noProviderError(injector, key) {
1207
    return injectionError(injector, key, function (keys) {
1208
        var /** @type {?} */ first = stringify(keys[0].token);
1209
        return "No provider for " + first + "!" + constructResolvingPath(keys);
1210
    });
1211
}
1212
/**
1213
 * Thrown when dependencies form a cycle.
1214
 *
1215
 * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
1216
 *
1217
 * ```typescript
1218
 * var injector = Injector.resolveAndCreate([
1219
 *   {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
1220
 *   {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
1221
 * ]);
1222
 *
1223
 * expect(() => injector.get("one")).toThrowError();
1224
 * ```
1225
 *
1226
 * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
1227
 * @param {?} injector
1228
 * @param {?} key
1229
 * @return {?}
1230
 */
1231
function cyclicDependencyError(injector, key) {
1232
    return injectionError(injector, key, function (keys) {
1233
        return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
1234
    });
1235
}
1236
/**
1237
 * Thrown when a constructing type returns with an Error.
1238
 *
1239
 * The `InstantiationError` class contains the original error plus the dependency graph which caused
1240
 * this object to be instantiated.
1241
 *
1242
 * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
1243
 *
1244
 * ```typescript
1245
 * class A {
1246
 *   constructor() {
1247
 *     throw new Error('message');
1248
 *   }
1249
 * }
1250
 *
1251
 * var injector = Injector.resolveAndCreate([A]);
1252
 * try {
1253
 *   injector.get(A);
1254
 * } catch (e) {
1255
 *   expect(e instanceof InstantiationError).toBe(true);
1256
 *   expect(e.originalException.message).toEqual("message");
1257
 *   expect(e.originalStack).toBeDefined();
1258
 * }
1259
 * ```
1260
 * @param {?} injector
1261
 * @param {?} originalException
1262
 * @param {?} originalStack
1263
 * @param {?} key
1264
 * @return {?}
1265
 */
1266
function instantiationError(injector, originalException, originalStack, key) {
1267
    return injectionError(injector, key, function (keys) {
1268
        var /** @type {?} */ first = stringify(keys[0].token);
1269
        return originalException.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(keys) + ".";
1270
    }, originalException);
1271
}
1272
/**
1273
 * Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
1274
 * creation.
1275
 *
1276
 * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
1277
 *
1278
 * ```typescript
1279
 * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
1280
 * ```
1281
 * @param {?} provider
1282
 * @return {?}
1283
 */
1284
function invalidProviderError(provider) {
1285
    return Error("Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
1286
}
1287
/**
1288
 * Thrown when the class has no annotation information.
1289
 *
1290
 * Lack of annotation information prevents the {\@link Injector} from determining which dependencies
1291
 * need to be injected into the constructor.
1292
 *
1293
 * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
1294
 *
1295
 * ```typescript
1296
 * class A {
1297
 *   constructor(b) {}
1298
 * }
1299
 *
1300
 * expect(() => Injector.resolveAndCreate([A])).toThrowError();
1301
 * ```
1302
 *
1303
 * This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
1304
 *
1305
 * ```typescript
1306
 * class B {}
1307
 *
1308
 * class A {
1309
 *   constructor(b:B) {} // no information about the parameter types of A is available at runtime.
1310
 * }
1311
 *
1312
 * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
1313
 * ```
1314
 * \@stable
1315
 * @param {?} typeOrFunc
1316
 * @param {?} params
1317
 * @return {?}
1318
 */
1319
function noAnnotationError(typeOrFunc, params) {
1320
    var /** @type {?} */ signature = [];
1321
    for (var /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
1322
        var /** @type {?} */ parameter = params[i];
1323
        if (!parameter || parameter.length == 0) {
1324
            signature.push('?');
1325
        }
1326
        else {
1327
            signature.push(parameter.map(stringify).join(' '));
1328
        }
1329
    }
1330
    return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
1331
        signature.join(', ') + '). ' +
1332
        'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
1333
        stringify(typeOrFunc) + '\' is decorated with Injectable.');
1334
}
1335
/**
1336
 * Thrown when getting an object by index.
1337
 *
1338
 * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
1339
 *
1340
 * ```typescript
1341
 * class A {}
1342
 *
1343
 * var injector = Injector.resolveAndCreate([A]);
1344
 *
1345
 * expect(() => injector.getAt(100)).toThrowError();
1346
 * ```
1347
 * \@stable
1348
 * @param {?} index
1349
 * @return {?}
1350
 */
1351
function outOfBoundsError(index) {
1352
    return Error("Index " + index + " is out-of-bounds.");
1353
}
1354
/**
1355
 * Thrown when a multi provider and a regular provider are bound to the same token.
1356
 *
1357
 * ### Example
1358
 *
1359
 * ```typescript
1360
 * expect(() => Injector.resolveAndCreate([
1361
 *   { provide: "Strings", useValue: "string1", multi: true},
1362
 *   { provide: "Strings", useValue: "string2", multi: false}
1363
 * ])).toThrowError();
1364
 * ```
1365
 * @param {?} provider1
1366
 * @param {?} provider2
1367
 * @return {?}
1368
 */
1369
function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
1370
    return Error("Cannot mix multi providers and regular providers, got: " + provider1 + " " + provider2);
1371
}
1372
/**
1373
 * @license
1374
 * Copyright Google Inc. All Rights Reserved.
1375
 *
1376
 * Use of this source code is governed by an MIT-style license that can be
1377
 * found in the LICENSE file at https://angular.io/license
1378
 */
1379
/**
1380
 * A unique object used for retrieving items from the {\@link ReflectiveInjector}.
1381
 *
1382
 * Keys have:
1383
 * - a system-wide unique `id`.
1384
 * - a `token`.
1385
 *
1386
 * `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
1387
 * the
1388
 * injector to store created objects in a more efficient way.
1389
 *
1390
 * `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
1391
 * resolving
1392
 * providers.
1393
 * \@experimental
1394
 */
1395
var ReflectiveKey = (function () {
1396
    /**
1397
     * Private
1398
     * @param {?} token
1399
     * @param {?} id
1400
     */
1401
    function ReflectiveKey(token, id) {
1402
        this.token = token;
1403
        this.id = id;
1404
        if (!token) {
1405
            throw new Error('Token must be defined!');
1406
        }
1407
    }
1408
    Object.defineProperty(ReflectiveKey.prototype, "displayName", {
1409
        /**
1410
         * Returns a stringified token.
1411
         * @return {?}
1412
         */
1413
        get: function () { return stringify(this.token); },
1414
        enumerable: true,
1415
        configurable: true
1416
    });
1417
    /**
1418
     * Retrieves a `Key` for a token.
1419
     * @param {?} token
1420
     * @return {?}
1421
     */
1422
    ReflectiveKey.get = function (token) {
1423
        return _globalKeyRegistry.get(resolveForwardRef(token));
1424
    };
1425
    Object.defineProperty(ReflectiveKey, "numberOfKeys", {
1426
        /**
1427
         * @return {?} the number of keys registered in the system.
1428
         */
1429
        get: function () { return _globalKeyRegistry.numberOfKeys; },
1430
        enumerable: true,
1431
        configurable: true
1432
    });
1433
    return ReflectiveKey;
1434
}());
1435
/**
1436
 * \@internal
1437
 */
1438
var KeyRegistry = (function () {
1439
    function KeyRegistry() {
1440
        this._allKeys = new Map();
1441
    }
1442
    /**
1443
     * @param {?} token
1444
     * @return {?}
1445
     */
1446
    KeyRegistry.prototype.get = function (token) {
1447
        if (token instanceof ReflectiveKey)
1448
            return token;
1449
        if (this._allKeys.has(token)) {
1450
            return ((this._allKeys.get(token)));
1451
        }
1452
        var /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
1453
        this._allKeys.set(token, newKey);
1454
        return newKey;
1455
    };
1456
    Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
1457
        /**
1458
         * @return {?}
1459
         */
1460
        get: function () { return this._allKeys.size; },
1461
        enumerable: true,
1462
        configurable: true
1463
    });
1464
    return KeyRegistry;
1465
}());
1466
var _globalKeyRegistry = new KeyRegistry();
1467
/**
1468
 * \@whatItDoes Represents a type that a Component or other object is instances of.
1469
 *
1470
 * \@description
1471
 *
1472
 * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
1473
 * the `MyCustomComponent` constructor function.
1474
 *
1475
 * \@stable
1476
 */
1477
var Type = Function;
1478
/**
1479
 * @param {?} v
1480
 * @return {?}
1481
 */
1482
function isType(v) {
1483
    return typeof v === 'function';
1484
}
1485
/**
1486
 * @license
1487
 * Copyright Google Inc. All Rights Reserved.
1488
 *
1489
 * Use of this source code is governed by an MIT-style license that can be
1490
 * found in the LICENSE file at https://angular.io/license
1491
 */
1492
/**
1493
 * Attention: This regex has to hold even if the code is minified!
1494
 */
1495
var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
1496
var ReflectionCapabilities = (function () {
1497
    /**
1498
     * @param {?=} reflect
1499
     */
1500
    function ReflectionCapabilities(reflect) {
1501
        this._reflect = reflect || _global['Reflect'];
1502
    }
1503
    /**
1504
     * @return {?}
1505
     */
1506
    ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; };
1507
    /**
1508
     * @template T
1509
     * @param {?} t
1510
     * @return {?}
1511
     */
1512
    ReflectionCapabilities.prototype.factory = function (t) { return function () {
1513
        var args = [];
1514
        for (var _i = 0; _i < arguments.length; _i++) {
1515
            args[_i] = arguments[_i];
1516
        }
1517
        return new (t.bind.apply(t, [void 0].concat(args)))();
1518
    }; };
1519
    /**
1520
     * \@internal
1521
     * @param {?} paramTypes
1522
     * @param {?} paramAnnotations
1523
     * @return {?}
1524
     */
1525
    ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) {
1526
        var /** @type {?} */ result;
1527
        if (typeof paramTypes === 'undefined') {
1528
            result = new Array(paramAnnotations.length);
1529
        }
1530
        else {
1531
            result = new Array(paramTypes.length);
1532
        }
1533
        for (var /** @type {?} */ i = 0; i < result.length; i++) {
1534
            // TS outputs Object for parameters without types, while Traceur omits
1535
            // the annotations. For now we preserve the Traceur behavior to aid
1536
            // migration, but this can be revisited.
1537
            if (typeof paramTypes === 'undefined') {
1538
                result[i] = [];
1539
            }
1540
            else if (paramTypes[i] != Object) {
1541
                result[i] = [paramTypes[i]];
1542
            }
1543
            else {
1544
                result[i] = [];
1545
            }
1546
            if (paramAnnotations && paramAnnotations[i] != null) {
1547
                result[i] = result[i].concat(paramAnnotations[i]);
1548
            }
1549
        }
1550
        return result;
1551
    };
1552
    /**
1553
     * @param {?} type
1554
     * @param {?} parentCtor
1555
     * @return {?}
1556
     */
1557
    ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) {
1558
        // If we have no decorators, we only have function.length as metadata.
1559
        // In that case, to detect whether a child class declared an own constructor or not,
1560
        // we need to look inside of that constructor to check whether it is
1561
        // just calling the parent.
1562
        // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
1563
        // that sets 'design:paramtypes' to []
1564
        // if a class inherits from another class but has no ctor declared itself.
1565
        if (DELEGATE_CTOR.exec(type.toString())) {
1566
            return null;
1567
        }
1568
        // Prefer the direct API.
1569
        if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
1570
            return ((type)).parameters;
1571
        }
1572
        // API of tsickle for lowering decorators to properties on the class.
1573
        var /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
1574
        if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
1575
            // Newer tsickle uses a function closure
1576
            // Retain the non-function case for compatibility with older tsickle
1577
            var /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
1578
            var /** @type {?} */ paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; });
1579
            var /** @type {?} */ paramAnnotations = ctorParameters.map(function (ctorParam) { return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators); });
1580
            return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1581
        }
1582
        // API for metadata created by invoking the decorators.
1583
        if (this._reflect != null && this._reflect.getOwnMetadata != null) {
1584
            var /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
1585
            var /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
1586
            if (paramTypes || paramAnnotations) {
1587
                return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
1588
            }
1589
        }
1590
        // If a class has no decorators, at least create metadata
1591
        // based on function.length.
1592
        // Note: We know that this is a real constructor as we checked
1593
        // the content of the constructor above.
1594
        return new Array(((type.length))).fill(undefined);
1595
    };
1596
    /**
1597
     * @param {?} type
1598
     * @return {?}
1599
     */
1600
    ReflectionCapabilities.prototype.parameters = function (type) {
1601
        // Note: only report metadata if we have at least one class decorator
1602
        // to stay in sync with the static reflector.
1603
        if (!isType(type)) {
1604
            return [];
1605
        }
1606
        var /** @type {?} */ parentCtor = getParentCtor(type);
1607
        var /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
1608
        if (!parameters && parentCtor !== Object) {
1609
            parameters = this.parameters(parentCtor);
1610
        }
1611
        return parameters || [];
1612
    };
1613
    /**
1614
     * @param {?} typeOrFunc
1615
     * @param {?} parentCtor
1616
     * @return {?}
1617
     */
1618
    ReflectionCapabilities.prototype._ownAnnotations = function (typeOrFunc, parentCtor) {
1619
        // Prefer the direct API.
1620
        if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
1621
            var /** @type {?} */ annotations = ((typeOrFunc)).annotations;
1622
            if (typeof annotations === 'function' && annotations.annotations) {
1623
                annotations = annotations.annotations;
1624
            }
1625
            return annotations;
1626
        }
1627
        // API of tsickle for lowering decorators to properties on the class.
1628
        if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
1629
            return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
1630
        }
1631
        // API for metadata created by invoking the decorators.
1632
        if (this._reflect && this._reflect.getOwnMetadata) {
1633
            return this._reflect.getOwnMetadata('annotations', typeOrFunc);
1634
        }
1635
        return null;
1636
    };
1637
    /**
1638
     * @param {?} typeOrFunc
1639
     * @return {?}
1640
     */
1641
    ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
1642
        if (!isType(typeOrFunc)) {
1643
            return [];
1644
        }
1645
        var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1646
        var /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
1647
        var /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
1648
        return parentAnnotations.concat(ownAnnotations);
1649
    };
1650
    /**
1651
     * @param {?} typeOrFunc
1652
     * @param {?} parentCtor
1653
     * @return {?}
1654
     */
1655
    ReflectionCapabilities.prototype._ownPropMetadata = function (typeOrFunc, parentCtor) {
1656
        // Prefer the direct API.
1657
        if (((typeOrFunc)).propMetadata &&
1658
            ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
1659
            var /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
1660
            if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
1661
                propMetadata = propMetadata.propMetadata;
1662
            }
1663
            return propMetadata;
1664
        }
1665
        // API of tsickle for lowering decorators to properties on the class.
1666
        if (((typeOrFunc)).propDecorators &&
1667
            ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
1668
            var /** @type {?} */ propDecorators_1 = ((typeOrFunc)).propDecorators;
1669
            var /** @type {?} */ propMetadata_1 = ({});
1670
            Object.keys(propDecorators_1).forEach(function (prop) {
1671
                propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]);
1672
            });
1673
            return propMetadata_1;
1674
        }
1675
        // API for metadata created by invoking the decorators.
1676
        if (this._reflect && this._reflect.getOwnMetadata) {
1677
            return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
1678
        }
1679
        return null;
1680
    };
1681
    /**
1682
     * @param {?} typeOrFunc
1683
     * @return {?}
1684
     */
1685
    ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) {
1686
        if (!isType(typeOrFunc)) {
1687
            return {};
1688
        }
1689
        var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
1690
        var /** @type {?} */ propMetadata = {};
1691
        if (parentCtor !== Object) {
1692
            var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentCtor);
1693
            Object.keys(parentPropMetadata_1).forEach(function (propName) {
1694
                propMetadata[propName] = parentPropMetadata_1[propName];
1695
            });
1696
        }
1697
        var /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
1698
        if (ownPropMetadata) {
1699
            Object.keys(ownPropMetadata).forEach(function (propName) {
1700
                var /** @type {?} */ decorators = [];
1701
                if (propMetadata.hasOwnProperty(propName)) {
1702
                    decorators.push.apply(decorators, propMetadata[propName]);
1703
                }
1704
                decorators.push.apply(decorators, ownPropMetadata[propName]);
1705
                propMetadata[propName] = decorators;
1706
            });
1707
        }
1708
        return propMetadata;
1709
    };
1710
    /**
1711
     * @param {?} type
1712
     * @param {?} lcProperty
1713
     * @return {?}
1714
     */
1715
    ReflectionCapabilities.prototype.hasLifecycleHook = function (type, lcProperty) {
1716
        return type instanceof Type && lcProperty in type.prototype;
1717
    };
1718
    /**
1719
     * @param {?} name
1720
     * @return {?}
1721
     */
1722
    ReflectionCapabilities.prototype.getter = function (name) { return (new Function('o', 'return o.' + name + ';')); };
1723
    /**
1724
     * @param {?} name
1725
     * @return {?}
1726
     */
1727
    ReflectionCapabilities.prototype.setter = function (name) {
1728
        return (new Function('o', 'v', 'return o.' + name + ' = v;'));
1729
    };
1730
    /**
1731
     * @param {?} name
1732
     * @return {?}
1733
     */
1734
    ReflectionCapabilities.prototype.method = function (name) {
1735
        var /** @type {?} */ functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n        return o." + name + ".apply(o, args);";
1736
        return (new Function('o', 'args', functionBody));
1737
    };
1738
    /**
1739
     * @param {?} type
1740
     * @return {?}
1741
     */
1742
    ReflectionCapabilities.prototype.importUri = function (type) {
1743
        // StaticSymbol
1744
        if (typeof type === 'object' && type['filePath']) {
1745
            return type['filePath'];
1746
        }
1747
        // Runtime type
1748
        return "./" + stringify(type);
1749
    };
1750
    /**
1751
     * @param {?} type
1752
     * @return {?}
1753
     */
1754
    ReflectionCapabilities.prototype.resourceUri = function (type) { return "./" + stringify(type); };
1755
    /**
1756
     * @param {?} name
1757
     * @param {?} moduleUrl
1758
     * @param {?} members
1759
     * @param {?} runtime
1760
     * @return {?}
1761
     */
1762
    ReflectionCapabilities.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
1763
        return runtime;
1764
    };
1765
    /**
1766
     * @param {?} enumIdentifier
1767
     * @param {?} name
1768
     * @return {?}
1769
     */
1770
    ReflectionCapabilities.prototype.resolveEnum = function (enumIdentifier, name) { return enumIdentifier[name]; };
1771
    return ReflectionCapabilities;
1772
}());
1773
/**
1774
 * @param {?} decoratorInvocations
1775
 * @return {?}
1776
 */
1777
function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
1778
    if (!decoratorInvocations) {
1779
        return [];
1780
    }
1781
    return decoratorInvocations.map(function (decoratorInvocation) {
1782
        var /** @type {?} */ decoratorType = decoratorInvocation.type;
1783
        var /** @type {?} */ annotationCls = decoratorType.annotationCls;
1784
        var /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
1785
        return new (annotationCls.bind.apply(annotationCls, [void 0].concat(annotationArgs)))();
1786
    });
1787
}
1788
/**
1789
 * @param {?} ctor
1790
 * @return {?}
1791
 */
1792
function getParentCtor(ctor) {
1793
    var /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
1794
    var /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
1795
    // Note: We always use `Object` as the null value
1796
    // to simplify checking later on.
1797
    return parentCtor || Object;
1798
}
1799
/**
1800
 * @license
1801
 * Copyright Google Inc. All Rights Reserved.
1802
 *
1803
 * Use of this source code is governed by an MIT-style license that can be
1804
 * found in the LICENSE file at https://angular.io/license
1805
 */
1806
/**
1807
 * Provides access to reflection data about symbols. Used internally by Angular
1808
 * to power dependency injection and compilation.
1809
 */
1810
var Reflector = (function () {
1811
    /**
1812
     * @param {?} reflectionCapabilities
1813
     */
1814
    function Reflector(reflectionCapabilities) {
1815
        this.reflectionCapabilities = reflectionCapabilities;
1816
    }
1817
    /**
1818
     * @param {?} caps
1819
     * @return {?}
1820
     */
1821
    Reflector.prototype.updateCapabilities = function (caps) { this.reflectionCapabilities = caps; };
1822
    /**
1823
     * @param {?} type
1824
     * @return {?}
1825
     */
1826
    Reflector.prototype.factory = function (type) { return this.reflectionCapabilities.factory(type); };
1827
    /**
1828
     * @param {?} typeOrFunc
1829
     * @return {?}
1830
     */
1831
    Reflector.prototype.parameters = function (typeOrFunc) {
1832
        return this.reflectionCapabilities.parameters(typeOrFunc);
1833
    };
1834
    /**
1835
     * @param {?} typeOrFunc
1836
     * @return {?}
1837
     */
1838
    Reflector.prototype.annotations = function (typeOrFunc) {
1839
        return this.reflectionCapabilities.annotations(typeOrFunc);
1840
    };
1841
    /**
1842
     * @param {?} typeOrFunc
1843
     * @return {?}
1844
     */
1845
    Reflector.prototype.propMetadata = function (typeOrFunc) {
1846
        return this.reflectionCapabilities.propMetadata(typeOrFunc);
1847
    };
1848
    /**
1849
     * @param {?} type
1850
     * @param {?} lcProperty
1851
     * @return {?}
1852
     */
1853
    Reflector.prototype.hasLifecycleHook = function (type, lcProperty) {
1854
        return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
1855
    };
1856
    /**
1857
     * @param {?} name
1858
     * @return {?}
1859
     */
1860
    Reflector.prototype.getter = function (name) { return this.reflectionCapabilities.getter(name); };
1861
    /**
1862
     * @param {?} name
1863
     * @return {?}
1864
     */
1865
    Reflector.prototype.setter = function (name) { return this.reflectionCapabilities.setter(name); };
1866
    /**
1867
     * @param {?} name
1868
     * @return {?}
1869
     */
1870
    Reflector.prototype.method = function (name) { return this.reflectionCapabilities.method(name); };
1871
    /**
1872
     * @param {?} type
1873
     * @return {?}
1874
     */
1875
    Reflector.prototype.importUri = function (type) { return this.reflectionCapabilities.importUri(type); };
1876
    /**
1877
     * @param {?} type
1878
     * @return {?}
1879
     */
1880
    Reflector.prototype.resourceUri = function (type) { return this.reflectionCapabilities.resourceUri(type); };
1881
    /**
1882
     * @param {?} name
1883
     * @param {?} moduleUrl
1884
     * @param {?} members
1885
     * @param {?} runtime
1886
     * @return {?}
1887
     */
1888
    Reflector.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
1889
        return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
1890
    };
1891
    /**
1892
     * @param {?} identifier
1893
     * @param {?} name
1894
     * @return {?}
1895
     */
1896
    Reflector.prototype.resolveEnum = function (identifier, name) {
1897
        return this.reflectionCapabilities.resolveEnum(identifier, name);
1898
    };
1899
    return Reflector;
1900
}());
1901
/**
1902
 * @license
1903
 * Copyright Google Inc. All Rights Reserved.
1904
 *
1905
 * Use of this source code is governed by an MIT-style license that can be
1906
 * found in the LICENSE file at https://angular.io/license
1907
 */
1908
/**
1909
 * The {\@link Reflector} used internally in Angular to access metadata
1910
 * about symbols.
1911
 */
1912
var reflector = new Reflector(new ReflectionCapabilities());
1913
/**
1914
 * @license
1915
 * Copyright Google Inc. All Rights Reserved.
1916
 *
1917
 * Use of this source code is governed by an MIT-style license that can be
1918
 * found in the LICENSE file at https://angular.io/license
1919
 */
1920
/**
1921
 * `Dependency` is used by the framework to extend DI.
1922
 * This is internal to Angular and should not be used directly.
1923
 */
1924
var ReflectiveDependency = (function () {
1925
    /**
1926
     * @param {?} key
1927
     * @param {?} optional
1928
     * @param {?} visibility
1929
     */
1930
    function ReflectiveDependency(key, optional, visibility) {
1931
        this.key = key;
1932
        this.optional = optional;
1933
        this.visibility = visibility;
1934
    }
1935
    /**
1936
     * @param {?} key
1937
     * @return {?}
1938
     */
1939
    ReflectiveDependency.fromKey = function (key) {
1940
        return new ReflectiveDependency(key, false, null);
1941
    };
1942
    return ReflectiveDependency;
1943
}());
1944
var _EMPTY_LIST = [];
1945
var ResolvedReflectiveProvider_ = (function () {
1946
    /**
1947
     * @param {?} key
1948
     * @param {?} resolvedFactories
1949
     * @param {?} multiProvider
1950
     */
1951
    function ResolvedReflectiveProvider_(key, resolvedFactories, multiProvider) {
1952
        this.key = key;
1953
        this.resolvedFactories = resolvedFactories;
1954
        this.multiProvider = multiProvider;
1955
    }
1956
    Object.defineProperty(ResolvedReflectiveProvider_.prototype, "resolvedFactory", {
1957
        /**
1958
         * @return {?}
1959
         */
1960
        get: function () { return this.resolvedFactories[0]; },
1961
        enumerable: true,
1962
        configurable: true
1963
    });
1964
    return ResolvedReflectiveProvider_;
1965
}());
1966
/**
1967
 * An internal resolved representation of a factory function created by resolving {\@link
1968
 * Provider}.
1969
 * \@experimental
1970
 */
1971
var ResolvedReflectiveFactory = (function () {
1972
    /**
1973
     * @param {?} factory
1974
     * @param {?} dependencies
1975
     */
1976
    function ResolvedReflectiveFactory(factory, dependencies) {
1977
        this.factory = factory;
1978
        this.dependencies = dependencies;
1979
    }
1980
    return ResolvedReflectiveFactory;
1981
}());
1982
/**
1983
 * Resolve a single provider.
1984
 * @param {?} provider
1985
 * @return {?}
1986
 */
1987
function resolveReflectiveFactory(provider) {
1988
    var /** @type {?} */ factoryFn;
1989
    var /** @type {?} */ resolvedDeps;
1990
    if (provider.useClass) {
1991
        var /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
1992
        factoryFn = reflector.factory(useClass);
1993
        resolvedDeps = _dependenciesFor(useClass);
1994
    }
1995
    else if (provider.useExisting) {
1996
        factoryFn = function (aliasInstance) { return aliasInstance; };
1997
        resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
1998
    }
1999
    else if (provider.useFactory) {
2000
        factoryFn = provider.useFactory;
2001
        resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
2002
    }
2003
    else {
2004
        factoryFn = function () { return provider.useValue; };
2005
        resolvedDeps = _EMPTY_LIST;
2006
    }
2007
    return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
2008
}
2009
/**
2010
 * Converts the {\@link Provider} into {\@link ResolvedProvider}.
2011
 *
2012
 * {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
2013
 * convenience provider syntax.
2014
 * @param {?} provider
2015
 * @return {?}
2016
 */
2017
function resolveReflectiveProvider(provider) {
2018
    return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
2019
}
2020
/**
2021
 * Resolve a list of Providers.
2022
 * @param {?} providers
2023
 * @return {?}
2024
 */
2025
function resolveReflectiveProviders(providers) {
2026
    var /** @type {?} */ normalized = _normalizeProviders(providers, []);
2027
    var /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
2028
    var /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
2029
    return Array.from(resolvedProviderMap.values());
2030
}
2031
/**
2032
 * Merges a list of ResolvedProviders into a list where
2033
 * each key is contained exactly once and multi providers
2034
 * have been merged.
2035
 * @param {?} providers
2036
 * @param {?} normalizedProvidersMap
2037
 * @return {?}
2038
 */
2039
function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
2040
    for (var /** @type {?} */ i = 0; i < providers.length; i++) {
2041
        var /** @type {?} */ provider = providers[i];
2042
        var /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
2043
        if (existing) {
2044
            if (provider.multiProvider !== existing.multiProvider) {
2045
                throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
2046
            }
2047
            if (provider.multiProvider) {
2048
                for (var /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
2049
                    existing.resolvedFactories.push(provider.resolvedFactories[j]);
2050
                }
2051
            }
2052
            else {
2053
                normalizedProvidersMap.set(provider.key.id, provider);
2054
            }
2055
        }
2056
        else {
2057
            var /** @type {?} */ resolvedProvider = void 0;
2058
            if (provider.multiProvider) {
2059
                resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
2060
            }
2061
            else {
2062
                resolvedProvider = provider;
2063
            }
2064
            normalizedProvidersMap.set(provider.key.id, resolvedProvider);
2065
        }
2066
    }
2067
    return normalizedProvidersMap;
2068
}
2069
/**
2070
 * @param {?} providers
2071
 * @param {?} res
2072
 * @return {?}
2073
 */
2074
function _normalizeProviders(providers, res) {
2075
    providers.forEach(function (b) {
2076
        if (b instanceof Type) {
2077
            res.push({ provide: b, useClass: b });
2078
        }
2079
        else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
2080
            res.push(/** @type {?} */ (b));
2081
        }
2082
        else if (b instanceof Array) {
2083
            _normalizeProviders(b, res);
2084
        }
2085
        else {
2086
            throw invalidProviderError(b);
2087
        }
2088
    });
2089
    return res;
2090
}
2091
/**
2092
 * @param {?} typeOrFunc
2093
 * @param {?=} dependencies
2094
 * @return {?}
2095
 */
2096
function constructDependencies(typeOrFunc, dependencies) {
2097
    if (!dependencies) {
2098
        return _dependenciesFor(typeOrFunc);
2099
    }
2100
    else {
2101
        var /** @type {?} */ params_1 = dependencies.map(function (t) { return [t]; });
2102
        return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params_1); });
2103
    }
2104
}
2105
/**
2106
 * @param {?} typeOrFunc
2107
 * @return {?}
2108
 */
2109
function _dependenciesFor(typeOrFunc) {
2110
    var /** @type {?} */ params = reflector.parameters(typeOrFunc);
2111
    if (!params)
2112
        return [];
2113
    if (params.some(function (p) { return p == null; })) {
2114
        throw noAnnotationError(typeOrFunc, params);
2115
    }
2116
    return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
2117
}
2118
/**
2119
 * @param {?} typeOrFunc
2120
 * @param {?} metadata
2121
 * @param {?} params
2122
 * @return {?}
2123
 */
2124
function _extractToken(typeOrFunc, metadata, params) {
2125
    var /** @type {?} */ token = null;
2126
    var /** @type {?} */ optional = false;
2127
    if (!Array.isArray(metadata)) {
2128
        if (metadata instanceof Inject) {
2129
            return _createDependency(metadata.token, optional, null);
2130
        }
2131
        else {
2132
            return _createDependency(metadata, optional, null);
2133
        }
2134
    }
2135
    var /** @type {?} */ visibility = null;
2136
    for (var /** @type {?} */ i = 0; i < metadata.length; ++i) {
2137
        var /** @type {?} */ paramMetadata = metadata[i];
2138
        if (paramMetadata instanceof Type) {
2139
            token = paramMetadata;
2140
        }
2141
        else if (paramMetadata instanceof Inject) {
2142
            token = paramMetadata.token;
2143
        }
2144
        else if (paramMetadata instanceof Optional) {
2145
            optional = true;
2146
        }
2147
        else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
2148
            visibility = paramMetadata;
2149
        }
2150
        else if (paramMetadata instanceof InjectionToken) {
2151
            token = paramMetadata;
2152
        }
2153
    }
2154
    token = resolveForwardRef(token);
2155
    if (token != null) {
2156
        return _createDependency(token, optional, visibility);
2157
    }
2158
    else {
2159
        throw noAnnotationError(typeOrFunc, params);
2160
    }
2161
}
2162
/**
2163
 * @param {?} token
2164
 * @param {?} optional
2165
 * @param {?} visibility
2166
 * @return {?}
2167
 */
2168
function _createDependency(token, optional, visibility) {
2169
    return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
2170
}
2171
/**
2172
 * @license
2173
 * Copyright Google Inc. All Rights Reserved.
2174
 *
2175
 * Use of this source code is governed by an MIT-style license that can be
2176
 * found in the LICENSE file at https://angular.io/license
2177
 */
2178
// Threshold for the dynamic version
2179
var UNDEFINED = new Object();
2180
/**
2181
 * A ReflectiveDependency injection container used for instantiating objects and resolving
2182
 * dependencies.
2183
 *
2184
 * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
2185
 * constructor dependencies.
2186
 *
2187
 * In typical use, application code asks for the dependencies in the constructor and they are
2188
 * resolved by the `Injector`.
2189
 *
2190
 * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
2191
 *
2192
 * The following example creates an `Injector` configured to create `Engine` and `Car`.
2193
 *
2194
 * ```typescript
2195
 * \@Injectable()
2196
 * class Engine {
2197
 * }
2198
 *
2199
 * \@Injectable()
2200
 * class Car {
2201
 *   constructor(public engine:Engine) {}
2202
 * }
2203
 *
2204
 * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2205
 * var car = injector.get(Car);
2206
 * expect(car instanceof Car).toBe(true);
2207
 * expect(car.engine instanceof Engine).toBe(true);
2208
 * ```
2209
 *
2210
 * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
2211
 * resolve all of the object's dependencies automatically.
2212
 *
2213
 * \@stable
2214
 * @abstract
2215
 */
2216
var ReflectiveInjector = (function () {
2217
    function ReflectiveInjector() {
2218
    }
2219
    /**
2220
     * Turns an array of provider definitions into an array of resolved providers.
2221
     *
2222
     * A resolution is a process of flattening multiple nested arrays and converting individual
2223
     * providers into an array of {\@link ResolvedReflectiveProvider}s.
2224
     *
2225
     * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
2226
     *
2227
     * ```typescript
2228
     * \@Injectable()
2229
     * class Engine {
2230
     * }
2231
     *
2232
     * \@Injectable()
2233
     * class Car {
2234
     *   constructor(public engine:Engine) {}
2235
     * }
2236
     *
2237
     * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
2238
     *
2239
     * expect(providers.length).toEqual(2);
2240
     *
2241
     * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
2242
     * expect(providers[0].key.displayName).toBe("Car");
2243
     * expect(providers[0].dependencies.length).toEqual(1);
2244
     * expect(providers[0].factory).toBeDefined();
2245
     *
2246
     * expect(providers[1].key.displayName).toBe("Engine");
2247
     * });
2248
     * ```
2249
     *
2250
     * See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
2251
     * @param {?} providers
2252
     * @return {?}
2253
     */
2254
    ReflectiveInjector.resolve = function (providers) {
2255
        return resolveReflectiveProviders(providers);
2256
    };
2257
    /**
2258
     * Resolves an array of providers and creates an injector from those providers.
2259
     *
2260
     * The passed-in providers can be an array of `Type`, {\@link Provider},
2261
     * or a recursive array of more providers.
2262
     *
2263
     * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
2264
     *
2265
     * ```typescript
2266
     * \@Injectable()
2267
     * class Engine {
2268
     * }
2269
     *
2270
     * \@Injectable()
2271
     * class Car {
2272
     *   constructor(public engine:Engine) {}
2273
     * }
2274
     *
2275
     * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
2276
     * expect(injector.get(Car) instanceof Car).toBe(true);
2277
     * ```
2278
     *
2279
     * This function is slower than the corresponding `fromResolvedProviders`
2280
     * because it needs to resolve the passed-in providers first.
2281
     * See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#fromResolvedProviders}.
2282
     * @param {?} providers
2283
     * @param {?=} parent
2284
     * @return {?}
2285
     */
2286
    ReflectiveInjector.resolveAndCreate = function (providers, parent) {
2287
        var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2288
        return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
2289
    };
2290
    /**
2291
     * Creates an injector from previously resolved providers.
2292
     *
2293
     * This API is the recommended way to construct injectors in performance-sensitive parts.
2294
     *
2295
     * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
2296
     *
2297
     * ```typescript
2298
     * \@Injectable()
2299
     * class Engine {
2300
     * }
2301
     *
2302
     * \@Injectable()
2303
     * class Car {
2304
     *   constructor(public engine:Engine) {}
2305
     * }
2306
     *
2307
     * var providers = ReflectiveInjector.resolve([Car, Engine]);
2308
     * var injector = ReflectiveInjector.fromResolvedProviders(providers);
2309
     * expect(injector.get(Car) instanceof Car).toBe(true);
2310
     * ```
2311
     * \@experimental
2312
     * @param {?} providers
2313
     * @param {?=} parent
2314
     * @return {?}
2315
     */
2316
    ReflectiveInjector.fromResolvedProviders = function (providers, parent) {
2317
        return new ReflectiveInjector_(providers, parent);
2318
    };
2319
    /**
2320
     * Parent of this injector.
2321
     *
2322
     * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2323
     * -->
2324
     *
2325
     * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
2326
     *
2327
     * ```typescript
2328
     * var parent = ReflectiveInjector.resolveAndCreate([]);
2329
     * var child = parent.resolveAndCreateChild([]);
2330
     * expect(child.parent).toBe(parent);
2331
     * ```
2332
     * @abstract
2333
     * @return {?}
2334
     */
2335
    ReflectiveInjector.prototype.parent = function () { };
2336
    /**
2337
     * Resolves an array of providers and creates a child injector from those providers.
2338
     *
2339
     * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2340
     * -->
2341
     *
2342
     * The passed-in providers can be an array of `Type`, {\@link Provider},
2343
     * or a recursive array of more providers.
2344
     *
2345
     * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
2346
     *
2347
     * ```typescript
2348
     * class ParentProvider {}
2349
     * class ChildProvider {}
2350
     *
2351
     * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
2352
     * var child = parent.resolveAndCreateChild([ChildProvider]);
2353
     *
2354
     * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2355
     * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2356
     * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2357
     * ```
2358
     *
2359
     * This function is slower than the corresponding `createChildFromResolved`
2360
     * because it needs to resolve the passed-in providers first.
2361
     * See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#createChildFromResolved}.
2362
     * @abstract
2363
     * @param {?} providers
2364
     * @return {?}
2365
     */
2366
    ReflectiveInjector.prototype.resolveAndCreateChild = function (providers) { };
2367
    /**
2368
     * Creates a child injector from previously resolved providers.
2369
     *
2370
     * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
2371
     * -->
2372
     *
2373
     * This API is the recommended way to construct injectors in performance-sensitive parts.
2374
     *
2375
     * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
2376
     *
2377
     * ```typescript
2378
     * class ParentProvider {}
2379
     * class ChildProvider {}
2380
     *
2381
     * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
2382
     * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
2383
     *
2384
     * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
2385
     * var child = parent.createChildFromResolved(childProviders);
2386
     *
2387
     * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
2388
     * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
2389
     * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
2390
     * ```
2391
     * @abstract
2392
     * @param {?} providers
2393
     * @return {?}
2394
     */
2395
    ReflectiveInjector.prototype.createChildFromResolved = function (providers) { };
2396
    /**
2397
     * Resolves a provider and instantiates an object in the context of the injector.
2398
     *
2399
     * The created object does not get cached by the injector.
2400
     *
2401
     * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
2402
     *
2403
     * ```typescript
2404
     * \@Injectable()
2405
     * class Engine {
2406
     * }
2407
     *
2408
     * \@Injectable()
2409
     * class Car {
2410
     *   constructor(public engine:Engine) {}
2411
     * }
2412
     *
2413
     * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2414
     *
2415
     * var car = injector.resolveAndInstantiate(Car);
2416
     * expect(car.engine).toBe(injector.get(Engine));
2417
     * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
2418
     * ```
2419
     * @abstract
2420
     * @param {?} provider
2421
     * @return {?}
2422
     */
2423
    ReflectiveInjector.prototype.resolveAndInstantiate = function (provider) { };
2424
    /**
2425
     * Instantiates an object using a resolved provider in the context of the injector.
2426
     *
2427
     * The created object does not get cached by the injector.
2428
     *
2429
     * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
2430
     *
2431
     * ```typescript
2432
     * \@Injectable()
2433
     * class Engine {
2434
     * }
2435
     *
2436
     * \@Injectable()
2437
     * class Car {
2438
     *   constructor(public engine:Engine) {}
2439
     * }
2440
     *
2441
     * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
2442
     * var carProvider = ReflectiveInjector.resolve([Car])[0];
2443
     * var car = injector.instantiateResolved(carProvider);
2444
     * expect(car.engine).toBe(injector.get(Engine));
2445
     * expect(car).not.toBe(injector.instantiateResolved(carProvider));
2446
     * ```
2447
     * @abstract
2448
     * @param {?} provider
2449
     * @return {?}
2450
     */
2451
    ReflectiveInjector.prototype.instantiateResolved = function (provider) { };
2452
    /**
2453
     * @abstract
2454
     * @param {?} token
2455
     * @param {?=} notFoundValue
2456
     * @return {?}
2457
     */
2458
    ReflectiveInjector.prototype.get = function (token, notFoundValue) { };
2459
    return ReflectiveInjector;
2460
}());
2461
var ReflectiveInjector_ = (function () {
2462
    /**
2463
     * Private
2464
     * @param {?} _providers
2465
     * @param {?=} _parent
2466
     */
2467
    function ReflectiveInjector_(_providers, _parent) {
2468
        /**
2469
         * \@internal
2470
         */
2471
        this._constructionCounter = 0;
2472
        this._providers = _providers;
2473
        this._parent = _parent || null;
2474
        var len = _providers.length;
2475
        this.keyIds = new Array(len);
2476
        this.objs = new Array(len);
2477
        for (var i = 0; i < len; i++) {
2478
            this.keyIds[i] = _providers[i].key.id;
2479
            this.objs[i] = UNDEFINED;
2480
        }
2481
    }
2482
    /**
2483
     * @param {?} token
2484
     * @param {?=} notFoundValue
2485
     * @return {?}
2486
     */
2487
    ReflectiveInjector_.prototype.get = function (token, notFoundValue) {
2488
        if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
2489
        return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
2490
    };
2491
    Object.defineProperty(ReflectiveInjector_.prototype, "parent", {
2492
        /**
2493
         * @return {?}
2494
         */
2495
        get: function () { return this._parent; },
2496
        enumerable: true,
2497
        configurable: true
2498
    });
2499
    /**
2500
     * @param {?} providers
2501
     * @return {?}
2502
     */
2503
    ReflectiveInjector_.prototype.resolveAndCreateChild = function (providers) {
2504
        var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
2505
        return this.createChildFromResolved(ResolvedReflectiveProviders);
2506
    };
2507
    /**
2508
     * @param {?} providers
2509
     * @return {?}
2510
     */
2511
    ReflectiveInjector_.prototype.createChildFromResolved = function (providers) {
2512
        var /** @type {?} */ inj = new ReflectiveInjector_(providers);
2513
        inj._parent = this;
2514
        return inj;
2515
    };
2516
    /**
2517
     * @param {?} provider
2518
     * @return {?}
2519
     */
2520
    ReflectiveInjector_.prototype.resolveAndInstantiate = function (provider) {
2521
        return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
2522
    };
2523
    /**
2524
     * @param {?} provider
2525
     * @return {?}
2526
     */
2527
    ReflectiveInjector_.prototype.instantiateResolved = function (provider) {
2528
        return this._instantiateProvider(provider);
2529
    };
2530
    /**
2531
     * @param {?} index
2532
     * @return {?}
2533
     */
2534
    ReflectiveInjector_.prototype.getProviderAtIndex = function (index) {
2535
        if (index < 0 || index >= this._providers.length) {
2536
            throw outOfBoundsError(index);
2537
        }
2538
        return this._providers[index];
2539
    };
2540
    /**
2541
     * \@internal
2542
     * @param {?} provider
2543
     * @return {?}
2544
     */
2545
    ReflectiveInjector_.prototype._new = function (provider) {
2546
        if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
2547
            throw cyclicDependencyError(this, provider.key);
2548
        }
2549
        return this._instantiateProvider(provider);
2550
    };
2551
    /**
2552
     * @return {?}
2553
     */
2554
    ReflectiveInjector_.prototype._getMaxNumberOfObjects = function () { return this.objs.length; };
2555
    /**
2556
     * @param {?} provider
2557
     * @return {?}
2558
     */
2559
    ReflectiveInjector_.prototype._instantiateProvider = function (provider) {
2560
        if (provider.multiProvider) {
2561
            var /** @type {?} */ res = new Array(provider.resolvedFactories.length);
2562
            for (var /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
2563
                res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
2564
            }
2565
            return res;
2566
        }
2567
        else {
2568
            return this._instantiate(provider, provider.resolvedFactories[0]);
2569
        }
2570
    };
2571
    /**
2572
     * @param {?} provider
2573
     * @param {?} ResolvedReflectiveFactory
2574
     * @return {?}
2575
     */
2576
    ReflectiveInjector_.prototype._instantiate = function (provider, ResolvedReflectiveFactory$$1) {
2577
        var _this = this;
2578
        var /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
2579
        var /** @type {?} */ deps;
2580
        try {
2581
            deps =
2582
                ResolvedReflectiveFactory$$1.dependencies.map(function (dep) { return _this._getByReflectiveDependency(dep); });
2583
        }
2584
        catch (e) {
2585
            if (e.addKey) {
2586
                e.addKey(this, provider.key);
2587
            }
2588
            throw e;
2589
        }
2590
        var /** @type {?} */ obj;
2591
        try {
2592
            obj = factory.apply(void 0, deps);
2593
        }
2594
        catch (e) {
2595
            throw instantiationError(this, e, e.stack, provider.key);
2596
        }
2597
        return obj;
2598
    };
2599
    /**
2600
     * @param {?} dep
2601
     * @return {?}
2602
     */
2603
    ReflectiveInjector_.prototype._getByReflectiveDependency = function (dep) {
2604
        return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
2605
    };
2606
    /**
2607
     * @param {?} key
2608
     * @param {?} visibility
2609
     * @param {?} notFoundValue
2610
     * @return {?}
2611
     */
2612
    ReflectiveInjector_.prototype._getByKey = function (key, visibility, notFoundValue) {
2613
        if (key === INJECTOR_KEY) {
2614
            return this;
2615
        }
2616
        if (visibility instanceof Self) {
2617
            return this._getByKeySelf(key, notFoundValue);
2618
        }
2619
        else {
2620
            return this._getByKeyDefault(key, notFoundValue, visibility);
2621
        }
2622
    };
2623
    /**
2624
     * @param {?} keyId
2625
     * @return {?}
2626
     */
2627
    ReflectiveInjector_.prototype._getObjByKeyId = function (keyId) {
2628
        for (var /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
2629
            if (this.keyIds[i] === keyId) {
2630
                if (this.objs[i] === UNDEFINED) {
2631
                    this.objs[i] = this._new(this._providers[i]);
2632
                }
2633
                return this.objs[i];
2634
            }
2635
        }
2636
        return UNDEFINED;
2637
    };
2638
    /**
2639
     * \@internal
2640
     * @param {?} key
2641
     * @param {?} notFoundValue
2642
     * @return {?}
2643
     */
2644
    ReflectiveInjector_.prototype._throwOrNull = function (key, notFoundValue) {
2645
        if (notFoundValue !== THROW_IF_NOT_FOUND) {
2646
            return notFoundValue;
2647
        }
2648
        else {
2649
            throw noProviderError(this, key);
2650
        }
2651
    };
2652
    /**
2653
     * \@internal
2654
     * @param {?} key
2655
     * @param {?} notFoundValue
2656
     * @return {?}
2657
     */
2658
    ReflectiveInjector_.prototype._getByKeySelf = function (key, notFoundValue) {
2659
        var /** @type {?} */ obj = this._getObjByKeyId(key.id);
2660
        return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
2661
    };
2662
    /**
2663
     * \@internal
2664
     * @param {?} key
2665
     * @param {?} notFoundValue
2666
     * @param {?} visibility
2667
     * @return {?}
2668
     */
2669
    ReflectiveInjector_.prototype._getByKeyDefault = function (key, notFoundValue, visibility) {
2670
        var /** @type {?} */ inj;
2671
        if (visibility instanceof SkipSelf) {
2672
            inj = this._parent;
2673
        }
2674
        else {
2675
            inj = this;
2676
        }
2677
        while (inj instanceof ReflectiveInjector_) {
2678
            var /** @type {?} */ inj_ = (inj);
2679
            var /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
2680
            if (obj !== UNDEFINED)
2681
                return obj;
2682
            inj = inj_._parent;
2683
        }
2684
        if (inj !== null) {
2685
            return inj.get(key.token, notFoundValue);
2686
        }
2687
        else {
2688
            return this._throwOrNull(key, notFoundValue);
2689
        }
2690
    };
2691
    Object.defineProperty(ReflectiveInjector_.prototype, "displayName", {
2692
        /**
2693
         * @return {?}
2694
         */
2695
        get: function () {
2696
            var /** @type {?} */ providers = _mapProviders(this, function (b) { return ' "' + b.key.displayName + '" '; })
2697
                .join(', ');
2698
            return "ReflectiveInjector(providers: [" + providers + "])";
2699
        },
2700
        enumerable: true,
2701
        configurable: true
2702
    });
2703
    /**
2704
     * @return {?}
2705
     */
2706
    ReflectiveInjector_.prototype.toString = function () { return this.displayName; };
2707
    return ReflectiveInjector_;
2708
}());
2709
var INJECTOR_KEY = ReflectiveKey.get(Injector);
2710
/**
2711
 * @param {?} injector
2712
 * @param {?} fn
2713
 * @return {?}
2714
 */
2715
function _mapProviders(injector, fn) {
2716
    var /** @type {?} */ res = new Array(injector._providers.length);
2717
    for (var /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
2718
        res[i] = fn(injector.getProviderAtIndex(i));
2719
    }
2720
    return res;
2721
}
2722
/**
2723
 * @license
2724
 * Copyright Google Inc. All Rights Reserved.
2725
 *
2726
 * Use of this source code is governed by an MIT-style license that can be
2727
 * found in the LICENSE file at https://angular.io/license
2728
 */
2729
/**
2730
 * @module
2731
 * @description
2732
 * The `di` module provides dependency injection container services.
2733
 */
2734
/**
2735
 * @license
2736
 * Copyright Google Inc. All Rights Reserved.
2737
 *
2738
 * Use of this source code is governed by an MIT-style license that can be
2739
 * found in the LICENSE file at https://angular.io/license
2740
 */
2741
/**
2742
 * Determine if the argument is shaped like a Promise
2743
 * @param {?} obj
2744
 * @return {?}
2745
 */
2746
function isPromise(obj) {
2747
    // allow any Promise/A+ compliant thenable.
2748
    // It's up to the caller to ensure that obj.then conforms to the spec
2749
    return !!obj && typeof obj.then === 'function';
2750
}
2751
/**
2752
 * Determine if the argument is an Observable
2753
 * @param {?} obj
2754
 * @return {?}
2755
 */
2756
function isObservable(obj) {
2757
    // TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
2758
    return !!obj && typeof obj.subscribe === 'function';
2759
}
2760
/**
2761
 * @license
2762
 * Copyright Google Inc. All Rights Reserved.
2763
 *
2764
 * Use of this source code is governed by an MIT-style license that can be
2765
 * found in the LICENSE file at https://angular.io/license
2766
 */
2767
/**
2768
 * A function that will be executed when an application is initialized.
2769
 * \@experimental
2770
 */
2771
var APP_INITIALIZER = new InjectionToken('Application Initializer');
2772
/**
2773
 * A class that reflects the state of running {\@link APP_INITIALIZER}s.
2774
 *
2775
 * \@experimental
2776
 */
2777
var ApplicationInitStatus = (function () {
2778
    /**
2779
     * @param {?} appInits
2780
     */
2781
    function ApplicationInitStatus(appInits) {
2782
        var _this = this;
2783
        this.appInits = appInits;
2784
        this.initialized = false;
2785
        this._done = false;
2786
        this._donePromise = new Promise(function (res, rej) {
2787
            _this.resolve = res;
2788
            _this.reject = rej;
2789
        });
2790
    }
2791
    /**
2792
     * \@internal
2793
     * @return {?}
2794
     */
2795
    ApplicationInitStatus.prototype.runInitializers = function () {
2796
        var _this = this;
2797
        if (this.initialized) {
2798
            return;
2799
        }
2800
        var /** @type {?} */ asyncInitPromises = [];
2801
        var /** @type {?} */ complete = function () {
2802
            _this._done = true;
2803
            _this.resolve();
2804
        };
2805
        if (this.appInits) {
2806
            for (var /** @type {?} */ i = 0; i < this.appInits.length; i++) {
2807
                var /** @type {?} */ initResult = this.appInits[i]();
2808
                if (isPromise(initResult)) {
2809
                    asyncInitPromises.push(initResult);
2810
                }
2811
            }
2812
        }
2813
        Promise.all(asyncInitPromises).then(function () { complete(); }).catch(function (e) { _this.reject(e); });
2814
        if (asyncInitPromises.length === 0) {
2815
            complete();
2816
        }
2817
        this.initialized = true;
2818
    };
2819
    Object.defineProperty(ApplicationInitStatus.prototype, "done", {
2820
        /**
2821
         * @return {?}
2822
         */
2823
        get: function () { return this._done; },
2824
        enumerable: true,
2825
        configurable: true
2826
    });
2827
    Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
2828
        /**
2829
         * @return {?}
2830
         */
2831
        get: function () { return this._donePromise; },
2832
        enumerable: true,
2833
        configurable: true
2834
    });
2835
    return ApplicationInitStatus;
2836
}());
2837
ApplicationInitStatus.decorators = [
2838
    { type: Injectable },
2839
];
2840
/**
2841
 * @nocollapse
2842
 */
2843
ApplicationInitStatus.ctorParameters = function () { return [
2844
    { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
2845
]; };
2846
/**
2847
 * @license
2848
 * Copyright Google Inc. All Rights Reserved.
2849
 *
2850
 * Use of this source code is governed by an MIT-style license that can be
2851
 * found in the LICENSE file at https://angular.io/license
2852
 */
2853
/**
2854
 * A DI Token representing a unique string id assigned to the application by Angular and used
2855
 * primarily for prefixing application attributes and CSS styles when
2856
 * {\@link ViewEncapsulation#Emulated} is being used.
2857
 *
2858
 * If you need to avoid randomly generated value to be used as an application id, you can provide
2859
 * a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
2860
 * using this token.
2861
 * \@experimental
2862
 */
2863
var APP_ID = new InjectionToken('AppId');
2864
/**
2865
 * @return {?}
2866
 */
2867
function _appIdRandomProviderFactory() {
2868
    return "" + _randomChar() + _randomChar() + _randomChar();
2869
}
2870
/**
2871
 * Providers that will generate a random APP_ID_TOKEN.
2872
 * \@experimental
2873
 */
2874
var APP_ID_RANDOM_PROVIDER = {
2875
    provide: APP_ID,
2876
    useFactory: _appIdRandomProviderFactory,
2877
    deps: [],
2878
};
2879
/**
2880
 * @return {?}
2881
 */
2882
function _randomChar() {
2883
    return String.fromCharCode(97 + Math.floor(Math.random() * 25));
2884
}
2885
/**
2886
 * A function that will be executed when a platform is initialized.
2887
 * \@experimental
2888
 */
2889
var PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
2890
/**
2891
 * A token that indicates an opaque platform id.
2892
 * \@experimental
2893
 */
2894
var PLATFORM_ID = new InjectionToken('Platform ID');
2895
/**
2896
 * All callbacks provided via this token will be called for every component that is bootstrapped.
2897
 * Signature of the callback:
2898
 *
2899
 * `(componentRef: ComponentRef) => void`.
2900
 *
2901
 * \@experimental
2902
 */
2903
var APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
2904
/**
2905
 * A token which indicates the root directory of the application
2906
 * \@experimental
2907
 */
2908
var PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
2909
/**
2910
 * @license
2911
 * Copyright Google Inc. All Rights Reserved.
2912
 *
2913
 * Use of this source code is governed by an MIT-style license that can be
2914
 * found in the LICENSE file at https://angular.io/license
2915
 */
2916
var Console = (function () {
2917
    function Console() {
2918
    }
2919
    /**
2920
     * @param {?} message
2921
     * @return {?}
2922
     */
2923
    Console.prototype.log = function (message) {
2924
        // tslint:disable-next-line:no-console
2925
        console.log(message);
2926
    };
2927
    /**
2928
     * @param {?} message
2929
     * @return {?}
2930
     */
2931
    Console.prototype.warn = function (message) {
2932
        // tslint:disable-next-line:no-console
2933
        console.warn(message);
2934
    };
2935
    return Console;
2936
}());
2937
Console.decorators = [
2938
    { type: Injectable },
2939
];
2940
/**
2941
 * @nocollapse
2942
 */
2943
Console.ctorParameters = function () { return []; };
2944
/**
2945
 * @license
2946
 * Copyright Google Inc. All Rights Reserved.
2947
 *
2948
 * Use of this source code is governed by an MIT-style license that can be
2949
 * found in the LICENSE file at https://angular.io/license
2950
 */
2951
/**
2952
 * Combination of NgModuleFactory and ComponentFactorys.
2953
 *
2954
 * \@experimental
2955
 */
2956
var ModuleWithComponentFactories = (function () {
2957
    /**
2958
     * @param {?} ngModuleFactory
2959
     * @param {?} componentFactories
2960
     */
2961
    function ModuleWithComponentFactories(ngModuleFactory, componentFactories) {
2962
        this.ngModuleFactory = ngModuleFactory;
2963
        this.componentFactories = componentFactories;
2964
    }
2965
    return ModuleWithComponentFactories;
2966
}());
2967
/**
2968
 * @return {?}
2969
 */
2970
function _throwError() {
2971
    throw new Error("Runtime compiler is not loaded");
2972
}
2973
/**
2974
 * Low-level service for running the angular compiler during runtime
2975
 * to create {\@link ComponentFactory}s, which
2976
 * can later be used to create and render a Component instance.
2977
 *
2978
 * Each `\@NgModule` provides an own `Compiler` to its injector,
2979
 * that will use the directives/pipes of the ng module for compilation
2980
 * of components.
2981
 * \@stable
2982
 */
2983
var Compiler = (function () {
2984
    function Compiler() {
2985
    }
2986
    /**
2987
     * Compiles the given NgModule and all of its components. All templates of the components listed
2988
     * in `entryComponents` have to be inlined.
2989
     * @template T
2990
     * @param {?} moduleType
2991
     * @return {?}
2992
     */
2993
    Compiler.prototype.compileModuleSync = function (moduleType) { throw _throwError(); };
2994
    /**
2995
     * Compiles the given NgModule and all of its components
2996
     * @template T
2997
     * @param {?} moduleType
2998
     * @return {?}
2999
     */
3000
    Compiler.prototype.compileModuleAsync = function (moduleType) { throw _throwError(); };
3001
    /**
3002
     * Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
3003
     * @template T
3004
     * @param {?} moduleType
3005
     * @return {?}
3006
     */
3007
    Compiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
3008
        throw _throwError();
3009
    };
3010
    /**
3011
     * Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
3012
     * @template T
3013
     * @param {?} moduleType
3014
     * @return {?}
3015
     */
3016
    Compiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
3017
        throw _throwError();
3018
    };
3019
    /**
3020
     * Exposes the CSS-style selectors that have been used in `ngContent` directives within
3021
     * the template of the given component.
3022
     * This is used by the `upgrade` library to compile the appropriate transclude content
3023
     * in the AngularJS wrapper component.
3024
     *
3025
     * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
3026
     * @param {?} component
3027
     * @return {?}
3028
     */
3029
    Compiler.prototype.getNgContentSelectors = function (component) { throw _throwError(); };
3030
    /**
3031
     * Clears all caches.
3032
     * @return {?}
3033
     */
3034
    Compiler.prototype.clearCache = function () { };
3035
    /**
3036
     * Clears the cache for the given component/ngModule.
3037
     * @param {?} type
3038
     * @return {?}
3039
     */
3040
    Compiler.prototype.clearCacheFor = function (type) { };
3041
    return Compiler;
3042
}());
3043
Compiler.decorators = [
3044
    { type: Injectable },
3045
];
3046
/**
3047
 * @nocollapse
3048
 */
3049
Compiler.ctorParameters = function () { return []; };
3050
/**
3051
 * Token to provide CompilerOptions in the platform injector.
3052
 *
3053
 * \@experimental
3054
 */
3055
var COMPILER_OPTIONS = new InjectionToken('compilerOptions');
3056
/**
3057
 * A factory for creating a Compiler
3058
 *
3059
 * \@experimental
3060
 * @abstract
3061
 */
3062
var CompilerFactory = (function () {
3063
    function CompilerFactory() {
3064
    }
3065
    /**
3066
     * @abstract
3067
     * @param {?=} options
3068
     * @return {?}
3069
     */
3070
    CompilerFactory.prototype.createCompiler = function (options) { };
3071
    return CompilerFactory;
3072
}());
3073
/**
3074
 * @license
3075
 * Copyright Google Inc. All Rights Reserved.
3076
 *
3077
 * Use of this source code is governed by an MIT-style license that can be
3078
 * found in the LICENSE file at https://angular.io/license
3079
 */
3080
/**
3081
 * Represents an instance of a Component created via a {\@link ComponentFactory}.
3082
 *
3083
 * `ComponentRef` provides access to the Component Instance as well other objects related to this
3084
 * Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
3085
 * method.
3086
 * \@stable
3087
 * @abstract
3088
 */
3089
var ComponentRef = (function () {
3090
    function ComponentRef() {
3091
    }
3092
    /**
3093
     * Location of the Host Element of this Component Instance.
3094
     * @abstract
3095
     * @return {?}
3096
     */
3097
    ComponentRef.prototype.location = function () { };
3098
    /**
3099
     * The injector on which the component instance exists.
3100
     * @abstract
3101
     * @return {?}
3102
     */
3103
    ComponentRef.prototype.injector = function () { };
3104
    /**
3105
     * The instance of the Component.
3106
     * @abstract
3107
     * @return {?}
3108
     */
3109
    ComponentRef.prototype.instance = function () { };
3110
    /**
3111
     * The {\@link ViewRef} of the Host View of this Component instance.
3112
     * @abstract
3113
     * @return {?}
3114
     */
3115
    ComponentRef.prototype.hostView = function () { };
3116
    /**
3117
     * The {\@link ChangeDetectorRef} of the Component instance.
3118
     * @abstract
3119
     * @return {?}
3120
     */
3121
    ComponentRef.prototype.changeDetectorRef = function () { };
3122
    /**
3123
     * The component type.
3124
     * @abstract
3125
     * @return {?}
3126
     */
3127
    ComponentRef.prototype.componentType = function () { };
3128
    /**
3129
     * Destroys the component instance and all of the data structures associated with it.
3130
     * @abstract
3131
     * @return {?}
3132
     */
3133
    ComponentRef.prototype.destroy = function () { };
3134
    /**
3135
     * Allows to register a callback that will be called when the component is destroyed.
3136
     * @abstract
3137
     * @param {?} callback
3138
     * @return {?}
3139
     */
3140
    ComponentRef.prototype.onDestroy = function (callback) { };
3141
    return ComponentRef;
3142
}());
3143
/**
3144
 * \@stable
3145
 * @abstract
3146
 */
3147
var ComponentFactory = (function () {
3148
    function ComponentFactory() {
3149
    }
3150
    /**
3151
     * @abstract
3152
     * @return {?}
3153
     */
3154
    ComponentFactory.prototype.selector = function () { };
3155
    /**
3156
     * @abstract
3157
     * @return {?}
3158
     */
3159
    ComponentFactory.prototype.componentType = function () { };
3160
    /**
3161
     * selector for all <ng-content> elements in the component.
3162
     * @abstract
3163
     * @return {?}
3164
     */
3165
    ComponentFactory.prototype.ngContentSelectors = function () { };
3166
    /**
3167
     * the inputs of the component.
3168
     * @abstract
3169
     * @return {?}
3170
     */
3171
    ComponentFactory.prototype.inputs = function () { };
3172
    /**
3173
     * the outputs of the component.
3174
     * @abstract
3175
     * @return {?}
3176
     */
3177
    ComponentFactory.prototype.outputs = function () { };
3178
    /**
3179
     * Creates a new component.
3180
     * @abstract
3181
     * @param {?} injector
3182
     * @param {?=} projectableNodes
3183
     * @param {?=} rootSelectorOrNode
3184
     * @param {?=} ngModule
3185
     * @return {?}
3186
     */
3187
    ComponentFactory.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) { };
3188
    return ComponentFactory;
3189
}());
3190
/**
3191
 * @license
3192
 * Copyright Google Inc. All Rights Reserved.
3193
 *
3194
 * Use of this source code is governed by an MIT-style license that can be
3195
 * found in the LICENSE file at https://angular.io/license
3196
 */
3197
/**
3198
 * @param {?} component
3199
 * @return {?}
3200
 */
3201
function noComponentFactoryError(component) {
3202
    var /** @type {?} */ error = Error("No component factory found for " + stringify(component) + ". Did you add it to @NgModule.entryComponents?");
3203
    ((error))[ERROR_COMPONENT] = component;
3204
    return error;
3205
}
3206
var ERROR_COMPONENT = 'ngComponent';
3207
/**
3208
 * @param {?} error
3209
 * @return {?}
3210
 */
3211
var _NullComponentFactoryResolver = (function () {
3212
    function _NullComponentFactoryResolver() {
3213
    }
3214
    /**
3215
     * @template T
3216
     * @param {?} component
3217
     * @return {?}
3218
     */
3219
    _NullComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
3220
        throw noComponentFactoryError(component);
3221
    };
3222
    return _NullComponentFactoryResolver;
3223
}());
3224
/**
3225
 * \@stable
3226
 * @abstract
3227
 */
3228
var ComponentFactoryResolver = (function () {
3229
    function ComponentFactoryResolver() {
3230
    }
3231
    /**
3232
     * @abstract
3233
     * @template T
3234
     * @param {?} component
3235
     * @return {?}
3236
     */
3237
    ComponentFactoryResolver.prototype.resolveComponentFactory = function (component) { };
3238
    return ComponentFactoryResolver;
3239
}());
3240
ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
3241
var CodegenComponentFactoryResolver = (function () {
3242
    /**
3243
     * @param {?} factories
3244
     * @param {?} _parent
3245
     * @param {?} _ngModule
3246
     */
3247
    function CodegenComponentFactoryResolver(factories, _parent, _ngModule) {
3248
        this._parent = _parent;
3249
        this._ngModule = _ngModule;
3250
        this._factories = new Map();
3251
        for (var i = 0; i < factories.length; i++) {
3252
            var factory = factories[i];
3253
            this._factories.set(factory.componentType, factory);
3254
        }
3255
    }
3256
    /**
3257
     * @template T
3258
     * @param {?} component
3259
     * @return {?}
3260
     */
3261
    CodegenComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
3262
        var /** @type {?} */ factory = this._factories.get(component);
3263
        if (!factory && this._parent) {
3264
            factory = this._parent.resolveComponentFactory(component);
3265
        }
3266
        if (!factory) {
3267
            throw noComponentFactoryError(component);
3268
        }
3269
        return new ComponentFactoryBoundToModule(factory, this._ngModule);
3270
    };
3271
    return CodegenComponentFactoryResolver;
3272
}());
3273
var ComponentFactoryBoundToModule = (function (_super) {
3274
    tslib_1.__extends(ComponentFactoryBoundToModule, _super);
3275
    /**
3276
     * @param {?} factory
3277
     * @param {?} ngModule
3278
     */
3279
    function ComponentFactoryBoundToModule(factory, ngModule) {
3280
        var _this = _super.call(this) || this;
3281
        _this.factory = factory;
3282
        _this.ngModule = ngModule;
3283
        return _this;
3284
    }
3285
    Object.defineProperty(ComponentFactoryBoundToModule.prototype, "selector", {
3286
        /**
3287
         * @return {?}
3288
         */
3289
        get: function () { return this.factory.selector; },
3290
        enumerable: true,
3291
        configurable: true
3292
    });
3293
    Object.defineProperty(ComponentFactoryBoundToModule.prototype, "componentType", {
3294
        /**
3295
         * @return {?}
3296
         */
3297
        get: function () { return this.factory.componentType; },
3298
        enumerable: true,
3299
        configurable: true
3300
    });
3301
    Object.defineProperty(ComponentFactoryBoundToModule.prototype, "ngContentSelectors", {
3302
        /**
3303
         * @return {?}
3304
         */
3305
        get: function () { return this.factory.ngContentSelectors; },
3306
        enumerable: true,
3307
        configurable: true
3308
    });
3309
    Object.defineProperty(ComponentFactoryBoundToModule.prototype, "inputs", {
3310
        /**
3311
         * @return {?}
3312
         */
3313
        get: function () { return this.factory.inputs; },
3314
        enumerable: true,
3315
        configurable: true
3316
    });
3317
    Object.defineProperty(ComponentFactoryBoundToModule.prototype, "outputs", {
3318
        /**
3319
         * @return {?}
3320
         */
3321
        get: function () { return this.factory.outputs; },
3322
        enumerable: true,
3323
        configurable: true
3324
    });
3325
    /**
3326
     * @param {?} injector
3327
     * @param {?=} projectableNodes
3328
     * @param {?=} rootSelectorOrNode
3329
     * @param {?=} ngModule
3330
     * @return {?}
3331
     */
3332
    ComponentFactoryBoundToModule.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
3333
        return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
3334
    };
3335
    return ComponentFactoryBoundToModule;
3336
}(ComponentFactory));
3337
/**
3338
 * @license
3339
 * Copyright Google Inc. All Rights Reserved.
3340
 *
3341
 * Use of this source code is governed by an MIT-style license that can be
3342
 * found in the LICENSE file at https://angular.io/license
3343
 */
3344
/**
3345
 * Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
3346
 *
3347
 * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
3348
 * NgModule Instance.
3349
 *
3350
 * \@stable
3351
 * @abstract
3352
 */
3353
var NgModuleRef = (function () {
3354
    function NgModuleRef() {
3355
    }
3356
    /**
3357
     * The injector that contains all of the providers of the NgModule.
3358
     * @abstract
3359
     * @return {?}
3360
     */
3361
    NgModuleRef.prototype.injector = function () { };
3362
    /**
3363
     * The ComponentFactoryResolver to get hold of the ComponentFactories
3364
     * declared in the `entryComponents` property of the module.
3365
     * @abstract
3366
     * @return {?}
3367
     */
3368
    NgModuleRef.prototype.componentFactoryResolver = function () { };
3369
    /**
3370
     * The NgModule instance.
3371
     * @abstract
3372
     * @return {?}
3373
     */
3374
    NgModuleRef.prototype.instance = function () { };
3375
    /**
3376
     * Destroys the module instance and all of the data structures associated with it.
3377
     * @abstract
3378
     * @return {?}
3379
     */
3380
    NgModuleRef.prototype.destroy = function () { };
3381
    /**
3382
     * Allows to register a callback that will be called when the module is destroyed.
3383
     * @abstract
3384
     * @param {?} callback
3385
     * @return {?}
3386
     */
3387
    NgModuleRef.prototype.onDestroy = function (callback) { };
3388
    return NgModuleRef;
3389
}());
3390
/**
3391
 * \@experimental
3392
 * @abstract
3393
 */
3394
var NgModuleFactory = (function () {
3395
    function NgModuleFactory() {
3396
    }
3397
    /**
3398
     * @abstract
3399
     * @return {?}
3400
     */
3401
    NgModuleFactory.prototype.moduleType = function () { };
3402
    /**
3403
     * @abstract
3404
     * @param {?} parentInjector
3405
     * @return {?}
3406
     */
3407
    NgModuleFactory.prototype.create = function (parentInjector) { };
3408
    return NgModuleFactory;
3409
}());
3410
/**
3411
 * @license
3412
 * Copyright Google Inc. All Rights Reserved.
3413
 *
3414
 * Use of this source code is governed by an MIT-style license that can be
3415
 * found in the LICENSE file at https://angular.io/license
3416
 */
3417
var trace;
3418
var events;
3419
/**
3420
 * @return {?}
3421
 */
3422
function detectWTF() {
3423
    var /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
3424
    if (wtf) {
3425
        trace = wtf['trace'];
3426
        if (trace) {
3427
            events = trace['events'];
3428
            return true;
3429
        }
3430
    }
3431
    return false;
3432
}
3433
/**
3434
 * @param {?} signature
3435
 * @param {?=} flags
3436
 * @return {?}
3437
 */
3438
function createScope$1(signature, flags) {
3439
    if (flags === void 0) { flags = null; }
3440
    return events.createScope(signature, flags);
3441
}
3442
/**
3443
 * @template T
3444
 * @param {?} scope
3445
 * @param {?=} returnValue
3446
 * @return {?}
3447
 */
3448
function leave(scope, returnValue) {
3449
    trace.leaveScope(scope, returnValue);
3450
    return returnValue;
3451
}
3452
/**
3453
 * @param {?} rangeType
3454
 * @param {?} action
3455
 * @return {?}
3456
 */
3457
function startTimeRange(rangeType, action) {
3458
    return trace.beginTimeRange(rangeType, action);
3459
}
3460
/**
3461
 * @param {?} range
3462
 * @return {?}
3463
 */
3464
function endTimeRange(range) {
3465
    trace.endTimeRange(range);
3466
}
3467
/**
3468
 * @license
3469
 * Copyright Google Inc. All Rights Reserved.
3470
 *
3471
 * Use of this source code is governed by an MIT-style license that can be
3472
 * found in the LICENSE file at https://angular.io/license
3473
 */
3474
/**
3475
 * True if WTF is enabled.
3476
 */
3477
var wtfEnabled = detectWTF();
3478
/**
3479
 * @param {?=} arg0
3480
 * @param {?=} arg1
3481
 * @return {?}
3482
 */
3483
function noopScope(arg0, arg1) {
3484
    return null;
3485
}
3486
/**
3487
 * Create trace scope.
3488
 *
3489
 * Scopes must be strictly nested and are analogous to stack frames, but
3490
 * do not have to follow the stack frames. Instead it is recommended that they follow logical
3491
 * nesting. You may want to use
3492
 * [Event
3493
 * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
3494
 * as they are defined in WTF.
3495
 *
3496
 * Used to mark scope entry. The return value is used to leave the scope.
3497
 *
3498
 *     var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
3499
 *
3500
 *     someMethod() {
3501
 *        var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
3502
 *        // DO SOME WORK HERE
3503
 *        return wtfLeave(s, 123); // Return value 123
3504
 *     }
3505
 *
3506
 * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
3507
 * negatively impact the performance of your application. For this reason we recommend that
3508
 * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
3509
 * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
3510
 * exception, will produce incorrect trace, but presence of exception signifies logic error which
3511
 * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
3512
 * an exception is expected during normal execution while profiling.
3513
 *
3514
 * \@experimental
3515
 */
3516
var wtfCreateScope = wtfEnabled ? createScope$1 : function (signature, flags) { return noopScope; };
3517
/**
3518
 * Used to mark end of Scope.
3519
 *
3520
 * - `scope` to end.
3521
 * - `returnValue` (optional) to be passed to the WTF.
3522
 *
3523
 * Returns the `returnValue for easy chaining.
3524
 * \@experimental
3525
 */
3526
var wtfLeave = wtfEnabled ? leave : function (s, r) { return r; };
3527
/**
3528
 * Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
3529
 * The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
3530
 * enabled.
3531
 *
3532
 *     someMethod() {
3533
 *        var s = wtfStartTimeRange('HTTP:GET', 'some.url');
3534
 *        var future = new Future.delay(5).then((_) {
3535
 *          wtfEndTimeRange(s);
3536
 *        });
3537
 *     }
3538
 * \@experimental
3539
 */
3540
var wtfStartTimeRange = wtfEnabled ? startTimeRange : function (rangeType, action) { return null; };
3541
/**
3542
 * Ends a async time range operation.
3543
 * [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
3544
 * enabled.
3545
 * \@experimental
3546
 */
3547
var wtfEndTimeRange = wtfEnabled ? endTimeRange : function (r) { return null; };
3548
/**
3549
 * @license
3550
 * Copyright Google Inc. All Rights Reserved.
3551
 *
3552
 * Use of this source code is governed by an MIT-style license that can be
3553
 * found in the LICENSE file at https://angular.io/license
3554
 */
3555
/**
3556
 * Use by directives and components to emit custom Events.
3557
 *
3558
 * ### Examples
3559
 *
3560
 * In the following example, `Zippy` alternatively emits `open` and `close` events when its
3561
 * title gets clicked:
3562
 *
3563
 * ```
3564
 * \@Component({
3565
 *   selector: 'zippy',
3566
 *   template: `
3567
 *   <div class="zippy">
3568
 *     <div (click)="toggle()">Toggle</div>
3569
 *     <div [hidden]="!visible">
3570
 *       <ng-content></ng-content>
3571
 *     </div>
3572
 *  </div>`})
3573
 * export class Zippy {
3574
 *   visible: boolean = true;
3575
 *   \@Output() open: EventEmitter<any> = new EventEmitter();
3576
 *   \@Output() close: EventEmitter<any> = new EventEmitter();
3577
 *
3578
 *   toggle() {
3579
 *     this.visible = !this.visible;
3580
 *     if (this.visible) {
3581
 *       this.open.emit(null);
3582
 *     } else {
3583
 *       this.close.emit(null);
3584
 *     }
3585
 *   }
3586
 * }
3587
 * ```
3588
 *
3589
 * The events payload can be accessed by the parameter `$event` on the components output event
3590
 * handler:
3591
 *
3592
 * ```
3593
 * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
3594
 * ```
3595
 *
3596
 * Uses Rx.Observable but provides an adapter to make it work as specified here:
3597
 * https://github.com/jhusain/observable-spec
3598
 *
3599
 * Once a reference implementation of the spec is available, switch to it.
3600
 * \@stable
3601
 */
3602
var EventEmitter = (function (_super) {
3603
    tslib_1.__extends(EventEmitter, _super);
3604
    /**
3605
     * Creates an instance of {\@link EventEmitter}, which depending on `isAsync`,
3606
     * delivers events synchronously or asynchronously.
3607
     *
3608
     * @param {?=} isAsync By default, events are delivered synchronously (default value: `false`).
3609
     * Set to `true` for asynchronous event delivery.
3610
     */
3611
    function EventEmitter(isAsync) {
3612
        if (isAsync === void 0) { isAsync = false; }
3613
        var _this = _super.call(this) || this;
3614
        _this.__isAsync = isAsync;
3615
        return _this;
3616
    }
3617
    /**
3618
     * @param {?=} value
3619
     * @return {?}
3620
     */
3621
    EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
3622
    /**
3623
     * @param {?=} generatorOrNext
3624
     * @param {?=} error
3625
     * @param {?=} complete
3626
     * @return {?}
3627
     */
3628
    EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
3629
        var /** @type {?} */ schedulerFn;
3630
        var /** @type {?} */ errorFn = function (err) { return null; };
3631
        var /** @type {?} */ completeFn = function () { return null; };
3632
        if (generatorOrNext && typeof generatorOrNext === 'object') {
3633
            schedulerFn = this.__isAsync ? function (value) {
3634
                setTimeout(function () { return generatorOrNext.next(value); });
3635
            } : function (value) { generatorOrNext.next(value); };
3636
            if (generatorOrNext.error) {
3637
                errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
3638
                    function (err) { generatorOrNext.error(err); };
3639
            }
3640
            if (generatorOrNext.complete) {
3641
                completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
3642
                    function () { generatorOrNext.complete(); };
3643
            }
3644
        }
3645
        else {
3646
            schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
3647
                function (value) { generatorOrNext(value); };
3648
            if (error) {
3649
                errorFn =
3650
                    this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
3651
            }
3652
            if (complete) {
3653
                completeFn =
3654
                    this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
3655
            }
3656
        }
3657
        return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
3658
    };
3659
    return EventEmitter;
3660
}(Subject));
3661
/**
3662
 * @license
3663
 * Copyright Google Inc. All Rights Reserved.
3664
 *
3665
 * Use of this source code is governed by an MIT-style license that can be
3666
 * found in the LICENSE file at https://angular.io/license
3667
 */
3668
/**
3669
 * An injectable service for executing work inside or outside of the Angular zone.
3670
 *
3671
 * The most common use of this service is to optimize performance when starting a work consisting of
3672
 * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
3673
 * Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
3674
 * can reenter the Angular zone via {\@link #run}.
3675
 *
3676
 * <!-- TODO: add/fix links to:
3677
 *   - docs explaining zones and the use of zones in Angular and change-detection
3678
 *   - link to runOutsideAngular/run (throughout this file!)
3679
 *   -->
3680
 *
3681
 * ### Example
3682
 *
3683
 * ```
3684
 * import {Component, NgZone} from '\@angular/core';
3685
 * import {NgIf} from '\@angular/common';
3686
 *
3687
 * \@Component({
3688
 *   selector: 'ng-zone-demo'.
3689
 *   template: `
3690
 *     <h2>Demo: NgZone</h2>
3691
 *
3692
 *     <p>Progress: {{progress}}%</p>
3693
 *     <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
3694
 *
3695
 *     <button (click)="processWithinAngularZone()">Process within Angular zone</button>
3696
 *     <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
3697
 *   `,
3698
 * })
3699
 * export class NgZoneDemo {
3700
 *   progress: number = 0;
3701
 *   label: string;
3702
 *
3703
 *   constructor(private _ngZone: NgZone) {}
3704
 *
3705
 *   // Loop inside the Angular zone
3706
 *   // so the UI DOES refresh after each setTimeout cycle
3707
 *   processWithinAngularZone() {
3708
 *     this.label = 'inside';
3709
 *     this.progress = 0;
3710
 *     this._increaseProgress(() => console.log('Inside Done!'));
3711
 *   }
3712
 *
3713
 *   // Loop outside of the Angular zone
3714
 *   // so the UI DOES NOT refresh after each setTimeout cycle
3715
 *   processOutsideOfAngularZone() {
3716
 *     this.label = 'outside';
3717
 *     this.progress = 0;
3718
 *     this._ngZone.runOutsideAngular(() => {
3719
 *       this._increaseProgress(() => {
3720
 *       // reenter the Angular zone and display done
3721
 *       this._ngZone.run(() => {console.log('Outside Done!') });
3722
 *     }}));
3723
 *   }
3724
 *
3725
 *   _increaseProgress(doneCallback: () => void) {
3726
 *     this.progress += 1;
3727
 *     console.log(`Current progress: ${this.progress}%`);
3728
 *
3729
 *     if (this.progress < 100) {
3730
 *       window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
3731
 *     } else {
3732
 *       doneCallback();
3733
 *     }
3734
 *   }
3735
 * }
3736
 * ```
3737
 *
3738
 * \@experimental
3739
 */
3740
var NgZone = (function () {
3741
    /**
3742
     * @param {?} __0
3743
     */
3744
    function NgZone(_a) {
3745
        var _b = _a.enableLongStackTrace, enableLongStackTrace = _b === void 0 ? false : _b;
3746
        this.hasPendingMicrotasks = false;
3747
        this.hasPendingMacrotasks = false;
3748
        /**
3749
         * Whether there are no outstanding microtasks or macrotasks.
3750
         */
3751
        this.isStable = true;
3752
        /**
3753
         * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
3754
         */
3755
        this.onUnstable = new EventEmitter(false);
3756
        /**
3757
         * Notifies when there is no more microtasks enqueue in the current VM Turn.
3758
         * This is a hint for Angular to do change detection, which may enqueue more microtasks.
3759
         * For this reason this event can fire multiple times per VM Turn.
3760
         */
3761
        this.onMicrotaskEmpty = new EventEmitter(false);
3762
        /**
3763
         * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
3764
         * implies we are about to relinquish VM turn.
3765
         * This event gets called just once.
3766
         */
3767
        this.onStable = new EventEmitter(false);
3768
        /**
3769
         * Notifies that an error has been delivered.
3770
         */
3771
        this.onError = new EventEmitter(false);
3772
        if (typeof Zone == 'undefined') {
3773
            throw new Error('Angular requires Zone.js prolyfill.');
3774
        }
3775
        Zone.assertZonePatched();
3776
        var self = this;
3777
        self._nesting = 0;
3778
        self._outer = self._inner = Zone.current;
3779
        if (Zone['wtfZoneSpec']) {
3780
            self._inner = self._inner.fork(Zone['wtfZoneSpec']);
3781
        }
3782
        if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
3783
            self._inner = self._inner.fork(Zone['longStackTraceZoneSpec']);
3784
        }
3785
        forkInnerZoneWithAngularBehavior(self);
3786
    }
3787
    /**
3788
     * @return {?}
3789
     */
3790
    NgZone.isInAngularZone = function () { return Zone.current.get('isAngularZone') === true; };
3791
    /**
3792
     * @return {?}
3793
     */
3794
    NgZone.assertInAngularZone = function () {
3795
        if (!NgZone.isInAngularZone()) {
3796
            throw new Error('Expected to be in Angular Zone, but it is not!');
3797
        }
3798
    };
3799
    /**
3800
     * @return {?}
3801
     */
3802
    NgZone.assertNotInAngularZone = function () {
3803
        if (NgZone.isInAngularZone()) {
3804
            throw new Error('Expected to not be in Angular Zone, but it is!');
3805
        }
3806
    };
3807
    /**
3808
     * Executes the `fn` function synchronously within the Angular zone and returns value returned by
3809
     * the function.
3810
     *
3811
     * Running functions via `run` allows you to reenter Angular zone from a task that was executed
3812
     * outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
3813
     *
3814
     * Any future tasks or microtasks scheduled from within this function will continue executing from
3815
     * within the Angular zone.
3816
     *
3817
     * If a synchronous error happens it will be rethrown and not reported via `onError`.
3818
     * @param {?} fn
3819
     * @return {?}
3820
     */
3821
    NgZone.prototype.run = function (fn) { return (((this)))._inner.run(fn); };
3822
    /**
3823
     * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
3824
     * rethrown.
3825
     * @param {?} fn
3826
     * @return {?}
3827
     */
3828
    NgZone.prototype.runGuarded = function (fn) { return (((this)))._inner.runGuarded(fn); };
3829
    /**
3830
     * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
3831
     * the function.
3832
     *
3833
     * Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
3834
     * work that
3835
     * doesn't trigger Angular change-detection or is subject to Angular's error handling.
3836
     *
3837
     * Any future tasks or microtasks scheduled from within this function will continue executing from
3838
     * outside of the Angular zone.
3839
     *
3840
     * Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
3841
     * @param {?} fn
3842
     * @return {?}
3843
     */
3844
    NgZone.prototype.runOutsideAngular = function (fn) { return (((this)))._outer.run(fn); };
3845
    return NgZone;
3846
}());
3847
/**
3848
 * @param {?} zone
3849
 * @return {?}
3850
 */
3851
function checkStable(zone) {
3852
    if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
3853
        try {
3854
            zone._nesting++;
3855
            zone.onMicrotaskEmpty.emit(null);
3856
        }
3857
        finally {
3858
            zone._nesting--;
3859
            if (!zone.hasPendingMicrotasks) {
3860
                try {
3861
                    zone.runOutsideAngular(function () { return zone.onStable.emit(null); });
3862
                }
3863
                finally {
3864
                    zone.isStable = true;
3865
                }
3866
            }
3867
        }
3868
    }
3869
}
3870
/**
3871
 * @param {?} zone
3872
 * @return {?}
3873
 */
3874
function forkInnerZoneWithAngularBehavior(zone) {
3875
    zone._inner = zone._inner.fork({
3876
        name: 'angular',
3877
        properties: /** @type {?} */ ({ 'isAngularZone': true }),
3878
        onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
3879
            try {
3880
                onEnter(zone);
3881
                return delegate.invokeTask(target, task, applyThis, applyArgs);
3882
            }
3883
            finally {
3884
                onLeave(zone);
3885
            }
3886
        },
3887
        onInvoke: function (delegate, current, target, callback, applyThis, applyArgs, source) {
3888
            try {
3889
                onEnter(zone);
3890
                return delegate.invoke(target, callback, applyThis, applyArgs, source);
3891
            }
3892
            finally {
3893
                onLeave(zone);
3894
            }
3895
        },
3896
        onHasTask: function (delegate, current, target, hasTaskState) {
3897
            delegate.hasTask(target, hasTaskState);
3898
            if (current === target) {
3899
                // We are only interested in hasTask events which originate from our zone
3900
                // (A child hasTask event is not interesting to us)
3901
                if (hasTaskState.change == 'microTask') {
3902
                    zone.hasPendingMicrotasks = hasTaskState.microTask;
3903
                    checkStable(zone);
3904
                }
3905
                else if (hasTaskState.change == 'macroTask') {
3906
                    zone.hasPendingMacrotasks = hasTaskState.macroTask;
3907
                }
3908
            }
3909
        },
3910
        onHandleError: function (delegate, current, target, error) {
3911
            delegate.handleError(target, error);
3912
            zone.runOutsideAngular(function () { return zone.onError.emit(error); });
3913
            return false;
3914
        }
3915
    });
3916
}
3917
/**
3918
 * @param {?} zone
3919
 * @return {?}
3920
 */
3921
function onEnter(zone) {
3922
    zone._nesting++;
3923
    if (zone.isStable) {
3924
        zone.isStable = false;
3925
        zone.onUnstable.emit(null);
3926
    }
3927
}
3928
/**
3929
 * @param {?} zone
3930
 * @return {?}
3931
 */
3932
function onLeave(zone) {
3933
    zone._nesting--;
3934
    checkStable(zone);
3935
}
3936
/**
3937
 * @license
3938
 * Copyright Google Inc. All Rights Reserved.
3939
 *
3940
 * Use of this source code is governed by an MIT-style license that can be
3941
 * found in the LICENSE file at https://angular.io/license
3942
 */
3943
/**
3944
 * The Testability service provides testing hooks that can be accessed from
3945
 * the browser and by services such as Protractor. Each bootstrapped Angular
3946
 * application on the page will have an instance of Testability.
3947
 * \@experimental
3948
 */
3949
var Testability = (function () {
3950
    /**
3951
     * @param {?} _ngZone
3952
     */
3953
    function Testability(_ngZone) {
3954
        this._ngZone = _ngZone;
3955
        /**
3956
         * \@internal
3957
         */
3958
        this._pendingCount = 0;
3959
        /**
3960
         * \@internal
3961
         */
3962
        this._isZoneStable = true;
3963
        /**
3964
         * Whether any work was done since the last 'whenStable' callback. This is
3965
         * useful to detect if this could have potentially destabilized another
3966
         * component while it is stabilizing.
3967
         * \@internal
3968
         */
3969
        this._didWork = false;
3970
        /**
3971
         * \@internal
3972
         */
3973
        this._callbacks = [];
3974
        this._watchAngularEvents();
3975
    }
3976
    /**
3977
     * \@internal
3978
     * @return {?}
3979
     */
3980
    Testability.prototype._watchAngularEvents = function () {
3981
        var _this = this;
3982
        this._ngZone.onUnstable.subscribe({
3983
            next: function () {
3984
                _this._didWork = true;
3985
                _this._isZoneStable = false;
3986
            }
3987
        });
3988
        this._ngZone.runOutsideAngular(function () {
3989
            _this._ngZone.onStable.subscribe({
3990
                next: function () {
3991
                    NgZone.assertNotInAngularZone();
3992
                    scheduleMicroTask(function () {
3993
                        _this._isZoneStable = true;
3994
                        _this._runCallbacksIfReady();
3995
                    });
3996
                }
3997
            });
3998
        });
3999
    };
4000
    /**
4001
     * @return {?}
4002
     */
4003
    Testability.prototype.increasePendingRequestCount = function () {
4004
        this._pendingCount += 1;
4005
        this._didWork = true;
4006
        return this._pendingCount;
4007
    };
4008
    /**
4009
     * @return {?}
4010
     */
4011
    Testability.prototype.decreasePendingRequestCount = function () {
4012
        this._pendingCount -= 1;
4013
        if (this._pendingCount < 0) {
4014
            throw new Error('pending async requests below zero');
4015
        }
4016
        this._runCallbacksIfReady();
4017
        return this._pendingCount;
4018
    };
4019
    /**
4020
     * @return {?}
4021
     */
4022
    Testability.prototype.isStable = function () {
4023
        return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
4024
    };
4025
    /**
4026
     * \@internal
4027
     * @return {?}
4028
     */
4029
    Testability.prototype._runCallbacksIfReady = function () {
4030
        var _this = this;
4031
        if (this.isStable()) {
4032
            // Schedules the call backs in a new frame so that it is always async.
4033
            scheduleMicroTask(function () {
4034
                while (_this._callbacks.length !== 0) {
4035
                    (((_this._callbacks.pop())))(_this._didWork);
4036
                }
4037
                _this._didWork = false;
4038
            });
4039
        }
4040
        else {
4041
            // Not Ready
4042
            this._didWork = true;
4043
        }
4044
    };
4045
    /**
4046
     * @param {?} callback
4047
     * @return {?}
4048
     */
4049
    Testability.prototype.whenStable = function (callback) {
4050
        this._callbacks.push(callback);
4051
        this._runCallbacksIfReady();
4052
    };
4053
    /**
4054
     * @return {?}
4055
     */
4056
    Testability.prototype.getPendingRequestCount = function () { return this._pendingCount; };
4057
    /**
4058
     * @deprecated use findProviders
4059
     * @param {?} using
4060
     * @param {?} provider
4061
     * @param {?} exactMatch
4062
     * @return {?}
4063
     */
4064
    Testability.prototype.findBindings = function (using, provider, exactMatch) {
4065
        // TODO(juliemr): implement.
4066
        return [];
4067
    };
4068
    /**
4069
     * @param {?} using
4070
     * @param {?} provider
4071
     * @param {?} exactMatch
4072
     * @return {?}
4073
     */
4074
    Testability.prototype.findProviders = function (using, provider, exactMatch) {
4075
        // TODO(juliemr): implement.
4076
        return [];
4077
    };
4078
    return Testability;
4079
}());
4080
Testability.decorators = [
4081
    { type: Injectable },
4082
];
4083
/**
4084
 * @nocollapse
4085
 */
4086
Testability.ctorParameters = function () { return [
4087
    { type: NgZone, },
4088
]; };
4089
/**
4090
 * A global registry of {\@link Testability} instances for specific elements.
4091
 * \@experimental
4092
 */
4093
var TestabilityRegistry = (function () {
4094
    function TestabilityRegistry() {
4095
        /**
4096
         * \@internal
4097
         */
4098
        this._applications = new Map();
4099
        _testabilityGetter.addToWindow(this);
4100
    }
4101
    /**
4102
     * @param {?} token
4103
     * @param {?} testability
4104
     * @return {?}
4105
     */
4106
    TestabilityRegistry.prototype.registerApplication = function (token, testability) {
4107
        this._applications.set(token, testability);
4108
    };
4109
    /**
4110
     * @param {?} elem
4111
     * @return {?}
4112
     */
4113
    TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem) || null; };
4114
    /**
4115
     * @return {?}
4116
     */
4117
    TestabilityRegistry.prototype.getAllTestabilities = function () { return Array.from(this._applications.values()); };
4118
    /**
4119
     * @return {?}
4120
     */
4121
    TestabilityRegistry.prototype.getAllRootElements = function () { return Array.from(this._applications.keys()); };
4122
    /**
4123
     * @param {?} elem
4124
     * @param {?=} findInAncestors
4125
     * @return {?}
4126
     */
4127
    TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
4128
        if (findInAncestors === void 0) { findInAncestors = true; }
4129
        return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
4130
    };
4131
    return TestabilityRegistry;
4132
}());
4133
TestabilityRegistry.decorators = [
4134
    { type: Injectable },
4135
];
4136
/**
4137
 * @nocollapse
4138
 */
4139
TestabilityRegistry.ctorParameters = function () { return []; };
4140
var _NoopGetTestability = (function () {
4141
    function _NoopGetTestability() {
4142
    }
4143
    /**
4144
     * @param {?} registry
4145
     * @return {?}
4146
     */
4147
    _NoopGetTestability.prototype.addToWindow = function (registry) { };
4148
    /**
4149
     * @param {?} registry
4150
     * @param {?} elem
4151
     * @param {?} findInAncestors
4152
     * @return {?}
4153
     */
4154
    _NoopGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
4155
        return null;
4156
    };
4157
    return _NoopGetTestability;
4158
}());
4159
/**
4160
 * Set the {\@link GetTestability} implementation used by the Angular testing framework.
4161
 * \@experimental
4162
 * @param {?} getter
4163
 * @return {?}
4164
 */
4165
function setTestabilityGetter(getter) {
4166
    _testabilityGetter = getter;
4167
}
4168
var _testabilityGetter = new _NoopGetTestability();
4169
/**
4170
 * @license
4171
 * Copyright Google Inc. All Rights Reserved.
4172
 *
4173
 * Use of this source code is governed by an MIT-style license that can be
4174
 * found in the LICENSE file at https://angular.io/license
4175
 */
4176
var _devMode = true;
4177
var _runModeLocked = false;
4178
var _platform;
4179
var ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
4180
/**
4181
 * Disable Angular's development mode, which turns off assertions and other
4182
 * checks within the framework.
4183
 *
4184
 * One important assertion this disables verifies that a change detection pass
4185
 * does not result in additional changes to any bindings (also known as
4186
 * unidirectional data flow).
4187
 *
4188
 * \@stable
4189
 * @return {?}
4190
 */
4191
function enableProdMode() {
4192
    if (_runModeLocked) {
4193
        throw new Error('Cannot enable prod mode after platform setup.');
4194
    }
4195
    _devMode = false;
4196
}
4197
/**
4198
 * Returns whether Angular is in development mode. After called once,
4199
 * the value is locked and won't change any more.
4200
 *
4201
 * By default, this is true, unless a user calls `enableProdMode` before calling this.
4202
 *
4203
 * \@experimental APIs related to application bootstrap are currently under review.
4204
 * @return {?}
4205
 */
4206
function isDevMode() {
4207
    _runModeLocked = true;
4208
    return _devMode;
4209
}
4210
/**
4211
 * A token for third-party components that can register themselves with NgProbe.
4212
 *
4213
 * \@experimental
4214
 */
4215
var NgProbeToken = (function () {
4216
    /**
4217
     * @param {?} name
4218
     * @param {?} token
4219
     */
4220
    function NgProbeToken(name, token) {
4221
        this.name = name;
4222
        this.token = token;
4223
    }
4224
    return NgProbeToken;
4225
}());
4226
/**
4227
 * Creates a platform.
4228
 * Platforms have to be eagerly created via this function.
4229
 *
4230
 * \@experimental APIs related to application bootstrap are currently under review.
4231
 * @param {?} injector
4232
 * @return {?}
4233
 */
4234
function createPlatform(injector) {
4235
    if (_platform && !_platform.destroyed &&
4236
        !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4237
        throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
4238
    }
4239
    _platform = injector.get(PlatformRef);
4240
    var /** @type {?} */ inits = injector.get(PLATFORM_INITIALIZER, null);
4241
    if (inits)
4242
        inits.forEach(function (init) { return init(); });
4243
    return _platform;
4244
}
4245
/**
4246
 * Creates a factory for a platform
4247
 *
4248
 * \@experimental APIs related to application bootstrap are currently under review.
4249
 * @param {?} parentPlatformFactory
4250
 * @param {?} name
4251
 * @param {?=} providers
4252
 * @return {?}
4253
 */
4254
function createPlatformFactory(parentPlatformFactory, name, providers) {
4255
    if (providers === void 0) { providers = []; }
4256
    var /** @type {?} */ marker = new InjectionToken("Platform: " + name);
4257
    return function (extraProviders) {
4258
        if (extraProviders === void 0) { extraProviders = []; }
4259
        var /** @type {?} */ platform = getPlatform();
4260
        if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
4261
            if (parentPlatformFactory) {
4262
                parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
4263
            }
4264
            else {
4265
                createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
4266
            }
4267
        }
4268
        return assertPlatform(marker);
4269
    };
4270
}
4271
/**
4272
 * Checks that there currently is a platform which contains the given token as a provider.
4273
 *
4274
 * \@experimental APIs related to application bootstrap are currently under review.
4275
 * @param {?} requiredToken
4276
 * @return {?}
4277
 */
4278
function assertPlatform(requiredToken) {
4279
    var /** @type {?} */ platform = getPlatform();
4280
    if (!platform) {
4281
        throw new Error('No platform exists!');
4282
    }
4283
    if (!platform.injector.get(requiredToken, null)) {
4284
        throw new Error('A platform with a different configuration has been created. Please destroy it first.');
4285
    }
4286
    return platform;
4287
}
4288
/**
4289
 * Destroy the existing platform.
4290
 *
4291
 * \@experimental APIs related to application bootstrap are currently under review.
4292
 * @return {?}
4293
 */
4294
function destroyPlatform() {
4295
    if (_platform && !_platform.destroyed) {
4296
        _platform.destroy();
4297
    }
4298
}
4299
/**
4300
 * Returns the current platform.
4301
 *
4302
 * \@experimental APIs related to application bootstrap are currently under review.
4303
 * @return {?}
4304
 */
4305
function getPlatform() {
4306
    return _platform && !_platform.destroyed ? _platform : null;
4307
}
4308
/**
4309
 * The Angular platform is the entry point for Angular on a web page. Each page
4310
 * has exactly one platform, and services (such as reflection) which are common
4311
 * to every Angular application running on the page are bound in its scope.
4312
 *
4313
 * A page's platform is initialized implicitly when a platform is created via a platform factory
4314
 * (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
4315
 *
4316
 * \@stable
4317
 * @abstract
4318
 */
4319
var PlatformRef = (function () {
4320
    function PlatformRef() {
4321
    }
4322
    /**
4323
     * Creates an instance of an `\@NgModule` for the given platform
4324
     * for offline compilation.
4325
     *
4326
     * ## Simple Example
4327
     *
4328
     * ```typescript
4329
     * my_module.ts:
4330
     *
4331
     * \@NgModule({
4332
     *   imports: [BrowserModule]
4333
     * })
4334
     * class MyModule {}
4335
     *
4336
     * main.ts:
4337
     * import {MyModuleNgFactory} from './my_module.ngfactory';
4338
     * import {platformBrowser} from '\@angular/platform-browser';
4339
     *
4340
     * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
4341
     * ```
4342
     *
4343
     * \@experimental APIs related to application bootstrap are currently under review.
4344
     * @abstract
4345
     * @template M
4346
     * @param {?} moduleFactory
4347
     * @return {?}
4348
     */
4349
    PlatformRef.prototype.bootstrapModuleFactory = function (moduleFactory) { };
4350
    /**
4351
     * Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
4352
     *
4353
     * ## Simple Example
4354
     *
4355
     * ```typescript
4356
     * \@NgModule({
4357
     *   imports: [BrowserModule]
4358
     * })
4359
     * class MyModule {}
4360
     *
4361
     * let moduleRef = platformBrowser().bootstrapModule(MyModule);
4362
     * ```
4363
     * \@stable
4364
     * @abstract
4365
     * @template M
4366
     * @param {?} moduleType
4367
     * @param {?=} compilerOptions
4368
     * @return {?}
4369
     */
4370
    PlatformRef.prototype.bootstrapModule = function (moduleType, compilerOptions) { };
4371
    /**
4372
     * Register a listener to be called when the platform is disposed.
4373
     * @abstract
4374
     * @param {?} callback
4375
     * @return {?}
4376
     */
4377
    PlatformRef.prototype.onDestroy = function (callback) { };
4378
    /**
4379
     * Retrieve the platform {\@link Injector}, which is the parent injector for
4380
     * every Angular application on the page and provides singleton providers.
4381
     * @abstract
4382
     * @return {?}
4383
     */
4384
    PlatformRef.prototype.injector = function () { };
4385
    /**
4386
     * Destroy the Angular platform and all Angular applications on the page.
4387
     * @abstract
4388
     * @return {?}
4389
     */
4390
    PlatformRef.prototype.destroy = function () { };
4391
    /**
4392
     * @abstract
4393
     * @return {?}
4394
     */
4395
    PlatformRef.prototype.destroyed = function () { };
4396
    return PlatformRef;
4397
}());
4398
/**
4399
 * @param {?} errorHandler
4400
 * @param {?} ngZone
4401
 * @param {?} callback
4402
 * @return {?}
4403
 */
4404
function _callAndReportToErrorHandler(errorHandler, ngZone, callback) {
4405
    try {
4406
        var /** @type {?} */ result = callback();
4407
        if (isPromise(result)) {
4408
            return result.catch(function (e) {
4409
                ngZone.runOutsideAngular(function () { return errorHandler.handleError(e); });
4410
                // rethrow as the exception handler might not do it
4411
                throw e;
4412
            });
4413
        }
4414
        return result;
4415
    }
4416
    catch (e) {
4417
        ngZone.runOutsideAngular(function () { return errorHandler.handleError(e); });
4418
        // rethrow as the exception handler might not do it
4419
        throw e;
4420
    }
4421
}
4422
/**
4423
 * workaround https://github.com/angular/tsickle/issues/350
4424
 * @suppress {checkTypes}
4425
 */
4426
var PlatformRef_ = (function (_super) {
4427
    tslib_1.__extends(PlatformRef_, _super);
4428
    /**
4429
     * @param {?} _injector
4430
     */
4431
    function PlatformRef_(_injector) {
4432
        var _this = _super.call(this) || this;
4433
        _this._injector = _injector;
4434
        _this._modules = [];
4435
        _this._destroyListeners = [];
4436
        _this._destroyed = false;
4437
        return _this;
4438
    }
4439
    /**
4440
     * @param {?} callback
4441
     * @return {?}
4442
     */
4443
    PlatformRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
4444
    Object.defineProperty(PlatformRef_.prototype, "injector", {
4445
        /**
4446
         * @return {?}
4447
         */
4448
        get: function () { return this._injector; },
4449
        enumerable: true,
4450
        configurable: true
4451
    });
4452
    Object.defineProperty(PlatformRef_.prototype, "destroyed", {
4453
        /**
4454
         * @return {?}
4455
         */
4456
        get: function () { return this._destroyed; },
4457
        enumerable: true,
4458
        configurable: true
4459
    });
4460
    /**
4461
     * @return {?}
4462
     */
4463
    PlatformRef_.prototype.destroy = function () {
4464
        if (this._destroyed) {
4465
            throw new Error('The platform has already been destroyed!');
4466
        }
4467
        this._modules.slice().forEach(function (module) { return module.destroy(); });
4468
        this._destroyListeners.forEach(function (listener) { return listener(); });
4469
        this._destroyed = true;
4470
    };
4471
    /**
4472
     * @template M
4473
     * @param {?} moduleFactory
4474
     * @return {?}
4475
     */
4476
    PlatformRef_.prototype.bootstrapModuleFactory = function (moduleFactory) {
4477
        return this._bootstrapModuleFactoryWithZone(moduleFactory);
4478
    };
4479
    /**
4480
     * @template M
4481
     * @param {?} moduleFactory
4482
     * @param {?=} ngZone
4483
     * @return {?}
4484
     */
4485
    PlatformRef_.prototype._bootstrapModuleFactoryWithZone = function (moduleFactory, ngZone) {
4486
        var _this = this;
4487
        // Note: We need to create the NgZone _before_ we instantiate the module,
4488
        // as instantiating the module creates some providers eagerly.
4489
        // So we create a mini parent injector that just contains the new NgZone and
4490
        // pass that as parent to the NgModuleFactory.
4491
        if (!ngZone)
4492
            ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
4493
        // Attention: Don't use ApplicationRef.run here,
4494
        // as we want to be sure that all possible constructor calls are inside `ngZone.run`!
4495
        return ngZone.run(function () {
4496
            var /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], _this.injector);
4497
            var /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
4498
            var /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
4499
            if (!exceptionHandler) {
4500
                throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
4501
            }
4502
            moduleRef.onDestroy(function () { return remove(_this._modules, moduleRef); }); /** @type {?} */
4503
            ((ngZone)).runOutsideAngular(function () { return ((ngZone)).onError.subscribe({ next: function (error) { exceptionHandler.handleError(error); } }); });
4504
            return _callAndReportToErrorHandler(exceptionHandler, /** @type {?} */ ((ngZone)), function () {
4505
                var /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
4506
                initStatus.runInitializers();
4507
                return initStatus.donePromise.then(function () {
4508
                    _this._moduleDoBootstrap(moduleRef);
4509
                    return moduleRef;
4510
                });
4511
            });
4512
        });
4513
    };
4514
    /**
4515
     * @template M
4516
     * @param {?} moduleType
4517
     * @param {?=} compilerOptions
4518
     * @return {?}
4519
     */
4520
    PlatformRef_.prototype.bootstrapModule = function (moduleType, compilerOptions) {
4521
        if (compilerOptions === void 0) { compilerOptions = []; }
4522
        return this._bootstrapModuleWithZone(moduleType, compilerOptions);
4523
    };
4524
    /**
4525
     * @template M
4526
     * @param {?} moduleType
4527
     * @param {?=} compilerOptions
4528
     * @param {?=} ngZone
4529
     * @return {?}
4530
     */
4531
    PlatformRef_.prototype._bootstrapModuleWithZone = function (moduleType, compilerOptions, ngZone) {
4532
        var _this = this;
4533
        if (compilerOptions === void 0) { compilerOptions = []; }
4534
        var /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
4535
        var /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
4536
        return compiler.compileModuleAsync(moduleType)
4537
            .then(function (moduleFactory) { return _this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone); });
4538
    };
4539
    /**
4540
     * @param {?} moduleRef
4541
     * @return {?}
4542
     */
4543
    PlatformRef_.prototype._moduleDoBootstrap = function (moduleRef) {
4544
        var /** @type {?} */ appRef = (moduleRef.injector.get(ApplicationRef));
4545
        if (moduleRef._bootstrapComponents.length > 0) {
4546
            moduleRef._bootstrapComponents.forEach(function (f) { return appRef.bootstrap(f); });
4547
        }
4548
        else if (moduleRef.instance.ngDoBootstrap) {
4549
            moduleRef.instance.ngDoBootstrap(appRef);
4550
        }
4551
        else {
4552
            throw new Error("The module " + stringify(moduleRef.instance.constructor) + " was bootstrapped, but it does not declare \"@NgModule.bootstrap\" components nor a \"ngDoBootstrap\" method. " +
4553
                "Please define one of these.");
4554
        }
4555
        this._modules.push(moduleRef);
4556
    };
4557
    return PlatformRef_;
4558
}(PlatformRef));
4559
PlatformRef_.decorators = [
4560
    { type: Injectable },
4561
];
4562
/**
4563
 * @nocollapse
4564
 */
4565
PlatformRef_.ctorParameters = function () { return [
4566
    { type: Injector, },
4567
]; };
4568
/**
4569
 * A reference to an Angular application running on a page.
4570
 *
4571
 * \@stable
4572
 * @abstract
4573
 */
4574
var ApplicationRef = (function () {
4575
    function ApplicationRef() {
4576
    }
4577
    /**
4578
     * Bootstrap a new component at the root level of the application.
4579
     *
4580
     * ### Bootstrap process
4581
     *
4582
     * When bootstrapping a new root component into an application, Angular mounts the
4583
     * specified application component onto DOM elements identified by the [componentType]'s
4584
     * selector and kicks off automatic change detection to finish initializing the component.
4585
     *
4586
     * Optionally, a component can be mounted onto a DOM element that does not match the
4587
     * [componentType]'s selector.
4588
     *
4589
     * ### Example
4590
     * {\@example core/ts/platform/platform.ts region='longform'}
4591
     * @abstract
4592
     * @template C
4593
     * @param {?} componentFactory
4594
     * @param {?=} rootSelectorOrNode
4595
     * @return {?}
4596
     */
4597
    ApplicationRef.prototype.bootstrap = function (componentFactory, rootSelectorOrNode) { };
4598
    /**
4599
     * Invoke this method to explicitly process change detection and its side-effects.
4600
     *
4601
     * In development mode, `tick()` also performs a second change detection cycle to ensure that no
4602
     * further changes are detected. If additional changes are picked up during this second cycle,
4603
     * bindings in the app have side-effects that cannot be resolved in a single change detection
4604
     * pass.
4605
     * In this case, Angular throws an error, since an Angular application can only have one change
4606
     * detection pass during which all change detection must complete.
4607
     * @abstract
4608
     * @return {?}
4609
     */
4610
    ApplicationRef.prototype.tick = function () { };
4611
    /**
4612
     * Get a list of component types registered to this application.
4613
     * This list is populated even before the component is created.
4614
     * @abstract
4615
     * @return {?}
4616
     */
4617
    ApplicationRef.prototype.componentTypes = function () { };
4618
    /**
4619
     * Get a list of components registered to this application.
4620
     * @abstract
4621
     * @return {?}
4622
     */
4623
    ApplicationRef.prototype.components = function () { };
4624
    /**
4625
     * Attaches a view so that it will be dirty checked.
4626
     * The view will be automatically detached when it is destroyed.
4627
     * This will throw if the view is already attached to a ViewContainer.
4628
     * @abstract
4629
     * @param {?} view
4630
     * @return {?}
4631
     */
4632
    ApplicationRef.prototype.attachView = function (view) { };
4633
    /**
4634
     * Detaches a view from dirty checking again.
4635
     * @abstract
4636
     * @param {?} view
4637
     * @return {?}
4638
     */
4639
    ApplicationRef.prototype.detachView = function (view) { };
4640
    /**
4641
     * Returns the number of attached views.
4642
     * @abstract
4643
     * @return {?}
4644
     */
4645
    ApplicationRef.prototype.viewCount = function () { };
4646
    /**
4647
     * Returns an Observable that indicates when the application is stable or unstable.
4648
     * @abstract
4649
     * @return {?}
4650
     */
4651
    ApplicationRef.prototype.isStable = function () { };
4652
    return ApplicationRef;
4653
}());
4654
/**
4655
 * workaround https://github.com/angular/tsickle/issues/350
4656
 * @suppress {checkTypes}
4657
 */
4658
var ApplicationRef_ = (function (_super) {
4659
    tslib_1.__extends(ApplicationRef_, _super);
4660
    /**
4661
     * @param {?} _zone
4662
     * @param {?} _console
4663
     * @param {?} _injector
4664
     * @param {?} _exceptionHandler
4665
     * @param {?} _componentFactoryResolver
4666
     * @param {?} _initStatus
4667
     */
4668
    function ApplicationRef_(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
4669
        var _this = _super.call(this) || this;
4670
        _this._zone = _zone;
4671
        _this._console = _console;
4672
        _this._injector = _injector;
4673
        _this._exceptionHandler = _exceptionHandler;
4674
        _this._componentFactoryResolver = _componentFactoryResolver;
4675
        _this._initStatus = _initStatus;
4676
        _this._bootstrapListeners = [];
4677
        _this._rootComponents = [];
4678
        _this._rootComponentTypes = [];
4679
        _this._views = [];
4680
        _this._runningTick = false;
4681
        _this._enforceNoNewChanges = false;
4682
        _this._stable = true;
4683
        _this._enforceNoNewChanges = isDevMode();
4684
        _this._zone.onMicrotaskEmpty.subscribe({ next: function () { _this._zone.run(function () { _this.tick(); }); } });
4685
        var isCurrentlyStable = new Observable(function (observer) {
4686
            _this._stable = _this._zone.isStable && !_this._zone.hasPendingMacrotasks &&
4687
                !_this._zone.hasPendingMicrotasks;
4688
            _this._zone.runOutsideAngular(function () {
4689
                observer.next(_this._stable);
4690
                observer.complete();
4691
            });
4692
        });
4693
        var isStable = new Observable(function (observer) {
4694
            // Create the subscription to onStable outside the Angular Zone so that
4695
            // the callback is run outside the Angular Zone.
4696
            var stableSub;
4697
            _this._zone.runOutsideAngular(function () {
4698
                stableSub = _this._zone.onStable.subscribe(function () {
4699
                    NgZone.assertNotInAngularZone();
4700
                    // Check whether there are no pending macro/micro tasks in the next tick
4701
                    // to allow for NgZone to update the state.
4702
                    scheduleMicroTask(function () {
4703
                        if (!_this._stable && !_this._zone.hasPendingMacrotasks &&
4704
                            !_this._zone.hasPendingMicrotasks) {
4705
                            _this._stable = true;
4706
                            observer.next(true);
4707
                        }
4708
                    });
4709
                });
4710
            });
4711
            var unstableSub = _this._zone.onUnstable.subscribe(function () {
4712
                NgZone.assertInAngularZone();
4713
                if (_this._stable) {
4714
                    _this._stable = false;
4715
                    _this._zone.runOutsideAngular(function () { observer.next(false); });
4716
                }
4717
            });
4718
            return function () {
4719
                stableSub.unsubscribe();
4720
                unstableSub.unsubscribe();
4721
            };
4722
        });
4723
        _this._isStable = merge(isCurrentlyStable, share.call(isStable));
4724
        return _this;
4725
    }
4726
    /**
4727
     * @param {?} viewRef
4728
     * @return {?}
4729
     */
4730
    ApplicationRef_.prototype.attachView = function (viewRef) {
4731
        var /** @type {?} */ view = ((viewRef));
4732
        this._views.push(view);
4733
        view.attachToAppRef(this);
4734
    };
4735
    /**
4736
     * @param {?} viewRef
4737
     * @return {?}
4738
     */
4739
    ApplicationRef_.prototype.detachView = function (viewRef) {
4740
        var /** @type {?} */ view = ((viewRef));
4741
        remove(this._views, view);
4742
        view.detachFromAppRef();
4743
    };
4744
    /**
4745
     * @template C
4746
     * @param {?} componentOrFactory
4747
     * @param {?=} rootSelectorOrNode
4748
     * @return {?}
4749
     */
4750
    ApplicationRef_.prototype.bootstrap = function (componentOrFactory, rootSelectorOrNode) {
4751
        var _this = this;
4752
        if (!this._initStatus.done) {
4753
            throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
4754
        }
4755
        var /** @type {?} */ componentFactory;
4756
        if (componentOrFactory instanceof ComponentFactory) {
4757
            componentFactory = componentOrFactory;
4758
        }
4759
        else {
4760
            componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
4761
        }
4762
        this._rootComponentTypes.push(componentFactory.componentType);
4763
        // Create a factory associated with the current module if it's not bound to some other
4764
        var /** @type {?} */ ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
4765
            null :
4766
            this._injector.get(NgModuleRef);
4767
        var /** @type {?} */ selectorOrNode = rootSelectorOrNode || componentFactory.selector;
4768
        var /** @type {?} */ compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
4769
        compRef.onDestroy(function () { _this._unloadComponent(compRef); });
4770
        var /** @type {?} */ testability = compRef.injector.get(Testability, null);
4771
        if (testability) {
4772
            compRef.injector.get(TestabilityRegistry)
4773
                .registerApplication(compRef.location.nativeElement, testability);
4774
        }
4775
        this._loadComponent(compRef);
4776
        if (isDevMode()) {
4777
            this._console.log("Angular is running in the development mode. Call enableProdMode() to enable the production mode.");
4778
        }
4779
        return compRef;
4780
    };
4781
    /**
4782
     * @param {?} componentRef
4783
     * @return {?}
4784
     */
4785
    ApplicationRef_.prototype._loadComponent = function (componentRef) {
4786
        this.attachView(componentRef.hostView);
4787
        this.tick();
4788
        this._rootComponents.push(componentRef);
4789
        // Get the listeners lazily to prevent DI cycles.
4790
        var /** @type {?} */ listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
4791
        listeners.forEach(function (listener) { return listener(componentRef); });
4792
    };
4793
    /**
4794
     * @param {?} componentRef
4795
     * @return {?}
4796
     */
4797
    ApplicationRef_.prototype._unloadComponent = function (componentRef) {
4798
        this.detachView(componentRef.hostView);
4799
        remove(this._rootComponents, componentRef);
4800
    };
4801
    /**
4802
     * @return {?}
4803
     */
4804
    ApplicationRef_.prototype.tick = function () {
4805
        var _this = this;
4806
        if (this._runningTick) {
4807
            throw new Error('ApplicationRef.tick is called recursively');
4808
        }
4809
        var /** @type {?} */ scope = ApplicationRef_._tickScope();
4810
        try {
4811
            this._runningTick = true;
4812
            this._views.forEach(function (view) { return view.detectChanges(); });
4813
            if (this._enforceNoNewChanges) {
4814
                this._views.forEach(function (view) { return view.checkNoChanges(); });
4815
            }
4816
        }
4817
        catch (e) {
4818
            // Attention: Don't rethrow as it could cancel subscriptions to Observables!
4819
            this._zone.runOutsideAngular(function () { return _this._exceptionHandler.handleError(e); });
4820
        }
4821
        finally {
4822
            this._runningTick = false;
4823
            wtfLeave(scope);
4824
        }
4825
    };
4826
    /**
4827
     * @return {?}
4828
     */
4829
    ApplicationRef_.prototype.ngOnDestroy = function () {
4830
        // TODO(alxhub): Dispose of the NgZone.
4831
        this._views.slice().forEach(function (view) { return view.destroy(); });
4832
    };
4833
    Object.defineProperty(ApplicationRef_.prototype, "viewCount", {
4834
        /**
4835
         * @return {?}
4836
         */
4837
        get: function () { return this._views.length; },
4838
        enumerable: true,
4839
        configurable: true
4840
    });
4841
    Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
4842
        /**
4843
         * @return {?}
4844
         */
4845
        get: function () { return this._rootComponentTypes; },
4846
        enumerable: true,
4847
        configurable: true
4848
    });
4849
    Object.defineProperty(ApplicationRef_.prototype, "components", {
4850
        /**
4851
         * @return {?}
4852
         */
4853
        get: function () { return this._rootComponents; },
4854
        enumerable: true,
4855
        configurable: true
4856
    });
4857
    Object.defineProperty(ApplicationRef_.prototype, "isStable", {
4858
        /**
4859
         * @return {?}
4860
         */
4861
        get: function () { return this._isStable; },
4862
        enumerable: true,
4863
        configurable: true
4864
    });
4865
    return ApplicationRef_;
4866
}(ApplicationRef));
4867
/**
4868
 * \@internal
4869
 */
4870
ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
4871
ApplicationRef_.decorators = [
4872
    { type: Injectable },
4873
];
4874
/**
4875
 * @nocollapse
4876
 */
4877
ApplicationRef_.ctorParameters = function () { return [
4878
    { type: NgZone, },
4879
    { type: Console, },
4880
    { type: Injector, },
4881
    { type: ErrorHandler, },
4882
    { type: ComponentFactoryResolver, },
4883
    { type: ApplicationInitStatus, },
4884
]; };
4885
/**
4886
 * @template T
4887
 * @param {?} list
4888
 * @param {?} el
4889
 * @return {?}
4890
 */
4891
function remove(list, el) {
4892
    var /** @type {?} */ index = list.indexOf(el);
4893
    if (index > -1) {
4894
        list.splice(index, 1);
4895
    }
4896
}
4897
/**
4898
 * @license
4899
 * Copyright Google Inc. All Rights Reserved.
4900
 *
4901
 * Use of this source code is governed by an MIT-style license that can be
4902
 * found in the LICENSE file at https://angular.io/license
4903
 */
4904
// Public API for Zone
4905
/**
4906
 * @license
4907
 * Copyright Google Inc. All Rights Reserved.
4908
 *
4909
 * Use of this source code is governed by an MIT-style license that can be
4910
 * found in the LICENSE file at https://angular.io/license
4911
 */
4912
/**
4913
 * @deprecated Use `RendererType2` (and `Renderer2`) instead.
4914
 */
4915
var RenderComponentType = (function () {
4916
    /**
4917
     * @param {?} id
4918
     * @param {?} templateUrl
4919
     * @param {?} slotCount
4920
     * @param {?} encapsulation
4921
     * @param {?} styles
4922
     * @param {?} animations
4923
     */
4924
    function RenderComponentType(id, templateUrl, slotCount, encapsulation, styles, animations) {
4925
        this.id = id;
4926
        this.templateUrl = templateUrl;
4927
        this.slotCount = slotCount;
4928
        this.encapsulation = encapsulation;
4929
        this.styles = styles;
4930
        this.animations = animations;
4931
    }
4932
    return RenderComponentType;
4933
}());
4934
/**
4935
 * @deprecated Debug info is handeled internally in the view engine now.
4936
 * @abstract
4937
 */
4938
var RenderDebugInfo = (function () {
4939
    function RenderDebugInfo() {
4940
    }
4941
    /**
4942
     * @abstract
4943
     * @return {?}
4944
     */
4945
    RenderDebugInfo.prototype.injector = function () { };
4946
    /**
4947
     * @abstract
4948
     * @return {?}
4949
     */
4950
    RenderDebugInfo.prototype.component = function () { };
4951
    /**
4952
     * @abstract
4953
     * @return {?}
4954
     */
4955
    RenderDebugInfo.prototype.providerTokens = function () { };
4956
    /**
4957
     * @abstract
4958
     * @return {?}
4959
     */
4960
    RenderDebugInfo.prototype.references = function () { };
4961
    /**
4962
     * @abstract
4963
     * @return {?}
4964
     */
4965
    RenderDebugInfo.prototype.context = function () { };
4966
    /**
4967
     * @abstract
4968
     * @return {?}
4969
     */
4970
    RenderDebugInfo.prototype.source = function () { };
4971
    return RenderDebugInfo;
4972
}());
4973
/**
4974
 * @deprecated Use the `Renderer2` instead.
4975
 * @abstract
4976
 */
4977
var Renderer = (function () {
4978
    function Renderer() {
4979
    }
4980
    /**
4981
     * @abstract
4982
     * @param {?} selectorOrNode
4983
     * @param {?=} debugInfo
4984
     * @return {?}
4985
     */
4986
    Renderer.prototype.selectRootElement = function (selectorOrNode, debugInfo) { };
4987
    /**
4988
     * @abstract
4989
     * @param {?} parentElement
4990
     * @param {?} name
4991
     * @param {?=} debugInfo
4992
     * @return {?}
4993
     */
4994
    Renderer.prototype.createElement = function (parentElement, name, debugInfo) { };
4995
    /**
4996
     * @abstract
4997
     * @param {?} hostElement
4998
     * @return {?}
4999
     */
5000
    Renderer.prototype.createViewRoot = function (hostElement) { };
5001
    /**
5002
     * @abstract
5003
     * @param {?} parentElement
5004
     * @param {?=} debugInfo
5005
     * @return {?}
5006
     */
5007
    Renderer.prototype.createTemplateAnchor = function (parentElement, debugInfo) { };
5008
    /**
5009
     * @abstract
5010
     * @param {?} parentElement
5011
     * @param {?} value
5012
     * @param {?=} debugInfo
5013
     * @return {?}
5014
     */
5015
    Renderer.prototype.createText = function (parentElement, value, debugInfo) { };
5016
    /**
5017
     * @abstract
5018
     * @param {?} parentElement
5019
     * @param {?} nodes
5020
     * @return {?}
5021
     */
5022
    Renderer.prototype.projectNodes = function (parentElement, nodes) { };
5023
    /**
5024
     * @abstract
5025
     * @param {?} node
5026
     * @param {?} viewRootNodes
5027
     * @return {?}
5028
     */
5029
    Renderer.prototype.attachViewAfter = function (node, viewRootNodes) { };
5030
    /**
5031
     * @abstract
5032
     * @param {?} viewRootNodes
5033
     * @return {?}
5034
     */
5035
    Renderer.prototype.detachView = function (viewRootNodes) { };
5036
    /**
5037
     * @abstract
5038
     * @param {?} hostElement
5039
     * @param {?} viewAllNodes
5040
     * @return {?}
5041
     */
5042
    Renderer.prototype.destroyView = function (hostElement, viewAllNodes) { };
5043
    /**
5044
     * @abstract
5045
     * @param {?} renderElement
5046
     * @param {?} name
5047
     * @param {?} callback
5048
     * @return {?}
5049
     */
5050
    Renderer.prototype.listen = function (renderElement, name, callback) { };
5051
    /**
5052
     * @abstract
5053
     * @param {?} target
5054
     * @param {?} name
5055
     * @param {?} callback
5056
     * @return {?}
5057
     */
5058
    Renderer.prototype.listenGlobal = function (target, name, callback) { };
5059
    /**
5060
     * @abstract
5061
     * @param {?} renderElement
5062
     * @param {?} propertyName
5063
     * @param {?} propertyValue
5064
     * @return {?}
5065
     */
5066
    Renderer.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) { };
5067
    /**
5068
     * @abstract
5069
     * @param {?} renderElement
5070
     * @param {?} attributeName
5071
     * @param {?} attributeValue
5072
     * @return {?}
5073
     */
5074
    Renderer.prototype.setElementAttribute = function (renderElement, attributeName, attributeValue) { };
5075
    /**
5076
     * Used only in debug mode to serialize property changes to dom nodes as attributes.
5077
     * @abstract
5078
     * @param {?} renderElement
5079
     * @param {?} propertyName
5080
     * @param {?} propertyValue
5081
     * @return {?}
5082
     */
5083
    Renderer.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
5084
    /**
5085
     * @abstract
5086
     * @param {?} renderElement
5087
     * @param {?} className
5088
     * @param {?} isAdd
5089
     * @return {?}
5090
     */
5091
    Renderer.prototype.setElementClass = function (renderElement, className, isAdd) { };
5092
    /**
5093
     * @abstract
5094
     * @param {?} renderElement
5095
     * @param {?} styleName
5096
     * @param {?} styleValue
5097
     * @return {?}
5098
     */
5099
    Renderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) { };
5100
    /**
5101
     * @abstract
5102
     * @param {?} renderElement
5103
     * @param {?} methodName
5104
     * @param {?=} args
5105
     * @return {?}
5106
     */
5107
    Renderer.prototype.invokeElementMethod = function (renderElement, methodName, args) { };
5108
    /**
5109
     * @abstract
5110
     * @param {?} renderNode
5111
     * @param {?} text
5112
     * @return {?}
5113
     */
5114
    Renderer.prototype.setText = function (renderNode, text) { };
5115
    /**
5116
     * @abstract
5117
     * @param {?} element
5118
     * @param {?} startingStyles
5119
     * @param {?} keyframes
5120
     * @param {?} duration
5121
     * @param {?} delay
5122
     * @param {?} easing
5123
     * @param {?=} previousPlayers
5124
     * @return {?}
5125
     */
5126
    Renderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { };
5127
    return Renderer;
5128
}());
5129
var Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
5130
/**
5131
 * Injectable service that provides a low-level interface for modifying the UI.
5132
 *
5133
 * Use this service to bypass Angular's templating and make custom UI changes that can't be
5134
 * expressed declaratively. For example if you need to set a property or an attribute whose name is
5135
 * not statically known, use {\@link Renderer#setElementProperty} or {\@link
5136
 * Renderer#setElementAttribute}
5137
 * respectively.
5138
 *
5139
 * If you are implementing a custom renderer, you must implement this interface.
5140
 *
5141
 * The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
5142
 *
5143
 * @deprecated Use `RendererFactory2` instead.
5144
 * @abstract
5145
 */
5146
var RootRenderer = (function () {
5147
    function RootRenderer() {
5148
    }
5149
    /**
5150
     * @abstract
5151
     * @param {?} componentType
5152
     * @return {?}
5153
     */
5154
    RootRenderer.prototype.renderComponent = function (componentType) { };
5155
    return RootRenderer;
5156
}());
5157
/**
5158
 * \@experimental
5159
 * @abstract
5160
 */
5161
var RendererFactory2 = (function () {
5162
    function RendererFactory2() {
5163
    }
5164
    /**
5165
     * @abstract
5166
     * @param {?} hostElement
5167
     * @param {?} type
5168
     * @return {?}
5169
     */
5170
    RendererFactory2.prototype.createRenderer = function (hostElement, type) { };
5171
    /**
5172
     * @abstract
5173
     * @return {?}
5174
     */
5175
    RendererFactory2.prototype.begin = function () { };
5176
    /**
5177
     * @abstract
5178
     * @return {?}
5179
     */
5180
    RendererFactory2.prototype.end = function () { };
5181
    /**
5182
     * @abstract
5183
     * @return {?}
5184
     */
5185
    RendererFactory2.prototype.whenRenderingDone = function () { };
5186
    return RendererFactory2;
5187
}());
5188
var RendererStyleFlags2 = {};
5189
RendererStyleFlags2.Important = 1;
5190
RendererStyleFlags2.DashCase = 2;
5191
RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
5192
RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
5193
/**
5194
 * \@experimental
5195
 * @abstract
5196
 */
5197
var Renderer2 = (function () {
5198
    function Renderer2() {
5199
    }
5200
    /**
5201
     * This field can be used to store arbitrary data on this renderer instance.
5202
     * This is useful for renderers that delegate to other renderers.
5203
     * @abstract
5204
     * @return {?}
5205
     */
5206
    Renderer2.prototype.data = function () { };
5207
    /**
5208
     * @abstract
5209
     * @return {?}
5210
     */
5211
    Renderer2.prototype.destroy = function () { };
5212
    /**
5213
     * @abstract
5214
     * @param {?} name
5215
     * @param {?=} namespace
5216
     * @return {?}
5217
     */
5218
    Renderer2.prototype.createElement = function (name, namespace) { };
5219
    /**
5220
     * @abstract
5221
     * @param {?} value
5222
     * @return {?}
5223
     */
5224
    Renderer2.prototype.createComment = function (value) { };
5225
    /**
5226
     * @abstract
5227
     * @param {?} value
5228
     * @return {?}
5229
     */
5230
    Renderer2.prototype.createText = function (value) { };
5231
    /**
5232
     * @abstract
5233
     * @param {?} parent
5234
     * @param {?} newChild
5235
     * @return {?}
5236
     */
5237
    Renderer2.prototype.appendChild = function (parent, newChild) { };
5238
    /**
5239
     * @abstract
5240
     * @param {?} parent
5241
     * @param {?} newChild
5242
     * @param {?} refChild
5243
     * @return {?}
5244
     */
5245
    Renderer2.prototype.insertBefore = function (parent, newChild, refChild) { };
5246
    /**
5247
     * @abstract
5248
     * @param {?} parent
5249
     * @param {?} oldChild
5250
     * @return {?}
5251
     */
5252
    Renderer2.prototype.removeChild = function (parent, oldChild) { };
5253
    /**
5254
     * @abstract
5255
     * @param {?} selectorOrNode
5256
     * @return {?}
5257
     */
5258
    Renderer2.prototype.selectRootElement = function (selectorOrNode) { };
5259
    /**
5260
     * Attention: On WebWorkers, this will always return a value,
5261
     * as we are asking for a result synchronously. I.e.
5262
     * the caller can't rely on checking whether this is null or not.
5263
     * @abstract
5264
     * @param {?} node
5265
     * @return {?}
5266
     */
5267
    Renderer2.prototype.parentNode = function (node) { };
5268
    /**
5269
     * Attention: On WebWorkers, this will always return a value,
5270
     * as we are asking for a result synchronously. I.e.
5271
     * the caller can't rely on checking whether this is null or not.
5272
     * @abstract
5273
     * @param {?} node
5274
     * @return {?}
5275
     */
5276
    Renderer2.prototype.nextSibling = function (node) { };
5277
    /**
5278
     * @abstract
5279
     * @param {?} el
5280
     * @param {?} name
5281
     * @param {?} value
5282
     * @param {?=} namespace
5283
     * @return {?}
5284
     */
5285
    Renderer2.prototype.setAttribute = function (el, name, value, namespace) { };
5286
    /**
5287
     * @abstract
5288
     * @param {?} el
5289
     * @param {?} name
5290
     * @param {?=} namespace
5291
     * @return {?}
5292
     */
5293
    Renderer2.prototype.removeAttribute = function (el, name, namespace) { };
5294
    /**
5295
     * @abstract
5296
     * @param {?} el
5297
     * @param {?} name
5298
     * @return {?}
5299
     */
5300
    Renderer2.prototype.addClass = function (el, name) { };
5301
    /**
5302
     * @abstract
5303
     * @param {?} el
5304
     * @param {?} name
5305
     * @return {?}
5306
     */
5307
    Renderer2.prototype.removeClass = function (el, name) { };
5308
    /**
5309
     * @abstract
5310
     * @param {?} el
5311
     * @param {?} style
5312
     * @param {?} value
5313
     * @param {?=} flags
5314
     * @return {?}
5315
     */
5316
    Renderer2.prototype.setStyle = function (el, style, value, flags) { };
5317
    /**
5318
     * @abstract
5319
     * @param {?} el
5320
     * @param {?} style
5321
     * @param {?=} flags
5322
     * @return {?}
5323
     */
5324
    Renderer2.prototype.removeStyle = function (el, style, flags) { };
5325
    /**
5326
     * @abstract
5327
     * @param {?} el
5328
     * @param {?} name
5329
     * @param {?} value
5330
     * @return {?}
5331
     */
5332
    Renderer2.prototype.setProperty = function (el, name, value) { };
5333
    /**
5334
     * @abstract
5335
     * @param {?} node
5336
     * @param {?} value
5337
     * @return {?}
5338
     */
5339
    Renderer2.prototype.setValue = function (node, value) { };
5340
    /**
5341
     * @abstract
5342
     * @param {?} target
5343
     * @param {?} eventName
5344
     * @param {?} callback
5345
     * @return {?}
5346
     */
5347
    Renderer2.prototype.listen = function (target, eventName, callback) { };
5348
    return Renderer2;
5349
}());
5350
/**
5351
 * @license
5352
 * Copyright Google Inc. All Rights Reserved.
5353
 *
5354
 * Use of this source code is governed by an MIT-style license that can be
5355
 * found in the LICENSE file at https://angular.io/license
5356
 */
5357
// Public API for render
5358
var ElementRef = (function () {
5359
    /**
5360
     * @param {?} nativeElement
5361
     */
5362
    function ElementRef(nativeElement) {
5363
        this.nativeElement = nativeElement;
5364
    }
5365
    return ElementRef;
5366
}());
5367
/**
5368
 * @license
5369
 * Copyright Google Inc. All Rights Reserved.
5370
 *
5371
 * Use of this source code is governed by an MIT-style license that can be
5372
 * found in the LICENSE file at https://angular.io/license
5373
 */
5374
/**
5375
 * Used to load ng module factories.
5376
 * \@stable
5377
 * @abstract
5378
 */
5379
var NgModuleFactoryLoader = (function () {
5380
    function NgModuleFactoryLoader() {
5381
    }
5382
    /**
5383
     * @abstract
5384
     * @param {?} path
5385
     * @return {?}
5386
     */
5387
    NgModuleFactoryLoader.prototype.load = function (path) { };
5388
    return NgModuleFactoryLoader;
5389
}());
5390
var moduleFactories = new Map();
5391
/**
5392
 * Registers a loaded module. Should only be called from generated NgModuleFactory code.
5393
 * \@experimental
5394
 * @param {?} id
5395
 * @param {?} factory
5396
 * @return {?}
5397
 */
5398
function registerModuleFactory(id, factory) {
5399
    var /** @type {?} */ existing = moduleFactories.get(id);
5400
    if (existing) {
5401
        throw new Error("Duplicate module registered for " + id + " - " + existing.moduleType.name + " vs " + factory.moduleType.name);
5402
    }
5403
    moduleFactories.set(id, factory);
5404
}
5405
/**
5406
 * @return {?}
5407
 */
5408
/**
5409
 * Returns the NgModuleFactory with the given id, if it exists and has been loaded.
5410
 * Factories for modules that do not specify an `id` cannot be retrieved. Throws if the module
5411
 * cannot be found.
5412
 * \@experimental
5413
 * @param {?} id
5414
 * @return {?}
5415
 */
5416
function getModuleFactory(id) {
5417
    var /** @type {?} */ factory = moduleFactories.get(id);
5418
    if (!factory)
5419
        throw new Error("No module with ID " + id + " loaded");
5420
    return factory;
5421
}
5422
/**
5423
 * @license
5424
 * Copyright Google Inc. All Rights Reserved.
5425
 *
5426
 * Use of this source code is governed by an MIT-style license that can be
5427
 * found in the LICENSE file at https://angular.io/license
5428
 */
5429
/**
5430
 * An unmodifiable list of items that Angular keeps up to date when the state
5431
 * of the application changes.
5432
 *
5433
 * The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
5434
 * provide.
5435
 *
5436
 * Implements an iterable interface, therefore it can be used in both ES6
5437
 * javascript `for (var i of items)` loops as well as in Angular templates with
5438
 * `*ngFor="let i of myList"`.
5439
 *
5440
 * Changes can be observed by subscribing to the changes `Observable`.
5441
 *
5442
 * NOTE: In the future this class will implement an `Observable` interface.
5443
 *
5444
 * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
5445
 * ```typescript
5446
 * \@Component({...})
5447
 * class Container {
5448
 *   \@ViewChildren(Item) items:QueryList<Item>;
5449
 * }
5450
 * ```
5451
 * \@stable
5452
 */
5453
var QueryList = (function () {
5454
    function QueryList() {
5455
        this._dirty = true;
5456
        this._results = [];
5457
        this._emitter = new EventEmitter();
5458
    }
5459
    Object.defineProperty(QueryList.prototype, "changes", {
5460
        /**
5461
         * @return {?}
5462
         */
5463
        get: function () { return this._emitter; },
5464
        enumerable: true,
5465
        configurable: true
5466
    });
5467
    Object.defineProperty(QueryList.prototype, "length", {
5468
        /**
5469
         * @return {?}
5470
         */
5471
        get: function () { return this._results.length; },
5472
        enumerable: true,
5473
        configurable: true
5474
    });
5475
    Object.defineProperty(QueryList.prototype, "first", {
5476
        /**
5477
         * @return {?}
5478
         */
5479
        get: function () { return this._results[0]; },
5480
        enumerable: true,
5481
        configurable: true
5482
    });
5483
    Object.defineProperty(QueryList.prototype, "last", {
5484
        /**
5485
         * @return {?}
5486
         */
5487
        get: function () { return this._results[this.length - 1]; },
5488
        enumerable: true,
5489
        configurable: true
5490
    });
5491
    /**
5492
     * See
5493
     * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
5494
     * @template U
5495
     * @param {?} fn
5496
     * @return {?}
5497
     */
5498
    QueryList.prototype.map = function (fn) { return this._results.map(fn); };
5499
    /**
5500
     * See
5501
     * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
5502
     * @param {?} fn
5503
     * @return {?}
5504
     */
5505
    QueryList.prototype.filter = function (fn) {
5506
        return this._results.filter(fn);
5507
    };
5508
    /**
5509
     * See
5510
     * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
5511
     * @param {?} fn
5512
     * @return {?}
5513
     */
5514
    QueryList.prototype.find = function (fn) {
5515
        return this._results.find(fn);
5516
    };
5517
    /**
5518
     * See
5519
     * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
5520
     * @template U
5521
     * @param {?} fn
5522
     * @param {?} init
5523
     * @return {?}
5524
     */
5525
    QueryList.prototype.reduce = function (fn, init) {
5526
        return this._results.reduce(fn, init);
5527
    };
5528
    /**
5529
     * See
5530
     * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
5531
     * @param {?} fn
5532
     * @return {?}
5533
     */
5534
    QueryList.prototype.forEach = function (fn) { this._results.forEach(fn); };
5535
    /**
5536
     * See
5537
     * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
5538
     * @param {?} fn
5539
     * @return {?}
5540
     */
5541
    QueryList.prototype.some = function (fn) {
5542
        return this._results.some(fn);
5543
    };
5544
    /**
5545
     * @return {?}
5546
     */
5547
    QueryList.prototype.toArray = function () { return this._results.slice(); };
5548
    /**
5549
     * @return {?}
5550
     */
5551
    QueryList.prototype[getSymbolIterator()] = function () { return ((this._results))[getSymbolIterator()](); };
5552
    /**
5553
     * @return {?}
5554
     */
5555
    QueryList.prototype.toString = function () { return this._results.toString(); };
5556
    /**
5557
     * @param {?} res
5558
     * @return {?}
5559
     */
5560
    QueryList.prototype.reset = function (res) {
5561
        this._results = flatten(res);
5562
        this._dirty = false;
5563
    };
5564
    /**
5565
     * @return {?}
5566
     */
5567
    QueryList.prototype.notifyOnChanges = function () { this._emitter.emit(this); };
5568
    /**
5569
     * internal
5570
     * @return {?}
5571
     */
5572
    QueryList.prototype.setDirty = function () { this._dirty = true; };
5573
    Object.defineProperty(QueryList.prototype, "dirty", {
5574
        /**
5575
         * internal
5576
         * @return {?}
5577
         */
5578
        get: function () { return this._dirty; },
5579
        enumerable: true,
5580
        configurable: true
5581
    });
5582
    /**
5583
     * internal
5584
     * @return {?}
5585
     */
5586
    QueryList.prototype.destroy = function () {
5587
        this._emitter.complete();
5588
        this._emitter.unsubscribe();
5589
    };
5590
    return QueryList;
5591
}());
5592
/**
5593
 * @template T
5594
 * @param {?} list
5595
 * @return {?}
5596
 */
5597
function flatten(list) {
5598
    return list.reduce(function (flat, item) {
5599
        var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
5600
        return ((flat)).concat(flatItem);
5601
    }, []);
5602
}
5603
/**
5604
 * @license
5605
 * Copyright Google Inc. All Rights Reserved.
5606
 *
5607
 * Use of this source code is governed by an MIT-style license that can be
5608
 * found in the LICENSE file at https://angular.io/license
5609
 */
5610
var _SEPARATOR = '#';
5611
var FACTORY_CLASS_SUFFIX = 'NgFactory';
5612
/**
5613
 * Configuration for SystemJsNgModuleLoader.
5614
 * token.
5615
 *
5616
 * \@experimental
5617
 * @abstract
5618
 */
5619
var SystemJsNgModuleLoaderConfig = (function () {
5620
    function SystemJsNgModuleLoaderConfig() {
5621
    }
5622
    return SystemJsNgModuleLoaderConfig;
5623
}());
5624
var DEFAULT_CONFIG = {
5625
    factoryPathPrefix: '',
5626
    factoryPathSuffix: '.ngfactory',
5627
};
5628
/**
5629
 * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
5630
 * \@experimental
5631
 */
5632
var SystemJsNgModuleLoader = (function () {
5633
    /**
5634
     * @param {?} _compiler
5635
     * @param {?=} config
5636
     */
5637
    function SystemJsNgModuleLoader(_compiler, config) {
5638
        this._compiler = _compiler;
5639
        this._config = config || DEFAULT_CONFIG;
5640
    }
5641
    /**
5642
     * @param {?} path
5643
     * @return {?}
5644
     */
5645
    SystemJsNgModuleLoader.prototype.load = function (path) {
5646
        var /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
5647
        return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
5648
    };
5649
    /**
5650
     * @param {?} path
5651
     * @return {?}
5652
     */
5653
    SystemJsNgModuleLoader.prototype.loadAndCompile = function (path) {
5654
        var _this = this;
5655
        var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
5656
        if (exportName === undefined) {
5657
            exportName = 'default';
5658
        }
5659
        return System.import(module)
5660
            .then(function (module) { return module[exportName]; })
5661
            .then(function (type) { return checkNotEmpty(type, module, exportName); })
5662
            .then(function (type) { return _this._compiler.compileModuleAsync(type); });
5663
    };
5664
    /**
5665
     * @param {?} path
5666
     * @return {?}
5667
     */
5668
    SystemJsNgModuleLoader.prototype.loadFactory = function (path) {
5669
        var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
5670
        var /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
5671
        if (exportName === undefined) {
5672
            exportName = 'default';
5673
            factoryClassSuffix = '';
5674
        }
5675
        return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
5676
            .then(function (module) { return module[exportName + factoryClassSuffix]; })
5677
            .then(function (factory) { return checkNotEmpty(factory, module, exportName); });
5678
    };
5679
    return SystemJsNgModuleLoader;
5680
}());
5681
SystemJsNgModuleLoader.decorators = [
5682
    { type: Injectable },
5683
];
5684
/**
5685
 * @nocollapse
5686
 */
5687
SystemJsNgModuleLoader.ctorParameters = function () { return [
5688
    { type: Compiler, },
5689
    { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
5690
]; };
5691
/**
5692
 * @param {?} value
5693
 * @param {?} modulePath
5694
 * @param {?} exportName
5695
 * @return {?}
5696
 */
5697
function checkNotEmpty(value, modulePath, exportName) {
5698
    if (!value) {
5699
        throw new Error("Cannot find '" + exportName + "' in '" + modulePath + "'");
5700
    }
5701
    return value;
5702
}
5703
/**
5704
 * @license
5705
 * Copyright Google Inc. All Rights Reserved.
5706
 *
5707
 * Use of this source code is governed by an MIT-style license that can be
5708
 * found in the LICENSE file at https://angular.io/license
5709
 */
5710
/**
5711
 * Represents an Embedded Template that can be used to instantiate Embedded Views.
5712
 *
5713
 * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
5714
 * (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
5715
 * the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
5716
 * the `TemplateRef` from a Component or a Directive via {\@link Query}.
5717
 *
5718
 * To instantiate Embedded Views based on a Template, use
5719
 * {\@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
5720
 * View Container.
5721
 * \@stable
5722
 * @abstract
5723
 */
5724
var TemplateRef = (function () {
5725
    function TemplateRef() {
5726
    }
5727
    /**
5728
     * @abstract
5729
     * @return {?}
5730
     */
5731
    TemplateRef.prototype.elementRef = function () { };
5732
    /**
5733
     * @abstract
5734
     * @param {?} context
5735
     * @return {?}
5736
     */
5737
    TemplateRef.prototype.createEmbeddedView = function (context) { };
5738
    return TemplateRef;
5739
}());
5740
/**
5741
 * @license
5742
 * Copyright Google Inc. All Rights Reserved.
5743
 *
5744
 * Use of this source code is governed by an MIT-style license that can be
5745
 * found in the LICENSE file at https://angular.io/license
5746
 */
5747
/**
5748
 * Represents a container where one or more Views can be attached.
5749
 *
5750
 * The container can contain two kinds of Views. Host Views, created by instantiating a
5751
 * {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
5752
 * {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
5753
 *
5754
 * The location of the View Container within the containing View is specified by the Anchor
5755
 * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
5756
 * have a single View Container.
5757
 *
5758
 * Root elements of Views attached to this container become siblings of the Anchor Element in
5759
 * the Rendered View.
5760
 *
5761
 * To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
5762
 * with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
5763
 * \@stable
5764
 * @abstract
5765
 */
5766
var ViewContainerRef = (function () {
5767
    function ViewContainerRef() {
5768
    }
5769
    /**
5770
     * Anchor element that specifies the location of this container in the containing View.
5771
     * <!-- TODO: rename to anchorElement -->
5772
     * @abstract
5773
     * @return {?}
5774
     */
5775
    ViewContainerRef.prototype.element = function () { };
5776
    /**
5777
     * @abstract
5778
     * @return {?}
5779
     */
5780
    ViewContainerRef.prototype.injector = function () { };
5781
    /**
5782
     * @abstract
5783
     * @return {?}
5784
     */
5785
    ViewContainerRef.prototype.parentInjector = function () { };
5786
    /**
5787
     * Destroys all Views in this container.
5788
     * @abstract
5789
     * @return {?}
5790
     */
5791
    ViewContainerRef.prototype.clear = function () { };
5792
    /**
5793
     * Returns the {\@link ViewRef} for the View located in this container at the specified index.
5794
     * @abstract
5795
     * @param {?} index
5796
     * @return {?}
5797
     */
5798
    ViewContainerRef.prototype.get = function (index) { };
5799
    /**
5800
     * Returns the number of Views currently attached to this container.
5801
     * @abstract
5802
     * @return {?}
5803
     */
5804
    ViewContainerRef.prototype.length = function () { };
5805
    /**
5806
     * Instantiates an Embedded View based on the {\@link TemplateRef `templateRef`} and inserts it
5807
     * into this container at the specified `index`.
5808
     *
5809
     * If `index` is not specified, the new View will be inserted as the last View in the container.
5810
     *
5811
     * Returns the {\@link ViewRef} for the newly created View.
5812
     * @abstract
5813
     * @template C
5814
     * @param {?} templateRef
5815
     * @param {?=} context
5816
     * @param {?=} index
5817
     * @return {?}
5818
     */
5819
    ViewContainerRef.prototype.createEmbeddedView = function (templateRef, context, index) { };
5820
    /**
5821
     * Instantiates a single {\@link Component} and inserts its Host View into this container at the
5822
     * specified `index`.
5823
     *
5824
     * The component is instantiated using its {\@link ComponentFactory} which can be
5825
     * obtained via {\@link ComponentFactoryResolver#resolveComponentFactory}.
5826
     *
5827
     * If `index` is not specified, the new View will be inserted as the last View in the container.
5828
     *
5829
     * You can optionally specify the {\@link Injector} that will be used as parent for the Component.
5830
     *
5831
     * Returns the {\@link ComponentRef} of the Host View created for the newly instantiated Component.
5832
     * @abstract
5833
     * @template C
5834
     * @param {?} componentFactory
5835
     * @param {?=} index
5836
     * @param {?=} injector
5837
     * @param {?=} projectableNodes
5838
     * @param {?=} ngModule
5839
     * @return {?}
5840
     */
5841
    ViewContainerRef.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModule) { };
5842
    /**
5843
     * Inserts a View identified by a {\@link ViewRef} into the container at the specified `index`.
5844
     *
5845
     * If `index` is not specified, the new View will be inserted as the last View in the container.
5846
     *
5847
     * Returns the inserted {\@link ViewRef}.
5848
     * @abstract
5849
     * @param {?} viewRef
5850
     * @param {?=} index
5851
     * @return {?}
5852
     */
5853
    ViewContainerRef.prototype.insert = function (viewRef, index) { };
5854
    /**
5855
     * Moves a View identified by a {\@link ViewRef} into the container at the specified `index`.
5856
     *
5857
     * Returns the inserted {\@link ViewRef}.
5858
     * @abstract
5859
     * @param {?} viewRef
5860
     * @param {?} currentIndex
5861
     * @return {?}
5862
     */
5863
    ViewContainerRef.prototype.move = function (viewRef, currentIndex) { };
5864
    /**
5865
     * Returns the index of the View, specified via {\@link ViewRef}, within the current container or
5866
     * `-1` if this container doesn't contain the View.
5867
     * @abstract
5868
     * @param {?} viewRef
5869
     * @return {?}
5870
     */
5871
    ViewContainerRef.prototype.indexOf = function (viewRef) { };
5872
    /**
5873
     * Destroys a View attached to this container at the specified `index`.
5874
     *
5875
     * If `index` is not specified, the last View in the container will be removed.
5876
     * @abstract
5877
     * @param {?=} index
5878
     * @return {?}
5879
     */
5880
    ViewContainerRef.prototype.remove = function (index) { };
5881
    /**
5882
     * Use along with {\@link #insert} to move a View within the current container.
5883
     *
5884
     * If the `index` param is omitted, the last {\@link ViewRef} is detached.
5885
     * @abstract
5886
     * @param {?=} index
5887
     * @return {?}
5888
     */
5889
    ViewContainerRef.prototype.detach = function (index) { };
5890
    return ViewContainerRef;
5891
}());
5892
/**
5893
 * \@stable
5894
 * @abstract
5895
 */
5896
var ChangeDetectorRef = (function () {
5897
    function ChangeDetectorRef() {
5898
    }
5899
    /**
5900
     * Marks all {\@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
5901
     *
5902
     * <!-- TODO: Add a link to a chapter on OnPush components -->
5903
     *
5904
     * ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
5905
     *
5906
     * ```typescript
5907
     * \@Component({
5908
     *   selector: 'cmp',
5909
     *   changeDetection: ChangeDetectionStrategy.OnPush,
5910
     *   template: `Number of ticks: {{numberOfTicks}}`
5911
     * })
5912
     * class Cmp {
5913
     *   numberOfTicks = 0;
5914
     *
5915
     *   constructor(private ref: ChangeDetectorRef) {
5916
     *     setInterval(() => {
5917
     *       this.numberOfTicks++;
5918
     *       // the following is required, otherwise the view will not be updated
5919
     *       this.ref.markForCheck();
5920
     *     }, 1000);
5921
     *   }
5922
     * }
5923
     *
5924
     * \@Component({
5925
     *   selector: 'app',
5926
     *   changeDetection: ChangeDetectionStrategy.OnPush,
5927
     *   template: `
5928
     *     <cmp><cmp>
5929
     *   `,
5930
     * })
5931
     * class App {
5932
     * }
5933
     * ```
5934
     * @abstract
5935
     * @return {?}
5936
     */
5937
    ChangeDetectorRef.prototype.markForCheck = function () { };
5938
    /**
5939
     * Detaches the change detector from the change detector tree.
5940
     *
5941
     * The detached change detector will not be checked until it is reattached.
5942
     *
5943
     * This can also be used in combination with {\@link ChangeDetectorRef#detectChanges} to implement
5944
     * local change
5945
     * detection checks.
5946
     *
5947
     * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
5948
     * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
5949
     *
5950
     * ### Example
5951
     *
5952
     * The following example defines a component with a large list of readonly data.
5953
     * Imagine the data changes constantly, many times per second. For performance reasons,
5954
     * we want to check and update the list every five seconds. We can do that by detaching
5955
     * the component's change detector and doing a local check every five seconds.
5956
     *
5957
     * ```typescript
5958
     * class DataProvider {
5959
     *   // in a real application the returned data will be different every time
5960
     *   get data() {
5961
     *     return [1,2,3,4,5];
5962
     *   }
5963
     * }
5964
     *
5965
     * \@Component({
5966
     *   selector: 'giant-list',
5967
     *   template: `
5968
     *     <li *ngFor="let d of dataProvider.data">Data {{d}}</li>
5969
     *   `,
5970
     * })
5971
     * class GiantList {
5972
     *   constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {
5973
     *     ref.detach();
5974
     *     setInterval(() => {
5975
     *       this.ref.detectChanges();
5976
     *     }, 5000);
5977
     *   }
5978
     * }
5979
     *
5980
     * \@Component({
5981
     *   selector: 'app',
5982
     *   providers: [DataProvider],
5983
     *   template: `
5984
     *     <giant-list><giant-list>
5985
     *   `,
5986
     * })
5987
     * class App {
5988
     * }
5989
     * ```
5990
     * @abstract
5991
     * @return {?}
5992
     */
5993
    ChangeDetectorRef.prototype.detach = function () { };
5994
    /**
5995
     * Checks the change detector and its children.
5996
     *
5997
     * This can also be used in combination with {\@link ChangeDetectorRef#detach} to implement local
5998
     * change detection
5999
     * checks.
6000
     *
6001
     * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
6002
     * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
6003
     *
6004
     * ### Example
6005
     *
6006
     * The following example defines a component with a large list of readonly data.
6007
     * Imagine, the data changes constantly, many times per second. For performance reasons,
6008
     * we want to check and update the list every five seconds.
6009
     *
6010
     * We can do that by detaching the component's change detector and doing a local change detection
6011
     * check
6012
     * every five seconds.
6013
     *
6014
     * See {\@link ChangeDetectorRef#detach} for more information.
6015
     * @abstract
6016
     * @return {?}
6017
     */
6018
    ChangeDetectorRef.prototype.detectChanges = function () { };
6019
    /**
6020
     * Checks the change detector and its children, and throws if any changes are detected.
6021
     *
6022
     * This is used in development mode to verify that running change detection doesn't introduce
6023
     * other changes.
6024
     * @abstract
6025
     * @return {?}
6026
     */
6027
    ChangeDetectorRef.prototype.checkNoChanges = function () { };
6028
    /**
6029
     * Reattach the change detector to the change detector tree.
6030
     *
6031
     * This also marks OnPush ancestors as to be checked. This reattached change detector will be
6032
     * checked during the next change detection run.
6033
     *
6034
     * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
6035
     *
6036
     * ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
6037
     *
6038
     * The following example creates a component displaying `live` data. The component will detach
6039
     * its change detector from the main change detector tree when the component's live property
6040
     * is set to false.
6041
     *
6042
     * ```typescript
6043
     * class DataProvider {
6044
     *   data = 1;
6045
     *
6046
     *   constructor() {
6047
     *     setInterval(() => {
6048
     *       this.data = this.data * 2;
6049
     *     }, 500);
6050
     *   }
6051
     * }
6052
     *
6053
     * \@Component({
6054
     *   selector: 'live-data',
6055
     *   inputs: ['live'],
6056
     *   template: 'Data: {{dataProvider.data}}'
6057
     * })
6058
     * class LiveData {
6059
     *   constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {}
6060
     *
6061
     *   set live(value) {
6062
     *     if (value) {
6063
     *       this.ref.reattach();
6064
     *     } else {
6065
     *       this.ref.detach();
6066
     *     }
6067
     *   }
6068
     * }
6069
     *
6070
     * \@Component({
6071
     *   selector: 'app',
6072
     *   providers: [DataProvider],
6073
     *   template: `
6074
     *     Live Update: <input type="checkbox" [(ngModel)]="live">
6075
     *     <live-data [live]="live"><live-data>
6076
     *   `,
6077
     * })
6078
     * class App {
6079
     *   live = true;
6080
     * }
6081
     * ```
6082
     * @abstract
6083
     * @return {?}
6084
     */
6085
    ChangeDetectorRef.prototype.reattach = function () { };
6086
    return ChangeDetectorRef;
6087
}());
6088
/**
6089
 * @license
6090
 * Copyright Google Inc. All Rights Reserved.
6091
 *
6092
 * Use of this source code is governed by an MIT-style license that can be
6093
 * found in the LICENSE file at https://angular.io/license
6094
 */
6095
/**
6096
 * \@stable
6097
 * @abstract
6098
 */
6099
var ViewRef = (function (_super) {
6100
    tslib_1.__extends(ViewRef, _super);
6101
    function ViewRef() {
6102
        return _super !== null && _super.apply(this, arguments) || this;
6103
    }
6104
    /**
6105
     * Destroys the view and all of the data structures associated with it.
6106
     * @abstract
6107
     * @return {?}
6108
     */
6109
    ViewRef.prototype.destroy = function () { };
6110
    /**
6111
     * @abstract
6112
     * @return {?}
6113
     */
6114
    ViewRef.prototype.destroyed = function () { };
6115
    /**
6116
     * @abstract
6117
     * @param {?} callback
6118
     * @return {?}
6119
     */
6120
    ViewRef.prototype.onDestroy = function (callback) { };
6121
    return ViewRef;
6122
}(ChangeDetectorRef));
6123
/**
6124
 * Represents an Angular View.
6125
 *
6126
 * <!-- TODO: move the next two paragraphs to the dev guide -->
6127
 * A View is a fundamental building block of the application UI. It is the smallest grouping of
6128
 * Elements which are created and destroyed together.
6129
 *
6130
 * Properties of elements in a View can change, but the structure (number and order) of elements in
6131
 * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
6132
 * removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
6133
 * <!-- /TODO -->
6134
 *
6135
 * ### Example
6136
 *
6137
 * Given this template...
6138
 *
6139
 * ```
6140
 * Count: {{items.length}}
6141
 * <ul>
6142
 *   <li *ngFor="let  item of items">{{item}}</li>
6143
 * </ul>
6144
 * ```
6145
 *
6146
 * We have two {\@link TemplateRef}s:
6147
 *
6148
 * Outer {\@link TemplateRef}:
6149
 * ```
6150
 * Count: {{items.length}}
6151
 * <ul>
6152
 *   <ng-template ngFor let-item [ngForOf]="items"></ng-template>
6153
 * </ul>
6154
 * ```
6155
 *
6156
 * Inner {\@link TemplateRef}:
6157
 * ```
6158
 *   <li>{{item}}</li>
6159
 * ```
6160
 *
6161
 * Notice that the original template is broken down into two separate {\@link TemplateRef}s.
6162
 *
6163
 * The outer/inner {\@link TemplateRef}s are then assembled into views like so:
6164
 *
6165
 * ```
6166
 * <!-- ViewRef: outer-0 -->
6167
 * Count: 2
6168
 * <ul>
6169
 *   <ng-template view-container-ref></ng-template>
6170
 *   <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
6171
 *   <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
6172
 * </ul>
6173
 * <!-- /ViewRef: outer-0 -->
6174
 * ```
6175
 * \@experimental
6176
 * @abstract
6177
 */
6178
var EmbeddedViewRef = (function (_super) {
6179
    tslib_1.__extends(EmbeddedViewRef, _super);
6180
    function EmbeddedViewRef() {
6181
        return _super !== null && _super.apply(this, arguments) || this;
6182
    }
6183
    /**
6184
     * @abstract
6185
     * @return {?}
6186
     */
6187
    EmbeddedViewRef.prototype.context = function () { };
6188
    /**
6189
     * @abstract
6190
     * @return {?}
6191
     */
6192
    EmbeddedViewRef.prototype.rootNodes = function () { };
6193
    return EmbeddedViewRef;
6194
}(ViewRef));
6195
/**
6196
 * @license
6197
 * Copyright Google Inc. All Rights Reserved.
6198
 *
6199
 * Use of this source code is governed by an MIT-style license that can be
6200
 * found in the LICENSE file at https://angular.io/license
6201
 */
6202
// Public API for compiler
6203
/**
6204
 * @license
6205
 * Copyright Google Inc. All Rights Reserved.
6206
 *
6207
 * Use of this source code is governed by an MIT-style license that can be
6208
 * found in the LICENSE file at https://angular.io/license
6209
 */
6210
var EventListener = (function () {
6211
    /**
6212
     * @param {?} name
6213
     * @param {?} callback
6214
     */
6215
    function EventListener(name, callback) {
6216
        this.name = name;
6217
        this.callback = callback;
6218
    }
6219
    return EventListener;
6220
}());
6221
/**
6222
 * \@experimental All debugging apis are currently experimental.
6223
 */
6224
var DebugNode = (function () {
6225
    /**
6226
     * @param {?} nativeNode
6227
     * @param {?} parent
6228
     * @param {?} _debugContext
6229
     */
6230
    function DebugNode(nativeNode, parent, _debugContext) {
6231
        this._debugContext = _debugContext;
6232
        this.nativeNode = nativeNode;
6233
        if (parent && parent instanceof DebugElement) {
6234
            parent.addChild(this);
6235
        }
6236
        else {
6237
            this.parent = null;
6238
        }
6239
        this.listeners = [];
6240
    }
6241
    Object.defineProperty(DebugNode.prototype, "injector", {
6242
        /**
6243
         * @return {?}
6244
         */
6245
        get: function () { return this._debugContext.injector; },
6246
        enumerable: true,
6247
        configurable: true
6248
    });
6249
    Object.defineProperty(DebugNode.prototype, "componentInstance", {
6250
        /**
6251
         * @return {?}
6252
         */
6253
        get: function () { return this._debugContext.component; },
6254
        enumerable: true,
6255
        configurable: true
6256
    });
6257
    Object.defineProperty(DebugNode.prototype, "context", {
6258
        /**
6259
         * @return {?}
6260
         */
6261
        get: function () { return this._debugContext.context; },
6262
        enumerable: true,
6263
        configurable: true
6264
    });
6265
    Object.defineProperty(DebugNode.prototype, "references", {
6266
        /**
6267
         * @return {?}
6268
         */
6269
        get: function () { return this._debugContext.references; },
6270
        enumerable: true,
6271
        configurable: true
6272
    });
6273
    Object.defineProperty(DebugNode.prototype, "providerTokens", {
6274
        /**
6275
         * @return {?}
6276
         */
6277
        get: function () { return this._debugContext.providerTokens; },
6278
        enumerable: true,
6279
        configurable: true
6280
    });
6281
    Object.defineProperty(DebugNode.prototype, "source", {
6282
        /**
6283
         * @deprecated since v4
6284
         * @return {?}
6285
         */
6286
        get: function () { return 'Deprecated since v4'; },
6287
        enumerable: true,
6288
        configurable: true
6289
    });
6290
    return DebugNode;
6291
}());
6292
/**
6293
 * \@experimental All debugging apis are currently experimental.
6294
 */
6295
var DebugElement = (function (_super) {
6296
    tslib_1.__extends(DebugElement, _super);
6297
    /**
6298
     * @param {?} nativeNode
6299
     * @param {?} parent
6300
     * @param {?} _debugContext
6301
     */
6302
    function DebugElement(nativeNode, parent, _debugContext) {
6303
        var _this = _super.call(this, nativeNode, parent, _debugContext) || this;
6304
        _this.properties = {};
6305
        _this.attributes = {};
6306
        _this.classes = {};
6307
        _this.styles = {};
6308
        _this.childNodes = [];
6309
        _this.nativeElement = nativeNode;
6310
        return _this;
6311
    }
6312
    /**
6313
     * @param {?} child
6314
     * @return {?}
6315
     */
6316
    DebugElement.prototype.addChild = function (child) {
6317
        if (child) {
6318
            this.childNodes.push(child);
6319
            child.parent = this;
6320
        }
6321
    };
6322
    /**
6323
     * @param {?} child
6324
     * @return {?}
6325
     */
6326
    DebugElement.prototype.removeChild = function (child) {
6327
        var /** @type {?} */ childIndex = this.childNodes.indexOf(child);
6328
        if (childIndex !== -1) {
6329
            child.parent = null;
6330
            this.childNodes.splice(childIndex, 1);
6331
        }
6332
    };
6333
    /**
6334
     * @param {?} child
6335
     * @param {?} newChildren
6336
     * @return {?}
6337
     */
6338
    DebugElement.prototype.insertChildrenAfter = function (child, newChildren) {
6339
        var _this = this;
6340
        var /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
6341
        if (siblingIndex !== -1) {
6342
            (_a = this.childNodes).splice.apply(_a, [siblingIndex + 1, 0].concat(newChildren));
6343
            newChildren.forEach(function (c) {
6344
                if (c.parent) {
6345
                    c.parent.removeChild(c);
6346
                }
6347
                c.parent = _this;
6348
            });
6349
        }
6350
        var _a;
6351
    };
6352
    /**
6353
     * @param {?} refChild
6354
     * @param {?} newChild
6355
     * @return {?}
6356
     */
6357
    DebugElement.prototype.insertBefore = function (refChild, newChild) {
6358
        var /** @type {?} */ refIndex = this.childNodes.indexOf(refChild);
6359
        if (refIndex === -1) {
6360
            this.addChild(newChild);
6361
        }
6362
        else {
6363
            if (newChild.parent) {
6364
                newChild.parent.removeChild(newChild);
6365
            }
6366
            newChild.parent = this;
6367
            this.childNodes.splice(refIndex, 0, newChild);
6368
        }
6369
    };
6370
    /**
6371
     * @param {?} predicate
6372
     * @return {?}
6373
     */
6374
    DebugElement.prototype.query = function (predicate) {
6375
        var /** @type {?} */ results = this.queryAll(predicate);
6376
        return results[0] || null;
6377
    };
6378
    /**
6379
     * @param {?} predicate
6380
     * @return {?}
6381
     */
6382
    DebugElement.prototype.queryAll = function (predicate) {
6383
        var /** @type {?} */ matches = [];
6384
        _queryElementChildren(this, predicate, matches);
6385
        return matches;
6386
    };
6387
    /**
6388
     * @param {?} predicate
6389
     * @return {?}
6390
     */
6391
    DebugElement.prototype.queryAllNodes = function (predicate) {
6392
        var /** @type {?} */ matches = [];
6393
        _queryNodeChildren(this, predicate, matches);
6394
        return matches;
6395
    };
6396
    Object.defineProperty(DebugElement.prototype, "children", {
6397
        /**
6398
         * @return {?}
6399
         */
6400
        get: function () {
6401
            return (this.childNodes.filter(function (node) { return node instanceof DebugElement; }));
6402
        },
6403
        enumerable: true,
6404
        configurable: true
6405
    });
6406
    /**
6407
     * @param {?} eventName
6408
     * @param {?} eventObj
6409
     * @return {?}
6410
     */
6411
    DebugElement.prototype.triggerEventHandler = function (eventName, eventObj) {
6412
        this.listeners.forEach(function (listener) {
6413
            if (listener.name == eventName) {
6414
                listener.callback(eventObj);
6415
            }
6416
        });
6417
    };
6418
    return DebugElement;
6419
}(DebugNode));
6420
/**
6421
 * \@experimental
6422
 * @param {?} debugEls
6423
 * @return {?}
6424
 */
6425
function asNativeElements(debugEls) {
6426
    return debugEls.map(function (el) { return el.nativeElement; });
6427
}
6428
/**
6429
 * @param {?} element
6430
 * @param {?} predicate
6431
 * @param {?} matches
6432
 * @return {?}
6433
 */
6434
function _queryElementChildren(element, predicate, matches) {
6435
    element.childNodes.forEach(function (node) {
6436
        if (node instanceof DebugElement) {
6437
            if (predicate(node)) {
6438
                matches.push(node);
6439
            }
6440
            _queryElementChildren(node, predicate, matches);
6441
        }
6442
    });
6443
}
6444
/**
6445
 * @param {?} parentNode
6446
 * @param {?} predicate
6447
 * @param {?} matches
6448
 * @return {?}
6449
 */
6450
function _queryNodeChildren(parentNode, predicate, matches) {
6451
    if (parentNode instanceof DebugElement) {
6452
        parentNode.childNodes.forEach(function (node) {
6453
            if (predicate(node)) {
6454
                matches.push(node);
6455
            }
6456
            if (node instanceof DebugElement) {
6457
                _queryNodeChildren(node, predicate, matches);
6458
            }
6459
        });
6460
    }
6461
}
6462
// Need to keep the nodes in a global Map so that multiple angular apps are supported.
6463
var _nativeNodeToDebugNode = new Map();
6464
/**
6465
 * \@experimental
6466
 * @param {?} nativeNode
6467
 * @return {?}
6468
 */
6469
function getDebugNode(nativeNode) {
6470
    return _nativeNodeToDebugNode.get(nativeNode) || null;
6471
}
6472
/**
6473
 * @return {?}
6474
 */
6475
/**
6476
 * @param {?} node
6477
 * @return {?}
6478
 */
6479
function indexDebugNode(node) {
6480
    _nativeNodeToDebugNode.set(node.nativeNode, node);
6481
}
6482
/**
6483
 * @param {?} node
6484
 * @return {?}
6485
 */
6486
function removeDebugNodeFromIndex(node) {
6487
    _nativeNodeToDebugNode.delete(node.nativeNode);
6488
}
6489
/**
6490
 * @license
6491
 * Copyright Google Inc. All Rights Reserved.
6492
 *
6493
 * Use of this source code is governed by an MIT-style license that can be
6494
 * found in the LICENSE file at https://angular.io/license
6495
 */
6496
/**
6497
 * @param {?} a
6498
 * @param {?} b
6499
 * @return {?}
6500
 */
6501
function devModeEqual(a, b) {
6502
    var /** @type {?} */ isListLikeIterableA = isListLikeIterable(a);
6503
    var /** @type {?} */ isListLikeIterableB = isListLikeIterable(b);
6504
    if (isListLikeIterableA && isListLikeIterableB) {
6505
        return areIterablesEqual(a, b, devModeEqual);
6506
    }
6507
    else {
6508
        var /** @type {?} */ isAObject = a && (typeof a === 'object' || typeof a === 'function');
6509
        var /** @type {?} */ isBObject = b && (typeof b === 'object' || typeof b === 'function');
6510
        if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
6511
            return true;
6512
        }
6513
        else {
6514
            return looseIdentical(a, b);
6515
        }
6516
    }
6517
}
6518
/**
6519
 * Indicates that the result of a {\@link Pipe} transformation has changed even though the
6520
 * reference
6521
 * has not changed.
6522
 *
6523
 * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
6524
 *
6525
 * Example:
6526
 *
6527
 * ```
6528
 * if (this._latestValue === this._latestReturnedValue) {
6529
 *    return this._latestReturnedValue;
6530
 *  } else {
6531
 *    this._latestReturnedValue = this._latestValue;
6532
 *    return WrappedValue.wrap(this._latestValue); // this will force update
6533
 *  }
6534
 * ```
6535
 * \@stable
6536
 */
6537
var WrappedValue = (function () {
6538
    /**
6539
     * @param {?} wrapped
6540
     */
6541
    function WrappedValue(wrapped) {
6542
        this.wrapped = wrapped;
6543
    }
6544
    /**
6545
     * @param {?} value
6546
     * @return {?}
6547
     */
6548
    WrappedValue.wrap = function (value) { return new WrappedValue(value); };
6549
    return WrappedValue;
6550
}());
6551
/**
6552
 * Helper class for unwrapping WrappedValue s
6553
 */
6554
var ValueUnwrapper = (function () {
6555
    function ValueUnwrapper() {
6556
        this.hasWrappedValue = false;
6557
    }
6558
    /**
6559
     * @param {?} value
6560
     * @return {?}
6561
     */
6562
    ValueUnwrapper.prototype.unwrap = function (value) {
6563
        if (value instanceof WrappedValue) {
6564
            this.hasWrappedValue = true;
6565
            return value.wrapped;
6566
        }
6567
        return value;
6568
    };
6569
    /**
6570
     * @return {?}
6571
     */
6572
    ValueUnwrapper.prototype.reset = function () { this.hasWrappedValue = false; };
6573
    return ValueUnwrapper;
6574
}());
6575
/**
6576
 * Represents a basic change from a previous to a new value.
6577
 * \@stable
6578
 */
6579
var SimpleChange = (function () {
6580
    /**
6581
     * @param {?} previousValue
6582
     * @param {?} currentValue
6583
     * @param {?} firstChange
6584
     */
6585
    function SimpleChange(previousValue, currentValue, firstChange) {
6586
        this.previousValue = previousValue;
6587
        this.currentValue = currentValue;
6588
        this.firstChange = firstChange;
6589
    }
6590
    /**
6591
     * Check whether the new value is the first value assigned.
6592
     * @return {?}
6593
     */
6594
    SimpleChange.prototype.isFirstChange = function () { return this.firstChange; };
6595
    return SimpleChange;
6596
}());
6597
/**
6598
 * @param {?} obj
6599
 * @return {?}
6600
 */
6601
function isListLikeIterable(obj) {
6602
    if (!isJsObject(obj))
6603
        return false;
6604
    return Array.isArray(obj) ||
6605
        (!(obj instanceof Map) &&
6606
            getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
6607
}
6608
/**
6609
 * @param {?} a
6610
 * @param {?} b
6611
 * @param {?} comparator
6612
 * @return {?}
6613
 */
6614
function areIterablesEqual(a, b, comparator) {
6615
    var /** @type {?} */ iterator1 = a[getSymbolIterator()]();
6616
    var /** @type {?} */ iterator2 = b[getSymbolIterator()]();
6617
    while (true) {
6618
        var /** @type {?} */ item1 = iterator1.next();
6619
        var /** @type {?} */ item2 = iterator2.next();
6620
        if (item1.done && item2.done)
6621
            return true;
6622
        if (item1.done || item2.done)
6623
            return false;
6624
        if (!comparator(item1.value, item2.value))
6625
            return false;
6626
    }
6627
}
6628
/**
6629
 * @param {?} obj
6630
 * @param {?} fn
6631
 * @return {?}
6632
 */
6633
function iterateListLike(obj, fn) {
6634
    if (Array.isArray(obj)) {
6635
        for (var /** @type {?} */ i = 0; i < obj.length; i++) {
6636
            fn(obj[i]);
6637
        }
6638
    }
6639
    else {
6640
        var /** @type {?} */ iterator = obj[getSymbolIterator()]();
6641
        var /** @type {?} */ item = void 0;
6642
        while (!((item = iterator.next()).done)) {
6643
            fn(item.value);
6644
        }
6645
    }
6646
}
6647
/**
6648
 * @param {?} o
6649
 * @return {?}
6650
 */
6651
function isJsObject(o) {
6652
    return o !== null && (typeof o === 'function' || typeof o === 'object');
6653
}
6654
/**
6655
 * @license
6656
 * Copyright Google Inc. All Rights Reserved.
6657
 *
6658
 * Use of this source code is governed by an MIT-style license that can be
6659
 * found in the LICENSE file at https://angular.io/license
6660
 */
6661
var DefaultIterableDifferFactory = (function () {
6662
    function DefaultIterableDifferFactory() {
6663
    }
6664
    /**
6665
     * @param {?} obj
6666
     * @return {?}
6667
     */
6668
    DefaultIterableDifferFactory.prototype.supports = function (obj) { return isListLikeIterable(obj); };
6669
    /**
6670
     * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
6671
     * @template V
6672
     * @param {?=} cdRefOrTrackBy
6673
     * @param {?=} trackByFn
6674
     * @return {?}
6675
     */
6676
    DefaultIterableDifferFactory.prototype.create = function (cdRefOrTrackBy, trackByFn) {
6677
        return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
6678
    };
6679
    return DefaultIterableDifferFactory;
6680
}());
6681
var trackByIdentity = function (index, item) { return item; };
6682
/**
6683
 * @deprecated v4.0.0 - Should not be part of public API.
6684
 */
6685
var DefaultIterableDiffer = (function () {
6686
    /**
6687
     * @param {?=} trackByFn
6688
     */
6689
    function DefaultIterableDiffer(trackByFn) {
6690
        this._length = 0;
6691
        this._collection = null;
6692
        this._linkedRecords = null;
6693
        this._unlinkedRecords = null;
6694
        this._previousItHead = null;
6695
        this._itHead = null;
6696
        this._itTail = null;
6697
        this._additionsHead = null;
6698
        this._additionsTail = null;
6699
        this._movesHead = null;
6700
        this._movesTail = null;
6701
        this._removalsHead = null;
6702
        this._removalsTail = null;
6703
        this._identityChangesHead = null;
6704
        this._identityChangesTail = null;
6705
        this._trackByFn = trackByFn || trackByIdentity;
6706
    }
6707
    Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
6708
        /**
6709
         * @return {?}
6710
         */
6711
        get: function () { return this._collection; },
6712
        enumerable: true,
6713
        configurable: true
6714
    });
6715
    Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
6716
        /**
6717
         * @return {?}
6718
         */
6719
        get: function () { return this._length; },
6720
        enumerable: true,
6721
        configurable: true
6722
    });
6723
    /**
6724
     * @param {?} fn
6725
     * @return {?}
6726
     */
6727
    DefaultIterableDiffer.prototype.forEachItem = function (fn) {
6728
        var /** @type {?} */ record;
6729
        for (record = this._itHead; record !== null; record = record._next) {
6730
            fn(record);
6731
        }
6732
    };
6733
    /**
6734
     * @param {?} fn
6735
     * @return {?}
6736
     */
6737
    DefaultIterableDiffer.prototype.forEachOperation = function (fn) {
6738
        var /** @type {?} */ nextIt = this._itHead;
6739
        var /** @type {?} */ nextRemove = this._removalsHead;
6740
        var /** @type {?} */ addRemoveOffset = 0;
6741
        var /** @type {?} */ moveOffsets = null;
6742
        while (nextIt || nextRemove) {
6743
            // Figure out which is the next record to process
6744
            // Order: remove, add, move
6745
            var /** @type {?} */ record = !nextRemove ||
6746
                nextIt && ((nextIt.currentIndex)) <
6747
                    getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
6748
                nextRemove;
6749
            var /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
6750
            var /** @type {?} */ currentIndex = record.currentIndex;
6751
            // consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
6752
            if (record === nextRemove) {
6753
                addRemoveOffset--;
6754
                nextRemove = nextRemove._nextRemoved;
6755
            }
6756
            else {
6757
                nextIt = ((nextIt))._next;
6758
                if (record.previousIndex == null) {
6759
                    addRemoveOffset++;
6760
                }
6761
                else {
6762
                    // INVARIANT:  currentIndex < previousIndex
6763
                    if (!moveOffsets)
6764
                        moveOffsets = [];
6765
                    var /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
6766
                    var /** @type {?} */ localCurrentIndex = ((currentIndex)) - addRemoveOffset;
6767
                    if (localMovePreviousIndex != localCurrentIndex) {
6768
                        for (var /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
6769
                            var /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
6770
                            var /** @type {?} */ index = offset + i;
6771
                            if (localCurrentIndex <= index && index < localMovePreviousIndex) {
6772
                                moveOffsets[i] = offset + 1;
6773
                            }
6774
                        }
6775
                        var /** @type {?} */ previousIndex = record.previousIndex;
6776
                        moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
6777
                    }
6778
                }
6779
            }
6780
            if (adjPreviousIndex !== currentIndex) {
6781
                fn(record, adjPreviousIndex, currentIndex);
6782
            }
6783
        }
6784
    };
6785
    /**
6786
     * @param {?} fn
6787
     * @return {?}
6788
     */
6789
    DefaultIterableDiffer.prototype.forEachPreviousItem = function (fn) {
6790
        var /** @type {?} */ record;
6791
        for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
6792
            fn(record);
6793
        }
6794
    };
6795
    /**
6796
     * @param {?} fn
6797
     * @return {?}
6798
     */
6799
    DefaultIterableDiffer.prototype.forEachAddedItem = function (fn) {
6800
        var /** @type {?} */ record;
6801
        for (record = this._additionsHead; record !== null; record = record._nextAdded) {
6802
            fn(record);
6803
        }
6804
    };
6805
    /**
6806
     * @param {?} fn
6807
     * @return {?}
6808
     */
6809
    DefaultIterableDiffer.prototype.forEachMovedItem = function (fn) {
6810
        var /** @type {?} */ record;
6811
        for (record = this._movesHead; record !== null; record = record._nextMoved) {
6812
            fn(record);
6813
        }
6814
    };
6815
    /**
6816
     * @param {?} fn
6817
     * @return {?}
6818
     */
6819
    DefaultIterableDiffer.prototype.forEachRemovedItem = function (fn) {
6820
        var /** @type {?} */ record;
6821
        for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
6822
            fn(record);
6823
        }
6824
    };
6825
    /**
6826
     * @param {?} fn
6827
     * @return {?}
6828
     */
6829
    DefaultIterableDiffer.prototype.forEachIdentityChange = function (fn) {
6830
        var /** @type {?} */ record;
6831
        for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
6832
            fn(record);
6833
        }
6834
    };
6835
    /**
6836
     * @param {?} collection
6837
     * @return {?}
6838
     */
6839
    DefaultIterableDiffer.prototype.diff = function (collection) {
6840
        if (collection == null)
6841
            collection = [];
6842
        if (!isListLikeIterable(collection)) {
6843
            throw new Error("Error trying to diff '" + stringify(collection) + "'. Only arrays and iterables are allowed");
6844
        }
6845
        if (this.check(collection)) {
6846
            return this;
6847
        }
6848
        else {
6849
            return null;
6850
        }
6851
    };
6852
    /**
6853
     * @return {?}
6854
     */
6855
    DefaultIterableDiffer.prototype.onDestroy = function () { };
6856
    /**
6857
     * @param {?} collection
6858
     * @return {?}
6859
     */
6860
    DefaultIterableDiffer.prototype.check = function (collection) {
6861
        var _this = this;
6862
        this._reset();
6863
        var /** @type {?} */ record = this._itHead;
6864
        var /** @type {?} */ mayBeDirty = false;
6865
        var /** @type {?} */ index;
6866
        var /** @type {?} */ item;
6867
        var /** @type {?} */ itemTrackBy;
6868
        if (Array.isArray(collection)) {
6869
            this._length = collection.length;
6870
            for (var /** @type {?} */ index_1 = 0; index_1 < this._length; index_1++) {
6871
                item = collection[index_1];
6872
                itemTrackBy = this._trackByFn(index_1, item);
6873
                if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
6874
                    record = this._mismatch(record, item, itemTrackBy, index_1);
6875
                    mayBeDirty = true;
6876
                }
6877
                else {
6878
                    if (mayBeDirty) {
6879
                        // TODO(misko): can we limit this to duplicates only?
6880
                        record = this._verifyReinsertion(record, item, itemTrackBy, index_1);
6881
                    }
6882
                    if (!looseIdentical(record.item, item))
6883
                        this._addIdentityChange(record, item);
6884
                }
6885
                record = record._next;
6886
            }
6887
        }
6888
        else {
6889
            index = 0;
6890
            iterateListLike(collection, function (item) {
6891
                itemTrackBy = _this._trackByFn(index, item);
6892
                if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
6893
                    record = _this._mismatch(record, item, itemTrackBy, index);
6894
                    mayBeDirty = true;
6895
                }
6896
                else {
6897
                    if (mayBeDirty) {
6898
                        // TODO(misko): can we limit this to duplicates only?
6899
                        record = _this._verifyReinsertion(record, item, itemTrackBy, index);
6900
                    }
6901
                    if (!looseIdentical(record.item, item))
6902
                        _this._addIdentityChange(record, item);
6903
                }
6904
                record = record._next;
6905
                index++;
6906
            });
6907
            this._length = index;
6908
        }
6909
        this._truncate(record);
6910
        this._collection = collection;
6911
        return this.isDirty;
6912
    };
6913
    Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
6914
        /**
6915
         * @return {?}
6916
         */
6917
        get: function () {
6918
            return this._additionsHead !== null || this._movesHead !== null ||
6919
                this._removalsHead !== null || this._identityChangesHead !== null;
6920
        },
6921
        enumerable: true,
6922
        configurable: true
6923
    });
6924
    /**
6925
     * Reset the state of the change objects to show no changes. This means set previousKey to
6926
     * currentKey, and clear all of the queues (additions, moves, removals).
6927
     * Set the previousIndexes of moved and added items to their currentIndexes
6928
     * Reset the list of additions, moves and removals
6929
     *
6930
     * \@internal
6931
     * @return {?}
6932
     */
6933
    DefaultIterableDiffer.prototype._reset = function () {
6934
        if (this.isDirty) {
6935
            var /** @type {?} */ record = void 0;
6936
            var /** @type {?} */ nextRecord = void 0;
6937
            for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
6938
                record._nextPrevious = record._next;
6939
            }
6940
            for (record = this._additionsHead; record !== null; record = record._nextAdded) {
6941
                record.previousIndex = record.currentIndex;
6942
            }
6943
            this._additionsHead = this._additionsTail = null;
6944
            for (record = this._movesHead; record !== null; record = nextRecord) {
6945
                record.previousIndex = record.currentIndex;
6946
                nextRecord = record._nextMoved;
6947
            }
6948
            this._movesHead = this._movesTail = null;
6949
            this._removalsHead = this._removalsTail = null;
6950
            this._identityChangesHead = this._identityChangesTail = null;
6951
            // todo(vicb) when assert gets supported
6952
            // assert(!this.isDirty);
6953
        }
6954
    };
6955
    /**
6956
     * This is the core function which handles differences between collections.
6957
     *
6958
     * - `record` is the record which we saw at this position last time. If null then it is a new
6959
     *   item.
6960
     * - `item` is the current item in the collection
6961
     * - `index` is the position of the item in the collection
6962
     *
6963
     * \@internal
6964
     * @param {?} record
6965
     * @param {?} item
6966
     * @param {?} itemTrackBy
6967
     * @param {?} index
6968
     * @return {?}
6969
     */
6970
    DefaultIterableDiffer.prototype._mismatch = function (record, item, itemTrackBy, index) {
6971
        // The previous record after which we will append the current one.
6972
        var /** @type {?} */ previousRecord;
6973
        if (record === null) {
6974
            previousRecord = this._itTail;
6975
        }
6976
        else {
6977
            previousRecord = record._prev;
6978
            // Remove the record from the collection since we know it does not match the item.
6979
            this._remove(record);
6980
        }
6981
        // Attempt to see if we have seen the item before.
6982
        record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
6983
        if (record !== null) {
6984
            // We have seen this before, we need to move it forward in the collection.
6985
            // But first we need to check if identity changed, so we can update in view if necessary
6986
            if (!looseIdentical(record.item, item))
6987
                this._addIdentityChange(record, item);
6988
            this._moveAfter(record, previousRecord, index);
6989
        }
6990
        else {
6991
            // Never seen it, check evicted list.
6992
            record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
6993
            if (record !== null) {
6994
                // It is an item which we have evicted earlier: reinsert it back into the list.
6995
                // But first we need to check if identity changed, so we can update in view if necessary
6996
                if (!looseIdentical(record.item, item))
6997
                    this._addIdentityChange(record, item);
6998
                this._reinsertAfter(record, previousRecord, index);
6999
            }
7000
            else {
7001
                // It is a new item: add it.
7002
                record =
7003
                    this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
7004
            }
7005
        }
7006
        return record;
7007
    };
7008
    /**
7009
     * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
7010
     *
7011
     * Use case: `[a, a]` => `[b, a, a]`
7012
     *
7013
     * If we did not have this check then the insertion of `b` would:
7014
     *   1) evict first `a`
7015
     *   2) insert `b` at `0` index.
7016
     *   3) leave `a` at index `1` as is. <-- this is wrong!
7017
     *   3) reinsert `a` at index 2. <-- this is wrong!
7018
     *
7019
     * The correct behavior is:
7020
     *   1) evict first `a`
7021
     *   2) insert `b` at `0` index.
7022
     *   3) reinsert `a` at index 1.
7023
     *   3) move `a` at from `1` to `2`.
7024
     *
7025
     *
7026
     * Double check that we have not evicted a duplicate item. We need to check if the item type may
7027
     * have already been removed:
7028
     * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
7029
     * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
7030
     * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
7031
     * at the end.
7032
     *
7033
     * \@internal
7034
     * @param {?} record
7035
     * @param {?} item
7036
     * @param {?} itemTrackBy
7037
     * @param {?} index
7038
     * @return {?}
7039
     */
7040
    DefaultIterableDiffer.prototype._verifyReinsertion = function (record, item, itemTrackBy, index) {
7041
        var /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
7042
        if (reinsertRecord !== null) {
7043
            record = this._reinsertAfter(reinsertRecord, /** @type {?} */ ((record._prev)), index);
7044
        }
7045
        else if (record.currentIndex != index) {
7046
            record.currentIndex = index;
7047
            this._addToMoves(record, index);
7048
        }
7049
        return record;
7050
    };
7051
    /**
7052
     * Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
7053
     *
7054
     * - `record` The first excess {\@link IterableChangeRecord_}.
7055
     *
7056
     * \@internal
7057
     * @param {?} record
7058
     * @return {?}
7059
     */
7060
    DefaultIterableDiffer.prototype._truncate = function (record) {
7061
        // Anything after that needs to be removed;
7062
        while (record !== null) {
7063
            var /** @type {?} */ nextRecord = record._next;
7064
            this._addToRemovals(this._unlink(record));
7065
            record = nextRecord;
7066
        }
7067
        if (this._unlinkedRecords !== null) {
7068
            this._unlinkedRecords.clear();
7069
        }
7070
        if (this._additionsTail !== null) {
7071
            this._additionsTail._nextAdded = null;
7072
        }
7073
        if (this._movesTail !== null) {
7074
            this._movesTail._nextMoved = null;
7075
        }
7076
        if (this._itTail !== null) {
7077
            this._itTail._next = null;
7078
        }
7079
        if (this._removalsTail !== null) {
7080
            this._removalsTail._nextRemoved = null;
7081
        }
7082
        if (this._identityChangesTail !== null) {
7083
            this._identityChangesTail._nextIdentityChange = null;
7084
        }
7085
    };
7086
    /**
7087
     * \@internal
7088
     * @param {?} record
7089
     * @param {?} prevRecord
7090
     * @param {?} index
7091
     * @return {?}
7092
     */
7093
    DefaultIterableDiffer.prototype._reinsertAfter = function (record, prevRecord, index) {
7094
        if (this._unlinkedRecords !== null) {
7095
            this._unlinkedRecords.remove(record);
7096
        }
7097
        var /** @type {?} */ prev = record._prevRemoved;
7098
        var /** @type {?} */ next = record._nextRemoved;
7099
        if (prev === null) {
7100
            this._removalsHead = next;
7101
        }
7102
        else {
7103
            prev._nextRemoved = next;
7104
        }
7105
        if (next === null) {
7106
            this._removalsTail = prev;
7107
        }
7108
        else {
7109
            next._prevRemoved = prev;
7110
        }
7111
        this._insertAfter(record, prevRecord, index);
7112
        this._addToMoves(record, index);
7113
        return record;
7114
    };
7115
    /**
7116
     * \@internal
7117
     * @param {?} record
7118
     * @param {?} prevRecord
7119
     * @param {?} index
7120
     * @return {?}
7121
     */
7122
    DefaultIterableDiffer.prototype._moveAfter = function (record, prevRecord, index) {
7123
        this._unlink(record);
7124
        this._insertAfter(record, prevRecord, index);
7125
        this._addToMoves(record, index);
7126
        return record;
7127
    };
7128
    /**
7129
     * \@internal
7130
     * @param {?} record
7131
     * @param {?} prevRecord
7132
     * @param {?} index
7133
     * @return {?}
7134
     */
7135
    DefaultIterableDiffer.prototype._addAfter = function (record, prevRecord, index) {
7136
        this._insertAfter(record, prevRecord, index);
7137
        if (this._additionsTail === null) {
7138
            // todo(vicb)
7139
            // assert(this._additionsHead === null);
7140
            this._additionsTail = this._additionsHead = record;
7141
        }
7142
        else {
7143
            // todo(vicb)
7144
            // assert(_additionsTail._nextAdded === null);
7145
            // assert(record._nextAdded === null);
7146
            this._additionsTail = this._additionsTail._nextAdded = record;
7147
        }
7148
        return record;
7149
    };
7150
    /**
7151
     * \@internal
7152
     * @param {?} record
7153
     * @param {?} prevRecord
7154
     * @param {?} index
7155
     * @return {?}
7156
     */
7157
    DefaultIterableDiffer.prototype._insertAfter = function (record, prevRecord, index) {
7158
        // todo(vicb)
7159
        // assert(record != prevRecord);
7160
        // assert(record._next === null);
7161
        // assert(record._prev === null);
7162
        var /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
7163
        // todo(vicb)
7164
        // assert(next != record);
7165
        // assert(prevRecord != record);
7166
        record._next = next;
7167
        record._prev = prevRecord;
7168
        if (next === null) {
7169
            this._itTail = record;
7170
        }
7171
        else {
7172
            next._prev = record;
7173
        }
7174
        if (prevRecord === null) {
7175
            this._itHead = record;
7176
        }
7177
        else {
7178
            prevRecord._next = record;
7179
        }
7180
        if (this._linkedRecords === null) {
7181
            this._linkedRecords = new _DuplicateMap();
7182
        }
7183
        this._linkedRecords.put(record);
7184
        record.currentIndex = index;
7185
        return record;
7186
    };
7187
    /**
7188
     * \@internal
7189
     * @param {?} record
7190
     * @return {?}
7191
     */
7192
    DefaultIterableDiffer.prototype._remove = function (record) {
7193
        return this._addToRemovals(this._unlink(record));
7194
    };
7195
    /**
7196
     * \@internal
7197
     * @param {?} record
7198
     * @return {?}
7199
     */
7200
    DefaultIterableDiffer.prototype._unlink = function (record) {
7201
        if (this._linkedRecords !== null) {
7202
            this._linkedRecords.remove(record);
7203
        }
7204
        var /** @type {?} */ prev = record._prev;
7205
        var /** @type {?} */ next = record._next;
7206
        // todo(vicb)
7207
        // assert((record._prev = null) === null);
7208
        // assert((record._next = null) === null);
7209
        if (prev === null) {
7210
            this._itHead = next;
7211
        }
7212
        else {
7213
            prev._next = next;
7214
        }
7215
        if (next === null) {
7216
            this._itTail = prev;
7217
        }
7218
        else {
7219
            next._prev = prev;
7220
        }
7221
        return record;
7222
    };
7223
    /**
7224
     * \@internal
7225
     * @param {?} record
7226
     * @param {?} toIndex
7227
     * @return {?}
7228
     */
7229
    DefaultIterableDiffer.prototype._addToMoves = function (record, toIndex) {
7230
        // todo(vicb)
7231
        // assert(record._nextMoved === null);
7232
        if (record.previousIndex === toIndex) {
7233
            return record;
7234
        }
7235
        if (this._movesTail === null) {
7236
            // todo(vicb)
7237
            // assert(_movesHead === null);
7238
            this._movesTail = this._movesHead = record;
7239
        }
7240
        else {
7241
            // todo(vicb)
7242
            // assert(_movesTail._nextMoved === null);
7243
            this._movesTail = this._movesTail._nextMoved = record;
7244
        }
7245
        return record;
7246
    };
7247
    /**
7248
     * @param {?} record
7249
     * @return {?}
7250
     */
7251
    DefaultIterableDiffer.prototype._addToRemovals = function (record) {
7252
        if (this._unlinkedRecords === null) {
7253
            this._unlinkedRecords = new _DuplicateMap();
7254
        }
7255
        this._unlinkedRecords.put(record);
7256
        record.currentIndex = null;
7257
        record._nextRemoved = null;
7258
        if (this._removalsTail === null) {
7259
            // todo(vicb)
7260
            // assert(_removalsHead === null);
7261
            this._removalsTail = this._removalsHead = record;
7262
            record._prevRemoved = null;
7263
        }
7264
        else {
7265
            // todo(vicb)
7266
            // assert(_removalsTail._nextRemoved === null);
7267
            // assert(record._nextRemoved === null);
7268
            record._prevRemoved = this._removalsTail;
7269
            this._removalsTail = this._removalsTail._nextRemoved = record;
7270
        }
7271
        return record;
7272
    };
7273
    /**
7274
     * \@internal
7275
     * @param {?} record
7276
     * @param {?} item
7277
     * @return {?}
7278
     */
7279
    DefaultIterableDiffer.prototype._addIdentityChange = function (record, item) {
7280
        record.item = item;
7281
        if (this._identityChangesTail === null) {
7282
            this._identityChangesTail = this._identityChangesHead = record;
7283
        }
7284
        else {
7285
            this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
7286
        }
7287
        return record;
7288
    };
7289
    /**
7290
     * @return {?}
7291
     */
7292
    DefaultIterableDiffer.prototype.toString = function () {
7293
        var /** @type {?} */ list = [];
7294
        this.forEachItem(function (record) { return list.push(record); });
7295
        var /** @type {?} */ previous = [];
7296
        this.forEachPreviousItem(function (record) { return previous.push(record); });
7297
        var /** @type {?} */ additions = [];
7298
        this.forEachAddedItem(function (record) { return additions.push(record); });
7299
        var /** @type {?} */ moves = [];
7300
        this.forEachMovedItem(function (record) { return moves.push(record); });
7301
        var /** @type {?} */ removals = [];
7302
        this.forEachRemovedItem(function (record) { return removals.push(record); });
7303
        var /** @type {?} */ identityChanges = [];
7304
        this.forEachIdentityChange(function (record) { return identityChanges.push(record); });
7305
        return 'collection: ' + list.join(', ') + '\n' +
7306
            'previous: ' + previous.join(', ') + '\n' +
7307
            'additions: ' + additions.join(', ') + '\n' +
7308
            'moves: ' + moves.join(', ') + '\n' +
7309
            'removals: ' + removals.join(', ') + '\n' +
7310
            'identityChanges: ' + identityChanges.join(', ') + '\n';
7311
    };
7312
    return DefaultIterableDiffer;
7313
}());
7314
/**
7315
 * \@stable
7316
 */
7317
var IterableChangeRecord_ = (function () {
7318
    /**
7319
     * @param {?} item
7320
     * @param {?} trackById
7321
     */
7322
    function IterableChangeRecord_(item, trackById) {
7323
        this.item = item;
7324
        this.trackById = trackById;
7325
        this.currentIndex = null;
7326
        this.previousIndex = null;
7327
        /**
7328
         * \@internal
7329
         */
7330
        this._nextPrevious = null;
7331
        /**
7332
         * \@internal
7333
         */
7334
        this._prev = null;
7335
        /**
7336
         * \@internal
7337
         */
7338
        this._next = null;
7339
        /**
7340
         * \@internal
7341
         */
7342
        this._prevDup = null;
7343
        /**
7344
         * \@internal
7345
         */
7346
        this._nextDup = null;
7347
        /**
7348
         * \@internal
7349
         */
7350
        this._prevRemoved = null;
7351
        /**
7352
         * \@internal
7353
         */
7354
        this._nextRemoved = null;
7355
        /**
7356
         * \@internal
7357
         */
7358
        this._nextAdded = null;
7359
        /**
7360
         * \@internal
7361
         */
7362
        this._nextMoved = null;
7363
        /**
7364
         * \@internal
7365
         */
7366
        this._nextIdentityChange = null;
7367
    }
7368
    /**
7369
     * @return {?}
7370
     */
7371
    IterableChangeRecord_.prototype.toString = function () {
7372
        return this.previousIndex === this.currentIndex ? stringify(this.item) :
7373
            stringify(this.item) + '[' +
7374
                stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
7375
    };
7376
    return IterableChangeRecord_;
7377
}());
7378
var _DuplicateItemRecordList = (function () {
7379
    function _DuplicateItemRecordList() {
7380
        /**
7381
         * \@internal
7382
         */
7383
        this._head = null;
7384
        /**
7385
         * \@internal
7386
         */
7387
        this._tail = null;
7388
    }
7389
    /**
7390
     * Append the record to the list of duplicates.
7391
     *
7392
     * Note: by design all records in the list of duplicates hold the same value in record.item.
7393
     * @param {?} record
7394
     * @return {?}
7395
     */
7396
    _DuplicateItemRecordList.prototype.add = function (record) {
7397
        if (this._head === null) {
7398
            this._head = this._tail = record;
7399
            record._nextDup = null;
7400
            record._prevDup = null;
7401
        }
7402
        else {
7403
            ((
7404
            // todo(vicb)
7405
            // assert(record.item ==  _head.item ||
7406
            //       record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
7407
            this._tail))._nextDup = record;
7408
            record._prevDup = this._tail;
7409
            record._nextDup = null;
7410
            this._tail = record;
7411
        }
7412
    };
7413
    /**
7414
     * @param {?} trackById
7415
     * @param {?} atOrAfterIndex
7416
     * @return {?}
7417
     */
7418
    _DuplicateItemRecordList.prototype.get = function (trackById, atOrAfterIndex) {
7419
        var /** @type {?} */ record;
7420
        for (record = this._head; record !== null; record = record._nextDup) {
7421
            if ((atOrAfterIndex === null || atOrAfterIndex <= ((record.currentIndex))) &&
7422
                looseIdentical(record.trackById, trackById)) {
7423
                return record;
7424
            }
7425
        }
7426
        return null;
7427
    };
7428
    /**
7429
     * Remove one {\@link IterableChangeRecord_} from the list of duplicates.
7430
     *
7431
     * Returns whether the list of duplicates is empty.
7432
     * @param {?} record
7433
     * @return {?}
7434
     */
7435
    _DuplicateItemRecordList.prototype.remove = function (record) {
7436
        // todo(vicb)
7437
        // assert(() {
7438
        //  // verify that the record being removed is in the list.
7439
        //  for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
7440
        //    if (identical(cursor, record)) return true;
7441
        //  }
7442
        //  return false;
7443
        //});
7444
        var /** @type {?} */ prev = record._prevDup;
7445
        var /** @type {?} */ next = record._nextDup;
7446
        if (prev === null) {
7447
            this._head = next;
7448
        }
7449
        else {
7450
            prev._nextDup = next;
7451
        }
7452
        if (next === null) {
7453
            this._tail = prev;
7454
        }
7455
        else {
7456
            next._prevDup = prev;
7457
        }
7458
        return this._head === null;
7459
    };
7460
    return _DuplicateItemRecordList;
7461
}());
7462
var _DuplicateMap = (function () {
7463
    function _DuplicateMap() {
7464
        this.map = new Map();
7465
    }
7466
    /**
7467
     * @param {?} record
7468
     * @return {?}
7469
     */
7470
    _DuplicateMap.prototype.put = function (record) {
7471
        var /** @type {?} */ key = record.trackById;
7472
        var /** @type {?} */ duplicates = this.map.get(key);
7473
        if (!duplicates) {
7474
            duplicates = new _DuplicateItemRecordList();
7475
            this.map.set(key, duplicates);
7476
        }
7477
        duplicates.add(record);
7478
    };
7479
    /**
7480
     * Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
7481
     * have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
7482
     *
7483
     * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
7484
     * have any more `a`s needs to return the second `a`.
7485
     * @param {?} trackById
7486
     * @param {?} atOrAfterIndex
7487
     * @return {?}
7488
     */
7489
    _DuplicateMap.prototype.get = function (trackById, atOrAfterIndex) {
7490
        var /** @type {?} */ key = trackById;
7491
        var /** @type {?} */ recordList = this.map.get(key);
7492
        return recordList ? recordList.get(trackById, atOrAfterIndex) : null;
7493
    };
7494
    /**
7495
     * Removes a {\@link IterableChangeRecord_} from the list of duplicates.
7496
     *
7497
     * The list of duplicates also is removed from the map if it gets empty.
7498
     * @param {?} record
7499
     * @return {?}
7500
     */
7501
    _DuplicateMap.prototype.remove = function (record) {
7502
        var /** @type {?} */ key = record.trackById;
7503
        var /** @type {?} */ recordList = ((this.map.get(key)));
7504
        // Remove the list of duplicates when it gets empty
7505
        if (recordList.remove(record)) {
7506
            this.map.delete(key);
7507
        }
7508
        return record;
7509
    };
7510
    Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
7511
        /**
7512
         * @return {?}
7513
         */
7514
        get: function () { return this.map.size === 0; },
7515
        enumerable: true,
7516
        configurable: true
7517
    });
7518
    /**
7519
     * @return {?}
7520
     */
7521
    _DuplicateMap.prototype.clear = function () { this.map.clear(); };
7522
    /**
7523
     * @return {?}
7524
     */
7525
    _DuplicateMap.prototype.toString = function () { return '_DuplicateMap(' + stringify(this.map) + ')'; };
7526
    return _DuplicateMap;
7527
}());
7528
/**
7529
 * @param {?} item
7530
 * @param {?} addRemoveOffset
7531
 * @param {?} moveOffsets
7532
 * @return {?}
7533
 */
7534
function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
7535
    var /** @type {?} */ previousIndex = item.previousIndex;
7536
    if (previousIndex === null)
7537
        return previousIndex;
7538
    var /** @type {?} */ moveOffset = 0;
7539
    if (moveOffsets && previousIndex < moveOffsets.length) {
7540
        moveOffset = moveOffsets[previousIndex];
7541
    }
7542
    return previousIndex + addRemoveOffset + moveOffset;
7543
}
7544
/**
7545
 * @license
7546
 * Copyright Google Inc. All Rights Reserved.
7547
 *
7548
 * Use of this source code is governed by an MIT-style license that can be
7549
 * found in the LICENSE file at https://angular.io/license
7550
 */
7551
var DefaultKeyValueDifferFactory = (function () {
7552
    function DefaultKeyValueDifferFactory() {
7553
    }
7554
    /**
7555
     * @param {?} obj
7556
     * @return {?}
7557
     */
7558
    DefaultKeyValueDifferFactory.prototype.supports = function (obj) { return obj instanceof Map || isJsObject(obj); };
7559
    /**
7560
     * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
7561
     * @template K, V
7562
     * @param {?=} cd
7563
     * @return {?}
7564
     */
7565
    DefaultKeyValueDifferFactory.prototype.create = function (cd) {
7566
        return new DefaultKeyValueDiffer();
7567
    };
7568
    return DefaultKeyValueDifferFactory;
7569
}());
7570
var DefaultKeyValueDiffer = (function () {
7571
    function DefaultKeyValueDiffer() {
7572
        this._records = new Map();
7573
        this._mapHead = null;
7574
        this._appendAfter = null;
7575
        this._previousMapHead = null;
7576
        this._changesHead = null;
7577
        this._changesTail = null;
7578
        this._additionsHead = null;
7579
        this._additionsTail = null;
7580
        this._removalsHead = null;
7581
        this._removalsTail = null;
7582
    }
7583
    Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
7584
        /**
7585
         * @return {?}
7586
         */
7587
        get: function () {
7588
            return this._additionsHead !== null || this._changesHead !== null ||
7589
                this._removalsHead !== null;
7590
        },
7591
        enumerable: true,
7592
        configurable: true
7593
    });
7594
    /**
7595
     * @param {?} fn
7596
     * @return {?}
7597
     */
7598
    DefaultKeyValueDiffer.prototype.forEachItem = function (fn) {
7599
        var /** @type {?} */ record;
7600
        for (record = this._mapHead; record !== null; record = record._next) {
7601
            fn(record);
7602
        }
7603
    };
7604
    /**
7605
     * @param {?} fn
7606
     * @return {?}
7607
     */
7608
    DefaultKeyValueDiffer.prototype.forEachPreviousItem = function (fn) {
7609
        var /** @type {?} */ record;
7610
        for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
7611
            fn(record);
7612
        }
7613
    };
7614
    /**
7615
     * @param {?} fn
7616
     * @return {?}
7617
     */
7618
    DefaultKeyValueDiffer.prototype.forEachChangedItem = function (fn) {
7619
        var /** @type {?} */ record;
7620
        for (record = this._changesHead; record !== null; record = record._nextChanged) {
7621
            fn(record);
7622
        }
7623
    };
7624
    /**
7625
     * @param {?} fn
7626
     * @return {?}
7627
     */
7628
    DefaultKeyValueDiffer.prototype.forEachAddedItem = function (fn) {
7629
        var /** @type {?} */ record;
7630
        for (record = this._additionsHead; record !== null; record = record._nextAdded) {
7631
            fn(record);
7632
        }
7633
    };
7634
    /**
7635
     * @param {?} fn
7636
     * @return {?}
7637
     */
7638
    DefaultKeyValueDiffer.prototype.forEachRemovedItem = function (fn) {
7639
        var /** @type {?} */ record;
7640
        for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
7641
            fn(record);
7642
        }
7643
    };
7644
    /**
7645
     * @param {?=} map
7646
     * @return {?}
7647
     */
7648
    DefaultKeyValueDiffer.prototype.diff = function (map) {
7649
        if (!map) {
7650
            map = new Map();
7651
        }
7652
        else if (!(map instanceof Map || isJsObject(map))) {
7653
            throw new Error("Error trying to diff '" + stringify(map) + "'. Only maps and objects are allowed");
7654
        }
7655
        return this.check(map) ? this : null;
7656
    };
7657
    /**
7658
     * @return {?}
7659
     */
7660
    DefaultKeyValueDiffer.prototype.onDestroy = function () { };
7661
    /**
7662
     * Check the current state of the map vs the previous.
7663
     * The algorithm is optimised for when the keys do no change.
7664
     * @param {?} map
7665
     * @return {?}
7666
     */
7667
    DefaultKeyValueDiffer.prototype.check = function (map) {
7668
        var _this = this;
7669
        this._reset();
7670
        var /** @type {?} */ insertBefore = this._mapHead;
7671
        this._appendAfter = null;
7672
        this._forEach(map, function (value, key) {
7673
            if (insertBefore && insertBefore.key === key) {
7674
                _this._maybeAddToChanges(insertBefore, value);
7675
                _this._appendAfter = insertBefore;
7676
                insertBefore = insertBefore._next;
7677
            }
7678
            else {
7679
                var /** @type {?} */ record = _this._getOrCreateRecordForKey(key, value);
7680
                insertBefore = _this._insertBeforeOrAppend(insertBefore, record);
7681
            }
7682
        });
7683
        // Items remaining at the end of the list have been deleted
7684
        if (insertBefore) {
7685
            if (insertBefore._prev) {
7686
                insertBefore._prev._next = null;
7687
            }
7688
            this._removalsHead = insertBefore;
7689
            for (var /** @type {?} */ record = insertBefore; record !== null; record = record._nextRemoved) {
7690
                if (record === this._mapHead) {
7691
                    this._mapHead = null;
7692
                }
7693
                this._records.delete(record.key);
7694
                record._nextRemoved = record._next;
7695
                record.previousValue = record.currentValue;
7696
                record.currentValue = null;
7697
                record._prev = null;
7698
                record._next = null;
7699
            }
7700
        }
7701
        // Make sure tails have no next records from previous runs
7702
        if (this._changesTail)
7703
            this._changesTail._nextChanged = null;
7704
        if (this._additionsTail)
7705
            this._additionsTail._nextAdded = null;
7706
        return this.isDirty;
7707
    };
7708
    /**
7709
     * Inserts a record before `before` or append at the end of the list when `before` is null.
7710
     *
7711
     * Notes:
7712
     * - This method appends at `this._appendAfter`,
7713
     * - This method updates `this._appendAfter`,
7714
     * - The return value is the new value for the insertion pointer.
7715
     * @param {?} before
7716
     * @param {?} record
7717
     * @return {?}
7718
     */
7719
    DefaultKeyValueDiffer.prototype._insertBeforeOrAppend = function (before, record) {
7720
        if (before) {
7721
            var /** @type {?} */ prev = before._prev;
7722
            record._next = before;
7723
            record._prev = prev;
7724
            before._prev = record;
7725
            if (prev) {
7726
                prev._next = record;
7727
            }
7728
            if (before === this._mapHead) {
7729
                this._mapHead = record;
7730
            }
7731
            this._appendAfter = before;
7732
            return before;
7733
        }
7734
        if (this._appendAfter) {
7735
            this._appendAfter._next = record;
7736
            record._prev = this._appendAfter;
7737
        }
7738
        else {
7739
            this._mapHead = record;
7740
        }
7741
        this._appendAfter = record;
7742
        return null;
7743
    };
7744
    /**
7745
     * @param {?} key
7746
     * @param {?} value
7747
     * @return {?}
7748
     */
7749
    DefaultKeyValueDiffer.prototype._getOrCreateRecordForKey = function (key, value) {
7750
        if (this._records.has(key)) {
7751
            var /** @type {?} */ record_1 = ((this._records.get(key)));
7752
            this._maybeAddToChanges(record_1, value);
7753
            var /** @type {?} */ prev = record_1._prev;
7754
            var /** @type {?} */ next = record_1._next;
7755
            if (prev) {
7756
                prev._next = next;
7757
            }
7758
            if (next) {
7759
                next._prev = prev;
7760
            }
7761
            record_1._next = null;
7762
            record_1._prev = null;
7763
            return record_1;
7764
        }
7765
        var /** @type {?} */ record = new KeyValueChangeRecord_(key);
7766
        this._records.set(key, record);
7767
        record.currentValue = value;
7768
        this._addToAdditions(record);
7769
        return record;
7770
    };
7771
    /**
7772
     * \@internal
7773
     * @return {?}
7774
     */
7775
    DefaultKeyValueDiffer.prototype._reset = function () {
7776
        if (this.isDirty) {
7777
            var /** @type {?} */ record = void 0;
7778
            // let `_previousMapHead` contain the state of the map before the changes
7779
            this._previousMapHead = this._mapHead;
7780
            for (record = this._previousMapHead; record !== null; record = record._next) {
7781
                record._nextPrevious = record._next;
7782
            }
7783
            // Update `record.previousValue` with the value of the item before the changes
7784
            // We need to update all changed items (that's those which have been added and changed)
7785
            for (record = this._changesHead; record !== null; record = record._nextChanged) {
7786
                record.previousValue = record.currentValue;
7787
            }
7788
            for (record = this._additionsHead; record != null; record = record._nextAdded) {
7789
                record.previousValue = record.currentValue;
7790
            }
7791
            this._changesHead = this._changesTail = null;
7792
            this._additionsHead = this._additionsTail = null;
7793
            this._removalsHead = null;
7794
        }
7795
    };
7796
    /**
7797
     * @param {?} record
7798
     * @param {?} newValue
7799
     * @return {?}
7800
     */
7801
    DefaultKeyValueDiffer.prototype._maybeAddToChanges = function (record, newValue) {
7802
        if (!looseIdentical(newValue, record.currentValue)) {
7803
            record.previousValue = record.currentValue;
7804
            record.currentValue = newValue;
7805
            this._addToChanges(record);
7806
        }
7807
    };
7808
    /**
7809
     * @param {?} record
7810
     * @return {?}
7811
     */
7812
    DefaultKeyValueDiffer.prototype._addToAdditions = function (record) {
7813
        if (this._additionsHead === null) {
7814
            this._additionsHead = this._additionsTail = record;
7815
        }
7816
        else {
7817
            ((this._additionsTail))._nextAdded = record;
7818
            this._additionsTail = record;
7819
        }
7820
    };
7821
    /**
7822
     * @param {?} record
7823
     * @return {?}
7824
     */
7825
    DefaultKeyValueDiffer.prototype._addToChanges = function (record) {
7826
        if (this._changesHead === null) {
7827
            this._changesHead = this._changesTail = record;
7828
        }
7829
        else {
7830
            ((this._changesTail))._nextChanged = record;
7831
            this._changesTail = record;
7832
        }
7833
    };
7834
    /**
7835
     * \@internal
7836
     * @template K, V
7837
     * @param {?} obj
7838
     * @param {?} fn
7839
     * @return {?}
7840
     */
7841
    DefaultKeyValueDiffer.prototype._forEach = function (obj, fn) {
7842
        if (obj instanceof Map) {
7843
            obj.forEach(fn);
7844
        }
7845
        else {
7846
            Object.keys(obj).forEach(function (k) { return fn(obj[k], k); });
7847
        }
7848
    };
7849
    return DefaultKeyValueDiffer;
7850
}());
7851
/**
7852
 * \@stable
7853
 */
7854
var KeyValueChangeRecord_ = (function () {
7855
    /**
7856
     * @param {?} key
7857
     */
7858
    function KeyValueChangeRecord_(key) {
7859
        this.key = key;
7860
        this.previousValue = null;
7861
        this.currentValue = null;
7862
        /**
7863
         * \@internal
7864
         */
7865
        this._nextPrevious = null;
7866
        /**
7867
         * \@internal
7868
         */
7869
        this._next = null;
7870
        /**
7871
         * \@internal
7872
         */
7873
        this._prev = null;
7874
        /**
7875
         * \@internal
7876
         */
7877
        this._nextAdded = null;
7878
        /**
7879
         * \@internal
7880
         */
7881
        this._nextRemoved = null;
7882
        /**
7883
         * \@internal
7884
         */
7885
        this._nextChanged = null;
7886
    }
7887
    return KeyValueChangeRecord_;
7888
}());
7889
/**
7890
 * @license
7891
 * Copyright Google Inc. All Rights Reserved.
7892
 *
7893
 * Use of this source code is governed by an MIT-style license that can be
7894
 * found in the LICENSE file at https://angular.io/license
7895
 */
7896
/**
7897
 * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
7898
 * \@stable
7899
 */
7900
var IterableDiffers = (function () {
7901
    /**
7902
     * @param {?} factories
7903
     */
7904
    function IterableDiffers(factories) {
7905
        this.factories = factories;
7906
    }
7907
    /**
7908
     * @param {?} factories
7909
     * @param {?=} parent
7910
     * @return {?}
7911
     */
7912
    IterableDiffers.create = function (factories, parent) {
7913
        if (parent != null) {
7914
            var /** @type {?} */ copied = parent.factories.slice();
7915
            factories = factories.concat(copied);
7916
            return new IterableDiffers(factories);
7917
        }
7918
        else {
7919
            return new IterableDiffers(factories);
7920
        }
7921
    };
7922
    /**
7923
     * Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
7924
     * inherited {\@link IterableDiffers} instance with the provided factories and return a new
7925
     * {\@link IterableDiffers} instance.
7926
     *
7927
     * The following example shows how to extend an existing list of factories,
7928
     * which will only be applied to the injector for this component and its children.
7929
     * This step is all that's required to make a new {\@link IterableDiffer} available.
7930
     *
7931
     * ### Example
7932
     *
7933
     * ```
7934
     * \@Component({
7935
     *   viewProviders: [
7936
     *     IterableDiffers.extend([new ImmutableListDiffer()])
7937
     *   ]
7938
     * })
7939
     * ```
7940
     * @param {?} factories
7941
     * @return {?}
7942
     */
7943
    IterableDiffers.extend = function (factories) {
7944
        return {
7945
            provide: IterableDiffers,
7946
            useFactory: function (parent) {
7947
                if (!parent) {
7948
                    // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
7949
                    // to
7950
                    // bootstrap(), which would override default pipes instead of extending them.
7951
                    throw new Error('Cannot extend IterableDiffers without a parent injector');
7952
                }
7953
                return IterableDiffers.create(factories, parent);
7954
            },
7955
            // Dependency technically isn't optional, but we can provide a better error message this way.
7956
            deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
7957
        };
7958
    };
7959
    /**
7960
     * @param {?} iterable
7961
     * @return {?}
7962
     */
7963
    IterableDiffers.prototype.find = function (iterable) {
7964
        var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(iterable); });
7965
        if (factory != null) {
7966
            return factory;
7967
        }
7968
        else {
7969
            throw new Error("Cannot find a differ supporting object '" + iterable + "' of type '" + getTypeNameForDebugging(iterable) + "'");
7970
        }
7971
    };
7972
    return IterableDiffers;
7973
}());
7974
/**
7975
 * @param {?} type
7976
 * @return {?}
7977
 */
7978
function getTypeNameForDebugging(type) {
7979
    return type['name'] || typeof type;
7980
}
7981
/**
7982
 * @license
7983
 * Copyright Google Inc. All Rights Reserved.
7984
 *
7985
 * Use of this source code is governed by an MIT-style license that can be
7986
 * found in the LICENSE file at https://angular.io/license
7987
 */
7988
/**
7989
 * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
7990
 * \@stable
7991
 */
7992
var KeyValueDiffers = (function () {
7993
    /**
7994
     * @param {?} factories
7995
     */
7996
    function KeyValueDiffers(factories) {
7997
        this.factories = factories;
7998
    }
7999
    /**
8000
     * @template S
8001
     * @param {?} factories
8002
     * @param {?=} parent
8003
     * @return {?}
8004
     */
8005
    KeyValueDiffers.create = function (factories, parent) {
8006
        if (parent) {
8007
            var /** @type {?} */ copied = parent.factories.slice();
8008
            factories = factories.concat(copied);
8009
        }
8010
        return new KeyValueDiffers(factories);
8011
    };
8012
    /**
8013
     * Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
8014
     * inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
8015
     * {\@link KeyValueDiffers} instance.
8016
     *
8017
     * The following example shows how to extend an existing list of factories,
8018
     * which will only be applied to the injector for this component and its children.
8019
     * This step is all that's required to make a new {\@link KeyValueDiffer} available.
8020
     *
8021
     * ### Example
8022
     *
8023
     * ```
8024
     * \@Component({
8025
     *   viewProviders: [
8026
     *     KeyValueDiffers.extend([new ImmutableMapDiffer()])
8027
     *   ]
8028
     * })
8029
     * ```
8030
     * @template S
8031
     * @param {?} factories
8032
     * @return {?}
8033
     */
8034
    KeyValueDiffers.extend = function (factories) {
8035
        return {
8036
            provide: KeyValueDiffers,
8037
            useFactory: function (parent) {
8038
                if (!parent) {
8039
                    // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
8040
                    // to bootstrap(), which would override default pipes instead of extending them.
8041
                    throw new Error('Cannot extend KeyValueDiffers without a parent injector');
8042
                }
8043
                return KeyValueDiffers.create(factories, parent);
8044
            },
8045
            // Dependency technically isn't optional, but we can provide a better error message this way.
8046
            deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
8047
        };
8048
    };
8049
    /**
8050
     * @param {?} kv
8051
     * @return {?}
8052
     */
8053
    KeyValueDiffers.prototype.find = function (kv) {
8054
        var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(kv); });
8055
        if (factory) {
8056
            return factory;
8057
        }
8058
        throw new Error("Cannot find a differ supporting object '" + kv + "'");
8059
    };
8060
    return KeyValueDiffers;
8061
}());
8062
/**
8063
 * @license
8064
 * Copyright Google Inc. All Rights Reserved.
8065
 *
8066
 * Use of this source code is governed by an MIT-style license that can be
8067
 * found in the LICENSE file at https://angular.io/license
8068
 */
8069
/**
8070
 * Structural diffing for `Object`s and `Map`s.
8071
 */
8072
var keyValDiff = [new DefaultKeyValueDifferFactory()];
8073
/**
8074
 * Structural diffing for `Iterable` types such as `Array`s.
8075
 */
8076
var iterableDiff = [new DefaultIterableDifferFactory()];
8077
var defaultIterableDiffers = new IterableDiffers(iterableDiff);
8078
var defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
8079
/**
8080
 * @license
8081
 * Copyright Google Inc. All Rights Reserved.
8082
 *
8083
 * Use of this source code is governed by an MIT-style license that can be
8084
 * found in the LICENSE file at https://angular.io/license
8085
 */
8086
/**
8087
 * @module
8088
 * @description
8089
 * Change detection enables data binding in Angular.
8090
 */
8091
/**
8092
 * @license
8093
 * Copyright Google Inc. All Rights Reserved.
8094
 *
8095
 * Use of this source code is governed by an MIT-style license that can be
8096
 * found in the LICENSE file at https://angular.io/license
8097
 */
8098
/**
8099
 * @return {?}
8100
 */
8101
function _reflector() {
8102
    return reflector;
8103
}
8104
var _CORE_PLATFORM_PROVIDERS = [
8105
    // Set a default platform name for platforms that don't set it explicitly.
8106
    { provide: PLATFORM_ID, useValue: 'unknown' },
8107
    PlatformRef_,
8108
    { provide: PlatformRef, useExisting: PlatformRef_ },
8109
    { provide: Reflector, useFactory: _reflector, deps: [] },
8110
    TestabilityRegistry,
8111
    Console,
8112
];
8113
/**
8114
 * This platform has to be included in any other platform
8115
 *
8116
 * \@experimental
8117
 */
8118
var platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
8119
/**
8120
 * @license
8121
 * Copyright Google Inc. All Rights Reserved.
8122
 *
8123
 * Use of this source code is governed by an MIT-style license that can be
8124
 * found in the LICENSE file at https://angular.io/license
8125
 */
8126
/**
8127
 * \@experimental i18n support is experimental.
8128
 */
8129
var LOCALE_ID = new InjectionToken('LocaleId');
8130
/**
8131
 * \@experimental i18n support is experimental.
8132
 */
8133
var TRANSLATIONS = new InjectionToken('Translations');
8134
/**
8135
 * \@experimental i18n support is experimental.
8136
 */
8137
var TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
8138
var MissingTranslationStrategy = {};
8139
MissingTranslationStrategy.Error = 0;
8140
MissingTranslationStrategy.Warning = 1;
8141
MissingTranslationStrategy.Ignore = 2;
8142
MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
8143
MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
8144
MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
8145
/**
8146
 * @license
8147
 * Copyright Google Inc. All Rights Reserved.
8148
 *
8149
 * Use of this source code is governed by an MIT-style license that can be
8150
 * found in the LICENSE file at https://angular.io/license
8151
 */
8152
/**
8153
 * @return {?}
8154
 */
8155
function _iterableDiffersFactory() {
8156
    return defaultIterableDiffers;
8157
}
8158
/**
8159
 * @return {?}
8160
 */
8161
function _keyValueDiffersFactory() {
8162
    return defaultKeyValueDiffers;
8163
}
8164
/**
8165
 * @param {?=} locale
8166
 * @return {?}
8167
 */
8168
function _localeFactory(locale) {
8169
    return locale || 'en-US';
8170
}
8171
/**
8172
 * This module includes the providers of \@angular/core that are needed
8173
 * to bootstrap components via `ApplicationRef`.
8174
 *
8175
 * \@experimental
8176
 */
8177
var ApplicationModule = (function () {
8178
    /**
8179
     * @param {?} appRef
8180
     */
8181
    function ApplicationModule(appRef) {
8182
    }
8183
    return ApplicationModule;
8184
}());
8185
ApplicationModule.decorators = [
8186
    { type: NgModule, args: [{
8187
                providers: [
8188
                    ApplicationRef_,
8189
                    { provide: ApplicationRef, useExisting: ApplicationRef_ },
8190
                    ApplicationInitStatus,
8191
                    Compiler,
8192
                    APP_ID_RANDOM_PROVIDER,
8193
                    { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
8194
                    { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
8195
                    {
8196
                        provide: LOCALE_ID,
8197
                        useFactory: _localeFactory,
8198
                        deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
8199
                    },
8200
                ]
8201
            },] },
8202
];
8203
/**
8204
 * @nocollapse
8205
 */
8206
ApplicationModule.ctorParameters = function () { return [
8207
    { type: ApplicationRef, },
8208
]; };
8209
var SecurityContext = {};
8210
SecurityContext.NONE = 0;
8211
SecurityContext.HTML = 1;
8212
SecurityContext.STYLE = 2;
8213
SecurityContext.SCRIPT = 3;
8214
SecurityContext.URL = 4;
8215
SecurityContext.RESOURCE_URL = 5;
8216
SecurityContext[SecurityContext.NONE] = "NONE";
8217
SecurityContext[SecurityContext.HTML] = "HTML";
8218
SecurityContext[SecurityContext.STYLE] = "STYLE";
8219
SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
8220
SecurityContext[SecurityContext.URL] = "URL";
8221
SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
8222
/**
8223
 * Sanitizer is used by the views to sanitize potentially dangerous values.
8224
 *
8225
 * \@stable
8226
 * @abstract
8227
 */
8228
var Sanitizer = (function () {
8229
    function Sanitizer() {
8230
    }
8231
    /**
8232
     * @abstract
8233
     * @param {?} context
8234
     * @param {?} value
8235
     * @return {?}
8236
     */
8237
    Sanitizer.prototype.sanitize = function (context, value) { };
8238
    return Sanitizer;
8239
}());
8240
/**
8241
 * @license
8242
 * Copyright Google Inc. All Rights Reserved.
8243
 *
8244
 * Use of this source code is governed by an MIT-style license that can be
8245
 * found in the LICENSE file at https://angular.io/license
8246
 */
8247
/**
8248
 * Node instance data.
8249
 *
8250
 * We have a separate type per NodeType to save memory
8251
 * (TextData | ElementData | ProviderData | PureExpressionData | QueryList<any>)
8252
 *
8253
 * To keep our code monomorphic,
8254
 * we prohibit using `NodeData` directly but enforce the use of accessors (`asElementData`, ...).
8255
 * This way, no usage site can get a `NodeData` from view.nodes and then use it for different
8256
 * purposes.
8257
 */
8258
/**
8259
 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8260
 * @param {?} view
8261
 * @param {?} index
8262
 * @return {?}
8263
 */
8264
function asTextData(view, index) {
8265
    return (view.nodes[index]);
8266
}
8267
/**
8268
 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8269
 * @param {?} view
8270
 * @param {?} index
8271
 * @return {?}
8272
 */
8273
function asElementData(view, index) {
8274
    return (view.nodes[index]);
8275
}
8276
/**
8277
 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8278
 * @param {?} view
8279
 * @param {?} index
8280
 * @return {?}
8281
 */
8282
function asProviderData(view, index) {
8283
    return (view.nodes[index]);
8284
}
8285
/**
8286
 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8287
 * @param {?} view
8288
 * @param {?} index
8289
 * @return {?}
8290
 */
8291
function asPureExpressionData(view, index) {
8292
    return (view.nodes[index]);
8293
}
8294
/**
8295
 * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
8296
 * @param {?} view
8297
 * @param {?} index
8298
 * @return {?}
8299
 */
8300
function asQueryList(view, index) {
8301
    return (view.nodes[index]);
8302
}
8303
/**
8304
 * @abstract
8305
 */
8306
var DebugContext = (function () {
8307
    function DebugContext() {
8308
    }
8309
    /**
8310
     * @abstract
8311
     * @return {?}
8312
     */
8313
    DebugContext.prototype.view = function () { };
8314
    /**
8315
     * @abstract
8316
     * @return {?}
8317
     */
8318
    DebugContext.prototype.nodeIndex = function () { };
8319
    /**
8320
     * @abstract
8321
     * @return {?}
8322
     */
8323
    DebugContext.prototype.injector = function () { };
8324
    /**
8325
     * @abstract
8326
     * @return {?}
8327
     */
8328
    DebugContext.prototype.component = function () { };
8329
    /**
8330
     * @abstract
8331
     * @return {?}
8332
     */
8333
    DebugContext.prototype.providerTokens = function () { };
8334
    /**
8335
     * @abstract
8336
     * @return {?}
8337
     */
8338
    DebugContext.prototype.references = function () { };
8339
    /**
8340
     * @abstract
8341
     * @return {?}
8342
     */
8343
    DebugContext.prototype.context = function () { };
8344
    /**
8345
     * @abstract
8346
     * @return {?}
8347
     */
8348
    DebugContext.prototype.componentRenderElement = function () { };
8349
    /**
8350
     * @abstract
8351
     * @return {?}
8352
     */
8353
    DebugContext.prototype.renderNode = function () { };
8354
    /**
8355
     * @abstract
8356
     * @param {?} console
8357
     * @param {...?} values
8358
     * @return {?}
8359
     */
8360
    DebugContext.prototype.logError = function (console) {
8361
        var values = [];
8362
        for (var _i = 1; _i < arguments.length; _i++) {
8363
            values[_i - 1] = arguments[_i];
8364
        }
8365
    };
8366
    return DebugContext;
8367
}());
8368
/**
8369
 * This object is used to prevent cycles in the source files and to have a place where
8370
 * debug mode can hook it. It is lazily filled when `isDevMode` is known.
8371
 */
8372
var Services = {
8373
    setCurrentNode: undefined,
8374
    createRootView: undefined,
8375
    createEmbeddedView: undefined,
8376
    createComponentView: undefined,
8377
    createNgModuleRef: undefined,
8378
    overrideProvider: undefined,
8379
    clearProviderOverrides: undefined,
8380
    checkAndUpdateView: undefined,
8381
    checkNoChangesView: undefined,
8382
    destroyView: undefined,
8383
    resolveDep: undefined,
8384
    createDebugContext: undefined,
8385
    handleEvent: undefined,
8386
    updateDirectives: undefined,
8387
    updateRenderer: undefined,
8388
    dirtyParentQueries: undefined,
8389
};
8390
/**
8391
 * @license
8392
 * Copyright Google Inc. All Rights Reserved.
8393
 *
8394
 * Use of this source code is governed by an MIT-style license that can be
8395
 * found in the LICENSE file at https://angular.io/license
8396
 */
8397
/**
8398
 * @param {?} context
8399
 * @param {?} oldValue
8400
 * @param {?} currValue
8401
 * @param {?} isFirstCheck
8402
 * @return {?}
8403
 */
8404
function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
8405
    var /** @type {?} */ msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'.";
8406
    if (isFirstCheck) {
8407
        msg +=
8408
            " It seems like the view has been created after its parent and its children have been dirty checked." +
8409
                " Has it been created in a change detection hook ?";
8410
    }
8411
    return viewDebugError(msg, context);
8412
}
8413
/**
8414
 * @param {?} err
8415
 * @param {?} context
8416
 * @return {?}
8417
 */
8418
function viewWrappedDebugError(err, context) {
8419
    if (!(err instanceof Error)) {
8420
        // errors that are not Error instances don't have a stack,
8421
        // so it is ok to wrap them into a new Error object...
8422
        err = new Error(err.toString());
8423
    }
8424
    _addDebugContext(err, context);
8425
    return err;
8426
}
8427
/**
8428
 * @param {?} msg
8429
 * @param {?} context
8430
 * @return {?}
8431
 */
8432
function viewDebugError(msg, context) {
8433
    var /** @type {?} */ err = new Error(msg);
8434
    _addDebugContext(err, context);
8435
    return err;
8436
}
8437
/**
8438
 * @param {?} err
8439
 * @param {?} context
8440
 * @return {?}
8441
 */
8442
function _addDebugContext(err, context) {
8443
    ((err))[ERROR_DEBUG_CONTEXT] = context;
8444
    ((err))[ERROR_LOGGER] = context.logError.bind(context);
8445
}
8446
/**
8447
 * @param {?} err
8448
 * @return {?}
8449
 */
8450
function isViewDebugError(err) {
8451
    return !!getDebugContext(err);
8452
}
8453
/**
8454
 * @param {?} action
8455
 * @return {?}
8456
 */
8457
function viewDestroyedError(action) {
8458
    return new Error("ViewDestroyedError: Attempt to use a destroyed view: " + action);
8459
}
8460
/**
8461
 * @license
8462
 * Copyright Google Inc. All Rights Reserved.
8463
 *
8464
 * Use of this source code is governed by an MIT-style license that can be
8465
 * found in the LICENSE file at https://angular.io/license
8466
 */
8467
var NOOP = function () { };
8468
var _tokenKeyCache = new Map();
8469
/**
8470
 * @param {?} token
8471
 * @return {?}
8472
 */
8473
function tokenKey(token) {
8474
    var /** @type {?} */ key = _tokenKeyCache.get(token);
8475
    if (!key) {
8476
        key = stringify(token) + '_' + _tokenKeyCache.size;
8477
        _tokenKeyCache.set(token, key);
8478
    }
8479
    return key;
8480
}
8481
/**
8482
 * @param {?} view
8483
 * @param {?} nodeIdx
8484
 * @param {?} bindingIdx
8485
 * @param {?} value
8486
 * @return {?}
8487
 */
8488
function unwrapValue(view, nodeIdx, bindingIdx, value) {
8489
    if (value instanceof WrappedValue) {
8490
        value = value.wrapped;
8491
        var /** @type {?} */ globalBindingIdx = view.def.nodes[nodeIdx].bindingIndex + bindingIdx;
8492
        var /** @type {?} */ oldValue = view.oldValues[globalBindingIdx];
8493
        if (oldValue instanceof WrappedValue) {
8494
            oldValue = oldValue.wrapped;
8495
        }
8496
        view.oldValues[globalBindingIdx] = new WrappedValue(oldValue);
8497
    }
8498
    return value;
8499
}
8500
var UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
8501
var EMPTY_RENDERER_TYPE_ID = '$$empty';
8502
/**
8503
 * @param {?} values
8504
 * @return {?}
8505
 */
8506
function createRendererType2(values) {
8507
    return {
8508
        id: UNDEFINED_RENDERER_TYPE_ID,
8509
        styles: values.styles,
8510
        encapsulation: values.encapsulation,
8511
        data: values.data
8512
    };
8513
}
8514
var _renderCompCount = 0;
8515
/**
8516
 * @param {?=} type
8517
 * @return {?}
8518
 */
8519
function resolveRendererType2(type) {
8520
    if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
8521
        // first time we see this RendererType2. Initialize it...
8522
        var /** @type {?} */ isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
8523
            type.styles.length || Object.keys(type.data).length);
8524
        if (isFilled) {
8525
            type.id = "c" + _renderCompCount++;
8526
        }
8527
        else {
8528
            type.id = EMPTY_RENDERER_TYPE_ID;
8529
        }
8530
    }
8531
    if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
8532
        type = null;
8533
    }
8534
    return type || null;
8535
}
8536
/**
8537
 * @param {?} view
8538
 * @param {?} def
8539
 * @param {?} bindingIdx
8540
 * @param {?} value
8541
 * @return {?}
8542
 */
8543
function checkBinding(view, def, bindingIdx, value) {
8544
    var /** @type {?} */ oldValues = view.oldValues;
8545
    if ((view.state & 2 /* FirstCheck */) ||
8546
        !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
8547
        return true;
8548
    }
8549
    return false;
8550
}
8551
/**
8552
 * @param {?} view
8553
 * @param {?} def
8554
 * @param {?} bindingIdx
8555
 * @param {?} value
8556
 * @return {?}
8557
 */
8558
function checkAndUpdateBinding(view, def, bindingIdx, value) {
8559
    if (checkBinding(view, def, bindingIdx, value)) {
8560
        view.oldValues[def.bindingIndex + bindingIdx] = value;
8561
        return true;
8562
    }
8563
    return false;
8564
}
8565
/**
8566
 * @param {?} view
8567
 * @param {?} def
8568
 * @param {?} bindingIdx
8569
 * @param {?} value
8570
 * @return {?}
8571
 */
8572
function checkBindingNoChanges(view, def, bindingIdx, value) {
8573
    var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
8574
    if ((view.state & 1 /* BeforeFirstCheck */) || !devModeEqual(oldValue, value)) {
8575
        throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.nodeIndex), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
8576
    }
8577
}
8578
/**
8579
 * @param {?} view
8580
 * @return {?}
8581
 */
8582
function markParentViewsForCheck(view) {
8583
    var /** @type {?} */ currView = view;
8584
    while (currView) {
8585
        if (currView.def.flags & 2 /* OnPush */) {
8586
            currView.state |= 8 /* ChecksEnabled */;
8587
        }
8588
        currView = currView.viewContainerParent || currView.parent;
8589
    }
8590
}
8591
/**
8592
 * @param {?} view
8593
 * @param {?} endView
8594
 * @return {?}
8595
 */
8596
function markParentViewsForCheckProjectedViews(view, endView) {
8597
    var /** @type {?} */ currView = view;
8598
    while (currView && currView !== endView) {
8599
        currView.state |= 64 /* CheckProjectedViews */;
8600
        currView = currView.viewContainerParent || currView.parent;
8601
    }
8602
}
8603
/**
8604
 * @param {?} view
8605
 * @param {?} nodeIndex
8606
 * @param {?} eventName
8607
 * @param {?} event
8608
 * @return {?}
8609
 */
8610
function dispatchEvent(view, nodeIndex, eventName, event) {
8611
    var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
8612
    var /** @type {?} */ startView = nodeDef.flags & 33554432 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
8613
    markParentViewsForCheck(startView);
8614
    return Services.handleEvent(view, nodeIndex, eventName, event);
8615
}
8616
/**
8617
 * @param {?} view
8618
 * @return {?}
8619
 */
8620
function declaredViewContainer(view) {
8621
    if (view.parent) {
8622
        var /** @type {?} */ parentView = view.parent;
8623
        return asElementData(parentView, /** @type {?} */ ((view.parentNodeDef)).nodeIndex);
8624
    }
8625
    return null;
8626
}
8627
/**
8628
 * for component views, this is the host element.
8629
 * for embedded views, this is the index of the parent node
8630
 * that contains the view container.
8631
 * @param {?} view
8632
 * @return {?}
8633
 */
8634
function viewParentEl(view) {
8635
    var /** @type {?} */ parentView = view.parent;
8636
    if (parentView) {
8637
        return ((view.parentNodeDef)).parent;
8638
    }
8639
    else {
8640
        return null;
8641
    }
8642
}
8643
/**
8644
 * @param {?} view
8645
 * @param {?} def
8646
 * @return {?}
8647
 */
8648
function renderNode(view, def) {
8649
    switch (def.flags & 201347067 /* Types */) {
8650
        case 1 /* TypeElement */:
8651
            return asElementData(view, def.nodeIndex).renderElement;
8652
        case 2 /* TypeText */:
8653
            return asTextData(view, def.nodeIndex).renderText;
8654
    }
8655
}
8656
/**
8657
 * @param {?} target
8658
 * @param {?} name
8659
 * @return {?}
8660
 */
8661
function elementEventFullName(target, name) {
8662
    return target ? target + ":" + name : name;
8663
}
8664
/**
8665
 * @param {?} view
8666
 * @return {?}
8667
 */
8668
function isComponentView(view) {
8669
    return !!view.parent && !!(((view.parentNodeDef)).flags & 32768 /* Component */);
8670
}
8671
/**
8672
 * @param {?} view
8673
 * @return {?}
8674
 */
8675
function isEmbeddedView(view) {
8676
    return !!view.parent && !(((view.parentNodeDef)).flags & 32768 /* Component */);
8677
}
8678
/**
8679
 * @param {?} queryId
8680
 * @return {?}
8681
 */
8682
function filterQueryId(queryId) {
8683
    return 1 << (queryId % 32);
8684
}
8685
/**
8686
 * @param {?} matchedQueriesDsl
8687
 * @return {?}
8688
 */
8689
function splitMatchedQueriesDsl(matchedQueriesDsl) {
8690
    var /** @type {?} */ matchedQueries = {};
8691
    var /** @type {?} */ matchedQueryIds = 0;
8692
    var /** @type {?} */ references = {};
8693
    if (matchedQueriesDsl) {
8694
        matchedQueriesDsl.forEach(function (_a) {
8695
            var queryId = _a[0], valueType = _a[1];
8696
            if (typeof queryId === 'number') {
8697
                matchedQueries[queryId] = valueType;
8698
                matchedQueryIds |= filterQueryId(queryId);
8699
            }
8700
            else {
8701
                references[queryId] = valueType;
8702
            }
8703
        });
8704
    }
8705
    return { matchedQueries: matchedQueries, references: references, matchedQueryIds: matchedQueryIds };
8706
}
8707
/**
8708
 * @param {?} deps
8709
 * @return {?}
8710
 */
8711
function splitDepsDsl(deps) {
8712
    return deps.map(function (value) {
8713
        var /** @type {?} */ token;
8714
        var /** @type {?} */ flags;
8715
        if (Array.isArray(value)) {
8716
            flags = value[0], token = value[1];
8717
        }
8718
        else {
8719
            flags = 0 /* None */;
8720
            token = value;
8721
        }
8722
        return { flags: flags, token: token, tokenKey: tokenKey(token) };
8723
    });
8724
}
8725
/**
8726
 * @param {?} view
8727
 * @param {?} renderHost
8728
 * @param {?} def
8729
 * @return {?}
8730
 */
8731
function getParentRenderElement(view, renderHost, def) {
8732
    var /** @type {?} */ renderParent = def.renderParent;
8733
    if (renderParent) {
8734
        if ((renderParent.flags & 1 /* TypeElement */) === 0 ||
8735
            (renderParent.flags & 33554432 /* ComponentView */) === 0 ||
8736
            (((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
8737
                ViewEncapsulation.Native)) {
8738
            // only children of non components, or children of components with native encapsulation should
8739
            // be attached.
8740
            return asElementData(view, /** @type {?} */ ((def.renderParent)).nodeIndex).renderElement;
8741
        }
8742
    }
8743
    else {
8744
        return renderHost;
8745
    }
8746
}
8747
var DEFINITION_CACHE = new WeakMap();
8748
/**
8749
 * @template D
8750
 * @param {?} factory
8751
 * @return {?}
8752
 */
8753
function resolveDefinition(factory) {
8754
    var /** @type {?} */ value = (((DEFINITION_CACHE.get(factory))));
8755
    if (!value) {
8756
        value = factory(function () { return NOOP; });
8757
        value.factory = factory;
8758
        DEFINITION_CACHE.set(factory, value);
8759
    }
8760
    return value;
8761
}
8762
/**
8763
 * @param {?} view
8764
 * @return {?}
8765
 */
8766
function rootRenderNodes(view) {
8767
    var /** @type {?} */ renderNodes = [];
8768
    visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
8769
    return renderNodes;
8770
}
8771
/**
8772
 * @param {?} view
8773
 * @param {?} action
8774
 * @param {?} parentNode
8775
 * @param {?} nextSibling
8776
 * @param {?=} target
8777
 * @return {?}
8778
 */
8779
function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
8780
    // We need to re-compute the parent node in case the nodes have been moved around manually
8781
    if (action === 3 /* RemoveChild */) {
8782
        parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */ ((view.def.lastRenderRootNode))));
8783
    }
8784
    visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
8785
}
8786
/**
8787
 * @param {?} view
8788
 * @param {?} action
8789
 * @param {?} startIndex
8790
 * @param {?} endIndex
8791
 * @param {?} parentNode
8792
 * @param {?} nextSibling
8793
 * @param {?=} target
8794
 * @return {?}
8795
 */
8796
function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
8797
    for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8798
        var /** @type {?} */ nodeDef = view.def.nodes[i];
8799
        if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 8 /* TypeNgContent */)) {
8800
            visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
8801
        }
8802
        // jump to next sibling
8803
        i += nodeDef.childCount;
8804
    }
8805
}
8806
/**
8807
 * @param {?} view
8808
 * @param {?} ngContentIndex
8809
 * @param {?} action
8810
 * @param {?} parentNode
8811
 * @param {?} nextSibling
8812
 * @param {?=} target
8813
 * @return {?}
8814
 */
8815
function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
8816
    var /** @type {?} */ compView = view;
8817
    while (compView && !isComponentView(compView)) {
8818
        compView = compView.parent;
8819
    }
8820
    var /** @type {?} */ hostView = ((compView)).parent;
8821
    var /** @type {?} */ hostElDef = viewParentEl(/** @type {?} */ ((compView)));
8822
    var /** @type {?} */ startIndex = ((hostElDef)).nodeIndex + 1;
8823
    var /** @type {?} */ endIndex = ((hostElDef)).nodeIndex + ((hostElDef)).childCount;
8824
    for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
8825
        var /** @type {?} */ nodeDef = ((hostView)).def.nodes[i];
8826
        if (nodeDef.ngContentIndex === ngContentIndex) {
8827
            visitRenderNode(/** @type {?} */ ((hostView)), nodeDef, action, parentNode, nextSibling, target);
8828
        }
8829
        // jump to next sibling
8830
        i += nodeDef.childCount;
8831
    }
8832
    if (!((hostView)).parent) {
8833
        // a root view
8834
        var /** @type {?} */ projectedNodes = view.root.projectableNodes[ngContentIndex];
8835
        if (projectedNodes) {
8836
            for (var /** @type {?} */ i = 0; i < projectedNodes.length; i++) {
8837
                execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
8838
            }
8839
        }
8840
    }
8841
}
8842
/**
8843
 * @param {?} view
8844
 * @param {?} nodeDef
8845
 * @param {?} action
8846
 * @param {?} parentNode
8847
 * @param {?} nextSibling
8848
 * @param {?=} target
8849
 * @return {?}
8850
 */
8851
function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
8852
    if (nodeDef.flags & 8 /* TypeNgContent */) {
8853
        visitProjectedRenderNodes(view, /** @type {?} */ ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
8854
    }
8855
    else {
8856
        var /** @type {?} */ rn = renderNode(view, nodeDef);
8857
        if (action === 3 /* RemoveChild */ && (nodeDef.flags & 33554432 /* ComponentView */) &&
8858
            (nodeDef.bindingFlags & 48 /* CatSyntheticProperty */)) {
8859
            // Note: we might need to do both actions.
8860
            if (nodeDef.bindingFlags & (16 /* SyntheticProperty */)) {
8861
                execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
8862
            }
8863
            if (nodeDef.bindingFlags & (32 /* SyntheticHostProperty */)) {
8864
                var /** @type {?} */ compView = asElementData(view, nodeDef.nodeIndex).componentView;
8865
                execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
8866
            }
8867
        }
8868
        else {
8869
            execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
8870
        }
8871
        if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
8872
            var /** @type {?} */ embeddedViews = ((asElementData(view, nodeDef.nodeIndex).viewContainer))._embeddedViews;
8873
            for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
8874
                visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
8875
            }
8876
        }
8877
        if (nodeDef.flags & 1 /* TypeElement */ && !((nodeDef.element)).name) {
8878
            visitSiblingRenderNodes(view, action, nodeDef.nodeIndex + 1, nodeDef.nodeIndex + nodeDef.childCount, parentNode, nextSibling, target);
8879
        }
8880
    }
8881
}
8882
/**
8883
 * @param {?} view
8884
 * @param {?} renderNode
8885
 * @param {?} action
8886
 * @param {?} parentNode
8887
 * @param {?} nextSibling
8888
 * @param {?=} target
8889
 * @return {?}
8890
 */
8891
function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
8892
    var /** @type {?} */ renderer = view.renderer;
8893
    switch (action) {
8894
        case 1 /* AppendChild */:
8895
            renderer.appendChild(parentNode, renderNode);
8896
            break;
8897
        case 2 /* InsertBefore */:
8898
            renderer.insertBefore(parentNode, renderNode, nextSibling);
8899
            break;
8900
        case 3 /* RemoveChild */:
8901
            renderer.removeChild(parentNode, renderNode);
8902
            break;
8903
        case 0 /* Collect */:
8904
            ((target)).push(renderNode);
8905
            break;
8906
    }
8907
}
8908
var NS_PREFIX_RE = /^:([^:]+):(.+)$/;
8909
/**
8910
 * @param {?} name
8911
 * @return {?}
8912
 */
8913
function splitNamespace(name) {
8914
    if (name[0] === ':') {
8915
        var /** @type {?} */ match = ((name.match(NS_PREFIX_RE)));
8916
        return [match[1], match[2]];
8917
    }
8918
    return ['', name];
8919
}
8920
/**
8921
 * @param {?} bindings
8922
 * @return {?}
8923
 */
8924
function calcBindingFlags(bindings) {
8925
    var /** @type {?} */ flags = 0;
8926
    for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
8927
        flags |= bindings[i].flags;
8928
    }
8929
    return flags;
8930
}
8931
/**
8932
 * @param {?} valueCount
8933
 * @param {?} constAndInterp
8934
 * @return {?}
8935
 */
8936
function interpolate(valueCount, constAndInterp) {
8937
    var /** @type {?} */ result = '';
8938
    for (var /** @type {?} */ i = 0; i < valueCount * 2; i = i + 2) {
8939
        result = result + constAndInterp[i] + _toStringWithNull(constAndInterp[i + 1]);
8940
    }
8941
    return result + constAndInterp[valueCount * 2];
8942
}
8943
/**
8944
 * @param {?} valueCount
8945
 * @param {?} c0
8946
 * @param {?} a1
8947
 * @param {?} c1
8948
 * @param {?=} a2
8949
 * @param {?=} c2
8950
 * @param {?=} a3
8951
 * @param {?=} c3
8952
 * @param {?=} a4
8953
 * @param {?=} c4
8954
 * @param {?=} a5
8955
 * @param {?=} c5
8956
 * @param {?=} a6
8957
 * @param {?=} c6
8958
 * @param {?=} a7
8959
 * @param {?=} c7
8960
 * @param {?=} a8
8961
 * @param {?=} c8
8962
 * @param {?=} a9
8963
 * @param {?=} c9
8964
 * @return {?}
8965
 */
8966
function inlineInterpolate(valueCount, c0, a1, c1, a2, c2, a3, c3, a4, c4, a5, c5, a6, c6, a7, c7, a8, c8, a9, c9) {
8967
    switch (valueCount) {
8968
        case 1:
8969
            return c0 + _toStringWithNull(a1) + c1;
8970
        case 2:
8971
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2;
8972
        case 3:
8973
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8974
                c3;
8975
        case 4:
8976
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8977
                c3 + _toStringWithNull(a4) + c4;
8978
        case 5:
8979
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8980
                c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5;
8981
        case 6:
8982
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8983
                c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) + c6;
8984
        case 7:
8985
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8986
                c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8987
                c6 + _toStringWithNull(a7) + c7;
8988
        case 8:
8989
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8990
                c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8991
                c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8;
8992
        case 9:
8993
            return c0 + _toStringWithNull(a1) + c1 + _toStringWithNull(a2) + c2 + _toStringWithNull(a3) +
8994
                c3 + _toStringWithNull(a4) + c4 + _toStringWithNull(a5) + c5 + _toStringWithNull(a6) +
8995
                c6 + _toStringWithNull(a7) + c7 + _toStringWithNull(a8) + c8 + _toStringWithNull(a9) + c9;
8996
        default:
8997
            throw new Error("Does not support more than 9 expressions");
8998
    }
8999
}
9000
/**
9001
 * @param {?} v
9002
 * @return {?}
9003
 */
9004
function _toStringWithNull(v) {
9005
    return v != null ? v.toString() : '';
9006
}
9007
var EMPTY_ARRAY = [];
9008
var EMPTY_MAP = {};
9009
/**
9010
 * @license
9011
 * Copyright Google Inc. All Rights Reserved.
9012
 *
9013
 * Use of this source code is governed by an MIT-style license that can be
9014
 * found in the LICENSE file at https://angular.io/license
9015
 */
9016
/**
9017
 * @param {?} flags
9018
 * @param {?} matchedQueriesDsl
9019
 * @param {?} ngContentIndex
9020
 * @param {?} childCount
9021
 * @param {?=} handleEvent
9022
 * @param {?=} templateFactory
9023
 * @return {?}
9024
 */
9025
function anchorDef(flags, matchedQueriesDsl, ngContentIndex, childCount, handleEvent, templateFactory) {
9026
    flags |= 1 /* TypeElement */;
9027
    var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
9028
    var /** @type {?} */ template = templateFactory ? resolveDefinition(templateFactory) : null;
9029
    return {
9030
        // will bet set by the view definition
9031
        nodeIndex: -1,
9032
        parent: null,
9033
        renderParent: null,
9034
        bindingIndex: -1,
9035
        outputIndex: -1,
9036
        // regular values
9037
        flags: flags,
9038
        checkIndex: -1,
9039
        childFlags: 0,
9040
        directChildFlags: 0,
9041
        childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
9042
        bindings: [],
9043
        bindingFlags: 0,
9044
        outputs: [],
9045
        element: {
9046
            ns: null,
9047
            name: null,
9048
            attrs: null, template: template,
9049
            componentProvider: null,
9050
            componentView: null,
9051
            componentRendererType: null,
9052
            publicProviders: null,
9053
            allProviders: null,
9054
            handleEvent: handleEvent || NOOP
9055
        },
9056
        provider: null,
9057
        text: null,
9058
        query: null,
9059
        ngContent: null
9060
    };
9061
}
9062
/**
9063
 * @param {?} checkIndex
9064
 * @param {?} flags
9065
 * @param {?} matchedQueriesDsl
9066
 * @param {?} ngContentIndex
9067
 * @param {?} childCount
9068
 * @param {?} namespaceAndName
9069
 * @param {?=} fixedAttrs
9070
 * @param {?=} bindings
9071
 * @param {?=} outputs
9072
 * @param {?=} handleEvent
9073
 * @param {?=} componentView
9074
 * @param {?=} componentRendererType
9075
 * @return {?}
9076
 */
9077
function elementDef(checkIndex, flags, matchedQueriesDsl, ngContentIndex, childCount, namespaceAndName, fixedAttrs, bindings, outputs, handleEvent, componentView, componentRendererType) {
9078
    if (fixedAttrs === void 0) { fixedAttrs = []; }
9079
    if (!handleEvent) {
9080
        handleEvent = NOOP;
9081
    }
9082
    var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
9083
    var /** @type {?} */ ns = ((null));
9084
    var /** @type {?} */ name = ((null));
9085
    if (namespaceAndName) {
9086
        _b = splitNamespace(namespaceAndName), ns = _b[0], name = _b[1];
9087
    }
9088
    bindings = bindings || [];
9089
    var /** @type {?} */ bindingDefs = new Array(bindings.length);
9090
    for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
9091
        var _c = bindings[i], bindingFlags = _c[0], namespaceAndName_1 = _c[1], suffixOrSecurityContext = _c[2];
9092
        var _d = splitNamespace(namespaceAndName_1), ns_1 = _d[0], name_1 = _d[1];
9093
        var /** @type {?} */ securityContext = ((undefined));
9094
        var /** @type {?} */ suffix = ((undefined));
9095
        switch (bindingFlags & 15 /* Types */) {
9096
            case 4 /* TypeElementStyle */:
9097
                suffix = (suffixOrSecurityContext);
9098
                break;
9099
            case 1 /* TypeElementAttribute */:
9100
            case 8 /* TypeProperty */:
9101
                securityContext = (suffixOrSecurityContext);
9102
                break;
9103
        }
9104
        bindingDefs[i] =
9105
            { flags: bindingFlags, ns: ns_1, name: name_1, nonMinifiedName: name_1, securityContext: securityContext, suffix: suffix };
9106
    }
9107
    outputs = outputs || [];
9108
    var /** @type {?} */ outputDefs = new Array(outputs.length);
9109
    for (var /** @type {?} */ i = 0; i < outputs.length; i++) {
9110
        var _e = outputs[i], target = _e[0], eventName = _e[1];
9111
        outputDefs[i] = {
9112
            type: 0 /* ElementOutput */,
9113
            target: /** @type {?} */ (target), eventName: eventName,
9114
            propName: null
9115
        };
9116
    }
9117
    fixedAttrs = fixedAttrs || [];
9118
    var /** @type {?} */ attrs = (fixedAttrs.map(function (_a) {
9119
        var namespaceAndName = _a[0], value = _a[1];
9120
        var _b = splitNamespace(namespaceAndName), ns = _b[0], name = _b[1];
9121
        return [ns, name, value];
9122
    }));
9123
    componentRendererType = resolveRendererType2(componentRendererType);
9124
    if (componentView) {
9125
        flags |= 33554432 /* ComponentView */;
9126
    }
9127
    flags |= 1 /* TypeElement */;
9128
    return {
9129
        // will bet set by the view definition
9130
        nodeIndex: -1,
9131
        parent: null,
9132
        renderParent: null,
9133
        bindingIndex: -1,
9134
        outputIndex: -1,
9135
        // regular values
9136
        checkIndex: checkIndex,
9137
        flags: flags,
9138
        childFlags: 0,
9139
        directChildFlags: 0,
9140
        childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references, ngContentIndex: ngContentIndex, childCount: childCount,
9141
        bindings: bindingDefs,
9142
        bindingFlags: calcBindingFlags(bindingDefs),
9143
        outputs: outputDefs,
9144
        element: {
9145
            ns: ns,
9146
            name: name,
9147
            attrs: attrs,
9148
            template: null,
9149
            // will bet set by the view definition
9150
            componentProvider: null,
9151
            componentView: componentView || null,
9152
            componentRendererType: componentRendererType,
9153
            publicProviders: null,
9154
            allProviders: null,
9155
            handleEvent: handleEvent || NOOP,
9156
        },
9157
        provider: null,
9158
        text: null,
9159
        query: null,
9160
        ngContent: null
9161
    };
9162
    var _b;
9163
}
9164
/**
9165
 * @param {?} view
9166
 * @param {?} renderHost
9167
 * @param {?} def
9168
 * @return {?}
9169
 */
9170
function createElement(view, renderHost, def) {
9171
    var /** @type {?} */ elDef = ((def.element));
9172
    var /** @type {?} */ rootSelectorOrNode = view.root.selectorOrNode;
9173
    var /** @type {?} */ renderer = view.renderer;
9174
    var /** @type {?} */ el;
9175
    if (view.parent || !rootSelectorOrNode) {
9176
        if (elDef.name) {
9177
            el = renderer.createElement(elDef.name, elDef.ns);
9178
        }
9179
        else {
9180
            el = renderer.createComment('');
9181
        }
9182
        var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
9183
        if (parentEl) {
9184
            renderer.appendChild(parentEl, el);
9185
        }
9186
    }
9187
    else {
9188
        el = renderer.selectRootElement(rootSelectorOrNode);
9189
    }
9190
    if (elDef.attrs) {
9191
        for (var /** @type {?} */ i = 0; i < elDef.attrs.length; i++) {
9192
            var _a = elDef.attrs[i], ns = _a[0], name = _a[1], value = _a[2];
9193
            renderer.setAttribute(el, name, value, ns);
9194
        }
9195
    }
9196
    return el;
9197
}
9198
/**
9199
 * @param {?} view
9200
 * @param {?} compView
9201
 * @param {?} def
9202
 * @param {?} el
9203
 * @return {?}
9204
 */
9205
function listenToElementOutputs(view, compView, def, el) {
9206
    for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
9207
        var /** @type {?} */ output = def.outputs[i];
9208
        var /** @type {?} */ handleEventClosure = renderEventHandlerClosure(view, def.nodeIndex, elementEventFullName(output.target, output.eventName));
9209
        var /** @type {?} */ listenTarget = output.target;
9210
        var /** @type {?} */ listenerView = view;
9211
        if (output.target === 'component') {
9212
            listenTarget = null;
9213
            listenerView = compView;
9214
        }
9215
        var /** @type {?} */ disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure)); /** @type {?} */
9216
        ((view.disposables))[def.outputIndex + i] = disposable;
9217
    }
9218
}
9219
/**
9220
 * @param {?} view
9221
 * @param {?} index
9222
 * @param {?} eventName
9223
 * @return {?}
9224
 */
9225
function renderEventHandlerClosure(view, index, eventName) {
9226
    return function (event) {
9227
        try {
9228
            return dispatchEvent(view, index, eventName, event);
9229
        }
9230
        catch (e) {
9231
            // Attention: Don't rethrow, to keep in sync with directive events.
9232
            view.root.errorHandler.handleError(e);
9233
        }
9234
    };
9235
}
9236
/**
9237
 * @param {?} view
9238
 * @param {?} def
9239
 * @param {?} v0
9240
 * @param {?} v1
9241
 * @param {?} v2
9242
 * @param {?} v3
9243
 * @param {?} v4
9244
 * @param {?} v5
9245
 * @param {?} v6
9246
 * @param {?} v7
9247
 * @param {?} v8
9248
 * @param {?} v9
9249
 * @return {?}
9250
 */
9251
function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
9252
    var /** @type {?} */ bindLen = def.bindings.length;
9253
    var /** @type {?} */ changed = false;
9254
    if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
9255
        changed = true;
9256
    if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
9257
        changed = true;
9258
    if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
9259
        changed = true;
9260
    if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
9261
        changed = true;
9262
    if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
9263
        changed = true;
9264
    if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
9265
        changed = true;
9266
    if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
9267
        changed = true;
9268
    if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
9269
        changed = true;
9270
    if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
9271
        changed = true;
9272
    if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
9273
        changed = true;
9274
    return changed;
9275
}
9276
/**
9277
 * @param {?} view
9278
 * @param {?} def
9279
 * @param {?} values
9280
 * @return {?}
9281
 */
9282
function checkAndUpdateElementDynamic(view, def, values) {
9283
    var /** @type {?} */ changed = false;
9284
    for (var /** @type {?} */ i = 0; i < values.length; i++) {
9285
        if (checkAndUpdateElementValue(view, def, i, values[i]))
9286
            changed = true;
9287
    }
9288
    return changed;
9289
}
9290
/**
9291
 * @param {?} view
9292
 * @param {?} def
9293
 * @param {?} bindingIdx
9294
 * @param {?} value
9295
 * @return {?}
9296
 */
9297
function checkAndUpdateElementValue(view, def, bindingIdx, value) {
9298
    if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
9299
        return false;
9300
    }
9301
    var /** @type {?} */ binding = def.bindings[bindingIdx];
9302
    var /** @type {?} */ elData = asElementData(view, def.nodeIndex);
9303
    var /** @type {?} */ renderNode$$1 = elData.renderElement;
9304
    var /** @type {?} */ name = ((binding.name));
9305
    switch (binding.flags & 15 /* Types */) {
9306
        case 1 /* TypeElementAttribute */:
9307
            setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
9308
            break;
9309
        case 2 /* TypeElementClass */:
9310
            setElementClass(view, renderNode$$1, name, value);
9311
            break;
9312
        case 4 /* TypeElementStyle */:
9313
            setElementStyle(view, binding, renderNode$$1, name, value);
9314
            break;
9315
        case 8 /* TypeProperty */:
9316
            var /** @type {?} */ bindView = (def.flags & 33554432 /* ComponentView */ &&
9317
                binding.flags & 32 /* SyntheticHostProperty */) ?
9318
                elData.componentView :
9319
                view;
9320
            setElementProperty(bindView, binding, renderNode$$1, name, value);
9321
            break;
9322
    }
9323
    return true;
9324
}
9325
/**
9326
 * @param {?} view
9327
 * @param {?} binding
9328
 * @param {?} renderNode
9329
 * @param {?} ns
9330
 * @param {?} name
9331
 * @param {?} value
9332
 * @return {?}
9333
 */
9334
function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
9335
    var /** @type {?} */ securityContext = binding.securityContext;
9336
    var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9337
    renderValue = renderValue != null ? renderValue.toString() : null;
9338
    var /** @type {?} */ renderer = view.renderer;
9339
    if (value != null) {
9340
        renderer.setAttribute(renderNode$$1, name, renderValue, ns);
9341
    }
9342
    else {
9343
        renderer.removeAttribute(renderNode$$1, name, ns);
9344
    }
9345
}
9346
/**
9347
 * @param {?} view
9348
 * @param {?} renderNode
9349
 * @param {?} name
9350
 * @param {?} value
9351
 * @return {?}
9352
 */
9353
function setElementClass(view, renderNode$$1, name, value) {
9354
    var /** @type {?} */ renderer = view.renderer;
9355
    if (value) {
9356
        renderer.addClass(renderNode$$1, name);
9357
    }
9358
    else {
9359
        renderer.removeClass(renderNode$$1, name);
9360
    }
9361
}
9362
/**
9363
 * @param {?} view
9364
 * @param {?} binding
9365
 * @param {?} renderNode
9366
 * @param {?} name
9367
 * @param {?} value
9368
 * @return {?}
9369
 */
9370
function setElementStyle(view, binding, renderNode$$1, name, value) {
9371
    var /** @type {?} */ renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */ (value));
9372
    if (renderValue != null) {
9373
        renderValue = renderValue.toString();
9374
        var /** @type {?} */ unit = binding.suffix;
9375
        if (unit != null) {
9376
            renderValue = renderValue + unit;
9377
        }
9378
    }
9379
    else {
9380
        renderValue = null;
9381
    }
9382
    var /** @type {?} */ renderer = view.renderer;
9383
    if (renderValue != null) {
9384
        renderer.setStyle(renderNode$$1, name, renderValue);
9385
    }
9386
    else {
9387
        renderer.removeStyle(renderNode$$1, name);
9388
    }
9389
}
9390
/**
9391
 * @param {?} view
9392
 * @param {?} binding
9393
 * @param {?} renderNode
9394
 * @param {?} name
9395
 * @param {?} value
9396
 * @return {?}
9397
 */
9398
function setElementProperty(view, binding, renderNode$$1, name, value) {
9399
    var /** @type {?} */ securityContext = binding.securityContext;
9400
    var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
9401
    view.renderer.setProperty(renderNode$$1, name, renderValue);
9402
}
9403
/**
9404
 * @license
9405
 * Copyright Google Inc. All Rights Reserved.
9406
 *
9407
 * Use of this source code is governed by an MIT-style license that can be
9408
 * found in the LICENSE file at https://angular.io/license
9409
 */
9410
var UNDEFINED_VALUE = new Object();
9411
var InjectorRefTokenKey$1 = tokenKey(Injector);
9412
var NgModuleRefTokenKey = tokenKey(NgModuleRef);
9413
/**
9414
 * @param {?} flags
9415
 * @param {?} token
9416
 * @param {?} value
9417
 * @param {?} deps
9418
 * @return {?}
9419
 */
9420
function moduleProvideDef(flags, token, value, deps) {
9421
    var /** @type {?} */ depDefs = splitDepsDsl(deps);
9422
    return {
9423
        // will bet set by the module definition
9424
        index: -1,
9425
        deps: depDefs, flags: flags, token: token, value: value
9426
    };
9427
}
9428
/**
9429
 * @param {?} providers
9430
 * @return {?}
9431
 */
9432
function moduleDef(providers) {
9433
    var /** @type {?} */ providersByKey = {};
9434
    for (var /** @type {?} */ i = 0; i < providers.length; i++) {
9435
        var /** @type {?} */ provider = providers[i];
9436
        provider.index = i;
9437
        providersByKey[tokenKey(provider.token)] = provider;
9438
    }
9439
    return {
9440
        // Will be filled later...
9441
        factory: null,
9442
        providersByKey: providersByKey,
9443
        providers: providers
9444
    };
9445
}
9446
/**
9447
 * @param {?} data
9448
 * @return {?}
9449
 */
9450
function initNgModule(data) {
9451
    var /** @type {?} */ def = data._def;
9452
    var /** @type {?} */ providers = data._providers = new Array(def.providers.length);
9453
    for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
9454
        var /** @type {?} */ provDef = def.providers[i];
9455
        if (!(provDef.flags & 4096 /* LazyProvider */)) {
9456
            providers[i] = _createProviderInstance$1(data, provDef);
9457
        }
9458
    }
9459
}
9460
/**
9461
 * @param {?} data
9462
 * @param {?} depDef
9463
 * @param {?=} notFoundValue
9464
 * @return {?}
9465
 */
9466
function resolveNgModuleDep(data, depDef, notFoundValue) {
9467
    if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
9468
    if (depDef.flags & 8 /* Value */) {
9469
        return depDef.token;
9470
    }
9471
    if (depDef.flags & 2 /* Optional */) {
9472
        notFoundValue = null;
9473
    }
9474
    if (depDef.flags & 1 /* SkipSelf */) {
9475
        return data._parent.get(depDef.token, notFoundValue);
9476
    }
9477
    var /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
9478
    switch (tokenKey$$1) {
9479
        case InjectorRefTokenKey$1:
9480
        case NgModuleRefTokenKey:
9481
            return data;
9482
    }
9483
    var /** @type {?} */ providerDef = data._def.providersByKey[tokenKey$$1];
9484
    if (providerDef) {
9485
        var /** @type {?} */ providerInstance = data._providers[providerDef.index];
9486
        if (providerInstance === undefined) {
9487
            providerInstance = data._providers[providerDef.index] =
9488
                _createProviderInstance$1(data, providerDef);
9489
        }
9490
        return providerInstance === UNDEFINED_VALUE ? undefined : providerInstance;
9491
    }
9492
    return data._parent.get(depDef.token, notFoundValue);
9493
}
9494
/**
9495
 * @param {?} ngModule
9496
 * @param {?} providerDef
9497
 * @return {?}
9498
 */
9499
function _createProviderInstance$1(ngModule, providerDef) {
9500
    var /** @type {?} */ injectable;
9501
    switch (providerDef.flags & 201347067 /* Types */) {
9502
        case 512 /* TypeClassProvider */:
9503
            injectable = _createClass(ngModule, providerDef.value, providerDef.deps);
9504
            break;
9505
        case 1024 /* TypeFactoryProvider */:
9506
            injectable = _callFactory(ngModule, providerDef.value, providerDef.deps);
9507
            break;
9508
        case 2048 /* TypeUseExistingProvider */:
9509
            injectable = resolveNgModuleDep(ngModule, providerDef.deps[0]);
9510
            break;
9511
        case 256 /* TypeValueProvider */:
9512
            injectable = providerDef.value;
9513
            break;
9514
    }
9515
    return injectable === undefined ? UNDEFINED_VALUE : injectable;
9516
}
9517
/**
9518
 * @param {?} ngModule
9519
 * @param {?} ctor
9520
 * @param {?} deps
9521
 * @return {?}
9522
 */
9523
function _createClass(ngModule, ctor, deps) {
9524
    var /** @type {?} */ len = deps.length;
9525
    switch (len) {
9526
        case 0:
9527
            return new ctor();
9528
        case 1:
9529
            return new ctor(resolveNgModuleDep(ngModule, deps[0]));
9530
        case 2:
9531
            return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
9532
        case 3:
9533
            return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
9534
        default:
9535
            var /** @type {?} */ depValues = new Array(len);
9536
            for (var /** @type {?} */ i = 0; i < len; i++) {
9537
                depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
9538
            }
9539
            return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
9540
    }
9541
}
9542
/**
9543
 * @param {?} ngModule
9544
 * @param {?} factory
9545
 * @param {?} deps
9546
 * @return {?}
9547
 */
9548
function _callFactory(ngModule, factory, deps) {
9549
    var /** @type {?} */ len = deps.length;
9550
    switch (len) {
9551
        case 0:
9552
            return factory();
9553
        case 1:
9554
            return factory(resolveNgModuleDep(ngModule, deps[0]));
9555
        case 2:
9556
            return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
9557
        case 3:
9558
            return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
9559
        default:
9560
            var /** @type {?} */ depValues = Array(len);
9561
            for (var /** @type {?} */ i = 0; i < len; i++) {
9562
                depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
9563
            }
9564
            return factory.apply(void 0, depValues);
9565
    }
9566
}
9567
/**
9568
 * @param {?} ngModule
9569
 * @param {?} lifecycles
9570
 * @return {?}
9571
 */
9572
function callNgModuleLifecycle(ngModule, lifecycles) {
9573
    var /** @type {?} */ def = ngModule._def;
9574
    for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
9575
        var /** @type {?} */ provDef = def.providers[i];
9576
        if (provDef.flags & 131072 /* OnDestroy */) {
9577
            var /** @type {?} */ instance = ngModule._providers[i];
9578
            if (instance && instance !== UNDEFINED_VALUE) {
9579
                instance.ngOnDestroy();
9580
            }
9581
        }
9582
    }
9583
}
9584
/**
9585
 * @license
9586
 * Copyright Google Inc. All Rights Reserved.
9587
 *
9588
 * Use of this source code is governed by an MIT-style license that can be
9589
 * found in the LICENSE file at https://angular.io/license
9590
 */
9591
/**
9592
 * @param {?} parentView
9593
 * @param {?} elementData
9594
 * @param {?} viewIndex
9595
 * @param {?} view
9596
 * @return {?}
9597
 */
9598
function attachEmbeddedView(parentView, elementData, viewIndex, view) {
9599
    var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9600
    if (viewIndex === null || viewIndex === undefined) {
9601
        viewIndex = embeddedViews.length;
9602
    }
9603
    view.viewContainerParent = parentView;
9604
    addToArray(embeddedViews, /** @type {?} */ ((viewIndex)), view);
9605
    attachProjectedView(elementData, view);
9606
    Services.dirtyParentQueries(view);
9607
    var /** @type {?} */ prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
9608
    renderAttachEmbeddedView(elementData, prevView, view);
9609
}
9610
/**
9611
 * @param {?} vcElementData
9612
 * @param {?} view
9613
 * @return {?}
9614
 */
9615
function attachProjectedView(vcElementData, view) {
9616
    var /** @type {?} */ dvcElementData = declaredViewContainer(view);
9617
    if (!dvcElementData || dvcElementData === vcElementData ||
9618
        view.state & 16 /* IsProjectedView */) {
9619
        return;
9620
    }
9621
    // Note: For performance reasons, we
9622
    // - add a view to template._projectedViews only 1x throughout its lifetime,
9623
    //   and remove it not until the view is destroyed.
9624
    //   (hard, as when a parent view is attached/detached we would need to attach/detach all
9625
    //    nested projected views as well, even accross component boundaries).
9626
    // - don't track the insertion order of views in the projected views array
9627
    //   (hard, as when the views of the same template are inserted different view containers)
9628
    view.state |= 16 /* IsProjectedView */;
9629
    var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9630
    if (!projectedViews) {
9631
        projectedViews = dvcElementData.template._projectedViews = [];
9632
    }
9633
    projectedViews.push(view);
9634
    // Note: we are changing the NodeDef here as we cannot calculate
9635
    // the fact whether a template is used for projection during compilation.
9636
    markNodeAsProjectedTemplate(/** @type {?} */ ((view.parent)).def, /** @type {?} */ ((view.parentNodeDef)));
9637
}
9638
/**
9639
 * @param {?} viewDef
9640
 * @param {?} nodeDef
9641
 * @return {?}
9642
 */
9643
function markNodeAsProjectedTemplate(viewDef, nodeDef) {
9644
    if (nodeDef.flags & 4 /* ProjectedTemplate */) {
9645
        return;
9646
    }
9647
    viewDef.nodeFlags |= 4 /* ProjectedTemplate */;
9648
    nodeDef.flags |= 4 /* ProjectedTemplate */;
9649
    var /** @type {?} */ parentNodeDef = nodeDef.parent;
9650
    while (parentNodeDef) {
9651
        parentNodeDef.childFlags |= 4 /* ProjectedTemplate */;
9652
        parentNodeDef = parentNodeDef.parent;
9653
    }
9654
}
9655
/**
9656
 * @param {?} elementData
9657
 * @param {?=} viewIndex
9658
 * @return {?}
9659
 */
9660
function detachEmbeddedView(elementData, viewIndex) {
9661
    var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9662
    if (viewIndex == null || viewIndex >= embeddedViews.length) {
9663
        viewIndex = embeddedViews.length - 1;
9664
    }
9665
    if (viewIndex < 0) {
9666
        return null;
9667
    }
9668
    var /** @type {?} */ view = embeddedViews[viewIndex];
9669
    view.viewContainerParent = null;
9670
    removeFromArray(embeddedViews, viewIndex);
9671
    // See attachProjectedView for why we don't update projectedViews here.
9672
    Services.dirtyParentQueries(view);
9673
    renderDetachView(view);
9674
    return view;
9675
}
9676
/**
9677
 * @param {?} view
9678
 * @return {?}
9679
 */
9680
function detachProjectedView(view) {
9681
    if (!(view.state & 16 /* IsProjectedView */)) {
9682
        return;
9683
    }
9684
    var /** @type {?} */ dvcElementData = declaredViewContainer(view);
9685
    if (dvcElementData) {
9686
        var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
9687
        if (projectedViews) {
9688
            removeFromArray(projectedViews, projectedViews.indexOf(view));
9689
            Services.dirtyParentQueries(view);
9690
        }
9691
    }
9692
}
9693
/**
9694
 * @param {?} elementData
9695
 * @param {?} oldViewIndex
9696
 * @param {?} newViewIndex
9697
 * @return {?}
9698
 */
9699
function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
9700
    var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
9701
    var /** @type {?} */ view = embeddedViews[oldViewIndex];
9702
    removeFromArray(embeddedViews, oldViewIndex);
9703
    if (newViewIndex == null) {
9704
        newViewIndex = embeddedViews.length;
9705
    }
9706
    addToArray(embeddedViews, newViewIndex, view);
9707
    // Note: Don't need to change projectedViews as the order in there
9708
    // as always invalid...
9709
    Services.dirtyParentQueries(view);
9710
    renderDetachView(view);
9711
    var /** @type {?} */ prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
9712
    renderAttachEmbeddedView(elementData, prevView, view);
9713
    return view;
9714
}
9715
/**
9716
 * @param {?} elementData
9717
 * @param {?} prevView
9718
 * @param {?} view
9719
 * @return {?}
9720
 */
9721
function renderAttachEmbeddedView(elementData, prevView, view) {
9722
    var /** @type {?} */ prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */ ((prevView.def.lastRenderRootNode))) :
9723
        elementData.renderElement;
9724
    var /** @type {?} */ parentNode = view.renderer.parentNode(prevRenderNode);
9725
    var /** @type {?} */ nextSibling = view.renderer.nextSibling(prevRenderNode);
9726
    // Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
9727
    // However, browsers automatically do `appendChild` when there is no `nextSibling`.
9728
    visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
9729
}
9730
/**
9731
 * @param {?} view
9732
 * @return {?}
9733
 */
9734
function renderDetachView(view) {
9735
    visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
9736
}
9737
/**
9738
 * @param {?} arr
9739
 * @param {?} index
9740
 * @param {?} value
9741
 * @return {?}
9742
 */
9743
function addToArray(arr, index, value) {
9744
    // perf: array.push is faster than array.splice!
9745
    if (index >= arr.length) {
9746
        arr.push(value);
9747
    }
9748
    else {
9749
        arr.splice(index, 0, value);
9750
    }
9751
}
9752
/**
9753
 * @param {?} arr
9754
 * @param {?} index
9755
 * @return {?}
9756
 */
9757
function removeFromArray(arr, index) {
9758
    // perf: array.pop is faster than array.splice!
9759
    if (index >= arr.length - 1) {
9760
        arr.pop();
9761
    }
9762
    else {
9763
        arr.splice(index, 1);
9764
    }
9765
}
9766
/**
9767
 * @license
9768
 * Copyright Google Inc. All Rights Reserved.
9769
 *
9770
 * Use of this source code is governed by an MIT-style license that can be
9771
 * found in the LICENSE file at https://angular.io/license
9772
 */
9773
var EMPTY_CONTEXT = new Object();
9774
/**
9775
 * @param {?} selector
9776
 * @param {?} componentType
9777
 * @param {?} viewDefFactory
9778
 * @param {?} inputs
9779
 * @param {?} outputs
9780
 * @param {?} ngContentSelectors
9781
 * @return {?}
9782
 */
9783
function createComponentFactory(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors) {
9784
    return new ComponentFactory_(selector, componentType, viewDefFactory, inputs, outputs, ngContentSelectors);
9785
}
9786
/**
9787
 * @param {?} componentFactory
9788
 * @return {?}
9789
 */
9790
function getComponentViewDefinitionFactory(componentFactory) {
9791
    return ((componentFactory)).viewDefFactory;
9792
}
9793
var ComponentFactory_ = (function (_super) {
9794
    tslib_1.__extends(ComponentFactory_, _super);
9795
    /**
9796
     * @param {?} selector
9797
     * @param {?} componentType
9798
     * @param {?} viewDefFactory
9799
     * @param {?} _inputs
9800
     * @param {?} _outputs
9801
     * @param {?} ngContentSelectors
9802
     */
9803
    function ComponentFactory_(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
9804
        var _this =
9805
        // Attention: this ctor is called as top level function.
9806
        // Putting any logic in here will destroy closure tree shaking!
9807
        _super.call(this) || this;
9808
        _this.selector = selector;
9809
        _this.componentType = componentType;
9810
        _this._inputs = _inputs;
9811
        _this._outputs = _outputs;
9812
        _this.ngContentSelectors = ngContentSelectors;
9813
        _this.viewDefFactory = viewDefFactory;
9814
        return _this;
9815
    }
9816
    Object.defineProperty(ComponentFactory_.prototype, "inputs", {
9817
        /**
9818
         * @return {?}
9819
         */
9820
        get: function () {
9821
            var /** @type {?} */ inputsArr = [];
9822
            var /** @type {?} */ inputs = ((this._inputs));
9823
            for (var /** @type {?} */ propName in inputs) {
9824
                var /** @type {?} */ templateName = inputs[propName];
9825
                inputsArr.push({ propName: propName, templateName: templateName });
9826
            }
9827
            return inputsArr;
9828
        },
9829
        enumerable: true,
9830
        configurable: true
9831
    });
9832
    Object.defineProperty(ComponentFactory_.prototype, "outputs", {
9833
        /**
9834
         * @return {?}
9835
         */
9836
        get: function () {
9837
            var /** @type {?} */ outputsArr = [];
9838
            for (var /** @type {?} */ propName in this._outputs) {
9839
                var /** @type {?} */ templateName = this._outputs[propName];
9840
                outputsArr.push({ propName: propName, templateName: templateName });
9841
            }
9842
            return outputsArr;
9843
        },
9844
        enumerable: true,
9845
        configurable: true
9846
    });
9847
    /**
9848
     * Creates a new component.
9849
     * @param {?} injector
9850
     * @param {?=} projectableNodes
9851
     * @param {?=} rootSelectorOrNode
9852
     * @param {?=} ngModule
9853
     * @return {?}
9854
     */
9855
    ComponentFactory_.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
9856
        if (!ngModule) {
9857
            throw new Error('ngModule should be provided');
9858
        }
9859
        var /** @type {?} */ viewDef = resolveDefinition(this.viewDefFactory);
9860
        var /** @type {?} */ componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).nodeIndex;
9861
        var /** @type {?} */ view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
9862
        var /** @type {?} */ component = asProviderData(view, componentNodeIndex).instance;
9863
        if (rootSelectorOrNode) {
9864
            view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
9865
        }
9866
        return new ComponentRef_(view, new ViewRef_(view), component);
9867
    };
9868
    return ComponentFactory_;
9869
}(ComponentFactory));
9870
var ComponentRef_ = (function (_super) {
9871
    tslib_1.__extends(ComponentRef_, _super);
9872
    /**
9873
     * @param {?} _view
9874
     * @param {?} _viewRef
9875
     * @param {?} _component
9876
     */
9877
    function ComponentRef_(_view, _viewRef, _component) {
9878
        var _this = _super.call(this) || this;
9879
        _this._view = _view;
9880
        _this._viewRef = _viewRef;
9881
        _this._component = _component;
9882
        _this._elDef = _this._view.def.nodes[0];
9883
        return _this;
9884
    }
9885
    Object.defineProperty(ComponentRef_.prototype, "location", {
9886
        /**
9887
         * @return {?}
9888
         */
9889
        get: function () {
9890
            return new ElementRef(asElementData(this._view, this._elDef.nodeIndex).renderElement);
9891
        },
9892
        enumerable: true,
9893
        configurable: true
9894
    });
9895
    Object.defineProperty(ComponentRef_.prototype, "injector", {
9896
        /**
9897
         * @return {?}
9898
         */
9899
        get: function () { return new Injector_(this._view, this._elDef); },
9900
        enumerable: true,
9901
        configurable: true
9902
    });
9903
    Object.defineProperty(ComponentRef_.prototype, "instance", {
9904
        /**
9905
         * @return {?}
9906
         */
9907
        get: function () { return this._component; },
9908
        enumerable: true,
9909
        configurable: true
9910
    });
9911
    Object.defineProperty(ComponentRef_.prototype, "hostView", {
9912
        /**
9913
         * @return {?}
9914
         */
9915
        get: function () { return this._viewRef; },
9916
        enumerable: true,
9917
        configurable: true
9918
    });
9919
    Object.defineProperty(ComponentRef_.prototype, "changeDetectorRef", {
9920
        /**
9921
         * @return {?}
9922
         */
9923
        get: function () { return this._viewRef; },
9924
        enumerable: true,
9925
        configurable: true
9926
    });
9927
    Object.defineProperty(ComponentRef_.prototype, "componentType", {
9928
        /**
9929
         * @return {?}
9930
         */
9931
        get: function () { return (this._component.constructor); },
9932
        enumerable: true,
9933
        configurable: true
9934
    });
9935
    /**
9936
     * @return {?}
9937
     */
9938
    ComponentRef_.prototype.destroy = function () { this._viewRef.destroy(); };
9939
    /**
9940
     * @param {?} callback
9941
     * @return {?}
9942
     */
9943
    ComponentRef_.prototype.onDestroy = function (callback) { this._viewRef.onDestroy(callback); };
9944
    return ComponentRef_;
9945
}(ComponentRef));
9946
/**
9947
 * @param {?} view
9948
 * @param {?} elDef
9949
 * @param {?} elData
9950
 * @return {?}
9951
 */
9952
function createViewContainerData(view, elDef, elData) {
9953
    return new ViewContainerRef_(view, elDef, elData);
9954
}
9955
var ViewContainerRef_ = (function () {
9956
    /**
9957
     * @param {?} _view
9958
     * @param {?} _elDef
9959
     * @param {?} _data
9960
     */
9961
    function ViewContainerRef_(_view, _elDef, _data) {
9962
        this._view = _view;
9963
        this._elDef = _elDef;
9964
        this._data = _data;
9965
        /**
9966
         * \@internal
9967
         */
9968
        this._embeddedViews = [];
9969
    }
9970
    Object.defineProperty(ViewContainerRef_.prototype, "element", {
9971
        /**
9972
         * @return {?}
9973
         */
9974
        get: function () { return new ElementRef(this._data.renderElement); },
9975
        enumerable: true,
9976
        configurable: true
9977
    });
9978
    Object.defineProperty(ViewContainerRef_.prototype, "injector", {
9979
        /**
9980
         * @return {?}
9981
         */
9982
        get: function () { return new Injector_(this._view, this._elDef); },
9983
        enumerable: true,
9984
        configurable: true
9985
    });
9986
    Object.defineProperty(ViewContainerRef_.prototype, "parentInjector", {
9987
        /**
9988
         * @return {?}
9989
         */
9990
        get: function () {
9991
            var /** @type {?} */ view = this._view;
9992
            var /** @type {?} */ elDef = this._elDef.parent;
9993
            while (!elDef && view) {
9994
                elDef = viewParentEl(view);
9995
                view = ((view.parent));
9996
            }
9997
            return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
9998
        },
9999
        enumerable: true,
10000
        configurable: true
10001
    });
10002
    /**
10003
     * @return {?}
10004
     */
10005
    ViewContainerRef_.prototype.clear = function () {
10006
        var /** @type {?} */ len = this._embeddedViews.length;
10007
        for (var /** @type {?} */ i = len - 1; i >= 0; i--) {
10008
            var /** @type {?} */ view = ((detachEmbeddedView(this._data, i)));
10009
            Services.destroyView(view);
10010
        }
10011
    };
10012
    /**
10013
     * @param {?} index
10014
     * @return {?}
10015
     */
10016
    ViewContainerRef_.prototype.get = function (index) {
10017
        var /** @type {?} */ view = this._embeddedViews[index];
10018
        if (view) {
10019
            var /** @type {?} */ ref = new ViewRef_(view);
10020
            ref.attachToViewContainerRef(this);
10021
            return ref;
10022
        }
10023
        return null;
10024
    };
10025
    Object.defineProperty(ViewContainerRef_.prototype, "length", {
10026
        /**
10027
         * @return {?}
10028
         */
10029
        get: function () { return this._embeddedViews.length; },
10030
        enumerable: true,
10031
        configurable: true
10032
    });
10033
    /**
10034
     * @template C
10035
     * @param {?} templateRef
10036
     * @param {?=} context
10037
     * @param {?=} index
10038
     * @return {?}
10039
     */
10040
    ViewContainerRef_.prototype.createEmbeddedView = function (templateRef, context, index) {
10041
        var /** @type {?} */ viewRef = templateRef.createEmbeddedView(context || ({}));
10042
        this.insert(viewRef, index);
10043
        return viewRef;
10044
    };
10045
    /**
10046
     * @template C
10047
     * @param {?} componentFactory
10048
     * @param {?=} index
10049
     * @param {?=} injector
10050
     * @param {?=} projectableNodes
10051
     * @param {?=} ngModuleRef
10052
     * @return {?}
10053
     */
10054
    ViewContainerRef_.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModuleRef) {
10055
        var /** @type {?} */ contextInjector = injector || this.parentInjector;
10056
        if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
10057
            ngModuleRef = contextInjector.get(NgModuleRef);
10058
        }
10059
        var /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
10060
        this.insert(componentRef.hostView, index);
10061
        return componentRef;
10062
    };
10063
    /**
10064
     * @param {?} viewRef
10065
     * @param {?=} index
10066
     * @return {?}
10067
     */
10068
    ViewContainerRef_.prototype.insert = function (viewRef, index) {
10069
        if (viewRef.destroyed) {
10070
            throw new Error('Cannot insert a destroyed View in a ViewContainer!');
10071
        }
10072
        var /** @type {?} */ viewRef_ = (viewRef);
10073
        var /** @type {?} */ viewData = viewRef_._view;
10074
        attachEmbeddedView(this._view, this._data, index, viewData);
10075
        viewRef_.attachToViewContainerRef(this);
10076
        return viewRef;
10077
    };
10078
    /**
10079
     * @param {?} viewRef
10080
     * @param {?} currentIndex
10081
     * @return {?}
10082
     */
10083
    ViewContainerRef_.prototype.move = function (viewRef, currentIndex) {
10084
        if (viewRef.destroyed) {
10085
            throw new Error('Cannot move a destroyed View in a ViewContainer!');
10086
        }
10087
        var /** @type {?} */ previousIndex = this._embeddedViews.indexOf(viewRef._view);
10088
        moveEmbeddedView(this._data, previousIndex, currentIndex);
10089
        return viewRef;
10090
    };
10091
    /**
10092
     * @param {?} viewRef
10093
     * @return {?}
10094
     */
10095
    ViewContainerRef_.prototype.indexOf = function (viewRef) {
10096
        return this._embeddedViews.indexOf(((viewRef))._view);
10097
    };
10098
    /**
10099
     * @param {?=} index
10100
     * @return {?}
10101
     */
10102
    ViewContainerRef_.prototype.remove = function (index) {
10103
        var /** @type {?} */ viewData = detachEmbeddedView(this._data, index);
10104
        if (viewData) {
10105
            Services.destroyView(viewData);
10106
        }
10107
    };
10108
    /**
10109
     * @param {?=} index
10110
     * @return {?}
10111
     */
10112
    ViewContainerRef_.prototype.detach = function (index) {
10113
        var /** @type {?} */ view = detachEmbeddedView(this._data, index);
10114
        return view ? new ViewRef_(view) : null;
10115
    };
10116
    return ViewContainerRef_;
10117
}());
10118
/**
10119
 * @param {?} view
10120
 * @return {?}
10121
 */
10122
function createChangeDetectorRef(view) {
10123
    return new ViewRef_(view);
10124
}
10125
var ViewRef_ = (function () {
10126
    /**
10127
     * @param {?} _view
10128
     */
10129
    function ViewRef_(_view) {
10130
        this._view = _view;
10131
        this._viewContainerRef = null;
10132
        this._appRef = null;
10133
    }
10134
    Object.defineProperty(ViewRef_.prototype, "rootNodes", {
10135
        /**
10136
         * @return {?}
10137
         */
10138
        get: function () { return rootRenderNodes(this._view); },
10139
        enumerable: true,
10140
        configurable: true
10141
    });
10142
    Object.defineProperty(ViewRef_.prototype, "context", {
10143
        /**
10144
         * @return {?}
10145
         */
10146
        get: function () { return this._view.context; },
10147
        enumerable: true,
10148
        configurable: true
10149
    });
10150
    Object.defineProperty(ViewRef_.prototype, "destroyed", {
10151
        /**
10152
         * @return {?}
10153
         */
10154
        get: function () { return (this._view.state & 128 /* Destroyed */) !== 0; },
10155
        enumerable: true,
10156
        configurable: true
10157
    });
10158
    /**
10159
     * @return {?}
10160
     */
10161
    ViewRef_.prototype.markForCheck = function () { markParentViewsForCheck(this._view); };
10162
    /**
10163
     * @return {?}
10164
     */
10165
    ViewRef_.prototype.detach = function () { this._view.state &= ~4 /* Attached */; };
10166
    /**
10167
     * @return {?}
10168
     */
10169
    ViewRef_.prototype.detectChanges = function () {
10170
        var /** @type {?} */ fs = this._view.root.rendererFactory;
10171
        if (fs.begin) {
10172
            fs.begin();
10173
        }
10174
        Services.checkAndUpdateView(this._view);
10175
        if (fs.end) {
10176
            fs.end();
10177
        }
10178
    };
10179
    /**
10180
     * @return {?}
10181
     */
10182
    ViewRef_.prototype.checkNoChanges = function () { Services.checkNoChangesView(this._view); };
10183
    /**
10184
     * @return {?}
10185
     */
10186
    ViewRef_.prototype.reattach = function () { this._view.state |= 4 /* Attached */; };
10187
    /**
10188
     * @param {?} callback
10189
     * @return {?}
10190
     */
10191
    ViewRef_.prototype.onDestroy = function (callback) {
10192
        if (!this._view.disposables) {
10193
            this._view.disposables = [];
10194
        }
10195
        this._view.disposables.push(/** @type {?} */ (callback));
10196
    };
10197
    /**
10198
     * @return {?}
10199
     */
10200
    ViewRef_.prototype.destroy = function () {
10201
        if (this._appRef) {
10202
            this._appRef.detachView(this);
10203
        }
10204
        else if (this._viewContainerRef) {
10205
            this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
10206
        }
10207
        Services.destroyView(this._view);
10208
    };
10209
    /**
10210
     * @return {?}
10211
     */
10212
    ViewRef_.prototype.detachFromAppRef = function () {
10213
        this._appRef = null;
10214
        renderDetachView(this._view);
10215
        Services.dirtyParentQueries(this._view);
10216
    };
10217
    /**
10218
     * @param {?} appRef
10219
     * @return {?}
10220
     */
10221
    ViewRef_.prototype.attachToAppRef = function (appRef) {
10222
        if (this._viewContainerRef) {
10223
            throw new Error('This view is already attached to a ViewContainer!');
10224
        }
10225
        this._appRef = appRef;
10226
    };
10227
    /**
10228
     * @param {?} vcRef
10229
     * @return {?}
10230
     */
10231
    ViewRef_.prototype.attachToViewContainerRef = function (vcRef) {
10232
        if (this._appRef) {
10233
            throw new Error('This view is already attached directly to the ApplicationRef!');
10234
        }
10235
        this._viewContainerRef = vcRef;
10236
    };
10237
    return ViewRef_;
10238
}());
10239
/**
10240
 * @param {?} view
10241
 * @param {?} def
10242
 * @return {?}
10243
 */
10244
function createTemplateData(view, def) {
10245
    return new TemplateRef_(view, def);
10246
}
10247
var TemplateRef_ = (function (_super) {
10248
    tslib_1.__extends(TemplateRef_, _super);
10249
    /**
10250
     * @param {?} _parentView
10251
     * @param {?} _def
10252
     */
10253
    function TemplateRef_(_parentView, _def) {
10254
        var _this = _super.call(this) || this;
10255
        _this._parentView = _parentView;
10256
        _this._def = _def;
10257
        return _this;
10258
    }
10259
    /**
10260
     * @param {?} context
10261
     * @return {?}
10262
     */
10263
    TemplateRef_.prototype.createEmbeddedView = function (context) {
10264
        return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, /** @type {?} */ ((((this._def.element)).template)), context));
10265
    };
10266
    Object.defineProperty(TemplateRef_.prototype, "elementRef", {
10267
        /**
10268
         * @return {?}
10269
         */
10270
        get: function () {
10271
            return new ElementRef(asElementData(this._parentView, this._def.nodeIndex).renderElement);
10272
        },
10273
        enumerable: true,
10274
        configurable: true
10275
    });
10276
    return TemplateRef_;
10277
}(TemplateRef));
10278
/**
10279
 * @param {?} view
10280
 * @param {?} elDef
10281
 * @return {?}
10282
 */
10283
function createInjector(view, elDef) {
10284
    return new Injector_(view, elDef);
10285
}
10286
var Injector_ = (function () {
10287
    /**
10288
     * @param {?} view
10289
     * @param {?} elDef
10290
     */
10291
    function Injector_(view, elDef) {
10292
        this.view = view;
10293
        this.elDef = elDef;
10294
    }
10295
    /**
10296
     * @param {?} token
10297
     * @param {?=} notFoundValue
10298
     * @return {?}
10299
     */
10300
    Injector_.prototype.get = function (token, notFoundValue) {
10301
        if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
10302
        var /** @type {?} */ allowPrivateServices = this.elDef ? (this.elDef.flags & 33554432 /* ComponentView */) !== 0 : false;
10303
        return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token: token, tokenKey: tokenKey(token) }, notFoundValue);
10304
    };
10305
    return Injector_;
10306
}());
10307
/**
10308
 * @param {?} view
10309
 * @param {?} index
10310
 * @return {?}
10311
 */
10312
function nodeValue(view, index) {
10313
    var /** @type {?} */ def = view.def.nodes[index];
10314
    if (def.flags & 1 /* TypeElement */) {
10315
        var /** @type {?} */ elData = asElementData(view, def.nodeIndex);
10316
        return ((def.element)).template ? elData.template : elData.renderElement;
10317
    }
10318
    else if (def.flags & 2 /* TypeText */) {
10319
        return asTextData(view, def.nodeIndex).renderText;
10320
    }
10321
    else if (def.flags & (20224 /* CatProvider */ | 16 /* TypePipe */)) {
10322
        return asProviderData(view, def.nodeIndex).instance;
10323
    }
10324
    throw new Error("Illegal state: read nodeValue for node index " + index);
10325
}
10326
/**
10327
 * @param {?} view
10328
 * @return {?}
10329
 */
10330
function createRendererV1(view) {
10331
    return new RendererAdapter(view.renderer);
10332
}
10333
var RendererAdapter = (function () {
10334
    /**
10335
     * @param {?} delegate
10336
     */
10337
    function RendererAdapter(delegate) {
10338
        this.delegate = delegate;
10339
    }
10340
    /**
10341
     * @param {?} selectorOrNode
10342
     * @return {?}
10343
     */
10344
    RendererAdapter.prototype.selectRootElement = function (selectorOrNode) {
10345
        return this.delegate.selectRootElement(selectorOrNode);
10346
    };
10347
    /**
10348
     * @param {?} parent
10349
     * @param {?} namespaceAndName
10350
     * @return {?}
10351
     */
10352
    RendererAdapter.prototype.createElement = function (parent, namespaceAndName) {
10353
        var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
10354
        var /** @type {?} */ el = this.delegate.createElement(name, ns);
10355
        if (parent) {
10356
            this.delegate.appendChild(parent, el);
10357
        }
10358
        return el;
10359
    };
10360
    /**
10361
     * @param {?} hostElement
10362
     * @return {?}
10363
     */
10364
    RendererAdapter.prototype.createViewRoot = function (hostElement) { return hostElement; };
10365
    /**
10366
     * @param {?} parentElement
10367
     * @return {?}
10368
     */
10369
    RendererAdapter.prototype.createTemplateAnchor = function (parentElement) {
10370
        var /** @type {?} */ comment = this.delegate.createComment('');
10371
        if (parentElement) {
10372
            this.delegate.appendChild(parentElement, comment);
10373
        }
10374
        return comment;
10375
    };
10376
    /**
10377
     * @param {?} parentElement
10378
     * @param {?} value
10379
     * @return {?}
10380
     */
10381
    RendererAdapter.prototype.createText = function (parentElement, value) {
10382
        var /** @type {?} */ node = this.delegate.createText(value);
10383
        if (parentElement) {
10384
            this.delegate.appendChild(parentElement, node);
10385
        }
10386
        return node;
10387
    };
10388
    /**
10389
     * @param {?} parentElement
10390
     * @param {?} nodes
10391
     * @return {?}
10392
     */
10393
    RendererAdapter.prototype.projectNodes = function (parentElement, nodes) {
10394
        for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
10395
            this.delegate.appendChild(parentElement, nodes[i]);
10396
        }
10397
    };
10398
    /**
10399
     * @param {?} node
10400
     * @param {?} viewRootNodes
10401
     * @return {?}
10402
     */
10403
    RendererAdapter.prototype.attachViewAfter = function (node, viewRootNodes) {
10404
        var /** @type {?} */ parentElement = this.delegate.parentNode(node);
10405
        var /** @type {?} */ nextSibling = this.delegate.nextSibling(node);
10406
        for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
10407
            this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
10408
        }
10409
    };
10410
    /**
10411
     * @param {?} viewRootNodes
10412
     * @return {?}
10413
     */
10414
    RendererAdapter.prototype.detachView = function (viewRootNodes) {
10415
        for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
10416
            var /** @type {?} */ node = viewRootNodes[i];
10417
            var /** @type {?} */ parentElement = this.delegate.parentNode(node);
10418
            this.delegate.removeChild(parentElement, node);
10419
        }
10420
    };
10421
    /**
10422
     * @param {?} hostElement
10423
     * @param {?} viewAllNodes
10424
     * @return {?}
10425
     */
10426
    RendererAdapter.prototype.destroyView = function (hostElement, viewAllNodes) {
10427
        for (var /** @type {?} */ i = 0; i < viewAllNodes.length; i++) {
10428
            ((this.delegate.destroyNode))(viewAllNodes[i]);
10429
        }
10430
    };
10431
    /**
10432
     * @param {?} renderElement
10433
     * @param {?} name
10434
     * @param {?} callback
10435
     * @return {?}
10436
     */
10437
    RendererAdapter.prototype.listen = function (renderElement, name, callback) {
10438
        return this.delegate.listen(renderElement, name, /** @type {?} */ (callback));
10439
    };
10440
    /**
10441
     * @param {?} target
10442
     * @param {?} name
10443
     * @param {?} callback
10444
     * @return {?}
10445
     */
10446
    RendererAdapter.prototype.listenGlobal = function (target, name, callback) {
10447
        return this.delegate.listen(target, name, /** @type {?} */ (callback));
10448
    };
10449
    /**
10450
     * @param {?} renderElement
10451
     * @param {?} propertyName
10452
     * @param {?} propertyValue
10453
     * @return {?}
10454
     */
10455
    RendererAdapter.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) {
10456
        this.delegate.setProperty(renderElement, propertyName, propertyValue);
10457
    };
10458
    /**
10459
     * @param {?} renderElement
10460
     * @param {?} namespaceAndName
10461
     * @param {?} attributeValue
10462
     * @return {?}
10463
     */
10464
    RendererAdapter.prototype.setElementAttribute = function (renderElement, namespaceAndName, attributeValue) {
10465
        var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
10466
        if (attributeValue != null) {
10467
            this.delegate.setAttribute(renderElement, name, attributeValue, ns);
10468
        }
10469
        else {
10470
            this.delegate.removeAttribute(renderElement, name, ns);
10471
        }
10472
    };
10473
    /**
10474
     * @param {?} renderElement
10475
     * @param {?} propertyName
10476
     * @param {?} propertyValue
10477
     * @return {?}
10478
     */
10479
    RendererAdapter.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
10480
    /**
10481
     * @param {?} renderElement
10482
     * @param {?} className
10483
     * @param {?} isAdd
10484
     * @return {?}
10485
     */
10486
    RendererAdapter.prototype.setElementClass = function (renderElement, className, isAdd) {
10487
        if (isAdd) {
10488
            this.delegate.addClass(renderElement, className);
10489
        }
10490
        else {
10491
            this.delegate.removeClass(renderElement, className);
10492
        }
10493
    };
10494
    /**
10495
     * @param {?} renderElement
10496
     * @param {?} styleName
10497
     * @param {?} styleValue
10498
     * @return {?}
10499
     */
10500
    RendererAdapter.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
10501
        if (styleValue != null) {
10502
            this.delegate.setStyle(renderElement, styleName, styleValue);
10503
        }
10504
        else {
10505
            this.delegate.removeStyle(renderElement, styleName);
10506
        }
10507
    };
10508
    /**
10509
     * @param {?} renderElement
10510
     * @param {?} methodName
10511
     * @param {?} args
10512
     * @return {?}
10513
     */
10514
    RendererAdapter.prototype.invokeElementMethod = function (renderElement, methodName, args) {
10515
        ((renderElement))[methodName].apply(renderElement, args);
10516
    };
10517
    /**
10518
     * @param {?} renderNode
10519
     * @param {?} text
10520
     * @return {?}
10521
     */
10522
    RendererAdapter.prototype.setText = function (renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); };
10523
    /**
10524
     * @return {?}
10525
     */
10526
    RendererAdapter.prototype.animate = function () { throw new Error('Renderer.animate is no longer supported!'); };
10527
    return RendererAdapter;
10528
}());
10529
/**
10530
 * @param {?} moduleType
10531
 * @param {?} parent
10532
 * @param {?} bootstrapComponents
10533
 * @param {?} def
10534
 * @return {?}
10535
 */
10536
function createNgModuleRef(moduleType, parent, bootstrapComponents, def) {
10537
    return new NgModuleRef_(moduleType, parent, bootstrapComponents, def);
10538
}
10539
var NgModuleRef_ = (function () {
10540
    /**
10541
     * @param {?} _moduleType
10542
     * @param {?} _parent
10543
     * @param {?} _bootstrapComponents
10544
     * @param {?} _def
10545
     */
10546
    function NgModuleRef_(_moduleType, _parent, _bootstrapComponents, _def) {
10547
        this._moduleType = _moduleType;
10548
        this._parent = _parent;
10549
        this._bootstrapComponents = _bootstrapComponents;
10550
        this._def = _def;
10551
        this._destroyListeners = [];
10552
        this._destroyed = false;
10553
        initNgModule(this);
10554
    }
10555
    /**
10556
     * @param {?} token
10557
     * @param {?=} notFoundValue
10558
     * @return {?}
10559
     */
10560
    NgModuleRef_.prototype.get = function (token, notFoundValue) {
10561
        if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
10562
        return resolveNgModuleDep(this, { token: token, tokenKey: tokenKey(token), flags: 0 /* None */ }, notFoundValue);
10563
    };
10564
    Object.defineProperty(NgModuleRef_.prototype, "instance", {
10565
        /**
10566
         * @return {?}
10567
         */
10568
        get: function () { return this.get(this._moduleType); },
10569
        enumerable: true,
10570
        configurable: true
10571
    });
10572
    Object.defineProperty(NgModuleRef_.prototype, "componentFactoryResolver", {
10573
        /**
10574
         * @return {?}
10575
         */
10576
        get: function () { return this.get(ComponentFactoryResolver); },
10577
        enumerable: true,
10578
        configurable: true
10579
    });
10580
    Object.defineProperty(NgModuleRef_.prototype, "injector", {
10581
        /**
10582
         * @return {?}
10583
         */
10584
        get: function () { return this; },
10585
        enumerable: true,
10586
        configurable: true
10587
    });
10588
    /**
10589
     * @return {?}
10590
     */
10591
    NgModuleRef_.prototype.destroy = function () {
10592
        if (this._destroyed) {
10593
            throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
10594
        }
10595
        this._destroyed = true;
10596
        callNgModuleLifecycle(this, 131072 /* OnDestroy */);
10597
        this._destroyListeners.forEach(function (listener) { return listener(); });
10598
    };
10599
    /**
10600
     * @param {?} callback
10601
     * @return {?}
10602
     */
10603
    NgModuleRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
10604
    return NgModuleRef_;
10605
}());
10606
/**
10607
 * @license
10608
 * Copyright Google Inc. All Rights Reserved.
10609
 *
10610
 * Use of this source code is governed by an MIT-style license that can be
10611
 * found in the LICENSE file at https://angular.io/license
10612
 */
10613
var RendererV1TokenKey = tokenKey(Renderer);
10614
var Renderer2TokenKey = tokenKey(Renderer2);
10615
var ElementRefTokenKey = tokenKey(ElementRef);
10616
var ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
10617
var TemplateRefTokenKey = tokenKey(TemplateRef);
10618
var ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
10619
var InjectorRefTokenKey = tokenKey(Injector);
10620
/**
10621
 * @param {?} checkIndex
10622
 * @param {?} flags
10623
 * @param {?} matchedQueries
10624
 * @param {?} childCount
10625
 * @param {?} ctor
10626
 * @param {?} deps
10627
 * @param {?=} props
10628
 * @param {?=} outputs
10629
 * @return {?}
10630
 */
10631
function directiveDef(checkIndex, flags, matchedQueries, childCount, ctor, deps, props, outputs) {
10632
    var /** @type {?} */ bindings = [];
10633
    if (props) {
10634
        for (var /** @type {?} */ prop in props) {
10635
            var _a = props[prop], bindingIndex = _a[0], nonMinifiedName = _a[1];
10636
            bindings[bindingIndex] = {
10637
                flags: 8 /* TypeProperty */,
10638
                name: prop, nonMinifiedName: nonMinifiedName,
10639
                ns: null,
10640
                securityContext: null,
10641
                suffix: null
10642
            };
10643
        }
10644
    }
10645
    var /** @type {?} */ outputDefs = [];
10646
    if (outputs) {
10647
        for (var /** @type {?} */ propName in outputs) {
10648
            outputDefs.push({ type: 1 /* DirectiveOutput */, propName: propName, target: null, eventName: outputs[propName] });
10649
        }
10650
    }
10651
    flags |= 16384 /* TypeDirective */;
10652
    return _def(checkIndex, flags, matchedQueries, childCount, ctor, ctor, deps, bindings, outputDefs);
10653
}
10654
/**
10655
 * @param {?} flags
10656
 * @param {?} ctor
10657
 * @param {?} deps
10658
 * @return {?}
10659
 */
10660
function pipeDef(flags, ctor, deps) {
10661
    flags |= 16 /* TypePipe */;
10662
    return _def(-1, flags, null, 0, ctor, ctor, deps);
10663
}
10664
/**
10665
 * @param {?} flags
10666
 * @param {?} matchedQueries
10667
 * @param {?} token
10668
 * @param {?} value
10669
 * @param {?} deps
10670
 * @return {?}
10671
 */
10672
function providerDef(flags, matchedQueries, token, value, deps) {
10673
    return _def(-1, flags, matchedQueries, 0, token, value, deps);
10674
}
10675
/**
10676
 * @param {?} checkIndex
10677
 * @param {?} flags
10678
 * @param {?} matchedQueriesDsl
10679
 * @param {?} childCount
10680
 * @param {?} token
10681
 * @param {?} value
10682
 * @param {?} deps
10683
 * @param {?=} bindings
10684
 * @param {?=} outputs
10685
 * @return {?}
10686
 */
10687
function _def(checkIndex, flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
10688
    var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
10689
    if (!outputs) {
10690
        outputs = [];
10691
    }
10692
    if (!bindings) {
10693
        bindings = [];
10694
    }
10695
    var /** @type {?} */ depDefs = splitDepsDsl(deps);
10696
    return {
10697
        // will bet set by the view definition
10698
        nodeIndex: -1,
10699
        parent: null,
10700
        renderParent: null,
10701
        bindingIndex: -1,
10702
        outputIndex: -1,
10703
        // regular values
10704
        checkIndex: checkIndex,
10705
        flags: flags,
10706
        childFlags: 0,
10707
        directChildFlags: 0,
10708
        childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references,
10709
        ngContentIndex: -1, childCount: childCount, bindings: bindings,
10710
        bindingFlags: calcBindingFlags(bindings), outputs: outputs,
10711
        element: null,
10712
        provider: { token: token, value: value, deps: depDefs },
10713
        text: null,
10714
        query: null,
10715
        ngContent: null
10716
    };
10717
}
10718
/**
10719
 * @param {?} view
10720
 * @param {?} def
10721
 * @return {?}
10722
 */
10723
function createProviderInstance(view, def) {
10724
    return _createProviderInstance(view, def);
10725
}
10726
/**
10727
 * @param {?} view
10728
 * @param {?} def
10729
 * @return {?}
10730
 */
10731
function createPipeInstance(view, def) {
10732
    // deps are looked up from component.
10733
    var /** @type {?} */ compView = view;
10734
    while (compView.parent && !isComponentView(compView)) {
10735
        compView = compView.parent;
10736
    }
10737
    // pipes can see the private services of the component
10738
    var /** @type {?} */ allowPrivateServices = true;
10739
    // pipes are always eager and classes!
10740
    return createClass(/** @type {?} */ ((compView.parent)), /** @type {?} */ ((viewParentEl(compView))), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10741
}
10742
/**
10743
 * @param {?} view
10744
 * @param {?} def
10745
 * @return {?}
10746
 */
10747
function createDirectiveInstance(view, def) {
10748
    // components can see other private services, other directives can't.
10749
    var /** @type {?} */ allowPrivateServices = (def.flags & 32768 /* Component */) > 0;
10750
    // directives are always eager and classes!
10751
    var /** @type {?} */ instance = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
10752
    if (def.outputs.length) {
10753
        for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
10754
            var /** @type {?} */ output = def.outputs[i];
10755
            var /** @type {?} */ subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, /** @type {?} */ ((def.parent)).nodeIndex, output.eventName)); /** @type {?} */
10756
            ((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
10757
        }
10758
    }
10759
    return instance;
10760
}
10761
/**
10762
 * @param {?} view
10763
 * @param {?} index
10764
 * @param {?} eventName
10765
 * @return {?}
10766
 */
10767
function eventHandlerClosure(view, index, eventName) {
10768
    return function (event) {
10769
        try {
10770
            return dispatchEvent(view, index, eventName, event);
10771
        }
10772
        catch (e) {
10773
            // Attention: Don't rethrow, as it would cancel Observable subscriptions!
10774
            view.root.errorHandler.handleError(e);
10775
        }
10776
    };
10777
}
10778
/**
10779
 * @param {?} view
10780
 * @param {?} def
10781
 * @param {?} v0
10782
 * @param {?} v1
10783
 * @param {?} v2
10784
 * @param {?} v3
10785
 * @param {?} v4
10786
 * @param {?} v5
10787
 * @param {?} v6
10788
 * @param {?} v7
10789
 * @param {?} v8
10790
 * @param {?} v9
10791
 * @return {?}
10792
 */
10793
function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
10794
    var /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
10795
    var /** @type {?} */ directive = providerData.instance;
10796
    var /** @type {?} */ changed = false;
10797
    var /** @type {?} */ changes = ((undefined));
10798
    var /** @type {?} */ bindLen = def.bindings.length;
10799
    if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
10800
        changed = true;
10801
        changes = updateProp(view, providerData, def, 0, v0, changes);
10802
    }
10803
    if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
10804
        changed = true;
10805
        changes = updateProp(view, providerData, def, 1, v1, changes);
10806
    }
10807
    if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
10808
        changed = true;
10809
        changes = updateProp(view, providerData, def, 2, v2, changes);
10810
    }
10811
    if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
10812
        changed = true;
10813
        changes = updateProp(view, providerData, def, 3, v3, changes);
10814
    }
10815
    if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
10816
        changed = true;
10817
        changes = updateProp(view, providerData, def, 4, v4, changes);
10818
    }
10819
    if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
10820
        changed = true;
10821
        changes = updateProp(view, providerData, def, 5, v5, changes);
10822
    }
10823
    if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
10824
        changed = true;
10825
        changes = updateProp(view, providerData, def, 6, v6, changes);
10826
    }
10827
    if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
10828
        changed = true;
10829
        changes = updateProp(view, providerData, def, 7, v7, changes);
10830
    }
10831
    if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
10832
        changed = true;
10833
        changes = updateProp(view, providerData, def, 8, v8, changes);
10834
    }
10835
    if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
10836
        changed = true;
10837
        changes = updateProp(view, providerData, def, 9, v9, changes);
10838
    }
10839
    if (changes) {
10840
        directive.ngOnChanges(changes);
10841
    }
10842
    if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
10843
        directive.ngOnInit();
10844
    }
10845
    if (def.flags & 262144 /* DoCheck */) {
10846
        directive.ngDoCheck();
10847
    }
10848
    return changed;
10849
}
10850
/**
10851
 * @param {?} view
10852
 * @param {?} def
10853
 * @param {?} values
10854
 * @return {?}
10855
 */
10856
function checkAndUpdateDirectiveDynamic(view, def, values) {
10857
    var /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
10858
    var /** @type {?} */ directive = providerData.instance;
10859
    var /** @type {?} */ changed = false;
10860
    var /** @type {?} */ changes = ((undefined));
10861
    for (var /** @type {?} */ i = 0; i < values.length; i++) {
10862
        if (checkBinding(view, def, i, values[i])) {
10863
            changed = true;
10864
            changes = updateProp(view, providerData, def, i, values[i], changes);
10865
        }
10866
    }
10867
    if (changes) {
10868
        directive.ngOnChanges(changes);
10869
    }
10870
    if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
10871
        directive.ngOnInit();
10872
    }
10873
    if (def.flags & 262144 /* DoCheck */) {
10874
        directive.ngDoCheck();
10875
    }
10876
    return changed;
10877
}
10878
/**
10879
 * @param {?} view
10880
 * @param {?} def
10881
 * @return {?}
10882
 */
10883
function _createProviderInstance(view, def) {
10884
    // private services can see other private services
10885
    var /** @type {?} */ allowPrivateServices = (def.flags & 8192 /* PrivateProvider */) > 0;
10886
    var /** @type {?} */ providerDef = def.provider;
10887
    switch (def.flags & 201347067 /* Types */) {
10888
        case 512 /* TypeClassProvider */:
10889
            return createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10890
        case 1024 /* TypeFactoryProvider */:
10891
            return callFactory(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
10892
        case 2048 /* TypeUseExistingProvider */:
10893
            return resolveDep(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).deps[0]);
10894
        case 256 /* TypeValueProvider */:
10895
            return ((providerDef)).value;
10896
    }
10897
}
10898
/**
10899
 * @param {?} view
10900
 * @param {?} elDef
10901
 * @param {?} allowPrivateServices
10902
 * @param {?} ctor
10903
 * @param {?} deps
10904
 * @return {?}
10905
 */
10906
function createClass(view, elDef, allowPrivateServices, ctor, deps) {
10907
    var /** @type {?} */ len = deps.length;
10908
    switch (len) {
10909
        case 0:
10910
            return new ctor();
10911
        case 1:
10912
            return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10913
        case 2:
10914
            return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10915
        case 3:
10916
            return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10917
        default:
10918
            var /** @type {?} */ depValues = new Array(len);
10919
            for (var /** @type {?} */ i = 0; i < len; i++) {
10920
                depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10921
            }
10922
            return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
10923
    }
10924
}
10925
/**
10926
 * @param {?} view
10927
 * @param {?} elDef
10928
 * @param {?} allowPrivateServices
10929
 * @param {?} factory
10930
 * @param {?} deps
10931
 * @return {?}
10932
 */
10933
function callFactory(view, elDef, allowPrivateServices, factory, deps) {
10934
    var /** @type {?} */ len = deps.length;
10935
    switch (len) {
10936
        case 0:
10937
            return factory();
10938
        case 1:
10939
            return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
10940
        case 2:
10941
            return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
10942
        case 3:
10943
            return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
10944
        default:
10945
            var /** @type {?} */ depValues = Array(len);
10946
            for (var /** @type {?} */ i = 0; i < len; i++) {
10947
                depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
10948
            }
10949
            return factory.apply(void 0, depValues);
10950
    }
10951
}
10952
// This default value is when checking the hierarchy for a token.
10953
//
10954
// It means both:
10955
// - the token is not provided by the current injector,
10956
// - only the element injectors should be checked (ie do not check module injectors
10957
//
10958
//          mod1
10959
//         /
10960
//       el1   mod2
10961
//         \  /
10962
//         el2
10963
//
10964
// When requesting el2.injector.get(token), we should check in the following order and return the
10965
// first found value:
10966
// - el2.injector.get(token, default)
10967
// - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
10968
// - mod2.injector.get(token, default)
10969
var NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
10970
/**
10971
 * @param {?} view
10972
 * @param {?} elDef
10973
 * @param {?} allowPrivateServices
10974
 * @param {?} depDef
10975
 * @param {?=} notFoundValue
10976
 * @return {?}
10977
 */
10978
function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue) {
10979
    if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
10980
    if (depDef.flags & 8 /* Value */) {
10981
        return depDef.token;
10982
    }
10983
    var /** @type {?} */ startView = view;
10984
    if (depDef.flags & 2 /* Optional */) {
10985
        notFoundValue = null;
10986
    }
10987
    var /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
10988
    if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
10989
        // directives on the same element as a component should be able to control the change detector
10990
        // of that component as well.
10991
        allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
10992
    }
10993
    if (elDef && (depDef.flags & 1 /* SkipSelf */)) {
10994
        allowPrivateServices = false;
10995
        elDef = ((elDef.parent));
10996
    }
10997
    while (view) {
10998
        if (elDef) {
10999
            switch (tokenKey$$1) {
11000
                case RendererV1TokenKey: {
11001
                    var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
11002
                    return createRendererV1(compView);
11003
                }
11004
                case Renderer2TokenKey: {
11005
                    var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
11006
                    return compView.renderer;
11007
                }
11008
                case ElementRefTokenKey:
11009
                    return new ElementRef(asElementData(view, elDef.nodeIndex).renderElement);
11010
                case ViewContainerRefTokenKey:
11011
                    return asElementData(view, elDef.nodeIndex).viewContainer;
11012
                case TemplateRefTokenKey: {
11013
                    if (((elDef.element)).template) {
11014
                        return asElementData(view, elDef.nodeIndex).template;
11015
                    }
11016
                    break;
11017
                }
11018
                case ChangeDetectorRefTokenKey: {
11019
                    var /** @type {?} */ cdView = findCompView(view, elDef, allowPrivateServices);
11020
                    return createChangeDetectorRef(cdView);
11021
                }
11022
                case InjectorRefTokenKey:
11023
                    return createInjector(view, elDef);
11024
                default:
11025
                    var /** @type {?} */ providerDef_1 = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
11026
                    if (providerDef_1) {
11027
                        var /** @type {?} */ providerData = asProviderData(view, providerDef_1.nodeIndex);
11028
                        if (!providerData) {
11029
                            providerData = { instance: _createProviderInstance(view, providerDef_1) };
11030
                            view.nodes[providerDef_1.nodeIndex] = (providerData);
11031
                        }
11032
                        return providerData.instance;
11033
                    }
11034
            }
11035
        }
11036
        allowPrivateServices = isComponentView(view);
11037
        elDef = ((viewParentEl(view)));
11038
        view = ((view.parent));
11039
    }
11040
    var /** @type {?} */ value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
11041
    if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
11042
        notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
11043
        // Return the value from the root element injector when
11044
        // - it provides it
11045
        //   (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
11046
        // - the module injector should not be checked
11047
        //   (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
11048
        return value;
11049
    }
11050
    return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
11051
}
11052
/**
11053
 * @param {?} view
11054
 * @param {?} elDef
11055
 * @param {?} allowPrivateServices
11056
 * @return {?}
11057
 */
11058
function findCompView(view, elDef, allowPrivateServices) {
11059
    var /** @type {?} */ compView;
11060
    if (allowPrivateServices) {
11061
        compView = asElementData(view, elDef.nodeIndex).componentView;
11062
    }
11063
    else {
11064
        compView = view;
11065
        while (compView.parent && !isComponentView(compView)) {
11066
            compView = compView.parent;
11067
        }
11068
    }
11069
    return compView;
11070
}
11071
/**
11072
 * @param {?} view
11073
 * @param {?} providerData
11074
 * @param {?} def
11075
 * @param {?} bindingIdx
11076
 * @param {?} value
11077
 * @param {?} changes
11078
 * @return {?}
11079
 */
11080
function updateProp(view, providerData, def, bindingIdx, value, changes) {
11081
    if (def.flags & 32768 /* Component */) {
11082
        var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((def.parent)).nodeIndex).componentView;
11083
        if (compView.def.flags & 2 /* OnPush */) {
11084
            compView.state |= 8 /* ChecksEnabled */;
11085
        }
11086
    }
11087
    var /** @type {?} */ binding = def.bindings[bindingIdx];
11088
    var /** @type {?} */ propName = ((binding.name));
11089
    // Note: This is still safe with Closure Compiler as
11090
    // the user passed in the property name as an object has to `providerDef`,
11091
    // so Closure Compiler will have renamed the property correctly already.
11092
    providerData.instance[propName] = value;
11093
    if (def.flags & 524288 /* OnChanges */) {
11094
        changes = changes || {};
11095
        var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
11096
        if (oldValue instanceof WrappedValue) {
11097
            oldValue = oldValue.wrapped;
11098
        }
11099
        var /** @type {?} */ binding_1 = def.bindings[bindingIdx];
11100
        changes[((binding_1.nonMinifiedName))] =
11101
            new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
11102
    }
11103
    view.oldValues[def.bindingIndex + bindingIdx] = value;
11104
    return changes;
11105
}
11106
/**
11107
 * @param {?} view
11108
 * @param {?} lifecycles
11109
 * @return {?}
11110
 */
11111
function callLifecycleHooksChildrenFirst(view, lifecycles) {
11112
    if (!(view.def.nodeFlags & lifecycles)) {
11113
        return;
11114
    }
11115
    var /** @type {?} */ nodes = view.def.nodes;
11116
    for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
11117
        var /** @type {?} */ nodeDef = nodes[i];
11118
        var /** @type {?} */ parent = nodeDef.parent;
11119
        if (!parent && nodeDef.flags & lifecycles) {
11120
            // matching root node (e.g. a pipe)
11121
            callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
11122
        }
11123
        if ((nodeDef.childFlags & lifecycles) === 0) {
11124
            // no child matches one of the lifecycles
11125
            i += nodeDef.childCount;
11126
        }
11127
        while (parent && (parent.flags & 1 /* TypeElement */) &&
11128
            i === parent.nodeIndex + parent.childCount) {
11129
            // last child of an element
11130
            if (parent.directChildFlags & lifecycles) {
11131
                callElementProvidersLifecycles(view, parent, lifecycles);
11132
            }
11133
            parent = parent.parent;
11134
        }
11135
    }
11136
}
11137
/**
11138
 * @param {?} view
11139
 * @param {?} elDef
11140
 * @param {?} lifecycles
11141
 * @return {?}
11142
 */
11143
function callElementProvidersLifecycles(view, elDef, lifecycles) {
11144
    for (var /** @type {?} */ i = elDef.nodeIndex + 1; i <= elDef.nodeIndex + elDef.childCount; i++) {
11145
        var /** @type {?} */ nodeDef = view.def.nodes[i];
11146
        if (nodeDef.flags & lifecycles) {
11147
            callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
11148
        }
11149
        // only visit direct children
11150
        i += nodeDef.childCount;
11151
    }
11152
}
11153
/**
11154
 * @param {?} view
11155
 * @param {?} index
11156
 * @param {?} lifecycles
11157
 * @return {?}
11158
 */
11159
function callProviderLifecycles(view, index, lifecycles) {
11160
    var /** @type {?} */ providerData = asProviderData(view, index);
11161
    if (!providerData) {
11162
        return;
11163
    }
11164
    var /** @type {?} */ provider = providerData.instance;
11165
    if (!provider) {
11166
        return;
11167
    }
11168
    Services.setCurrentNode(view, index);
11169
    if (lifecycles & 1048576 /* AfterContentInit */) {
11170
        provider.ngAfterContentInit();
11171
    }
11172
    if (lifecycles & 2097152 /* AfterContentChecked */) {
11173
        provider.ngAfterContentChecked();
11174
    }
11175
    if (lifecycles & 4194304 /* AfterViewInit */) {
11176
        provider.ngAfterViewInit();
11177
    }
11178
    if (lifecycles & 8388608 /* AfterViewChecked */) {
11179
        provider.ngAfterViewChecked();
11180
    }
11181
    if (lifecycles & 131072 /* OnDestroy */) {
11182
        provider.ngOnDestroy();
11183
    }
11184
}
11185
/**
11186
 * @license
11187
 * Copyright Google Inc. All Rights Reserved.
11188
 *
11189
 * Use of this source code is governed by an MIT-style license that can be
11190
 * found in the LICENSE file at https://angular.io/license
11191
 */
11192
/**
11193
 * @param {?} flags
11194
 * @param {?} id
11195
 * @param {?} bindings
11196
 * @return {?}
11197
 */
11198
function queryDef(flags, id, bindings) {
11199
    var /** @type {?} */ bindingDefs = [];
11200
    for (var /** @type {?} */ propName in bindings) {
11201
        var /** @type {?} */ bindingType = bindings[propName];
11202
        bindingDefs.push({ propName: propName, bindingType: bindingType });
11203
    }
11204
    return {
11205
        // will bet set by the view definition
11206
        nodeIndex: -1,
11207
        parent: null,
11208
        renderParent: null,
11209
        bindingIndex: -1,
11210
        outputIndex: -1,
11211
        // regular values
11212
        // TODO(vicb): check
11213
        checkIndex: -1, flags: flags,
11214
        childFlags: 0,
11215
        directChildFlags: 0,
11216
        childMatchedQueries: 0,
11217
        ngContentIndex: -1,
11218
        matchedQueries: {},
11219
        matchedQueryIds: 0,
11220
        references: {},
11221
        childCount: 0,
11222
        bindings: [],
11223
        bindingFlags: 0,
11224
        outputs: [],
11225
        element: null,
11226
        provider: null,
11227
        text: null,
11228
        query: { id: id, filterId: filterQueryId(id), bindings: bindingDefs },
11229
        ngContent: null
11230
    };
11231
}
11232
/**
11233
 * @return {?}
11234
 */
11235
function createQuery() {
11236
    return new QueryList();
11237
}
11238
/**
11239
 * @param {?} view
11240
 * @return {?}
11241
 */
11242
function dirtyParentQueries(view) {
11243
    var /** @type {?} */ queryIds = view.def.nodeMatchedQueries;
11244
    while (view.parent && isEmbeddedView(view)) {
11245
        var /** @type {?} */ tplDef = ((view.parentNodeDef));
11246
        view = view.parent;
11247
        // content queries
11248
        var /** @type {?} */ end = tplDef.nodeIndex + tplDef.childCount;
11249
        for (var /** @type {?} */ i = 0; i <= end; i++) {
11250
            var /** @type {?} */ nodeDef = view.def.nodes[i];
11251
            if ((nodeDef.flags & 67108864 /* TypeContentQuery */) &&
11252
                (nodeDef.flags & 536870912 /* DynamicQuery */) &&
11253
                (((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
11254
                asQueryList(view, i).setDirty();
11255
            }
11256
            if ((nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.nodeIndex) ||
11257
                !(nodeDef.childFlags & 67108864 /* TypeContentQuery */) ||
11258
                !(nodeDef.childFlags & 536870912 /* DynamicQuery */)) {
11259
                // skip elements that don't contain the template element or no query.
11260
                i += nodeDef.childCount;
11261
            }
11262
        }
11263
    }
11264
    // view queries
11265
    if (view.def.nodeFlags & 134217728 /* TypeViewQuery */) {
11266
        for (var /** @type {?} */ i = 0; i < view.def.nodes.length; i++) {
11267
            var /** @type {?} */ nodeDef = view.def.nodes[i];
11268
            if ((nodeDef.flags & 134217728 /* TypeViewQuery */) && (nodeDef.flags & 536870912 /* DynamicQuery */)) {
11269
                asQueryList(view, i).setDirty();
11270
            }
11271
            // only visit the root nodes
11272
            i += nodeDef.childCount;
11273
        }
11274
    }
11275
}
11276
/**
11277
 * @param {?} view
11278
 * @param {?} nodeDef
11279
 * @return {?}
11280
 */
11281
function checkAndUpdateQuery(view, nodeDef) {
11282
    var /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
11283
    if (!queryList.dirty) {
11284
        return;
11285
    }
11286
    var /** @type {?} */ directiveInstance;
11287
    var /** @type {?} */ newValues = ((undefined));
11288
    if (nodeDef.flags & 67108864 /* TypeContentQuery */) {
11289
        var /** @type {?} */ elementDef_1 = ((((nodeDef.parent)).parent));
11290
        newValues = calcQueryValues(view, elementDef_1.nodeIndex, elementDef_1.nodeIndex + elementDef_1.childCount, /** @type {?} */ ((nodeDef.query)), []);
11291
        directiveInstance = asProviderData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).instance;
11292
    }
11293
    else if (nodeDef.flags & 134217728 /* TypeViewQuery */) {
11294
        newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */ ((nodeDef.query)), []);
11295
        directiveInstance = view.component;
11296
    }
11297
    queryList.reset(newValues);
11298
    var /** @type {?} */ bindings = ((nodeDef.query)).bindings;
11299
    var /** @type {?} */ notify = false;
11300
    for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
11301
        var /** @type {?} */ binding = bindings[i];
11302
        var /** @type {?} */ boundValue = void 0;
11303
        switch (binding.bindingType) {
11304
            case 0 /* First */:
11305
                boundValue = queryList.first;
11306
                break;
11307
            case 1 /* All */:
11308
                boundValue = queryList;
11309
                notify = true;
11310
                break;
11311
        }
11312
        directiveInstance[binding.propName] = boundValue;
11313
    }
11314
    if (notify) {
11315
        queryList.notifyOnChanges();
11316
    }
11317
}
11318
/**
11319
 * @param {?} view
11320
 * @param {?} startIndex
11321
 * @param {?} endIndex
11322
 * @param {?} queryDef
11323
 * @param {?} values
11324
 * @return {?}
11325
 */
11326
function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
11327
    for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
11328
        var /** @type {?} */ nodeDef = view.def.nodes[i];
11329
        var /** @type {?} */ valueType = nodeDef.matchedQueries[queryDef.id];
11330
        if (valueType != null) {
11331
            values.push(getQueryValue(view, nodeDef, valueType));
11332
        }
11333
        if (nodeDef.flags & 1 /* TypeElement */ && ((nodeDef.element)).template &&
11334
            (((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
11335
                queryDef.filterId) {
11336
            var /** @type {?} */ elementData = asElementData(view, i);
11337
            // check embedded views that were attached at the place of their template,
11338
            // but process child nodes first if some match the query (see issue #16568)
11339
            if ((nodeDef.childMatchedQueries & queryDef.filterId) === queryDef.filterId) {
11340
                calcQueryValues(view, i + 1, i + nodeDef.childCount, queryDef, values);
11341
                i += nodeDef.childCount;
11342
            }
11343
            if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
11344
                var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
11345
                for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
11346
                    var /** @type {?} */ embeddedView = embeddedViews[k];
11347
                    var /** @type {?} */ dvc = declaredViewContainer(embeddedView);
11348
                    if (dvc && dvc === elementData) {
11349
                        calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
11350
                    }
11351
                }
11352
            }
11353
            var /** @type {?} */ projectedViews = elementData.template._projectedViews;
11354
            if (projectedViews) {
11355
                for (var /** @type {?} */ k = 0; k < projectedViews.length; k++) {
11356
                    var /** @type {?} */ projectedView = projectedViews[k];
11357
                    calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
11358
                }
11359
            }
11360
        }
11361
        if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
11362
            // if no child matches the query, skip the children.
11363
            i += nodeDef.childCount;
11364
        }
11365
    }
11366
    return values;
11367
}
11368
/**
11369
 * @param {?} view
11370
 * @param {?} nodeDef
11371
 * @param {?} queryValueType
11372
 * @return {?}
11373
 */
11374
function getQueryValue(view, nodeDef, queryValueType) {
11375
    if (queryValueType != null) {
11376
        // a match
11377
        switch (queryValueType) {
11378
            case 1 /* RenderElement */:
11379
                return asElementData(view, nodeDef.nodeIndex).renderElement;
11380
            case 0 /* ElementRef */:
11381
                return new ElementRef(asElementData(view, nodeDef.nodeIndex).renderElement);
11382
            case 2 /* TemplateRef */:
11383
                return asElementData(view, nodeDef.nodeIndex).template;
11384
            case 3 /* ViewContainerRef */:
11385
                return asElementData(view, nodeDef.nodeIndex).viewContainer;
11386
            case 4 /* Provider */:
11387
                return asProviderData(view, nodeDef.nodeIndex).instance;
11388
        }
11389
    }
11390
}
11391
/**
11392
 * @license
11393
 * Copyright Google Inc. All Rights Reserved.
11394
 *
11395
 * Use of this source code is governed by an MIT-style license that can be
11396
 * found in the LICENSE file at https://angular.io/license
11397
 */
11398
/**
11399
 * @param {?} ngContentIndex
11400
 * @param {?} index
11401
 * @return {?}
11402
 */
11403
function ngContentDef(ngContentIndex, index) {
11404
    return {
11405
        // will bet set by the view definition
11406
        nodeIndex: -1,
11407
        parent: null,
11408
        renderParent: null,
11409
        bindingIndex: -1,
11410
        outputIndex: -1,
11411
        // regular values
11412
        checkIndex: -1,
11413
        flags: 8 /* TypeNgContent */,
11414
        childFlags: 0,
11415
        directChildFlags: 0,
11416
        childMatchedQueries: 0,
11417
        matchedQueries: {},
11418
        matchedQueryIds: 0,
11419
        references: {}, ngContentIndex: ngContentIndex,
11420
        childCount: 0,
11421
        bindings: [],
11422
        bindingFlags: 0,
11423
        outputs: [],
11424
        element: null,
11425
        provider: null,
11426
        text: null,
11427
        query: null,
11428
        ngContent: { index: index }
11429
    };
11430
}
11431
/**
11432
 * @param {?} view
11433
 * @param {?} renderHost
11434
 * @param {?} def
11435
 * @return {?}
11436
 */
11437
function appendNgContent(view, renderHost, def) {
11438
    var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
11439
    if (!parentEl) {
11440
        // Nothing to do if there is no parent element.
11441
        return;
11442
    }
11443
    var /** @type {?} */ ngContentIndex = ((def.ngContent)).index;
11444
    visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
11445
}
11446
/**
11447
 * @license
11448
 * Copyright Google Inc. All Rights Reserved.
11449
 *
11450
 * Use of this source code is governed by an MIT-style license that can be
11451
 * found in the LICENSE file at https://angular.io/license
11452
 */
11453
/**
11454
 * @param {?} checkIndex
11455
 * @param {?} argCount
11456
 * @return {?}
11457
 */
11458
function purePipeDef(checkIndex, argCount) {
11459
    // argCount + 1 to include the pipe as first arg
11460
    return _pureExpressionDef(128 /* TypePurePipe */, checkIndex, new Array(argCount + 1));
11461
}
11462
/**
11463
 * @param {?} checkIndex
11464
 * @param {?} argCount
11465
 * @return {?}
11466
 */
11467
function pureArrayDef(checkIndex, argCount) {
11468
    return _pureExpressionDef(32 /* TypePureArray */, checkIndex, new Array(argCount));
11469
}
11470
/**
11471
 * @param {?} checkIndex
11472
 * @param {?} propToIndex
11473
 * @return {?}
11474
 */
11475
function pureObjectDef(checkIndex, propToIndex) {
11476
    var /** @type {?} */ keys = Object.keys(propToIndex);
11477
    var /** @type {?} */ nbKeys = keys.length;
11478
    var /** @type {?} */ propertyNames = new Array(nbKeys);
11479
    for (var /** @type {?} */ i = 0; i < nbKeys; i++) {
11480
        var /** @type {?} */ key = keys[i];
11481
        var /** @type {?} */ index = propToIndex[key];
11482
        propertyNames[index] = key;
11483
    }
11484
    return _pureExpressionDef(64 /* TypePureObject */, checkIndex, propertyNames);
11485
}
11486
/**
11487
 * @param {?} flags
11488
 * @param {?} checkIndex
11489
 * @param {?} propertyNames
11490
 * @return {?}
11491
 */
11492
function _pureExpressionDef(flags, checkIndex, propertyNames) {
11493
    var /** @type {?} */ bindings = new Array(propertyNames.length);
11494
    for (var /** @type {?} */ i = 0; i < propertyNames.length; i++) {
11495
        var /** @type {?} */ prop = propertyNames[i];
11496
        bindings[i] = {
11497
            flags: 8 /* TypeProperty */,
11498
            name: prop,
11499
            ns: null,
11500
            nonMinifiedName: prop,
11501
            securityContext: null,
11502
            suffix: null
11503
        };
11504
    }
11505
    return {
11506
        // will bet set by the view definition
11507
        nodeIndex: -1,
11508
        parent: null,
11509
        renderParent: null,
11510
        bindingIndex: -1,
11511
        outputIndex: -1,
11512
        // regular values
11513
        checkIndex: checkIndex,
11514
        flags: flags,
11515
        childFlags: 0,
11516
        directChildFlags: 0,
11517
        childMatchedQueries: 0,
11518
        matchedQueries: {},
11519
        matchedQueryIds: 0,
11520
        references: {},
11521
        ngContentIndex: -1,
11522
        childCount: 0, bindings: bindings,
11523
        bindingFlags: calcBindingFlags(bindings),
11524
        outputs: [],
11525
        element: null,
11526
        provider: null,
11527
        text: null,
11528
        query: null,
11529
        ngContent: null
11530
    };
11531
}
11532
/**
11533
 * @param {?} view
11534
 * @param {?} def
11535
 * @return {?}
11536
 */
11537
function createPureExpression(view, def) {
11538
    return { value: undefined };
11539
}
11540
/**
11541
 * @param {?} view
11542
 * @param {?} def
11543
 * @param {?} v0
11544
 * @param {?} v1
11545
 * @param {?} v2
11546
 * @param {?} v3
11547
 * @param {?} v4
11548
 * @param {?} v5
11549
 * @param {?} v6
11550
 * @param {?} v7
11551
 * @param {?} v8
11552
 * @param {?} v9
11553
 * @return {?}
11554
 */
11555
function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11556
    var /** @type {?} */ bindings = def.bindings;
11557
    var /** @type {?} */ changed = false;
11558
    var /** @type {?} */ bindLen = bindings.length;
11559
    if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
11560
        changed = true;
11561
    if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
11562
        changed = true;
11563
    if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
11564
        changed = true;
11565
    if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
11566
        changed = true;
11567
    if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
11568
        changed = true;
11569
    if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
11570
        changed = true;
11571
    if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
11572
        changed = true;
11573
    if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
11574
        changed = true;
11575
    if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
11576
        changed = true;
11577
    if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
11578
        changed = true;
11579
    if (changed) {
11580
        var /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
11581
        var /** @type {?} */ value = void 0;
11582
        switch (def.flags & 201347067 /* Types */) {
11583
            case 32 /* TypePureArray */:
11584
                value = new Array(bindings.length);
11585
                if (bindLen > 0)
11586
                    value[0] = v0;
11587
                if (bindLen > 1)
11588
                    value[1] = v1;
11589
                if (bindLen > 2)
11590
                    value[2] = v2;
11591
                if (bindLen > 3)
11592
                    value[3] = v3;
11593
                if (bindLen > 4)
11594
                    value[4] = v4;
11595
                if (bindLen > 5)
11596
                    value[5] = v5;
11597
                if (bindLen > 6)
11598
                    value[6] = v6;
11599
                if (bindLen > 7)
11600
                    value[7] = v7;
11601
                if (bindLen > 8)
11602
                    value[8] = v8;
11603
                if (bindLen > 9)
11604
                    value[9] = v9;
11605
                break;
11606
            case 64 /* TypePureObject */:
11607
                value = {};
11608
                if (bindLen > 0)
11609
                    value[((bindings[0].name))] = v0;
11610
                if (bindLen > 1)
11611
                    value[((bindings[1].name))] = v1;
11612
                if (bindLen > 2)
11613
                    value[((bindings[2].name))] = v2;
11614
                if (bindLen > 3)
11615
                    value[((bindings[3].name))] = v3;
11616
                if (bindLen > 4)
11617
                    value[((bindings[4].name))] = v4;
11618
                if (bindLen > 5)
11619
                    value[((bindings[5].name))] = v5;
11620
                if (bindLen > 6)
11621
                    value[((bindings[6].name))] = v6;
11622
                if (bindLen > 7)
11623
                    value[((bindings[7].name))] = v7;
11624
                if (bindLen > 8)
11625
                    value[((bindings[8].name))] = v8;
11626
                if (bindLen > 9)
11627
                    value[((bindings[9].name))] = v9;
11628
                break;
11629
            case 128 /* TypePurePipe */:
11630
                var /** @type {?} */ pipe = v0;
11631
                switch (bindLen) {
11632
                    case 1:
11633
                        value = pipe.transform(v0);
11634
                        break;
11635
                    case 2:
11636
                        value = pipe.transform(v1);
11637
                        break;
11638
                    case 3:
11639
                        value = pipe.transform(v1, v2);
11640
                        break;
11641
                    case 4:
11642
                        value = pipe.transform(v1, v2, v3);
11643
                        break;
11644
                    case 5:
11645
                        value = pipe.transform(v1, v2, v3, v4);
11646
                        break;
11647
                    case 6:
11648
                        value = pipe.transform(v1, v2, v3, v4, v5);
11649
                        break;
11650
                    case 7:
11651
                        value = pipe.transform(v1, v2, v3, v4, v5, v6);
11652
                        break;
11653
                    case 8:
11654
                        value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
11655
                        break;
11656
                    case 9:
11657
                        value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
11658
                        break;
11659
                    case 10:
11660
                        value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
11661
                        break;
11662
                }
11663
                break;
11664
        }
11665
        data.value = value;
11666
    }
11667
    return changed;
11668
}
11669
/**
11670
 * @param {?} view
11671
 * @param {?} def
11672
 * @param {?} values
11673
 * @return {?}
11674
 */
11675
function checkAndUpdatePureExpressionDynamic(view, def, values) {
11676
    var /** @type {?} */ bindings = def.bindings;
11677
    var /** @type {?} */ changed = false;
11678
    for (var /** @type {?} */ i = 0; i < values.length; i++) {
11679
        // Note: We need to loop over all values, so that
11680
        // the old values are updates as well!
11681
        if (checkAndUpdateBinding(view, def, i, values[i])) {
11682
            changed = true;
11683
        }
11684
    }
11685
    if (changed) {
11686
        var /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
11687
        var /** @type {?} */ value = void 0;
11688
        switch (def.flags & 201347067 /* Types */) {
11689
            case 32 /* TypePureArray */:
11690
                value = values;
11691
                break;
11692
            case 64 /* TypePureObject */:
11693
                value = {};
11694
                for (var /** @type {?} */ i = 0; i < values.length; i++) {
11695
                    value[((bindings[i].name))] = values[i];
11696
                }
11697
                break;
11698
            case 128 /* TypePurePipe */:
11699
                var /** @type {?} */ pipe = values[0];
11700
                var /** @type {?} */ params = values.slice(1);
11701
                value = pipe.transform.apply(pipe, params);
11702
                break;
11703
        }
11704
        data.value = value;
11705
    }
11706
    return changed;
11707
}
11708
/**
11709
 * @license
11710
 * Copyright Google Inc. All Rights Reserved.
11711
 *
11712
 * Use of this source code is governed by an MIT-style license that can be
11713
 * found in the LICENSE file at https://angular.io/license
11714
 */
11715
/**
11716
 * @param {?} checkIndex
11717
 * @param {?} ngContentIndex
11718
 * @param {?} staticText
11719
 * @return {?}
11720
 */
11721
function textDef(checkIndex, ngContentIndex, staticText) {
11722
    var /** @type {?} */ bindings = new Array(staticText.length - 1);
11723
    for (var /** @type {?} */ i = 1; i < staticText.length; i++) {
11724
        bindings[i - 1] = {
11725
            flags: 8 /* TypeProperty */,
11726
            name: null,
11727
            ns: null,
11728
            nonMinifiedName: null,
11729
            securityContext: null,
11730
            suffix: staticText[i],
11731
        };
11732
    }
11733
    return {
11734
        // will bet set by the view definition
11735
        nodeIndex: -1,
11736
        parent: null,
11737
        renderParent: null,
11738
        bindingIndex: -1,
11739
        outputIndex: -1,
11740
        // regular values
11741
        checkIndex: checkIndex,
11742
        flags: 2 /* TypeText */,
11743
        childFlags: 0,
11744
        directChildFlags: 0,
11745
        childMatchedQueries: 0,
11746
        matchedQueries: {},
11747
        matchedQueryIds: 0,
11748
        references: {}, ngContentIndex: ngContentIndex,
11749
        childCount: 0, bindings: bindings,
11750
        bindingFlags: 8 /* TypeProperty */,
11751
        outputs: [],
11752
        element: null,
11753
        provider: null,
11754
        text: { prefix: staticText[0] },
11755
        query: null,
11756
        ngContent: null,
11757
    };
11758
}
11759
/**
11760
 * @param {?} view
11761
 * @param {?} renderHost
11762
 * @param {?} def
11763
 * @return {?}
11764
 */
11765
function createText(view, renderHost, def) {
11766
    var /** @type {?} */ renderNode$$1;
11767
    var /** @type {?} */ renderer = view.renderer;
11768
    renderNode$$1 = renderer.createText(/** @type {?} */ ((def.text)).prefix);
11769
    var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
11770
    if (parentEl) {
11771
        renderer.appendChild(parentEl, renderNode$$1);
11772
    }
11773
    return { renderText: renderNode$$1 };
11774
}
11775
/**
11776
 * @param {?} view
11777
 * @param {?} def
11778
 * @param {?} v0
11779
 * @param {?} v1
11780
 * @param {?} v2
11781
 * @param {?} v3
11782
 * @param {?} v4
11783
 * @param {?} v5
11784
 * @param {?} v6
11785
 * @param {?} v7
11786
 * @param {?} v8
11787
 * @param {?} v9
11788
 * @return {?}
11789
 */
11790
function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
11791
    var /** @type {?} */ changed = false;
11792
    var /** @type {?} */ bindings = def.bindings;
11793
    var /** @type {?} */ bindLen = bindings.length;
11794
    if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
11795
        changed = true;
11796
    if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
11797
        changed = true;
11798
    if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
11799
        changed = true;
11800
    if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
11801
        changed = true;
11802
    if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
11803
        changed = true;
11804
    if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
11805
        changed = true;
11806
    if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
11807
        changed = true;
11808
    if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
11809
        changed = true;
11810
    if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
11811
        changed = true;
11812
    if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
11813
        changed = true;
11814
    if (changed) {
11815
        var /** @type {?} */ value = ((def.text)).prefix;
11816
        if (bindLen > 0)
11817
            value += _addInterpolationPart(v0, bindings[0]);
11818
        if (bindLen > 1)
11819
            value += _addInterpolationPart(v1, bindings[1]);
11820
        if (bindLen > 2)
11821
            value += _addInterpolationPart(v2, bindings[2]);
11822
        if (bindLen > 3)
11823
            value += _addInterpolationPart(v3, bindings[3]);
11824
        if (bindLen > 4)
11825
            value += _addInterpolationPart(v4, bindings[4]);
11826
        if (bindLen > 5)
11827
            value += _addInterpolationPart(v5, bindings[5]);
11828
        if (bindLen > 6)
11829
            value += _addInterpolationPart(v6, bindings[6]);
11830
        if (bindLen > 7)
11831
            value += _addInterpolationPart(v7, bindings[7]);
11832
        if (bindLen > 8)
11833
            value += _addInterpolationPart(v8, bindings[8]);
11834
        if (bindLen > 9)
11835
            value += _addInterpolationPart(v9, bindings[9]);
11836
        var /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
11837
        view.renderer.setValue(renderNode$$1, value);
11838
    }
11839
    return changed;
11840
}
11841
/**
11842
 * @param {?} view
11843
 * @param {?} def
11844
 * @param {?} values
11845
 * @return {?}
11846
 */
11847
function checkAndUpdateTextDynamic(view, def, values) {
11848
    var /** @type {?} */ bindings = def.bindings;
11849
    var /** @type {?} */ changed = false;
11850
    for (var /** @type {?} */ i = 0; i < values.length; i++) {
11851
        // Note: We need to loop over all values, so that
11852
        // the old values are updates as well!
11853
        if (checkAndUpdateBinding(view, def, i, values[i])) {
11854
            changed = true;
11855
        }
11856
    }
11857
    if (changed) {
11858
        var /** @type {?} */ value = '';
11859
        for (var /** @type {?} */ i = 0; i < values.length; i++) {
11860
            value = value + _addInterpolationPart(values[i], bindings[i]);
11861
        }
11862
        value = ((def.text)).prefix + value;
11863
        var /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
11864
        view.renderer.setValue(renderNode$$1, value);
11865
    }
11866
    return changed;
11867
}
11868
/**
11869
 * @param {?} value
11870
 * @param {?} binding
11871
 * @return {?}
11872
 */
11873
function _addInterpolationPart(value, binding) {
11874
    var /** @type {?} */ valueStr = value != null ? value.toString() : '';
11875
    return valueStr + binding.suffix;
11876
}
11877
/**
11878
 * @license
11879
 * Copyright Google Inc. All Rights Reserved.
11880
 *
11881
 * Use of this source code is governed by an MIT-style license that can be
11882
 * found in the LICENSE file at https://angular.io/license
11883
 */
11884
/**
11885
 * @param {?} flags
11886
 * @param {?} nodes
11887
 * @param {?=} updateDirectives
11888
 * @param {?=} updateRenderer
11889
 * @return {?}
11890
 */
11891
function viewDef(flags, nodes, updateDirectives, updateRenderer) {
11892
    // clone nodes and set auto calculated values
11893
    var /** @type {?} */ viewBindingCount = 0;
11894
    var /** @type {?} */ viewDisposableCount = 0;
11895
    var /** @type {?} */ viewNodeFlags = 0;
11896
    var /** @type {?} */ viewRootNodeFlags = 0;
11897
    var /** @type {?} */ viewMatchedQueries = 0;
11898
    var /** @type {?} */ currentParent = null;
11899
    var /** @type {?} */ currentRenderParent = null;
11900
    var /** @type {?} */ currentElementHasPublicProviders = false;
11901
    var /** @type {?} */ currentElementHasPrivateProviders = false;
11902
    var /** @type {?} */ lastRenderRootNode = null;
11903
    for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
11904
        var /** @type {?} */ node = nodes[i];
11905
        node.nodeIndex = i;
11906
        node.parent = currentParent;
11907
        node.bindingIndex = viewBindingCount;
11908
        node.outputIndex = viewDisposableCount;
11909
        node.renderParent = currentRenderParent;
11910
        viewNodeFlags |= node.flags;
11911
        viewMatchedQueries |= node.matchedQueryIds;
11912
        if (node.element) {
11913
            var /** @type {?} */ elDef = node.element;
11914
            elDef.publicProviders =
11915
                currentParent ? ((currentParent.element)).publicProviders : Object.create(null);
11916
            elDef.allProviders = elDef.publicProviders;
11917
            // Note: We assume that all providers of an element are before any child element!
11918
            currentElementHasPublicProviders = false;
11919
            currentElementHasPrivateProviders = false;
11920
            if (node.element.template) {
11921
                viewMatchedQueries |= node.element.template.nodeMatchedQueries;
11922
            }
11923
        }
11924
        validateNode(currentParent, node, nodes.length);
11925
        viewBindingCount += node.bindings.length;
11926
        viewDisposableCount += node.outputs.length;
11927
        if (!currentRenderParent && (node.flags & 3 /* CatRenderNode */)) {
11928
            lastRenderRootNode = node;
11929
        }
11930
        if (node.flags & 20224 /* CatProvider */) {
11931
            if (!currentElementHasPublicProviders) {
11932
                currentElementHasPublicProviders = true; /** @type {?} */
11933
                ((((
11934
                // Use prototypical inheritance to not get O(n^2) complexity...
11935
                currentParent)).element)).publicProviders =
11936
                    Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders); /** @type {?} */
11937
                ((((currentParent)).element)).allProviders = ((((currentParent)).element)).publicProviders;
11938
            }
11939
            var /** @type {?} */ isPrivateService = (node.flags & 8192 /* PrivateProvider */) !== 0;
11940
            var /** @type {?} */ isComponent = (node.flags & 32768 /* Component */) !== 0;
11941
            if (!isPrivateService || isComponent) {
11942
                ((((((currentParent)).element)).publicProviders))[tokenKey(/** @type {?} */ ((node.provider)).token)] = node;
11943
            }
11944
            else {
11945
                if (!currentElementHasPrivateProviders) {
11946
                    currentElementHasPrivateProviders = true; /** @type {?} */
11947
                    ((((
11948
                    // Use prototypical inheritance to not get O(n^2) complexity...
11949
                    currentParent)).element)).allProviders =
11950
                        Object.create(/** @type {?} */ ((((currentParent)).element)).publicProviders);
11951
                } /** @type {?} */
11952
                ((((((currentParent)).element)).allProviders))[tokenKey(/** @type {?} */ ((node.provider)).token)] = node;
11953
            }
11954
            if (isComponent) {
11955
                ((((currentParent)).element)).componentProvider = node;
11956
            }
11957
        }
11958
        if (currentParent) {
11959
            currentParent.childFlags |= node.flags;
11960
            currentParent.directChildFlags |= node.flags;
11961
            currentParent.childMatchedQueries |= node.matchedQueryIds;
11962
            if (node.element && node.element.template) {
11963
                currentParent.childMatchedQueries |= node.element.template.nodeMatchedQueries;
11964
            }
11965
        }
11966
        else {
11967
            viewRootNodeFlags |= node.flags;
11968
        }
11969
        if (node.childCount > 0) {
11970
            currentParent = node;
11971
            if (!isNgContainer(node)) {
11972
                currentRenderParent = node;
11973
            }
11974
        }
11975
        else {
11976
            // When the current node has no children, check if it is the last children of its parent.
11977
            // When it is, propagate the flags up.
11978
            // The loop is required because an element could be the last transitive children of several
11979
            // elements. We loop to either the root or the highest opened element (= with remaining
11980
            // children)
11981
            while (currentParent && i === currentParent.nodeIndex + currentParent.childCount) {
11982
                var /** @type {?} */ newParent = currentParent.parent;
11983
                if (newParent) {
11984
                    newParent.childFlags |= currentParent.childFlags;
11985
                    newParent.childMatchedQueries |= currentParent.childMatchedQueries;
11986
                }
11987
                currentParent = newParent;
11988
                // We also need to update the render parent & account for ng-container
11989
                if (currentParent && isNgContainer(currentParent)) {
11990
                    currentRenderParent = currentParent.renderParent;
11991
                }
11992
                else {
11993
                    currentRenderParent = currentParent;
11994
                }
11995
            }
11996
        }
11997
    }
11998
    var /** @type {?} */ handleEvent = function (view, nodeIndex, eventName, event) { return ((((nodes[nodeIndex].element)).handleEvent))(view, eventName, event); };
11999
    return {
12000
        // Will be filled later...
12001
        factory: null,
12002
        nodeFlags: viewNodeFlags,
12003
        rootNodeFlags: viewRootNodeFlags,
12004
        nodeMatchedQueries: viewMatchedQueries, flags: flags,
12005
        nodes: nodes,
12006
        updateDirectives: updateDirectives || NOOP,
12007
        updateRenderer: updateRenderer || NOOP, handleEvent: handleEvent,
12008
        bindingCount: viewBindingCount,
12009
        outputCount: viewDisposableCount, lastRenderRootNode: lastRenderRootNode
12010
    };
12011
}
12012
/**
12013
 * @param {?} node
12014
 * @return {?}
12015
 */
12016
function isNgContainer(node) {
12017
    return (node.flags & 1 /* TypeElement */) !== 0 && ((node.element)).name === null;
12018
}
12019
/**
12020
 * @param {?} parent
12021
 * @param {?} node
12022
 * @param {?} nodeCount
12023
 * @return {?}
12024
 */
12025
function validateNode(parent, node, nodeCount) {
12026
    var /** @type {?} */ template = node.element && node.element.template;
12027
    if (template) {
12028
        if (!template.lastRenderRootNode) {
12029
            throw new Error("Illegal State: Embedded templates without nodes are not allowed!");
12030
        }
12031
        if (template.lastRenderRootNode &&
12032
            template.lastRenderRootNode.flags & 16777216 /* EmbeddedViews */) {
12033
            throw new Error("Illegal State: Last root node of a template can't have embedded views, at index " + node.nodeIndex + "!");
12034
        }
12035
    }
12036
    if (node.flags & 20224 /* CatProvider */) {
12037
        var /** @type {?} */ parentFlags = parent ? parent.flags : 0;
12038
        if ((parentFlags & 1 /* TypeElement */) === 0) {
12039
            throw new Error("Illegal State: StaticProvider/Directive nodes need to be children of elements or anchors, at index " + node.nodeIndex + "!");
12040
        }
12041
    }
12042
    if (node.query) {
12043
        if (node.flags & 67108864 /* TypeContentQuery */ &&
12044
            (!parent || (parent.flags & 16384 /* TypeDirective */) === 0)) {
12045
            throw new Error("Illegal State: Content Query nodes need to be children of directives, at index " + node.nodeIndex + "!");
12046
        }
12047
        if (node.flags & 134217728 /* TypeViewQuery */ && parent) {
12048
            throw new Error("Illegal State: View Query nodes have to be top level nodes, at index " + node.nodeIndex + "!");
12049
        }
12050
    }
12051
    if (node.childCount) {
12052
        var /** @type {?} */ parentEnd = parent ? parent.nodeIndex + parent.childCount : nodeCount - 1;
12053
        if (node.nodeIndex <= parentEnd && node.nodeIndex + node.childCount > parentEnd) {
12054
            throw new Error("Illegal State: childCount of node leads outside of parent, at index " + node.nodeIndex + "!");
12055
        }
12056
    }
12057
}
12058
/**
12059
 * @param {?} parent
12060
 * @param {?} anchorDef
12061
 * @param {?} viewDef
12062
 * @param {?=} context
12063
 * @return {?}
12064
 */
12065
function createEmbeddedView(parent, anchorDef$$1, viewDef, context) {
12066
    // embedded views are seen as siblings to the anchor, so we need
12067
    // to get the parent of the anchor and use it as parentIndex.
12068
    var /** @type {?} */ view = createView(parent.root, parent.renderer, parent, anchorDef$$1, viewDef);
12069
    initView(view, parent.component, context);
12070
    createViewNodes(view);
12071
    return view;
12072
}
12073
/**
12074
 * @param {?} root
12075
 * @param {?} def
12076
 * @param {?=} context
12077
 * @return {?}
12078
 */
12079
function createRootView(root, def, context) {
12080
    var /** @type {?} */ view = createView(root, root.renderer, null, null, def);
12081
    initView(view, context, context);
12082
    createViewNodes(view);
12083
    return view;
12084
}
12085
/**
12086
 * @param {?} parentView
12087
 * @param {?} nodeDef
12088
 * @param {?} viewDef
12089
 * @param {?} hostElement
12090
 * @return {?}
12091
 */
12092
function createComponentView(parentView, nodeDef, viewDef, hostElement) {
12093
    var /** @type {?} */ rendererType = ((nodeDef.element)).componentRendererType;
12094
    var /** @type {?} */ compRenderer;
12095
    if (!rendererType) {
12096
        compRenderer = parentView.root.renderer;
12097
    }
12098
    else {
12099
        compRenderer = parentView.root.rendererFactory.createRenderer(hostElement, rendererType);
12100
    }
12101
    return createView(parentView.root, compRenderer, parentView, /** @type {?} */ ((nodeDef.element)).componentProvider, viewDef);
12102
}
12103
/**
12104
 * @param {?} root
12105
 * @param {?} renderer
12106
 * @param {?} parent
12107
 * @param {?} parentNodeDef
12108
 * @param {?} def
12109
 * @return {?}
12110
 */
12111
function createView(root, renderer, parent, parentNodeDef, def) {
12112
    var /** @type {?} */ nodes = new Array(def.nodes.length);
12113
    var /** @type {?} */ disposables = def.outputCount ? new Array(def.outputCount) : null;
12114
    var /** @type {?} */ view = {
12115
        def: def,
12116
        parent: parent,
12117
        viewContainerParent: null, parentNodeDef: parentNodeDef,
12118
        context: null,
12119
        component: null, nodes: nodes,
12120
        state: 13 /* CatInit */, root: root, renderer: renderer,
12121
        oldValues: new Array(def.bindingCount), disposables: disposables
12122
    };
12123
    return view;
12124
}
12125
/**
12126
 * @param {?} view
12127
 * @param {?} component
12128
 * @param {?} context
12129
 * @return {?}
12130
 */
12131
function initView(view, component, context) {
12132
    view.component = component;
12133
    view.context = context;
12134
}
12135
/**
12136
 * @param {?} view
12137
 * @return {?}
12138
 */
12139
function createViewNodes(view) {
12140
    var /** @type {?} */ renderHost;
12141
    if (isComponentView(view)) {
12142
        var /** @type {?} */ hostDef = view.parentNodeDef;
12143
        renderHost = asElementData(/** @type {?} */ ((view.parent)), /** @type {?} */ ((((hostDef)).parent)).nodeIndex).renderElement;
12144
    }
12145
    var /** @type {?} */ def = view.def;
12146
    var /** @type {?} */ nodes = view.nodes;
12147
    for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12148
        var /** @type {?} */ nodeDef = def.nodes[i];
12149
        Services.setCurrentNode(view, i);
12150
        var /** @type {?} */ nodeData = void 0;
12151
        switch (nodeDef.flags & 201347067 /* Types */) {
12152
            case 1 /* TypeElement */:
12153
                var /** @type {?} */ el = (createElement(view, renderHost, nodeDef));
12154
                var /** @type {?} */ componentView = ((undefined));
12155
                if (nodeDef.flags & 33554432 /* ComponentView */) {
12156
                    var /** @type {?} */ compViewDef = resolveDefinition(/** @type {?} */ ((((nodeDef.element)).componentView)));
12157
                    componentView = Services.createComponentView(view, nodeDef, compViewDef, el);
12158
                }
12159
                listenToElementOutputs(view, componentView, nodeDef, el);
12160
                nodeData = ({
12161
                    renderElement: el,
12162
                    componentView: componentView,
12163
                    viewContainer: null,
12164
                    template: /** @type {?} */ ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
12165
                });
12166
                if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
12167
                    nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
12168
                }
12169
                break;
12170
            case 2 /* TypeText */:
12171
                nodeData = (createText(view, renderHost, nodeDef));
12172
                break;
12173
            case 512 /* TypeClassProvider */:
12174
            case 1024 /* TypeFactoryProvider */:
12175
            case 2048 /* TypeUseExistingProvider */:
12176
            case 256 /* TypeValueProvider */: {
12177
                nodeData = nodes[i];
12178
                if (!nodeData && !(nodeDef.flags & 4096 /* LazyProvider */)) {
12179
                    var /** @type {?} */ instance = createProviderInstance(view, nodeDef);
12180
                    nodeData = ({ instance: instance });
12181
                }
12182
                break;
12183
            }
12184
            case 16 /* TypePipe */: {
12185
                var /** @type {?} */ instance = createPipeInstance(view, nodeDef);
12186
                nodeData = ({ instance: instance });
12187
                break;
12188
            }
12189
            case 16384 /* TypeDirective */: {
12190
                nodeData = nodes[i];
12191
                if (!nodeData) {
12192
                    var /** @type {?} */ instance = createDirectiveInstance(view, nodeDef);
12193
                    nodeData = ({ instance: instance });
12194
                }
12195
                if (nodeDef.flags & 32768 /* Component */) {
12196
                    var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).componentView;
12197
                    initView(compView, nodeData.instance, nodeData.instance);
12198
                }
12199
                break;
12200
            }
12201
            case 32 /* TypePureArray */:
12202
            case 64 /* TypePureObject */:
12203
            case 128 /* TypePurePipe */:
12204
                nodeData = (createPureExpression(view, nodeDef));
12205
                break;
12206
            case 67108864 /* TypeContentQuery */:
12207
            case 134217728 /* TypeViewQuery */:
12208
                nodeData = (createQuery());
12209
                break;
12210
            case 8 /* TypeNgContent */:
12211
                appendNgContent(view, renderHost, nodeDef);
12212
                // no runtime data needed for NgContent...
12213
                nodeData = undefined;
12214
                break;
12215
        }
12216
        nodes[i] = nodeData;
12217
    }
12218
    // Create the ViewData.nodes of component views after we created everything else,
12219
    // so that e.g. ng-content works
12220
    execComponentViewsAction(view, ViewAction.CreateViewNodes);
12221
    // fill static content and view queries
12222
    execQueriesAction(view, 67108864 /* TypeContentQuery */ | 134217728 /* TypeViewQuery */, 268435456 /* StaticQuery */, 0 /* CheckAndUpdate */);
12223
}
12224
/**
12225
 * @param {?} view
12226
 * @return {?}
12227
 */
12228
function checkNoChangesView(view) {
12229
    markProjectedViewsForCheck(view);
12230
    Services.updateDirectives(view, 1 /* CheckNoChanges */);
12231
    execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
12232
    Services.updateRenderer(view, 1 /* CheckNoChanges */);
12233
    execComponentViewsAction(view, ViewAction.CheckNoChanges);
12234
    // Note: We don't check queries for changes as we didn't do this in v2.x.
12235
    // TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
12236
    view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
12237
}
12238
/**
12239
 * @param {?} view
12240
 * @return {?}
12241
 */
12242
function checkAndUpdateView(view) {
12243
    if (view.state & 1 /* BeforeFirstCheck */) {
12244
        view.state &= ~1 /* BeforeFirstCheck */;
12245
        view.state |= 2 /* FirstCheck */;
12246
    }
12247
    else {
12248
        view.state &= ~2 /* FirstCheck */;
12249
    }
12250
    markProjectedViewsForCheck(view);
12251
    Services.updateDirectives(view, 0 /* CheckAndUpdate */);
12252
    execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
12253
    execQueriesAction(view, 67108864 /* TypeContentQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
12254
    callLifecycleHooksChildrenFirst(view, 2097152 /* AfterContentChecked */ |
12255
        (view.state & 2 /* FirstCheck */ ? 1048576 /* AfterContentInit */ : 0));
12256
    Services.updateRenderer(view, 0 /* CheckAndUpdate */);
12257
    execComponentViewsAction(view, ViewAction.CheckAndUpdate);
12258
    execQueriesAction(view, 134217728 /* TypeViewQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
12259
    callLifecycleHooksChildrenFirst(view, 8388608 /* AfterViewChecked */ |
12260
        (view.state & 2 /* FirstCheck */ ? 4194304 /* AfterViewInit */ : 0));
12261
    if (view.def.flags & 2 /* OnPush */) {
12262
        view.state &= ~8 /* ChecksEnabled */;
12263
    }
12264
    view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
12265
}
12266
/**
12267
 * @param {?} view
12268
 * @param {?} nodeDef
12269
 * @param {?} argStyle
12270
 * @param {?=} v0
12271
 * @param {?=} v1
12272
 * @param {?=} v2
12273
 * @param {?=} v3
12274
 * @param {?=} v4
12275
 * @param {?=} v5
12276
 * @param {?=} v6
12277
 * @param {?=} v7
12278
 * @param {?=} v8
12279
 * @param {?=} v9
12280
 * @return {?}
12281
 */
12282
function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12283
    if (argStyle === 0 /* Inline */) {
12284
        return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12285
    }
12286
    else {
12287
        return checkAndUpdateNodeDynamic(view, nodeDef, v0);
12288
    }
12289
}
12290
/**
12291
 * @param {?} view
12292
 * @return {?}
12293
 */
12294
function markProjectedViewsForCheck(view) {
12295
    var /** @type {?} */ def = view.def;
12296
    if (!(def.nodeFlags & 4 /* ProjectedTemplate */)) {
12297
        return;
12298
    }
12299
    for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12300
        var /** @type {?} */ nodeDef = def.nodes[i];
12301
        if (nodeDef.flags & 4 /* ProjectedTemplate */) {
12302
            var /** @type {?} */ projectedViews = asElementData(view, i).template._projectedViews;
12303
            if (projectedViews) {
12304
                for (var /** @type {?} */ i_1 = 0; i_1 < projectedViews.length; i_1++) {
12305
                    var /** @type {?} */ projectedView = projectedViews[i_1];
12306
                    projectedView.state |= 32 /* CheckProjectedView */;
12307
                    markParentViewsForCheckProjectedViews(projectedView, view);
12308
                }
12309
            }
12310
        }
12311
        else if ((nodeDef.childFlags & 4 /* ProjectedTemplate */) === 0) {
12312
            // a parent with leafs
12313
            // no child is a component,
12314
            // then skip the children
12315
            i += nodeDef.childCount;
12316
        }
12317
    }
12318
}
12319
/**
12320
 * @param {?} view
12321
 * @param {?} nodeDef
12322
 * @param {?=} v0
12323
 * @param {?=} v1
12324
 * @param {?=} v2
12325
 * @param {?=} v3
12326
 * @param {?=} v4
12327
 * @param {?=} v5
12328
 * @param {?=} v6
12329
 * @param {?=} v7
12330
 * @param {?=} v8
12331
 * @param {?=} v9
12332
 * @return {?}
12333
 */
12334
function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12335
    switch (nodeDef.flags & 201347067 /* Types */) {
12336
        case 1 /* TypeElement */:
12337
            return checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12338
        case 2 /* TypeText */:
12339
            return checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12340
        case 16384 /* TypeDirective */:
12341
            return checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12342
        case 32 /* TypePureArray */:
12343
        case 64 /* TypePureObject */:
12344
        case 128 /* TypePurePipe */:
12345
            return checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12346
        default:
12347
            throw 'unreachable';
12348
    }
12349
}
12350
/**
12351
 * @param {?} view
12352
 * @param {?} nodeDef
12353
 * @param {?} values
12354
 * @return {?}
12355
 */
12356
function checkAndUpdateNodeDynamic(view, nodeDef, values) {
12357
    switch (nodeDef.flags & 201347067 /* Types */) {
12358
        case 1 /* TypeElement */:
12359
            return checkAndUpdateElementDynamic(view, nodeDef, values);
12360
        case 2 /* TypeText */:
12361
            return checkAndUpdateTextDynamic(view, nodeDef, values);
12362
        case 16384 /* TypeDirective */:
12363
            return checkAndUpdateDirectiveDynamic(view, nodeDef, values);
12364
        case 32 /* TypePureArray */:
12365
        case 64 /* TypePureObject */:
12366
        case 128 /* TypePurePipe */:
12367
            return checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
12368
        default:
12369
            throw 'unreachable';
12370
    }
12371
}
12372
/**
12373
 * @param {?} view
12374
 * @param {?} nodeDef
12375
 * @param {?} argStyle
12376
 * @param {?=} v0
12377
 * @param {?=} v1
12378
 * @param {?=} v2
12379
 * @param {?=} v3
12380
 * @param {?=} v4
12381
 * @param {?=} v5
12382
 * @param {?=} v6
12383
 * @param {?=} v7
12384
 * @param {?=} v8
12385
 * @param {?=} v9
12386
 * @return {?}
12387
 */
12388
function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12389
    if (argStyle === 0 /* Inline */) {
12390
        checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12391
    }
12392
    else {
12393
        checkNoChangesNodeDynamic(view, nodeDef, v0);
12394
    }
12395
    // Returning false is ok here as we would have thrown in case of a change.
12396
    return false;
12397
}
12398
/**
12399
 * @param {?} view
12400
 * @param {?} nodeDef
12401
 * @param {?} v0
12402
 * @param {?} v1
12403
 * @param {?} v2
12404
 * @param {?} v3
12405
 * @param {?} v4
12406
 * @param {?} v5
12407
 * @param {?} v6
12408
 * @param {?} v7
12409
 * @param {?} v8
12410
 * @param {?} v9
12411
 * @return {?}
12412
 */
12413
function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12414
    var /** @type {?} */ bindLen = nodeDef.bindings.length;
12415
    if (bindLen > 0)
12416
        checkBindingNoChanges(view, nodeDef, 0, v0);
12417
    if (bindLen > 1)
12418
        checkBindingNoChanges(view, nodeDef, 1, v1);
12419
    if (bindLen > 2)
12420
        checkBindingNoChanges(view, nodeDef, 2, v2);
12421
    if (bindLen > 3)
12422
        checkBindingNoChanges(view, nodeDef, 3, v3);
12423
    if (bindLen > 4)
12424
        checkBindingNoChanges(view, nodeDef, 4, v4);
12425
    if (bindLen > 5)
12426
        checkBindingNoChanges(view, nodeDef, 5, v5);
12427
    if (bindLen > 6)
12428
        checkBindingNoChanges(view, nodeDef, 6, v6);
12429
    if (bindLen > 7)
12430
        checkBindingNoChanges(view, nodeDef, 7, v7);
12431
    if (bindLen > 8)
12432
        checkBindingNoChanges(view, nodeDef, 8, v8);
12433
    if (bindLen > 9)
12434
        checkBindingNoChanges(view, nodeDef, 9, v9);
12435
}
12436
/**
12437
 * @param {?} view
12438
 * @param {?} nodeDef
12439
 * @param {?} values
12440
 * @return {?}
12441
 */
12442
function checkNoChangesNodeDynamic(view, nodeDef, values) {
12443
    for (var /** @type {?} */ i = 0; i < values.length; i++) {
12444
        checkBindingNoChanges(view, nodeDef, i, values[i]);
12445
    }
12446
}
12447
/**
12448
 * Workaround https://github.com/angular/tsickle/issues/497
12449
 * @suppress {misplacedTypeAnnotation}
12450
 * @param {?} view
12451
 * @param {?} nodeDef
12452
 * @return {?}
12453
 */
12454
function checkNoChangesQuery(view, nodeDef) {
12455
    var /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
12456
    if (queryList.dirty) {
12457
        throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.nodeIndex), "Query " + ((nodeDef.query)).id + " not dirty", "Query " + ((nodeDef.query)).id + " dirty", (view.state & 1 /* BeforeFirstCheck */) !== 0);
12458
    }
12459
}
12460
/**
12461
 * @param {?} view
12462
 * @return {?}
12463
 */
12464
function destroyView(view) {
12465
    if (view.state & 128 /* Destroyed */) {
12466
        return;
12467
    }
12468
    execEmbeddedViewsAction(view, ViewAction.Destroy);
12469
    execComponentViewsAction(view, ViewAction.Destroy);
12470
    callLifecycleHooksChildrenFirst(view, 131072 /* OnDestroy */);
12471
    if (view.disposables) {
12472
        for (var /** @type {?} */ i = 0; i < view.disposables.length; i++) {
12473
            view.disposables[i]();
12474
        }
12475
    }
12476
    detachProjectedView(view);
12477
    if (view.renderer.destroyNode) {
12478
        destroyViewNodes(view);
12479
    }
12480
    if (isComponentView(view)) {
12481
        view.renderer.destroy();
12482
    }
12483
    view.state |= 128 /* Destroyed */;
12484
}
12485
/**
12486
 * @param {?} view
12487
 * @return {?}
12488
 */
12489
function destroyViewNodes(view) {
12490
    var /** @type {?} */ len = view.def.nodes.length;
12491
    for (var /** @type {?} */ i = 0; i < len; i++) {
12492
        var /** @type {?} */ def = view.def.nodes[i];
12493
        if (def.flags & 1 /* TypeElement */) {
12494
            ((view.renderer.destroyNode))(asElementData(view, i).renderElement);
12495
        }
12496
        else if (def.flags & 2 /* TypeText */) {
12497
            ((view.renderer.destroyNode))(asTextData(view, i).renderText);
12498
        }
12499
        else if (def.flags & 67108864 /* TypeContentQuery */ || def.flags & 134217728 /* TypeViewQuery */) {
12500
            asQueryList(view, i).destroy();
12501
        }
12502
    }
12503
}
12504
var ViewAction = {};
12505
ViewAction.CreateViewNodes = 0;
12506
ViewAction.CheckNoChanges = 1;
12507
ViewAction.CheckNoChangesProjectedViews = 2;
12508
ViewAction.CheckAndUpdate = 3;
12509
ViewAction.CheckAndUpdateProjectedViews = 4;
12510
ViewAction.Destroy = 5;
12511
ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
12512
ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
12513
ViewAction[ViewAction.CheckNoChangesProjectedViews] = "CheckNoChangesProjectedViews";
12514
ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
12515
ViewAction[ViewAction.CheckAndUpdateProjectedViews] = "CheckAndUpdateProjectedViews";
12516
ViewAction[ViewAction.Destroy] = "Destroy";
12517
/**
12518
 * @param {?} view
12519
 * @param {?} action
12520
 * @return {?}
12521
 */
12522
function execComponentViewsAction(view, action) {
12523
    var /** @type {?} */ def = view.def;
12524
    if (!(def.nodeFlags & 33554432 /* ComponentView */)) {
12525
        return;
12526
    }
12527
    for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12528
        var /** @type {?} */ nodeDef = def.nodes[i];
12529
        if (nodeDef.flags & 33554432 /* ComponentView */) {
12530
            // a leaf
12531
            callViewAction(asElementData(view, i).componentView, action);
12532
        }
12533
        else if ((nodeDef.childFlags & 33554432 /* ComponentView */) === 0) {
12534
            // a parent with leafs
12535
            // no child is a component,
12536
            // then skip the children
12537
            i += nodeDef.childCount;
12538
        }
12539
    }
12540
}
12541
/**
12542
 * @param {?} view
12543
 * @param {?} action
12544
 * @return {?}
12545
 */
12546
function execEmbeddedViewsAction(view, action) {
12547
    var /** @type {?} */ def = view.def;
12548
    if (!(def.nodeFlags & 16777216 /* EmbeddedViews */)) {
12549
        return;
12550
    }
12551
    for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12552
        var /** @type {?} */ nodeDef = def.nodes[i];
12553
        if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
12554
            // a leaf
12555
            var /** @type {?} */ embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
12556
            for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
12557
                callViewAction(embeddedViews[k], action);
12558
            }
12559
        }
12560
        else if ((nodeDef.childFlags & 16777216 /* EmbeddedViews */) === 0) {
12561
            // a parent with leafs
12562
            // no child is a component,
12563
            // then skip the children
12564
            i += nodeDef.childCount;
12565
        }
12566
    }
12567
}
12568
/**
12569
 * @param {?} view
12570
 * @param {?} action
12571
 * @return {?}
12572
 */
12573
function callViewAction(view, action) {
12574
    var /** @type {?} */ viewState = view.state;
12575
    switch (action) {
12576
        case ViewAction.CheckNoChanges:
12577
            if ((viewState & 128 /* Destroyed */) === 0) {
12578
                if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
12579
                    checkNoChangesView(view);
12580
                }
12581
                else if (viewState & 64 /* CheckProjectedViews */) {
12582
                    execProjectedViewsAction(view, ViewAction.CheckNoChangesProjectedViews);
12583
                }
12584
            }
12585
            break;
12586
        case ViewAction.CheckNoChangesProjectedViews:
12587
            if ((viewState & 128 /* Destroyed */) === 0) {
12588
                if (viewState & 32 /* CheckProjectedView */) {
12589
                    checkNoChangesView(view);
12590
                }
12591
                else if (viewState & 64 /* CheckProjectedViews */) {
12592
                    execProjectedViewsAction(view, action);
12593
                }
12594
            }
12595
            break;
12596
        case ViewAction.CheckAndUpdate:
12597
            if ((viewState & 128 /* Destroyed */) === 0) {
12598
                if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
12599
                    checkAndUpdateView(view);
12600
                }
12601
                else if (viewState & 64 /* CheckProjectedViews */) {
12602
                    execProjectedViewsAction(view, ViewAction.CheckAndUpdateProjectedViews);
12603
                }
12604
            }
12605
            break;
12606
        case ViewAction.CheckAndUpdateProjectedViews:
12607
            if ((viewState & 128 /* Destroyed */) === 0) {
12608
                if (viewState & 32 /* CheckProjectedView */) {
12609
                    checkAndUpdateView(view);
12610
                }
12611
                else if (viewState & 64 /* CheckProjectedViews */) {
12612
                    execProjectedViewsAction(view, action);
12613
                }
12614
            }
12615
            break;
12616
        case ViewAction.Destroy:
12617
            // Note: destroyView recurses over all views,
12618
            // so we don't need to special case projected views here.
12619
            destroyView(view);
12620
            break;
12621
        case ViewAction.CreateViewNodes:
12622
            createViewNodes(view);
12623
            break;
12624
    }
12625
}
12626
/**
12627
 * @param {?} view
12628
 * @param {?} action
12629
 * @return {?}
12630
 */
12631
function execProjectedViewsAction(view, action) {
12632
    execEmbeddedViewsAction(view, action);
12633
    execComponentViewsAction(view, action);
12634
}
12635
/**
12636
 * @param {?} view
12637
 * @param {?} queryFlags
12638
 * @param {?} staticDynamicQueryFlag
12639
 * @param {?} checkType
12640
 * @return {?}
12641
 */
12642
function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
12643
    if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
12644
        return;
12645
    }
12646
    var /** @type {?} */ nodeCount = view.def.nodes.length;
12647
    for (var /** @type {?} */ i = 0; i < nodeCount; i++) {
12648
        var /** @type {?} */ nodeDef = view.def.nodes[i];
12649
        if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
12650
            Services.setCurrentNode(view, nodeDef.nodeIndex);
12651
            switch (checkType) {
12652
                case 0 /* CheckAndUpdate */:
12653
                    checkAndUpdateQuery(view, nodeDef);
12654
                    break;
12655
                case 1 /* CheckNoChanges */:
12656
                    checkNoChangesQuery(view, nodeDef);
12657
                    break;
12658
            }
12659
        }
12660
        if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
12661
            // no child has a matching query
12662
            // then skip the children
12663
            i += nodeDef.childCount;
12664
        }
12665
    }
12666
}
12667
/**
12668
 * @license
12669
 * Copyright Google Inc. All Rights Reserved.
12670
 *
12671
 * Use of this source code is governed by an MIT-style license that can be
12672
 * found in the LICENSE file at https://angular.io/license
12673
 */
12674
var initialized = false;
12675
/**
12676
 * @return {?}
12677
 */
12678
function initServicesIfNeeded() {
12679
    if (initialized) {
12680
        return;
12681
    }
12682
    initialized = true;
12683
    var /** @type {?} */ services = isDevMode() ? createDebugServices() : createProdServices();
12684
    Services.setCurrentNode = services.setCurrentNode;
12685
    Services.createRootView = services.createRootView;
12686
    Services.createEmbeddedView = services.createEmbeddedView;
12687
    Services.createComponentView = services.createComponentView;
12688
    Services.createNgModuleRef = services.createNgModuleRef;
12689
    Services.overrideProvider = services.overrideProvider;
12690
    Services.clearProviderOverrides = services.clearProviderOverrides;
12691
    Services.checkAndUpdateView = services.checkAndUpdateView;
12692
    Services.checkNoChangesView = services.checkNoChangesView;
12693
    Services.destroyView = services.destroyView;
12694
    Services.resolveDep = resolveDep;
12695
    Services.createDebugContext = services.createDebugContext;
12696
    Services.handleEvent = services.handleEvent;
12697
    Services.updateDirectives = services.updateDirectives;
12698
    Services.updateRenderer = services.updateRenderer;
12699
    Services.dirtyParentQueries = dirtyParentQueries;
12700
}
12701
/**
12702
 * @return {?}
12703
 */
12704
function createProdServices() {
12705
    return {
12706
        setCurrentNode: function () { },
12707
        createRootView: createProdRootView,
12708
        createEmbeddedView: createEmbeddedView,
12709
        createComponentView: createComponentView,
12710
        createNgModuleRef: createNgModuleRef,
12711
        overrideProvider: NOOP,
12712
        clearProviderOverrides: NOOP,
12713
        checkAndUpdateView: checkAndUpdateView,
12714
        checkNoChangesView: checkNoChangesView,
12715
        destroyView: destroyView,
12716
        createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
12717
        handleEvent: function (view, nodeIndex, eventName, event) { return view.def.handleEvent(view, nodeIndex, eventName, event); },
12718
        updateDirectives: function (view, checkType) { return view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12719
            prodCheckNoChangesNode, view); },
12720
        updateRenderer: function (view, checkType) { return view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
12721
            prodCheckNoChangesNode, view); },
12722
    };
12723
}
12724
/**
12725
 * @return {?}
12726
 */
12727
function createDebugServices() {
12728
    return {
12729
        setCurrentNode: debugSetCurrentNode,
12730
        createRootView: debugCreateRootView,
12731
        createEmbeddedView: debugCreateEmbeddedView,
12732
        createComponentView: debugCreateComponentView,
12733
        createNgModuleRef: debugCreateNgModuleRef,
12734
        overrideProvider: debugOverrideProvider,
12735
        clearProviderOverrides: debugClearProviderOverrides,
12736
        checkAndUpdateView: debugCheckAndUpdateView,
12737
        checkNoChangesView: debugCheckNoChangesView,
12738
        destroyView: debugDestroyView,
12739
        createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
12740
        handleEvent: debugHandleEvent,
12741
        updateDirectives: debugUpdateDirectives,
12742
        updateRenderer: debugUpdateRenderer,
12743
    };
12744
}
12745
/**
12746
 * @param {?} elInjector
12747
 * @param {?} projectableNodes
12748
 * @param {?} rootSelectorOrNode
12749
 * @param {?} def
12750
 * @param {?} ngModule
12751
 * @param {?=} context
12752
 * @return {?}
12753
 */
12754
function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12755
    var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12756
    return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
12757
}
12758
/**
12759
 * @param {?} elInjector
12760
 * @param {?} projectableNodes
12761
 * @param {?} rootSelectorOrNode
12762
 * @param {?} def
12763
 * @param {?} ngModule
12764
 * @param {?=} context
12765
 * @return {?}
12766
 */
12767
function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
12768
    var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
12769
    var /** @type {?} */ root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
12770
    var /** @type {?} */ defWithOverride = applyProviderOverridesToView(def);
12771
    return callWithDebugContext(DebugAction.create, createRootView, null, [root, defWithOverride, context]);
12772
}
12773
/**
12774
 * @param {?} elInjector
12775
 * @param {?} ngModule
12776
 * @param {?} rendererFactory
12777
 * @param {?} projectableNodes
12778
 * @param {?} rootSelectorOrNode
12779
 * @return {?}
12780
 */
12781
function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
12782
    var /** @type {?} */ sanitizer = ngModule.injector.get(Sanitizer);
12783
    var /** @type {?} */ errorHandler = ngModule.injector.get(ErrorHandler);
12784
    var /** @type {?} */ renderer = rendererFactory.createRenderer(null, null);
12785
    return {
12786
        ngModule: ngModule,
12787
        injector: elInjector, projectableNodes: projectableNodes,
12788
        selectorOrNode: rootSelectorOrNode, sanitizer: sanitizer, rendererFactory: rendererFactory, renderer: renderer, errorHandler: errorHandler
12789
    };
12790
}
12791
/**
12792
 * @param {?} parentView
12793
 * @param {?} anchorDef
12794
 * @param {?} viewDef
12795
 * @param {?=} context
12796
 * @return {?}
12797
 */
12798
function debugCreateEmbeddedView(parentView, anchorDef, viewDef$$1, context) {
12799
    var /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
12800
    return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parentView, anchorDef, defWithOverride, context]);
12801
}
12802
/**
12803
 * @param {?} parentView
12804
 * @param {?} nodeDef
12805
 * @param {?} viewDef
12806
 * @param {?} hostElement
12807
 * @return {?}
12808
 */
12809
function debugCreateComponentView(parentView, nodeDef, viewDef$$1, hostElement) {
12810
    var /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
12811
    return callWithDebugContext(DebugAction.create, createComponentView, null, [parentView, nodeDef, defWithOverride, hostElement]);
12812
}
12813
/**
12814
 * @param {?} moduleType
12815
 * @param {?} parentInjector
12816
 * @param {?} bootstrapComponents
12817
 * @param {?} def
12818
 * @return {?}
12819
 */
12820
function debugCreateNgModuleRef(moduleType, parentInjector, bootstrapComponents, def) {
12821
    var /** @type {?} */ defWithOverride = applyProviderOverridesToNgModule(def);
12822
    return createNgModuleRef(moduleType, parentInjector, bootstrapComponents, defWithOverride);
12823
}
12824
var providerOverrides = new Map();
12825
/**
12826
 * @param {?} override
12827
 * @return {?}
12828
 */
12829
function debugOverrideProvider(override) {
12830
    providerOverrides.set(override.token, override);
12831
}
12832
/**
12833
 * @return {?}
12834
 */
12835
function debugClearProviderOverrides() {
12836
    providerOverrides.clear();
12837
}
12838
/**
12839
 * @param {?} def
12840
 * @return {?}
12841
 */
12842
function applyProviderOverridesToView(def) {
12843
    if (providerOverrides.size === 0) {
12844
        return def;
12845
    }
12846
    var /** @type {?} */ elementIndicesWithOverwrittenProviders = findElementIndicesWithOverwrittenProviders(def);
12847
    if (elementIndicesWithOverwrittenProviders.length === 0) {
12848
        return def;
12849
    }
12850
    // clone the whole view definition,
12851
    // as it maintains references between the nodes that are hard to update.
12852
    def = ((def.factory))(function () { return NOOP; });
12853
    for (var /** @type {?} */ i = 0; i < elementIndicesWithOverwrittenProviders.length; i++) {
12854
        applyProviderOverridesToElement(def, elementIndicesWithOverwrittenProviders[i]);
12855
    }
12856
    return def;
12857
    /**
12858
     * @param {?} def
12859
     * @return {?}
12860
     */
12861
    function findElementIndicesWithOverwrittenProviders(def) {
12862
        var /** @type {?} */ elIndicesWithOverwrittenProviders = [];
12863
        var /** @type {?} */ lastElementDef = null;
12864
        for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
12865
            var /** @type {?} */ nodeDef = def.nodes[i];
12866
            if (nodeDef.flags & 1 /* TypeElement */) {
12867
                lastElementDef = nodeDef;
12868
            }
12869
            if (lastElementDef && nodeDef.flags & 3840 /* CatProviderNoDirective */ &&
12870
                providerOverrides.has(/** @type {?} */ ((nodeDef.provider)).token)) {
12871
                elIndicesWithOverwrittenProviders.push(/** @type {?} */ ((lastElementDef)).nodeIndex);
12872
                lastElementDef = null;
12873
            }
12874
        }
12875
        return elIndicesWithOverwrittenProviders;
12876
    }
12877
    /**
12878
     * @param {?} viewDef
12879
     * @param {?} elIndex
12880
     * @return {?}
12881
     */
12882
    function applyProviderOverridesToElement(viewDef$$1, elIndex) {
12883
        for (var /** @type {?} */ i = elIndex + 1; i < viewDef$$1.nodes.length; i++) {
12884
            var /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
12885
            if (nodeDef.flags & 1 /* TypeElement */) {
12886
                // stop at the next element
12887
                return;
12888
            }
12889
            if (nodeDef.flags & 3840 /* CatProviderNoDirective */) {
12890
                var /** @type {?} */ provider = ((nodeDef.provider));
12891
                var /** @type {?} */ override = providerOverrides.get(provider.token);
12892
                if (override) {
12893
                    nodeDef.flags = (nodeDef.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
12894
                    provider.deps = splitDepsDsl(override.deps);
12895
                    provider.value = override.value;
12896
                }
12897
            }
12898
        }
12899
    }
12900
}
12901
/**
12902
 * @param {?} def
12903
 * @return {?}
12904
 */
12905
function applyProviderOverridesToNgModule(def) {
12906
    var _a = calcHasOverrides(def), hasOverrides = _a.hasOverrides, hasDeprecatedOverrides = _a.hasDeprecatedOverrides;
12907
    if (!hasOverrides) {
12908
        return def;
12909
    }
12910
    // clone the whole view definition,
12911
    // as it maintains references between the nodes that are hard to update.
12912
    def = ((def.factory))(function () { return NOOP; });
12913
    applyProviderOverrides(def);
12914
    return def;
12915
    /**
12916
     * @param {?} def
12917
     * @return {?}
12918
     */
12919
    function calcHasOverrides(def) {
12920
        var /** @type {?} */ hasOverrides = false;
12921
        var /** @type {?} */ hasDeprecatedOverrides = false;
12922
        if (providerOverrides.size === 0) {
12923
            return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
12924
        }
12925
        def.providers.forEach(function (node) {
12926
            var /** @type {?} */ override = providerOverrides.get(node.token);
12927
            if ((node.flags & 3840 /* CatProviderNoDirective */) && override) {
12928
                hasOverrides = true;
12929
                hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
12930
            }
12931
        });
12932
        return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
12933
    }
12934
    /**
12935
     * @param {?} def
12936
     * @return {?}
12937
     */
12938
    function applyProviderOverrides(def) {
12939
        for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
12940
            var /** @type {?} */ provider = def.providers[i];
12941
            if (hasDeprecatedOverrides) {
12942
                // We had a bug where me made
12943
                // all providers lazy. Keep this logic behind a flag
12944
                // for migrating existing users.
12945
                provider.flags |= 4096 /* LazyProvider */;
12946
            }
12947
            var /** @type {?} */ override = providerOverrides.get(provider.token);
12948
            if (override) {
12949
                provider.flags = (provider.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
12950
                provider.deps = splitDepsDsl(override.deps);
12951
                provider.value = override.value;
12952
            }
12953
        }
12954
    }
12955
}
12956
/**
12957
 * @param {?} view
12958
 * @param {?} checkIndex
12959
 * @param {?} argStyle
12960
 * @param {?=} v0
12961
 * @param {?=} v1
12962
 * @param {?=} v2
12963
 * @param {?=} v3
12964
 * @param {?=} v4
12965
 * @param {?=} v5
12966
 * @param {?=} v6
12967
 * @param {?=} v7
12968
 * @param {?=} v8
12969
 * @param {?=} v9
12970
 * @return {?}
12971
 */
12972
function prodCheckAndUpdateNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12973
    var /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
12974
    checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12975
    return (nodeDef.flags & 224 /* CatPureExpression */) ?
12976
        asPureExpressionData(view, checkIndex).value :
12977
        undefined;
12978
}
12979
/**
12980
 * @param {?} view
12981
 * @param {?} checkIndex
12982
 * @param {?} argStyle
12983
 * @param {?=} v0
12984
 * @param {?=} v1
12985
 * @param {?=} v2
12986
 * @param {?=} v3
12987
 * @param {?=} v4
12988
 * @param {?=} v5
12989
 * @param {?=} v6
12990
 * @param {?=} v7
12991
 * @param {?=} v8
12992
 * @param {?=} v9
12993
 * @return {?}
12994
 */
12995
function prodCheckNoChangesNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
12996
    var /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
12997
    checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
12998
    return (nodeDef.flags & 224 /* CatPureExpression */) ?
12999
        asPureExpressionData(view, checkIndex).value :
13000
        undefined;
13001
}
13002
/**
13003
 * @param {?} view
13004
 * @return {?}
13005
 */
13006
function debugCheckAndUpdateView(view) {
13007
    return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
13008
}
13009
/**
13010
 * @param {?} view
13011
 * @return {?}
13012
 */
13013
function debugCheckNoChangesView(view) {
13014
    return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
13015
}
13016
/**
13017
 * @param {?} view
13018
 * @return {?}
13019
 */
13020
function debugDestroyView(view) {
13021
    return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
13022
}
13023
var DebugAction = {};
13024
DebugAction.create = 0;
13025
DebugAction.detectChanges = 1;
13026
DebugAction.checkNoChanges = 2;
13027
DebugAction.destroy = 3;
13028
DebugAction.handleEvent = 4;
13029
DebugAction[DebugAction.create] = "create";
13030
DebugAction[DebugAction.detectChanges] = "detectChanges";
13031
DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
13032
DebugAction[DebugAction.destroy] = "destroy";
13033
DebugAction[DebugAction.handleEvent] = "handleEvent";
13034
var _currentAction;
13035
var _currentView;
13036
var _currentNodeIndex;
13037
/**
13038
 * @param {?} view
13039
 * @param {?} nodeIndex
13040
 * @return {?}
13041
 */
13042
function debugSetCurrentNode(view, nodeIndex) {
13043
    _currentView = view;
13044
    _currentNodeIndex = nodeIndex;
13045
}
13046
/**
13047
 * @param {?} view
13048
 * @param {?} nodeIndex
13049
 * @param {?} eventName
13050
 * @param {?} event
13051
 * @return {?}
13052
 */
13053
function debugHandleEvent(view, nodeIndex, eventName, event) {
13054
    debugSetCurrentNode(view, nodeIndex);
13055
    return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
13056
}
13057
/**
13058
 * @param {?} view
13059
 * @param {?} checkType
13060
 * @return {?}
13061
 */
13062
function debugUpdateDirectives(view, checkType) {
13063
    if (view.state & 128 /* Destroyed */) {
13064
        throw viewDestroyedError(DebugAction[_currentAction]);
13065
    }
13066
    debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
13067
    return view.def.updateDirectives(debugCheckDirectivesFn, view);
13068
    /**
13069
     * @param {?} view
13070
     * @param {?} nodeIndex
13071
     * @param {?} argStyle
13072
     * @param {...?} values
13073
     * @return {?}
13074
     */
13075
    function debugCheckDirectivesFn(view, nodeIndex, argStyle) {
13076
        var values = [];
13077
        for (var _i = 3; _i < arguments.length; _i++) {
13078
            values[_i - 3] = arguments[_i];
13079
        }
13080
        var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
13081
        if (checkType === 0 /* CheckAndUpdate */) {
13082
            debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
13083
        }
13084
        else {
13085
            debugCheckNoChangesNode(view, nodeDef, argStyle, values);
13086
        }
13087
        if (nodeDef.flags & 16384 /* TypeDirective */) {
13088
            debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
13089
        }
13090
        return (nodeDef.flags & 224 /* CatPureExpression */) ?
13091
            asPureExpressionData(view, nodeDef.nodeIndex).value :
13092
            undefined;
13093
    }
13094
}
13095
/**
13096
 * @param {?} view
13097
 * @param {?} checkType
13098
 * @return {?}
13099
 */
13100
function debugUpdateRenderer(view, checkType) {
13101
    if (view.state & 128 /* Destroyed */) {
13102
        throw viewDestroyedError(DebugAction[_currentAction]);
13103
    }
13104
    debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
13105
    return view.def.updateRenderer(debugCheckRenderNodeFn, view);
13106
    /**
13107
     * @param {?} view
13108
     * @param {?} nodeIndex
13109
     * @param {?} argStyle
13110
     * @param {...?} values
13111
     * @return {?}
13112
     */
13113
    function debugCheckRenderNodeFn(view, nodeIndex, argStyle) {
13114
        var values = [];
13115
        for (var _i = 3; _i < arguments.length; _i++) {
13116
            values[_i - 3] = arguments[_i];
13117
        }
13118
        var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
13119
        if (checkType === 0 /* CheckAndUpdate */) {
13120
            debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
13121
        }
13122
        else {
13123
            debugCheckNoChangesNode(view, nodeDef, argStyle, values);
13124
        }
13125
        if (nodeDef.flags & 3 /* CatRenderNode */) {
13126
            debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
13127
        }
13128
        return (nodeDef.flags & 224 /* CatPureExpression */) ?
13129
            asPureExpressionData(view, nodeDef.nodeIndex).value :
13130
            undefined;
13131
    }
13132
}
13133
/**
13134
 * @param {?} view
13135
 * @param {?} nodeDef
13136
 * @param {?} argStyle
13137
 * @param {?} givenValues
13138
 * @return {?}
13139
 */
13140
function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
13141
    var /** @type {?} */ changed = ((checkAndUpdateNode)).apply(void 0, [view, nodeDef, argStyle].concat(givenValues));
13142
    if (changed) {
13143
        var /** @type {?} */ values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
13144
        if (nodeDef.flags & 16384 /* TypeDirective */) {
13145
            var /** @type {?} */ bindingValues = {};
13146
            for (var /** @type {?} */ i = 0; i < nodeDef.bindings.length; i++) {
13147
                var /** @type {?} */ binding = nodeDef.bindings[i];
13148
                var /** @type {?} */ value = values[i];
13149
                if (binding.flags & 8 /* TypeProperty */) {
13150
                    bindingValues[normalizeDebugBindingName(/** @type {?} */ ((binding.nonMinifiedName)))] =
13151
                        normalizeDebugBindingValue(value);
13152
                }
13153
            }
13154
            var /** @type {?} */ elDef = ((nodeDef.parent));
13155
            var /** @type {?} */ el = asElementData(view, elDef.nodeIndex).renderElement;
13156
            if (!((elDef.element)).name) {
13157
                // a comment.
13158
                view.renderer.setValue(el, "bindings=" + JSON.stringify(bindingValues, null, 2));
13159
            }
13160
            else {
13161
                // a regular element.
13162
                for (var /** @type {?} */ attr in bindingValues) {
13163
                    var /** @type {?} */ value = bindingValues[attr];
13164
                    if (value != null) {
13165
                        view.renderer.setAttribute(el, attr, value);
13166
                    }
13167
                    else {
13168
                        view.renderer.removeAttribute(el, attr);
13169
                    }
13170
                }
13171
            }
13172
        }
13173
    }
13174
}
13175
/**
13176
 * @param {?} view
13177
 * @param {?} nodeDef
13178
 * @param {?} argStyle
13179
 * @param {?} values
13180
 * @return {?}
13181
 */
13182
function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
13183
    ((checkNoChangesNode)).apply(void 0, [view, nodeDef, argStyle].concat(values));
13184
}
13185
/**
13186
 * @param {?} name
13187
 * @return {?}
13188
 */
13189
function normalizeDebugBindingName(name) {
13190
    // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
13191
    name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
13192
    return "ng-reflect-" + name;
13193
}
13194
var CAMEL_CASE_REGEXP = /([A-Z])/g;
13195
/**
13196
 * @param {?} input
13197
 * @return {?}
13198
 */
13199
function camelCaseToDashCase(input) {
13200
    return input.replace(CAMEL_CASE_REGEXP, function () {
13201
        var m = [];
13202
        for (var _i = 0; _i < arguments.length; _i++) {
13203
            m[_i] = arguments[_i];
13204
        }
13205
        return '-' + m[1].toLowerCase();
13206
    });
13207
}
13208
/**
13209
 * @param {?} value
13210
 * @return {?}
13211
 */
13212
function normalizeDebugBindingValue(value) {
13213
    try {
13214
        // Limit the size of the value as otherwise the DOM just gets polluted.
13215
        return value != null ? value.toString().slice(0, 30) : value;
13216
    }
13217
    catch (e) {
13218
        return '[ERROR] Exception while trying to serialize the value';
13219
    }
13220
}
13221
/**
13222
 * @param {?} view
13223
 * @param {?} nodeIndex
13224
 * @return {?}
13225
 */
13226
function nextDirectiveWithBinding(view, nodeIndex) {
13227
    for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
13228
        var /** @type {?} */ nodeDef = view.def.nodes[i];
13229
        if (nodeDef.flags & 16384 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
13230
            return i;
13231
        }
13232
    }
13233
    return null;
13234
}
13235
/**
13236
 * @param {?} view
13237
 * @param {?} nodeIndex
13238
 * @return {?}
13239
 */
13240
function nextRenderNodeWithBinding(view, nodeIndex) {
13241
    for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
13242
        var /** @type {?} */ nodeDef = view.def.nodes[i];
13243
        if ((nodeDef.flags & 3 /* CatRenderNode */) && nodeDef.bindings && nodeDef.bindings.length) {
13244
            return i;
13245
        }
13246
    }
13247
    return null;
13248
}
13249
var DebugContext_ = (function () {
13250
    /**
13251
     * @param {?} view
13252
     * @param {?} nodeIndex
13253
     */
13254
    function DebugContext_(view, nodeIndex) {
13255
        this.view = view;
13256
        this.nodeIndex = nodeIndex;
13257
        if (nodeIndex == null) {
13258
            this.nodeIndex = nodeIndex = 0;
13259
        }
13260
        this.nodeDef = view.def.nodes[nodeIndex];
13261
        var elDef = this.nodeDef;
13262
        var elView = view;
13263
        while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
13264
            elDef = elDef.parent;
13265
        }
13266
        if (!elDef) {
13267
            while (!elDef && elView) {
13268
                elDef = viewParentEl(elView);
13269
                elView = elView.parent;
13270
            }
13271
        }
13272
        this.elDef = elDef;
13273
        this.elView = elView;
13274
    }
13275
    Object.defineProperty(DebugContext_.prototype, "elOrCompView", {
13276
        /**
13277
         * @return {?}
13278
         */
13279
        get: function () {
13280
            // Has to be done lazily as we use the DebugContext also during creation of elements...
13281
            return asElementData(this.elView, this.elDef.nodeIndex).componentView || this.view;
13282
        },
13283
        enumerable: true,
13284
        configurable: true
13285
    });
13286
    Object.defineProperty(DebugContext_.prototype, "injector", {
13287
        /**
13288
         * @return {?}
13289
         */
13290
        get: function () { return createInjector(this.elView, this.elDef); },
13291
        enumerable: true,
13292
        configurable: true
13293
    });
13294
    Object.defineProperty(DebugContext_.prototype, "component", {
13295
        /**
13296
         * @return {?}
13297
         */
13298
        get: function () { return this.elOrCompView.component; },
13299
        enumerable: true,
13300
        configurable: true
13301
    });
13302
    Object.defineProperty(DebugContext_.prototype, "context", {
13303
        /**
13304
         * @return {?}
13305
         */
13306
        get: function () { return this.elOrCompView.context; },
13307
        enumerable: true,
13308
        configurable: true
13309
    });
13310
    Object.defineProperty(DebugContext_.prototype, "providerTokens", {
13311
        /**
13312
         * @return {?}
13313
         */
13314
        get: function () {
13315
            var /** @type {?} */ tokens = [];
13316
            if (this.elDef) {
13317
                for (var /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
13318
                    var /** @type {?} */ childDef = this.elView.def.nodes[i];
13319
                    if (childDef.flags & 20224 /* CatProvider */) {
13320
                        tokens.push(/** @type {?} */ ((childDef.provider)).token);
13321
                    }
13322
                    i += childDef.childCount;
13323
                }
13324
            }
13325
            return tokens;
13326
        },
13327
        enumerable: true,
13328
        configurable: true
13329
    });
13330
    Object.defineProperty(DebugContext_.prototype, "references", {
13331
        /**
13332
         * @return {?}
13333
         */
13334
        get: function () {
13335
            var /** @type {?} */ references = {};
13336
            if (this.elDef) {
13337
                collectReferences(this.elView, this.elDef, references);
13338
                for (var /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
13339
                    var /** @type {?} */ childDef = this.elView.def.nodes[i];
13340
                    if (childDef.flags & 20224 /* CatProvider */) {
13341
                        collectReferences(this.elView, childDef, references);
13342
                    }
13343
                    i += childDef.childCount;
13344
                }
13345
            }
13346
            return references;
13347
        },
13348
        enumerable: true,
13349
        configurable: true
13350
    });
13351
    Object.defineProperty(DebugContext_.prototype, "componentRenderElement", {
13352
        /**
13353
         * @return {?}
13354
         */
13355
        get: function () {
13356
            var /** @type {?} */ elData = findHostElement(this.elOrCompView);
13357
            return elData ? elData.renderElement : undefined;
13358
        },
13359
        enumerable: true,
13360
        configurable: true
13361
    });
13362
    Object.defineProperty(DebugContext_.prototype, "renderNode", {
13363
        /**
13364
         * @return {?}
13365
         */
13366
        get: function () {
13367
            return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) :
13368
                renderNode(this.elView, this.elDef);
13369
        },
13370
        enumerable: true,
13371
        configurable: true
13372
    });
13373
    /**
13374
     * @param {?} console
13375
     * @param {...?} values
13376
     * @return {?}
13377
     */
13378
    DebugContext_.prototype.logError = function (console) {
13379
        var values = [];
13380
        for (var _i = 1; _i < arguments.length; _i++) {
13381
            values[_i - 1] = arguments[_i];
13382
        }
13383
        var /** @type {?} */ logViewDef;
13384
        var /** @type {?} */ logNodeIndex;
13385
        if (this.nodeDef.flags & 2 /* TypeText */) {
13386
            logViewDef = this.view.def;
13387
            logNodeIndex = this.nodeDef.nodeIndex;
13388
        }
13389
        else {
13390
            logViewDef = this.elView.def;
13391
            logNodeIndex = this.elDef.nodeIndex;
13392
        }
13393
        // Note: we only generate a log function for text and element nodes
13394
        // to make the generated code as small as possible.
13395
        var /** @type {?} */ renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
13396
        var /** @type {?} */ currRenderNodeIndex = -1;
13397
        var /** @type {?} */ nodeLogger = function () {
13398
            currRenderNodeIndex++;
13399
            if (currRenderNodeIndex === renderNodeIndex) {
13400
                return (_a = console.error).bind.apply(_a, [console].concat(values));
13401
            }
13402
            else {
13403
                return NOOP;
13404
            }
13405
            var _a;
13406
        }; /** @type {?} */
13407
        ((logViewDef.factory))(nodeLogger);
13408
        if (currRenderNodeIndex < renderNodeIndex) {
13409
            console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
13410
            console.error.apply(console, values);
13411
        }
13412
    };
13413
    return DebugContext_;
13414
}());
13415
/**
13416
 * @param {?} viewDef
13417
 * @param {?} nodeIndex
13418
 * @return {?}
13419
 */
13420
function getRenderNodeIndex(viewDef$$1, nodeIndex) {
13421
    var /** @type {?} */ renderNodeIndex = -1;
13422
    for (var /** @type {?} */ i = 0; i <= nodeIndex; i++) {
13423
        var /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
13424
        if (nodeDef.flags & 3 /* CatRenderNode */) {
13425
            renderNodeIndex++;
13426
        }
13427
    }
13428
    return renderNodeIndex;
13429
}
13430
/**
13431
 * @param {?} view
13432
 * @return {?}
13433
 */
13434
function findHostElement(view) {
13435
    while (view && !isComponentView(view)) {
13436
        view = ((view.parent));
13437
    }
13438
    if (view.parent) {
13439
        return asElementData(view.parent, /** @type {?} */ ((viewParentEl(view))).nodeIndex);
13440
    }
13441
    return null;
13442
}
13443
/**
13444
 * @param {?} view
13445
 * @param {?} nodeDef
13446
 * @param {?} references
13447
 * @return {?}
13448
 */
13449
function collectReferences(view, nodeDef, references) {
13450
    for (var /** @type {?} */ refName in nodeDef.references) {
13451
        references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
13452
    }
13453
}
13454
/**
13455
 * @param {?} action
13456
 * @param {?} fn
13457
 * @param {?} self
13458
 * @param {?} args
13459
 * @return {?}
13460
 */
13461
function callWithDebugContext(action, fn, self, args) {
13462
    var /** @type {?} */ oldAction = _currentAction;
13463
    var /** @type {?} */ oldView = _currentView;
13464
    var /** @type {?} */ oldNodeIndex = _currentNodeIndex;
13465
    try {
13466
        _currentAction = action;
13467
        var /** @type {?} */ result = fn.apply(self, args);
13468
        _currentView = oldView;
13469
        _currentNodeIndex = oldNodeIndex;
13470
        _currentAction = oldAction;
13471
        return result;
13472
    }
13473
    catch (e) {
13474
        if (isViewDebugError(e) || !_currentView) {
13475
            throw e;
13476
        }
13477
        throw viewWrappedDebugError(e, /** @type {?} */ ((getCurrentDebugContext())));
13478
    }
13479
}
13480
/**
13481
 * @return {?}
13482
 */
13483
function getCurrentDebugContext() {
13484
    return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
13485
}
13486
var DebugRendererFactory2 = (function () {
13487
    /**
13488
     * @param {?} delegate
13489
     */
13490
    function DebugRendererFactory2(delegate) {
13491
        this.delegate = delegate;
13492
    }
13493
    /**
13494
     * @param {?} element
13495
     * @param {?} renderData
13496
     * @return {?}
13497
     */
13498
    DebugRendererFactory2.prototype.createRenderer = function (element, renderData) {
13499
        return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
13500
    };
13501
    /**
13502
     * @return {?}
13503
     */
13504
    DebugRendererFactory2.prototype.begin = function () {
13505
        if (this.delegate.begin) {
13506
            this.delegate.begin();
13507
        }
13508
    };
13509
    /**
13510
     * @return {?}
13511
     */
13512
    DebugRendererFactory2.prototype.end = function () {
13513
        if (this.delegate.end) {
13514
            this.delegate.end();
13515
        }
13516
    };
13517
    /**
13518
     * @return {?}
13519
     */
13520
    DebugRendererFactory2.prototype.whenRenderingDone = function () {
13521
        if (this.delegate.whenRenderingDone) {
13522
            return this.delegate.whenRenderingDone();
13523
        }
13524
        return Promise.resolve(null);
13525
    };
13526
    return DebugRendererFactory2;
13527
}());
13528
var DebugRenderer2 = (function () {
13529
    /**
13530
     * @param {?} delegate
13531
     */
13532
    function DebugRenderer2(delegate) {
13533
        this.delegate = delegate;
13534
    }
13535
    Object.defineProperty(DebugRenderer2.prototype, "data", {
13536
        /**
13537
         * @return {?}
13538
         */
13539
        get: function () { return this.delegate.data; },
13540
        enumerable: true,
13541
        configurable: true
13542
    });
13543
    /**
13544
     * @param {?} node
13545
     * @return {?}
13546
     */
13547
    DebugRenderer2.prototype.destroyNode = function (node) {
13548
        removeDebugNodeFromIndex(/** @type {?} */ ((getDebugNode(node))));
13549
        if (this.delegate.destroyNode) {
13550
            this.delegate.destroyNode(node);
13551
        }
13552
    };
13553
    /**
13554
     * @return {?}
13555
     */
13556
    DebugRenderer2.prototype.destroy = function () { this.delegate.destroy(); };
13557
    /**
13558
     * @param {?} name
13559
     * @param {?=} namespace
13560
     * @return {?}
13561
     */
13562
    DebugRenderer2.prototype.createElement = function (name, namespace) {
13563
        var /** @type {?} */ el = this.delegate.createElement(name, namespace);
13564
        var /** @type {?} */ debugCtx = getCurrentDebugContext();
13565
        if (debugCtx) {
13566
            var /** @type {?} */ debugEl = new DebugElement(el, null, debugCtx);
13567
            debugEl.name = name;
13568
            indexDebugNode(debugEl);
13569
        }
13570
        return el;
13571
    };
13572
    /**
13573
     * @param {?} value
13574
     * @return {?}
13575
     */
13576
    DebugRenderer2.prototype.createComment = function (value) {
13577
        var /** @type {?} */ comment = this.delegate.createComment(value);
13578
        var /** @type {?} */ debugCtx = getCurrentDebugContext();
13579
        if (debugCtx) {
13580
            indexDebugNode(new DebugNode(comment, null, debugCtx));
13581
        }
13582
        return comment;
13583
    };
13584
    /**
13585
     * @param {?} value
13586
     * @return {?}
13587
     */
13588
    DebugRenderer2.prototype.createText = function (value) {
13589
        var /** @type {?} */ text = this.delegate.createText(value);
13590
        var /** @type {?} */ debugCtx = getCurrentDebugContext();
13591
        if (debugCtx) {
13592
            indexDebugNode(new DebugNode(text, null, debugCtx));
13593
        }
13594
        return text;
13595
    };
13596
    /**
13597
     * @param {?} parent
13598
     * @param {?} newChild
13599
     * @return {?}
13600
     */
13601
    DebugRenderer2.prototype.appendChild = function (parent, newChild) {
13602
        var /** @type {?} */ debugEl = getDebugNode(parent);
13603
        var /** @type {?} */ debugChildEl = getDebugNode(newChild);
13604
        if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13605
            debugEl.addChild(debugChildEl);
13606
        }
13607
        this.delegate.appendChild(parent, newChild);
13608
    };
13609
    /**
13610
     * @param {?} parent
13611
     * @param {?} newChild
13612
     * @param {?} refChild
13613
     * @return {?}
13614
     */
13615
    DebugRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
13616
        var /** @type {?} */ debugEl = getDebugNode(parent);
13617
        var /** @type {?} */ debugChildEl = getDebugNode(newChild);
13618
        var /** @type {?} */ debugRefEl = ((getDebugNode(refChild)));
13619
        if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13620
            debugEl.insertBefore(debugRefEl, debugChildEl);
13621
        }
13622
        this.delegate.insertBefore(parent, newChild, refChild);
13623
    };
13624
    /**
13625
     * @param {?} parent
13626
     * @param {?} oldChild
13627
     * @return {?}
13628
     */
13629
    DebugRenderer2.prototype.removeChild = function (parent, oldChild) {
13630
        var /** @type {?} */ debugEl = getDebugNode(parent);
13631
        var /** @type {?} */ debugChildEl = getDebugNode(oldChild);
13632
        if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
13633
            debugEl.removeChild(debugChildEl);
13634
        }
13635
        this.delegate.removeChild(parent, oldChild);
13636
    };
13637
    /**
13638
     * @param {?} selectorOrNode
13639
     * @return {?}
13640
     */
13641
    DebugRenderer2.prototype.selectRootElement = function (selectorOrNode) {
13642
        var /** @type {?} */ el = this.delegate.selectRootElement(selectorOrNode);
13643
        var /** @type {?} */ debugCtx = getCurrentDebugContext();
13644
        if (debugCtx) {
13645
            indexDebugNode(new DebugElement(el, null, debugCtx));
13646
        }
13647
        return el;
13648
    };
13649
    /**
13650
     * @param {?} el
13651
     * @param {?} name
13652
     * @param {?} value
13653
     * @param {?=} namespace
13654
     * @return {?}
13655
     */
13656
    DebugRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
13657
        var /** @type {?} */ debugEl = getDebugNode(el);
13658
        if (debugEl && debugEl instanceof DebugElement) {
13659
            var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
13660
            debugEl.attributes[fullName] = value;
13661
        }
13662
        this.delegate.setAttribute(el, name, value, namespace);
13663
    };
13664
    /**
13665
     * @param {?} el
13666
     * @param {?} name
13667
     * @param {?=} namespace
13668
     * @return {?}
13669
     */
13670
    DebugRenderer2.prototype.removeAttribute = function (el, name, namespace) {
13671
        var /** @type {?} */ debugEl = getDebugNode(el);
13672
        if (debugEl && debugEl instanceof DebugElement) {
13673
            var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
13674
            debugEl.attributes[fullName] = null;
13675
        }
13676
        this.delegate.removeAttribute(el, name, namespace);
13677
    };
13678
    /**
13679
     * @param {?} el
13680
     * @param {?} name
13681
     * @return {?}
13682
     */
13683
    DebugRenderer2.prototype.addClass = function (el, name) {
13684
        var /** @type {?} */ debugEl = getDebugNode(el);
13685
        if (debugEl && debugEl instanceof DebugElement) {
13686
            debugEl.classes[name] = true;
13687
        }
13688
        this.delegate.addClass(el, name);
13689
    };
13690
    /**
13691
     * @param {?} el
13692
     * @param {?} name
13693
     * @return {?}
13694
     */
13695
    DebugRenderer2.prototype.removeClass = function (el, name) {
13696
        var /** @type {?} */ debugEl = getDebugNode(el);
13697
        if (debugEl && debugEl instanceof DebugElement) {
13698
            debugEl.classes[name] = false;
13699
        }
13700
        this.delegate.removeClass(el, name);
13701
    };
13702
    /**
13703
     * @param {?} el
13704
     * @param {?} style
13705
     * @param {?} value
13706
     * @param {?} flags
13707
     * @return {?}
13708
     */
13709
    DebugRenderer2.prototype.setStyle = function (el, style, value, flags) {
13710
        var /** @type {?} */ debugEl = getDebugNode(el);
13711
        if (debugEl && debugEl instanceof DebugElement) {
13712
            debugEl.styles[style] = value;
13713
        }
13714
        this.delegate.setStyle(el, style, value, flags);
13715
    };
13716
    /**
13717
     * @param {?} el
13718
     * @param {?} style
13719
     * @param {?} flags
13720
     * @return {?}
13721
     */
13722
    DebugRenderer2.prototype.removeStyle = function (el, style, flags) {
13723
        var /** @type {?} */ debugEl = getDebugNode(el);
13724
        if (debugEl && debugEl instanceof DebugElement) {
13725
            debugEl.styles[style] = null;
13726
        }
13727
        this.delegate.removeStyle(el, style, flags);
13728
    };
13729
    /**
13730
     * @param {?} el
13731
     * @param {?} name
13732
     * @param {?} value
13733
     * @return {?}
13734
     */
13735
    DebugRenderer2.prototype.setProperty = function (el, name, value) {
13736
        var /** @type {?} */ debugEl = getDebugNode(el);
13737
        if (debugEl && debugEl instanceof DebugElement) {
13738
            debugEl.properties[name] = value;
13739
        }
13740
        this.delegate.setProperty(el, name, value);
13741
    };
13742
    /**
13743
     * @param {?} target
13744
     * @param {?} eventName
13745
     * @param {?} callback
13746
     * @return {?}
13747
     */
13748
    DebugRenderer2.prototype.listen = function (target, eventName, callback) {
13749
        if (typeof target !== 'string') {
13750
            var /** @type {?} */ debugEl = getDebugNode(target);
13751
            if (debugEl) {
13752
                debugEl.listeners.push(new EventListener(eventName, callback));
13753
            }
13754
        }
13755
        return this.delegate.listen(target, eventName, callback);
13756
    };
13757
    /**
13758
     * @param {?} node
13759
     * @return {?}
13760
     */
13761
    DebugRenderer2.prototype.parentNode = function (node) { return this.delegate.parentNode(node); };
13762
    /**
13763
     * @param {?} node
13764
     * @return {?}
13765
     */
13766
    DebugRenderer2.prototype.nextSibling = function (node) { return this.delegate.nextSibling(node); };
13767
    /**
13768
     * @param {?} node
13769
     * @param {?} value
13770
     * @return {?}
13771
     */
13772
    DebugRenderer2.prototype.setValue = function (node, value) { return this.delegate.setValue(node, value); };
13773
    return DebugRenderer2;
13774
}());
13775
/**
13776
 * @license
13777
 * Copyright Google Inc. All Rights Reserved.
13778
 *
13779
 * Use of this source code is governed by an MIT-style license that can be
13780
 * found in the LICENSE file at https://angular.io/license
13781
 */
13782
/**
13783
 * @param {?} override
13784
 * @return {?}
13785
 */
13786
function overrideProvider(override) {
13787
    initServicesIfNeeded();
13788
    return Services.overrideProvider(override);
13789
}
13790
/**
13791
 * @return {?}
13792
 */
13793
function clearProviderOverrides() {
13794
    initServicesIfNeeded();
13795
    return Services.clearProviderOverrides();
13796
}
13797
/**
13798
 * @param {?} ngModuleType
13799
 * @param {?} bootstrapComponents
13800
 * @param {?} defFactory
13801
 * @return {?}
13802
 */
13803
function createNgModuleFactory(ngModuleType, bootstrapComponents, defFactory) {
13804
    return new NgModuleFactory_(ngModuleType, bootstrapComponents, defFactory);
13805
}
13806
var NgModuleFactory_ = (function (_super) {
13807
    tslib_1.__extends(NgModuleFactory_, _super);
13808
    /**
13809
     * @param {?} moduleType
13810
     * @param {?} _bootstrapComponents
13811
     * @param {?} _ngModuleDefFactory
13812
     */
13813
    function NgModuleFactory_(moduleType, _bootstrapComponents, _ngModuleDefFactory) {
13814
        var _this =
13815
        // Attention: this ctor is called as top level function.
13816
        // Putting any logic in here will destroy closure tree shaking!
13817
        _super.call(this) || this;
13818
        _this.moduleType = moduleType;
13819
        _this._bootstrapComponents = _bootstrapComponents;
13820
        _this._ngModuleDefFactory = _ngModuleDefFactory;
13821
        return _this;
13822
    }
13823
    /**
13824
     * @param {?} parentInjector
13825
     * @return {?}
13826
     */
13827
    NgModuleFactory_.prototype.create = function (parentInjector) {
13828
        initServicesIfNeeded();
13829
        var /** @type {?} */ def = resolveDefinition(this._ngModuleDefFactory);
13830
        return Services.createNgModuleRef(this.moduleType, parentInjector || Injector.NULL, this._bootstrapComponents, def);
13831
    };
13832
    return NgModuleFactory_;
13833
}(NgModuleFactory));
13834
/**
13835
 * @license
13836
 * Copyright Google Inc. All Rights Reserved.
13837
 *
13838
 * Use of this source code is governed by an MIT-style license that can be
13839
 * found in the LICENSE file at https://angular.io/license
13840
 */
13841
/**
13842
 * @license
13843
 * Copyright Google Inc. All Rights Reserved.
13844
 *
13845
 * Use of this source code is governed by an MIT-style license that can be
13846
 * found in the LICENSE file at https://angular.io/license
13847
 */
13848
/**
13849
 * @license
13850
 * Copyright Google Inc. All Rights Reserved.
13851
 *
13852
 * Use of this source code is governed by an MIT-style license that can be
13853
 * found in the LICENSE file at https://angular.io/license
13854
 */
13855
/**
13856
 * \@experimental Animation support is experimental.
13857
 */
13858
/**
13859
 * `trigger` is an animation-specific function that is designed to be used inside of Angular's
13860
 * animation DSL language. If this information is new, please navigate to the
13861
 * {\@link Component#animations component animations metadata page} to gain a better
13862
 * understanding of how animations in Angular are used.
13863
 *
13864
 * `trigger` Creates an animation trigger which will a list of {\@link state state} and
13865
 * {\@link transition transition} entries that will be evaluated when the expression
13866
 * bound to the trigger changes.
13867
 *
13868
 * Triggers are registered within the component annotation data under the
13869
 * {\@link Component#animations animations section}. An animation trigger can be placed on an element
13870
 * within a template by referencing the name of the trigger followed by the expression value that
13871
 * the
13872
 * trigger is bound to (in the form of `[\@triggerName]="expression"`.
13873
 *
13874
 * Animation trigger bindings strigify values and then match the previous and current values against
13875
 * any linked transitions. If a boolean value is provided into the trigger binding then it will both
13876
 * be represented as `1` or `true` and `0` or `false` for a true and false boolean values
13877
 * respectively.
13878
 *
13879
 * ### Usage
13880
 *
13881
 * `trigger` will create an animation trigger reference based on the provided `name` value. The
13882
 * provided `animation` value is expected to be an array consisting of {\@link state state} and
13883
 * {\@link transition transition} declarations.
13884
 *
13885
 * ```typescript
13886
 * \@Component({
13887
 *   selector: 'my-component',
13888
 *   templateUrl: 'my-component-tpl.html',
13889
 *   animations: [
13890
 *     trigger("myAnimationTrigger", [
13891
 *       state(...),
13892
 *       state(...),
13893
 *       transition(...),
13894
 *       transition(...)
13895
 *     ])
13896
 *   ]
13897
 * })
13898
 * class MyComponent {
13899
 *   myStatusExp = "something";
13900
 * }
13901
 * ```
13902
 *
13903
 * The template associated with this component will make use of the `myAnimationTrigger` animation
13904
 * trigger by binding to an element within its template code.
13905
 *
13906
 * ```html
13907
 * <!-- somewhere inside of my-component-tpl.html -->
13908
 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
13909
 * ```
13910
 *
13911
 * ## Disable Animations
13912
 * A special animation control binding called `\@.disabled` can be placed on an element which will
13913
 * then disable animations for any inner animation triggers situated within the element as well as
13914
 * any animations on the element itself.
13915
 *
13916
 * When true, the `\@.disabled` binding will prevent all animations from rendering. The example
13917
 * below shows how to use this feature:
13918
 *
13919
 * ```ts
13920
 * \@Component({
13921
 *   selector: 'my-component',
13922
 *   template: `
13923
 *     <div [\@.disabled]="isDisabled">
13924
 *       <div [\@childAnimation]="exp"></div>
13925
 *     </div>
13926
 *   `,
13927
 *   animations: [
13928
 *     trigger("childAnimation", [
13929
 *       // ...
13930
 *     ])
13931
 *   ]
13932
 * })
13933
 * class MyComponent {
13934
 *   isDisabled = true;
13935
 *   exp = '...';
13936
 * }
13937
 * ```
13938
 *
13939
 * The `\@childAnimation` trigger will not animate because `\@.disabled` prevents it from happening
13940
 * (when true).
13941
 *
13942
 * Note that `\@.disbled` will only disable all animations (this means any animations running on
13943
 * the same element will also be disabled).
13944
 *
13945
 * ### Disabling Animations Application-wide
13946
 * When an area of the template is set to have animations disabled, **all** inner components will
13947
 * also have their animations disabled as well. This means that all animations for an angular
13948
 * application can be disabled by placing a host binding set on `\@.disabled` on the topmost Angular
13949
 * component.
13950
 *
13951
 * ```ts
13952
 * import {Component, HostBinding} from '\@angular/core';
13953
 *
13954
 * \@Component({
13955
 *   selector: 'app-component',
13956
 *   templateUrl: 'app.component.html',
13957
 * })
13958
 * class AppComponent {
13959
 *   \@HostBinding('\@.disabled')
13960
 *   public animationsDisabled = true;
13961
 * }
13962
 * ```
13963
 *
13964
 * ### What about animations that us `query()` and `animateChild()`?
13965
 * Despite inner animations being disabled, a parent animation can {\@link query query} for inner
13966
 * elements located in disabled areas of the template and still animate them as it sees fit. This is
13967
 * also the case for when a sub animation is queried by a parent and then later animated using {\@link
13968
 * animateChild animateChild}.
13969
 *
13970
 * \@experimental Animation support is experimental.
13971
 * @param {?} name
13972
 * @param {?} definitions
13973
 * @return {?}
13974
 */
13975
function trigger$1(name, definitions) {
13976
    return { type: 7 /* Trigger */, name: name, definitions: definitions, options: {} };
13977
}
13978
/**
13979
 * `animate` is an animation-specific function that is designed to be used inside of Angular's
13980
 * animation DSL language. If this information is new, please navigate to the {\@link
13981
 * Component#animations component animations metadata page} to gain a better understanding of
13982
 * how animations in Angular are used.
13983
 *
13984
 * `animate` specifies an animation step that will apply the provided `styles` data for a given
13985
 * amount of time based on the provided `timing` expression value. Calls to `animate` are expected
13986
 * to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
13987
 * transition transition}.
13988
 *
13989
 * ### Usage
13990
 *
13991
 * The `animate` function accepts two input parameters: `timing` and `styles`:
13992
 *
13993
 * - `timing` is a string based value that can be a combination of a duration with optional delay
13994
 * and easing values. The format for the expression breaks down to `duration delay easing`
13995
 * (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
13996
 * delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
13997
 * `duration` value in millisecond form.
13998
 * - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
13999
 * keyframes keyframes}. If left empty then the styles from the destination state will be collected
14000
 * and used (this is useful when describing an animation step that will complete an animation by
14001
 * {\@link transition#the-final-animate-call animating to the final state}).
14002
 *
14003
 * ```typescript
14004
 * // various functions for specifying timing data
14005
 * animate(500, style(...))
14006
 * animate("1s", style(...))
14007
 * animate("100ms 0.5s", style(...))
14008
 * animate("5s ease", style(...))
14009
 * animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
14010
 *
14011
 * // either style() of keyframes() can be used
14012
 * animate(500, style({ background: "red" }))
14013
 * animate(500, keyframes([
14014
 *   style({ background: "blue" })),
14015
 *   style({ background: "red" }))
14016
 * ])
14017
 * ```
14018
 *
14019
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14020
 *
14021
 * \@experimental Animation support is experimental.
14022
 * @param {?} timings
14023
 * @param {?=} styles
14024
 * @return {?}
14025
 */
14026
function animate$1(timings, styles) {
14027
    if (styles === void 0) { styles = null; }
14028
    return { type: 4 /* Animate */, styles: styles, timings: timings };
14029
}
14030
/**
14031
 * `group` is an animation-specific function that is designed to be used inside of Angular's
14032
 * animation DSL language. If this information is new, please navigate to the {\@link
14033
 * Component#animations component animations metadata page} to gain a better understanding of
14034
 * how animations in Angular are used.
14035
 *
14036
 * `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
14037
 * useful when a series of styles must be animated/closed off at different starting/ending times.
14038
 *
14039
 * The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
14040
 * transition} and it will only continue to the next instruction once all of the inner animation
14041
 * steps have completed.
14042
 *
14043
 * ### Usage
14044
 *
14045
 * The `steps` data that is passed into the `group` animation function can either consist of {\@link
14046
 * style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
14047
 * within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
14048
 * animate#usage animate() with a delay value} to offset styles to be applied at a later time).
14049
 *
14050
 * ```typescript
14051
 * group([
14052
 *   animate("1s", { background: "black" }))
14053
 *   animate("2s", { color: "white" }))
14054
 * ])
14055
 * ```
14056
 *
14057
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14058
 *
14059
 * \@experimental Animation support is experimental.
14060
 * @param {?} steps
14061
 * @param {?=} options
14062
 * @return {?}
14063
 */
14064
function group$1(steps, options) {
14065
    if (options === void 0) { options = null; }
14066
    return { type: 3 /* Group */, steps: steps, options: options };
14067
}
14068
/**
14069
 * `sequence` is an animation-specific function that is designed to be used inside of Angular's
14070
 * animation DSL language. If this information is new, please navigate to the {\@link
14071
 * Component#animations component animations metadata page} to gain a better understanding of
14072
 * how animations in Angular are used.
14073
 *
14074
 * `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
14075
 * default when an array is passed as animation data into {\@link transition transition}.)
14076
 *
14077
 * The `sequence` function can either be used within a {\@link group group} or a {\@link transition
14078
 * transition} and it will only continue to the next instruction once each of the inner animation
14079
 * steps have completed.
14080
 *
14081
 * To perform animation styling in parallel with other animation steps then have a look at the
14082
 * {\@link group group} animation function.
14083
 *
14084
 * ### Usage
14085
 *
14086
 * The `steps` data that is passed into the `sequence` animation function can either consist of
14087
 * {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
14088
 * provided styling data immediately while a call to `animate()` will apply its styling data over a
14089
 * given time depending on its timing data.
14090
 *
14091
 * ```typescript
14092
 * sequence([
14093
 *   style({ opacity: 0 })),
14094
 *   animate("1s", { opacity: 1 }))
14095
 * ])
14096
 * ```
14097
 *
14098
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14099
 *
14100
 * \@experimental Animation support is experimental.
14101
 * @param {?} steps
14102
 * @param {?=} options
14103
 * @return {?}
14104
 */
14105
function sequence$1(steps, options) {
14106
    if (options === void 0) { options = null; }
14107
    return { type: 2 /* Sequence */, steps: steps, options: options };
14108
}
14109
/**
14110
 * `style` is an animation-specific function that is designed to be used inside of Angular's
14111
 * animation DSL language. If this information is new, please navigate to the {\@link
14112
 * Component#animations component animations metadata page} to gain a better understanding of
14113
 * how animations in Angular are used.
14114
 *
14115
 * `style` declares a key/value object containing CSS properties/styles that can then be used for
14116
 * {\@link state animation states}, within an {\@link sequence animation sequence}, or as styling data
14117
 * for both {\@link animate animate} and {\@link keyframes keyframes}.
14118
 *
14119
 * ### Usage
14120
 *
14121
 * `style` takes in a key/value string map as data and expects one or more CSS property/value pairs
14122
 * to be defined.
14123
 *
14124
 * ```typescript
14125
 * // string values are used for css properties
14126
 * style({ background: "red", color: "blue" })
14127
 *
14128
 * // numerical (pixel) values are also supported
14129
 * style({ width: 100, height: 0 })
14130
 * ```
14131
 *
14132
 * #### Auto-styles (using `*`)
14133
 *
14134
 * When an asterix (`*`) character is used as a value then it will be detected from the element
14135
 * being animated and applied as animation data when the animation starts.
14136
 *
14137
 * This feature proves useful for a state depending on layout and/or environment factors; in such
14138
 * cases the styles are calculated just before the animation starts.
14139
 *
14140
 * ```typescript
14141
 * // the steps below will animate from 0 to the
14142
 * // actual height of the element
14143
 * style({ height: 0 }),
14144
 * animate("1s", style({ height: "*" }))
14145
 * ```
14146
 *
14147
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14148
 *
14149
 * \@experimental Animation support is experimental.
14150
 * @param {?} tokens
14151
 * @return {?}
14152
 */
14153
function style$1(tokens) {
14154
    return { type: 6 /* Style */, styles: tokens, offset: null };
14155
}
14156
/**
14157
 * `state` is an animation-specific function that is designed to be used inside of Angular's
14158
 * animation DSL language. If this information is new, please navigate to the {\@link
14159
 * Component#animations component animations metadata page} to gain a better understanding of
14160
 * how animations in Angular are used.
14161
 *
14162
 * `state` declares an animation state within the given trigger. When a state is active within a
14163
 * component then its associated styles will persist on the element that the trigger is attached to
14164
 * (even when the animation ends).
14165
 *
14166
 * To animate between states, have a look at the animation {\@link transition transition} DSL
14167
 * function. To register states to an animation trigger please have a look at the {\@link trigger
14168
 * trigger} function.
14169
 *
14170
 * #### The `void` state
14171
 *
14172
 * The `void` state value is a reserved word that angular uses to determine when the element is not
14173
 * apart of the application anymore (e.g. when an `ngIf` evaluates to false then the state of the
14174
 * associated element is void).
14175
 *
14176
 * #### The `*` (default) state
14177
 *
14178
 * The `*` state (when styled) is a fallback state that will be used if the state that is being
14179
 * animated is not declared within the trigger.
14180
 *
14181
 * ### Usage
14182
 *
14183
 * `state` will declare an animation state with its associated styles
14184
 * within the given trigger.
14185
 *
14186
 * - `stateNameExpr` can be one or more state names separated by commas.
14187
 * - `styles` refers to the {\@link style styling data} that will be persisted on the element once
14188
 * the state has been reached.
14189
 *
14190
 * ```typescript
14191
 * // "void" is a reserved name for a state and is used to represent
14192
 * // the state in which an element is detached from from the application.
14193
 * state("void", style({ height: 0 }))
14194
 *
14195
 * // user-defined states
14196
 * state("closed", style({ height: 0 }))
14197
 * state("open, visible", style({ height: "*" }))
14198
 * ```
14199
 *
14200
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14201
 *
14202
 * \@experimental Animation support is experimental.
14203
 * @param {?} name
14204
 * @param {?} styles
14205
 * @param {?=} options
14206
 * @return {?}
14207
 */
14208
function state$1(name, styles, options) {
14209
    return { type: 0 /* State */, name: name, styles: styles, options: options };
14210
}
14211
/**
14212
 * `keyframes` is an animation-specific function that is designed to be used inside of Angular's
14213
 * animation DSL language. If this information is new, please navigate to the {\@link
14214
 * Component#animations component animations metadata page} to gain a better understanding of
14215
 * how animations in Angular are used.
14216
 *
14217
 * `keyframes` specifies a collection of {\@link style style} entries each optionally characterized
14218
 * by an `offset` value.
14219
 *
14220
 * ### Usage
14221
 *
14222
 * The `keyframes` animation function is designed to be used alongside the {\@link animate animate}
14223
 * animation function. Instead of applying animations from where they are currently to their
14224
 * destination, keyframes can describe how each style entry is applied and at what point within the
14225
 * animation arc (much like CSS Keyframe Animations do).
14226
 *
14227
 * For each `style()` entry an `offset` value can be set. Doing so allows to specifiy at what
14228
 * percentage of the animate time the styles will be applied.
14229
 *
14230
 * ```typescript
14231
 * // the provided offset values describe when each backgroundColor value is applied.
14232
 * animate("5s", keyframes([
14233
 *   style({ backgroundColor: "red", offset: 0 }),
14234
 *   style({ backgroundColor: "blue", offset: 0.2 }),
14235
 *   style({ backgroundColor: "orange", offset: 0.3 }),
14236
 *   style({ backgroundColor: "black", offset: 1 })
14237
 * ]))
14238
 * ```
14239
 *
14240
 * Alternatively, if there are no `offset` values used within the style entries then the offsets
14241
 * will be calculated automatically.
14242
 *
14243
 * ```typescript
14244
 * animate("5s", keyframes([
14245
 *   style({ backgroundColor: "red" }) // offset = 0
14246
 *   style({ backgroundColor: "blue" }) // offset = 0.33
14247
 *   style({ backgroundColor: "orange" }) // offset = 0.66
14248
 *   style({ backgroundColor: "black" }) // offset = 1
14249
 * ]))
14250
 * ```
14251
 *
14252
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14253
 *
14254
 * \@experimental Animation support is experimental.
14255
 * @param {?} steps
14256
 * @return {?}
14257
 */
14258
function keyframes$1(steps) {
14259
    return { type: 5 /* Keyframes */, steps: steps };
14260
}
14261
/**
14262
 * `transition` is an animation-specific function that is designed to be used inside of Angular's
14263
 * animation DSL language. If this information is new, please navigate to the {\@link
14264
 * Component#animations component animations metadata page} to gain a better understanding of
14265
 * how animations in Angular are used.
14266
 *
14267
 * `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
14268
 * provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
14269
 * state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
14270
 * and/or ending state).
14271
 *
14272
 * A function can also be provided as the `stateChangeExpr` argument for a transition and this
14273
 * function will be executed each time a state change occurs. If the value returned within the
14274
 * function is true then the associated animation will be run.
14275
 *
14276
 * Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
14277
 * to animate to a state value and persist its styles then one or more {\@link state animation
14278
 * states} is expected to be defined.
14279
 *
14280
 * ### Usage
14281
 *
14282
 * An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
14283
 * what the previous state is and what the current state has become. In other words, if a transition
14284
 * is defined that matches the old/current state criteria then the associated animation will be
14285
 * triggered.
14286
 *
14287
 * ```typescript
14288
 * // all transition/state changes are defined within an animation trigger
14289
 * trigger("myAnimationTrigger", [
14290
 *   // if a state is defined then its styles will be persisted when the
14291
 *   // animation has fully completed itself
14292
 *   state("on", style({ background: "green" })),
14293
 *   state("off", style({ background: "grey" })),
14294
 *
14295
 *   // a transition animation that will be kicked off when the state value
14296
 *   // bound to "myAnimationTrigger" changes from "on" to "off"
14297
 *   transition("on => off", animate(500)),
14298
 *
14299
 *   // it is also possible to do run the same animation for both directions
14300
 *   transition("on <=> off", animate(500)),
14301
 *
14302
 *   // or to define multiple states pairs separated by commas
14303
 *   transition("on => off, off => void", animate(500)),
14304
 *
14305
 *   // this is a catch-all state change for when an element is inserted into
14306
 *   // the page and the destination state is unknown
14307
 *   transition("void => *", [
14308
 *     style({ opacity: 0 }),
14309
 *     animate(500)
14310
 *   ]),
14311
 *
14312
 *   // this will capture a state change between any states
14313
 *   transition("* => *", animate("1s 0s")),
14314
 *
14315
 *   // you can also go full out and include a function
14316
 *   transition((fromState, toState) => {
14317
 *     // when `true` then it will allow the animation below to be invoked
14318
 *     return fromState == "off" && toState == "on";
14319
 *   }, animate("1s 0s"))
14320
 * ])
14321
 * ```
14322
 *
14323
 * The template associated with this component will make use of the `myAnimationTrigger` animation
14324
 * trigger by binding to an element within its template code.
14325
 *
14326
 * ```html
14327
 * <!-- somewhere inside of my-component-tpl.html -->
14328
 * <div [\@myAnimationTrigger]="myStatusExp">...</div>
14329
 * ```
14330
 *
14331
 * #### The final `animate` call
14332
 *
14333
 * If the final step within the transition steps is a call to `animate()` that **only** uses a
14334
 * timing value with **no style data** then it will be automatically used as the final animation arc
14335
 * for the element to animate itself to the final state. This involves an automatic mix of
14336
 * adding/removing CSS styles so that the element will be in the exact state it should be for the
14337
 * applied state to be presented correctly.
14338
 *
14339
 * ```
14340
 * // start off by hiding the element, but make sure that it animates properly to whatever state
14341
 * // is currently active for "myAnimationTrigger"
14342
 * transition("void => *", [
14343
 *   style({ opacity: 0 }),
14344
 *   animate(500)
14345
 * ])
14346
 * ```
14347
 *
14348
 * ### Transition Aliases (`:enter` and `:leave`)
14349
 *
14350
 * Given that enter (insertion) and leave (removal) animations are so common, the `transition`
14351
 * function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
14352
 * => void` state changes.
14353
 *
14354
 * ```
14355
 * transition(":enter", [
14356
 *   style({ opacity: 0 }),
14357
 *   animate(500, style({ opacity: 1 }))
14358
 * ])
14359
 * transition(":leave", [
14360
 *   animate(500, style({ opacity: 0 }))
14361
 * ])
14362
 * ```
14363
 *
14364
 * ### Boolean values
14365
 * if a trigger binding value is a boolean value then it can be matched using a transition
14366
 * expression that compares `true` and `false` or `1` and `0`.
14367
 *
14368
 * ```
14369
 * // in the template
14370
 * <div [\@openClose]="open ? true : false">...</div>
14371
 *
14372
 * // in the component metadata
14373
 * trigger('openClose', [
14374
 *   state('true', style({ height: '*' })),
14375
 *   state('false', style({ height: '0px' })),
14376
 *   transition('false <=> true', animate(500))
14377
 * ])
14378
 * ```
14379
 * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
14380
 *
14381
 * \@experimental Animation support is experimental.
14382
 * @param {?} stateChangeExpr
14383
 * @param {?} steps
14384
 * @param {?=} options
14385
 * @return {?}
14386
 */
14387
function transition$1(stateChangeExpr, steps, options) {
14388
    if (options === void 0) { options = null; }
14389
    return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options: options };
14390
}
14391
/**
14392
 * `animation` is an animation-specific function that is designed to be used inside of Angular's
14393
 * animation DSL language.
14394
 *
14395
 * `var myAnimation = animation(...)` is designed to produce a reusable animation that can be later
14396
 * invoked in another animation or sequence. Reusable animations are designed to make use of
14397
 * animation parameters and the produced animation can be used via the `useAnimation` method.
14398
 *
14399
 * ```
14400
 * var fadeAnimation = animation([
14401
 *   style({ opacity: '{{ start }}' }),
14402
 *   animate('{{ time }}',
14403
 *     style({ opacity: '{{ end }}'}))
14404
 * ], { params: { time: '1000ms', start: 0, end: 1 }});
14405
 * ```
14406
 *
14407
 * If parameters are attached to an animation then they act as **default parameter values**. When an
14408
 * animation is invoked via `useAnimation` then parameter values are allowed to be passed in
14409
 * directly. If any of the passed in parameter values are missing then the default values will be
14410
 * used.
14411
 *
14412
 * ```
14413
 * useAnimation(fadeAnimation, {
14414
 *   params: {
14415
 *     time: '2s',
14416
 *     start: 1,
14417
 *     end: 0
14418
 *   }
14419
 * })
14420
 * ```
14421
 *
14422
 * If one or more parameter values are missing before animated then an error will be thrown.
14423
 *
14424
 * \@experimental Animation support is experimental.
14425
 * @param {?} steps
14426
 * @param {?=} options
14427
 * @return {?}
14428
 */
14429
/**
14430
 * `animateChild` is an animation-specific function that is designed to be used inside of Angular's
14431
 * animation DSL language. It works by allowing a queried element to execute its own
14432
 * animation within the animation sequence.
14433
 *
14434
 * Each time an animation is triggered in angular, the parent animation
14435
 * will always get priority and any child animations will be blocked. In order
14436
 * for a child animation to run, the parent animation must query each of the elements
14437
 * containing child animations and then allow the animations to run using `animateChild`.
14438
 *
14439
 * The example HTML code below shows both parent and child elements that have animation
14440
 * triggers that will execute at the same time.
14441
 *
14442
 * ```html
14443
 * <!-- parent-child.component.html -->
14444
 * <button (click)="exp =! exp">Toggle</button>
14445
 * <hr>
14446
 *
14447
 * <div [\@parentAnimation]="exp">
14448
 *   <header>Hello</header>
14449
 *   <div [\@childAnimation]="exp">
14450
 *       one
14451
 *   </div>
14452
 *   <div [\@childAnimation]="exp">
14453
 *       two
14454
 *   </div>
14455
 *   <div [\@childAnimation]="exp">
14456
 *       three
14457
 *   </div>
14458
 * </div>
14459
 * ```
14460
 *
14461
 * Now when the `exp` value changes to true, only the `parentAnimation` animation will animate
14462
 * because it has priority. However, using `query` and `animateChild` each of the inner animations
14463
 * can also fire:
14464
 *
14465
 * ```ts
14466
 * // parent-child.component.ts
14467
 * import {trigger, transition, animate, style, query, animateChild} from '\@angular/animations';
14468
 * \@Component({
14469
 *   selector: 'parent-child-component',
14470
 *   animations: [
14471
 *     trigger('parentAnimation', [
14472
 *       transition('false => true', [
14473
 *         query('header', [
14474
 *           style({ opacity: 0 }),
14475
 *           animate(500, style({ opacity: 1 }))
14476
 *         ]),
14477
 *         query('\@childAnimation', [
14478
 *           animateChild()
14479
 *         ])
14480
 *       ])
14481
 *     ]),
14482
 *     trigger('childAnimation', [
14483
 *       transition('false => true', [
14484
 *         style({ opacity: 0 }),
14485
 *         animate(500, style({ opacity: 1 }))
14486
 *       ])
14487
 *     ])
14488
 *   ]
14489
 * })
14490
 * class ParentChildCmp {
14491
 *   exp: boolean = false;
14492
 * }
14493
 * ```
14494
 *
14495
 * In the animation code above, when the `parentAnimation` transition kicks off it first queries to
14496
 * find the header element and fades it in. It then finds each of the sub elements that contain the
14497
 * `\@childAnimation` trigger and then allows for their animations to fire.
14498
 *
14499
 * This example can be further extended by using stagger:
14500
 *
14501
 * ```ts
14502
 * query('\@childAnimation', stagger(100, [
14503
 *   animateChild()
14504
 * ]))
14505
 * ```
14506
 *
14507
 * Now each of the sub animations start off with respect to the `100ms` staggering step.
14508
 *
14509
 * ## The first frame of child animations
14510
 * When sub animations are executed using `animateChild` the animation engine will always apply the
14511
 * first frame of every sub animation immediately at the start of the animation sequence. This way
14512
 * the parent animation does not need to set any initial styling data on the sub elements before the
14513
 * sub animations kick off.
14514
 *
14515
 * In the example above the first frame of the `childAnimation`'s `false => true` transition
14516
 * consists of a style of `opacity: 0`. This is applied immediately when the `parentAnimation`
14517
 * animation transition sequence starts. Only then when the `\@childAnimation` is queried and called
14518
 * with `animateChild` will it then animate to its destination of `opacity: 1`.
14519
 *
14520
 * Note that this feature designed to be used alongside {\@link query query()} and it will only work
14521
 * with animations that are assigned using the Angular animation DSL (this means that CSS keyframes
14522
 * and transitions are not handled by this API).
14523
 *
14524
 * \@experimental Animation support is experimental.
14525
 * @param {?=} options
14526
 * @return {?}
14527
 */
14528
/**
14529
 * `useAnimation` is an animation-specific function that is designed to be used inside of Angular's
14530
 * animation DSL language. It is used to kick off a reusable animation that is created using {\@link
14531
 * animation animation()}.
14532
 *
14533
 * \@experimental Animation support is experimental.
14534
 * @param {?} animation
14535
 * @param {?=} options
14536
 * @return {?}
14537
 */
14538
/**
14539
 * `query` is an animation-specific function that is designed to be used inside of Angular's
14540
 * animation DSL language.
14541
 *
14542
 * query() is used to find one or more inner elements within the current element that is
14543
 * being animated within the sequence. The provided animation steps are applied
14544
 * to the queried element (by default, an array is provided, then this will be
14545
 * treated as an animation sequence).
14546
 *
14547
 * ### Usage
14548
 *
14549
 * query() is designed to collect mutiple elements and works internally by using
14550
 * `element.querySelectorAll`. An additional options object can be provided which
14551
 * can be used to limit the total amount of items to be collected.
14552
 *
14553
 * ```js
14554
 * query('div', [
14555
 *   animate(...),
14556
 *   animate(...)
14557
 * ], { limit: 1 })
14558
 * ```
14559
 *
14560
 * query(), by default, will throw an error when zero items are found. If a query
14561
 * has the `optional` flag set to true then this error will be ignored.
14562
 *
14563
 * ```js
14564
 * query('.some-element-that-may-not-be-there', [
14565
 *   animate(...),
14566
 *   animate(...)
14567
 * ], { optional: true })
14568
 * ```
14569
 *
14570
 * ### Special Selector Values
14571
 *
14572
 * The selector value within a query can collect elements that contain angular-specific
14573
 * characteristics
14574
 * using special pseudo-selectors tokens.
14575
 *
14576
 * These include:
14577
 *
14578
 *  - Querying for newly inserted/removed elements using `query(":enter")`/`query(":leave")`
14579
 *  - Querying all currently animating elements using `query(":animating")`
14580
 *  - Querying elements that contain an animation trigger using `query("\@triggerName")`
14581
 *  - Querying all elements that contain an animation triggers using `query("\@*")`
14582
 *  - Including the current element into the animation sequence using `query(":self")`
14583
 *
14584
 *
14585
 *  Each of these pseudo-selector tokens can be merged together into a combined query selector
14586
 * string:
14587
 *
14588
 *  ```
14589
 *  query(':self, .record:enter, .record:leave, \@subTrigger', [...])
14590
 *  ```
14591
 *
14592
 * ### Demo
14593
 *
14594
 * ```
14595
 * \@Component({
14596
 *   selector: 'inner',
14597
 *   template: `
14598
 *     <div [\@queryAnimation]="exp">
14599
 *       <h1>Title</h1>
14600
 *       <div class="content">
14601
 *         Blah blah blah
14602
 *       </div>
14603
 *     </div>
14604
 *   `,
14605
 *   animations: [
14606
 *    trigger('queryAnimation', [
14607
 *      transition('* => goAnimate', [
14608
 *        // hide the inner elements
14609
 *        query('h1', style({ opacity: 0 })),
14610
 *        query('.content', style({ opacity: 0 })),
14611
 *
14612
 *        // animate the inner elements in, one by one
14613
 *        query('h1', animate(1000, style({ opacity: 1 })),
14614
 *        query('.content', animate(1000, style({ opacity: 1 })),
14615
 *      ])
14616
 *    ])
14617
 *  ]
14618
 * })
14619
 * class Cmp {
14620
 *   exp = '';
14621
 *
14622
 *   goAnimate() {
14623
 *     this.exp = 'goAnimate';
14624
 *   }
14625
 * }
14626
 * ```
14627
 *
14628
 * \@experimental Animation support is experimental.
14629
 * @param {?} selector
14630
 * @param {?} animation
14631
 * @param {?=} options
14632
 * @return {?}
14633
 */
14634
/**
14635
 * `stagger` is an animation-specific function that is designed to be used inside of Angular's
14636
 * animation DSL language. It is designed to be used inside of an animation {\@link query query()}
14637
 * and works by issuing a timing gap between after each queried item is animated.
14638
 *
14639
 * ### Usage
14640
 *
14641
 * In the example below there is a container element that wraps a list of items stamped out
14642
 * by an ngFor. The container element contains an animation trigger that will later be set
14643
 * to query for each of the inner items.
14644
 *
14645
 * ```html
14646
 * <!-- list.component.html -->
14647
 * <button (click)="toggle()">Show / Hide Items</button>
14648
 * <hr />
14649
 * <div [\@listAnimation]="items.length">
14650
 *   <div *ngFor="let item of items">
14651
 *     {{ item }}
14652
 *   </div>
14653
 * </div>
14654
 * ```
14655
 *
14656
 * The component code for this looks as such:
14657
 *
14658
 * ```ts
14659
 * import {trigger, transition, style, animate, query, stagger} from '\@angular/animations';
14660
 * \@Component({
14661
 *   templateUrl: 'list.component.html',
14662
 *   animations: [
14663
 *     trigger('listAnimation', [
14664
 *        //...
14665
 *     ])
14666
 *   ]
14667
 * })
14668
 * class ListComponent {
14669
 *   items = [];
14670
 *
14671
 *   showItems() {
14672
 *     this.items = [0,1,2,3,4];
14673
 *   }
14674
 *
14675
 *   hideItems() {
14676
 *     this.items = [];
14677
 *   }
14678
 *
14679
 *   toggle() {
14680
 *     this.items.length ? this.hideItems() : this.showItems();
14681
 *   }
14682
 * }
14683
 * ```
14684
 *
14685
 * And now for the animation trigger code:
14686
 *
14687
 * ```ts
14688
 * trigger('listAnimation', [
14689
 *   transition('* => *', [ // each time the binding value changes
14690
 *     query(':leave', [
14691
 *       stagger(100, [
14692
 *         animate('0.5s', style({ opacity: 0 }))
14693
 *       ])
14694
 *     ]),
14695
 *     query(':enter', [
14696
 *       style({ opacity: 0 }),
14697
 *       stagger(100, [
14698
 *         animate('0.5s', style({ opacity: 1 }))
14699
 *       ])
14700
 *     ])
14701
 *   ])
14702
 * ])
14703
 * ```
14704
 *
14705
 * Now each time the items are added/removed then either the opacity
14706
 * fade-in animation will run or each removed item will be faded out.
14707
 * When either of these animations occur then a stagger effect will be
14708
 * applied after each item's animation is started.
14709
 *
14710
 * \@experimental Animation support is experimental.
14711
 * @param {?} timings
14712
 * @param {?} animation
14713
 * @return {?}
14714
 */
14715
/**
14716
 * @license
14717
 * Copyright Google Inc. All Rights Reserved.
14718
 *
14719
 * Use of this source code is governed by an MIT-style license that can be
14720
 * found in the LICENSE file at https://angular.io/license
14721
 */
14722
/**
14723
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14724
 */
14725
var AUTO_STYLE$$1 = '*';
14726
/**
14727
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14728
 * @param {?} name
14729
 * @param {?} definitions
14730
 * @return {?}
14731
 */
14732
function trigger$$1(name, definitions) {
14733
    return trigger$1(name, definitions);
14734
}
14735
/**
14736
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14737
 * @param {?} timings
14738
 * @param {?=} styles
14739
 * @return {?}
14740
 */
14741
function animate$$1(timings, styles) {
14742
    return animate$1(timings, styles);
14743
}
14744
/**
14745
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14746
 * @param {?} steps
14747
 * @return {?}
14748
 */
14749
function group$$1(steps) {
14750
    return group$1(steps);
14751
}
14752
/**
14753
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14754
 * @param {?} steps
14755
 * @return {?}
14756
 */
14757
function sequence$$1(steps) {
14758
    return sequence$1(steps);
14759
}
14760
/**
14761
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14762
 * @param {?} tokens
14763
 * @return {?}
14764
 */
14765
function style$$1(tokens) {
14766
    return style$1(tokens);
14767
}
14768
/**
14769
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14770
 * @param {?} name
14771
 * @param {?} styles
14772
 * @return {?}
14773
 */
14774
function state$$1(name, styles) {
14775
    return state$1(name, styles);
14776
}
14777
/**
14778
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14779
 * @param {?} steps
14780
 * @return {?}
14781
 */
14782
function keyframes$$1(steps) {
14783
    return keyframes$1(steps);
14784
}
14785
/**
14786
 * @deprecated This symbol has moved. Please Import from \@angular/animations instead!
14787
 * @param {?} stateChangeExpr
14788
 * @param {?} steps
14789
 * @return {?}
14790
 */
14791
function transition$$1(stateChangeExpr, steps) {
14792
    return transition$1(stateChangeExpr, steps);
14793
}
14794
/**
14795
 * @license
14796
 * Copyright Google Inc. All Rights Reserved.
14797
 *
14798
 * Use of this source code is governed by an MIT-style license that can be
14799
 * found in the LICENSE file at https://angular.io/license
14800
 */
14801
/**
14802
 * @module
14803
 * @description
14804
 * Entry point from which you should import all public core APIs.
14805
 */
14806
/**
14807
 * @license
14808
 * Copyright Google Inc. All Rights Reserved.
14809
 *
14810
 * Use of this source code is governed by an MIT-style license that can be
14811
 * found in the LICENSE file at https://angular.io/license
14812
 */
14813
/**
14814
 * @module
14815
 * @description
14816
 * Entry point for all public APIs of the core package.
14817
 */
14818
// This file only reexports content of the `src` folder. Keep it that way.
14819
/**
14820
 * Generated bundle index. Do not edit.
14821
 */
14822
export { Class, createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken, APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER, APP_INITIALIZER, ApplicationInitStatus, DebugElement, DebugNode, asNativeElements, getDebugNode, Testability, TestabilityRegistry, setTestabilityGetter, TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID, MissingTranslationStrategy, ApplicationModule, wtfCreateScope, wtfLeave, wtfStartTimeRange, wtfEndTimeRange, Type, EventEmitter, ErrorHandler, Sanitizer, SecurityContext, ANALYZE_FOR_ENTRY_COMPONENTS, Attribute, ContentChild, ContentChildren, Query, ViewChild, ViewChildren, Component, Directive, HostBinding, HostListener, Input, Output, Pipe, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, ViewEncapsulation, Version, VERSION, forwardRef, resolveForwardRef, Injector, ReflectiveInjector, ResolvedReflectiveFactory, ReflectiveKey, InjectionToken, OpaqueToken, Inject, Optional, Injectable, Self, SkipSelf, Host, NgZone, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererStyleFlags2, RootRenderer, COMPILER_OPTIONS, Compiler, CompilerFactory, ModuleWithComponentFactories, ComponentFactory, ComponentRef, ComponentFactoryResolver, ElementRef, NgModuleFactory, NgModuleRef, NgModuleFactoryLoader, getModuleFactory, QueryList, SystemJsNgModuleLoader, SystemJsNgModuleLoaderConfig, TemplateRef, ViewContainerRef, EmbeddedViewRef, ViewRef, ChangeDetectionStrategy, ChangeDetectorRef, DefaultIterableDiffer, IterableDiffers, KeyValueDiffers, SimpleChange, WrappedValue, platformCore, ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER, ValueUnwrapper as ɵValueUnwrapper, devModeEqual as ɵdevModeEqual, isListLikeIterable as ɵisListLikeIterable, ChangeDetectorStatus as ɵChangeDetectorStatus, isDefaultChangeDetectionStrategy as ɵisDefaultChangeDetectionStrategy, Console as ɵConsole, ERROR_COMPONENT_TYPE as ɵERROR_COMPONENT_TYPE, ComponentFactory as ɵComponentFactory, CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver, ViewMetadata as ɵViewMetadata, ReflectionCapabilities as ɵReflectionCapabilities, RenderDebugInfo as ɵRenderDebugInfo, _global as ɵglobal, looseIdentical as ɵlooseIdentical, stringify as ɵstringify, makeDecorator as ɵmakeDecorator, isObservable as ɵisObservable, isPromise as ɵisPromise, clearProviderOverrides as ɵclearProviderOverrides, overrideProvider as ɵoverrideProvider, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, registerModuleFactory as ɵregisterModuleFactory, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, anchorDef as ɵand, createComponentFactory as ɵccf, createNgModuleFactory as ɵcmf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, moduleDef as ɵmod, moduleProvideDef as ɵmpd, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid, AUTO_STYLE$$1 as AUTO_STYLE, trigger$$1 as trigger, animate$$1 as animate, group$$1 as group, sequence$$1 as sequence, style$$1 as style, state$$1 as state, keyframes$$1 as keyframes, transition$$1 as transition, animate$1 as ɵx, group$1 as ɵy, keyframes$1 as ɵbc, sequence$1 as ɵz, state$1 as ɵbb, style$1 as ɵba, transition$1 as ɵbd, trigger$1 as ɵw, _iterableDiffersFactory as ɵk, _keyValueDiffersFactory as ɵl, _localeFactory as ɵm, ApplicationRef_ as ɵe, _appIdRandomProviderFactory as ɵf, defaultIterableDiffers as ɵg, defaultKeyValueDiffers as ɵh, DefaultIterableDifferFactory as ɵi, DefaultKeyValueDifferFactory as ɵj, ReflectiveInjector_ as ɵb, ReflectiveDependency as ɵc, resolveReflectiveProviders as ɵd, wtfEnabled as ɵn, createScope$1 as ɵp, detectWTF as ɵo, endTimeRange as ɵs, leave as ɵq, startTimeRange as ɵr, makeParamDecorator as ɵa, _def as ɵt, DebugContext as ɵu };
14823
//# sourceMappingURL=core.es5.js.map