UNPKG

145 kBJavaScriptView Raw
1/**
2 * @license Angular v8.2.14
3 * (c) 2010-2019 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { ɵparseCookieValue, PlatformLocation, DOCUMENT, isPlatformServer, ɵPLATFORM_BROWSER_ID, CommonModule } from '@angular/common';
8import { ɵglobal, Injectable, Inject, InjectionToken, ApplicationInitStatus, APP_INITIALIZER, Injector, setTestabilityGetter, ApplicationRef, NgZone, getDebugNode, NgProbeToken, Optional, ViewEncapsulation, APP_ID, RendererStyleFlags2, PLATFORM_ID, ɵConsole, SecurityContext, ɵ_sanitizeHtml, ɵ_sanitizeStyle, ɵ_sanitizeUrl, PLATFORM_INITIALIZER, Sanitizer, createPlatformFactory, platformCore, ErrorHandler, ɵAPP_ROOT, RendererFactory2, Testability, NgModule, ApplicationModule, SkipSelf, ɵɵinject, ɵɵdefineInjectable, Version } from '@angular/core';
9
10/**
11 * @fileoverview added by tsickle
12 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
13 */
14/**
15 * @license
16 * Copyright Google Inc. All Rights Reserved.
17 *
18 * Use of this source code is governed by an MIT-style license that can be
19 * found in the LICENSE file at https://angular.io/license
20 */
21/** @type {?} */
22let _DOM = (/** @type {?} */ (null));
23/**
24 * @return {?}
25 */
26function getDOM() {
27 return _DOM;
28}
29/**
30 * @param {?} adapter
31 * @return {?}
32 */
33function setDOM(adapter) {
34 _DOM = adapter;
35}
36/**
37 * @param {?} adapter
38 * @return {?}
39 */
40function setRootDomAdapter(adapter) {
41 if (!_DOM) {
42 _DOM = adapter;
43 }
44}
45/* tslint:disable:requireParameterType */
46/**
47 * Provides DOM operations in an environment-agnostic way.
48 *
49 * \@security Tread carefully! Interacting with the DOM directly is dangerous and
50 * can introduce XSS risks.
51 * @abstract
52 */
53class DomAdapter {
54 constructor() {
55 this.resourceLoaderType = (/** @type {?} */ (null));
56 }
57 /**
58 * Maps attribute names to their corresponding property names for cases
59 * where attribute name doesn't match property name.
60 * @return {?}
61 */
62 get attrToPropMap() { return this._attrToPropMap; }
63 /**
64 * @param {?} value
65 * @return {?}
66 */
67 set attrToPropMap(value) { this._attrToPropMap = value; }
68}
69if (false) {
70 /** @type {?} */
71 DomAdapter.prototype.resourceLoaderType;
72 /**
73 * \@internal
74 * @type {?}
75 */
76 DomAdapter.prototype._attrToPropMap;
77 /**
78 * @abstract
79 * @param {?} element
80 * @param {?} name
81 * @return {?}
82 */
83 DomAdapter.prototype.hasProperty = function (element, name) { };
84 /**
85 * @abstract
86 * @param {?} el
87 * @param {?} name
88 * @param {?} value
89 * @return {?}
90 */
91 DomAdapter.prototype.setProperty = function (el, name, value) { };
92 /**
93 * @abstract
94 * @param {?} el
95 * @param {?} name
96 * @return {?}
97 */
98 DomAdapter.prototype.getProperty = function (el, name) { };
99 /**
100 * @abstract
101 * @param {?} el
102 * @param {?} methodName
103 * @param {?} args
104 * @return {?}
105 */
106 DomAdapter.prototype.invoke = function (el, methodName, args) { };
107 /**
108 * @abstract
109 * @param {?} error
110 * @return {?}
111 */
112 DomAdapter.prototype.logError = function (error) { };
113 /**
114 * @abstract
115 * @param {?} error
116 * @return {?}
117 */
118 DomAdapter.prototype.log = function (error) { };
119 /**
120 * @abstract
121 * @param {?} error
122 * @return {?}
123 */
124 DomAdapter.prototype.logGroup = function (error) { };
125 /**
126 * @abstract
127 * @return {?}
128 */
129 DomAdapter.prototype.logGroupEnd = function () { };
130 /**
131 * @abstract
132 * @param {?} nodeA
133 * @param {?} nodeB
134 * @return {?}
135 */
136 DomAdapter.prototype.contains = function (nodeA, nodeB) { };
137 /**
138 * @abstract
139 * @param {?} templateHtml
140 * @return {?}
141 */
142 DomAdapter.prototype.parse = function (templateHtml) { };
143 /**
144 * @abstract
145 * @param {?} el
146 * @param {?} selector
147 * @return {?}
148 */
149 DomAdapter.prototype.querySelector = function (el, selector) { };
150 /**
151 * @abstract
152 * @param {?} el
153 * @param {?} selector
154 * @return {?}
155 */
156 DomAdapter.prototype.querySelectorAll = function (el, selector) { };
157 /**
158 * @abstract
159 * @param {?} el
160 * @param {?} evt
161 * @param {?} listener
162 * @return {?}
163 */
164 DomAdapter.prototype.on = function (el, evt, listener) { };
165 /**
166 * @abstract
167 * @param {?} el
168 * @param {?} evt
169 * @param {?} listener
170 * @return {?}
171 */
172 DomAdapter.prototype.onAndCancel = function (el, evt, listener) { };
173 /**
174 * @abstract
175 * @param {?} el
176 * @param {?} evt
177 * @return {?}
178 */
179 DomAdapter.prototype.dispatchEvent = function (el, evt) { };
180 /**
181 * @abstract
182 * @param {?} eventType
183 * @return {?}
184 */
185 DomAdapter.prototype.createMouseEvent = function (eventType) { };
186 /**
187 * @abstract
188 * @param {?} eventType
189 * @return {?}
190 */
191 DomAdapter.prototype.createEvent = function (eventType) { };
192 /**
193 * @abstract
194 * @param {?} evt
195 * @return {?}
196 */
197 DomAdapter.prototype.preventDefault = function (evt) { };
198 /**
199 * @abstract
200 * @param {?} evt
201 * @return {?}
202 */
203 DomAdapter.prototype.isPrevented = function (evt) { };
204 /**
205 * @abstract
206 * @param {?} el
207 * @return {?}
208 */
209 DomAdapter.prototype.getInnerHTML = function (el) { };
210 /**
211 * Returns content if el is a <template> element, null otherwise.
212 * @abstract
213 * @param {?} el
214 * @return {?}
215 */
216 DomAdapter.prototype.getTemplateContent = function (el) { };
217 /**
218 * @abstract
219 * @param {?} el
220 * @return {?}
221 */
222 DomAdapter.prototype.getOuterHTML = function (el) { };
223 /**
224 * @abstract
225 * @param {?} node
226 * @return {?}
227 */
228 DomAdapter.prototype.nodeName = function (node) { };
229 /**
230 * @abstract
231 * @param {?} node
232 * @return {?}
233 */
234 DomAdapter.prototype.nodeValue = function (node) { };
235 /**
236 * @abstract
237 * @param {?} node
238 * @return {?}
239 */
240 DomAdapter.prototype.type = function (node) { };
241 /**
242 * @abstract
243 * @param {?} node
244 * @return {?}
245 */
246 DomAdapter.prototype.content = function (node) { };
247 /**
248 * @abstract
249 * @param {?} el
250 * @return {?}
251 */
252 DomAdapter.prototype.firstChild = function (el) { };
253 /**
254 * @abstract
255 * @param {?} el
256 * @return {?}
257 */
258 DomAdapter.prototype.nextSibling = function (el) { };
259 /**
260 * @abstract
261 * @param {?} el
262 * @return {?}
263 */
264 DomAdapter.prototype.parentElement = function (el) { };
265 /**
266 * @abstract
267 * @param {?} el
268 * @return {?}
269 */
270 DomAdapter.prototype.childNodes = function (el) { };
271 /**
272 * @abstract
273 * @param {?} el
274 * @return {?}
275 */
276 DomAdapter.prototype.childNodesAsList = function (el) { };
277 /**
278 * @abstract
279 * @param {?} el
280 * @return {?}
281 */
282 DomAdapter.prototype.clearNodes = function (el) { };
283 /**
284 * @abstract
285 * @param {?} el
286 * @param {?} node
287 * @return {?}
288 */
289 DomAdapter.prototype.appendChild = function (el, node) { };
290 /**
291 * @abstract
292 * @param {?} el
293 * @param {?} node
294 * @return {?}
295 */
296 DomAdapter.prototype.removeChild = function (el, node) { };
297 /**
298 * @abstract
299 * @param {?} el
300 * @param {?} newNode
301 * @param {?} oldNode
302 * @return {?}
303 */
304 DomAdapter.prototype.replaceChild = function (el, newNode, oldNode) { };
305 /**
306 * @abstract
307 * @param {?} el
308 * @return {?}
309 */
310 DomAdapter.prototype.remove = function (el) { };
311 /**
312 * @abstract
313 * @param {?} parent
314 * @param {?} ref
315 * @param {?} node
316 * @return {?}
317 */
318 DomAdapter.prototype.insertBefore = function (parent, ref, node) { };
319 /**
320 * @abstract
321 * @param {?} parent
322 * @param {?} ref
323 * @param {?} nodes
324 * @return {?}
325 */
326 DomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) { };
327 /**
328 * @abstract
329 * @param {?} parent
330 * @param {?} el
331 * @param {?} node
332 * @return {?}
333 */
334 DomAdapter.prototype.insertAfter = function (parent, el, node) { };
335 /**
336 * @abstract
337 * @param {?} el
338 * @param {?} value
339 * @return {?}
340 */
341 DomAdapter.prototype.setInnerHTML = function (el, value) { };
342 /**
343 * @abstract
344 * @param {?} el
345 * @return {?}
346 */
347 DomAdapter.prototype.getText = function (el) { };
348 /**
349 * @abstract
350 * @param {?} el
351 * @param {?} value
352 * @return {?}
353 */
354 DomAdapter.prototype.setText = function (el, value) { };
355 /**
356 * @abstract
357 * @param {?} el
358 * @return {?}
359 */
360 DomAdapter.prototype.getValue = function (el) { };
361 /**
362 * @abstract
363 * @param {?} el
364 * @param {?} value
365 * @return {?}
366 */
367 DomAdapter.prototype.setValue = function (el, value) { };
368 /**
369 * @abstract
370 * @param {?} el
371 * @return {?}
372 */
373 DomAdapter.prototype.getChecked = function (el) { };
374 /**
375 * @abstract
376 * @param {?} el
377 * @param {?} value
378 * @return {?}
379 */
380 DomAdapter.prototype.setChecked = function (el, value) { };
381 /**
382 * @abstract
383 * @param {?} text
384 * @return {?}
385 */
386 DomAdapter.prototype.createComment = function (text) { };
387 /**
388 * @abstract
389 * @param {?} html
390 * @return {?}
391 */
392 DomAdapter.prototype.createTemplate = function (html) { };
393 /**
394 * @abstract
395 * @param {?} tagName
396 * @param {?=} doc
397 * @return {?}
398 */
399 DomAdapter.prototype.createElement = function (tagName, doc) { };
400 /**
401 * @abstract
402 * @param {?} ns
403 * @param {?} tagName
404 * @param {?=} doc
405 * @return {?}
406 */
407 DomAdapter.prototype.createElementNS = function (ns, tagName, doc) { };
408 /**
409 * @abstract
410 * @param {?} text
411 * @param {?=} doc
412 * @return {?}
413 */
414 DomAdapter.prototype.createTextNode = function (text, doc) { };
415 /**
416 * @abstract
417 * @param {?} attrName
418 * @param {?} attrValue
419 * @param {?=} doc
420 * @return {?}
421 */
422 DomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) { };
423 /**
424 * @abstract
425 * @param {?} css
426 * @param {?=} doc
427 * @return {?}
428 */
429 DomAdapter.prototype.createStyleElement = function (css, doc) { };
430 /**
431 * @abstract
432 * @param {?} el
433 * @return {?}
434 */
435 DomAdapter.prototype.createShadowRoot = function (el) { };
436 /**
437 * @abstract
438 * @param {?} el
439 * @return {?}
440 */
441 DomAdapter.prototype.getShadowRoot = function (el) { };
442 /**
443 * @abstract
444 * @param {?} el
445 * @return {?}
446 */
447 DomAdapter.prototype.getHost = function (el) { };
448 /**
449 * @abstract
450 * @param {?} el
451 * @return {?}
452 */
453 DomAdapter.prototype.getDistributedNodes = function (el) { };
454 /**
455 * @abstract
456 * @param {?} node
457 * @return {?}
458 */
459 DomAdapter.prototype.clone = function (node) { };
460 /**
461 * @abstract
462 * @param {?} element
463 * @param {?} name
464 * @return {?}
465 */
466 DomAdapter.prototype.getElementsByClassName = function (element, name) { };
467 /**
468 * @abstract
469 * @param {?} element
470 * @param {?} name
471 * @return {?}
472 */
473 DomAdapter.prototype.getElementsByTagName = function (element, name) { };
474 /**
475 * @abstract
476 * @param {?} element
477 * @return {?}
478 */
479 DomAdapter.prototype.classList = function (element) { };
480 /**
481 * @abstract
482 * @param {?} element
483 * @param {?} className
484 * @return {?}
485 */
486 DomAdapter.prototype.addClass = function (element, className) { };
487 /**
488 * @abstract
489 * @param {?} element
490 * @param {?} className
491 * @return {?}
492 */
493 DomAdapter.prototype.removeClass = function (element, className) { };
494 /**
495 * @abstract
496 * @param {?} element
497 * @param {?} className
498 * @return {?}
499 */
500 DomAdapter.prototype.hasClass = function (element, className) { };
501 /**
502 * @abstract
503 * @param {?} element
504 * @param {?} styleName
505 * @param {?} styleValue
506 * @return {?}
507 */
508 DomAdapter.prototype.setStyle = function (element, styleName, styleValue) { };
509 /**
510 * @abstract
511 * @param {?} element
512 * @param {?} styleName
513 * @return {?}
514 */
515 DomAdapter.prototype.removeStyle = function (element, styleName) { };
516 /**
517 * @abstract
518 * @param {?} element
519 * @param {?} styleName
520 * @return {?}
521 */
522 DomAdapter.prototype.getStyle = function (element, styleName) { };
523 /**
524 * @abstract
525 * @param {?} element
526 * @param {?} styleName
527 * @param {?=} styleValue
528 * @return {?}
529 */
530 DomAdapter.prototype.hasStyle = function (element, styleName, styleValue) { };
531 /**
532 * @abstract
533 * @param {?} element
534 * @return {?}
535 */
536 DomAdapter.prototype.tagName = function (element) { };
537 /**
538 * @abstract
539 * @param {?} element
540 * @return {?}
541 */
542 DomAdapter.prototype.attributeMap = function (element) { };
543 /**
544 * @abstract
545 * @param {?} element
546 * @param {?} attribute
547 * @return {?}
548 */
549 DomAdapter.prototype.hasAttribute = function (element, attribute) { };
550 /**
551 * @abstract
552 * @param {?} element
553 * @param {?} ns
554 * @param {?} attribute
555 * @return {?}
556 */
557 DomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) { };
558 /**
559 * @abstract
560 * @param {?} element
561 * @param {?} attribute
562 * @return {?}
563 */
564 DomAdapter.prototype.getAttribute = function (element, attribute) { };
565 /**
566 * @abstract
567 * @param {?} element
568 * @param {?} ns
569 * @param {?} attribute
570 * @return {?}
571 */
572 DomAdapter.prototype.getAttributeNS = function (element, ns, attribute) { };
573 /**
574 * @abstract
575 * @param {?} element
576 * @param {?} name
577 * @param {?} value
578 * @return {?}
579 */
580 DomAdapter.prototype.setAttribute = function (element, name, value) { };
581 /**
582 * @abstract
583 * @param {?} element
584 * @param {?} ns
585 * @param {?} name
586 * @param {?} value
587 * @return {?}
588 */
589 DomAdapter.prototype.setAttributeNS = function (element, ns, name, value) { };
590 /**
591 * @abstract
592 * @param {?} element
593 * @param {?} attribute
594 * @return {?}
595 */
596 DomAdapter.prototype.removeAttribute = function (element, attribute) { };
597 /**
598 * @abstract
599 * @param {?} element
600 * @param {?} ns
601 * @param {?} attribute
602 * @return {?}
603 */
604 DomAdapter.prototype.removeAttributeNS = function (element, ns, attribute) { };
605 /**
606 * @abstract
607 * @param {?} el
608 * @return {?}
609 */
610 DomAdapter.prototype.templateAwareRoot = function (el) { };
611 /**
612 * @abstract
613 * @return {?}
614 */
615 DomAdapter.prototype.createHtmlDocument = function () { };
616 /**
617 * @abstract
618 * @return {?}
619 */
620 DomAdapter.prototype.getDefaultDocument = function () { };
621 /**
622 * @abstract
623 * @param {?} el
624 * @return {?}
625 */
626 DomAdapter.prototype.getBoundingClientRect = function (el) { };
627 /**
628 * @abstract
629 * @param {?} doc
630 * @return {?}
631 */
632 DomAdapter.prototype.getTitle = function (doc) { };
633 /**
634 * @abstract
635 * @param {?} doc
636 * @param {?} newTitle
637 * @return {?}
638 */
639 DomAdapter.prototype.setTitle = function (doc, newTitle) { };
640 /**
641 * @abstract
642 * @param {?} n
643 * @param {?} selector
644 * @return {?}
645 */
646 DomAdapter.prototype.elementMatches = function (n, selector) { };
647 /**
648 * @abstract
649 * @param {?} el
650 * @return {?}
651 */
652 DomAdapter.prototype.isTemplateElement = function (el) { };
653 /**
654 * @abstract
655 * @param {?} node
656 * @return {?}
657 */
658 DomAdapter.prototype.isTextNode = function (node) { };
659 /**
660 * @abstract
661 * @param {?} node
662 * @return {?}
663 */
664 DomAdapter.prototype.isCommentNode = function (node) { };
665 /**
666 * @abstract
667 * @param {?} node
668 * @return {?}
669 */
670 DomAdapter.prototype.isElementNode = function (node) { };
671 /**
672 * @abstract
673 * @param {?} node
674 * @return {?}
675 */
676 DomAdapter.prototype.hasShadowRoot = function (node) { };
677 /**
678 * @abstract
679 * @param {?} node
680 * @return {?}
681 */
682 DomAdapter.prototype.isShadowRoot = function (node) { };
683 /**
684 * @abstract
685 * @param {?} node
686 * @return {?}
687 */
688 DomAdapter.prototype.importIntoDoc = function (node) { };
689 /**
690 * @abstract
691 * @param {?} node
692 * @return {?}
693 */
694 DomAdapter.prototype.adoptNode = function (node) { };
695 /**
696 * @abstract
697 * @param {?} element
698 * @return {?}
699 */
700 DomAdapter.prototype.getHref = function (element) { };
701 /**
702 * @abstract
703 * @param {?} event
704 * @return {?}
705 */
706 DomAdapter.prototype.getEventKey = function (event) { };
707 /**
708 * @abstract
709 * @param {?} element
710 * @param {?} baseUrl
711 * @param {?} href
712 * @return {?}
713 */
714 DomAdapter.prototype.resolveAndSetHref = function (element, baseUrl, href) { };
715 /**
716 * @abstract
717 * @return {?}
718 */
719 DomAdapter.prototype.supportsDOMEvents = function () { };
720 /**
721 * @abstract
722 * @return {?}
723 */
724 DomAdapter.prototype.supportsNativeShadowDOM = function () { };
725 /**
726 * @abstract
727 * @param {?} doc
728 * @param {?} target
729 * @return {?}
730 */
731 DomAdapter.prototype.getGlobalEventTarget = function (doc, target) { };
732 /**
733 * @abstract
734 * @return {?}
735 */
736 DomAdapter.prototype.getHistory = function () { };
737 /**
738 * @abstract
739 * @return {?}
740 */
741 DomAdapter.prototype.getLocation = function () { };
742 /**
743 * @abstract
744 * @param {?} doc
745 * @return {?}
746 */
747 DomAdapter.prototype.getBaseHref = function (doc) { };
748 /**
749 * @abstract
750 * @return {?}
751 */
752 DomAdapter.prototype.resetBaseElement = function () { };
753 /**
754 * @abstract
755 * @return {?}
756 */
757 DomAdapter.prototype.getUserAgent = function () { };
758 /**
759 * @abstract
760 * @param {?} element
761 * @param {?} name
762 * @param {?} value
763 * @return {?}
764 */
765 DomAdapter.prototype.setData = function (element, name, value) { };
766 /**
767 * @abstract
768 * @param {?} element
769 * @return {?}
770 */
771 DomAdapter.prototype.getComputedStyle = function (element) { };
772 /**
773 * @abstract
774 * @param {?} element
775 * @param {?} name
776 * @return {?}
777 */
778 DomAdapter.prototype.getData = function (element, name) { };
779 /**
780 * @abstract
781 * @return {?}
782 */
783 DomAdapter.prototype.supportsWebAnimation = function () { };
784 /**
785 * @abstract
786 * @return {?}
787 */
788 DomAdapter.prototype.performanceNow = function () { };
789 /**
790 * @abstract
791 * @return {?}
792 */
793 DomAdapter.prototype.getAnimationPrefix = function () { };
794 /**
795 * @abstract
796 * @return {?}
797 */
798 DomAdapter.prototype.getTransitionEnd = function () { };
799 /**
800 * @abstract
801 * @return {?}
802 */
803 DomAdapter.prototype.supportsAnimation = function () { };
804 /**
805 * @abstract
806 * @return {?}
807 */
808 DomAdapter.prototype.supportsCookies = function () { };
809 /**
810 * @abstract
811 * @param {?} name
812 * @return {?}
813 */
814 DomAdapter.prototype.getCookie = function (name) { };
815 /**
816 * @abstract
817 * @param {?} name
818 * @param {?} value
819 * @return {?}
820 */
821 DomAdapter.prototype.setCookie = function (name, value) { };
822}
823
824/**
825 * @fileoverview added by tsickle
826 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
827 */
828/**
829 * Provides DOM operations in any browser environment.
830 *
831 * \@security Tread carefully! Interacting with the DOM directly is dangerous and
832 * can introduce XSS risks.
833 * @abstract
834 */
835class GenericBrowserDomAdapter extends DomAdapter {
836 constructor() {
837 super();
838 this._animationPrefix = null;
839 this._transitionEnd = null;
840 try {
841 /** @type {?} */
842 const element = this.createElement('div', document);
843 if (this.getStyle(element, 'animationName') != null) {
844 this._animationPrefix = '';
845 }
846 else {
847 /** @type {?} */
848 const domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
849 for (let i = 0; i < domPrefixes.length; i++) {
850 if (this.getStyle(element, domPrefixes[i] + 'AnimationName') != null) {
851 this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
852 break;
853 }
854 }
855 }
856 /** @type {?} */
857 const transEndEventNames = {
858 WebkitTransition: 'webkitTransitionEnd',
859 MozTransition: 'transitionend',
860 OTransition: 'oTransitionEnd otransitionend',
861 transition: 'transitionend'
862 };
863 Object.keys(transEndEventNames).forEach((/**
864 * @param {?} key
865 * @return {?}
866 */
867 (key) => {
868 if (this.getStyle(element, key) != null) {
869 this._transitionEnd = transEndEventNames[key];
870 }
871 }));
872 }
873 catch (_a) {
874 this._animationPrefix = null;
875 this._transitionEnd = null;
876 }
877 }
878 /**
879 * @param {?} el
880 * @return {?}
881 */
882 getDistributedNodes(el) { return ((/** @type {?} */ (el))).getDistributedNodes(); }
883 /**
884 * @param {?} el
885 * @param {?} baseUrl
886 * @param {?} href
887 * @return {?}
888 */
889 resolveAndSetHref(el, baseUrl, href) {
890 el.href = href == null ? baseUrl : baseUrl + '/../' + href;
891 }
892 /**
893 * @return {?}
894 */
895 supportsDOMEvents() { return true; }
896 /**
897 * @return {?}
898 */
899 supportsNativeShadowDOM() {
900 return typeof ((/** @type {?} */ (document.body))).createShadowRoot === 'function';
901 }
902 /**
903 * @return {?}
904 */
905 getAnimationPrefix() { return this._animationPrefix ? this._animationPrefix : ''; }
906 /**
907 * @return {?}
908 */
909 getTransitionEnd() { return this._transitionEnd ? this._transitionEnd : ''; }
910 /**
911 * @return {?}
912 */
913 supportsAnimation() {
914 return this._animationPrefix != null && this._transitionEnd != null;
915 }
916}
917if (false) {
918 /**
919 * @type {?}
920 * @private
921 */
922 GenericBrowserDomAdapter.prototype._animationPrefix;
923 /**
924 * @type {?}
925 * @private
926 */
927 GenericBrowserDomAdapter.prototype._transitionEnd;
928}
929
930/**
931 * @fileoverview added by tsickle
932 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
933 */
934/** @type {?} */
935const _attrToPropMap = {
936 'class': 'className',
937 'innerHtml': 'innerHTML',
938 'readonly': 'readOnly',
939 'tabindex': 'tabIndex',
940};
941/** @type {?} */
942const DOM_KEY_LOCATION_NUMPAD = 3;
943// Map to convert some key or keyIdentifier values to what will be returned by getEventKey
944/** @type {?} */
945const _keyMap = {
946 // The following values are here for cross-browser compatibility and to match the W3C standard
947 // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
948 '\b': 'Backspace',
949 '\t': 'Tab',
950 '\x7F': 'Delete',
951 '\x1B': 'Escape',
952 'Del': 'Delete',
953 'Esc': 'Escape',
954 'Left': 'ArrowLeft',
955 'Right': 'ArrowRight',
956 'Up': 'ArrowUp',
957 'Down': 'ArrowDown',
958 'Menu': 'ContextMenu',
959 'Scroll': 'ScrollLock',
960 'Win': 'OS'
961};
962// There is a bug in Chrome for numeric keypad keys:
963// https://code.google.com/p/chromium/issues/detail?id=155654
964// 1, 2, 3 ... are reported as A, B, C ...
965/** @type {?} */
966const _chromeNumKeyPadMap = {
967 'A': '1',
968 'B': '2',
969 'C': '3',
970 'D': '4',
971 'E': '5',
972 'F': '6',
973 'G': '7',
974 'H': '8',
975 'I': '9',
976 'J': '*',
977 'K': '+',
978 'M': '-',
979 'N': '.',
980 'O': '/',
981 '\x60': '0',
982 '\x90': 'NumLock'
983};
984const ɵ0 = /**
985 * @return {?}
986 */
987() => {
988 if (ɵglobal['Node']) {
989 return ɵglobal['Node'].prototype.contains || (/**
990 * @this {?}
991 * @param {?} node
992 * @return {?}
993 */
994 function (node) {
995 return !!(this.compareDocumentPosition(node) & 16);
996 });
997 }
998 return (/** @type {?} */ (undefined));
999};
1000/** @type {?} */
1001const nodeContains = ((ɵ0))();
1002/**
1003 * A `DomAdapter` powered by full browser DOM APIs.
1004 *
1005 * \@security Tread carefully! Interacting with the DOM directly is dangerous and
1006 * can introduce XSS risks.
1007 */
1008/* tslint:disable:requireParameterType no-console */
1009class BrowserDomAdapter extends GenericBrowserDomAdapter {
1010 /**
1011 * @param {?} templateHtml
1012 * @return {?}
1013 */
1014 parse(templateHtml) { throw new Error('parse not implemented'); }
1015 /**
1016 * @return {?}
1017 */
1018 static makeCurrent() { setRootDomAdapter(new BrowserDomAdapter()); }
1019 /**
1020 * @param {?} element
1021 * @param {?} name
1022 * @return {?}
1023 */
1024 hasProperty(element, name) { return name in element; }
1025 /**
1026 * @param {?} el
1027 * @param {?} name
1028 * @param {?} value
1029 * @return {?}
1030 */
1031 setProperty(el, name, value) { ((/** @type {?} */ (el)))[name] = value; }
1032 /**
1033 * @param {?} el
1034 * @param {?} name
1035 * @return {?}
1036 */
1037 getProperty(el, name) { return ((/** @type {?} */ (el)))[name]; }
1038 /**
1039 * @param {?} el
1040 * @param {?} methodName
1041 * @param {?} args
1042 * @return {?}
1043 */
1044 invoke(el, methodName, args) { ((/** @type {?} */ (el)))[methodName](...args); }
1045 // TODO(tbosch): move this into a separate environment class once we have it
1046 /**
1047 * @param {?} error
1048 * @return {?}
1049 */
1050 logError(error) {
1051 if (window.console) {
1052 if (console.error) {
1053 console.error(error);
1054 }
1055 else {
1056 console.log(error);
1057 }
1058 }
1059 }
1060 /**
1061 * @param {?} error
1062 * @return {?}
1063 */
1064 log(error) {
1065 if (window.console) {
1066 window.console.log && window.console.log(error);
1067 }
1068 }
1069 /**
1070 * @param {?} error
1071 * @return {?}
1072 */
1073 logGroup(error) {
1074 if (window.console) {
1075 window.console.group && window.console.group(error);
1076 }
1077 }
1078 /**
1079 * @return {?}
1080 */
1081 logGroupEnd() {
1082 if (window.console) {
1083 window.console.groupEnd && window.console.groupEnd();
1084 }
1085 }
1086 /**
1087 * @return {?}
1088 */
1089 get attrToPropMap() { return _attrToPropMap; }
1090 /**
1091 * @param {?} nodeA
1092 * @param {?} nodeB
1093 * @return {?}
1094 */
1095 contains(nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); }
1096 /**
1097 * @param {?} el
1098 * @param {?} selector
1099 * @return {?}
1100 */
1101 querySelector(el, selector) { return el.querySelector(selector); }
1102 /**
1103 * @param {?} el
1104 * @param {?} selector
1105 * @return {?}
1106 */
1107 querySelectorAll(el, selector) { return el.querySelectorAll(selector); }
1108 /**
1109 * @param {?} el
1110 * @param {?} evt
1111 * @param {?} listener
1112 * @return {?}
1113 */
1114 on(el, evt, listener) { el.addEventListener(evt, listener, false); }
1115 /**
1116 * @param {?} el
1117 * @param {?} evt
1118 * @param {?} listener
1119 * @return {?}
1120 */
1121 onAndCancel(el, evt, listener) {
1122 el.addEventListener(evt, listener, false);
1123 // Needed to follow Dart's subscription semantic, until fix of
1124 // https://code.google.com/p/dart/issues/detail?id=17406
1125 return (/**
1126 * @return {?}
1127 */
1128 () => { el.removeEventListener(evt, listener, false); });
1129 }
1130 /**
1131 * @param {?} el
1132 * @param {?} evt
1133 * @return {?}
1134 */
1135 dispatchEvent(el, evt) { el.dispatchEvent(evt); }
1136 /**
1137 * @param {?} eventType
1138 * @return {?}
1139 */
1140 createMouseEvent(eventType) {
1141 /** @type {?} */
1142 const evt = this.getDefaultDocument().createEvent('MouseEvent');
1143 evt.initEvent(eventType, true, true);
1144 return evt;
1145 }
1146 /**
1147 * @param {?} eventType
1148 * @return {?}
1149 */
1150 createEvent(eventType) {
1151 /** @type {?} */
1152 const evt = this.getDefaultDocument().createEvent('Event');
1153 evt.initEvent(eventType, true, true);
1154 return evt;
1155 }
1156 /**
1157 * @param {?} evt
1158 * @return {?}
1159 */
1160 preventDefault(evt) {
1161 evt.preventDefault();
1162 evt.returnValue = false;
1163 }
1164 /**
1165 * @param {?} evt
1166 * @return {?}
1167 */
1168 isPrevented(evt) {
1169 return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
1170 }
1171 /**
1172 * @param {?} el
1173 * @return {?}
1174 */
1175 getInnerHTML(el) { return el.innerHTML; }
1176 /**
1177 * @param {?} el
1178 * @return {?}
1179 */
1180 getTemplateContent(el) {
1181 return 'content' in el && this.isTemplateElement(el) ? ((/** @type {?} */ (el))).content : null;
1182 }
1183 /**
1184 * @param {?} el
1185 * @return {?}
1186 */
1187 getOuterHTML(el) { return el.outerHTML; }
1188 /**
1189 * @param {?} node
1190 * @return {?}
1191 */
1192 nodeName(node) { return node.nodeName; }
1193 /**
1194 * @param {?} node
1195 * @return {?}
1196 */
1197 nodeValue(node) { return node.nodeValue; }
1198 /**
1199 * @param {?} node
1200 * @return {?}
1201 */
1202 type(node) { return node.type; }
1203 /**
1204 * @param {?} node
1205 * @return {?}
1206 */
1207 content(node) {
1208 if (this.hasProperty(node, 'content')) {
1209 return ((/** @type {?} */ (node))).content;
1210 }
1211 else {
1212 return node;
1213 }
1214 }
1215 /**
1216 * @param {?} el
1217 * @return {?}
1218 */
1219 firstChild(el) { return el.firstChild; }
1220 /**
1221 * @param {?} el
1222 * @return {?}
1223 */
1224 nextSibling(el) { return el.nextSibling; }
1225 /**
1226 * @param {?} el
1227 * @return {?}
1228 */
1229 parentElement(el) { return el.parentNode; }
1230 /**
1231 * @param {?} el
1232 * @return {?}
1233 */
1234 childNodes(el) { return el.childNodes; }
1235 /**
1236 * @param {?} el
1237 * @return {?}
1238 */
1239 childNodesAsList(el) {
1240 /** @type {?} */
1241 const childNodes = el.childNodes;
1242 /** @type {?} */
1243 const res = new Array(childNodes.length);
1244 for (let i = 0; i < childNodes.length; i++) {
1245 res[i] = childNodes[i];
1246 }
1247 return res;
1248 }
1249 /**
1250 * @param {?} el
1251 * @return {?}
1252 */
1253 clearNodes(el) {
1254 while (el.firstChild) {
1255 el.removeChild(el.firstChild);
1256 }
1257 }
1258 /**
1259 * @param {?} el
1260 * @param {?} node
1261 * @return {?}
1262 */
1263 appendChild(el, node) { el.appendChild(node); }
1264 /**
1265 * @param {?} el
1266 * @param {?} node
1267 * @return {?}
1268 */
1269 removeChild(el, node) { el.removeChild(node); }
1270 /**
1271 * @param {?} el
1272 * @param {?} newChild
1273 * @param {?} oldChild
1274 * @return {?}
1275 */
1276 replaceChild(el, newChild, oldChild) { el.replaceChild(newChild, oldChild); }
1277 /**
1278 * @param {?} node
1279 * @return {?}
1280 */
1281 remove(node) {
1282 if (node.parentNode) {
1283 node.parentNode.removeChild(node);
1284 }
1285 return node;
1286 }
1287 /**
1288 * @param {?} parent
1289 * @param {?} ref
1290 * @param {?} node
1291 * @return {?}
1292 */
1293 insertBefore(parent, ref, node) { parent.insertBefore(node, ref); }
1294 /**
1295 * @param {?} parent
1296 * @param {?} ref
1297 * @param {?} nodes
1298 * @return {?}
1299 */
1300 insertAllBefore(parent, ref, nodes) {
1301 nodes.forEach((/**
1302 * @param {?} n
1303 * @return {?}
1304 */
1305 (n) => parent.insertBefore(n, ref)));
1306 }
1307 /**
1308 * @param {?} parent
1309 * @param {?} ref
1310 * @param {?} node
1311 * @return {?}
1312 */
1313 insertAfter(parent, ref, node) { parent.insertBefore(node, ref.nextSibling); }
1314 /**
1315 * @param {?} el
1316 * @param {?} value
1317 * @return {?}
1318 */
1319 setInnerHTML(el, value) { el.innerHTML = value; }
1320 /**
1321 * @param {?} el
1322 * @return {?}
1323 */
1324 getText(el) { return el.textContent; }
1325 /**
1326 * @param {?} el
1327 * @param {?} value
1328 * @return {?}
1329 */
1330 setText(el, value) { el.textContent = value; }
1331 /**
1332 * @param {?} el
1333 * @return {?}
1334 */
1335 getValue(el) { return el.value; }
1336 /**
1337 * @param {?} el
1338 * @param {?} value
1339 * @return {?}
1340 */
1341 setValue(el, value) { el.value = value; }
1342 /**
1343 * @param {?} el
1344 * @return {?}
1345 */
1346 getChecked(el) { return el.checked; }
1347 /**
1348 * @param {?} el
1349 * @param {?} value
1350 * @return {?}
1351 */
1352 setChecked(el, value) { el.checked = value; }
1353 /**
1354 * @param {?} text
1355 * @return {?}
1356 */
1357 createComment(text) { return this.getDefaultDocument().createComment(text); }
1358 /**
1359 * @param {?} html
1360 * @return {?}
1361 */
1362 createTemplate(html) {
1363 /** @type {?} */
1364 const t = this.getDefaultDocument().createElement('template');
1365 t.innerHTML = html;
1366 return t;
1367 }
1368 /**
1369 * @param {?} tagName
1370 * @param {?=} doc
1371 * @return {?}
1372 */
1373 createElement(tagName, doc) {
1374 doc = doc || this.getDefaultDocument();
1375 return doc.createElement(tagName);
1376 }
1377 /**
1378 * @param {?} ns
1379 * @param {?} tagName
1380 * @param {?=} doc
1381 * @return {?}
1382 */
1383 createElementNS(ns, tagName, doc) {
1384 doc = doc || this.getDefaultDocument();
1385 return doc.createElementNS(ns, tagName);
1386 }
1387 /**
1388 * @param {?} text
1389 * @param {?=} doc
1390 * @return {?}
1391 */
1392 createTextNode(text, doc) {
1393 doc = doc || this.getDefaultDocument();
1394 return doc.createTextNode(text);
1395 }
1396 /**
1397 * @param {?} attrName
1398 * @param {?} attrValue
1399 * @param {?=} doc
1400 * @return {?}
1401 */
1402 createScriptTag(attrName, attrValue, doc) {
1403 doc = doc || this.getDefaultDocument();
1404 /** @type {?} */
1405 const el = (/** @type {?} */ (doc.createElement('SCRIPT')));
1406 el.setAttribute(attrName, attrValue);
1407 return el;
1408 }
1409 /**
1410 * @param {?} css
1411 * @param {?=} doc
1412 * @return {?}
1413 */
1414 createStyleElement(css, doc) {
1415 doc = doc || this.getDefaultDocument();
1416 /** @type {?} */
1417 const style = (/** @type {?} */ (doc.createElement('style')));
1418 this.appendChild(style, this.createTextNode(css, doc));
1419 return style;
1420 }
1421 /**
1422 * @param {?} el
1423 * @return {?}
1424 */
1425 createShadowRoot(el) { return ((/** @type {?} */ (el))).createShadowRoot(); }
1426 /**
1427 * @param {?} el
1428 * @return {?}
1429 */
1430 getShadowRoot(el) { return ((/** @type {?} */ (el))).shadowRoot; }
1431 /**
1432 * @param {?} el
1433 * @return {?}
1434 */
1435 getHost(el) { return ((/** @type {?} */ (el))).host; }
1436 /**
1437 * @param {?} node
1438 * @return {?}
1439 */
1440 clone(node) { return node.cloneNode(true); }
1441 /**
1442 * @param {?} element
1443 * @param {?} name
1444 * @return {?}
1445 */
1446 getElementsByClassName(element, name) {
1447 return element.getElementsByClassName(name);
1448 }
1449 /**
1450 * @param {?} element
1451 * @param {?} name
1452 * @return {?}
1453 */
1454 getElementsByTagName(element, name) {
1455 return element.getElementsByTagName(name);
1456 }
1457 /**
1458 * @param {?} element
1459 * @return {?}
1460 */
1461 classList(element) { return Array.prototype.slice.call(element.classList, 0); }
1462 /**
1463 * @param {?} element
1464 * @param {?} className
1465 * @return {?}
1466 */
1467 addClass(element, className) { element.classList.add(className); }
1468 /**
1469 * @param {?} element
1470 * @param {?} className
1471 * @return {?}
1472 */
1473 removeClass(element, className) { element.classList.remove(className); }
1474 /**
1475 * @param {?} element
1476 * @param {?} className
1477 * @return {?}
1478 */
1479 hasClass(element, className) {
1480 return element.classList.contains(className);
1481 }
1482 /**
1483 * @param {?} element
1484 * @param {?} styleName
1485 * @param {?} styleValue
1486 * @return {?}
1487 */
1488 setStyle(element, styleName, styleValue) {
1489 element.style[styleName] = styleValue;
1490 }
1491 /**
1492 * @param {?} element
1493 * @param {?} stylename
1494 * @return {?}
1495 */
1496 removeStyle(element, stylename) {
1497 // IE requires '' instead of null
1498 // see https://github.com/angular/angular/issues/7916
1499 element.style[stylename] = '';
1500 }
1501 /**
1502 * @param {?} element
1503 * @param {?} stylename
1504 * @return {?}
1505 */
1506 getStyle(element, stylename) { return element.style[stylename]; }
1507 /**
1508 * @param {?} element
1509 * @param {?} styleName
1510 * @param {?=} styleValue
1511 * @return {?}
1512 */
1513 hasStyle(element, styleName, styleValue) {
1514 /** @type {?} */
1515 const value = this.getStyle(element, styleName) || '';
1516 return styleValue ? value == styleValue : value.length > 0;
1517 }
1518 /**
1519 * @param {?} element
1520 * @return {?}
1521 */
1522 tagName(element) { return element.tagName; }
1523 /**
1524 * @param {?} element
1525 * @return {?}
1526 */
1527 attributeMap(element) {
1528 /** @type {?} */
1529 const res = new Map();
1530 /** @type {?} */
1531 const elAttrs = element.attributes;
1532 for (let i = 0; i < elAttrs.length; i++) {
1533 /** @type {?} */
1534 const attrib = elAttrs.item(i);
1535 res.set(attrib.name, attrib.value);
1536 }
1537 return res;
1538 }
1539 /**
1540 * @param {?} element
1541 * @param {?} attribute
1542 * @return {?}
1543 */
1544 hasAttribute(element, attribute) {
1545 return element.hasAttribute(attribute);
1546 }
1547 /**
1548 * @param {?} element
1549 * @param {?} ns
1550 * @param {?} attribute
1551 * @return {?}
1552 */
1553 hasAttributeNS(element, ns, attribute) {
1554 return element.hasAttributeNS(ns, attribute);
1555 }
1556 /**
1557 * @param {?} element
1558 * @param {?} attribute
1559 * @return {?}
1560 */
1561 getAttribute(element, attribute) {
1562 return element.getAttribute(attribute);
1563 }
1564 /**
1565 * @param {?} element
1566 * @param {?} ns
1567 * @param {?} name
1568 * @return {?}
1569 */
1570 getAttributeNS(element, ns, name) {
1571 return element.getAttributeNS(ns, name);
1572 }
1573 /**
1574 * @param {?} element
1575 * @param {?} name
1576 * @param {?} value
1577 * @return {?}
1578 */
1579 setAttribute(element, name, value) { element.setAttribute(name, value); }
1580 /**
1581 * @param {?} element
1582 * @param {?} ns
1583 * @param {?} name
1584 * @param {?} value
1585 * @return {?}
1586 */
1587 setAttributeNS(element, ns, name, value) {
1588 element.setAttributeNS(ns, name, value);
1589 }
1590 /**
1591 * @param {?} element
1592 * @param {?} attribute
1593 * @return {?}
1594 */
1595 removeAttribute(element, attribute) { element.removeAttribute(attribute); }
1596 /**
1597 * @param {?} element
1598 * @param {?} ns
1599 * @param {?} name
1600 * @return {?}
1601 */
1602 removeAttributeNS(element, ns, name) {
1603 element.removeAttributeNS(ns, name);
1604 }
1605 /**
1606 * @param {?} el
1607 * @return {?}
1608 */
1609 templateAwareRoot(el) { return this.isTemplateElement(el) ? this.content(el) : el; }
1610 /**
1611 * @return {?}
1612 */
1613 createHtmlDocument() {
1614 return document.implementation.createHTMLDocument('fakeTitle');
1615 }
1616 /**
1617 * @return {?}
1618 */
1619 getDefaultDocument() { return document; }
1620 /**
1621 * @param {?} el
1622 * @return {?}
1623 */
1624 getBoundingClientRect(el) {
1625 try {
1626 return el.getBoundingClientRect();
1627 }
1628 catch (_a) {
1629 return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
1630 }
1631 }
1632 /**
1633 * @param {?} doc
1634 * @return {?}
1635 */
1636 getTitle(doc) { return doc.title; }
1637 /**
1638 * @param {?} doc
1639 * @param {?} newTitle
1640 * @return {?}
1641 */
1642 setTitle(doc, newTitle) { doc.title = newTitle || ''; }
1643 /**
1644 * @param {?} n
1645 * @param {?} selector
1646 * @return {?}
1647 */
1648 elementMatches(n, selector) {
1649 if (this.isElementNode(n)) {
1650 return n.matches && n.matches(selector) ||
1651 n.msMatchesSelector && n.msMatchesSelector(selector) ||
1652 n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
1653 }
1654 return false;
1655 }
1656 /**
1657 * @param {?} el
1658 * @return {?}
1659 */
1660 isTemplateElement(el) {
1661 return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
1662 }
1663 /**
1664 * @param {?} node
1665 * @return {?}
1666 */
1667 isTextNode(node) { return node.nodeType === Node.TEXT_NODE; }
1668 /**
1669 * @param {?} node
1670 * @return {?}
1671 */
1672 isCommentNode(node) { return node.nodeType === Node.COMMENT_NODE; }
1673 /**
1674 * @param {?} node
1675 * @return {?}
1676 */
1677 isElementNode(node) { return node.nodeType === Node.ELEMENT_NODE; }
1678 /**
1679 * @param {?} node
1680 * @return {?}
1681 */
1682 hasShadowRoot(node) {
1683 return node.shadowRoot != null && node instanceof HTMLElement;
1684 }
1685 /**
1686 * @param {?} node
1687 * @return {?}
1688 */
1689 isShadowRoot(node) { return node instanceof DocumentFragment; }
1690 /**
1691 * @param {?} node
1692 * @return {?}
1693 */
1694 importIntoDoc(node) { return document.importNode(this.templateAwareRoot(node), true); }
1695 /**
1696 * @param {?} node
1697 * @return {?}
1698 */
1699 adoptNode(node) { return document.adoptNode(node); }
1700 /**
1701 * @param {?} el
1702 * @return {?}
1703 */
1704 getHref(el) { return (/** @type {?} */ (el.getAttribute('href'))); }
1705 /**
1706 * @param {?} event
1707 * @return {?}
1708 */
1709 getEventKey(event) {
1710 /** @type {?} */
1711 let key = event.key;
1712 if (key == null) {
1713 key = event.keyIdentifier;
1714 // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
1715 // Safari cf
1716 // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
1717 if (key == null) {
1718 return 'Unidentified';
1719 }
1720 if (key.startsWith('U+')) {
1721 key = String.fromCharCode(parseInt(key.substring(2), 16));
1722 if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
1723 // There is a bug in Chrome for numeric keypad keys:
1724 // https://code.google.com/p/chromium/issues/detail?id=155654
1725 // 1, 2, 3 ... are reported as A, B, C ...
1726 key = ((/** @type {?} */ (_chromeNumKeyPadMap)))[key];
1727 }
1728 }
1729 }
1730 return _keyMap[key] || key;
1731 }
1732 /**
1733 * @param {?} doc
1734 * @param {?} target
1735 * @return {?}
1736 */
1737 getGlobalEventTarget(doc, target) {
1738 if (target === 'window') {
1739 return window;
1740 }
1741 if (target === 'document') {
1742 return doc;
1743 }
1744 if (target === 'body') {
1745 return doc.body;
1746 }
1747 return null;
1748 }
1749 /**
1750 * @return {?}
1751 */
1752 getHistory() { return window.history; }
1753 /**
1754 * @return {?}
1755 */
1756 getLocation() { return window.location; }
1757 /**
1758 * @param {?} doc
1759 * @return {?}
1760 */
1761 getBaseHref(doc) {
1762 /** @type {?} */
1763 const href = getBaseElementHref();
1764 return href == null ? null : relativePath(href);
1765 }
1766 /**
1767 * @return {?}
1768 */
1769 resetBaseElement() { baseElement = null; }
1770 /**
1771 * @return {?}
1772 */
1773 getUserAgent() { return window.navigator.userAgent; }
1774 /**
1775 * @param {?} element
1776 * @param {?} name
1777 * @param {?} value
1778 * @return {?}
1779 */
1780 setData(element, name, value) {
1781 this.setAttribute(element, 'data-' + name, value);
1782 }
1783 /**
1784 * @param {?} element
1785 * @param {?} name
1786 * @return {?}
1787 */
1788 getData(element, name) {
1789 return this.getAttribute(element, 'data-' + name);
1790 }
1791 /**
1792 * @param {?} element
1793 * @return {?}
1794 */
1795 getComputedStyle(element) { return getComputedStyle(element); }
1796 // TODO(tbosch): move this into a separate environment class once we have it
1797 /**
1798 * @return {?}
1799 */
1800 supportsWebAnimation() {
1801 return typeof ((/** @type {?} */ (Element))).prototype['animate'] === 'function';
1802 }
1803 /**
1804 * @return {?}
1805 */
1806 performanceNow() {
1807 // performance.now() is not available in all browsers, see
1808 // http://caniuse.com/#search=performance.now
1809 return window.performance && window.performance.now ? window.performance.now() :
1810 new Date().getTime();
1811 }
1812 /**
1813 * @return {?}
1814 */
1815 supportsCookies() { return true; }
1816 /**
1817 * @param {?} name
1818 * @return {?}
1819 */
1820 getCookie(name) { return ɵparseCookieValue(document.cookie, name); }
1821 /**
1822 * @param {?} name
1823 * @param {?} value
1824 * @return {?}
1825 */
1826 setCookie(name, value) {
1827 // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
1828 // not clear other cookies.
1829 document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
1830 }
1831}
1832/** @type {?} */
1833let baseElement = null;
1834/**
1835 * @return {?}
1836 */
1837function getBaseElementHref() {
1838 if (!baseElement) {
1839 baseElement = (/** @type {?} */ (document.querySelector('base')));
1840 if (!baseElement) {
1841 return null;
1842 }
1843 }
1844 return baseElement.getAttribute('href');
1845}
1846// based on urlUtils.js in AngularJS 1
1847/** @type {?} */
1848let urlParsingNode;
1849/**
1850 * @param {?} url
1851 * @return {?}
1852 */
1853function relativePath(url) {
1854 if (!urlParsingNode) {
1855 urlParsingNode = document.createElement('a');
1856 }
1857 urlParsingNode.setAttribute('href', url);
1858 return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
1859 '/' + urlParsingNode.pathname;
1860}
1861
1862/**
1863 * @fileoverview added by tsickle
1864 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1865 */
1866/**
1867 * @license
1868 * Copyright Google Inc. All Rights Reserved.
1869 *
1870 * Use of this source code is governed by an MIT-style license that can be
1871 * found in the LICENSE file at https://angular.io/license
1872 */
1873/**
1874 * @return {?}
1875 */
1876function supportsState() {
1877 return !!window.history.pushState;
1878}
1879
1880/**
1881 * @fileoverview added by tsickle
1882 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1883 */
1884/**
1885 * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
1886 * This class should not be used directly by an application developer. Instead, use
1887 * {\@link Location}.
1888 */
1889class BrowserPlatformLocation extends PlatformLocation {
1890 /**
1891 * @param {?} _doc
1892 */
1893 constructor(_doc) {
1894 super();
1895 this._doc = _doc;
1896 this._init();
1897 }
1898 // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
1899 /**
1900 * \@internal
1901 * @return {?}
1902 */
1903 _init() {
1904 ((/** @type {?} */ (this))).location = getDOM().getLocation();
1905 this._history = getDOM().getHistory();
1906 }
1907 /**
1908 * @return {?}
1909 */
1910 getBaseHrefFromDOM() { return (/** @type {?} */ (getDOM().getBaseHref(this._doc))); }
1911 /**
1912 * @param {?} fn
1913 * @return {?}
1914 */
1915 onPopState(fn) {
1916 getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
1917 }
1918 /**
1919 * @param {?} fn
1920 * @return {?}
1921 */
1922 onHashChange(fn) {
1923 getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
1924 }
1925 /**
1926 * @return {?}
1927 */
1928 get href() { return this.location.href; }
1929 /**
1930 * @return {?}
1931 */
1932 get protocol() { return this.location.protocol; }
1933 /**
1934 * @return {?}
1935 */
1936 get hostname() { return this.location.hostname; }
1937 /**
1938 * @return {?}
1939 */
1940 get port() { return this.location.port; }
1941 /**
1942 * @return {?}
1943 */
1944 get pathname() { return this.location.pathname; }
1945 /**
1946 * @return {?}
1947 */
1948 get search() { return this.location.search; }
1949 /**
1950 * @return {?}
1951 */
1952 get hash() { return this.location.hash; }
1953 /**
1954 * @param {?} newPath
1955 * @return {?}
1956 */
1957 set pathname(newPath) { this.location.pathname = newPath; }
1958 /**
1959 * @param {?} state
1960 * @param {?} title
1961 * @param {?} url
1962 * @return {?}
1963 */
1964 pushState(state, title, url) {
1965 if (supportsState()) {
1966 this._history.pushState(state, title, url);
1967 }
1968 else {
1969 this.location.hash = url;
1970 }
1971 }
1972 /**
1973 * @param {?} state
1974 * @param {?} title
1975 * @param {?} url
1976 * @return {?}
1977 */
1978 replaceState(state, title, url) {
1979 if (supportsState()) {
1980 this._history.replaceState(state, title, url);
1981 }
1982 else {
1983 this.location.hash = url;
1984 }
1985 }
1986 /**
1987 * @return {?}
1988 */
1989 forward() { this._history.forward(); }
1990 /**
1991 * @return {?}
1992 */
1993 back() { this._history.back(); }
1994 /**
1995 * @return {?}
1996 */
1997 getState() { return this._history.state; }
1998}
1999BrowserPlatformLocation.decorators = [
2000 { type: Injectable }
2001];
2002/** @nocollapse */
2003BrowserPlatformLocation.ctorParameters = () => [
2004 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2005];
2006if (false) {
2007 /** @type {?} */
2008 BrowserPlatformLocation.prototype.location;
2009 /**
2010 * @type {?}
2011 * @private
2012 */
2013 BrowserPlatformLocation.prototype._history;
2014 /**
2015 * @type {?}
2016 * @private
2017 */
2018 BrowserPlatformLocation.prototype._doc;
2019}
2020
2021/**
2022 * @fileoverview added by tsickle
2023 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2024 */
2025/**
2026 * An id that identifies a particular application being bootstrapped, that should
2027 * match across the client/server boundary.
2028 * @type {?}
2029 */
2030const TRANSITION_ID = new InjectionToken('TRANSITION_ID');
2031/**
2032 * @param {?} transitionId
2033 * @param {?} document
2034 * @param {?} injector
2035 * @return {?}
2036 */
2037function appInitializerFactory(transitionId, document, injector) {
2038 return (/**
2039 * @return {?}
2040 */
2041 () => {
2042 // Wait for all application initializers to be completed before removing the styles set by
2043 // the server.
2044 injector.get(ApplicationInitStatus).donePromise.then((/**
2045 * @return {?}
2046 */
2047 () => {
2048 /** @type {?} */
2049 const dom = getDOM();
2050 /** @type {?} */
2051 const styles = Array.prototype.slice.apply(dom.querySelectorAll(document, `style[ng-transition]`));
2052 styles.filter((/**
2053 * @param {?} el
2054 * @return {?}
2055 */
2056 el => dom.getAttribute(el, 'ng-transition') === transitionId))
2057 .forEach((/**
2058 * @param {?} el
2059 * @return {?}
2060 */
2061 el => dom.remove(el)));
2062 }));
2063 });
2064}
2065/** @type {?} */
2066const SERVER_TRANSITION_PROVIDERS = [
2067 {
2068 provide: APP_INITIALIZER,
2069 useFactory: appInitializerFactory,
2070 deps: [TRANSITION_ID, DOCUMENT, Injector],
2071 multi: true
2072 },
2073];
2074
2075/**
2076 * @fileoverview added by tsickle
2077 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2078 */
2079class BrowserGetTestability {
2080 /**
2081 * @return {?}
2082 */
2083 static init() { setTestabilityGetter(new BrowserGetTestability()); }
2084 /**
2085 * @param {?} registry
2086 * @return {?}
2087 */
2088 addToWindow(registry) {
2089 ɵglobal['getAngularTestability'] = (/**
2090 * @param {?} elem
2091 * @param {?=} findInAncestors
2092 * @return {?}
2093 */
2094 (elem, findInAncestors = true) => {
2095 /** @type {?} */
2096 const testability = registry.findTestabilityInTree(elem, findInAncestors);
2097 if (testability == null) {
2098 throw new Error('Could not find testability for element.');
2099 }
2100 return testability;
2101 });
2102 ɵglobal['getAllAngularTestabilities'] = (/**
2103 * @return {?}
2104 */
2105 () => registry.getAllTestabilities());
2106 ɵglobal['getAllAngularRootElements'] = (/**
2107 * @return {?}
2108 */
2109 () => registry.getAllRootElements());
2110 /** @type {?} */
2111 const whenAllStable = (/**
2112 * @param {?} callback
2113 * @return {?}
2114 */
2115 (callback /** TODO #9100 */) => {
2116 /** @type {?} */
2117 const testabilities = ɵglobal['getAllAngularTestabilities']();
2118 /** @type {?} */
2119 let count = testabilities.length;
2120 /** @type {?} */
2121 let didWork = false;
2122 /** @type {?} */
2123 const decrement = (/**
2124 * @param {?} didWork_
2125 * @return {?}
2126 */
2127 function (didWork_ /** TODO #9100 */) {
2128 didWork = didWork || didWork_;
2129 count--;
2130 if (count == 0) {
2131 callback(didWork);
2132 }
2133 });
2134 testabilities.forEach((/**
2135 * @param {?} testability
2136 * @return {?}
2137 */
2138 function (testability /** TODO #9100 */) {
2139 testability.whenStable(decrement);
2140 }));
2141 });
2142 if (!ɵglobal['frameworkStabilizers']) {
2143 ɵglobal['frameworkStabilizers'] = [];
2144 }
2145 ɵglobal['frameworkStabilizers'].push(whenAllStable);
2146 }
2147 /**
2148 * @param {?} registry
2149 * @param {?} elem
2150 * @param {?} findInAncestors
2151 * @return {?}
2152 */
2153 findTestabilityInTree(registry, elem, findInAncestors) {
2154 if (elem == null) {
2155 return null;
2156 }
2157 /** @type {?} */
2158 const t = registry.getTestability(elem);
2159 if (t != null) {
2160 return t;
2161 }
2162 else if (!findInAncestors) {
2163 return null;
2164 }
2165 if (getDOM().isShadowRoot(elem)) {
2166 return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
2167 }
2168 return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
2169 }
2170}
2171
2172/**
2173 * @fileoverview added by tsickle
2174 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2175 */
2176/** @type {?} */
2177const CAMEL_CASE_REGEXP = /([A-Z])/g;
2178/** @type {?} */
2179const DASH_CASE_REGEXP = /-([a-z])/g;
2180/**
2181 * @param {?} input
2182 * @return {?}
2183 */
2184function camelCaseToDashCase(input) {
2185 return input.replace(CAMEL_CASE_REGEXP, (/**
2186 * @param {...?} m
2187 * @return {?}
2188 */
2189 (...m) => '-' + m[1].toLowerCase()));
2190}
2191/**
2192 * @param {?} input
2193 * @return {?}
2194 */
2195function dashCaseToCamelCase(input) {
2196 return input.replace(DASH_CASE_REGEXP, (/**
2197 * @param {...?} m
2198 * @return {?}
2199 */
2200 (...m) => m[1].toUpperCase()));
2201}
2202/**
2203 * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
2204 * `name` is `'probe'`.
2205 * @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
2206 * global `ng` object.
2207 * @param {?} value The value to export.
2208 * @return {?}
2209 */
2210function exportNgVar(name, value) {
2211 if (typeof COMPILED === 'undefined' || !COMPILED) {
2212 // Note: we can't export `ng` when using closure enhanced optimization as:
2213 // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
2214 // - we can't declare a closure extern as the namespace `ng` is already used within Google
2215 // for typings for angularJS (via `goog.provide('ng....')`).
2216 /** @type {?} */
2217 const ng = ɵglobal['ng'] = ((/** @type {?} */ (ɵglobal['ng']))) || {};
2218 ng[name] = value;
2219 }
2220}
2221
2222/**
2223 * @fileoverview added by tsickle
2224 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2225 */
2226const ɵ0$1 = /**
2227 * @return {?}
2228 */
2229() => ({
2230 'ApplicationRef': ApplicationRef,
2231 'NgZone': NgZone,
2232});
2233/** @type {?} */
2234const CORE_TOKENS = ((ɵ0$1))();
2235/** @type {?} */
2236const INSPECT_GLOBAL_NAME = 'probe';
2237/** @type {?} */
2238const CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
2239/**
2240 * Returns a {\@link DebugElement} for the given native DOM element, or
2241 * null if the given native element does not have an Angular view associated
2242 * with it.
2243 * @param {?} element
2244 * @return {?}
2245 */
2246function inspectNativeElement(element) {
2247 return getDebugNode(element);
2248}
2249/**
2250 * @param {?} coreTokens
2251 * @return {?}
2252 */
2253function _createNgProbe(coreTokens) {
2254 exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
2255 exportNgVar(CORE_TOKENS_GLOBAL_NAME, Object.assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
2256 return (/**
2257 * @return {?}
2258 */
2259 () => inspectNativeElement);
2260}
2261/**
2262 * @param {?} tokens
2263 * @return {?}
2264 */
2265function _ngProbeTokensToMap(tokens) {
2266 return tokens.reduce((/**
2267 * @param {?} prev
2268 * @param {?} t
2269 * @return {?}
2270 */
2271 (prev, t) => (prev[t.name] = t.token, prev)), {});
2272}
2273/**
2274 * In Ivy, we don't support NgProbe because we have our own set of testing utilities
2275 * with more robust functionality.
2276 *
2277 * We shouldn't bring in NgProbe because it prevents DebugNode and friends from
2278 * tree-shaking properly.
2279 * @type {?}
2280 */
2281const ELEMENT_PROBE_PROVIDERS__POST_R3__ = [];
2282/**
2283 * Providers which support debugging Angular applications (e.g. via `ng.probe`).
2284 * @type {?}
2285 */
2286const ELEMENT_PROBE_PROVIDERS__PRE_R3__ = [
2287 {
2288 provide: APP_INITIALIZER,
2289 useFactory: _createNgProbe,
2290 deps: [
2291 [NgProbeToken, new Optional()],
2292 ],
2293 multi: true,
2294 },
2295];
2296/** @type {?} */
2297const ELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS__PRE_R3__;
2298
2299/**
2300 * @fileoverview added by tsickle
2301 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2302 */
2303/**
2304 * The injection token for the event-manager plug-in service.
2305 *
2306 * \@publicApi
2307 * @type {?}
2308 */
2309const EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
2310/**
2311 * An injectable service that provides event management for Angular
2312 * through a browser plug-in.
2313 *
2314 * \@publicApi
2315 */
2316class EventManager {
2317 /**
2318 * Initializes an instance of the event-manager service.
2319 * @param {?} plugins
2320 * @param {?} _zone
2321 */
2322 constructor(plugins, _zone) {
2323 this._zone = _zone;
2324 this._eventNameToPlugin = new Map();
2325 plugins.forEach((/**
2326 * @template THIS
2327 * @this {THIS}
2328 * @param {?} p
2329 * @return {THIS}
2330 */
2331 p => p.manager = this));
2332 this._plugins = plugins.slice().reverse();
2333 }
2334 /**
2335 * Registers a handler for a specific element and event.
2336 *
2337 * @param {?} element The HTML element to receive event notifications.
2338 * @param {?} eventName The name of the event to listen for.
2339 * @param {?} handler A function to call when the notification occurs. Receives the
2340 * event object as an argument.
2341 * @return {?} A callback function that can be used to remove the handler.
2342 */
2343 addEventListener(element, eventName, handler) {
2344 /** @type {?} */
2345 const plugin = this._findPluginFor(eventName);
2346 return plugin.addEventListener(element, eventName, handler);
2347 }
2348 /**
2349 * Registers a global handler for an event in a target view.
2350 *
2351 * @param {?} target A target for global event notifications. One of "window", "document", or "body".
2352 * @param {?} eventName The name of the event to listen for.
2353 * @param {?} handler A function to call when the notification occurs. Receives the
2354 * event object as an argument.
2355 * @return {?} A callback function that can be used to remove the handler.
2356 */
2357 addGlobalEventListener(target, eventName, handler) {
2358 /** @type {?} */
2359 const plugin = this._findPluginFor(eventName);
2360 return plugin.addGlobalEventListener(target, eventName, handler);
2361 }
2362 /**
2363 * Retrieves the compilation zone in which event listeners are registered.
2364 * @return {?}
2365 */
2366 getZone() { return this._zone; }
2367 /**
2368 * \@internal
2369 * @param {?} eventName
2370 * @return {?}
2371 */
2372 _findPluginFor(eventName) {
2373 /** @type {?} */
2374 const plugin = this._eventNameToPlugin.get(eventName);
2375 if (plugin) {
2376 return plugin;
2377 }
2378 /** @type {?} */
2379 const plugins = this._plugins;
2380 for (let i = 0; i < plugins.length; i++) {
2381 /** @type {?} */
2382 const plugin = plugins[i];
2383 if (plugin.supports(eventName)) {
2384 this._eventNameToPlugin.set(eventName, plugin);
2385 return plugin;
2386 }
2387 }
2388 throw new Error(`No event manager plugin found for event ${eventName}`);
2389 }
2390}
2391EventManager.decorators = [
2392 { type: Injectable }
2393];
2394/** @nocollapse */
2395EventManager.ctorParameters = () => [
2396 { type: Array, decorators: [{ type: Inject, args: [EVENT_MANAGER_PLUGINS,] }] },
2397 { type: NgZone }
2398];
2399if (false) {
2400 /**
2401 * @type {?}
2402 * @private
2403 */
2404 EventManager.prototype._plugins;
2405 /**
2406 * @type {?}
2407 * @private
2408 */
2409 EventManager.prototype._eventNameToPlugin;
2410 /**
2411 * @type {?}
2412 * @private
2413 */
2414 EventManager.prototype._zone;
2415}
2416/**
2417 * @abstract
2418 */
2419class EventManagerPlugin {
2420 /**
2421 * @param {?} _doc
2422 */
2423 constructor(_doc) {
2424 this._doc = _doc;
2425 }
2426 /**
2427 * @param {?} element
2428 * @param {?} eventName
2429 * @param {?} handler
2430 * @return {?}
2431 */
2432 addGlobalEventListener(element, eventName, handler) {
2433 /** @type {?} */
2434 const target = getDOM().getGlobalEventTarget(this._doc, element);
2435 if (!target) {
2436 throw new Error(`Unsupported event target ${target} for event ${eventName}`);
2437 }
2438 return this.addEventListener(target, eventName, handler);
2439 }
2440}
2441if (false) {
2442 /** @type {?} */
2443 EventManagerPlugin.prototype.manager;
2444 /**
2445 * @type {?}
2446 * @private
2447 */
2448 EventManagerPlugin.prototype._doc;
2449 /**
2450 * @abstract
2451 * @param {?} eventName
2452 * @return {?}
2453 */
2454 EventManagerPlugin.prototype.supports = function (eventName) { };
2455 /**
2456 * @abstract
2457 * @param {?} element
2458 * @param {?} eventName
2459 * @param {?} handler
2460 * @return {?}
2461 */
2462 EventManagerPlugin.prototype.addEventListener = function (element, eventName, handler) { };
2463}
2464
2465/**
2466 * @fileoverview added by tsickle
2467 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2468 */
2469class SharedStylesHost {
2470 constructor() {
2471 /**
2472 * \@internal
2473 */
2474 this._stylesSet = new Set();
2475 }
2476 /**
2477 * @param {?} styles
2478 * @return {?}
2479 */
2480 addStyles(styles) {
2481 /** @type {?} */
2482 const additions = new Set();
2483 styles.forEach((/**
2484 * @param {?} style
2485 * @return {?}
2486 */
2487 style => {
2488 if (!this._stylesSet.has(style)) {
2489 this._stylesSet.add(style);
2490 additions.add(style);
2491 }
2492 }));
2493 this.onStylesAdded(additions);
2494 }
2495 /**
2496 * @param {?} additions
2497 * @return {?}
2498 */
2499 onStylesAdded(additions) { }
2500 /**
2501 * @return {?}
2502 */
2503 getAllStyles() { return Array.from(this._stylesSet); }
2504}
2505SharedStylesHost.decorators = [
2506 { type: Injectable }
2507];
2508if (false) {
2509 /**
2510 * \@internal
2511 * @type {?}
2512 * @protected
2513 */
2514 SharedStylesHost.prototype._stylesSet;
2515}
2516class DomSharedStylesHost extends SharedStylesHost {
2517 /**
2518 * @param {?} _doc
2519 */
2520 constructor(_doc) {
2521 super();
2522 this._doc = _doc;
2523 this._hostNodes = new Set();
2524 this._styleNodes = new Set();
2525 this._hostNodes.add(_doc.head);
2526 }
2527 /**
2528 * @private
2529 * @param {?} styles
2530 * @param {?} host
2531 * @return {?}
2532 */
2533 _addStylesToHost(styles, host) {
2534 styles.forEach((/**
2535 * @param {?} style
2536 * @return {?}
2537 */
2538 (style) => {
2539 /** @type {?} */
2540 const styleEl = this._doc.createElement('style');
2541 styleEl.textContent = style;
2542 this._styleNodes.add(host.appendChild(styleEl));
2543 }));
2544 }
2545 /**
2546 * @param {?} hostNode
2547 * @return {?}
2548 */
2549 addHost(hostNode) {
2550 this._addStylesToHost(this._stylesSet, hostNode);
2551 this._hostNodes.add(hostNode);
2552 }
2553 /**
2554 * @param {?} hostNode
2555 * @return {?}
2556 */
2557 removeHost(hostNode) { this._hostNodes.delete(hostNode); }
2558 /**
2559 * @param {?} additions
2560 * @return {?}
2561 */
2562 onStylesAdded(additions) {
2563 this._hostNodes.forEach((/**
2564 * @param {?} hostNode
2565 * @return {?}
2566 */
2567 hostNode => this._addStylesToHost(additions, hostNode)));
2568 }
2569 /**
2570 * @return {?}
2571 */
2572 ngOnDestroy() { this._styleNodes.forEach((/**
2573 * @param {?} styleNode
2574 * @return {?}
2575 */
2576 styleNode => getDOM().remove(styleNode))); }
2577}
2578DomSharedStylesHost.decorators = [
2579 { type: Injectable }
2580];
2581/** @nocollapse */
2582DomSharedStylesHost.ctorParameters = () => [
2583 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
2584];
2585if (false) {
2586 /**
2587 * @type {?}
2588 * @private
2589 */
2590 DomSharedStylesHost.prototype._hostNodes;
2591 /**
2592 * @type {?}
2593 * @private
2594 */
2595 DomSharedStylesHost.prototype._styleNodes;
2596 /**
2597 * @type {?}
2598 * @private
2599 */
2600 DomSharedStylesHost.prototype._doc;
2601}
2602
2603/**
2604 * @fileoverview added by tsickle
2605 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2606 */
2607/** @type {?} */
2608const NAMESPACE_URIS = {
2609 'svg': 'http://www.w3.org/2000/svg',
2610 'xhtml': 'http://www.w3.org/1999/xhtml',
2611 'xlink': 'http://www.w3.org/1999/xlink',
2612 'xml': 'http://www.w3.org/XML/1998/namespace',
2613 'xmlns': 'http://www.w3.org/2000/xmlns/',
2614};
2615/** @type {?} */
2616const COMPONENT_REGEX = /%COMP%/g;
2617/** @type {?} */
2618const COMPONENT_VARIABLE = '%COMP%';
2619/** @type {?} */
2620const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
2621/** @type {?} */
2622const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
2623/**
2624 * @param {?} componentShortId
2625 * @return {?}
2626 */
2627function shimContentAttribute(componentShortId) {
2628 return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
2629}
2630/**
2631 * @param {?} componentShortId
2632 * @return {?}
2633 */
2634function shimHostAttribute(componentShortId) {
2635 return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
2636}
2637/**
2638 * @param {?} compId
2639 * @param {?} styles
2640 * @param {?} target
2641 * @return {?}
2642 */
2643function flattenStyles(compId, styles, target) {
2644 for (let i = 0; i < styles.length; i++) {
2645 /** @type {?} */
2646 let style = styles[i];
2647 if (Array.isArray(style)) {
2648 flattenStyles(compId, style, target);
2649 }
2650 else {
2651 style = style.replace(COMPONENT_REGEX, compId);
2652 target.push(style);
2653 }
2654 }
2655 return target;
2656}
2657/**
2658 * @param {?} eventHandler
2659 * @return {?}
2660 */
2661function decoratePreventDefault(eventHandler) {
2662 return (/**
2663 * @param {?} event
2664 * @return {?}
2665 */
2666 (event) => {
2667 /** @type {?} */
2668 const allowDefaultBehavior = eventHandler(event);
2669 if (allowDefaultBehavior === false) {
2670 // TODO(tbosch): move preventDefault into event plugins...
2671 event.preventDefault();
2672 event.returnValue = false;
2673 }
2674 });
2675}
2676class DomRendererFactory2 {
2677 /**
2678 * @param {?} eventManager
2679 * @param {?} sharedStylesHost
2680 * @param {?} appId
2681 */
2682 constructor(eventManager, sharedStylesHost, appId) {
2683 this.eventManager = eventManager;
2684 this.sharedStylesHost = sharedStylesHost;
2685 this.appId = appId;
2686 this.rendererByCompId = new Map();
2687 this.defaultRenderer = new DefaultDomRenderer2(eventManager);
2688 }
2689 /**
2690 * @param {?} element
2691 * @param {?} type
2692 * @return {?}
2693 */
2694 createRenderer(element, type) {
2695 if (!element || !type) {
2696 return this.defaultRenderer;
2697 }
2698 switch (type.encapsulation) {
2699 case ViewEncapsulation.Emulated: {
2700 /** @type {?} */
2701 let renderer = this.rendererByCompId.get(type.id);
2702 if (!renderer) {
2703 renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type, this.appId);
2704 this.rendererByCompId.set(type.id, renderer);
2705 }
2706 ((/** @type {?} */ (renderer))).applyToHost(element);
2707 return renderer;
2708 }
2709 case ViewEncapsulation.Native:
2710 case ViewEncapsulation.ShadowDom:
2711 return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
2712 default: {
2713 if (!this.rendererByCompId.has(type.id)) {
2714 /** @type {?} */
2715 const styles = flattenStyles(type.id, type.styles, []);
2716 this.sharedStylesHost.addStyles(styles);
2717 this.rendererByCompId.set(type.id, this.defaultRenderer);
2718 }
2719 return this.defaultRenderer;
2720 }
2721 }
2722 }
2723 /**
2724 * @return {?}
2725 */
2726 begin() { }
2727 /**
2728 * @return {?}
2729 */
2730 end() { }
2731}
2732DomRendererFactory2.decorators = [
2733 { type: Injectable }
2734];
2735/** @nocollapse */
2736DomRendererFactory2.ctorParameters = () => [
2737 { type: EventManager },
2738 { type: DomSharedStylesHost },
2739 { type: String, decorators: [{ type: Inject, args: [APP_ID,] }] }
2740];
2741if (false) {
2742 /**
2743 * @type {?}
2744 * @private
2745 */
2746 DomRendererFactory2.prototype.rendererByCompId;
2747 /**
2748 * @type {?}
2749 * @private
2750 */
2751 DomRendererFactory2.prototype.defaultRenderer;
2752 /**
2753 * @type {?}
2754 * @private
2755 */
2756 DomRendererFactory2.prototype.eventManager;
2757 /**
2758 * @type {?}
2759 * @private
2760 */
2761 DomRendererFactory2.prototype.sharedStylesHost;
2762 /**
2763 * @type {?}
2764 * @private
2765 */
2766 DomRendererFactory2.prototype.appId;
2767}
2768class DefaultDomRenderer2 {
2769 /**
2770 * @param {?} eventManager
2771 */
2772 constructor(eventManager) {
2773 this.eventManager = eventManager;
2774 this.data = Object.create(null);
2775 }
2776 /**
2777 * @return {?}
2778 */
2779 destroy() { }
2780 /**
2781 * @param {?} name
2782 * @param {?=} namespace
2783 * @return {?}
2784 */
2785 createElement(name, namespace) {
2786 if (namespace) {
2787 // In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key
2788 // will result in undefined, so we just return the namespace here.
2789 return document.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
2790 }
2791 return document.createElement(name);
2792 }
2793 /**
2794 * @param {?} value
2795 * @return {?}
2796 */
2797 createComment(value) { return document.createComment(value); }
2798 /**
2799 * @param {?} value
2800 * @return {?}
2801 */
2802 createText(value) { return document.createTextNode(value); }
2803 /**
2804 * @param {?} parent
2805 * @param {?} newChild
2806 * @return {?}
2807 */
2808 appendChild(parent, newChild) { parent.appendChild(newChild); }
2809 /**
2810 * @param {?} parent
2811 * @param {?} newChild
2812 * @param {?} refChild
2813 * @return {?}
2814 */
2815 insertBefore(parent, newChild, refChild) {
2816 if (parent) {
2817 parent.insertBefore(newChild, refChild);
2818 }
2819 }
2820 /**
2821 * @param {?} parent
2822 * @param {?} oldChild
2823 * @return {?}
2824 */
2825 removeChild(parent, oldChild) {
2826 if (parent) {
2827 parent.removeChild(oldChild);
2828 }
2829 }
2830 /**
2831 * @param {?} selectorOrNode
2832 * @param {?=} preserveContent
2833 * @return {?}
2834 */
2835 selectRootElement(selectorOrNode, preserveContent) {
2836 /** @type {?} */
2837 let el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
2838 selectorOrNode;
2839 if (!el) {
2840 throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
2841 }
2842 if (!preserveContent) {
2843 el.textContent = '';
2844 }
2845 return el;
2846 }
2847 /**
2848 * @param {?} node
2849 * @return {?}
2850 */
2851 parentNode(node) { return node.parentNode; }
2852 /**
2853 * @param {?} node
2854 * @return {?}
2855 */
2856 nextSibling(node) { return node.nextSibling; }
2857 /**
2858 * @param {?} el
2859 * @param {?} name
2860 * @param {?} value
2861 * @param {?=} namespace
2862 * @return {?}
2863 */
2864 setAttribute(el, name, value, namespace) {
2865 if (namespace) {
2866 name = namespace + ':' + name;
2867 // TODO(benlesh): Ivy may cause issues here because it's passing around
2868 // full URIs for namespaces, therefore this lookup will fail.
2869 /** @type {?} */
2870 const namespaceUri = NAMESPACE_URIS[namespace];
2871 if (namespaceUri) {
2872 el.setAttributeNS(namespaceUri, name, value);
2873 }
2874 else {
2875 el.setAttribute(name, value);
2876 }
2877 }
2878 else {
2879 el.setAttribute(name, value);
2880 }
2881 }
2882 /**
2883 * @param {?} el
2884 * @param {?} name
2885 * @param {?=} namespace
2886 * @return {?}
2887 */
2888 removeAttribute(el, name, namespace) {
2889 if (namespace) {
2890 // TODO(benlesh): Ivy may cause issues here because it's passing around
2891 // full URIs for namespaces, therefore this lookup will fail.
2892 /** @type {?} */
2893 const namespaceUri = NAMESPACE_URIS[namespace];
2894 if (namespaceUri) {
2895 el.removeAttributeNS(namespaceUri, name);
2896 }
2897 else {
2898 // TODO(benlesh): Since ivy is passing around full URIs for namespaces
2899 // this could result in properties like `http://www.w3.org/2000/svg:cx="123"`,
2900 // which is wrong.
2901 el.removeAttribute(`${namespace}:${name}`);
2902 }
2903 }
2904 else {
2905 el.removeAttribute(name);
2906 }
2907 }
2908 /**
2909 * @param {?} el
2910 * @param {?} name
2911 * @return {?}
2912 */
2913 addClass(el, name) { el.classList.add(name); }
2914 /**
2915 * @param {?} el
2916 * @param {?} name
2917 * @return {?}
2918 */
2919 removeClass(el, name) { el.classList.remove(name); }
2920 /**
2921 * @param {?} el
2922 * @param {?} style
2923 * @param {?} value
2924 * @param {?} flags
2925 * @return {?}
2926 */
2927 setStyle(el, style, value, flags) {
2928 if (flags & RendererStyleFlags2.DashCase) {
2929 el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
2930 }
2931 else {
2932 el.style[style] = value;
2933 }
2934 }
2935 /**
2936 * @param {?} el
2937 * @param {?} style
2938 * @param {?} flags
2939 * @return {?}
2940 */
2941 removeStyle(el, style, flags) {
2942 if (flags & RendererStyleFlags2.DashCase) {
2943 el.style.removeProperty(style);
2944 }
2945 else {
2946 // IE requires '' instead of null
2947 // see https://github.com/angular/angular/issues/7916
2948 el.style[style] = '';
2949 }
2950 }
2951 /**
2952 * @param {?} el
2953 * @param {?} name
2954 * @param {?} value
2955 * @return {?}
2956 */
2957 setProperty(el, name, value) {
2958 checkNoSyntheticProp(name, 'property');
2959 el[name] = value;
2960 }
2961 /**
2962 * @param {?} node
2963 * @param {?} value
2964 * @return {?}
2965 */
2966 setValue(node, value) { node.nodeValue = value; }
2967 /**
2968 * @param {?} target
2969 * @param {?} event
2970 * @param {?} callback
2971 * @return {?}
2972 */
2973 listen(target, event, callback) {
2974 checkNoSyntheticProp(event, 'listener');
2975 if (typeof target === 'string') {
2976 return (/** @type {?} */ (this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback))));
2977 }
2978 return (/** @type {?} */ ((/** @type {?} */ (this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))))));
2979 }
2980}
2981if (false) {
2982 /** @type {?} */
2983 DefaultDomRenderer2.prototype.data;
2984 /** @type {?} */
2985 DefaultDomRenderer2.prototype.destroyNode;
2986 /**
2987 * @type {?}
2988 * @private
2989 */
2990 DefaultDomRenderer2.prototype.eventManager;
2991}
2992const ɵ0$2 = /**
2993 * @return {?}
2994 */
2995() => '@'.charCodeAt(0);
2996/** @type {?} */
2997const AT_CHARCODE = ((ɵ0$2))();
2998/**
2999 * @param {?} name
3000 * @param {?} nameKind
3001 * @return {?}
3002 */
3003function checkNoSyntheticProp(name, nameKind) {
3004 if (name.charCodeAt(0) === AT_CHARCODE) {
3005 throw new Error(`Found the synthetic ${nameKind} ${name}. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.`);
3006 }
3007}
3008class EmulatedEncapsulationDomRenderer2 extends DefaultDomRenderer2 {
3009 /**
3010 * @param {?} eventManager
3011 * @param {?} sharedStylesHost
3012 * @param {?} component
3013 * @param {?} appId
3014 */
3015 constructor(eventManager, sharedStylesHost, component, appId) {
3016 super(eventManager);
3017 this.component = component;
3018 /** @type {?} */
3019 const styles = flattenStyles(appId + '-' + component.id, component.styles, []);
3020 sharedStylesHost.addStyles(styles);
3021 this.contentAttr = shimContentAttribute(appId + '-' + component.id);
3022 this.hostAttr = shimHostAttribute(appId + '-' + component.id);
3023 }
3024 /**
3025 * @param {?} element
3026 * @return {?}
3027 */
3028 applyToHost(element) { super.setAttribute(element, this.hostAttr, ''); }
3029 /**
3030 * @param {?} parent
3031 * @param {?} name
3032 * @return {?}
3033 */
3034 createElement(parent, name) {
3035 /** @type {?} */
3036 const el = super.createElement(parent, name);
3037 super.setAttribute(el, this.contentAttr, '');
3038 return el;
3039 }
3040}
3041if (false) {
3042 /**
3043 * @type {?}
3044 * @private
3045 */
3046 EmulatedEncapsulationDomRenderer2.prototype.contentAttr;
3047 /**
3048 * @type {?}
3049 * @private
3050 */
3051 EmulatedEncapsulationDomRenderer2.prototype.hostAttr;
3052 /**
3053 * @type {?}
3054 * @private
3055 */
3056 EmulatedEncapsulationDomRenderer2.prototype.component;
3057}
3058class ShadowDomRenderer extends DefaultDomRenderer2 {
3059 /**
3060 * @param {?} eventManager
3061 * @param {?} sharedStylesHost
3062 * @param {?} hostEl
3063 * @param {?} component
3064 */
3065 constructor(eventManager, sharedStylesHost, hostEl, component) {
3066 super(eventManager);
3067 this.sharedStylesHost = sharedStylesHost;
3068 this.hostEl = hostEl;
3069 this.component = component;
3070 if (component.encapsulation === ViewEncapsulation.ShadowDom) {
3071 this.shadowRoot = ((/** @type {?} */ (hostEl))).attachShadow({ mode: 'open' });
3072 }
3073 else {
3074 this.shadowRoot = ((/** @type {?} */ (hostEl))).createShadowRoot();
3075 }
3076 this.sharedStylesHost.addHost(this.shadowRoot);
3077 /** @type {?} */
3078 const styles = flattenStyles(component.id, component.styles, []);
3079 for (let i = 0; i < styles.length; i++) {
3080 /** @type {?} */
3081 const styleEl = document.createElement('style');
3082 styleEl.textContent = styles[i];
3083 this.shadowRoot.appendChild(styleEl);
3084 }
3085 }
3086 /**
3087 * @private
3088 * @param {?} node
3089 * @return {?}
3090 */
3091 nodeOrShadowRoot(node) { return node === this.hostEl ? this.shadowRoot : node; }
3092 /**
3093 * @return {?}
3094 */
3095 destroy() { this.sharedStylesHost.removeHost(this.shadowRoot); }
3096 /**
3097 * @param {?} parent
3098 * @param {?} newChild
3099 * @return {?}
3100 */
3101 appendChild(parent, newChild) {
3102 return super.appendChild(this.nodeOrShadowRoot(parent), newChild);
3103 }
3104 /**
3105 * @param {?} parent
3106 * @param {?} newChild
3107 * @param {?} refChild
3108 * @return {?}
3109 */
3110 insertBefore(parent, newChild, refChild) {
3111 return super.insertBefore(this.nodeOrShadowRoot(parent), newChild, refChild);
3112 }
3113 /**
3114 * @param {?} parent
3115 * @param {?} oldChild
3116 * @return {?}
3117 */
3118 removeChild(parent, oldChild) {
3119 return super.removeChild(this.nodeOrShadowRoot(parent), oldChild);
3120 }
3121 /**
3122 * @param {?} node
3123 * @return {?}
3124 */
3125 parentNode(node) {
3126 return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(node)));
3127 }
3128}
3129if (false) {
3130 /**
3131 * @type {?}
3132 * @private
3133 */
3134 ShadowDomRenderer.prototype.shadowRoot;
3135 /**
3136 * @type {?}
3137 * @private
3138 */
3139 ShadowDomRenderer.prototype.sharedStylesHost;
3140 /**
3141 * @type {?}
3142 * @private
3143 */
3144 ShadowDomRenderer.prototype.hostEl;
3145 /**
3146 * @type {?}
3147 * @private
3148 */
3149 ShadowDomRenderer.prototype.component;
3150}
3151
3152/**
3153 * @fileoverview added by tsickle
3154 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3155 */
3156const ɵ0$3 = /**
3157 * @return {?}
3158 */
3159() => (typeof Zone !== 'undefined') && ((/** @type {?} */ (Zone)))['__symbol__'] ||
3160 (/**
3161 * @param {?} v
3162 * @return {?}
3163 */
3164 function (v) { return '__zone_symbol__' + v; });
3165/**
3166 * Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
3167 * since Angular can do much more
3168 * efficient bookkeeping than Zone can, because we have additional information. This speeds up
3169 * addEventListener by 3x.
3170 * @type {?}
3171 */
3172const __symbol__ = ((ɵ0$3))();
3173/** @type {?} */
3174const ADD_EVENT_LISTENER = __symbol__('addEventListener');
3175/** @type {?} */
3176const REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
3177/** @type {?} */
3178const symbolNames = {};
3179/** @type {?} */
3180const FALSE = 'FALSE';
3181/** @type {?} */
3182const ANGULAR = 'ANGULAR';
3183/** @type {?} */
3184const NATIVE_ADD_LISTENER = 'addEventListener';
3185/** @type {?} */
3186const NATIVE_REMOVE_LISTENER = 'removeEventListener';
3187// use the same symbol string which is used in zone.js
3188/** @type {?} */
3189const stopSymbol = '__zone_symbol__propagationStopped';
3190/** @type {?} */
3191const stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
3192const ɵ1 = /**
3193 * @return {?}
3194 */
3195() => {
3196 /** @type {?} */
3197 const blackListedEvents = (typeof Zone !== 'undefined') && ((/** @type {?} */ (Zone)))[__symbol__('BLACK_LISTED_EVENTS')];
3198 if (blackListedEvents) {
3199 /** @type {?} */
3200 const res = {};
3201 blackListedEvents.forEach((/**
3202 * @param {?} eventName
3203 * @return {?}
3204 */
3205 eventName => { res[eventName] = eventName; }));
3206 return res;
3207 }
3208 return undefined;
3209};
3210/** @type {?} */
3211const blackListedMap = ((ɵ1))();
3212/** @type {?} */
3213const isBlackListedEvent = (/**
3214 * @param {?} eventName
3215 * @return {?}
3216 */
3217function (eventName) {
3218 if (!blackListedMap) {
3219 return false;
3220 }
3221 return blackListedMap.hasOwnProperty(eventName);
3222});
3223const ɵ2 = isBlackListedEvent;
3224/**
3225 * @record
3226 */
3227function TaskData() { }
3228if (false) {
3229 /** @type {?} */
3230 TaskData.prototype.zone;
3231 /** @type {?} */
3232 TaskData.prototype.handler;
3233}
3234// a global listener to handle all dom event,
3235// so we do not need to create a closure every time
3236/** @type {?} */
3237const globalListener = (/**
3238 * @this {?}
3239 * @param {?} event
3240 * @return {?}
3241 */
3242function (event) {
3243 /** @type {?} */
3244 const symbolName = symbolNames[event.type];
3245 if (!symbolName) {
3246 return;
3247 }
3248 /** @type {?} */
3249 const taskDatas = this[symbolName];
3250 if (!taskDatas) {
3251 return;
3252 }
3253 /** @type {?} */
3254 const args = [event];
3255 if (taskDatas.length === 1) {
3256 // if taskDatas only have one element, just invoke it
3257 /** @type {?} */
3258 const taskData = taskDatas[0];
3259 if (taskData.zone !== Zone.current) {
3260 // only use Zone.run when Zone.current not equals to stored zone
3261 return taskData.zone.run(taskData.handler, this, args);
3262 }
3263 else {
3264 return taskData.handler.apply(this, args);
3265 }
3266 }
3267 else {
3268 // copy tasks as a snapshot to avoid event handlers remove
3269 // itself or others
3270 /** @type {?} */
3271 const copiedTasks = taskDatas.slice();
3272 for (let i = 0; i < copiedTasks.length; i++) {
3273 // if other listener call event.stopImmediatePropagation
3274 // just break
3275 if (((/** @type {?} */ (event)))[stopSymbol] === true) {
3276 break;
3277 }
3278 /** @type {?} */
3279 const taskData = copiedTasks[i];
3280 if (taskData.zone !== Zone.current) {
3281 // only use Zone.run when Zone.current not equals to stored zone
3282 taskData.zone.run(taskData.handler, this, args);
3283 }
3284 else {
3285 taskData.handler.apply(this, args);
3286 }
3287 }
3288 }
3289});
3290const ɵ3 = globalListener;
3291class DomEventsPlugin extends EventManagerPlugin {
3292 /**
3293 * @param {?} doc
3294 * @param {?} ngZone
3295 * @param {?} platformId
3296 */
3297 constructor(doc, ngZone, platformId) {
3298 super(doc);
3299 this.ngZone = ngZone;
3300 if (!platformId || !isPlatformServer(platformId)) {
3301 this.patchEvent();
3302 }
3303 }
3304 /**
3305 * @private
3306 * @return {?}
3307 */
3308 patchEvent() {
3309 if (typeof Event === 'undefined' || !Event || !Event.prototype) {
3310 return;
3311 }
3312 if (((/** @type {?} */ (Event.prototype)))[stopMethodSymbol]) {
3313 // already patched by zone.js
3314 return;
3315 }
3316 /** @type {?} */
3317 const delegate = ((/** @type {?} */ (Event.prototype)))[stopMethodSymbol] =
3318 Event.prototype.stopImmediatePropagation;
3319 Event.prototype.stopImmediatePropagation = (/**
3320 * @this {?}
3321 * @return {?}
3322 */
3323 function () {
3324 if (this) {
3325 this[stopSymbol] = true;
3326 }
3327 // We should call native delegate in case in some environment part of
3328 // the application will not use the patched Event. Also we cast the
3329 // "arguments" to any since "stopImmediatePropagation" technically does not
3330 // accept any arguments, but we don't know what developers pass through the
3331 // function and we want to not break these calls.
3332 delegate && delegate.apply(this, (/** @type {?} */ (arguments)));
3333 });
3334 }
3335 // This plugin should come last in the list of plugins, because it accepts all
3336 // events.
3337 /**
3338 * @param {?} eventName
3339 * @return {?}
3340 */
3341 supports(eventName) { return true; }
3342 /**
3343 * @param {?} element
3344 * @param {?} eventName
3345 * @param {?} handler
3346 * @return {?}
3347 */
3348 addEventListener(element, eventName, handler) {
3349 /**
3350 * This code is about to add a listener to the DOM. If Zone.js is present, than
3351 * `addEventListener` has been patched. The patched code adds overhead in both
3352 * memory and speed (3x slower) than native. For this reason if we detect that
3353 * Zone.js is present we use a simple version of zone aware addEventListener instead.
3354 * The result is faster registration and the zone will be restored.
3355 * But ZoneSpec.onScheduleTask, ZoneSpec.onInvokeTask, ZoneSpec.onCancelTask
3356 * will not be invoked
3357 * We also do manual zone restoration in element.ts renderEventHandlerClosure method.
3358 *
3359 * NOTE: it is possible that the element is from different iframe, and so we
3360 * have to check before we execute the method.
3361 * @type {?}
3362 */
3363 const self = this;
3364 /** @type {?} */
3365 const zoneJsLoaded = element[ADD_EVENT_LISTENER];
3366 /** @type {?} */
3367 let callback = (/** @type {?} */ (handler));
3368 // if zonejs is loaded and current zone is not ngZone
3369 // we keep Zone.current on target for later restoration.
3370 if (zoneJsLoaded && (!NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
3371 /** @type {?} */
3372 let symbolName = symbolNames[eventName];
3373 if (!symbolName) {
3374 symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
3375 }
3376 /** @type {?} */
3377 let taskDatas = ((/** @type {?} */ (element)))[symbolName];
3378 /** @type {?} */
3379 const globalListenerRegistered = taskDatas && taskDatas.length > 0;
3380 if (!taskDatas) {
3381 taskDatas = ((/** @type {?} */ (element)))[symbolName] = [];
3382 }
3383 /** @type {?} */
3384 const zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
3385 if (taskDatas.length === 0) {
3386 taskDatas.push({ zone: zone, handler: callback });
3387 }
3388 else {
3389 /** @type {?} */
3390 let callbackRegistered = false;
3391 for (let i = 0; i < taskDatas.length; i++) {
3392 if (taskDatas[i].handler === callback) {
3393 callbackRegistered = true;
3394 break;
3395 }
3396 }
3397 if (!callbackRegistered) {
3398 taskDatas.push({ zone: zone, handler: callback });
3399 }
3400 }
3401 if (!globalListenerRegistered) {
3402 element[ADD_EVENT_LISTENER](eventName, globalListener, false);
3403 }
3404 }
3405 else {
3406 element[NATIVE_ADD_LISTENER](eventName, callback, false);
3407 }
3408 return (/**
3409 * @return {?}
3410 */
3411 () => this.removeEventListener(element, eventName, callback));
3412 }
3413 /**
3414 * @param {?} target
3415 * @param {?} eventName
3416 * @param {?} callback
3417 * @return {?}
3418 */
3419 removeEventListener(target, eventName, callback) {
3420 /** @type {?} */
3421 let underlyingRemove = target[REMOVE_EVENT_LISTENER];
3422 // zone.js not loaded, use native removeEventListener
3423 if (!underlyingRemove) {
3424 return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
3425 }
3426 /** @type {?} */
3427 let symbolName = symbolNames[eventName];
3428 /** @type {?} */
3429 let taskDatas = symbolName && target[symbolName];
3430 if (!taskDatas) {
3431 // addEventListener not using patched version
3432 // just call native removeEventListener
3433 return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
3434 }
3435 // fix issue 20532, should be able to remove
3436 // listener which was added inside of ngZone
3437 /** @type {?} */
3438 let found = false;
3439 for (let i = 0; i < taskDatas.length; i++) {
3440 // remove listener from taskDatas if the callback equals
3441 if (taskDatas[i].handler === callback) {
3442 found = true;
3443 taskDatas.splice(i, 1);
3444 break;
3445 }
3446 }
3447 if (found) {
3448 if (taskDatas.length === 0) {
3449 // all listeners are removed, we can remove the globalListener from target
3450 underlyingRemove.apply(target, [eventName, globalListener, false]);
3451 }
3452 }
3453 else {
3454 // not found in taskDatas, the callback may be added inside of ngZone
3455 // use native remove listener to remove the callback
3456 target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
3457 }
3458 }
3459}
3460DomEventsPlugin.decorators = [
3461 { type: Injectable }
3462];
3463/** @nocollapse */
3464DomEventsPlugin.ctorParameters = () => [
3465 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
3466 { type: NgZone },
3467 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [PLATFORM_ID,] }] }
3468];
3469if (false) {
3470 /**
3471 * @type {?}
3472 * @private
3473 */
3474 DomEventsPlugin.prototype.ngZone;
3475}
3476
3477/**
3478 * @fileoverview added by tsickle
3479 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3480 */
3481/**
3482 * Supported HammerJS recognizer event names.
3483 * @type {?}
3484 */
3485const EVENT_NAMES = {
3486 // pan
3487 'pan': true,
3488 'panstart': true,
3489 'panmove': true,
3490 'panend': true,
3491 'pancancel': true,
3492 'panleft': true,
3493 'panright': true,
3494 'panup': true,
3495 'pandown': true,
3496 // pinch
3497 'pinch': true,
3498 'pinchstart': true,
3499 'pinchmove': true,
3500 'pinchend': true,
3501 'pinchcancel': true,
3502 'pinchin': true,
3503 'pinchout': true,
3504 // press
3505 'press': true,
3506 'pressup': true,
3507 // rotate
3508 'rotate': true,
3509 'rotatestart': true,
3510 'rotatemove': true,
3511 'rotateend': true,
3512 'rotatecancel': true,
3513 // swipe
3514 'swipe': true,
3515 'swipeleft': true,
3516 'swiperight': true,
3517 'swipeup': true,
3518 'swipedown': true,
3519 // tap
3520 'tap': true,
3521};
3522/**
3523 * DI token for providing [HammerJS](http://hammerjs.github.io/) support to Angular.
3524 * @see `HammerGestureConfig`
3525 *
3526 * \@publicApi
3527 * @type {?}
3528 */
3529const HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
3530/**
3531 * Injection token used to provide a {\@link HammerLoader} to Angular.
3532 *
3533 * \@publicApi
3534 * @type {?}
3535 */
3536const HAMMER_LOADER = new InjectionToken('HammerLoader');
3537/**
3538 * @record
3539 */
3540function HammerInstance() { }
3541if (false) {
3542 /**
3543 * @param {?} eventName
3544 * @param {?=} callback
3545 * @return {?}
3546 */
3547 HammerInstance.prototype.on = function (eventName, callback) { };
3548 /**
3549 * @param {?} eventName
3550 * @param {?=} callback
3551 * @return {?}
3552 */
3553 HammerInstance.prototype.off = function (eventName, callback) { };
3554 /**
3555 * @return {?}
3556 */
3557 HammerInstance.prototype.destroy = function () { };
3558}
3559/**
3560 * An injectable [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
3561 * for gesture recognition. Configures specific event recognition.
3562 * \@publicApi
3563 */
3564class HammerGestureConfig {
3565 constructor() {
3566 /**
3567 * A set of supported event names for gestures to be used in Angular.
3568 * Angular supports all built-in recognizers, as listed in
3569 * [HammerJS documentation](http://hammerjs.github.io/).
3570 */
3571 this.events = [];
3572 /**
3573 * Maps gesture event names to a set of configuration options
3574 * that specify overrides to the default values for specific properties.
3575 *
3576 * The key is a supported event name to be configured,
3577 * and the options object contains a set of properties, with override values
3578 * to be applied to the named recognizer event.
3579 * For example, to disable recognition of the rotate event, specify
3580 * `{"rotate": {"enable": false}}`.
3581 *
3582 * Properties that are not present take the HammerJS default values.
3583 * For information about which properties are supported for which events,
3584 * and their allowed and default values, see
3585 * [HammerJS documentation](http://hammerjs.github.io/).
3586 *
3587 */
3588 this.overrides = {};
3589 }
3590 /**
3591 * Creates a [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
3592 * and attaches it to a given HTML element.
3593 * @param {?} element The element that will recognize gestures.
3594 * @return {?} A HammerJS event-manager object.
3595 */
3596 buildHammer(element) {
3597 /** @type {?} */
3598 const mc = new (/** @type {?} */ (Hammer))(element, this.options);
3599 mc.get('pinch').set({ enable: true });
3600 mc.get('rotate').set({ enable: true });
3601 for (const eventName in this.overrides) {
3602 mc.get(eventName).set(this.overrides[eventName]);
3603 }
3604 return mc;
3605 }
3606}
3607HammerGestureConfig.decorators = [
3608 { type: Injectable }
3609];
3610if (false) {
3611 /**
3612 * A set of supported event names for gestures to be used in Angular.
3613 * Angular supports all built-in recognizers, as listed in
3614 * [HammerJS documentation](http://hammerjs.github.io/).
3615 * @type {?}
3616 */
3617 HammerGestureConfig.prototype.events;
3618 /**
3619 * Maps gesture event names to a set of configuration options
3620 * that specify overrides to the default values for specific properties.
3621 *
3622 * The key is a supported event name to be configured,
3623 * and the options object contains a set of properties, with override values
3624 * to be applied to the named recognizer event.
3625 * For example, to disable recognition of the rotate event, specify
3626 * `{"rotate": {"enable": false}}`.
3627 *
3628 * Properties that are not present take the HammerJS default values.
3629 * For information about which properties are supported for which events,
3630 * and their allowed and default values, see
3631 * [HammerJS documentation](http://hammerjs.github.io/).
3632 *
3633 * @type {?}
3634 */
3635 HammerGestureConfig.prototype.overrides;
3636 /**
3637 * Properties whose default values can be overridden for a given event.
3638 * Different sets of properties apply to different events.
3639 * For information about which properties are supported for which events,
3640 * and their allowed and default values, see
3641 * [HammerJS documentation](http://hammerjs.github.io/).
3642 * @type {?}
3643 */
3644 HammerGestureConfig.prototype.options;
3645}
3646class HammerGesturesPlugin extends EventManagerPlugin {
3647 /**
3648 * @param {?} doc
3649 * @param {?} _config
3650 * @param {?} console
3651 * @param {?=} loader
3652 */
3653 constructor(doc, _config, console, loader) {
3654 super(doc);
3655 this._config = _config;
3656 this.console = console;
3657 this.loader = loader;
3658 }
3659 /**
3660 * @param {?} eventName
3661 * @return {?}
3662 */
3663 supports(eventName) {
3664 if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
3665 return false;
3666 }
3667 if (!((/** @type {?} */ (window))).Hammer && !this.loader) {
3668 this.console.warn(`The "${eventName}" event cannot be bound because Hammer.JS is not ` +
3669 `loaded and no custom loader has been specified.`);
3670 return false;
3671 }
3672 return true;
3673 }
3674 /**
3675 * @param {?} element
3676 * @param {?} eventName
3677 * @param {?} handler
3678 * @return {?}
3679 */
3680 addEventListener(element, eventName, handler) {
3681 /** @type {?} */
3682 const zone = this.manager.getZone();
3683 eventName = eventName.toLowerCase();
3684 // If Hammer is not present but a loader is specified, we defer adding the event listener
3685 // until Hammer is loaded.
3686 if (!((/** @type {?} */ (window))).Hammer && this.loader) {
3687 // This `addEventListener` method returns a function to remove the added listener.
3688 // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
3689 // than remove anything.
3690 /** @type {?} */
3691 let cancelRegistration = false;
3692 /** @type {?} */
3693 let deregister = (/**
3694 * @return {?}
3695 */
3696 () => { cancelRegistration = true; });
3697 this.loader()
3698 .then((/**
3699 * @return {?}
3700 */
3701 () => {
3702 // If Hammer isn't actually loaded when the custom loader resolves, give up.
3703 if (!((/** @type {?} */ (window))).Hammer) {
3704 this.console.warn(`The custom HAMMER_LOADER completed, but Hammer.JS is not present.`);
3705 deregister = (/**
3706 * @return {?}
3707 */
3708 () => { });
3709 return;
3710 }
3711 if (!cancelRegistration) {
3712 // Now that Hammer is loaded and the listener is being loaded for real,
3713 // the deregistration function changes from canceling registration to removal.
3714 deregister = this.addEventListener(element, eventName, handler);
3715 }
3716 }))
3717 .catch((/**
3718 * @return {?}
3719 */
3720 () => {
3721 this.console.warn(`The "${eventName}" event cannot be bound because the custom ` +
3722 `Hammer.JS loader failed.`);
3723 deregister = (/**
3724 * @return {?}
3725 */
3726 () => { });
3727 }));
3728 // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
3729 // can change the behavior of `deregister` once the listener is added. Using a closure in
3730 // this way allows us to avoid any additional data structures to track listener removal.
3731 return (/**
3732 * @return {?}
3733 */
3734 () => { deregister(); });
3735 }
3736 return zone.runOutsideAngular((/**
3737 * @return {?}
3738 */
3739 () => {
3740 // Creating the manager bind events, must be done outside of angular
3741 /** @type {?} */
3742 const mc = this._config.buildHammer(element);
3743 /** @type {?} */
3744 const callback = (/**
3745 * @param {?} eventObj
3746 * @return {?}
3747 */
3748 function (eventObj) {
3749 zone.runGuarded((/**
3750 * @return {?}
3751 */
3752 function () { handler(eventObj); }));
3753 });
3754 mc.on(eventName, callback);
3755 return (/**
3756 * @return {?}
3757 */
3758 () => {
3759 mc.off(eventName, callback);
3760 // destroy mc to prevent memory leak
3761 if (typeof mc.destroy === 'function') {
3762 mc.destroy();
3763 }
3764 });
3765 }));
3766 }
3767 /**
3768 * @param {?} eventName
3769 * @return {?}
3770 */
3771 isCustomEvent(eventName) { return this._config.events.indexOf(eventName) > -1; }
3772}
3773HammerGesturesPlugin.decorators = [
3774 { type: Injectable }
3775];
3776/** @nocollapse */
3777HammerGesturesPlugin.ctorParameters = () => [
3778 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
3779 { type: HammerGestureConfig, decorators: [{ type: Inject, args: [HAMMER_GESTURE_CONFIG,] }] },
3780 { type: ɵConsole },
3781 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [HAMMER_LOADER,] }] }
3782];
3783if (false) {
3784 /**
3785 * @type {?}
3786 * @private
3787 */
3788 HammerGesturesPlugin.prototype._config;
3789 /**
3790 * @type {?}
3791 * @private
3792 */
3793 HammerGesturesPlugin.prototype.console;
3794 /**
3795 * @type {?}
3796 * @private
3797 */
3798 HammerGesturesPlugin.prototype.loader;
3799}
3800
3801/**
3802 * @fileoverview added by tsickle
3803 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3804 */
3805/**
3806 * Defines supported modifiers for key events.
3807 * @type {?}
3808 */
3809const MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
3810const ɵ0$4 = /**
3811 * @param {?} event
3812 * @return {?}
3813 */
3814(event) => event.altKey, ɵ1$1 = /**
3815 * @param {?} event
3816 * @return {?}
3817 */
3818(event) => event.ctrlKey, ɵ2$1 = /**
3819 * @param {?} event
3820 * @return {?}
3821 */
3822(event) => event.metaKey, ɵ3$1 = /**
3823 * @param {?} event
3824 * @return {?}
3825 */
3826(event) => event.shiftKey;
3827/**
3828 * Retrieves modifiers from key-event objects.
3829 * @type {?}
3830 */
3831const MODIFIER_KEY_GETTERS = {
3832 'alt': (ɵ0$4),
3833 'control': (ɵ1$1),
3834 'meta': (ɵ2$1),
3835 'shift': (ɵ3$1)
3836};
3837/**
3838 * \@publicApi
3839 * A browser plug-in that provides support for handling of key events in Angular.
3840 */
3841class KeyEventsPlugin extends EventManagerPlugin {
3842 /**
3843 * Initializes an instance of the browser plug-in.
3844 * @param {?} doc The document in which key events will be detected.
3845 */
3846 constructor(doc) { super(doc); }
3847 /**
3848 * Reports whether a named key event is supported.
3849 * @param {?} eventName The event name to query.
3850 * @return {?} True if the named key event is supported.
3851 */
3852 supports(eventName) { return KeyEventsPlugin.parseEventName(eventName) != null; }
3853 /**
3854 * Registers a handler for a specific element and key event.
3855 * @param {?} element The HTML element to receive event notifications.
3856 * @param {?} eventName The name of the key event to listen for.
3857 * @param {?} handler A function to call when the notification occurs. Receives the
3858 * event object as an argument.
3859 * @return {?} The key event that was registered.
3860 */
3861 addEventListener(element, eventName, handler) {
3862 /** @type {?} */
3863 const parsedEvent = (/** @type {?} */ (KeyEventsPlugin.parseEventName(eventName)));
3864 /** @type {?} */
3865 const outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
3866 return this.manager.getZone().runOutsideAngular((/**
3867 * @return {?}
3868 */
3869 () => {
3870 return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
3871 }));
3872 }
3873 /**
3874 * @param {?} eventName
3875 * @return {?}
3876 */
3877 static parseEventName(eventName) {
3878 /** @type {?} */
3879 const parts = eventName.toLowerCase().split('.');
3880 /** @type {?} */
3881 const domEventName = parts.shift();
3882 if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
3883 return null;
3884 }
3885 /** @type {?} */
3886 const key = KeyEventsPlugin._normalizeKey((/** @type {?} */ (parts.pop())));
3887 /** @type {?} */
3888 let fullKey = '';
3889 MODIFIER_KEYS.forEach((/**
3890 * @param {?} modifierName
3891 * @return {?}
3892 */
3893 modifierName => {
3894 /** @type {?} */
3895 const index = parts.indexOf(modifierName);
3896 if (index > -1) {
3897 parts.splice(index, 1);
3898 fullKey += modifierName + '.';
3899 }
3900 }));
3901 fullKey += key;
3902 if (parts.length != 0 || key.length === 0) {
3903 // returning null instead of throwing to let another plugin process the event
3904 return null;
3905 }
3906 /** @type {?} */
3907 const result = {};
3908 result['domEventName'] = domEventName;
3909 result['fullKey'] = fullKey;
3910 return result;
3911 }
3912 /**
3913 * @param {?} event
3914 * @return {?}
3915 */
3916 static getEventFullKey(event) {
3917 /** @type {?} */
3918 let fullKey = '';
3919 /** @type {?} */
3920 let key = getDOM().getEventKey(event);
3921 key = key.toLowerCase();
3922 if (key === ' ') {
3923 key = 'space'; // for readability
3924 }
3925 else if (key === '.') {
3926 key = 'dot'; // because '.' is used as a separator in event names
3927 }
3928 MODIFIER_KEYS.forEach((/**
3929 * @param {?} modifierName
3930 * @return {?}
3931 */
3932 modifierName => {
3933 if (modifierName != key) {
3934 /** @type {?} */
3935 const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
3936 if (modifierGetter(event)) {
3937 fullKey += modifierName + '.';
3938 }
3939 }
3940 }));
3941 fullKey += key;
3942 return fullKey;
3943 }
3944 /**
3945 * Configures a handler callback for a key event.
3946 * @param {?} fullKey The event name that combines all simultaneous keystrokes.
3947 * @param {?} handler The function that responds to the key event.
3948 * @param {?} zone The zone in which the event occurred.
3949 * @return {?} A callback function.
3950 */
3951 static eventCallback(fullKey, handler, zone) {
3952 return (/**
3953 * @param {?} event
3954 * @return {?}
3955 */
3956 (event /** TODO #9100 */) => {
3957 if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
3958 zone.runGuarded((/**
3959 * @return {?}
3960 */
3961 () => handler(event)));
3962 }
3963 });
3964 }
3965 /**
3966 * \@internal
3967 * @param {?} keyName
3968 * @return {?}
3969 */
3970 static _normalizeKey(keyName) {
3971 // TODO: switch to a Map if the mapping grows too much
3972 switch (keyName) {
3973 case 'esc':
3974 return 'escape';
3975 default:
3976 return keyName;
3977 }
3978 }
3979}
3980KeyEventsPlugin.decorators = [
3981 { type: Injectable }
3982];
3983/** @nocollapse */
3984KeyEventsPlugin.ctorParameters = () => [
3985 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
3986];
3987
3988/**
3989 * @fileoverview added by tsickle
3990 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3991 */
3992/**
3993 * Marker interface for a value that's safe to use in a particular context.
3994 *
3995 * \@publicApi
3996 * @record
3997 */
3998function SafeValue() { }
3999/**
4000 * Marker interface for a value that's safe to use as HTML.
4001 *
4002 * \@publicApi
4003 * @record
4004 */
4005function SafeHtml() { }
4006/**
4007 * Marker interface for a value that's safe to use as style (CSS).
4008 *
4009 * \@publicApi
4010 * @record
4011 */
4012function SafeStyle() { }
4013/**
4014 * Marker interface for a value that's safe to use as JavaScript.
4015 *
4016 * \@publicApi
4017 * @record
4018 */
4019function SafeScript() { }
4020/**
4021 * Marker interface for a value that's safe to use as a URL linking to a document.
4022 *
4023 * \@publicApi
4024 * @record
4025 */
4026function SafeUrl() { }
4027/**
4028 * Marker interface for a value that's safe to use as a URL to load executable code from.
4029 *
4030 * \@publicApi
4031 * @record
4032 */
4033function SafeResourceUrl() { }
4034/**
4035 * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
4036 * values to be safe to use in the different DOM contexts.
4037 *
4038 * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
4039 * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
4040 * the website.
4041 *
4042 * In specific situations, it might be necessary to disable sanitization, for example if the
4043 * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
4044 * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
4045 * methods, and then binding to that value from the template.
4046 *
4047 * These situations should be very rare, and extraordinary care must be taken to avoid creating a
4048 * Cross Site Scripting (XSS) security bug!
4049 *
4050 * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
4051 * close as possible to the source of the value, to make it easy to verify no security bug is
4052 * created by its use.
4053 *
4054 * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
4055 * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
4056 * code. The sanitizer leaves safe values intact.
4057 *
4058 * \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
4059 * sanitization for the value passed in. Carefully check and audit all values and code paths going
4060 * into this call. Make sure any user data is appropriately escaped for this security context.
4061 * For more detail, see the [Security Guide](http://g.co/ng/security).
4062 *
4063 * \@publicApi
4064 * @abstract
4065 */
4066class DomSanitizer {
4067}
4068if (false) {
4069 /**
4070 * Sanitizes a value for use in the given SecurityContext.
4071 *
4072 * If value is trusted for the context, this method will unwrap the contained safe value and use
4073 * it directly. Otherwise, value will be sanitized to be safe in the given context, for example
4074 * by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
4075 * is responsible to make sure that the value can definitely be safely used in the given context.
4076 * @abstract
4077 * @param {?} context
4078 * @param {?} value
4079 * @return {?}
4080 */
4081 DomSanitizer.prototype.sanitize = function (context, value) { };
4082 /**
4083 * Bypass security and trust the given value to be safe HTML. Only use this when the bound HTML
4084 * is unsafe (e.g. contains `<script>` tags) and the code should be executed. The sanitizer will
4085 * leave safe HTML intact, so in most situations this method should not be used.
4086 *
4087 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
4088 * security risks!
4089 * @abstract
4090 * @param {?} value
4091 * @return {?}
4092 */
4093 DomSanitizer.prototype.bypassSecurityTrustHtml = function (value) { };
4094 /**
4095 * Bypass security and trust the given value to be safe style value (CSS).
4096 *
4097 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
4098 * security risks!
4099 * @abstract
4100 * @param {?} value
4101 * @return {?}
4102 */
4103 DomSanitizer.prototype.bypassSecurityTrustStyle = function (value) { };
4104 /**
4105 * Bypass security and trust the given value to be safe JavaScript.
4106 *
4107 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
4108 * security risks!
4109 * @abstract
4110 * @param {?} value
4111 * @return {?}
4112 */
4113 DomSanitizer.prototype.bypassSecurityTrustScript = function (value) { };
4114 /**
4115 * Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used
4116 * in hyperlinks or `<img src>`.
4117 *
4118 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
4119 * security risks!
4120 * @abstract
4121 * @param {?} value
4122 * @return {?}
4123 */
4124 DomSanitizer.prototype.bypassSecurityTrustUrl = function (value) { };
4125 /**
4126 * Bypass security and trust the given value to be a safe resource URL, i.e. a location that may
4127 * be used to load executable code from, like `<script src>`, or `<iframe src>`.
4128 *
4129 * **WARNING:** calling this method with untrusted user data exposes your application to XSS
4130 * security risks!
4131 * @abstract
4132 * @param {?} value
4133 * @return {?}
4134 */
4135 DomSanitizer.prototype.bypassSecurityTrustResourceUrl = function (value) { };
4136}
4137class DomSanitizerImpl extends DomSanitizer {
4138 /**
4139 * @param {?} _doc
4140 */
4141 constructor(_doc) {
4142 super();
4143 this._doc = _doc;
4144 }
4145 /**
4146 * @param {?} ctx
4147 * @param {?} value
4148 * @return {?}
4149 */
4150 sanitize(ctx, value) {
4151 if (value == null)
4152 return null;
4153 switch (ctx) {
4154 case SecurityContext.NONE:
4155 return (/** @type {?} */ (value));
4156 case SecurityContext.HTML:
4157 if (value instanceof SafeHtmlImpl)
4158 return value.changingThisBreaksApplicationSecurity;
4159 this.checkNotSafeValue(value, 'HTML');
4160 return ɵ_sanitizeHtml(this._doc, String(value));
4161 case SecurityContext.STYLE:
4162 if (value instanceof SafeStyleImpl)
4163 return value.changingThisBreaksApplicationSecurity;
4164 this.checkNotSafeValue(value, 'Style');
4165 return ɵ_sanitizeStyle((/** @type {?} */ (value)));
4166 case SecurityContext.SCRIPT:
4167 if (value instanceof SafeScriptImpl)
4168 return value.changingThisBreaksApplicationSecurity;
4169 this.checkNotSafeValue(value, 'Script');
4170 throw new Error('unsafe value used in a script context');
4171 case SecurityContext.URL:
4172 if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
4173 // Allow resource URLs in URL contexts, they are strictly more trusted.
4174 return value.changingThisBreaksApplicationSecurity;
4175 }
4176 this.checkNotSafeValue(value, 'URL');
4177 return ɵ_sanitizeUrl(String(value));
4178 case SecurityContext.RESOURCE_URL:
4179 if (value instanceof SafeResourceUrlImpl) {
4180 return value.changingThisBreaksApplicationSecurity;
4181 }
4182 this.checkNotSafeValue(value, 'ResourceURL');
4183 throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
4184 default:
4185 throw new Error(`Unexpected SecurityContext ${ctx} (see http://g.co/ng/security#xss)`);
4186 }
4187 }
4188 /**
4189 * @private
4190 * @param {?} value
4191 * @param {?} expectedType
4192 * @return {?}
4193 */
4194 checkNotSafeValue(value, expectedType) {
4195 if (value instanceof SafeValueImpl) {
4196 throw new Error(`Required a safe ${expectedType}, got a ${value.getTypeName()} ` +
4197 `(see http://g.co/ng/security#xss)`);
4198 }
4199 }
4200 /**
4201 * @param {?} value
4202 * @return {?}
4203 */
4204 bypassSecurityTrustHtml(value) { return new SafeHtmlImpl(value); }
4205 /**
4206 * @param {?} value
4207 * @return {?}
4208 */
4209 bypassSecurityTrustStyle(value) { return new SafeStyleImpl(value); }
4210 /**
4211 * @param {?} value
4212 * @return {?}
4213 */
4214 bypassSecurityTrustScript(value) { return new SafeScriptImpl(value); }
4215 /**
4216 * @param {?} value
4217 * @return {?}
4218 */
4219 bypassSecurityTrustUrl(value) { return new SafeUrlImpl(value); }
4220 /**
4221 * @param {?} value
4222 * @return {?}
4223 */
4224 bypassSecurityTrustResourceUrl(value) {
4225 return new SafeResourceUrlImpl(value);
4226 }
4227}
4228DomSanitizerImpl.decorators = [
4229 { type: Injectable }
4230];
4231/** @nocollapse */
4232DomSanitizerImpl.ctorParameters = () => [
4233 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
4234];
4235if (false) {
4236 /**
4237 * @type {?}
4238 * @private
4239 */
4240 DomSanitizerImpl.prototype._doc;
4241}
4242/**
4243 * @abstract
4244 */
4245class SafeValueImpl {
4246 /**
4247 * @param {?} changingThisBreaksApplicationSecurity
4248 */
4249 constructor(changingThisBreaksApplicationSecurity) {
4250 this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
4251 // empty
4252 }
4253 /**
4254 * @return {?}
4255 */
4256 toString() {
4257 return `SafeValue must use [property]=binding: ${this.changingThisBreaksApplicationSecurity}` +
4258 ` (see http://g.co/ng/security#xss)`;
4259 }
4260}
4261if (false) {
4262 /** @type {?} */
4263 SafeValueImpl.prototype.changingThisBreaksApplicationSecurity;
4264 /**
4265 * @abstract
4266 * @return {?}
4267 */
4268 SafeValueImpl.prototype.getTypeName = function () { };
4269}
4270class SafeHtmlImpl extends SafeValueImpl {
4271 /**
4272 * @return {?}
4273 */
4274 getTypeName() { return 'HTML'; }
4275}
4276class SafeStyleImpl extends SafeValueImpl {
4277 /**
4278 * @return {?}
4279 */
4280 getTypeName() { return 'Style'; }
4281}
4282class SafeScriptImpl extends SafeValueImpl {
4283 /**
4284 * @return {?}
4285 */
4286 getTypeName() { return 'Script'; }
4287}
4288class SafeUrlImpl extends SafeValueImpl {
4289 /**
4290 * @return {?}
4291 */
4292 getTypeName() { return 'URL'; }
4293}
4294class SafeResourceUrlImpl extends SafeValueImpl {
4295 /**
4296 * @return {?}
4297 */
4298 getTypeName() { return 'ResourceURL'; }
4299}
4300
4301/**
4302 * @fileoverview added by tsickle
4303 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4304 */
4305const ɵ0$5 = ɵPLATFORM_BROWSER_ID;
4306/** @type {?} */
4307const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
4308 { provide: PLATFORM_ID, useValue: ɵ0$5 },
4309 { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
4310 { provide: PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT] },
4311 { provide: DOCUMENT, useFactory: _document, deps: [] },
4312];
4313/**
4314 * \@security Replacing built-in sanitization providers exposes the application to XSS risks.
4315 * Attacker-controlled data introduced by an unsanitized provider could expose your
4316 * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
4317 * \@publicApi
4318 * @type {?}
4319 */
4320const BROWSER_SANITIZATION_PROVIDERS = [
4321 { provide: Sanitizer, useExisting: DomSanitizer },
4322 { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
4323];
4324/**
4325 * \@publicApi
4326 * @type {?}
4327 */
4328const platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
4329/**
4330 * @return {?}
4331 */
4332function initDomAdapter() {
4333 BrowserDomAdapter.makeCurrent();
4334 BrowserGetTestability.init();
4335}
4336/**
4337 * @return {?}
4338 */
4339function errorHandler() {
4340 return new ErrorHandler();
4341}
4342/**
4343 * @return {?}
4344 */
4345function _document() {
4346 return document;
4347}
4348/** @type {?} */
4349const BROWSER_MODULE_PROVIDERS = [
4350 BROWSER_SANITIZATION_PROVIDERS,
4351 { provide: ɵAPP_ROOT, useValue: true },
4352 { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
4353 {
4354 provide: EVENT_MANAGER_PLUGINS,
4355 useClass: DomEventsPlugin,
4356 multi: true,
4357 deps: [DOCUMENT, NgZone, PLATFORM_ID]
4358 },
4359 { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
4360 {
4361 provide: EVENT_MANAGER_PLUGINS,
4362 useClass: HammerGesturesPlugin,
4363 multi: true,
4364 deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
4365 },
4366 { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
4367 {
4368 provide: DomRendererFactory2,
4369 useClass: DomRendererFactory2,
4370 deps: [EventManager, DomSharedStylesHost, APP_ID]
4371 },
4372 { provide: RendererFactory2, useExisting: DomRendererFactory2 },
4373 { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
4374 { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
4375 { provide: Testability, useClass: Testability, deps: [NgZone] },
4376 { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
4377 ELEMENT_PROBE_PROVIDERS,
4378];
4379/**
4380 * Exports required infrastructure for all Angular apps.
4381 * Included by default in all Angular apps created with the CLI
4382 * `new` command.
4383 * Re-exports `CommonModule` and `ApplicationModule`, making their
4384 * exports and providers available to all apps.
4385 *
4386 * \@publicApi
4387 */
4388class BrowserModule {
4389 /**
4390 * @param {?} parentModule
4391 */
4392 constructor(parentModule) {
4393 if (parentModule) {
4394 throw new Error(`BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.`);
4395 }
4396 }
4397 /**
4398 * Configures a browser-based app to transition from a server-rendered app, if
4399 * one is present on the page.
4400 *
4401 * @param {?} params An object containing an identifier for the app to transition.
4402 * The ID must match between the client and server versions of the app.
4403 * @return {?} The reconfigured `BrowserModule` to import into the app's root `AppModule`.
4404 */
4405 static withServerTransition(params) {
4406 return {
4407 ngModule: BrowserModule,
4408 providers: [
4409 { provide: APP_ID, useValue: params.appId },
4410 { provide: TRANSITION_ID, useExisting: APP_ID },
4411 SERVER_TRANSITION_PROVIDERS,
4412 ],
4413 };
4414 }
4415}
4416BrowserModule.decorators = [
4417 { type: NgModule, args: [{ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] },] }
4418];
4419/** @nocollapse */
4420BrowserModule.ctorParameters = () => [
4421 { type: undefined, decorators: [{ type: Optional }, { type: SkipSelf }, { type: Inject, args: [BrowserModule,] }] }
4422];
4423
4424/**
4425 * @fileoverview added by tsickle
4426 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4427 */
4428/**
4429 * Factory to create Meta service.
4430 * @return {?}
4431 */
4432function createMeta() {
4433 return new Meta(ɵɵinject(DOCUMENT));
4434}
4435/**
4436 * A service that can be used to get and add meta tags.
4437 *
4438 * \@publicApi
4439 */
4440class Meta {
4441 /**
4442 * @param {?} _doc
4443 */
4444 constructor(_doc) {
4445 this._doc = _doc;
4446 this._dom = getDOM();
4447 }
4448 /**
4449 * @param {?} tag
4450 * @param {?=} forceCreation
4451 * @return {?}
4452 */
4453 addTag(tag, forceCreation = false) {
4454 if (!tag)
4455 return null;
4456 return this._getOrCreateElement(tag, forceCreation);
4457 }
4458 /**
4459 * @param {?} tags
4460 * @param {?=} forceCreation
4461 * @return {?}
4462 */
4463 addTags(tags, forceCreation = false) {
4464 if (!tags)
4465 return [];
4466 return tags.reduce((/**
4467 * @param {?} result
4468 * @param {?} tag
4469 * @return {?}
4470 */
4471 (result, tag) => {
4472 if (tag) {
4473 result.push(this._getOrCreateElement(tag, forceCreation));
4474 }
4475 return result;
4476 }), []);
4477 }
4478 /**
4479 * @param {?} attrSelector
4480 * @return {?}
4481 */
4482 getTag(attrSelector) {
4483 if (!attrSelector)
4484 return null;
4485 return this._dom.querySelector(this._doc, `meta[${attrSelector}]`) || null;
4486 }
4487 /**
4488 * @param {?} attrSelector
4489 * @return {?}
4490 */
4491 getTags(attrSelector) {
4492 if (!attrSelector)
4493 return [];
4494 /** @type {?} */
4495 const list /*NodeList*/ = this._dom.querySelectorAll(this._doc, `meta[${attrSelector}]`);
4496 return list ? [].slice.call(list) : [];
4497 }
4498 /**
4499 * @param {?} tag
4500 * @param {?=} selector
4501 * @return {?}
4502 */
4503 updateTag(tag, selector) {
4504 if (!tag)
4505 return null;
4506 selector = selector || this._parseSelector(tag);
4507 /** @type {?} */
4508 const meta = (/** @type {?} */ (this.getTag(selector)));
4509 if (meta) {
4510 return this._setMetaElementAttributes(tag, meta);
4511 }
4512 return this._getOrCreateElement(tag, true);
4513 }
4514 /**
4515 * @param {?} attrSelector
4516 * @return {?}
4517 */
4518 removeTag(attrSelector) { this.removeTagElement((/** @type {?} */ (this.getTag(attrSelector)))); }
4519 /**
4520 * @param {?} meta
4521 * @return {?}
4522 */
4523 removeTagElement(meta) {
4524 if (meta) {
4525 this._dom.remove(meta);
4526 }
4527 }
4528 /**
4529 * @private
4530 * @param {?} meta
4531 * @param {?=} forceCreation
4532 * @return {?}
4533 */
4534 _getOrCreateElement(meta, forceCreation = false) {
4535 if (!forceCreation) {
4536 /** @type {?} */
4537 const selector = this._parseSelector(meta);
4538 /** @type {?} */
4539 const elem = (/** @type {?} */ (this.getTag(selector)));
4540 // It's allowed to have multiple elements with the same name so it's not enough to
4541 // just check that element with the same name already present on the page. We also need to
4542 // check if element has tag attributes
4543 if (elem && this._containsAttributes(meta, elem))
4544 return elem;
4545 }
4546 /** @type {?} */
4547 const element = (/** @type {?} */ (this._dom.createElement('meta')));
4548 this._setMetaElementAttributes(meta, element);
4549 /** @type {?} */
4550 const head = this._dom.getElementsByTagName(this._doc, 'head')[0];
4551 this._dom.appendChild(head, element);
4552 return element;
4553 }
4554 /**
4555 * @private
4556 * @param {?} tag
4557 * @param {?} el
4558 * @return {?}
4559 */
4560 _setMetaElementAttributes(tag, el) {
4561 Object.keys(tag).forEach((/**
4562 * @param {?} prop
4563 * @return {?}
4564 */
4565 (prop) => this._dom.setAttribute(el, prop, tag[prop])));
4566 return el;
4567 }
4568 /**
4569 * @private
4570 * @param {?} tag
4571 * @return {?}
4572 */
4573 _parseSelector(tag) {
4574 /** @type {?} */
4575 const attr = tag.name ? 'name' : 'property';
4576 return `${attr}="${tag[attr]}"`;
4577 }
4578 /**
4579 * @private
4580 * @param {?} tag
4581 * @param {?} elem
4582 * @return {?}
4583 */
4584 _containsAttributes(tag, elem) {
4585 return Object.keys(tag).every((/**
4586 * @param {?} key
4587 * @return {?}
4588 */
4589 (key) => this._dom.getAttribute(elem, key) === tag[key]));
4590 }
4591}
4592Meta.decorators = [
4593 { type: Injectable, args: [{ providedIn: 'root', useFactory: createMeta, deps: [] },] }
4594];
4595/** @nocollapse */
4596Meta.ctorParameters = () => [
4597 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
4598];
4599/** @nocollapse */ Meta.ngInjectableDef = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
4600if (false) {
4601 /**
4602 * @type {?}
4603 * @private
4604 */
4605 Meta.prototype._dom;
4606 /**
4607 * @type {?}
4608 * @private
4609 */
4610 Meta.prototype._doc;
4611}
4612
4613/**
4614 * @fileoverview added by tsickle
4615 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4616 */
4617/**
4618 * Factory to create Title service.
4619 * @return {?}
4620 */
4621function createTitle() {
4622 return new Title(ɵɵinject(DOCUMENT));
4623}
4624/**
4625 * A service that can be used to get and set the title of a current HTML document.
4626 *
4627 * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
4628 * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
4629 * (representing the `<title>` tag). Instead, this service can be used to set and get the current
4630 * title value.
4631 *
4632 * \@publicApi
4633 */
4634class Title {
4635 /**
4636 * @param {?} _doc
4637 */
4638 constructor(_doc) {
4639 this._doc = _doc;
4640 }
4641 /**
4642 * Get the title of the current HTML document.
4643 * @return {?}
4644 */
4645 getTitle() { return getDOM().getTitle(this._doc); }
4646 /**
4647 * Set the title of the current HTML document.
4648 * @param {?} newTitle
4649 * @return {?}
4650 */
4651 setTitle(newTitle) { getDOM().setTitle(this._doc, newTitle); }
4652}
4653Title.decorators = [
4654 { type: Injectable, args: [{ providedIn: 'root', useFactory: createTitle, deps: [] },] }
4655];
4656/** @nocollapse */
4657Title.ctorParameters = () => [
4658 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
4659];
4660/** @nocollapse */ Title.ngInjectableDef = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
4661if (false) {
4662 /**
4663 * @type {?}
4664 * @private
4665 */
4666 Title.prototype._doc;
4667}
4668
4669/**
4670 * @fileoverview added by tsickle
4671 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4672 */
4673/**
4674 * @license
4675 * Copyright Google Inc. All Rights Reserved.
4676 *
4677 * Use of this source code is governed by an MIT-style license that can be
4678 * found in the LICENSE file at https://angular.io/license
4679 */
4680/** @type {?} */
4681const win = typeof window !== 'undefined' && window || (/** @type {?} */ ({}));
4682
4683/**
4684 * @fileoverview added by tsickle
4685 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4686 */
4687class ChangeDetectionPerfRecord {
4688 /**
4689 * @param {?} msPerTick
4690 * @param {?} numTicks
4691 */
4692 constructor(msPerTick, numTicks) {
4693 this.msPerTick = msPerTick;
4694 this.numTicks = numTicks;
4695 }
4696}
4697if (false) {
4698 /** @type {?} */
4699 ChangeDetectionPerfRecord.prototype.msPerTick;
4700 /** @type {?} */
4701 ChangeDetectionPerfRecord.prototype.numTicks;
4702}
4703/**
4704 * Entry point for all Angular profiling-related debug tools. This object
4705 * corresponds to the `ng.profiler` in the dev console.
4706 */
4707class AngularProfiler {
4708 /**
4709 * @param {?} ref
4710 */
4711 constructor(ref) { this.appRef = ref.injector.get(ApplicationRef); }
4712 // tslint:disable:no-console
4713 /**
4714 * Exercises change detection in a loop and then prints the average amount of
4715 * time in milliseconds how long a single round of change detection takes for
4716 * the current state of the UI. It runs a minimum of 5 rounds for a minimum
4717 * of 500 milliseconds.
4718 *
4719 * Optionally, a user may pass a `config` parameter containing a map of
4720 * options. Supported options are:
4721 *
4722 * `record` (boolean) - causes the profiler to record a CPU profile while
4723 * it exercises the change detector. Example:
4724 *
4725 * ```
4726 * ng.profiler.timeChangeDetection({record: true})
4727 * ```
4728 * @param {?} config
4729 * @return {?}
4730 */
4731 timeChangeDetection(config) {
4732 /** @type {?} */
4733 const record = config && config['record'];
4734 /** @type {?} */
4735 const profileName = 'Change Detection';
4736 // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
4737 /** @type {?} */
4738 const isProfilerAvailable = win.console.profile != null;
4739 if (record && isProfilerAvailable) {
4740 win.console.profile(profileName);
4741 }
4742 /** @type {?} */
4743 const start = getDOM().performanceNow();
4744 /** @type {?} */
4745 let numTicks = 0;
4746 while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
4747 this.appRef.tick();
4748 numTicks++;
4749 }
4750 /** @type {?} */
4751 const end = getDOM().performanceNow();
4752 if (record && isProfilerAvailable) {
4753 win.console.profileEnd(profileName);
4754 }
4755 /** @type {?} */
4756 const msPerTick = (end - start) / numTicks;
4757 win.console.log(`ran ${numTicks} change detection cycles`);
4758 win.console.log(`${msPerTick.toFixed(2)} ms per check`);
4759 return new ChangeDetectionPerfRecord(msPerTick, numTicks);
4760 }
4761}
4762if (false) {
4763 /** @type {?} */
4764 AngularProfiler.prototype.appRef;
4765}
4766
4767/**
4768 * @fileoverview added by tsickle
4769 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4770 */
4771/** @type {?} */
4772const PROFILER_GLOBAL_NAME = 'profiler';
4773/**
4774 * Enabled Angular debug tools that are accessible via your browser's
4775 * developer console.
4776 *
4777 * Usage:
4778 *
4779 * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
4780 * 1. Type `ng.` (usually the console will show auto-complete suggestion)
4781 * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
4782 * then hit Enter.
4783 *
4784 * \@publicApi
4785 * @template T
4786 * @param {?} ref
4787 * @return {?}
4788 */
4789function enableDebugTools(ref) {
4790 exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
4791 return ref;
4792}
4793/**
4794 * Disables Angular tools.
4795 *
4796 * \@publicApi
4797 * @return {?}
4798 */
4799function disableDebugTools() {
4800 exportNgVar(PROFILER_GLOBAL_NAME, null);
4801}
4802
4803/**
4804 * @fileoverview added by tsickle
4805 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4806 */
4807/**
4808 * @param {?} text
4809 * @return {?}
4810 */
4811function escapeHtml(text) {
4812 /** @type {?} */
4813 const escapedText = {
4814 '&': '&a;',
4815 '"': '&q;',
4816 '\'': '&s;',
4817 '<': '&l;',
4818 '>': '&g;',
4819 };
4820 return text.replace(/[&"'<>]/g, (/**
4821 * @param {?} s
4822 * @return {?}
4823 */
4824 s => escapedText[s]));
4825}
4826/**
4827 * @param {?} text
4828 * @return {?}
4829 */
4830function unescapeHtml(text) {
4831 /** @type {?} */
4832 const unescapedText = {
4833 '&a;': '&',
4834 '&q;': '"',
4835 '&s;': '\'',
4836 '&l;': '<',
4837 '&g;': '>',
4838 };
4839 return text.replace(/&[^;]+;/g, (/**
4840 * @param {?} s
4841 * @return {?}
4842 */
4843 s => unescapedText[s]));
4844}
4845/**
4846 * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
4847 *
4848 * Example:
4849 *
4850 * ```
4851 * const COUNTER_KEY = makeStateKey<number>('counter');
4852 * let value = 10;
4853 *
4854 * transferState.set(COUNTER_KEY, value);
4855 * ```
4856 *
4857 * \@publicApi
4858 * @template T
4859 * @param {?} key
4860 * @return {?}
4861 */
4862function makeStateKey(key) {
4863 return (/** @type {?} */ (key));
4864}
4865/**
4866 * A key value store that is transferred from the application on the server side to the application
4867 * on the client side.
4868 *
4869 * `TransferState` will be available as an injectable token. To use it import
4870 * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
4871 *
4872 * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
4873 * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
4874 * non-lossy manner.
4875 *
4876 * \@publicApi
4877 */
4878class TransferState {
4879 constructor() {
4880 this.store = {};
4881 this.onSerializeCallbacks = {};
4882 }
4883 /**
4884 * \@internal
4885 * @param {?} initState
4886 * @return {?}
4887 */
4888 static init(initState) {
4889 /** @type {?} */
4890 const transferState = new TransferState();
4891 transferState.store = initState;
4892 return transferState;
4893 }
4894 /**
4895 * Get the value corresponding to a key. Return `defaultValue` if key is not found.
4896 * @template T
4897 * @param {?} key
4898 * @param {?} defaultValue
4899 * @return {?}
4900 */
4901 get(key, defaultValue) {
4902 return this.store[key] !== undefined ? (/** @type {?} */ (this.store[key])) : defaultValue;
4903 }
4904 /**
4905 * Set the value corresponding to a key.
4906 * @template T
4907 * @param {?} key
4908 * @param {?} value
4909 * @return {?}
4910 */
4911 set(key, value) { this.store[key] = value; }
4912 /**
4913 * Remove a key from the store.
4914 * @template T
4915 * @param {?} key
4916 * @return {?}
4917 */
4918 remove(key) { delete this.store[key]; }
4919 /**
4920 * Test whether a key exists in the store.
4921 * @template T
4922 * @param {?} key
4923 * @return {?}
4924 */
4925 hasKey(key) { return this.store.hasOwnProperty(key); }
4926 /**
4927 * Register a callback to provide the value for a key when `toJson` is called.
4928 * @template T
4929 * @param {?} key
4930 * @param {?} callback
4931 * @return {?}
4932 */
4933 onSerialize(key, callback) {
4934 this.onSerializeCallbacks[key] = callback;
4935 }
4936 /**
4937 * Serialize the current state of the store to JSON.
4938 * @return {?}
4939 */
4940 toJson() {
4941 // Call the onSerialize callbacks and put those values into the store.
4942 for (const key in this.onSerializeCallbacks) {
4943 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
4944 try {
4945 this.store[key] = this.onSerializeCallbacks[key]();
4946 }
4947 catch (e) {
4948 console.warn('Exception in onSerialize callback: ', e);
4949 }
4950 }
4951 }
4952 return JSON.stringify(this.store);
4953 }
4954}
4955TransferState.decorators = [
4956 { type: Injectable }
4957];
4958if (false) {
4959 /**
4960 * @type {?}
4961 * @private
4962 */
4963 TransferState.prototype.store;
4964 /**
4965 * @type {?}
4966 * @private
4967 */
4968 TransferState.prototype.onSerializeCallbacks;
4969}
4970/**
4971 * @param {?} doc
4972 * @param {?} appId
4973 * @return {?}
4974 */
4975function initTransferState(doc, appId) {
4976 // Locate the script tag with the JSON data transferred from the server.
4977 // The id of the script tag is set to the Angular appId + 'state'.
4978 /** @type {?} */
4979 const script = doc.getElementById(appId + '-state');
4980 /** @type {?} */
4981 let initialState = {};
4982 if (script && script.textContent) {
4983 try {
4984 initialState = JSON.parse(unescapeHtml(script.textContent));
4985 }
4986 catch (e) {
4987 console.warn('Exception while restoring TransferState for app ' + appId, e);
4988 }
4989 }
4990 return TransferState.init(initialState);
4991}
4992/**
4993 * NgModule to install on the client side while using the `TransferState` to transfer state from
4994 * server to client.
4995 *
4996 * \@publicApi
4997 */
4998class BrowserTransferStateModule {
4999}
5000BrowserTransferStateModule.decorators = [
5001 { type: NgModule, args: [{
5002 providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
5003 },] }
5004];
5005
5006/**
5007 * @fileoverview added by tsickle
5008 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5009 */
5010/**
5011 * Predicates for use with {\@link DebugElement}'s query functions.
5012 *
5013 * \@publicApi
5014 */
5015class By {
5016 /**
5017 * Match all nodes.
5018 *
5019 * \@usageNotes
5020 * ### Example
5021 *
5022 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
5023 * @return {?}
5024 */
5025 static all() { return (/**
5026 * @return {?}
5027 */
5028 () => true); }
5029 /**
5030 * Match elements by the given CSS selector.
5031 *
5032 * \@usageNotes
5033 * ### Example
5034 *
5035 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
5036 * @param {?} selector
5037 * @return {?}
5038 */
5039 static css(selector) {
5040 return (/**
5041 * @param {?} debugElement
5042 * @return {?}
5043 */
5044 (debugElement) => {
5045 return debugElement.nativeElement != null ?
5046 getDOM().elementMatches(debugElement.nativeElement, selector) :
5047 false;
5048 });
5049 }
5050 /**
5051 * Match nodes that have the given directive present.
5052 *
5053 * \@usageNotes
5054 * ### Example
5055 *
5056 * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
5057 * @param {?} type
5058 * @return {?}
5059 */
5060 static directive(type) {
5061 return (/**
5062 * @param {?} debugNode
5063 * @return {?}
5064 */
5065 (debugNode) => (/** @type {?} */ (debugNode.providerTokens)).indexOf(type) !== -1);
5066 }
5067}
5068
5069/**
5070 * @fileoverview added by tsickle
5071 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5072 */
5073
5074/**
5075 * @fileoverview added by tsickle
5076 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5077 */
5078/**
5079 * \@publicApi
5080 * @type {?}
5081 */
5082const VERSION = new Version('8.2.14');
5083
5084/**
5085 * @fileoverview added by tsickle
5086 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5087 */
5088
5089/**
5090 * @fileoverview added by tsickle
5091 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5092 */
5093
5094/**
5095 * @fileoverview added by tsickle
5096 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5097 */
5098
5099/**
5100 * Generated bundle index. Do not edit.
5101 */
5102
5103export { BROWSER_MODULE_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_c, _document as ɵangular_packages_platform_browser_platform_browser_b, errorHandler as ɵangular_packages_platform_browser_platform_browser_a, GenericBrowserDomAdapter as ɵangular_packages_platform_browser_platform_browser_l, createMeta as ɵangular_packages_platform_browser_platform_browser_d, SERVER_TRANSITION_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_i, appInitializerFactory as ɵangular_packages_platform_browser_platform_browser_h, createTitle as ɵangular_packages_platform_browser_platform_browser_e, initTransferState as ɵangular_packages_platform_browser_platform_browser_f, ELEMENT_PROBE_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_k, _createNgProbe as ɵangular_packages_platform_browser_platform_browser_j, EventManagerPlugin as ɵangular_packages_platform_browser_platform_browser_g, BrowserModule, platformBrowser, Meta, Title, disableDebugTools, enableDebugTools, BrowserTransferStateModule, TransferState, makeStateKey, By, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HAMMER_LOADER, HammerGestureConfig, DomSanitizer, VERSION, ELEMENT_PROBE_PROVIDERS__POST_R3__ as ɵELEMENT_PROBE_PROVIDERS__POST_R3__, BROWSER_SANITIZATION_PROVIDERS as ɵBROWSER_SANITIZATION_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, initDomAdapter as ɵinitDomAdapter, BrowserDomAdapter as ɵBrowserDomAdapter, BrowserPlatformLocation as ɵBrowserPlatformLocation, TRANSITION_ID as ɵTRANSITION_ID, BrowserGetTestability as ɵBrowserGetTestability, escapeHtml as ɵescapeHtml, ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS, DomAdapter as ɵDomAdapter, getDOM as ɵgetDOM, setRootDomAdapter as ɵsetRootDomAdapter, DomRendererFactory2 as ɵDomRendererFactory2, NAMESPACE_URIS as ɵNAMESPACE_URIS, flattenStyles as ɵflattenStyles, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute, DomEventsPlugin as ɵDomEventsPlugin, HammerGesturesPlugin as ɵHammerGesturesPlugin, KeyEventsPlugin as ɵKeyEventsPlugin, DomSharedStylesHost as ɵDomSharedStylesHost, SharedStylesHost as ɵSharedStylesHost, DomSanitizerImpl as ɵDomSanitizerImpl };
5104//# sourceMappingURL=platform-browser.js.map