UNPKG

106 kBJavaScriptView Raw
1/**
2 * @license Angular v8.2.12
3 * (c) 2010-2019 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { __extends, __spread, __decorate, __param, __metadata, __assign } from 'tslib';
8import { ɵparseCookieValue, DOCUMENT, PlatformLocation, isPlatformServer, ɵPLATFORM_BROWSER_ID, CommonModule } from '@angular/common';
9import { ɵ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';
10
11/**
12 * @license
13 * Copyright Google Inc. All Rights Reserved.
14 *
15 * Use of this source code is governed by an MIT-style license that can be
16 * found in the LICENSE file at https://angular.io/license
17 */
18var _DOM = null;
19function getDOM() {
20 return _DOM;
21}
22function setDOM(adapter) {
23 _DOM = adapter;
24}
25function setRootDomAdapter(adapter) {
26 if (!_DOM) {
27 _DOM = adapter;
28 }
29}
30/* tslint:disable:requireParameterType */
31/**
32 * Provides DOM operations in an environment-agnostic way.
33 *
34 * @security Tread carefully! Interacting with the DOM directly is dangerous and
35 * can introduce XSS risks.
36 */
37var DomAdapter = /** @class */ (function () {
38 function DomAdapter() {
39 this.resourceLoaderType = null;
40 }
41 Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
42 /**
43 * Maps attribute names to their corresponding property names for cases
44 * where attribute name doesn't match property name.
45 */
46 get: function () { return this._attrToPropMap; },
47 set: function (value) { this._attrToPropMap = value; },
48 enumerable: true,
49 configurable: true
50 });
51 return DomAdapter;
52}());
53
54/**
55 * @license
56 * Copyright Google Inc. All Rights Reserved.
57 *
58 * Use of this source code is governed by an MIT-style license that can be
59 * found in the LICENSE file at https://angular.io/license
60 */
61/**
62 * Provides DOM operations in any browser environment.
63 *
64 * @security Tread carefully! Interacting with the DOM directly is dangerous and
65 * can introduce XSS risks.
66 */
67var GenericBrowserDomAdapter = /** @class */ (function (_super) {
68 __extends(GenericBrowserDomAdapter, _super);
69 function GenericBrowserDomAdapter() {
70 var _this = _super.call(this) || this;
71 _this._animationPrefix = null;
72 _this._transitionEnd = null;
73 try {
74 var element_1 = _this.createElement('div', document);
75 if (_this.getStyle(element_1, 'animationName') != null) {
76 _this._animationPrefix = '';
77 }
78 else {
79 var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
80 for (var i = 0; i < domPrefixes.length; i++) {
81 if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
82 _this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
83 break;
84 }
85 }
86 }
87 var transEndEventNames_1 = {
88 WebkitTransition: 'webkitTransitionEnd',
89 MozTransition: 'transitionend',
90 OTransition: 'oTransitionEnd otransitionend',
91 transition: 'transitionend'
92 };
93 Object.keys(transEndEventNames_1).forEach(function (key) {
94 if (_this.getStyle(element_1, key) != null) {
95 _this._transitionEnd = transEndEventNames_1[key];
96 }
97 });
98 }
99 catch (_a) {
100 _this._animationPrefix = null;
101 _this._transitionEnd = null;
102 }
103 return _this;
104 }
105 GenericBrowserDomAdapter.prototype.getDistributedNodes = function (el) { return el.getDistributedNodes(); };
106 GenericBrowserDomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) {
107 el.href = href == null ? baseUrl : baseUrl + '/../' + href;
108 };
109 GenericBrowserDomAdapter.prototype.supportsDOMEvents = function () { return true; };
110 GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = function () {
111 return typeof document.body.createShadowRoot === 'function';
112 };
113 GenericBrowserDomAdapter.prototype.getAnimationPrefix = function () { return this._animationPrefix ? this._animationPrefix : ''; };
114 GenericBrowserDomAdapter.prototype.getTransitionEnd = function () { return this._transitionEnd ? this._transitionEnd : ''; };
115 GenericBrowserDomAdapter.prototype.supportsAnimation = function () {
116 return this._animationPrefix != null && this._transitionEnd != null;
117 };
118 return GenericBrowserDomAdapter;
119}(DomAdapter));
120
121/**
122 * @license
123 * Copyright Google Inc. All Rights Reserved.
124 *
125 * Use of this source code is governed by an MIT-style license that can be
126 * found in the LICENSE file at https://angular.io/license
127 */
128var _attrToPropMap = {
129 'class': 'className',
130 'innerHtml': 'innerHTML',
131 'readonly': 'readOnly',
132 'tabindex': 'tabIndex',
133};
134var DOM_KEY_LOCATION_NUMPAD = 3;
135// Map to convert some key or keyIdentifier values to what will be returned by getEventKey
136var _keyMap = {
137 // The following values are here for cross-browser compatibility and to match the W3C standard
138 // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
139 '\b': 'Backspace',
140 '\t': 'Tab',
141 '\x7F': 'Delete',
142 '\x1B': 'Escape',
143 'Del': 'Delete',
144 'Esc': 'Escape',
145 'Left': 'ArrowLeft',
146 'Right': 'ArrowRight',
147 'Up': 'ArrowUp',
148 'Down': 'ArrowDown',
149 'Menu': 'ContextMenu',
150 'Scroll': 'ScrollLock',
151 'Win': 'OS'
152};
153// There is a bug in Chrome for numeric keypad keys:
154// https://code.google.com/p/chromium/issues/detail?id=155654
155// 1, 2, 3 ... are reported as A, B, C ...
156var _chromeNumKeyPadMap = {
157 'A': '1',
158 'B': '2',
159 'C': '3',
160 'D': '4',
161 'E': '5',
162 'F': '6',
163 'G': '7',
164 'H': '8',
165 'I': '9',
166 'J': '*',
167 'K': '+',
168 'M': '-',
169 'N': '.',
170 'O': '/',
171 '\x60': '0',
172 '\x90': 'NumLock'
173};
174var ɵ0 = function () {
175 if (ɵglobal['Node']) {
176 return ɵglobal['Node'].prototype.contains || function (node) {
177 return !!(this.compareDocumentPosition(node) & 16);
178 };
179 }
180 return undefined;
181};
182var nodeContains = (ɵ0)();
183/**
184 * A `DomAdapter` powered by full browser DOM APIs.
185 *
186 * @security Tread carefully! Interacting with the DOM directly is dangerous and
187 * can introduce XSS risks.
188 */
189/* tslint:disable:requireParameterType no-console */
190var BrowserDomAdapter = /** @class */ (function (_super) {
191 __extends(BrowserDomAdapter, _super);
192 function BrowserDomAdapter() {
193 return _super !== null && _super.apply(this, arguments) || this;
194 }
195 BrowserDomAdapter.prototype.parse = function (templateHtml) { throw new Error('parse not implemented'); };
196 BrowserDomAdapter.makeCurrent = function () { setRootDomAdapter(new BrowserDomAdapter()); };
197 BrowserDomAdapter.prototype.hasProperty = function (element, name) { return name in element; };
198 BrowserDomAdapter.prototype.setProperty = function (el, name, value) { el[name] = value; };
199 BrowserDomAdapter.prototype.getProperty = function (el, name) { return el[name]; };
200 BrowserDomAdapter.prototype.invoke = function (el, methodName, args) {
201 var _a;
202 (_a = el)[methodName].apply(_a, __spread(args));
203 };
204 // TODO(tbosch): move this into a separate environment class once we have it
205 BrowserDomAdapter.prototype.logError = function (error) {
206 if (window.console) {
207 if (console.error) {
208 console.error(error);
209 }
210 else {
211 console.log(error);
212 }
213 }
214 };
215 BrowserDomAdapter.prototype.log = function (error) {
216 if (window.console) {
217 window.console.log && window.console.log(error);
218 }
219 };
220 BrowserDomAdapter.prototype.logGroup = function (error) {
221 if (window.console) {
222 window.console.group && window.console.group(error);
223 }
224 };
225 BrowserDomAdapter.prototype.logGroupEnd = function () {
226 if (window.console) {
227 window.console.groupEnd && window.console.groupEnd();
228 }
229 };
230 Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
231 get: function () { return _attrToPropMap; },
232 enumerable: true,
233 configurable: true
234 });
235 BrowserDomAdapter.prototype.contains = function (nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); };
236 BrowserDomAdapter.prototype.querySelector = function (el, selector) { return el.querySelector(selector); };
237 BrowserDomAdapter.prototype.querySelectorAll = function (el, selector) { return el.querySelectorAll(selector); };
238 BrowserDomAdapter.prototype.on = function (el, evt, listener) { el.addEventListener(evt, listener, false); };
239 BrowserDomAdapter.prototype.onAndCancel = function (el, evt, listener) {
240 el.addEventListener(evt, listener, false);
241 // Needed to follow Dart's subscription semantic, until fix of
242 // https://code.google.com/p/dart/issues/detail?id=17406
243 return function () { el.removeEventListener(evt, listener, false); };
244 };
245 BrowserDomAdapter.prototype.dispatchEvent = function (el, evt) { el.dispatchEvent(evt); };
246 BrowserDomAdapter.prototype.createMouseEvent = function (eventType) {
247 var evt = this.getDefaultDocument().createEvent('MouseEvent');
248 evt.initEvent(eventType, true, true);
249 return evt;
250 };
251 BrowserDomAdapter.prototype.createEvent = function (eventType) {
252 var evt = this.getDefaultDocument().createEvent('Event');
253 evt.initEvent(eventType, true, true);
254 return evt;
255 };
256 BrowserDomAdapter.prototype.preventDefault = function (evt) {
257 evt.preventDefault();
258 evt.returnValue = false;
259 };
260 BrowserDomAdapter.prototype.isPrevented = function (evt) {
261 return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
262 };
263 BrowserDomAdapter.prototype.getInnerHTML = function (el) { return el.innerHTML; };
264 BrowserDomAdapter.prototype.getTemplateContent = function (el) {
265 return 'content' in el && this.isTemplateElement(el) ? el.content : null;
266 };
267 BrowserDomAdapter.prototype.getOuterHTML = function (el) { return el.outerHTML; };
268 BrowserDomAdapter.prototype.nodeName = function (node) { return node.nodeName; };
269 BrowserDomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; };
270 BrowserDomAdapter.prototype.type = function (node) { return node.type; };
271 BrowserDomAdapter.prototype.content = function (node) {
272 if (this.hasProperty(node, 'content')) {
273 return node.content;
274 }
275 else {
276 return node;
277 }
278 };
279 BrowserDomAdapter.prototype.firstChild = function (el) { return el.firstChild; };
280 BrowserDomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; };
281 BrowserDomAdapter.prototype.parentElement = function (el) { return el.parentNode; };
282 BrowserDomAdapter.prototype.childNodes = function (el) { return el.childNodes; };
283 BrowserDomAdapter.prototype.childNodesAsList = function (el) {
284 var childNodes = el.childNodes;
285 var res = new Array(childNodes.length);
286 for (var i = 0; i < childNodes.length; i++) {
287 res[i] = childNodes[i];
288 }
289 return res;
290 };
291 BrowserDomAdapter.prototype.clearNodes = function (el) {
292 while (el.firstChild) {
293 el.removeChild(el.firstChild);
294 }
295 };
296 BrowserDomAdapter.prototype.appendChild = function (el, node) { el.appendChild(node); };
297 BrowserDomAdapter.prototype.removeChild = function (el, node) { el.removeChild(node); };
298 BrowserDomAdapter.prototype.replaceChild = function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
299 BrowserDomAdapter.prototype.remove = function (node) {
300 if (node.parentNode) {
301 node.parentNode.removeChild(node);
302 }
303 return node;
304 };
305 BrowserDomAdapter.prototype.insertBefore = function (parent, ref, node) { parent.insertBefore(node, ref); };
306 BrowserDomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) {
307 nodes.forEach(function (n) { return parent.insertBefore(n, ref); });
308 };
309 BrowserDomAdapter.prototype.insertAfter = function (parent, ref, node) { parent.insertBefore(node, ref.nextSibling); };
310 BrowserDomAdapter.prototype.setInnerHTML = function (el, value) { el.innerHTML = value; };
311 BrowserDomAdapter.prototype.getText = function (el) { return el.textContent; };
312 BrowserDomAdapter.prototype.setText = function (el, value) { el.textContent = value; };
313 BrowserDomAdapter.prototype.getValue = function (el) { return el.value; };
314 BrowserDomAdapter.prototype.setValue = function (el, value) { el.value = value; };
315 BrowserDomAdapter.prototype.getChecked = function (el) { return el.checked; };
316 BrowserDomAdapter.prototype.setChecked = function (el, value) { el.checked = value; };
317 BrowserDomAdapter.prototype.createComment = function (text) { return this.getDefaultDocument().createComment(text); };
318 BrowserDomAdapter.prototype.createTemplate = function (html) {
319 var t = this.getDefaultDocument().createElement('template');
320 t.innerHTML = html;
321 return t;
322 };
323 BrowserDomAdapter.prototype.createElement = function (tagName, doc) {
324 doc = doc || this.getDefaultDocument();
325 return doc.createElement(tagName);
326 };
327 BrowserDomAdapter.prototype.createElementNS = function (ns, tagName, doc) {
328 doc = doc || this.getDefaultDocument();
329 return doc.createElementNS(ns, tagName);
330 };
331 BrowserDomAdapter.prototype.createTextNode = function (text, doc) {
332 doc = doc || this.getDefaultDocument();
333 return doc.createTextNode(text);
334 };
335 BrowserDomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) {
336 doc = doc || this.getDefaultDocument();
337 var el = doc.createElement('SCRIPT');
338 el.setAttribute(attrName, attrValue);
339 return el;
340 };
341 BrowserDomAdapter.prototype.createStyleElement = function (css, doc) {
342 doc = doc || this.getDefaultDocument();
343 var style = doc.createElement('style');
344 this.appendChild(style, this.createTextNode(css, doc));
345 return style;
346 };
347 BrowserDomAdapter.prototype.createShadowRoot = function (el) { return el.createShadowRoot(); };
348 BrowserDomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; };
349 BrowserDomAdapter.prototype.getHost = function (el) { return el.host; };
350 BrowserDomAdapter.prototype.clone = function (node) { return node.cloneNode(true); };
351 BrowserDomAdapter.prototype.getElementsByClassName = function (element, name) {
352 return element.getElementsByClassName(name);
353 };
354 BrowserDomAdapter.prototype.getElementsByTagName = function (element, name) {
355 return element.getElementsByTagName(name);
356 };
357 BrowserDomAdapter.prototype.classList = function (element) { return Array.prototype.slice.call(element.classList, 0); };
358 BrowserDomAdapter.prototype.addClass = function (element, className) { element.classList.add(className); };
359 BrowserDomAdapter.prototype.removeClass = function (element, className) { element.classList.remove(className); };
360 BrowserDomAdapter.prototype.hasClass = function (element, className) {
361 return element.classList.contains(className);
362 };
363 BrowserDomAdapter.prototype.setStyle = function (element, styleName, styleValue) {
364 element.style[styleName] = styleValue;
365 };
366 BrowserDomAdapter.prototype.removeStyle = function (element, stylename) {
367 // IE requires '' instead of null
368 // see https://github.com/angular/angular/issues/7916
369 element.style[stylename] = '';
370 };
371 BrowserDomAdapter.prototype.getStyle = function (element, stylename) { return element.style[stylename]; };
372 BrowserDomAdapter.prototype.hasStyle = function (element, styleName, styleValue) {
373 var value = this.getStyle(element, styleName) || '';
374 return styleValue ? value == styleValue : value.length > 0;
375 };
376 BrowserDomAdapter.prototype.tagName = function (element) { return element.tagName; };
377 BrowserDomAdapter.prototype.attributeMap = function (element) {
378 var res = new Map();
379 var elAttrs = element.attributes;
380 for (var i = 0; i < elAttrs.length; i++) {
381 var attrib = elAttrs.item(i);
382 res.set(attrib.name, attrib.value);
383 }
384 return res;
385 };
386 BrowserDomAdapter.prototype.hasAttribute = function (element, attribute) {
387 return element.hasAttribute(attribute);
388 };
389 BrowserDomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) {
390 return element.hasAttributeNS(ns, attribute);
391 };
392 BrowserDomAdapter.prototype.getAttribute = function (element, attribute) {
393 return element.getAttribute(attribute);
394 };
395 BrowserDomAdapter.prototype.getAttributeNS = function (element, ns, name) {
396 return element.getAttributeNS(ns, name);
397 };
398 BrowserDomAdapter.prototype.setAttribute = function (element, name, value) { element.setAttribute(name, value); };
399 BrowserDomAdapter.prototype.setAttributeNS = function (element, ns, name, value) {
400 element.setAttributeNS(ns, name, value);
401 };
402 BrowserDomAdapter.prototype.removeAttribute = function (element, attribute) { element.removeAttribute(attribute); };
403 BrowserDomAdapter.prototype.removeAttributeNS = function (element, ns, name) {
404 element.removeAttributeNS(ns, name);
405 };
406 BrowserDomAdapter.prototype.templateAwareRoot = function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
407 BrowserDomAdapter.prototype.createHtmlDocument = function () {
408 return document.implementation.createHTMLDocument('fakeTitle');
409 };
410 BrowserDomAdapter.prototype.getDefaultDocument = function () { return document; };
411 BrowserDomAdapter.prototype.getBoundingClientRect = function (el) {
412 try {
413 return el.getBoundingClientRect();
414 }
415 catch (_a) {
416 return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
417 }
418 };
419 BrowserDomAdapter.prototype.getTitle = function (doc) { return doc.title; };
420 BrowserDomAdapter.prototype.setTitle = function (doc, newTitle) { doc.title = newTitle || ''; };
421 BrowserDomAdapter.prototype.elementMatches = function (n, selector) {
422 if (this.isElementNode(n)) {
423 return n.matches && n.matches(selector) ||
424 n.msMatchesSelector && n.msMatchesSelector(selector) ||
425 n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
426 }
427 return false;
428 };
429 BrowserDomAdapter.prototype.isTemplateElement = function (el) {
430 return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
431 };
432 BrowserDomAdapter.prototype.isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
433 BrowserDomAdapter.prototype.isCommentNode = function (node) { return node.nodeType === Node.COMMENT_NODE; };
434 BrowserDomAdapter.prototype.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
435 BrowserDomAdapter.prototype.hasShadowRoot = function (node) {
436 return node.shadowRoot != null && node instanceof HTMLElement;
437 };
438 BrowserDomAdapter.prototype.isShadowRoot = function (node) { return node instanceof DocumentFragment; };
439 BrowserDomAdapter.prototype.importIntoDoc = function (node) { return document.importNode(this.templateAwareRoot(node), true); };
440 BrowserDomAdapter.prototype.adoptNode = function (node) { return document.adoptNode(node); };
441 BrowserDomAdapter.prototype.getHref = function (el) { return el.getAttribute('href'); };
442 BrowserDomAdapter.prototype.getEventKey = function (event) {
443 var key = event.key;
444 if (key == null) {
445 key = event.keyIdentifier;
446 // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
447 // Safari cf
448 // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
449 if (key == null) {
450 return 'Unidentified';
451 }
452 if (key.startsWith('U+')) {
453 key = String.fromCharCode(parseInt(key.substring(2), 16));
454 if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
455 // There is a bug in Chrome for numeric keypad keys:
456 // https://code.google.com/p/chromium/issues/detail?id=155654
457 // 1, 2, 3 ... are reported as A, B, C ...
458 key = _chromeNumKeyPadMap[key];
459 }
460 }
461 }
462 return _keyMap[key] || key;
463 };
464 BrowserDomAdapter.prototype.getGlobalEventTarget = function (doc, target) {
465 if (target === 'window') {
466 return window;
467 }
468 if (target === 'document') {
469 return doc;
470 }
471 if (target === 'body') {
472 return doc.body;
473 }
474 return null;
475 };
476 BrowserDomAdapter.prototype.getHistory = function () { return window.history; };
477 BrowserDomAdapter.prototype.getLocation = function () { return window.location; };
478 BrowserDomAdapter.prototype.getBaseHref = function (doc) {
479 var href = getBaseElementHref();
480 return href == null ? null : relativePath(href);
481 };
482 BrowserDomAdapter.prototype.resetBaseElement = function () { baseElement = null; };
483 BrowserDomAdapter.prototype.getUserAgent = function () { return window.navigator.userAgent; };
484 BrowserDomAdapter.prototype.setData = function (element, name, value) {
485 this.setAttribute(element, 'data-' + name, value);
486 };
487 BrowserDomAdapter.prototype.getData = function (element, name) {
488 return this.getAttribute(element, 'data-' + name);
489 };
490 BrowserDomAdapter.prototype.getComputedStyle = function (element) { return getComputedStyle(element); };
491 // TODO(tbosch): move this into a separate environment class once we have it
492 BrowserDomAdapter.prototype.supportsWebAnimation = function () {
493 return typeof Element.prototype['animate'] === 'function';
494 };
495 BrowserDomAdapter.prototype.performanceNow = function () {
496 // performance.now() is not available in all browsers, see
497 // http://caniuse.com/#search=performance.now
498 return window.performance && window.performance.now ? window.performance.now() :
499 new Date().getTime();
500 };
501 BrowserDomAdapter.prototype.supportsCookies = function () { return true; };
502 BrowserDomAdapter.prototype.getCookie = function (name) { return ɵparseCookieValue(document.cookie, name); };
503 BrowserDomAdapter.prototype.setCookie = function (name, value) {
504 // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
505 // not clear other cookies.
506 document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
507 };
508 return BrowserDomAdapter;
509}(GenericBrowserDomAdapter));
510var baseElement = null;
511function getBaseElementHref() {
512 if (!baseElement) {
513 baseElement = document.querySelector('base');
514 if (!baseElement) {
515 return null;
516 }
517 }
518 return baseElement.getAttribute('href');
519}
520// based on urlUtils.js in AngularJS 1
521var urlParsingNode;
522function relativePath(url) {
523 if (!urlParsingNode) {
524 urlParsingNode = document.createElement('a');
525 }
526 urlParsingNode.setAttribute('href', url);
527 return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
528 '/' + urlParsingNode.pathname;
529}
530
531/**
532 * @license
533 * Copyright Google Inc. All Rights Reserved.
534 *
535 * Use of this source code is governed by an MIT-style license that can be
536 * found in the LICENSE file at https://angular.io/license
537 */
538function supportsState() {
539 return !!window.history.pushState;
540}
541
542/**
543 * @license
544 * Copyright Google Inc. All Rights Reserved.
545 *
546 * Use of this source code is governed by an MIT-style license that can be
547 * found in the LICENSE file at https://angular.io/license
548 */
549/**
550 * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
551 * This class should not be used directly by an application developer. Instead, use
552 * {@link Location}.
553 */
554var BrowserPlatformLocation = /** @class */ (function (_super) {
555 __extends(BrowserPlatformLocation, _super);
556 function BrowserPlatformLocation(_doc) {
557 var _this = _super.call(this) || this;
558 _this._doc = _doc;
559 _this._init();
560 return _this;
561 }
562 // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
563 /** @internal */
564 BrowserPlatformLocation.prototype._init = function () {
565 this.location = getDOM().getLocation();
566 this._history = getDOM().getHistory();
567 };
568 BrowserPlatformLocation.prototype.getBaseHrefFromDOM = function () { return getDOM().getBaseHref(this._doc); };
569 BrowserPlatformLocation.prototype.onPopState = function (fn) {
570 getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
571 };
572 BrowserPlatformLocation.prototype.onHashChange = function (fn) {
573 getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
574 };
575 Object.defineProperty(BrowserPlatformLocation.prototype, "href", {
576 get: function () { return this.location.href; },
577 enumerable: true,
578 configurable: true
579 });
580 Object.defineProperty(BrowserPlatformLocation.prototype, "protocol", {
581 get: function () { return this.location.protocol; },
582 enumerable: true,
583 configurable: true
584 });
585 Object.defineProperty(BrowserPlatformLocation.prototype, "hostname", {
586 get: function () { return this.location.hostname; },
587 enumerable: true,
588 configurable: true
589 });
590 Object.defineProperty(BrowserPlatformLocation.prototype, "port", {
591 get: function () { return this.location.port; },
592 enumerable: true,
593 configurable: true
594 });
595 Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
596 get: function () { return this.location.pathname; },
597 set: function (newPath) { this.location.pathname = newPath; },
598 enumerable: true,
599 configurable: true
600 });
601 Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
602 get: function () { return this.location.search; },
603 enumerable: true,
604 configurable: true
605 });
606 Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
607 get: function () { return this.location.hash; },
608 enumerable: true,
609 configurable: true
610 });
611 BrowserPlatformLocation.prototype.pushState = function (state, title, url) {
612 if (supportsState()) {
613 this._history.pushState(state, title, url);
614 }
615 else {
616 this.location.hash = url;
617 }
618 };
619 BrowserPlatformLocation.prototype.replaceState = function (state, title, url) {
620 if (supportsState()) {
621 this._history.replaceState(state, title, url);
622 }
623 else {
624 this.location.hash = url;
625 }
626 };
627 BrowserPlatformLocation.prototype.forward = function () { this._history.forward(); };
628 BrowserPlatformLocation.prototype.back = function () { this._history.back(); };
629 BrowserPlatformLocation.prototype.getState = function () { return this._history.state; };
630 BrowserPlatformLocation = __decorate([
631 Injectable(),
632 __param(0, Inject(DOCUMENT)),
633 __metadata("design:paramtypes", [Object])
634 ], BrowserPlatformLocation);
635 return BrowserPlatformLocation;
636}(PlatformLocation));
637
638/**
639 * @license
640 * Copyright Google Inc. All Rights Reserved.
641 *
642 * Use of this source code is governed by an MIT-style license that can be
643 * found in the LICENSE file at https://angular.io/license
644 */
645/**
646 * An id that identifies a particular application being bootstrapped, that should
647 * match across the client/server boundary.
648 */
649var TRANSITION_ID = new InjectionToken('TRANSITION_ID');
650function appInitializerFactory(transitionId, document, injector) {
651 return function () {
652 // Wait for all application initializers to be completed before removing the styles set by
653 // the server.
654 injector.get(ApplicationInitStatus).donePromise.then(function () {
655 var dom = getDOM();
656 var styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
657 styles.filter(function (el) { return dom.getAttribute(el, 'ng-transition') === transitionId; })
658 .forEach(function (el) { return dom.remove(el); });
659 });
660 };
661}
662var SERVER_TRANSITION_PROVIDERS = [
663 {
664 provide: APP_INITIALIZER,
665 useFactory: appInitializerFactory,
666 deps: [TRANSITION_ID, DOCUMENT, Injector],
667 multi: true
668 },
669];
670
671/**
672 * @license
673 * Copyright Google Inc. All Rights Reserved.
674 *
675 * Use of this source code is governed by an MIT-style license that can be
676 * found in the LICENSE file at https://angular.io/license
677 */
678var BrowserGetTestability = /** @class */ (function () {
679 function BrowserGetTestability() {
680 }
681 BrowserGetTestability.init = function () { setTestabilityGetter(new BrowserGetTestability()); };
682 BrowserGetTestability.prototype.addToWindow = function (registry) {
683 ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
684 if (findInAncestors === void 0) { findInAncestors = true; }
685 var testability = registry.findTestabilityInTree(elem, findInAncestors);
686 if (testability == null) {
687 throw new Error('Could not find testability for element.');
688 }
689 return testability;
690 };
691 ɵglobal['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
692 ɵglobal['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
693 var whenAllStable = function (callback /** TODO #9100 */) {
694 var testabilities = ɵglobal['getAllAngularTestabilities']();
695 var count = testabilities.length;
696 var didWork = false;
697 var decrement = function (didWork_ /** TODO #9100 */) {
698 didWork = didWork || didWork_;
699 count--;
700 if (count == 0) {
701 callback(didWork);
702 }
703 };
704 testabilities.forEach(function (testability /** TODO #9100 */) {
705 testability.whenStable(decrement);
706 });
707 };
708 if (!ɵglobal['frameworkStabilizers']) {
709 ɵglobal['frameworkStabilizers'] = [];
710 }
711 ɵglobal['frameworkStabilizers'].push(whenAllStable);
712 };
713 BrowserGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
714 if (elem == null) {
715 return null;
716 }
717 var t = registry.getTestability(elem);
718 if (t != null) {
719 return t;
720 }
721 else if (!findInAncestors) {
722 return null;
723 }
724 if (getDOM().isShadowRoot(elem)) {
725 return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
726 }
727 return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
728 };
729 return BrowserGetTestability;
730}());
731
732/**
733 * @license
734 * Copyright Google Inc. All Rights Reserved.
735 *
736 * Use of this source code is governed by an MIT-style license that can be
737 * found in the LICENSE file at https://angular.io/license
738 */
739var CAMEL_CASE_REGEXP = /([A-Z])/g;
740var DASH_CASE_REGEXP = /-([a-z])/g;
741function camelCaseToDashCase(input) {
742 return input.replace(CAMEL_CASE_REGEXP, function () {
743 var m = [];
744 for (var _i = 0; _i < arguments.length; _i++) {
745 m[_i] = arguments[_i];
746 }
747 return '-' + m[1].toLowerCase();
748 });
749}
750function dashCaseToCamelCase(input) {
751 return input.replace(DASH_CASE_REGEXP, function () {
752 var m = [];
753 for (var _i = 0; _i < arguments.length; _i++) {
754 m[_i] = arguments[_i];
755 }
756 return m[1].toUpperCase();
757 });
758}
759/**
760 * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
761 * `name` is `'probe'`.
762 * @param name Name under which it will be exported. Keep in mind this will be a property of the
763 * global `ng` object.
764 * @param value The value to export.
765 */
766function exportNgVar(name, value) {
767 if (typeof COMPILED === 'undefined' || !COMPILED) {
768 // Note: we can't export `ng` when using closure enhanced optimization as:
769 // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
770 // - we can't declare a closure extern as the namespace `ng` is already used within Google
771 // for typings for angularJS (via `goog.provide('ng....')`).
772 var ng = ɵglobal['ng'] = ɵglobal['ng'] || {};
773 ng[name] = value;
774 }
775}
776
777/**
778 * @license
779 * Copyright Google Inc. All Rights Reserved.
780 *
781 * Use of this source code is governed by an MIT-style license that can be
782 * found in the LICENSE file at https://angular.io/license
783 */
784var ɵ0$1 = function () { return ({
785 'ApplicationRef': ApplicationRef,
786 'NgZone': NgZone,
787}); };
788var CORE_TOKENS = (ɵ0$1)();
789var INSPECT_GLOBAL_NAME = 'probe';
790var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
791/**
792 * Returns a {@link DebugElement} for the given native DOM element, or
793 * null if the given native element does not have an Angular view associated
794 * with it.
795 */
796function inspectNativeElement(element) {
797 return getDebugNode(element);
798}
799function _createNgProbe(coreTokens) {
800 exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
801 exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
802 return function () { return inspectNativeElement; };
803}
804function _ngProbeTokensToMap(tokens) {
805 return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
806}
807/**
808 * In Ivy, we don't support NgProbe because we have our own set of testing utilities
809 * with more robust functionality.
810 *
811 * We shouldn't bring in NgProbe because it prevents DebugNode and friends from
812 * tree-shaking properly.
813 */
814var ELEMENT_PROBE_PROVIDERS__POST_R3__ = [];
815/**
816 * Providers which support debugging Angular applications (e.g. via `ng.probe`).
817 */
818var ELEMENT_PROBE_PROVIDERS__PRE_R3__ = [
819 {
820 provide: APP_INITIALIZER,
821 useFactory: _createNgProbe,
822 deps: [
823 [NgProbeToken, new Optional()],
824 ],
825 multi: true,
826 },
827];
828var ELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS__PRE_R3__;
829
830/**
831 * @license
832 * Copyright Google Inc. All Rights Reserved.
833 *
834 * Use of this source code is governed by an MIT-style license that can be
835 * found in the LICENSE file at https://angular.io/license
836 */
837/**
838 * The injection token for the event-manager plug-in service.
839 *
840 * @publicApi
841 */
842var EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
843/**
844 * An injectable service that provides event management for Angular
845 * through a browser plug-in.
846 *
847 * @publicApi
848 */
849var EventManager = /** @class */ (function () {
850 /**
851 * Initializes an instance of the event-manager service.
852 */
853 function EventManager(plugins, _zone) {
854 var _this = this;
855 this._zone = _zone;
856 this._eventNameToPlugin = new Map();
857 plugins.forEach(function (p) { return p.manager = _this; });
858 this._plugins = plugins.slice().reverse();
859 }
860 /**
861 * Registers a handler for a specific element and event.
862 *
863 * @param element The HTML element to receive event notifications.
864 * @param eventName The name of the event to listen for.
865 * @param handler A function to call when the notification occurs. Receives the
866 * event object as an argument.
867 * @returns A callback function that can be used to remove the handler.
868 */
869 EventManager.prototype.addEventListener = function (element, eventName, handler) {
870 var plugin = this._findPluginFor(eventName);
871 return plugin.addEventListener(element, eventName, handler);
872 };
873 /**
874 * Registers a global handler for an event in a target view.
875 *
876 * @param target A target for global event notifications. One of "window", "document", or "body".
877 * @param eventName The name of the event to listen for.
878 * @param handler A function to call when the notification occurs. Receives the
879 * event object as an argument.
880 * @returns A callback function that can be used to remove the handler.
881 */
882 EventManager.prototype.addGlobalEventListener = function (target, eventName, handler) {
883 var plugin = this._findPluginFor(eventName);
884 return plugin.addGlobalEventListener(target, eventName, handler);
885 };
886 /**
887 * Retrieves the compilation zone in which event listeners are registered.
888 */
889 EventManager.prototype.getZone = function () { return this._zone; };
890 /** @internal */
891 EventManager.prototype._findPluginFor = function (eventName) {
892 var plugin = this._eventNameToPlugin.get(eventName);
893 if (plugin) {
894 return plugin;
895 }
896 var plugins = this._plugins;
897 for (var i = 0; i < plugins.length; i++) {
898 var plugin_1 = plugins[i];
899 if (plugin_1.supports(eventName)) {
900 this._eventNameToPlugin.set(eventName, plugin_1);
901 return plugin_1;
902 }
903 }
904 throw new Error("No event manager plugin found for event " + eventName);
905 };
906 EventManager = __decorate([
907 Injectable(),
908 __param(0, Inject(EVENT_MANAGER_PLUGINS)),
909 __metadata("design:paramtypes", [Array, NgZone])
910 ], EventManager);
911 return EventManager;
912}());
913var EventManagerPlugin = /** @class */ (function () {
914 function EventManagerPlugin(_doc) {
915 this._doc = _doc;
916 }
917 EventManagerPlugin.prototype.addGlobalEventListener = function (element, eventName, handler) {
918 var target = getDOM().getGlobalEventTarget(this._doc, element);
919 if (!target) {
920 throw new Error("Unsupported event target " + target + " for event " + eventName);
921 }
922 return this.addEventListener(target, eventName, handler);
923 };
924 return EventManagerPlugin;
925}());
926
927/**
928 * @license
929 * Copyright Google Inc. All Rights Reserved.
930 *
931 * Use of this source code is governed by an MIT-style license that can be
932 * found in the LICENSE file at https://angular.io/license
933 */
934var SharedStylesHost = /** @class */ (function () {
935 function SharedStylesHost() {
936 /** @internal */
937 this._stylesSet = new Set();
938 }
939 SharedStylesHost.prototype.addStyles = function (styles) {
940 var _this = this;
941 var additions = new Set();
942 styles.forEach(function (style) {
943 if (!_this._stylesSet.has(style)) {
944 _this._stylesSet.add(style);
945 additions.add(style);
946 }
947 });
948 this.onStylesAdded(additions);
949 };
950 SharedStylesHost.prototype.onStylesAdded = function (additions) { };
951 SharedStylesHost.prototype.getAllStyles = function () { return Array.from(this._stylesSet); };
952 SharedStylesHost = __decorate([
953 Injectable()
954 ], SharedStylesHost);
955 return SharedStylesHost;
956}());
957var DomSharedStylesHost = /** @class */ (function (_super) {
958 __extends(DomSharedStylesHost, _super);
959 function DomSharedStylesHost(_doc) {
960 var _this = _super.call(this) || this;
961 _this._doc = _doc;
962 _this._hostNodes = new Set();
963 _this._styleNodes = new Set();
964 _this._hostNodes.add(_doc.head);
965 return _this;
966 }
967 DomSharedStylesHost.prototype._addStylesToHost = function (styles, host) {
968 var _this = this;
969 styles.forEach(function (style) {
970 var styleEl = _this._doc.createElement('style');
971 styleEl.textContent = style;
972 _this._styleNodes.add(host.appendChild(styleEl));
973 });
974 };
975 DomSharedStylesHost.prototype.addHost = function (hostNode) {
976 this._addStylesToHost(this._stylesSet, hostNode);
977 this._hostNodes.add(hostNode);
978 };
979 DomSharedStylesHost.prototype.removeHost = function (hostNode) { this._hostNodes.delete(hostNode); };
980 DomSharedStylesHost.prototype.onStylesAdded = function (additions) {
981 var _this = this;
982 this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
983 };
984 DomSharedStylesHost.prototype.ngOnDestroy = function () { this._styleNodes.forEach(function (styleNode) { return getDOM().remove(styleNode); }); };
985 DomSharedStylesHost = __decorate([
986 Injectable(),
987 __param(0, Inject(DOCUMENT)),
988 __metadata("design:paramtypes", [Object])
989 ], DomSharedStylesHost);
990 return DomSharedStylesHost;
991}(SharedStylesHost));
992
993/**
994 * @license
995 * Copyright Google Inc. All Rights Reserved.
996 *
997 * Use of this source code is governed by an MIT-style license that can be
998 * found in the LICENSE file at https://angular.io/license
999 */
1000var NAMESPACE_URIS = {
1001 'svg': 'http://www.w3.org/2000/svg',
1002 'xhtml': 'http://www.w3.org/1999/xhtml',
1003 'xlink': 'http://www.w3.org/1999/xlink',
1004 'xml': 'http://www.w3.org/XML/1998/namespace',
1005 'xmlns': 'http://www.w3.org/2000/xmlns/',
1006};
1007var COMPONENT_REGEX = /%COMP%/g;
1008var COMPONENT_VARIABLE = '%COMP%';
1009var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
1010var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
1011function shimContentAttribute(componentShortId) {
1012 return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
1013}
1014function shimHostAttribute(componentShortId) {
1015 return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
1016}
1017function flattenStyles(compId, styles, target) {
1018 for (var i = 0; i < styles.length; i++) {
1019 var style = styles[i];
1020 if (Array.isArray(style)) {
1021 flattenStyles(compId, style, target);
1022 }
1023 else {
1024 style = style.replace(COMPONENT_REGEX, compId);
1025 target.push(style);
1026 }
1027 }
1028 return target;
1029}
1030function decoratePreventDefault(eventHandler) {
1031 return function (event) {
1032 var allowDefaultBehavior = eventHandler(event);
1033 if (allowDefaultBehavior === false) {
1034 // TODO(tbosch): move preventDefault into event plugins...
1035 event.preventDefault();
1036 event.returnValue = false;
1037 }
1038 };
1039}
1040var DomRendererFactory2 = /** @class */ (function () {
1041 function DomRendererFactory2(eventManager, sharedStylesHost, appId) {
1042 this.eventManager = eventManager;
1043 this.sharedStylesHost = sharedStylesHost;
1044 this.appId = appId;
1045 this.rendererByCompId = new Map();
1046 this.defaultRenderer = new DefaultDomRenderer2(eventManager);
1047 }
1048 DomRendererFactory2.prototype.createRenderer = function (element, type) {
1049 if (!element || !type) {
1050 return this.defaultRenderer;
1051 }
1052 switch (type.encapsulation) {
1053 case ViewEncapsulation.Emulated: {
1054 var renderer = this.rendererByCompId.get(type.id);
1055 if (!renderer) {
1056 renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type, this.appId);
1057 this.rendererByCompId.set(type.id, renderer);
1058 }
1059 renderer.applyToHost(element);
1060 return renderer;
1061 }
1062 case ViewEncapsulation.Native:
1063 case ViewEncapsulation.ShadowDom:
1064 return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
1065 default: {
1066 if (!this.rendererByCompId.has(type.id)) {
1067 var styles = flattenStyles(type.id, type.styles, []);
1068 this.sharedStylesHost.addStyles(styles);
1069 this.rendererByCompId.set(type.id, this.defaultRenderer);
1070 }
1071 return this.defaultRenderer;
1072 }
1073 }
1074 };
1075 DomRendererFactory2.prototype.begin = function () { };
1076 DomRendererFactory2.prototype.end = function () { };
1077 DomRendererFactory2 = __decorate([
1078 Injectable(),
1079 __param(2, Inject(APP_ID)),
1080 __metadata("design:paramtypes", [EventManager, DomSharedStylesHost, String])
1081 ], DomRendererFactory2);
1082 return DomRendererFactory2;
1083}());
1084var DefaultDomRenderer2 = /** @class */ (function () {
1085 function DefaultDomRenderer2(eventManager) {
1086 this.eventManager = eventManager;
1087 this.data = Object.create(null);
1088 }
1089 DefaultDomRenderer2.prototype.destroy = function () { };
1090 DefaultDomRenderer2.prototype.createElement = function (name, namespace) {
1091 if (namespace) {
1092 // In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key
1093 // will result in undefined, so we just return the namespace here.
1094 return document.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
1095 }
1096 return document.createElement(name);
1097 };
1098 DefaultDomRenderer2.prototype.createComment = function (value) { return document.createComment(value); };
1099 DefaultDomRenderer2.prototype.createText = function (value) { return document.createTextNode(value); };
1100 DefaultDomRenderer2.prototype.appendChild = function (parent, newChild) { parent.appendChild(newChild); };
1101 DefaultDomRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
1102 if (parent) {
1103 parent.insertBefore(newChild, refChild);
1104 }
1105 };
1106 DefaultDomRenderer2.prototype.removeChild = function (parent, oldChild) {
1107 if (parent) {
1108 parent.removeChild(oldChild);
1109 }
1110 };
1111 DefaultDomRenderer2.prototype.selectRootElement = function (selectorOrNode, preserveContent) {
1112 var el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
1113 selectorOrNode;
1114 if (!el) {
1115 throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
1116 }
1117 if (!preserveContent) {
1118 el.textContent = '';
1119 }
1120 return el;
1121 };
1122 DefaultDomRenderer2.prototype.parentNode = function (node) { return node.parentNode; };
1123 DefaultDomRenderer2.prototype.nextSibling = function (node) { return node.nextSibling; };
1124 DefaultDomRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
1125 if (namespace) {
1126 name = namespace + ':' + name;
1127 // TODO(benlesh): Ivy may cause issues here because it's passing around
1128 // full URIs for namespaces, therefore this lookup will fail.
1129 var namespaceUri = NAMESPACE_URIS[namespace];
1130 if (namespaceUri) {
1131 el.setAttributeNS(namespaceUri, name, value);
1132 }
1133 else {
1134 el.setAttribute(name, value);
1135 }
1136 }
1137 else {
1138 el.setAttribute(name, value);
1139 }
1140 };
1141 DefaultDomRenderer2.prototype.removeAttribute = function (el, name, namespace) {
1142 if (namespace) {
1143 // TODO(benlesh): Ivy may cause issues here because it's passing around
1144 // full URIs for namespaces, therefore this lookup will fail.
1145 var namespaceUri = NAMESPACE_URIS[namespace];
1146 if (namespaceUri) {
1147 el.removeAttributeNS(namespaceUri, name);
1148 }
1149 else {
1150 // TODO(benlesh): Since ivy is passing around full URIs for namespaces
1151 // this could result in properties like `http://www.w3.org/2000/svg:cx="123"`,
1152 // which is wrong.
1153 el.removeAttribute(namespace + ":" + name);
1154 }
1155 }
1156 else {
1157 el.removeAttribute(name);
1158 }
1159 };
1160 DefaultDomRenderer2.prototype.addClass = function (el, name) { el.classList.add(name); };
1161 DefaultDomRenderer2.prototype.removeClass = function (el, name) { el.classList.remove(name); };
1162 DefaultDomRenderer2.prototype.setStyle = function (el, style, value, flags) {
1163 if (flags & RendererStyleFlags2.DashCase) {
1164 el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
1165 }
1166 else {
1167 el.style[style] = value;
1168 }
1169 };
1170 DefaultDomRenderer2.prototype.removeStyle = function (el, style, flags) {
1171 if (flags & RendererStyleFlags2.DashCase) {
1172 el.style.removeProperty(style);
1173 }
1174 else {
1175 // IE requires '' instead of null
1176 // see https://github.com/angular/angular/issues/7916
1177 el.style[style] = '';
1178 }
1179 };
1180 DefaultDomRenderer2.prototype.setProperty = function (el, name, value) {
1181 checkNoSyntheticProp(name, 'property');
1182 el[name] = value;
1183 };
1184 DefaultDomRenderer2.prototype.setValue = function (node, value) { node.nodeValue = value; };
1185 DefaultDomRenderer2.prototype.listen = function (target, event, callback) {
1186 checkNoSyntheticProp(event, 'listener');
1187 if (typeof target === 'string') {
1188 return this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback));
1189 }
1190 return this.eventManager.addEventListener(target, event, decoratePreventDefault(callback));
1191 };
1192 return DefaultDomRenderer2;
1193}());
1194var ɵ0$2 = function () { return '@'.charCodeAt(0); };
1195var AT_CHARCODE = (ɵ0$2)();
1196function checkNoSyntheticProp(name, nameKind) {
1197 if (name.charCodeAt(0) === AT_CHARCODE) {
1198 throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
1199 }
1200}
1201var EmulatedEncapsulationDomRenderer2 = /** @class */ (function (_super) {
1202 __extends(EmulatedEncapsulationDomRenderer2, _super);
1203 function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component, appId) {
1204 var _this = _super.call(this, eventManager) || this;
1205 _this.component = component;
1206 var styles = flattenStyles(appId + '-' + component.id, component.styles, []);
1207 sharedStylesHost.addStyles(styles);
1208 _this.contentAttr = shimContentAttribute(appId + '-' + component.id);
1209 _this.hostAttr = shimHostAttribute(appId + '-' + component.id);
1210 return _this;
1211 }
1212 EmulatedEncapsulationDomRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
1213 EmulatedEncapsulationDomRenderer2.prototype.createElement = function (parent, name) {
1214 var el = _super.prototype.createElement.call(this, parent, name);
1215 _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
1216 return el;
1217 };
1218 return EmulatedEncapsulationDomRenderer2;
1219}(DefaultDomRenderer2));
1220var ShadowDomRenderer = /** @class */ (function (_super) {
1221 __extends(ShadowDomRenderer, _super);
1222 function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
1223 var _this = _super.call(this, eventManager) || this;
1224 _this.sharedStylesHost = sharedStylesHost;
1225 _this.hostEl = hostEl;
1226 _this.component = component;
1227 if (component.encapsulation === ViewEncapsulation.ShadowDom) {
1228 _this.shadowRoot = hostEl.attachShadow({ mode: 'open' });
1229 }
1230 else {
1231 _this.shadowRoot = hostEl.createShadowRoot();
1232 }
1233 _this.sharedStylesHost.addHost(_this.shadowRoot);
1234 var styles = flattenStyles(component.id, component.styles, []);
1235 for (var i = 0; i < styles.length; i++) {
1236 var styleEl = document.createElement('style');
1237 styleEl.textContent = styles[i];
1238 _this.shadowRoot.appendChild(styleEl);
1239 }
1240 return _this;
1241 }
1242 ShadowDomRenderer.prototype.nodeOrShadowRoot = function (node) { return node === this.hostEl ? this.shadowRoot : node; };
1243 ShadowDomRenderer.prototype.destroy = function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
1244 ShadowDomRenderer.prototype.appendChild = function (parent, newChild) {
1245 return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
1246 };
1247 ShadowDomRenderer.prototype.insertBefore = function (parent, newChild, refChild) {
1248 return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
1249 };
1250 ShadowDomRenderer.prototype.removeChild = function (parent, oldChild) {
1251 return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
1252 };
1253 ShadowDomRenderer.prototype.parentNode = function (node) {
1254 return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
1255 };
1256 return ShadowDomRenderer;
1257}(DefaultDomRenderer2));
1258
1259/**
1260 * @license
1261 * Copyright Google Inc. All Rights Reserved.
1262 *
1263 * Use of this source code is governed by an MIT-style license that can be
1264 * found in the LICENSE file at https://angular.io/license
1265 */
1266var ɵ0$3 = function () { return (typeof Zone !== 'undefined') && Zone['__symbol__'] ||
1267 function (v) { return '__zone_symbol__' + v; }; };
1268/**
1269 * Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
1270 * since Angular can do much more
1271 * efficient bookkeeping than Zone can, because we have additional information. This speeds up
1272 * addEventListener by 3x.
1273 */
1274var __symbol__ = (ɵ0$3)();
1275var ADD_EVENT_LISTENER = __symbol__('addEventListener');
1276var REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
1277var symbolNames = {};
1278var FALSE = 'FALSE';
1279var ANGULAR = 'ANGULAR';
1280var NATIVE_ADD_LISTENER = 'addEventListener';
1281var NATIVE_REMOVE_LISTENER = 'removeEventListener';
1282// use the same symbol string which is used in zone.js
1283var stopSymbol = '__zone_symbol__propagationStopped';
1284var stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
1285var ɵ1 = function () {
1286 var blackListedEvents = (typeof Zone !== 'undefined') && Zone[__symbol__('BLACK_LISTED_EVENTS')];
1287 if (blackListedEvents) {
1288 var res_1 = {};
1289 blackListedEvents.forEach(function (eventName) { res_1[eventName] = eventName; });
1290 return res_1;
1291 }
1292 return undefined;
1293};
1294var blackListedMap = (ɵ1)();
1295var isBlackListedEvent = function (eventName) {
1296 if (!blackListedMap) {
1297 return false;
1298 }
1299 return blackListedMap.hasOwnProperty(eventName);
1300};
1301var ɵ2 = isBlackListedEvent;
1302// a global listener to handle all dom event,
1303// so we do not need to create a closure every time
1304var globalListener = function (event) {
1305 var symbolName = symbolNames[event.type];
1306 if (!symbolName) {
1307 return;
1308 }
1309 var taskDatas = this[symbolName];
1310 if (!taskDatas) {
1311 return;
1312 }
1313 var args = [event];
1314 if (taskDatas.length === 1) {
1315 // if taskDatas only have one element, just invoke it
1316 var taskData = taskDatas[0];
1317 if (taskData.zone !== Zone.current) {
1318 // only use Zone.run when Zone.current not equals to stored zone
1319 return taskData.zone.run(taskData.handler, this, args);
1320 }
1321 else {
1322 return taskData.handler.apply(this, args);
1323 }
1324 }
1325 else {
1326 // copy tasks as a snapshot to avoid event handlers remove
1327 // itself or others
1328 var copiedTasks = taskDatas.slice();
1329 for (var i = 0; i < copiedTasks.length; i++) {
1330 // if other listener call event.stopImmediatePropagation
1331 // just break
1332 if (event[stopSymbol] === true) {
1333 break;
1334 }
1335 var taskData = copiedTasks[i];
1336 if (taskData.zone !== Zone.current) {
1337 // only use Zone.run when Zone.current not equals to stored zone
1338 taskData.zone.run(taskData.handler, this, args);
1339 }
1340 else {
1341 taskData.handler.apply(this, args);
1342 }
1343 }
1344 }
1345};
1346var ɵ3 = globalListener;
1347var DomEventsPlugin = /** @class */ (function (_super) {
1348 __extends(DomEventsPlugin, _super);
1349 function DomEventsPlugin(doc, ngZone, platformId) {
1350 var _this = _super.call(this, doc) || this;
1351 _this.ngZone = ngZone;
1352 if (!platformId || !isPlatformServer(platformId)) {
1353 _this.patchEvent();
1354 }
1355 return _this;
1356 }
1357 DomEventsPlugin.prototype.patchEvent = function () {
1358 if (typeof Event === 'undefined' || !Event || !Event.prototype) {
1359 return;
1360 }
1361 if (Event.prototype[stopMethodSymbol]) {
1362 // already patched by zone.js
1363 return;
1364 }
1365 var delegate = Event.prototype[stopMethodSymbol] =
1366 Event.prototype.stopImmediatePropagation;
1367 Event.prototype.stopImmediatePropagation = function () {
1368 if (this) {
1369 this[stopSymbol] = true;
1370 }
1371 // We should call native delegate in case in some environment part of
1372 // the application will not use the patched Event. Also we cast the
1373 // "arguments" to any since "stopImmediatePropagation" technically does not
1374 // accept any arguments, but we don't know what developers pass through the
1375 // function and we want to not break these calls.
1376 delegate && delegate.apply(this, arguments);
1377 };
1378 };
1379 // This plugin should come last in the list of plugins, because it accepts all
1380 // events.
1381 DomEventsPlugin.prototype.supports = function (eventName) { return true; };
1382 DomEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
1383 var _this = this;
1384 /**
1385 * This code is about to add a listener to the DOM. If Zone.js is present, than
1386 * `addEventListener` has been patched. The patched code adds overhead in both
1387 * memory and speed (3x slower) than native. For this reason if we detect that
1388 * Zone.js is present we use a simple version of zone aware addEventListener instead.
1389 * The result is faster registration and the zone will be restored.
1390 * But ZoneSpec.onScheduleTask, ZoneSpec.onInvokeTask, ZoneSpec.onCancelTask
1391 * will not be invoked
1392 * We also do manual zone restoration in element.ts renderEventHandlerClosure method.
1393 *
1394 * NOTE: it is possible that the element is from different iframe, and so we
1395 * have to check before we execute the method.
1396 */
1397 var self = this;
1398 var zoneJsLoaded = element[ADD_EVENT_LISTENER];
1399 var callback = handler;
1400 // if zonejs is loaded and current zone is not ngZone
1401 // we keep Zone.current on target for later restoration.
1402 if (zoneJsLoaded && (!NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
1403 var symbolName = symbolNames[eventName];
1404 if (!symbolName) {
1405 symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
1406 }
1407 var taskDatas = element[symbolName];
1408 var globalListenerRegistered = taskDatas && taskDatas.length > 0;
1409 if (!taskDatas) {
1410 taskDatas = element[symbolName] = [];
1411 }
1412 var zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
1413 if (taskDatas.length === 0) {
1414 taskDatas.push({ zone: zone, handler: callback });
1415 }
1416 else {
1417 var callbackRegistered = false;
1418 for (var i = 0; i < taskDatas.length; i++) {
1419 if (taskDatas[i].handler === callback) {
1420 callbackRegistered = true;
1421 break;
1422 }
1423 }
1424 if (!callbackRegistered) {
1425 taskDatas.push({ zone: zone, handler: callback });
1426 }
1427 }
1428 if (!globalListenerRegistered) {
1429 element[ADD_EVENT_LISTENER](eventName, globalListener, false);
1430 }
1431 }
1432 else {
1433 element[NATIVE_ADD_LISTENER](eventName, callback, false);
1434 }
1435 return function () { return _this.removeEventListener(element, eventName, callback); };
1436 };
1437 DomEventsPlugin.prototype.removeEventListener = function (target, eventName, callback) {
1438 var underlyingRemove = target[REMOVE_EVENT_LISTENER];
1439 // zone.js not loaded, use native removeEventListener
1440 if (!underlyingRemove) {
1441 return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
1442 }
1443 var symbolName = symbolNames[eventName];
1444 var taskDatas = symbolName && target[symbolName];
1445 if (!taskDatas) {
1446 // addEventListener not using patched version
1447 // just call native removeEventListener
1448 return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
1449 }
1450 // fix issue 20532, should be able to remove
1451 // listener which was added inside of ngZone
1452 var found = false;
1453 for (var i = 0; i < taskDatas.length; i++) {
1454 // remove listener from taskDatas if the callback equals
1455 if (taskDatas[i].handler === callback) {
1456 found = true;
1457 taskDatas.splice(i, 1);
1458 break;
1459 }
1460 }
1461 if (found) {
1462 if (taskDatas.length === 0) {
1463 // all listeners are removed, we can remove the globalListener from target
1464 underlyingRemove.apply(target, [eventName, globalListener, false]);
1465 }
1466 }
1467 else {
1468 // not found in taskDatas, the callback may be added inside of ngZone
1469 // use native remove listener to remove the callback
1470 target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
1471 }
1472 };
1473 DomEventsPlugin = __decorate([
1474 Injectable(),
1475 __param(0, Inject(DOCUMENT)),
1476 __param(2, Optional()), __param(2, Inject(PLATFORM_ID)),
1477 __metadata("design:paramtypes", [Object, NgZone, Object])
1478 ], DomEventsPlugin);
1479 return DomEventsPlugin;
1480}(EventManagerPlugin));
1481
1482/**
1483 * @license
1484 * Copyright Google Inc. All Rights Reserved.
1485 *
1486 * Use of this source code is governed by an MIT-style license that can be
1487 * found in the LICENSE file at https://angular.io/license
1488 */
1489/**
1490 * Supported HammerJS recognizer event names.
1491 */
1492var EVENT_NAMES = {
1493 // pan
1494 'pan': true,
1495 'panstart': true,
1496 'panmove': true,
1497 'panend': true,
1498 'pancancel': true,
1499 'panleft': true,
1500 'panright': true,
1501 'panup': true,
1502 'pandown': true,
1503 // pinch
1504 'pinch': true,
1505 'pinchstart': true,
1506 'pinchmove': true,
1507 'pinchend': true,
1508 'pinchcancel': true,
1509 'pinchin': true,
1510 'pinchout': true,
1511 // press
1512 'press': true,
1513 'pressup': true,
1514 // rotate
1515 'rotate': true,
1516 'rotatestart': true,
1517 'rotatemove': true,
1518 'rotateend': true,
1519 'rotatecancel': true,
1520 // swipe
1521 'swipe': true,
1522 'swipeleft': true,
1523 'swiperight': true,
1524 'swipeup': true,
1525 'swipedown': true,
1526 // tap
1527 'tap': true,
1528};
1529/**
1530 * DI token for providing [HammerJS](http://hammerjs.github.io/) support to Angular.
1531 * @see `HammerGestureConfig`
1532 *
1533 * @publicApi
1534 */
1535var HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
1536/**
1537 * Injection token used to provide a {@link HammerLoader} to Angular.
1538 *
1539 * @publicApi
1540 */
1541var HAMMER_LOADER = new InjectionToken('HammerLoader');
1542/**
1543 * An injectable [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
1544 * for gesture recognition. Configures specific event recognition.
1545 * @publicApi
1546 */
1547var HammerGestureConfig = /** @class */ (function () {
1548 function HammerGestureConfig() {
1549 /**
1550 * A set of supported event names for gestures to be used in Angular.
1551 * Angular supports all built-in recognizers, as listed in
1552 * [HammerJS documentation](http://hammerjs.github.io/).
1553 */
1554 this.events = [];
1555 /**
1556 * Maps gesture event names to a set of configuration options
1557 * that specify overrides to the default values for specific properties.
1558 *
1559 * The key is a supported event name to be configured,
1560 * and the options object contains a set of properties, with override values
1561 * to be applied to the named recognizer event.
1562 * For example, to disable recognition of the rotate event, specify
1563 * `{"rotate": {"enable": false}}`.
1564 *
1565 * Properties that are not present take the HammerJS default values.
1566 * For information about which properties are supported for which events,
1567 * and their allowed and default values, see
1568 * [HammerJS documentation](http://hammerjs.github.io/).
1569 *
1570 */
1571 this.overrides = {};
1572 }
1573 /**
1574 * Creates a [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
1575 * and attaches it to a given HTML element.
1576 * @param element The element that will recognize gestures.
1577 * @returns A HammerJS event-manager object.
1578 */
1579 HammerGestureConfig.prototype.buildHammer = function (element) {
1580 var mc = new Hammer(element, this.options);
1581 mc.get('pinch').set({ enable: true });
1582 mc.get('rotate').set({ enable: true });
1583 for (var eventName in this.overrides) {
1584 mc.get(eventName).set(this.overrides[eventName]);
1585 }
1586 return mc;
1587 };
1588 HammerGestureConfig = __decorate([
1589 Injectable()
1590 ], HammerGestureConfig);
1591 return HammerGestureConfig;
1592}());
1593var HammerGesturesPlugin = /** @class */ (function (_super) {
1594 __extends(HammerGesturesPlugin, _super);
1595 function HammerGesturesPlugin(doc, _config, console, loader) {
1596 var _this = _super.call(this, doc) || this;
1597 _this._config = _config;
1598 _this.console = console;
1599 _this.loader = loader;
1600 return _this;
1601 }
1602 HammerGesturesPlugin.prototype.supports = function (eventName) {
1603 if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
1604 return false;
1605 }
1606 if (!window.Hammer && !this.loader) {
1607 this.console.warn("The \"" + eventName + "\" event cannot be bound because Hammer.JS is not " +
1608 "loaded and no custom loader has been specified.");
1609 return false;
1610 }
1611 return true;
1612 };
1613 HammerGesturesPlugin.prototype.addEventListener = function (element, eventName, handler) {
1614 var _this = this;
1615 var zone = this.manager.getZone();
1616 eventName = eventName.toLowerCase();
1617 // If Hammer is not present but a loader is specified, we defer adding the event listener
1618 // until Hammer is loaded.
1619 if (!window.Hammer && this.loader) {
1620 // This `addEventListener` method returns a function to remove the added listener.
1621 // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
1622 // than remove anything.
1623 var cancelRegistration_1 = false;
1624 var deregister_1 = function () { cancelRegistration_1 = true; };
1625 this.loader()
1626 .then(function () {
1627 // If Hammer isn't actually loaded when the custom loader resolves, give up.
1628 if (!window.Hammer) {
1629 _this.console.warn("The custom HAMMER_LOADER completed, but Hammer.JS is not present.");
1630 deregister_1 = function () { };
1631 return;
1632 }
1633 if (!cancelRegistration_1) {
1634 // Now that Hammer is loaded and the listener is being loaded for real,
1635 // the deregistration function changes from canceling registration to removal.
1636 deregister_1 = _this.addEventListener(element, eventName, handler);
1637 }
1638 })
1639 .catch(function () {
1640 _this.console.warn("The \"" + eventName + "\" event cannot be bound because the custom " +
1641 "Hammer.JS loader failed.");
1642 deregister_1 = function () { };
1643 });
1644 // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
1645 // can change the behavior of `deregister` once the listener is added. Using a closure in
1646 // this way allows us to avoid any additional data structures to track listener removal.
1647 return function () { deregister_1(); };
1648 }
1649 return zone.runOutsideAngular(function () {
1650 // Creating the manager bind events, must be done outside of angular
1651 var mc = _this._config.buildHammer(element);
1652 var callback = function (eventObj) {
1653 zone.runGuarded(function () { handler(eventObj); });
1654 };
1655 mc.on(eventName, callback);
1656 return function () {
1657 mc.off(eventName, callback);
1658 // destroy mc to prevent memory leak
1659 if (typeof mc.destroy === 'function') {
1660 mc.destroy();
1661 }
1662 };
1663 });
1664 };
1665 HammerGesturesPlugin.prototype.isCustomEvent = function (eventName) { return this._config.events.indexOf(eventName) > -1; };
1666 HammerGesturesPlugin = __decorate([
1667 Injectable(),
1668 __param(0, Inject(DOCUMENT)),
1669 __param(1, Inject(HAMMER_GESTURE_CONFIG)),
1670 __param(3, Optional()), __param(3, Inject(HAMMER_LOADER)),
1671 __metadata("design:paramtypes", [Object, HammerGestureConfig, ɵConsole, Object])
1672 ], HammerGesturesPlugin);
1673 return HammerGesturesPlugin;
1674}(EventManagerPlugin));
1675
1676/**
1677 * @license
1678 * Copyright Google Inc. All Rights Reserved.
1679 *
1680 * Use of this source code is governed by an MIT-style license that can be
1681 * found in the LICENSE file at https://angular.io/license
1682 */
1683/**
1684 * Defines supported modifiers for key events.
1685 */
1686var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
1687var ɵ0$4 = function (event) { return event.altKey; }, ɵ1$1 = function (event) { return event.ctrlKey; }, ɵ2$1 = function (event) { return event.metaKey; }, ɵ3$1 = function (event) { return event.shiftKey; };
1688/**
1689 * Retrieves modifiers from key-event objects.
1690 */
1691var MODIFIER_KEY_GETTERS = {
1692 'alt': ɵ0$4,
1693 'control': ɵ1$1,
1694 'meta': ɵ2$1,
1695 'shift': ɵ3$1
1696};
1697/**
1698 * @publicApi
1699 * A browser plug-in that provides support for handling of key events in Angular.
1700 */
1701var KeyEventsPlugin = /** @class */ (function (_super) {
1702 __extends(KeyEventsPlugin, _super);
1703 /**
1704 * Initializes an instance of the browser plug-in.
1705 * @param doc The document in which key events will be detected.
1706 */
1707 function KeyEventsPlugin(doc) {
1708 return _super.call(this, doc) || this;
1709 }
1710 KeyEventsPlugin_1 = KeyEventsPlugin;
1711 /**
1712 * Reports whether a named key event is supported.
1713 * @param eventName The event name to query.
1714 * @return True if the named key event is supported.
1715 */
1716 KeyEventsPlugin.prototype.supports = function (eventName) { return KeyEventsPlugin_1.parseEventName(eventName) != null; };
1717 /**
1718 * Registers a handler for a specific element and key event.
1719 * @param element The HTML element to receive event notifications.
1720 * @param eventName The name of the key event to listen for.
1721 * @param handler A function to call when the notification occurs. Receives the
1722 * event object as an argument.
1723 * @returns The key event that was registered.
1724 */
1725 KeyEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
1726 var parsedEvent = KeyEventsPlugin_1.parseEventName(eventName);
1727 var outsideHandler = KeyEventsPlugin_1.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
1728 return this.manager.getZone().runOutsideAngular(function () {
1729 return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
1730 });
1731 };
1732 KeyEventsPlugin.parseEventName = function (eventName) {
1733 var parts = eventName.toLowerCase().split('.');
1734 var domEventName = parts.shift();
1735 if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
1736 return null;
1737 }
1738 var key = KeyEventsPlugin_1._normalizeKey(parts.pop());
1739 var fullKey = '';
1740 MODIFIER_KEYS.forEach(function (modifierName) {
1741 var index = parts.indexOf(modifierName);
1742 if (index > -1) {
1743 parts.splice(index, 1);
1744 fullKey += modifierName + '.';
1745 }
1746 });
1747 fullKey += key;
1748 if (parts.length != 0 || key.length === 0) {
1749 // returning null instead of throwing to let another plugin process the event
1750 return null;
1751 }
1752 var result = {};
1753 result['domEventName'] = domEventName;
1754 result['fullKey'] = fullKey;
1755 return result;
1756 };
1757 KeyEventsPlugin.getEventFullKey = function (event) {
1758 var fullKey = '';
1759 var key = getDOM().getEventKey(event);
1760 key = key.toLowerCase();
1761 if (key === ' ') {
1762 key = 'space'; // for readability
1763 }
1764 else if (key === '.') {
1765 key = 'dot'; // because '.' is used as a separator in event names
1766 }
1767 MODIFIER_KEYS.forEach(function (modifierName) {
1768 if (modifierName != key) {
1769 var modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
1770 if (modifierGetter(event)) {
1771 fullKey += modifierName + '.';
1772 }
1773 }
1774 });
1775 fullKey += key;
1776 return fullKey;
1777 };
1778 /**
1779 * Configures a handler callback for a key event.
1780 * @param fullKey The event name that combines all simultaneous keystrokes.
1781 * @param handler The function that responds to the key event.
1782 * @param zone The zone in which the event occurred.
1783 * @returns A callback function.
1784 */
1785 KeyEventsPlugin.eventCallback = function (fullKey, handler, zone) {
1786 return function (event /** TODO #9100 */) {
1787 if (KeyEventsPlugin_1.getEventFullKey(event) === fullKey) {
1788 zone.runGuarded(function () { return handler(event); });
1789 }
1790 };
1791 };
1792 /** @internal */
1793 KeyEventsPlugin._normalizeKey = function (keyName) {
1794 // TODO: switch to a Map if the mapping grows too much
1795 switch (keyName) {
1796 case 'esc':
1797 return 'escape';
1798 default:
1799 return keyName;
1800 }
1801 };
1802 var KeyEventsPlugin_1;
1803 KeyEventsPlugin = KeyEventsPlugin_1 = __decorate([
1804 Injectable(),
1805 __param(0, Inject(DOCUMENT)),
1806 __metadata("design:paramtypes", [Object])
1807 ], KeyEventsPlugin);
1808 return KeyEventsPlugin;
1809}(EventManagerPlugin));
1810
1811/**
1812 * @license
1813 * Copyright Google Inc. All Rights Reserved.
1814 *
1815 * Use of this source code is governed by an MIT-style license that can be
1816 * found in the LICENSE file at https://angular.io/license
1817 */
1818/**
1819 * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
1820 * values to be safe to use in the different DOM contexts.
1821 *
1822 * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
1823 * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
1824 * the website.
1825 *
1826 * In specific situations, it might be necessary to disable sanitization, for example if the
1827 * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
1828 * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
1829 * methods, and then binding to that value from the template.
1830 *
1831 * These situations should be very rare, and extraordinary care must be taken to avoid creating a
1832 * Cross Site Scripting (XSS) security bug!
1833 *
1834 * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
1835 * close as possible to the source of the value, to make it easy to verify no security bug is
1836 * created by its use.
1837 *
1838 * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
1839 * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
1840 * code. The sanitizer leaves safe values intact.
1841 *
1842 * @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
1843 * sanitization for the value passed in. Carefully check and audit all values and code paths going
1844 * into this call. Make sure any user data is appropriately escaped for this security context.
1845 * For more detail, see the [Security Guide](http://g.co/ng/security).
1846 *
1847 * @publicApi
1848 */
1849var DomSanitizer = /** @class */ (function () {
1850 function DomSanitizer() {
1851 }
1852 return DomSanitizer;
1853}());
1854var DomSanitizerImpl = /** @class */ (function (_super) {
1855 __extends(DomSanitizerImpl, _super);
1856 function DomSanitizerImpl(_doc) {
1857 var _this = _super.call(this) || this;
1858 _this._doc = _doc;
1859 return _this;
1860 }
1861 DomSanitizerImpl.prototype.sanitize = function (ctx, value) {
1862 if (value == null)
1863 return null;
1864 switch (ctx) {
1865 case SecurityContext.NONE:
1866 return value;
1867 case SecurityContext.HTML:
1868 if (value instanceof SafeHtmlImpl)
1869 return value.changingThisBreaksApplicationSecurity;
1870 this.checkNotSafeValue(value, 'HTML');
1871 return ɵ_sanitizeHtml(this._doc, String(value));
1872 case SecurityContext.STYLE:
1873 if (value instanceof SafeStyleImpl)
1874 return value.changingThisBreaksApplicationSecurity;
1875 this.checkNotSafeValue(value, 'Style');
1876 return ɵ_sanitizeStyle(value);
1877 case SecurityContext.SCRIPT:
1878 if (value instanceof SafeScriptImpl)
1879 return value.changingThisBreaksApplicationSecurity;
1880 this.checkNotSafeValue(value, 'Script');
1881 throw new Error('unsafe value used in a script context');
1882 case SecurityContext.URL:
1883 if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
1884 // Allow resource URLs in URL contexts, they are strictly more trusted.
1885 return value.changingThisBreaksApplicationSecurity;
1886 }
1887 this.checkNotSafeValue(value, 'URL');
1888 return ɵ_sanitizeUrl(String(value));
1889 case SecurityContext.RESOURCE_URL:
1890 if (value instanceof SafeResourceUrlImpl) {
1891 return value.changingThisBreaksApplicationSecurity;
1892 }
1893 this.checkNotSafeValue(value, 'ResourceURL');
1894 throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
1895 default:
1896 throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
1897 }
1898 };
1899 DomSanitizerImpl.prototype.checkNotSafeValue = function (value, expectedType) {
1900 if (value instanceof SafeValueImpl) {
1901 throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " +
1902 "(see http://g.co/ng/security#xss)");
1903 }
1904 };
1905 DomSanitizerImpl.prototype.bypassSecurityTrustHtml = function (value) { return new SafeHtmlImpl(value); };
1906 DomSanitizerImpl.prototype.bypassSecurityTrustStyle = function (value) { return new SafeStyleImpl(value); };
1907 DomSanitizerImpl.prototype.bypassSecurityTrustScript = function (value) { return new SafeScriptImpl(value); };
1908 DomSanitizerImpl.prototype.bypassSecurityTrustUrl = function (value) { return new SafeUrlImpl(value); };
1909 DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = function (value) {
1910 return new SafeResourceUrlImpl(value);
1911 };
1912 DomSanitizerImpl = __decorate([
1913 Injectable(),
1914 __param(0, Inject(DOCUMENT)),
1915 __metadata("design:paramtypes", [Object])
1916 ], DomSanitizerImpl);
1917 return DomSanitizerImpl;
1918}(DomSanitizer));
1919var SafeValueImpl = /** @class */ (function () {
1920 function SafeValueImpl(changingThisBreaksApplicationSecurity) {
1921 this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
1922 // empty
1923 }
1924 SafeValueImpl.prototype.toString = function () {
1925 return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity +
1926 " (see http://g.co/ng/security#xss)";
1927 };
1928 return SafeValueImpl;
1929}());
1930var SafeHtmlImpl = /** @class */ (function (_super) {
1931 __extends(SafeHtmlImpl, _super);
1932 function SafeHtmlImpl() {
1933 return _super !== null && _super.apply(this, arguments) || this;
1934 }
1935 SafeHtmlImpl.prototype.getTypeName = function () { return 'HTML'; };
1936 return SafeHtmlImpl;
1937}(SafeValueImpl));
1938var SafeStyleImpl = /** @class */ (function (_super) {
1939 __extends(SafeStyleImpl, _super);
1940 function SafeStyleImpl() {
1941 return _super !== null && _super.apply(this, arguments) || this;
1942 }
1943 SafeStyleImpl.prototype.getTypeName = function () { return 'Style'; };
1944 return SafeStyleImpl;
1945}(SafeValueImpl));
1946var SafeScriptImpl = /** @class */ (function (_super) {
1947 __extends(SafeScriptImpl, _super);
1948 function SafeScriptImpl() {
1949 return _super !== null && _super.apply(this, arguments) || this;
1950 }
1951 SafeScriptImpl.prototype.getTypeName = function () { return 'Script'; };
1952 return SafeScriptImpl;
1953}(SafeValueImpl));
1954var SafeUrlImpl = /** @class */ (function (_super) {
1955 __extends(SafeUrlImpl, _super);
1956 function SafeUrlImpl() {
1957 return _super !== null && _super.apply(this, arguments) || this;
1958 }
1959 SafeUrlImpl.prototype.getTypeName = function () { return 'URL'; };
1960 return SafeUrlImpl;
1961}(SafeValueImpl));
1962var SafeResourceUrlImpl = /** @class */ (function (_super) {
1963 __extends(SafeResourceUrlImpl, _super);
1964 function SafeResourceUrlImpl() {
1965 return _super !== null && _super.apply(this, arguments) || this;
1966 }
1967 SafeResourceUrlImpl.prototype.getTypeName = function () { return 'ResourceURL'; };
1968 return SafeResourceUrlImpl;
1969}(SafeValueImpl));
1970
1971/**
1972 * @license
1973 * Copyright Google Inc. All Rights Reserved.
1974 *
1975 * Use of this source code is governed by an MIT-style license that can be
1976 * found in the LICENSE file at https://angular.io/license
1977 */
1978var ɵ0$5 = ɵPLATFORM_BROWSER_ID;
1979var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
1980 { provide: PLATFORM_ID, useValue: ɵ0$5 },
1981 { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
1982 { provide: PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT] },
1983 { provide: DOCUMENT, useFactory: _document, deps: [] },
1984];
1985/**
1986 * @security Replacing built-in sanitization providers exposes the application to XSS risks.
1987 * Attacker-controlled data introduced by an unsanitized provider could expose your
1988 * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
1989 * @publicApi
1990 */
1991var BROWSER_SANITIZATION_PROVIDERS = [
1992 { provide: Sanitizer, useExisting: DomSanitizer },
1993 { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
1994];
1995/**
1996 * @publicApi
1997 */
1998var platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
1999function initDomAdapter() {
2000 BrowserDomAdapter.makeCurrent();
2001 BrowserGetTestability.init();
2002}
2003function errorHandler() {
2004 return new ErrorHandler();
2005}
2006function _document() {
2007 return document;
2008}
2009var BROWSER_MODULE_PROVIDERS = [
2010 BROWSER_SANITIZATION_PROVIDERS,
2011 { provide: ɵAPP_ROOT, useValue: true },
2012 { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
2013 {
2014 provide: EVENT_MANAGER_PLUGINS,
2015 useClass: DomEventsPlugin,
2016 multi: true,
2017 deps: [DOCUMENT, NgZone, PLATFORM_ID]
2018 },
2019 { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
2020 {
2021 provide: EVENT_MANAGER_PLUGINS,
2022 useClass: HammerGesturesPlugin,
2023 multi: true,
2024 deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
2025 },
2026 { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
2027 {
2028 provide: DomRendererFactory2,
2029 useClass: DomRendererFactory2,
2030 deps: [EventManager, DomSharedStylesHost, APP_ID]
2031 },
2032 { provide: RendererFactory2, useExisting: DomRendererFactory2 },
2033 { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
2034 { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
2035 { provide: Testability, useClass: Testability, deps: [NgZone] },
2036 { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
2037 ELEMENT_PROBE_PROVIDERS,
2038];
2039/**
2040 * Exports required infrastructure for all Angular apps.
2041 * Included by default in all Angular apps created with the CLI
2042 * `new` command.
2043 * Re-exports `CommonModule` and `ApplicationModule`, making their
2044 * exports and providers available to all apps.
2045 *
2046 * @publicApi
2047 */
2048var BrowserModule = /** @class */ (function () {
2049 function BrowserModule(parentModule) {
2050 if (parentModule) {
2051 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.");
2052 }
2053 }
2054 BrowserModule_1 = BrowserModule;
2055 /**
2056 * Configures a browser-based app to transition from a server-rendered app, if
2057 * one is present on the page.
2058 *
2059 * @param params An object containing an identifier for the app to transition.
2060 * The ID must match between the client and server versions of the app.
2061 * @returns The reconfigured `BrowserModule` to import into the app's root `AppModule`.
2062 */
2063 BrowserModule.withServerTransition = function (params) {
2064 return {
2065 ngModule: BrowserModule_1,
2066 providers: [
2067 { provide: APP_ID, useValue: params.appId },
2068 { provide: TRANSITION_ID, useExisting: APP_ID },
2069 SERVER_TRANSITION_PROVIDERS,
2070 ],
2071 };
2072 };
2073 var BrowserModule_1;
2074 BrowserModule = BrowserModule_1 = __decorate([
2075 NgModule({ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] }),
2076 __param(0, Optional()), __param(0, SkipSelf()), __param(0, Inject(BrowserModule_1)),
2077 __metadata("design:paramtypes", [Object])
2078 ], BrowserModule);
2079 return BrowserModule;
2080}());
2081
2082/**
2083 * Factory to create Meta service.
2084 */
2085function createMeta() {
2086 return new Meta(ɵɵinject(DOCUMENT));
2087}
2088/**
2089 * A service that can be used to get and add meta tags.
2090 *
2091 * @publicApi
2092 */
2093var Meta = /** @class */ (function () {
2094 function Meta(_doc) {
2095 this._doc = _doc;
2096 this._dom = getDOM();
2097 }
2098 Meta.prototype.addTag = function (tag, forceCreation) {
2099 if (forceCreation === void 0) { forceCreation = false; }
2100 if (!tag)
2101 return null;
2102 return this._getOrCreateElement(tag, forceCreation);
2103 };
2104 Meta.prototype.addTags = function (tags, forceCreation) {
2105 var _this = this;
2106 if (forceCreation === void 0) { forceCreation = false; }
2107 if (!tags)
2108 return [];
2109 return tags.reduce(function (result, tag) {
2110 if (tag) {
2111 result.push(_this._getOrCreateElement(tag, forceCreation));
2112 }
2113 return result;
2114 }, []);
2115 };
2116 Meta.prototype.getTag = function (attrSelector) {
2117 if (!attrSelector)
2118 return null;
2119 return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]") || null;
2120 };
2121 Meta.prototype.getTags = function (attrSelector) {
2122 if (!attrSelector)
2123 return [];
2124 var list /*NodeList*/ = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
2125 return list ? [].slice.call(list) : [];
2126 };
2127 Meta.prototype.updateTag = function (tag, selector) {
2128 if (!tag)
2129 return null;
2130 selector = selector || this._parseSelector(tag);
2131 var meta = this.getTag(selector);
2132 if (meta) {
2133 return this._setMetaElementAttributes(tag, meta);
2134 }
2135 return this._getOrCreateElement(tag, true);
2136 };
2137 Meta.prototype.removeTag = function (attrSelector) { this.removeTagElement(this.getTag(attrSelector)); };
2138 Meta.prototype.removeTagElement = function (meta) {
2139 if (meta) {
2140 this._dom.remove(meta);
2141 }
2142 };
2143 Meta.prototype._getOrCreateElement = function (meta, forceCreation) {
2144 if (forceCreation === void 0) { forceCreation = false; }
2145 if (!forceCreation) {
2146 var selector = this._parseSelector(meta);
2147 var elem = this.getTag(selector);
2148 // It's allowed to have multiple elements with the same name so it's not enough to
2149 // just check that element with the same name already present on the page. We also need to
2150 // check if element has tag attributes
2151 if (elem && this._containsAttributes(meta, elem))
2152 return elem;
2153 }
2154 var element = this._dom.createElement('meta');
2155 this._setMetaElementAttributes(meta, element);
2156 var head = this._dom.getElementsByTagName(this._doc, 'head')[0];
2157 this._dom.appendChild(head, element);
2158 return element;
2159 };
2160 Meta.prototype._setMetaElementAttributes = function (tag, el) {
2161 var _this = this;
2162 Object.keys(tag).forEach(function (prop) { return _this._dom.setAttribute(el, prop, tag[prop]); });
2163 return el;
2164 };
2165 Meta.prototype._parseSelector = function (tag) {
2166 var attr = tag.name ? 'name' : 'property';
2167 return attr + "=\"" + tag[attr] + "\"";
2168 };
2169 Meta.prototype._containsAttributes = function (tag, elem) {
2170 var _this = this;
2171 return Object.keys(tag).every(function (key) { return _this._dom.getAttribute(elem, key) === tag[key]; });
2172 };
2173 Meta.ngInjectableDef = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
2174 Meta = __decorate([
2175 Injectable({ providedIn: 'root', useFactory: createMeta, deps: [] }),
2176 __param(0, Inject(DOCUMENT)),
2177 __metadata("design:paramtypes", [Object])
2178 ], Meta);
2179 return Meta;
2180}());
2181
2182/**
2183 * Factory to create Title service.
2184 */
2185function createTitle() {
2186 return new Title(ɵɵinject(DOCUMENT));
2187}
2188/**
2189 * A service that can be used to get and set the title of a current HTML document.
2190 *
2191 * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
2192 * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
2193 * (representing the `<title>` tag). Instead, this service can be used to set and get the current
2194 * title value.
2195 *
2196 * @publicApi
2197 */
2198var Title = /** @class */ (function () {
2199 function Title(_doc) {
2200 this._doc = _doc;
2201 }
2202 /**
2203 * Get the title of the current HTML document.
2204 */
2205 Title.prototype.getTitle = function () { return getDOM().getTitle(this._doc); };
2206 /**
2207 * Set the title of the current HTML document.
2208 * @param newTitle
2209 */
2210 Title.prototype.setTitle = function (newTitle) { getDOM().setTitle(this._doc, newTitle); };
2211 Title.ngInjectableDef = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
2212 Title = __decorate([
2213 Injectable({ providedIn: 'root', useFactory: createTitle, deps: [] }),
2214 __param(0, Inject(DOCUMENT)),
2215 __metadata("design:paramtypes", [Object])
2216 ], Title);
2217 return Title;
2218}());
2219
2220/**
2221 * @license
2222 * Copyright Google Inc. All Rights Reserved.
2223 *
2224 * Use of this source code is governed by an MIT-style license that can be
2225 * found in the LICENSE file at https://angular.io/license
2226 */
2227var win = typeof window !== 'undefined' && window || {};
2228
2229/**
2230 * @license
2231 * Copyright Google Inc. All Rights Reserved.
2232 *
2233 * Use of this source code is governed by an MIT-style license that can be
2234 * found in the LICENSE file at https://angular.io/license
2235 */
2236var ChangeDetectionPerfRecord = /** @class */ (function () {
2237 function ChangeDetectionPerfRecord(msPerTick, numTicks) {
2238 this.msPerTick = msPerTick;
2239 this.numTicks = numTicks;
2240 }
2241 return ChangeDetectionPerfRecord;
2242}());
2243/**
2244 * Entry point for all Angular profiling-related debug tools. This object
2245 * corresponds to the `ng.profiler` in the dev console.
2246 */
2247var AngularProfiler = /** @class */ (function () {
2248 function AngularProfiler(ref) {
2249 this.appRef = ref.injector.get(ApplicationRef);
2250 }
2251 // tslint:disable:no-console
2252 /**
2253 * Exercises change detection in a loop and then prints the average amount of
2254 * time in milliseconds how long a single round of change detection takes for
2255 * the current state of the UI. It runs a minimum of 5 rounds for a minimum
2256 * of 500 milliseconds.
2257 *
2258 * Optionally, a user may pass a `config` parameter containing a map of
2259 * options. Supported options are:
2260 *
2261 * `record` (boolean) - causes the profiler to record a CPU profile while
2262 * it exercises the change detector. Example:
2263 *
2264 * ```
2265 * ng.profiler.timeChangeDetection({record: true})
2266 * ```
2267 */
2268 AngularProfiler.prototype.timeChangeDetection = function (config) {
2269 var record = config && config['record'];
2270 var profileName = 'Change Detection';
2271 // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
2272 var isProfilerAvailable = win.console.profile != null;
2273 if (record && isProfilerAvailable) {
2274 win.console.profile(profileName);
2275 }
2276 var start = getDOM().performanceNow();
2277 var numTicks = 0;
2278 while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
2279 this.appRef.tick();
2280 numTicks++;
2281 }
2282 var end = getDOM().performanceNow();
2283 if (record && isProfilerAvailable) {
2284 win.console.profileEnd(profileName);
2285 }
2286 var msPerTick = (end - start) / numTicks;
2287 win.console.log("ran " + numTicks + " change detection cycles");
2288 win.console.log(msPerTick.toFixed(2) + " ms per check");
2289 return new ChangeDetectionPerfRecord(msPerTick, numTicks);
2290 };
2291 return AngularProfiler;
2292}());
2293
2294/**
2295 * @license
2296 * Copyright Google Inc. All Rights Reserved.
2297 *
2298 * Use of this source code is governed by an MIT-style license that can be
2299 * found in the LICENSE file at https://angular.io/license
2300 */
2301var PROFILER_GLOBAL_NAME = 'profiler';
2302/**
2303 * Enabled Angular debug tools that are accessible via your browser's
2304 * developer console.
2305 *
2306 * Usage:
2307 *
2308 * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
2309 * 1. Type `ng.` (usually the console will show auto-complete suggestion)
2310 * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
2311 * then hit Enter.
2312 *
2313 * @publicApi
2314 */
2315function enableDebugTools(ref) {
2316 exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
2317 return ref;
2318}
2319/**
2320 * Disables Angular tools.
2321 *
2322 * @publicApi
2323 */
2324function disableDebugTools() {
2325 exportNgVar(PROFILER_GLOBAL_NAME, null);
2326}
2327
2328/**
2329 * @license
2330 * Copyright Google Inc. All Rights Reserved.
2331 *
2332 * Use of this source code is governed by an MIT-style license that can be
2333 * found in the LICENSE file at https://angular.io/license
2334 */
2335function escapeHtml(text) {
2336 var escapedText = {
2337 '&': '&a;',
2338 '"': '&q;',
2339 '\'': '&s;',
2340 '<': '&l;',
2341 '>': '&g;',
2342 };
2343 return text.replace(/[&"'<>]/g, function (s) { return escapedText[s]; });
2344}
2345function unescapeHtml(text) {
2346 var unescapedText = {
2347 '&a;': '&',
2348 '&q;': '"',
2349 '&s;': '\'',
2350 '&l;': '<',
2351 '&g;': '>',
2352 };
2353 return text.replace(/&[^;]+;/g, function (s) { return unescapedText[s]; });
2354}
2355/**
2356 * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
2357 *
2358 * Example:
2359 *
2360 * ```
2361 * const COUNTER_KEY = makeStateKey<number>('counter');
2362 * let value = 10;
2363 *
2364 * transferState.set(COUNTER_KEY, value);
2365 * ```
2366 *
2367 * @publicApi
2368 */
2369function makeStateKey(key) {
2370 return key;
2371}
2372/**
2373 * A key value store that is transferred from the application on the server side to the application
2374 * on the client side.
2375 *
2376 * `TransferState` will be available as an injectable token. To use it import
2377 * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
2378 *
2379 * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
2380 * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
2381 * non-lossy manner.
2382 *
2383 * @publicApi
2384 */
2385var TransferState = /** @class */ (function () {
2386 function TransferState() {
2387 this.store = {};
2388 this.onSerializeCallbacks = {};
2389 }
2390 TransferState_1 = TransferState;
2391 /** @internal */
2392 TransferState.init = function (initState) {
2393 var transferState = new TransferState_1();
2394 transferState.store = initState;
2395 return transferState;
2396 };
2397 /**
2398 * Get the value corresponding to a key. Return `defaultValue` if key is not found.
2399 */
2400 TransferState.prototype.get = function (key, defaultValue) {
2401 return this.store[key] !== undefined ? this.store[key] : defaultValue;
2402 };
2403 /**
2404 * Set the value corresponding to a key.
2405 */
2406 TransferState.prototype.set = function (key, value) { this.store[key] = value; };
2407 /**
2408 * Remove a key from the store.
2409 */
2410 TransferState.prototype.remove = function (key) { delete this.store[key]; };
2411 /**
2412 * Test whether a key exists in the store.
2413 */
2414 TransferState.prototype.hasKey = function (key) { return this.store.hasOwnProperty(key); };
2415 /**
2416 * Register a callback to provide the value for a key when `toJson` is called.
2417 */
2418 TransferState.prototype.onSerialize = function (key, callback) {
2419 this.onSerializeCallbacks[key] = callback;
2420 };
2421 /**
2422 * Serialize the current state of the store to JSON.
2423 */
2424 TransferState.prototype.toJson = function () {
2425 // Call the onSerialize callbacks and put those values into the store.
2426 for (var key in this.onSerializeCallbacks) {
2427 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
2428 try {
2429 this.store[key] = this.onSerializeCallbacks[key]();
2430 }
2431 catch (e) {
2432 console.warn('Exception in onSerialize callback: ', e);
2433 }
2434 }
2435 }
2436 return JSON.stringify(this.store);
2437 };
2438 var TransferState_1;
2439 TransferState = TransferState_1 = __decorate([
2440 Injectable()
2441 ], TransferState);
2442 return TransferState;
2443}());
2444function initTransferState(doc, appId) {
2445 // Locate the script tag with the JSON data transferred from the server.
2446 // The id of the script tag is set to the Angular appId + 'state'.
2447 var script = doc.getElementById(appId + '-state');
2448 var initialState = {};
2449 if (script && script.textContent) {
2450 try {
2451 initialState = JSON.parse(unescapeHtml(script.textContent));
2452 }
2453 catch (e) {
2454 console.warn('Exception while restoring TransferState for app ' + appId, e);
2455 }
2456 }
2457 return TransferState.init(initialState);
2458}
2459/**
2460 * NgModule to install on the client side while using the `TransferState` to transfer state from
2461 * server to client.
2462 *
2463 * @publicApi
2464 */
2465var BrowserTransferStateModule = /** @class */ (function () {
2466 function BrowserTransferStateModule() {
2467 }
2468 BrowserTransferStateModule = __decorate([
2469 NgModule({
2470 providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
2471 })
2472 ], BrowserTransferStateModule);
2473 return BrowserTransferStateModule;
2474}());
2475
2476/**
2477 * @license
2478 * Copyright Google Inc. All Rights Reserved.
2479 *
2480 * Use of this source code is governed by an MIT-style license that can be
2481 * found in the LICENSE file at https://angular.io/license
2482 */
2483/**
2484 * Predicates for use with {@link DebugElement}'s query functions.
2485 *
2486 * @publicApi
2487 */
2488var By = /** @class */ (function () {
2489 function By() {
2490 }
2491 /**
2492 * Match all nodes.
2493 *
2494 * @usageNotes
2495 * ### Example
2496 *
2497 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
2498 */
2499 By.all = function () { return function () { return true; }; };
2500 /**
2501 * Match elements by the given CSS selector.
2502 *
2503 * @usageNotes
2504 * ### Example
2505 *
2506 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
2507 */
2508 By.css = function (selector) {
2509 return function (debugElement) {
2510 return debugElement.nativeElement != null ?
2511 getDOM().elementMatches(debugElement.nativeElement, selector) :
2512 false;
2513 };
2514 };
2515 /**
2516 * Match nodes that have the given directive present.
2517 *
2518 * @usageNotes
2519 * ### Example
2520 *
2521 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
2522 */
2523 By.directive = function (type) {
2524 return function (debugNode) { return debugNode.providerTokens.indexOf(type) !== -1; };
2525 };
2526 return By;
2527}());
2528
2529/**
2530 * @license
2531 * Copyright Google Inc. All Rights Reserved.
2532 *
2533 * Use of this source code is governed by an MIT-style license that can be
2534 * found in the LICENSE file at https://angular.io/license
2535 */
2536
2537/**
2538 * @license
2539 * Copyright Google Inc. All Rights Reserved.
2540 *
2541 * Use of this source code is governed by an MIT-style license that can be
2542 * found in the LICENSE file at https://angular.io/license
2543 */
2544/**
2545 * @publicApi
2546 */
2547var VERSION = new Version('8.2.12');
2548
2549/**
2550 * @license
2551 * Copyright Google Inc. All Rights Reserved.
2552 *
2553 * Use of this source code is governed by an MIT-style license that can be
2554 * found in the LICENSE file at https://angular.io/license
2555 */
2556
2557/**
2558 * @license
2559 * Copyright Google Inc. All Rights Reserved.
2560 *
2561 * Use of this source code is governed by an MIT-style license that can be
2562 * found in the LICENSE file at https://angular.io/license
2563 */
2564// This file only reexports content of the `src` folder. Keep it that way.
2565
2566/**
2567 * @license
2568 * Copyright Google Inc. All Rights Reserved.
2569 *
2570 * Use of this source code is governed by an MIT-style license that can be
2571 * found in the LICENSE file at https://angular.io/license
2572 */
2573
2574/**
2575 * Generated bundle index. Do not edit.
2576 */
2577
2578export { 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 };
2579//# sourceMappingURL=platform-browser.js.map