UNPKG

262 kBJavaScriptView Raw
1/**
2 * @license Angular v8.0.2
3 * (c) 2010-2019 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7(function (global, factory) {
8 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/platform-browser')) :
9 typeof define === 'function' && define.amd ? define('@angular/router', ['exports', '@angular/common', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/platform-browser'], factory) :
10 (global = global || self, factory((global.ng = global.ng || {}, global.ng.router = {}), global.ng.common, global.ng.core, global.rxjs, global.rxjs.operators, global.ng.platformBrowser));
11}(this, function (exports, common, core, rxjs, operators, platformBrowser) { 'use strict';
12
13 /*! *****************************************************************************
14 Copyright (c) Microsoft Corporation. All rights reserved.
15 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16 this file except in compliance with the License. You may obtain a copy of the
17 License at http://www.apache.org/licenses/LICENSE-2.0
18
19 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
21 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
22 MERCHANTABLITY OR NON-INFRINGEMENT.
23
24 See the Apache Version 2.0 License for specific language governing permissions
25 and limitations under the License.
26 ***************************************************************************** */
27 /* global Reflect, Promise */
28
29 var extendStatics = function(d, b) {
30 extendStatics = Object.setPrototypeOf ||
31 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33 return extendStatics(d, b);
34 };
35
36 function __extends(d, b) {
37 extendStatics(d, b);
38 function __() { this.constructor = d; }
39 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40 }
41
42 var __assign = function() {
43 __assign = Object.assign || function __assign(t) {
44 for (var s, i = 1, n = arguments.length; i < n; i++) {
45 s = arguments[i];
46 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47 }
48 return t;
49 };
50 return __assign.apply(this, arguments);
51 };
52
53 function __decorate(decorators, target, key, desc) {
54 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
55 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
56 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
57 return c > 3 && r && Object.defineProperty(target, key, r), r;
58 }
59
60 function __param(paramIndex, decorator) {
61 return function (target, key) { decorator(target, key, paramIndex); }
62 }
63
64 function __metadata(metadataKey, metadataValue) {
65 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
66 }
67
68 function __values(o) {
69 var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
70 if (m) return m.call(o);
71 return {
72 next: function () {
73 if (o && i >= o.length) o = void 0;
74 return { value: o && o[i++], done: !o };
75 }
76 };
77 }
78
79 function __read(o, n) {
80 var m = typeof Symbol === "function" && o[Symbol.iterator];
81 if (!m) return o;
82 var i = m.call(o), r, ar = [], e;
83 try {
84 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
85 }
86 catch (error) { e = { error: error }; }
87 finally {
88 try {
89 if (r && !r.done && (m = i["return"])) m.call(i);
90 }
91 finally { if (e) throw e.error; }
92 }
93 return ar;
94 }
95
96 function __spread() {
97 for (var ar = [], i = 0; i < arguments.length; i++)
98 ar = ar.concat(__read(arguments[i]));
99 return ar;
100 }
101
102 /**
103 * @license
104 * Copyright Google Inc. All Rights Reserved.
105 *
106 * Use of this source code is governed by an MIT-style license that can be
107 * found in the LICENSE file at https://angular.io/license
108 */
109 /**
110 * @description
111 *
112 * Base for events the Router goes through, as opposed to events tied to a specific
113 * Route. `RouterEvent`s will only be fired one time for any given navigation.
114 *
115 * Example:
116 *
117 * ```
118 * class MyService {
119 * constructor(public router: Router, logger: Logger) {
120 * router.events.pipe(
121 * filter(e => e instanceof RouterEvent)
122 * ).subscribe(e => {
123 * logger.log(e.id, e.url);
124 * });
125 * }
126 * }
127 * ```
128 *
129 * @publicApi
130 */
131 var RouterEvent = /** @class */ (function () {
132 function RouterEvent(
133 /** @docsNotRequired */
134 id,
135 /** @docsNotRequired */
136 url) {
137 this.id = id;
138 this.url = url;
139 }
140 return RouterEvent;
141 }());
142 /**
143 * @description
144 *
145 * Represents an event triggered when a navigation starts.
146 *
147 * @publicApi
148 */
149 var NavigationStart = /** @class */ (function (_super) {
150 __extends(NavigationStart, _super);
151 function NavigationStart(
152 /** @docsNotRequired */
153 id,
154 /** @docsNotRequired */
155 url,
156 /** @docsNotRequired */
157 navigationTrigger,
158 /** @docsNotRequired */
159 restoredState) {
160 if (navigationTrigger === void 0) { navigationTrigger = 'imperative'; }
161 if (restoredState === void 0) { restoredState = null; }
162 var _this = _super.call(this, id, url) || this;
163 _this.navigationTrigger = navigationTrigger;
164 _this.restoredState = restoredState;
165 return _this;
166 }
167 /** @docsNotRequired */
168 NavigationStart.prototype.toString = function () { return "NavigationStart(id: " + this.id + ", url: '" + this.url + "')"; };
169 return NavigationStart;
170 }(RouterEvent));
171 /**
172 * @description
173 *
174 * Represents an event triggered when a navigation ends successfully.
175 *
176 * @publicApi
177 */
178 var NavigationEnd = /** @class */ (function (_super) {
179 __extends(NavigationEnd, _super);
180 function NavigationEnd(
181 /** @docsNotRequired */
182 id,
183 /** @docsNotRequired */
184 url,
185 /** @docsNotRequired */
186 urlAfterRedirects) {
187 var _this = _super.call(this, id, url) || this;
188 _this.urlAfterRedirects = urlAfterRedirects;
189 return _this;
190 }
191 /** @docsNotRequired */
192 NavigationEnd.prototype.toString = function () {
193 return "NavigationEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "')";
194 };
195 return NavigationEnd;
196 }(RouterEvent));
197 /**
198 * @description
199 *
200 * Represents an event triggered when a navigation is canceled.
201 *
202 * @publicApi
203 */
204 var NavigationCancel = /** @class */ (function (_super) {
205 __extends(NavigationCancel, _super);
206 function NavigationCancel(
207 /** @docsNotRequired */
208 id,
209 /** @docsNotRequired */
210 url,
211 /** @docsNotRequired */
212 reason) {
213 var _this = _super.call(this, id, url) || this;
214 _this.reason = reason;
215 return _this;
216 }
217 /** @docsNotRequired */
218 NavigationCancel.prototype.toString = function () { return "NavigationCancel(id: " + this.id + ", url: '" + this.url + "')"; };
219 return NavigationCancel;
220 }(RouterEvent));
221 /**
222 * @description
223 *
224 * Represents an event triggered when a navigation fails due to an unexpected error.
225 *
226 * @publicApi
227 */
228 var NavigationError = /** @class */ (function (_super) {
229 __extends(NavigationError, _super);
230 function NavigationError(
231 /** @docsNotRequired */
232 id,
233 /** @docsNotRequired */
234 url,
235 /** @docsNotRequired */
236 error) {
237 var _this = _super.call(this, id, url) || this;
238 _this.error = error;
239 return _this;
240 }
241 /** @docsNotRequired */
242 NavigationError.prototype.toString = function () {
243 return "NavigationError(id: " + this.id + ", url: '" + this.url + "', error: " + this.error + ")";
244 };
245 return NavigationError;
246 }(RouterEvent));
247 /**
248 * @description
249 *
250 * Represents an event triggered when routes are recognized.
251 *
252 * @publicApi
253 */
254 var RoutesRecognized = /** @class */ (function (_super) {
255 __extends(RoutesRecognized, _super);
256 function RoutesRecognized(
257 /** @docsNotRequired */
258 id,
259 /** @docsNotRequired */
260 url,
261 /** @docsNotRequired */
262 urlAfterRedirects,
263 /** @docsNotRequired */
264 state) {
265 var _this = _super.call(this, id, url) || this;
266 _this.urlAfterRedirects = urlAfterRedirects;
267 _this.state = state;
268 return _this;
269 }
270 /** @docsNotRequired */
271 RoutesRecognized.prototype.toString = function () {
272 return "RoutesRecognized(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
273 };
274 return RoutesRecognized;
275 }(RouterEvent));
276 /**
277 * @description
278 *
279 * Represents the start of the Guard phase of routing.
280 *
281 * @publicApi
282 */
283 var GuardsCheckStart = /** @class */ (function (_super) {
284 __extends(GuardsCheckStart, _super);
285 function GuardsCheckStart(
286 /** @docsNotRequired */
287 id,
288 /** @docsNotRequired */
289 url,
290 /** @docsNotRequired */
291 urlAfterRedirects,
292 /** @docsNotRequired */
293 state) {
294 var _this = _super.call(this, id, url) || this;
295 _this.urlAfterRedirects = urlAfterRedirects;
296 _this.state = state;
297 return _this;
298 }
299 GuardsCheckStart.prototype.toString = function () {
300 return "GuardsCheckStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
301 };
302 return GuardsCheckStart;
303 }(RouterEvent));
304 /**
305 * @description
306 *
307 * Represents the end of the Guard phase of routing.
308 *
309 * @publicApi
310 */
311 var GuardsCheckEnd = /** @class */ (function (_super) {
312 __extends(GuardsCheckEnd, _super);
313 function GuardsCheckEnd(
314 /** @docsNotRequired */
315 id,
316 /** @docsNotRequired */
317 url,
318 /** @docsNotRequired */
319 urlAfterRedirects,
320 /** @docsNotRequired */
321 state,
322 /** @docsNotRequired */
323 shouldActivate) {
324 var _this = _super.call(this, id, url) || this;
325 _this.urlAfterRedirects = urlAfterRedirects;
326 _this.state = state;
327 _this.shouldActivate = shouldActivate;
328 return _this;
329 }
330 GuardsCheckEnd.prototype.toString = function () {
331 return "GuardsCheckEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ", shouldActivate: " + this.shouldActivate + ")";
332 };
333 return GuardsCheckEnd;
334 }(RouterEvent));
335 /**
336 * @description
337 *
338 * Represents the start of the Resolve phase of routing. The timing of this
339 * event may change, thus it's experimental. In the current iteration it will run
340 * in the "resolve" phase whether there's things to resolve or not. In the future this
341 * behavior may change to only run when there are things to be resolved.
342 *
343 * @publicApi
344 */
345 var ResolveStart = /** @class */ (function (_super) {
346 __extends(ResolveStart, _super);
347 function ResolveStart(
348 /** @docsNotRequired */
349 id,
350 /** @docsNotRequired */
351 url,
352 /** @docsNotRequired */
353 urlAfterRedirects,
354 /** @docsNotRequired */
355 state) {
356 var _this = _super.call(this, id, url) || this;
357 _this.urlAfterRedirects = urlAfterRedirects;
358 _this.state = state;
359 return _this;
360 }
361 ResolveStart.prototype.toString = function () {
362 return "ResolveStart(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
363 };
364 return ResolveStart;
365 }(RouterEvent));
366 /**
367 * @description
368 *
369 * Represents the end of the Resolve phase of routing. See note on
370 * `ResolveStart` for use of this experimental API.
371 *
372 * @publicApi
373 */
374 var ResolveEnd = /** @class */ (function (_super) {
375 __extends(ResolveEnd, _super);
376 function ResolveEnd(
377 /** @docsNotRequired */
378 id,
379 /** @docsNotRequired */
380 url,
381 /** @docsNotRequired */
382 urlAfterRedirects,
383 /** @docsNotRequired */
384 state) {
385 var _this = _super.call(this, id, url) || this;
386 _this.urlAfterRedirects = urlAfterRedirects;
387 _this.state = state;
388 return _this;
389 }
390 ResolveEnd.prototype.toString = function () {
391 return "ResolveEnd(id: " + this.id + ", url: '" + this.url + "', urlAfterRedirects: '" + this.urlAfterRedirects + "', state: " + this.state + ")";
392 };
393 return ResolveEnd;
394 }(RouterEvent));
395 /**
396 * @description
397 *
398 * Represents an event triggered before lazy loading a route config.
399 *
400 * @publicApi
401 */
402 var RouteConfigLoadStart = /** @class */ (function () {
403 function RouteConfigLoadStart(
404 /** @docsNotRequired */
405 route) {
406 this.route = route;
407 }
408 RouteConfigLoadStart.prototype.toString = function () { return "RouteConfigLoadStart(path: " + this.route.path + ")"; };
409 return RouteConfigLoadStart;
410 }());
411 /**
412 * @description
413 *
414 * Represents an event triggered when a route has been lazy loaded.
415 *
416 * @publicApi
417 */
418 var RouteConfigLoadEnd = /** @class */ (function () {
419 function RouteConfigLoadEnd(
420 /** @docsNotRequired */
421 route) {
422 this.route = route;
423 }
424 RouteConfigLoadEnd.prototype.toString = function () { return "RouteConfigLoadEnd(path: " + this.route.path + ")"; };
425 return RouteConfigLoadEnd;
426 }());
427 /**
428 * @description
429 *
430 * Represents the start of end of the Resolve phase of routing. See note on
431 * `ChildActivationEnd` for use of this experimental API.
432 *
433 * @publicApi
434 */
435 var ChildActivationStart = /** @class */ (function () {
436 function ChildActivationStart(
437 /** @docsNotRequired */
438 snapshot) {
439 this.snapshot = snapshot;
440 }
441 ChildActivationStart.prototype.toString = function () {
442 var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
443 return "ChildActivationStart(path: '" + path + "')";
444 };
445 return ChildActivationStart;
446 }());
447 /**
448 * @description
449 *
450 * Represents the start of end of the Resolve phase of routing. See note on
451 * `ChildActivationStart` for use of this experimental API.
452 *
453 * @publicApi
454 */
455 var ChildActivationEnd = /** @class */ (function () {
456 function ChildActivationEnd(
457 /** @docsNotRequired */
458 snapshot) {
459 this.snapshot = snapshot;
460 }
461 ChildActivationEnd.prototype.toString = function () {
462 var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
463 return "ChildActivationEnd(path: '" + path + "')";
464 };
465 return ChildActivationEnd;
466 }());
467 /**
468 * @description
469 *
470 * Represents the start of end of the Resolve phase of routing. See note on
471 * `ActivationEnd` for use of this experimental API.
472 *
473 * @publicApi
474 */
475 var ActivationStart = /** @class */ (function () {
476 function ActivationStart(
477 /** @docsNotRequired */
478 snapshot) {
479 this.snapshot = snapshot;
480 }
481 ActivationStart.prototype.toString = function () {
482 var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
483 return "ActivationStart(path: '" + path + "')";
484 };
485 return ActivationStart;
486 }());
487 /**
488 * @description
489 *
490 * Represents the start of end of the Resolve phase of routing. See note on
491 * `ActivationStart` for use of this experimental API.
492 *
493 * @publicApi
494 */
495 var ActivationEnd = /** @class */ (function () {
496 function ActivationEnd(
497 /** @docsNotRequired */
498 snapshot) {
499 this.snapshot = snapshot;
500 }
501 ActivationEnd.prototype.toString = function () {
502 var path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
503 return "ActivationEnd(path: '" + path + "')";
504 };
505 return ActivationEnd;
506 }());
507 /**
508 * @description
509 *
510 * Represents a scrolling event.
511 *
512 * @publicApi
513 */
514 var Scroll = /** @class */ (function () {
515 function Scroll(
516 /** @docsNotRequired */
517 routerEvent,
518 /** @docsNotRequired */
519 position,
520 /** @docsNotRequired */
521 anchor) {
522 this.routerEvent = routerEvent;
523 this.position = position;
524 this.anchor = anchor;
525 }
526 Scroll.prototype.toString = function () {
527 var pos = this.position ? this.position[0] + ", " + this.position[1] : null;
528 return "Scroll(anchor: '" + this.anchor + "', position: '" + pos + "')";
529 };
530 return Scroll;
531 }());
532
533 /**
534 * @license
535 * Copyright Google Inc. All Rights Reserved.
536 *
537 * Use of this source code is governed by an MIT-style license that can be
538 * found in the LICENSE file at https://angular.io/license
539 */
540 /**
541 * This component is used internally within the router to be a placeholder when an empty
542 * router-outlet is needed. For example, with a config such as:
543 *
544 * `{path: 'parent', outlet: 'nav', children: [...]}`
545 *
546 * In order to render, there needs to be a component on this config, which will default
547 * to this `EmptyOutletComponent`.
548 */
549 var ɵEmptyOutletComponent = /** @class */ (function () {
550 function ɵEmptyOutletComponent() {
551 }
552 ɵEmptyOutletComponent = __decorate([
553 core.Component({ template: "<router-outlet></router-outlet>" })
554 ], ɵEmptyOutletComponent);
555 return ɵEmptyOutletComponent;
556 }());
557
558 /**
559 * @license
560 * Copyright Google Inc. All Rights Reserved.
561 *
562 * Use of this source code is governed by an MIT-style license that can be
563 * found in the LICENSE file at https://angular.io/license
564 */
565 /**
566 * @description
567 *
568 * Name of the primary outlet.
569 *
570 * @publicApi
571 */
572 var PRIMARY_OUTLET = 'primary';
573 var ParamsAsMap = /** @class */ (function () {
574 function ParamsAsMap(params) {
575 this.params = params || {};
576 }
577 ParamsAsMap.prototype.has = function (name) { return this.params.hasOwnProperty(name); };
578 ParamsAsMap.prototype.get = function (name) {
579 if (this.has(name)) {
580 var v = this.params[name];
581 return Array.isArray(v) ? v[0] : v;
582 }
583 return null;
584 };
585 ParamsAsMap.prototype.getAll = function (name) {
586 if (this.has(name)) {
587 var v = this.params[name];
588 return Array.isArray(v) ? v : [v];
589 }
590 return [];
591 };
592 Object.defineProperty(ParamsAsMap.prototype, "keys", {
593 get: function () { return Object.keys(this.params); },
594 enumerable: true,
595 configurable: true
596 });
597 return ParamsAsMap;
598 }());
599 /**
600 * Convert a `Params` instance to a `ParamMap`.
601 *
602 * @publicApi
603 */
604 function convertToParamMap(params) {
605 return new ParamsAsMap(params);
606 }
607 var NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
608 function navigationCancelingError(message) {
609 var error = Error('NavigationCancelingError: ' + message);
610 error[NAVIGATION_CANCELING_ERROR] = true;
611 return error;
612 }
613 function isNavigationCancelingError(error) {
614 return error && error[NAVIGATION_CANCELING_ERROR];
615 }
616 // Matches the route configuration (`route`) against the actual URL (`segments`).
617 function defaultUrlMatcher(segments, segmentGroup, route) {
618 var parts = route.path.split('/');
619 if (parts.length > segments.length) {
620 // The actual URL is shorter than the config, no match
621 return null;
622 }
623 if (route.pathMatch === 'full' &&
624 (segmentGroup.hasChildren() || parts.length < segments.length)) {
625 // The config is longer than the actual URL but we are looking for a full match, return null
626 return null;
627 }
628 var posParams = {};
629 // Check each config part against the actual URL
630 for (var index = 0; index < parts.length; index++) {
631 var part = parts[index];
632 var segment = segments[index];
633 var isParameter = part.startsWith(':');
634 if (isParameter) {
635 posParams[part.substring(1)] = segment;
636 }
637 else if (part !== segment.path) {
638 // The actual URL part does not match the config, no match
639 return null;
640 }
641 }
642 return { consumed: segments.slice(0, parts.length), posParams: posParams };
643 }
644
645 /**
646 * @license
647 * Copyright Google Inc. All Rights Reserved.
648 *
649 * Use of this source code is governed by an MIT-style license that can be
650 * found in the LICENSE file at https://angular.io/license
651 */
652 var LoadedRouterConfig = /** @class */ (function () {
653 function LoadedRouterConfig(routes, module) {
654 this.routes = routes;
655 this.module = module;
656 }
657 return LoadedRouterConfig;
658 }());
659 function validateConfig(config, parentPath) {
660 if (parentPath === void 0) { parentPath = ''; }
661 // forEach doesn't iterate undefined values
662 for (var i = 0; i < config.length; i++) {
663 var route = config[i];
664 var fullPath = getFullPath(parentPath, route);
665 validateNode(route, fullPath);
666 }
667 }
668 function validateNode(route, fullPath) {
669 if (!route) {
670 throw new Error("\n Invalid configuration of route '" + fullPath + "': Encountered undefined route.\n The reason might be an extra comma.\n\n Example:\n const routes: Routes = [\n { path: '', redirectTo: '/dashboard', pathMatch: 'full' },\n { path: 'dashboard', component: DashboardComponent },, << two commas\n { path: 'detail/:id', component: HeroDetailComponent }\n ];\n ");
671 }
672 if (Array.isArray(route)) {
673 throw new Error("Invalid configuration of route '" + fullPath + "': Array cannot be specified");
674 }
675 if (!route.component && !route.children && !route.loadChildren &&
676 (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
677 throw new Error("Invalid configuration of route '" + fullPath + "': a componentless route without children or loadChildren cannot have a named outlet set");
678 }
679 if (route.redirectTo && route.children) {
680 throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and children cannot be used together");
681 }
682 if (route.redirectTo && route.loadChildren) {
683 throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and loadChildren cannot be used together");
684 }
685 if (route.children && route.loadChildren) {
686 throw new Error("Invalid configuration of route '" + fullPath + "': children and loadChildren cannot be used together");
687 }
688 if (route.redirectTo && route.component) {
689 throw new Error("Invalid configuration of route '" + fullPath + "': redirectTo and component cannot be used together");
690 }
691 if (route.path && route.matcher) {
692 throw new Error("Invalid configuration of route '" + fullPath + "': path and matcher cannot be used together");
693 }
694 if (route.redirectTo === void 0 && !route.component && !route.children && !route.loadChildren) {
695 throw new Error("Invalid configuration of route '" + fullPath + "'. One of the following must be provided: component, redirectTo, children or loadChildren");
696 }
697 if (route.path === void 0 && route.matcher === void 0) {
698 throw new Error("Invalid configuration of route '" + fullPath + "': routes must have either a path or a matcher specified");
699 }
700 if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
701 throw new Error("Invalid configuration of route '" + fullPath + "': path cannot start with a slash");
702 }
703 if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
704 var exp = "The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.";
705 throw new Error("Invalid configuration of route '{path: \"" + fullPath + "\", redirectTo: \"" + route.redirectTo + "\"}': please provide 'pathMatch'. " + exp);
706 }
707 if (route.pathMatch !== void 0 && route.pathMatch !== 'full' && route.pathMatch !== 'prefix') {
708 throw new Error("Invalid configuration of route '" + fullPath + "': pathMatch can only be set to 'prefix' or 'full'");
709 }
710 if (route.children) {
711 validateConfig(route.children, fullPath);
712 }
713 }
714 function getFullPath(parentPath, currentRoute) {
715 if (!currentRoute) {
716 return parentPath;
717 }
718 if (!parentPath && !currentRoute.path) {
719 return '';
720 }
721 else if (parentPath && !currentRoute.path) {
722 return parentPath + "/";
723 }
724 else if (!parentPath && currentRoute.path) {
725 return currentRoute.path;
726 }
727 else {
728 return parentPath + "/" + currentRoute.path;
729 }
730 }
731 /**
732 * Makes a copy of the config and adds any default required properties.
733 */
734 function standardizeConfig(r) {
735 var children = r.children && r.children.map(standardizeConfig);
736 var c = children ? __assign({}, r, { children: children }) : __assign({}, r);
737 if (!c.component && (children || c.loadChildren) && (c.outlet && c.outlet !== PRIMARY_OUTLET)) {
738 c.component = ɵEmptyOutletComponent;
739 }
740 return c;
741 }
742
743 /**
744 * @license
745 * Copyright Google Inc. All Rights Reserved.
746 *
747 * Use of this source code is governed by an MIT-style license that can be
748 * found in the LICENSE file at https://angular.io/license
749 */
750 function shallowEqualArrays(a, b) {
751 if (a.length !== b.length)
752 return false;
753 for (var i = 0; i < a.length; ++i) {
754 if (!shallowEqual(a[i], b[i]))
755 return false;
756 }
757 return true;
758 }
759 function shallowEqual(a, b) {
760 // Casting Object.keys return values to include `undefined` as there are some cases
761 // in IE 11 where this can happen. Cannot provide a test because the behavior only
762 // exists in certain circumstances in IE 11, therefore doing this cast ensures the
763 // logic is correct for when this edge case is hit.
764 var k1 = Object.keys(a);
765 var k2 = Object.keys(b);
766 if (!k1 || !k2 || k1.length != k2.length) {
767 return false;
768 }
769 var key;
770 for (var i = 0; i < k1.length; i++) {
771 key = k1[i];
772 if (a[key] !== b[key]) {
773 return false;
774 }
775 }
776 return true;
777 }
778 /**
779 * Flattens single-level nested arrays.
780 */
781 function flatten(arr) {
782 return Array.prototype.concat.apply([], arr);
783 }
784 /**
785 * Return the last element of an array.
786 */
787 function last(a) {
788 return a.length > 0 ? a[a.length - 1] : null;
789 }
790 function forEach(map, callback) {
791 for (var prop in map) {
792 if (map.hasOwnProperty(prop)) {
793 callback(map[prop], prop);
794 }
795 }
796 }
797 function waitForMap(obj, fn) {
798 if (Object.keys(obj).length === 0) {
799 return rxjs.of({});
800 }
801 var waitHead = [];
802 var waitTail = [];
803 var res = {};
804 forEach(obj, function (a, k) {
805 var mapped = fn(k, a).pipe(operators.map(function (r) { return res[k] = r; }));
806 if (k === PRIMARY_OUTLET) {
807 waitHead.push(mapped);
808 }
809 else {
810 waitTail.push(mapped);
811 }
812 });
813 // Closure compiler has problem with using spread operator here. So just using Array.concat.
814 return rxjs.of.apply(null, waitHead.concat(waitTail)).pipe(operators.concatAll(), operators.last(), operators.map(function () { return res; }));
815 }
816 function wrapIntoObservable(value) {
817 if (core.ɵisObservable(value)) {
818 return value;
819 }
820 if (core.ɵisPromise(value)) {
821 // Use `Promise.resolve()` to wrap promise-like instances.
822 // Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
823 // change detection.
824 return rxjs.from(Promise.resolve(value));
825 }
826 return rxjs.of(value);
827 }
828
829 /**
830 * @license
831 * Copyright Google Inc. All Rights Reserved.
832 *
833 * Use of this source code is governed by an MIT-style license that can be
834 * found in the LICENSE file at https://angular.io/license
835 */
836 function createEmptyUrlTree() {
837 return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
838 }
839 function containsTree(container, containee, exact) {
840 if (exact) {
841 return equalQueryParams(container.queryParams, containee.queryParams) &&
842 equalSegmentGroups(container.root, containee.root);
843 }
844 return containsQueryParams(container.queryParams, containee.queryParams) &&
845 containsSegmentGroup(container.root, containee.root);
846 }
847 function equalQueryParams(container, containee) {
848 // TODO: This does not handle array params correctly.
849 return shallowEqual(container, containee);
850 }
851 function equalSegmentGroups(container, containee) {
852 if (!equalPath(container.segments, containee.segments))
853 return false;
854 if (container.numberOfChildren !== containee.numberOfChildren)
855 return false;
856 for (var c in containee.children) {
857 if (!container.children[c])
858 return false;
859 if (!equalSegmentGroups(container.children[c], containee.children[c]))
860 return false;
861 }
862 return true;
863 }
864 function containsQueryParams(container, containee) {
865 // TODO: This does not handle array params correctly.
866 return Object.keys(containee).length <= Object.keys(container).length &&
867 Object.keys(containee).every(function (key) { return containee[key] === container[key]; });
868 }
869 function containsSegmentGroup(container, containee) {
870 return containsSegmentGroupHelper(container, containee, containee.segments);
871 }
872 function containsSegmentGroupHelper(container, containee, containeePaths) {
873 if (container.segments.length > containeePaths.length) {
874 var current = container.segments.slice(0, containeePaths.length);
875 if (!equalPath(current, containeePaths))
876 return false;
877 if (containee.hasChildren())
878 return false;
879 return true;
880 }
881 else if (container.segments.length === containeePaths.length) {
882 if (!equalPath(container.segments, containeePaths))
883 return false;
884 for (var c in containee.children) {
885 if (!container.children[c])
886 return false;
887 if (!containsSegmentGroup(container.children[c], containee.children[c]))
888 return false;
889 }
890 return true;
891 }
892 else {
893 var current = containeePaths.slice(0, container.segments.length);
894 var next = containeePaths.slice(container.segments.length);
895 if (!equalPath(container.segments, current))
896 return false;
897 if (!container.children[PRIMARY_OUTLET])
898 return false;
899 return containsSegmentGroupHelper(container.children[PRIMARY_OUTLET], containee, next);
900 }
901 }
902 /**
903 * @description
904 *
905 * Represents the parsed URL.
906 *
907 * Since a router state is a tree, and the URL is nothing but a serialized state, the URL is a
908 * serialized tree.
909 * UrlTree is a data structure that provides a lot of affordances in dealing with URLs
910 *
911 * @usageNotes
912 * ### Example
913 *
914 * ```
915 * @Component({templateUrl:'template.html'})
916 * class MyComponent {
917 * constructor(router: Router) {
918 * const tree: UrlTree =
919 * router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment');
920 * const f = tree.fragment; // return 'fragment'
921 * const q = tree.queryParams; // returns {debug: 'true'}
922 * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
923 * const s: UrlSegment[] = g.segments; // returns 2 segments 'team' and '33'
924 * g.children[PRIMARY_OUTLET].segments; // returns 2 segments 'user' and 'victor'
925 * g.children['support'].segments; // return 1 segment 'help'
926 * }
927 * }
928 * ```
929 *
930 * @publicApi
931 */
932 var UrlTree = /** @class */ (function () {
933 /** @internal */
934 function UrlTree(
935 /** The root segment group of the URL tree */
936 root,
937 /** The query params of the URL */
938 queryParams,
939 /** The fragment of the URL */
940 fragment) {
941 this.root = root;
942 this.queryParams = queryParams;
943 this.fragment = fragment;
944 }
945 Object.defineProperty(UrlTree.prototype, "queryParamMap", {
946 get: function () {
947 if (!this._queryParamMap) {
948 this._queryParamMap = convertToParamMap(this.queryParams);
949 }
950 return this._queryParamMap;
951 },
952 enumerable: true,
953 configurable: true
954 });
955 /** @docsNotRequired */
956 UrlTree.prototype.toString = function () { return DEFAULT_SERIALIZER.serialize(this); };
957 return UrlTree;
958 }());
959 /**
960 * @description
961 *
962 * Represents the parsed URL segment group.
963 *
964 * See `UrlTree` for more information.
965 *
966 * @publicApi
967 */
968 var UrlSegmentGroup = /** @class */ (function () {
969 function UrlSegmentGroup(
970 /** The URL segments of this group. See `UrlSegment` for more information */
971 segments,
972 /** The list of children of this group */
973 children) {
974 var _this = this;
975 this.segments = segments;
976 this.children = children;
977 /** The parent node in the url tree */
978 this.parent = null;
979 forEach(children, function (v, k) { return v.parent = _this; });
980 }
981 /** Whether the segment has child segments */
982 UrlSegmentGroup.prototype.hasChildren = function () { return this.numberOfChildren > 0; };
983 Object.defineProperty(UrlSegmentGroup.prototype, "numberOfChildren", {
984 /** Number of child segments */
985 get: function () { return Object.keys(this.children).length; },
986 enumerable: true,
987 configurable: true
988 });
989 /** @docsNotRequired */
990 UrlSegmentGroup.prototype.toString = function () { return serializePaths(this); };
991 return UrlSegmentGroup;
992 }());
993 /**
994 * @description
995 *
996 * Represents a single URL segment.
997 *
998 * A UrlSegment is a part of a URL between the two slashes. It contains a path and the matrix
999 * parameters associated with the segment.
1000 *
1001 * @usageNotes
1002 * ### Example
1003 *
1004 * ```
1005 * @Component({templateUrl:'template.html'})
1006 * class MyComponent {
1007 * constructor(router: Router) {
1008 * const tree: UrlTree = router.parseUrl('/team;id=33');
1009 * const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET];
1010 * const s: UrlSegment[] = g.segments;
1011 * s[0].path; // returns 'team'
1012 * s[0].parameters; // returns {id: 33}
1013 * }
1014 * }
1015 * ```
1016 *
1017 * @publicApi
1018 */
1019 var UrlSegment = /** @class */ (function () {
1020 function UrlSegment(
1021 /** The path part of a URL segment */
1022 path,
1023 /** The matrix parameters associated with a segment */
1024 parameters) {
1025 this.path = path;
1026 this.parameters = parameters;
1027 }
1028 Object.defineProperty(UrlSegment.prototype, "parameterMap", {
1029 get: function () {
1030 if (!this._parameterMap) {
1031 this._parameterMap = convertToParamMap(this.parameters);
1032 }
1033 return this._parameterMap;
1034 },
1035 enumerable: true,
1036 configurable: true
1037 });
1038 /** @docsNotRequired */
1039 UrlSegment.prototype.toString = function () { return serializePath(this); };
1040 return UrlSegment;
1041 }());
1042 function equalSegments(as, bs) {
1043 return equalPath(as, bs) && as.every(function (a, i) { return shallowEqual(a.parameters, bs[i].parameters); });
1044 }
1045 function equalPath(as, bs) {
1046 if (as.length !== bs.length)
1047 return false;
1048 return as.every(function (a, i) { return a.path === bs[i].path; });
1049 }
1050 function mapChildrenIntoArray(segment, fn) {
1051 var res = [];
1052 forEach(segment.children, function (child, childOutlet) {
1053 if (childOutlet === PRIMARY_OUTLET) {
1054 res = res.concat(fn(child, childOutlet));
1055 }
1056 });
1057 forEach(segment.children, function (child, childOutlet) {
1058 if (childOutlet !== PRIMARY_OUTLET) {
1059 res = res.concat(fn(child, childOutlet));
1060 }
1061 });
1062 return res;
1063 }
1064 /**
1065 * @description
1066 *
1067 * Serializes and deserializes a URL string into a URL tree.
1068 *
1069 * The url serialization strategy is customizable. You can
1070 * make all URLs case insensitive by providing a custom UrlSerializer.
1071 *
1072 * See `DefaultUrlSerializer` for an example of a URL serializer.
1073 *
1074 * @publicApi
1075 */
1076 var UrlSerializer = /** @class */ (function () {
1077 function UrlSerializer() {
1078 }
1079 return UrlSerializer;
1080 }());
1081 /**
1082 * @description
1083 *
1084 * A default implementation of the `UrlSerializer`.
1085 *
1086 * Example URLs:
1087 *
1088 * ```
1089 * /inbox/33(popup:compose)
1090 * /inbox/33;open=true/messages/44
1091 * ```
1092 *
1093 * DefaultUrlSerializer uses parentheses to serialize secondary segments (e.g., popup:compose), the
1094 * colon syntax to specify the outlet, and the ';parameter=value' syntax (e.g., open=true) to
1095 * specify route specific parameters.
1096 *
1097 * @publicApi
1098 */
1099 var DefaultUrlSerializer = /** @class */ (function () {
1100 function DefaultUrlSerializer() {
1101 }
1102 /** Parses a url into a `UrlTree` */
1103 DefaultUrlSerializer.prototype.parse = function (url) {
1104 var p = new UrlParser(url);
1105 return new UrlTree(p.parseRootSegment(), p.parseQueryParams(), p.parseFragment());
1106 };
1107 /** Converts a `UrlTree` into a url */
1108 DefaultUrlSerializer.prototype.serialize = function (tree) {
1109 var segment = "/" + serializeSegment(tree.root, true);
1110 var query = serializeQueryParams(tree.queryParams);
1111 var fragment = typeof tree.fragment === "string" ? "#" + encodeUriFragment(tree.fragment) : '';
1112 return "" + segment + query + fragment;
1113 };
1114 return DefaultUrlSerializer;
1115 }());
1116 var DEFAULT_SERIALIZER = new DefaultUrlSerializer();
1117 function serializePaths(segment) {
1118 return segment.segments.map(function (p) { return serializePath(p); }).join('/');
1119 }
1120 function serializeSegment(segment, root) {
1121 if (!segment.hasChildren()) {
1122 return serializePaths(segment);
1123 }
1124 if (root) {
1125 var primary = segment.children[PRIMARY_OUTLET] ?
1126 serializeSegment(segment.children[PRIMARY_OUTLET], false) :
1127 '';
1128 var children_1 = [];
1129 forEach(segment.children, function (v, k) {
1130 if (k !== PRIMARY_OUTLET) {
1131 children_1.push(k + ":" + serializeSegment(v, false));
1132 }
1133 });
1134 return children_1.length > 0 ? primary + "(" + children_1.join('//') + ")" : primary;
1135 }
1136 else {
1137 var children = mapChildrenIntoArray(segment, function (v, k) {
1138 if (k === PRIMARY_OUTLET) {
1139 return [serializeSegment(segment.children[PRIMARY_OUTLET], false)];
1140 }
1141 return [k + ":" + serializeSegment(v, false)];
1142 });
1143 return serializePaths(segment) + "/(" + children.join('//') + ")";
1144 }
1145 }
1146 /**
1147 * Encodes a URI string with the default encoding. This function will only ever be called from
1148 * `encodeUriQuery` or `encodeUriSegment` as it's the base set of encodings to be used. We need
1149 * a custom encoding because encodeURIComponent is too aggressive and encodes stuff that doesn't
1150 * have to be encoded per https://url.spec.whatwg.org.
1151 */
1152 function encodeUriString(s) {
1153 return encodeURIComponent(s)
1154 .replace(/%40/g, '@')
1155 .replace(/%3A/gi, ':')
1156 .replace(/%24/g, '$')
1157 .replace(/%2C/gi, ',');
1158 }
1159 /**
1160 * This function should be used to encode both keys and values in a query string key/value. In
1161 * the following URL, you need to call encodeUriQuery on "k" and "v":
1162 *
1163 * http://www.site.org/html;mk=mv?k=v#f
1164 */
1165 function encodeUriQuery(s) {
1166 return encodeUriString(s).replace(/%3B/gi, ';');
1167 }
1168 /**
1169 * This function should be used to encode a URL fragment. In the following URL, you need to call
1170 * encodeUriFragment on "f":
1171 *
1172 * http://www.site.org/html;mk=mv?k=v#f
1173 */
1174 function encodeUriFragment(s) {
1175 return encodeURI(s);
1176 }
1177 /**
1178 * This function should be run on any URI segment as well as the key and value in a key/value
1179 * pair for matrix params. In the following URL, you need to call encodeUriSegment on "html",
1180 * "mk", and "mv":
1181 *
1182 * http://www.site.org/html;mk=mv?k=v#f
1183 */
1184 function encodeUriSegment(s) {
1185 return encodeUriString(s).replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/%26/gi, '&');
1186 }
1187 function decode(s) {
1188 return decodeURIComponent(s);
1189 }
1190 // Query keys/values should have the "+" replaced first, as "+" in a query string is " ".
1191 // decodeURIComponent function will not decode "+" as a space.
1192 function decodeQuery(s) {
1193 return decode(s.replace(/\+/g, '%20'));
1194 }
1195 function serializePath(path) {
1196 return "" + encodeUriSegment(path.path) + serializeMatrixParams(path.parameters);
1197 }
1198 function serializeMatrixParams(params) {
1199 return Object.keys(params)
1200 .map(function (key) { return ";" + encodeUriSegment(key) + "=" + encodeUriSegment(params[key]); })
1201 .join('');
1202 }
1203 function serializeQueryParams(params) {
1204 var strParams = Object.keys(params).map(function (name) {
1205 var value = params[name];
1206 return Array.isArray(value) ?
1207 value.map(function (v) { return encodeUriQuery(name) + "=" + encodeUriQuery(v); }).join('&') :
1208 encodeUriQuery(name) + "=" + encodeUriQuery(value);
1209 });
1210 return strParams.length ? "?" + strParams.join("&") : '';
1211 }
1212 var SEGMENT_RE = /^[^\/()?;=#]+/;
1213 function matchSegments(str) {
1214 var match = str.match(SEGMENT_RE);
1215 return match ? match[0] : '';
1216 }
1217 var QUERY_PARAM_RE = /^[^=?&#]+/;
1218 // Return the name of the query param at the start of the string or an empty string
1219 function matchQueryParams(str) {
1220 var match = str.match(QUERY_PARAM_RE);
1221 return match ? match[0] : '';
1222 }
1223 var QUERY_PARAM_VALUE_RE = /^[^?&#]+/;
1224 // Return the value of the query param at the start of the string or an empty string
1225 function matchUrlQueryParamValue(str) {
1226 var match = str.match(QUERY_PARAM_VALUE_RE);
1227 return match ? match[0] : '';
1228 }
1229 var UrlParser = /** @class */ (function () {
1230 function UrlParser(url) {
1231 this.url = url;
1232 this.remaining = url;
1233 }
1234 UrlParser.prototype.parseRootSegment = function () {
1235 this.consumeOptional('/');
1236 if (this.remaining === '' || this.peekStartsWith('?') || this.peekStartsWith('#')) {
1237 return new UrlSegmentGroup([], {});
1238 }
1239 // The root segment group never has segments
1240 return new UrlSegmentGroup([], this.parseChildren());
1241 };
1242 UrlParser.prototype.parseQueryParams = function () {
1243 var params = {};
1244 if (this.consumeOptional('?')) {
1245 do {
1246 this.parseQueryParam(params);
1247 } while (this.consumeOptional('&'));
1248 }
1249 return params;
1250 };
1251 UrlParser.prototype.parseFragment = function () {
1252 return this.consumeOptional('#') ? decodeURIComponent(this.remaining) : null;
1253 };
1254 UrlParser.prototype.parseChildren = function () {
1255 if (this.remaining === '') {
1256 return {};
1257 }
1258 this.consumeOptional('/');
1259 var segments = [];
1260 if (!this.peekStartsWith('(')) {
1261 segments.push(this.parseSegment());
1262 }
1263 while (this.peekStartsWith('/') && !this.peekStartsWith('//') && !this.peekStartsWith('/(')) {
1264 this.capture('/');
1265 segments.push(this.parseSegment());
1266 }
1267 var children = {};
1268 if (this.peekStartsWith('/(')) {
1269 this.capture('/');
1270 children = this.parseParens(true);
1271 }
1272 var res = {};
1273 if (this.peekStartsWith('(')) {
1274 res = this.parseParens(false);
1275 }
1276 if (segments.length > 0 || Object.keys(children).length > 0) {
1277 res[PRIMARY_OUTLET] = new UrlSegmentGroup(segments, children);
1278 }
1279 return res;
1280 };
1281 // parse a segment with its matrix parameters
1282 // ie `name;k1=v1;k2`
1283 UrlParser.prototype.parseSegment = function () {
1284 var path = matchSegments(this.remaining);
1285 if (path === '' && this.peekStartsWith(';')) {
1286 throw new Error("Empty path url segment cannot have parameters: '" + this.remaining + "'.");
1287 }
1288 this.capture(path);
1289 return new UrlSegment(decode(path), this.parseMatrixParams());
1290 };
1291 UrlParser.prototype.parseMatrixParams = function () {
1292 var params = {};
1293 while (this.consumeOptional(';')) {
1294 this.parseParam(params);
1295 }
1296 return params;
1297 };
1298 UrlParser.prototype.parseParam = function (params) {
1299 var key = matchSegments(this.remaining);
1300 if (!key) {
1301 return;
1302 }
1303 this.capture(key);
1304 var value = '';
1305 if (this.consumeOptional('=')) {
1306 var valueMatch = matchSegments(this.remaining);
1307 if (valueMatch) {
1308 value = valueMatch;
1309 this.capture(value);
1310 }
1311 }
1312 params[decode(key)] = decode(value);
1313 };
1314 // Parse a single query parameter `name[=value]`
1315 UrlParser.prototype.parseQueryParam = function (params) {
1316 var key = matchQueryParams(this.remaining);
1317 if (!key) {
1318 return;
1319 }
1320 this.capture(key);
1321 var value = '';
1322 if (this.consumeOptional('=')) {
1323 var valueMatch = matchUrlQueryParamValue(this.remaining);
1324 if (valueMatch) {
1325 value = valueMatch;
1326 this.capture(value);
1327 }
1328 }
1329 var decodedKey = decodeQuery(key);
1330 var decodedVal = decodeQuery(value);
1331 if (params.hasOwnProperty(decodedKey)) {
1332 // Append to existing values
1333 var currentVal = params[decodedKey];
1334 if (!Array.isArray(currentVal)) {
1335 currentVal = [currentVal];
1336 params[decodedKey] = currentVal;
1337 }
1338 currentVal.push(decodedVal);
1339 }
1340 else {
1341 // Create a new value
1342 params[decodedKey] = decodedVal;
1343 }
1344 };
1345 // parse `(a/b//outlet_name:c/d)`
1346 UrlParser.prototype.parseParens = function (allowPrimary) {
1347 var segments = {};
1348 this.capture('(');
1349 while (!this.consumeOptional(')') && this.remaining.length > 0) {
1350 var path = matchSegments(this.remaining);
1351 var next = this.remaining[path.length];
1352 // if is is not one of these characters, then the segment was unescaped
1353 // or the group was not closed
1354 if (next !== '/' && next !== ')' && next !== ';') {
1355 throw new Error("Cannot parse url '" + this.url + "'");
1356 }
1357 var outletName = undefined;
1358 if (path.indexOf(':') > -1) {
1359 outletName = path.substr(0, path.indexOf(':'));
1360 this.capture(outletName);
1361 this.capture(':');
1362 }
1363 else if (allowPrimary) {
1364 outletName = PRIMARY_OUTLET;
1365 }
1366 var children = this.parseChildren();
1367 segments[outletName] = Object.keys(children).length === 1 ? children[PRIMARY_OUTLET] :
1368 new UrlSegmentGroup([], children);
1369 this.consumeOptional('//');
1370 }
1371 return segments;
1372 };
1373 UrlParser.prototype.peekStartsWith = function (str) { return this.remaining.startsWith(str); };
1374 // Consumes the prefix when it is present and returns whether it has been consumed
1375 UrlParser.prototype.consumeOptional = function (str) {
1376 if (this.peekStartsWith(str)) {
1377 this.remaining = this.remaining.substring(str.length);
1378 return true;
1379 }
1380 return false;
1381 };
1382 UrlParser.prototype.capture = function (str) {
1383 if (!this.consumeOptional(str)) {
1384 throw new Error("Expected \"" + str + "\".");
1385 }
1386 };
1387 return UrlParser;
1388 }());
1389
1390 /**
1391 * @license
1392 * Copyright Google Inc. All Rights Reserved.
1393 *
1394 * Use of this source code is governed by an MIT-style license that can be
1395 * found in the LICENSE file at https://angular.io/license
1396 */
1397 var Tree = /** @class */ (function () {
1398 function Tree(root) {
1399 this._root = root;
1400 }
1401 Object.defineProperty(Tree.prototype, "root", {
1402 get: function () { return this._root.value; },
1403 enumerable: true,
1404 configurable: true
1405 });
1406 /**
1407 * @internal
1408 */
1409 Tree.prototype.parent = function (t) {
1410 var p = this.pathFromRoot(t);
1411 return p.length > 1 ? p[p.length - 2] : null;
1412 };
1413 /**
1414 * @internal
1415 */
1416 Tree.prototype.children = function (t) {
1417 var n = findNode(t, this._root);
1418 return n ? n.children.map(function (t) { return t.value; }) : [];
1419 };
1420 /**
1421 * @internal
1422 */
1423 Tree.prototype.firstChild = function (t) {
1424 var n = findNode(t, this._root);
1425 return n && n.children.length > 0 ? n.children[0].value : null;
1426 };
1427 /**
1428 * @internal
1429 */
1430 Tree.prototype.siblings = function (t) {
1431 var p = findPath(t, this._root);
1432 if (p.length < 2)
1433 return [];
1434 var c = p[p.length - 2].children.map(function (c) { return c.value; });
1435 return c.filter(function (cc) { return cc !== t; });
1436 };
1437 /**
1438 * @internal
1439 */
1440 Tree.prototype.pathFromRoot = function (t) { return findPath(t, this._root).map(function (s) { return s.value; }); };
1441 return Tree;
1442 }());
1443 // DFS for the node matching the value
1444 function findNode(value, node) {
1445 var e_1, _a;
1446 if (value === node.value)
1447 return node;
1448 try {
1449 for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
1450 var child = _c.value;
1451 var node_1 = findNode(value, child);
1452 if (node_1)
1453 return node_1;
1454 }
1455 }
1456 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1457 finally {
1458 try {
1459 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1460 }
1461 finally { if (e_1) throw e_1.error; }
1462 }
1463 return null;
1464 }
1465 // Return the path to the node with the given value using DFS
1466 function findPath(value, node) {
1467 var e_2, _a;
1468 if (value === node.value)
1469 return [node];
1470 try {
1471 for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
1472 var child = _c.value;
1473 var path = findPath(value, child);
1474 if (path.length) {
1475 path.unshift(node);
1476 return path;
1477 }
1478 }
1479 }
1480 catch (e_2_1) { e_2 = { error: e_2_1 }; }
1481 finally {
1482 try {
1483 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1484 }
1485 finally { if (e_2) throw e_2.error; }
1486 }
1487 return [];
1488 }
1489 var TreeNode = /** @class */ (function () {
1490 function TreeNode(value, children) {
1491 this.value = value;
1492 this.children = children;
1493 }
1494 TreeNode.prototype.toString = function () { return "TreeNode(" + this.value + ")"; };
1495 return TreeNode;
1496 }());
1497 // Return the list of T indexed by outlet name
1498 function nodeChildrenAsMap(node) {
1499 var map = {};
1500 if (node) {
1501 node.children.forEach(function (child) { return map[child.value.outlet] = child; });
1502 }
1503 return map;
1504 }
1505
1506 /**
1507 * @license
1508 * Copyright Google Inc. All Rights Reserved.
1509 *
1510 * Use of this source code is governed by an MIT-style license that can be
1511 * found in the LICENSE file at https://angular.io/license
1512 */
1513 /**
1514 * @description
1515 *
1516 * Represents the state of the router.
1517 *
1518 * RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL
1519 * segments, the extracted parameters, and the resolved data.
1520 *
1521 * @usageNotes
1522 * ### Example
1523 *
1524 * ```
1525 * @Component({templateUrl:'template.html'})
1526 * class MyComponent {
1527 * constructor(router: Router) {
1528 * const state: RouterState = router.routerState;
1529 * const root: ActivatedRoute = state.root;
1530 * const child = root.firstChild;
1531 * const id: Observable<string> = child.params.map(p => p.id);
1532 * //...
1533 * }
1534 * }
1535 * ```
1536 *
1537 * See `ActivatedRoute` for more information.
1538 *
1539 * @publicApi
1540 */
1541 var RouterState = /** @class */ (function (_super) {
1542 __extends(RouterState, _super);
1543 /** @internal */
1544 function RouterState(root,
1545 /** The current snapshot of the router state */
1546 snapshot) {
1547 var _this = _super.call(this, root) || this;
1548 _this.snapshot = snapshot;
1549 setRouterState(_this, root);
1550 return _this;
1551 }
1552 RouterState.prototype.toString = function () { return this.snapshot.toString(); };
1553 return RouterState;
1554 }(Tree));
1555 function createEmptyState(urlTree, rootComponent) {
1556 var snapshot = createEmptyStateSnapshot(urlTree, rootComponent);
1557 var emptyUrl = new rxjs.BehaviorSubject([new UrlSegment('', {})]);
1558 var emptyParams = new rxjs.BehaviorSubject({});
1559 var emptyData = new rxjs.BehaviorSubject({});
1560 var emptyQueryParams = new rxjs.BehaviorSubject({});
1561 var fragment = new rxjs.BehaviorSubject('');
1562 var activated = new ActivatedRoute(emptyUrl, emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, snapshot.root);
1563 activated.snapshot = snapshot.root;
1564 return new RouterState(new TreeNode(activated, []), snapshot);
1565 }
1566 function createEmptyStateSnapshot(urlTree, rootComponent) {
1567 var emptyParams = {};
1568 var emptyData = {};
1569 var emptyQueryParams = {};
1570 var fragment = '';
1571 var activated = new ActivatedRouteSnapshot([], emptyParams, emptyQueryParams, fragment, emptyData, PRIMARY_OUTLET, rootComponent, null, urlTree.root, -1, {});
1572 return new RouterStateSnapshot('', new TreeNode(activated, []));
1573 }
1574 /**
1575 * @description
1576 *
1577 * Contains the information about a route associated with a component loaded in an
1578 * outlet. An `ActivatedRoute` can also be used to traverse the router state tree.
1579 *
1580 * {@example router/activated-route/module.ts region="activated-route"
1581 * header="activated-route.component.ts" linenums="false"}
1582 *
1583 * @publicApi
1584 */
1585 var ActivatedRoute = /** @class */ (function () {
1586 /** @internal */
1587 function ActivatedRoute(
1588 /** An observable of the URL segments matched by this route */
1589 url,
1590 /** An observable of the matrix parameters scoped to this route */
1591 params,
1592 /** An observable of the query parameters shared by all the routes */
1593 queryParams,
1594 /** An observable of the URL fragment shared by all the routes */
1595 fragment,
1596 /** An observable of the static and resolved data of this route. */
1597 data,
1598 /** The outlet name of the route. It's a constant */
1599 outlet,
1600 /** The component of the route. It's a constant */
1601 // TODO(vsavkin): remove |string
1602 component, futureSnapshot) {
1603 this.url = url;
1604 this.params = params;
1605 this.queryParams = queryParams;
1606 this.fragment = fragment;
1607 this.data = data;
1608 this.outlet = outlet;
1609 this.component = component;
1610 this._futureSnapshot = futureSnapshot;
1611 }
1612 Object.defineProperty(ActivatedRoute.prototype, "routeConfig", {
1613 /** The configuration used to match this route */
1614 get: function () { return this._futureSnapshot.routeConfig; },
1615 enumerable: true,
1616 configurable: true
1617 });
1618 Object.defineProperty(ActivatedRoute.prototype, "root", {
1619 /** The root of the router state */
1620 get: function () { return this._routerState.root; },
1621 enumerable: true,
1622 configurable: true
1623 });
1624 Object.defineProperty(ActivatedRoute.prototype, "parent", {
1625 /** The parent of this route in the router state tree */
1626 get: function () { return this._routerState.parent(this); },
1627 enumerable: true,
1628 configurable: true
1629 });
1630 Object.defineProperty(ActivatedRoute.prototype, "firstChild", {
1631 /** The first child of this route in the router state tree */
1632 get: function () { return this._routerState.firstChild(this); },
1633 enumerable: true,
1634 configurable: true
1635 });
1636 Object.defineProperty(ActivatedRoute.prototype, "children", {
1637 /** The children of this route in the router state tree */
1638 get: function () { return this._routerState.children(this); },
1639 enumerable: true,
1640 configurable: true
1641 });
1642 Object.defineProperty(ActivatedRoute.prototype, "pathFromRoot", {
1643 /** The path from the root of the router state tree to this route */
1644 get: function () { return this._routerState.pathFromRoot(this); },
1645 enumerable: true,
1646 configurable: true
1647 });
1648 Object.defineProperty(ActivatedRoute.prototype, "paramMap", {
1649 get: function () {
1650 if (!this._paramMap) {
1651 this._paramMap = this.params.pipe(operators.map(function (p) { return convertToParamMap(p); }));
1652 }
1653 return this._paramMap;
1654 },
1655 enumerable: true,
1656 configurable: true
1657 });
1658 Object.defineProperty(ActivatedRoute.prototype, "queryParamMap", {
1659 get: function () {
1660 if (!this._queryParamMap) {
1661 this._queryParamMap =
1662 this.queryParams.pipe(operators.map(function (p) { return convertToParamMap(p); }));
1663 }
1664 return this._queryParamMap;
1665 },
1666 enumerable: true,
1667 configurable: true
1668 });
1669 ActivatedRoute.prototype.toString = function () {
1670 return this.snapshot ? this.snapshot.toString() : "Future(" + this._futureSnapshot + ")";
1671 };
1672 return ActivatedRoute;
1673 }());
1674 /**
1675 * Returns the inherited params, data, and resolve for a given route.
1676 * By default, this only inherits values up to the nearest path-less or component-less route.
1677 * @internal
1678 */
1679 function inheritedParamsDataResolve(route, paramsInheritanceStrategy) {
1680 if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
1681 var pathFromRoot = route.pathFromRoot;
1682 var inheritingStartingFrom = 0;
1683 if (paramsInheritanceStrategy !== 'always') {
1684 inheritingStartingFrom = pathFromRoot.length - 1;
1685 while (inheritingStartingFrom >= 1) {
1686 var current = pathFromRoot[inheritingStartingFrom];
1687 var parent_1 = pathFromRoot[inheritingStartingFrom - 1];
1688 // current route is an empty path => inherits its parent's params and data
1689 if (current.routeConfig && current.routeConfig.path === '') {
1690 inheritingStartingFrom--;
1691 // parent is componentless => current route should inherit its params and data
1692 }
1693 else if (!parent_1.component) {
1694 inheritingStartingFrom--;
1695 }
1696 else {
1697 break;
1698 }
1699 }
1700 }
1701 return flattenInherited(pathFromRoot.slice(inheritingStartingFrom));
1702 }
1703 /** @internal */
1704 function flattenInherited(pathFromRoot) {
1705 return pathFromRoot.reduce(function (res, curr) {
1706 var params = __assign({}, res.params, curr.params);
1707 var data = __assign({}, res.data, curr.data);
1708 var resolve = __assign({}, res.resolve, curr._resolvedData);
1709 return { params: params, data: data, resolve: resolve };
1710 }, { params: {}, data: {}, resolve: {} });
1711 }
1712 /**
1713 * @description
1714 *
1715 * Contains the information about a route associated with a component loaded in an
1716 * outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to
1717 * traverse the router state tree.
1718 *
1719 * ```
1720 * @Component({templateUrl:'./my-component.html'})
1721 * class MyComponent {
1722 * constructor(route: ActivatedRoute) {
1723 * const id: string = route.snapshot.params.id;
1724 * const url: string = route.snapshot.url.join('');
1725 * const user = route.snapshot.data.user;
1726 * }
1727 * }
1728 * ```
1729 *
1730 * @publicApi
1731 */
1732 var ActivatedRouteSnapshot = /** @class */ (function () {
1733 /** @internal */
1734 function ActivatedRouteSnapshot(
1735 /** The URL segments matched by this route */
1736 url,
1737 /** The matrix parameters scoped to this route */
1738 params,
1739 /** The query parameters shared by all the routes */
1740 queryParams,
1741 /** The URL fragment shared by all the routes */
1742 fragment,
1743 /** The static and resolved data of this route */
1744 data,
1745 /** The outlet name of the route */
1746 outlet,
1747 /** The component of the route */
1748 component, routeConfig, urlSegment, lastPathIndex, resolve) {
1749 this.url = url;
1750 this.params = params;
1751 this.queryParams = queryParams;
1752 this.fragment = fragment;
1753 this.data = data;
1754 this.outlet = outlet;
1755 this.component = component;
1756 this.routeConfig = routeConfig;
1757 this._urlSegment = urlSegment;
1758 this._lastPathIndex = lastPathIndex;
1759 this._resolve = resolve;
1760 }
1761 Object.defineProperty(ActivatedRouteSnapshot.prototype, "root", {
1762 /** The root of the router state */
1763 get: function () { return this._routerState.root; },
1764 enumerable: true,
1765 configurable: true
1766 });
1767 Object.defineProperty(ActivatedRouteSnapshot.prototype, "parent", {
1768 /** The parent of this route in the router state tree */
1769 get: function () { return this._routerState.parent(this); },
1770 enumerable: true,
1771 configurable: true
1772 });
1773 Object.defineProperty(ActivatedRouteSnapshot.prototype, "firstChild", {
1774 /** The first child of this route in the router state tree */
1775 get: function () { return this._routerState.firstChild(this); },
1776 enumerable: true,
1777 configurable: true
1778 });
1779 Object.defineProperty(ActivatedRouteSnapshot.prototype, "children", {
1780 /** The children of this route in the router state tree */
1781 get: function () { return this._routerState.children(this); },
1782 enumerable: true,
1783 configurable: true
1784 });
1785 Object.defineProperty(ActivatedRouteSnapshot.prototype, "pathFromRoot", {
1786 /** The path from the root of the router state tree to this route */
1787 get: function () { return this._routerState.pathFromRoot(this); },
1788 enumerable: true,
1789 configurable: true
1790 });
1791 Object.defineProperty(ActivatedRouteSnapshot.prototype, "paramMap", {
1792 get: function () {
1793 if (!this._paramMap) {
1794 this._paramMap = convertToParamMap(this.params);
1795 }
1796 return this._paramMap;
1797 },
1798 enumerable: true,
1799 configurable: true
1800 });
1801 Object.defineProperty(ActivatedRouteSnapshot.prototype, "queryParamMap", {
1802 get: function () {
1803 if (!this._queryParamMap) {
1804 this._queryParamMap = convertToParamMap(this.queryParams);
1805 }
1806 return this._queryParamMap;
1807 },
1808 enumerable: true,
1809 configurable: true
1810 });
1811 ActivatedRouteSnapshot.prototype.toString = function () {
1812 var url = this.url.map(function (segment) { return segment.toString(); }).join('/');
1813 var matched = this.routeConfig ? this.routeConfig.path : '';
1814 return "Route(url:'" + url + "', path:'" + matched + "')";
1815 };
1816 return ActivatedRouteSnapshot;
1817 }());
1818 /**
1819 * @description
1820 *
1821 * Represents the state of the router at a moment in time.
1822 *
1823 * This is a tree of activated route snapshots. Every node in this tree knows about
1824 * the "consumed" URL segments, the extracted parameters, and the resolved data.
1825 *
1826 * @usageNotes
1827 * ### Example
1828 *
1829 * ```
1830 * @Component({templateUrl:'template.html'})
1831 * class MyComponent {
1832 * constructor(router: Router) {
1833 * const state: RouterState = router.routerState;
1834 * const snapshot: RouterStateSnapshot = state.snapshot;
1835 * const root: ActivatedRouteSnapshot = snapshot.root;
1836 * const child = root.firstChild;
1837 * const id: Observable<string> = child.params.map(p => p.id);
1838 * //...
1839 * }
1840 * }
1841 * ```
1842 *
1843 * @publicApi
1844 */
1845 var RouterStateSnapshot = /** @class */ (function (_super) {
1846 __extends(RouterStateSnapshot, _super);
1847 /** @internal */
1848 function RouterStateSnapshot(
1849 /** The url from which this snapshot was created */
1850 url, root) {
1851 var _this = _super.call(this, root) || this;
1852 _this.url = url;
1853 setRouterState(_this, root);
1854 return _this;
1855 }
1856 RouterStateSnapshot.prototype.toString = function () { return serializeNode(this._root); };
1857 return RouterStateSnapshot;
1858 }(Tree));
1859 function setRouterState(state, node) {
1860 node.value._routerState = state;
1861 node.children.forEach(function (c) { return setRouterState(state, c); });
1862 }
1863 function serializeNode(node) {
1864 var c = node.children.length > 0 ? " { " + node.children.map(serializeNode).join(', ') + " } " : '';
1865 return "" + node.value + c;
1866 }
1867 /**
1868 * The expectation is that the activate route is created with the right set of parameters.
1869 * So we push new values into the observables only when they are not the initial values.
1870 * And we detect that by checking if the snapshot field is set.
1871 */
1872 function advanceActivatedRoute(route) {
1873 if (route.snapshot) {
1874 var currentSnapshot = route.snapshot;
1875 var nextSnapshot = route._futureSnapshot;
1876 route.snapshot = nextSnapshot;
1877 if (!shallowEqual(currentSnapshot.queryParams, nextSnapshot.queryParams)) {
1878 route.queryParams.next(nextSnapshot.queryParams);
1879 }
1880 if (currentSnapshot.fragment !== nextSnapshot.fragment) {
1881 route.fragment.next(nextSnapshot.fragment);
1882 }
1883 if (!shallowEqual(currentSnapshot.params, nextSnapshot.params)) {
1884 route.params.next(nextSnapshot.params);
1885 }
1886 if (!shallowEqualArrays(currentSnapshot.url, nextSnapshot.url)) {
1887 route.url.next(nextSnapshot.url);
1888 }
1889 if (!shallowEqual(currentSnapshot.data, nextSnapshot.data)) {
1890 route.data.next(nextSnapshot.data);
1891 }
1892 }
1893 else {
1894 route.snapshot = route._futureSnapshot;
1895 // this is for resolved data
1896 route.data.next(route._futureSnapshot.data);
1897 }
1898 }
1899 function equalParamsAndUrlSegments(a, b) {
1900 var equalUrlParams = shallowEqual(a.params, b.params) && equalSegments(a.url, b.url);
1901 var parentsMismatch = !a.parent !== !b.parent;
1902 return equalUrlParams && !parentsMismatch &&
1903 (!a.parent || equalParamsAndUrlSegments(a.parent, b.parent));
1904 }
1905
1906 /**
1907 * @license
1908 * Copyright Google Inc. All Rights Reserved.
1909 *
1910 * Use of this source code is governed by an MIT-style license that can be
1911 * found in the LICENSE file at https://angular.io/license
1912 */
1913 function createRouterState(routeReuseStrategy, curr, prevState) {
1914 var root = createNode(routeReuseStrategy, curr._root, prevState ? prevState._root : undefined);
1915 return new RouterState(root, curr);
1916 }
1917 function createNode(routeReuseStrategy, curr, prevState) {
1918 // reuse an activated route that is currently displayed on the screen
1919 if (prevState && routeReuseStrategy.shouldReuseRoute(curr.value, prevState.value.snapshot)) {
1920 var value = prevState.value;
1921 value._futureSnapshot = curr.value;
1922 var children = createOrReuseChildren(routeReuseStrategy, curr, prevState);
1923 return new TreeNode(value, children);
1924 // retrieve an activated route that is used to be displayed, but is not currently displayed
1925 }
1926 else {
1927 var detachedRouteHandle = routeReuseStrategy.retrieve(curr.value);
1928 if (detachedRouteHandle) {
1929 var tree = detachedRouteHandle.route;
1930 setFutureSnapshotsOfActivatedRoutes(curr, tree);
1931 return tree;
1932 }
1933 else {
1934 var value = createActivatedRoute(curr.value);
1935 var children = curr.children.map(function (c) { return createNode(routeReuseStrategy, c); });
1936 return new TreeNode(value, children);
1937 }
1938 }
1939 }
1940 function setFutureSnapshotsOfActivatedRoutes(curr, result) {
1941 if (curr.value.routeConfig !== result.value.routeConfig) {
1942 throw new Error('Cannot reattach ActivatedRouteSnapshot created from a different route');
1943 }
1944 if (curr.children.length !== result.children.length) {
1945 throw new Error('Cannot reattach ActivatedRouteSnapshot with a different number of children');
1946 }
1947 result.value._futureSnapshot = curr.value;
1948 for (var i = 0; i < curr.children.length; ++i) {
1949 setFutureSnapshotsOfActivatedRoutes(curr.children[i], result.children[i]);
1950 }
1951 }
1952 function createOrReuseChildren(routeReuseStrategy, curr, prevState) {
1953 return curr.children.map(function (child) {
1954 var e_1, _a;
1955 try {
1956 for (var _b = __values(prevState.children), _c = _b.next(); !_c.done; _c = _b.next()) {
1957 var p = _c.value;
1958 if (routeReuseStrategy.shouldReuseRoute(p.value.snapshot, child.value)) {
1959 return createNode(routeReuseStrategy, child, p);
1960 }
1961 }
1962 }
1963 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1964 finally {
1965 try {
1966 if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1967 }
1968 finally { if (e_1) throw e_1.error; }
1969 }
1970 return createNode(routeReuseStrategy, child);
1971 });
1972 }
1973 function createActivatedRoute(c) {
1974 return new ActivatedRoute(new rxjs.BehaviorSubject(c.url), new rxjs.BehaviorSubject(c.params), new rxjs.BehaviorSubject(c.queryParams), new rxjs.BehaviorSubject(c.fragment), new rxjs.BehaviorSubject(c.data), c.outlet, c.component, c);
1975 }
1976
1977 /**
1978 * @license
1979 * Copyright Google Inc. All Rights Reserved.
1980 *
1981 * Use of this source code is governed by an MIT-style license that can be
1982 * found in the LICENSE file at https://angular.io/license
1983 */
1984 function createUrlTree(route, urlTree, commands, queryParams, fragment) {
1985 if (commands.length === 0) {
1986 return tree(urlTree.root, urlTree.root, urlTree, queryParams, fragment);
1987 }
1988 var nav = computeNavigation(commands);
1989 if (nav.toRoot()) {
1990 return tree(urlTree.root, new UrlSegmentGroup([], {}), urlTree, queryParams, fragment);
1991 }
1992 var startingPosition = findStartingPosition(nav, urlTree, route);
1993 var segmentGroup = startingPosition.processChildren ?
1994 updateSegmentGroupChildren(startingPosition.segmentGroup, startingPosition.index, nav.commands) :
1995 updateSegmentGroup(startingPosition.segmentGroup, startingPosition.index, nav.commands);
1996 return tree(startingPosition.segmentGroup, segmentGroup, urlTree, queryParams, fragment);
1997 }
1998 function isMatrixParams(command) {
1999 return typeof command === 'object' && command != null && !command.outlets && !command.segmentPath;
2000 }
2001 function tree(oldSegmentGroup, newSegmentGroup, urlTree, queryParams, fragment) {
2002 var qp = {};
2003 if (queryParams) {
2004 forEach(queryParams, function (value, name) {
2005 qp[name] = Array.isArray(value) ? value.map(function (v) { return "" + v; }) : "" + value;
2006 });
2007 }
2008 if (urlTree.root === oldSegmentGroup) {
2009 return new UrlTree(newSegmentGroup, qp, fragment);
2010 }
2011 return new UrlTree(replaceSegment(urlTree.root, oldSegmentGroup, newSegmentGroup), qp, fragment);
2012 }
2013 function replaceSegment(current, oldSegment, newSegment) {
2014 var children = {};
2015 forEach(current.children, function (c, outletName) {
2016 if (c === oldSegment) {
2017 children[outletName] = newSegment;
2018 }
2019 else {
2020 children[outletName] = replaceSegment(c, oldSegment, newSegment);
2021 }
2022 });
2023 return new UrlSegmentGroup(current.segments, children);
2024 }
2025 var Navigation = /** @class */ (function () {
2026 function Navigation(isAbsolute, numberOfDoubleDots, commands) {
2027 this.isAbsolute = isAbsolute;
2028 this.numberOfDoubleDots = numberOfDoubleDots;
2029 this.commands = commands;
2030 if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
2031 throw new Error('Root segment cannot have matrix parameters');
2032 }
2033 var cmdWithOutlet = commands.find(function (c) { return typeof c === 'object' && c != null && c.outlets; });
2034 if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
2035 throw new Error('{outlets:{}} has to be the last command');
2036 }
2037 }
2038 Navigation.prototype.toRoot = function () {
2039 return this.isAbsolute && this.commands.length === 1 && this.commands[0] == '/';
2040 };
2041 return Navigation;
2042 }());
2043 /** Transforms commands to a normalized `Navigation` */
2044 function computeNavigation(commands) {
2045 if ((typeof commands[0] === 'string') && commands.length === 1 && commands[0] === '/') {
2046 return new Navigation(true, 0, commands);
2047 }
2048 var numberOfDoubleDots = 0;
2049 var isAbsolute = false;
2050 var res = commands.reduce(function (res, cmd, cmdIdx) {
2051 if (typeof cmd === 'object' && cmd != null) {
2052 if (cmd.outlets) {
2053 var outlets_1 = {};
2054 forEach(cmd.outlets, function (commands, name) {
2055 outlets_1[name] = typeof commands === 'string' ? commands.split('/') : commands;
2056 });
2057 return __spread(res, [{ outlets: outlets_1 }]);
2058 }
2059 if (cmd.segmentPath) {
2060 return __spread(res, [cmd.segmentPath]);
2061 }
2062 }
2063 if (!(typeof cmd === 'string')) {
2064 return __spread(res, [cmd]);
2065 }
2066 if (cmdIdx === 0) {
2067 cmd.split('/').forEach(function (urlPart, partIndex) {
2068 if (partIndex == 0 && urlPart === '.') ;
2069 else if (partIndex == 0 && urlPart === '') { // '/a'
2070 isAbsolute = true;
2071 }
2072 else if (urlPart === '..') { // '../a'
2073 numberOfDoubleDots++;
2074 }
2075 else if (urlPart != '') {
2076 res.push(urlPart);
2077 }
2078 });
2079 return res;
2080 }
2081 return __spread(res, [cmd]);
2082 }, []);
2083 return new Navigation(isAbsolute, numberOfDoubleDots, res);
2084 }
2085 var Position = /** @class */ (function () {
2086 function Position(segmentGroup, processChildren, index) {
2087 this.segmentGroup = segmentGroup;
2088 this.processChildren = processChildren;
2089 this.index = index;
2090 }
2091 return Position;
2092 }());
2093 function findStartingPosition(nav, tree, route) {
2094 if (nav.isAbsolute) {
2095 return new Position(tree.root, true, 0);
2096 }
2097 if (route.snapshot._lastPathIndex === -1) {
2098 return new Position(route.snapshot._urlSegment, true, 0);
2099 }
2100 var modifier = isMatrixParams(nav.commands[0]) ? 0 : 1;
2101 var index = route.snapshot._lastPathIndex + modifier;
2102 return createPositionApplyingDoubleDots(route.snapshot._urlSegment, index, nav.numberOfDoubleDots);
2103 }
2104 function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
2105 var g = group;
2106 var ci = index;
2107 var dd = numberOfDoubleDots;
2108 while (dd > ci) {
2109 dd -= ci;
2110 g = g.parent;
2111 if (!g) {
2112 throw new Error('Invalid number of \'../\'');
2113 }
2114 ci = g.segments.length;
2115 }
2116 return new Position(g, false, ci - dd);
2117 }
2118 function getPath(command) {
2119 if (typeof command === 'object' && command != null && command.outlets) {
2120 return command.outlets[PRIMARY_OUTLET];
2121 }
2122 return "" + command;
2123 }
2124 function getOutlets(commands) {
2125 var _a, _b;
2126 if (!(typeof commands[0] === 'object'))
2127 return _a = {}, _a[PRIMARY_OUTLET] = commands, _a;
2128 if (commands[0].outlets === undefined)
2129 return _b = {}, _b[PRIMARY_OUTLET] = commands, _b;
2130 return commands[0].outlets;
2131 }
2132 function updateSegmentGroup(segmentGroup, startIndex, commands) {
2133 if (!segmentGroup) {
2134 segmentGroup = new UrlSegmentGroup([], {});
2135 }
2136 if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
2137 return updateSegmentGroupChildren(segmentGroup, startIndex, commands);
2138 }
2139 var m = prefixedWith(segmentGroup, startIndex, commands);
2140 var slicedCommands = commands.slice(m.commandIndex);
2141 if (m.match && m.pathIndex < segmentGroup.segments.length) {
2142 var g = new UrlSegmentGroup(segmentGroup.segments.slice(0, m.pathIndex), {});
2143 g.children[PRIMARY_OUTLET] =
2144 new UrlSegmentGroup(segmentGroup.segments.slice(m.pathIndex), segmentGroup.children);
2145 return updateSegmentGroupChildren(g, 0, slicedCommands);
2146 }
2147 else if (m.match && slicedCommands.length === 0) {
2148 return new UrlSegmentGroup(segmentGroup.segments, {});
2149 }
2150 else if (m.match && !segmentGroup.hasChildren()) {
2151 return createNewSegmentGroup(segmentGroup, startIndex, commands);
2152 }
2153 else if (m.match) {
2154 return updateSegmentGroupChildren(segmentGroup, 0, slicedCommands);
2155 }
2156 else {
2157 return createNewSegmentGroup(segmentGroup, startIndex, commands);
2158 }
2159 }
2160 function updateSegmentGroupChildren(segmentGroup, startIndex, commands) {
2161 if (commands.length === 0) {
2162 return new UrlSegmentGroup(segmentGroup.segments, {});
2163 }
2164 else {
2165 var outlets_2 = getOutlets(commands);
2166 var children_1 = {};
2167 forEach(outlets_2, function (commands, outlet) {
2168 if (commands !== null) {
2169 children_1[outlet] = updateSegmentGroup(segmentGroup.children[outlet], startIndex, commands);
2170 }
2171 });
2172 forEach(segmentGroup.children, function (child, childOutlet) {
2173 if (outlets_2[childOutlet] === undefined) {
2174 children_1[childOutlet] = child;
2175 }
2176 });
2177 return new UrlSegmentGroup(segmentGroup.segments, children_1);
2178 }
2179 }
2180 function prefixedWith(segmentGroup, startIndex, commands) {
2181 var currentCommandIndex = 0;
2182 var currentPathIndex = startIndex;
2183 var noMatch = { match: false, pathIndex: 0, commandIndex: 0 };
2184 while (currentPathIndex < segmentGroup.segments.length) {
2185 if (currentCommandIndex >= commands.length)
2186 return noMatch;
2187 var path = segmentGroup.segments[currentPathIndex];
2188 var curr = getPath(commands[currentCommandIndex]);
2189 var next = currentCommandIndex < commands.length - 1 ? commands[currentCommandIndex + 1] : null;
2190 if (currentPathIndex > 0 && curr === undefined)
2191 break;
2192 if (curr && next && (typeof next === 'object') && next.outlets === undefined) {
2193 if (!compare(curr, next, path))
2194 return noMatch;
2195 currentCommandIndex += 2;
2196 }
2197 else {
2198 if (!compare(curr, {}, path))
2199 return noMatch;
2200 currentCommandIndex++;
2201 }
2202 currentPathIndex++;
2203 }
2204 return { match: true, pathIndex: currentPathIndex, commandIndex: currentCommandIndex };
2205 }
2206 function createNewSegmentGroup(segmentGroup, startIndex, commands) {
2207 var paths = segmentGroup.segments.slice(0, startIndex);
2208 var i = 0;
2209 while (i < commands.length) {
2210 if (typeof commands[i] === 'object' && commands[i].outlets !== undefined) {
2211 var children = createNewSegmentChildren(commands[i].outlets);
2212 return new UrlSegmentGroup(paths, children);
2213 }
2214 // if we start with an object literal, we need to reuse the path part from the segment
2215 if (i === 0 && isMatrixParams(commands[0])) {
2216 var p = segmentGroup.segments[startIndex];
2217 paths.push(new UrlSegment(p.path, commands[0]));
2218 i++;
2219 continue;
2220 }
2221 var curr = getPath(commands[i]);
2222 var next = (i < commands.length - 1) ? commands[i + 1] : null;
2223 if (curr && next && isMatrixParams(next)) {
2224 paths.push(new UrlSegment(curr, stringify(next)));
2225 i += 2;
2226 }
2227 else {
2228 paths.push(new UrlSegment(curr, {}));
2229 i++;
2230 }
2231 }
2232 return new UrlSegmentGroup(paths, {});
2233 }
2234 function createNewSegmentChildren(outlets) {
2235 var children = {};
2236 forEach(outlets, function (commands, outlet) {
2237 if (commands !== null) {
2238 children[outlet] = createNewSegmentGroup(new UrlSegmentGroup([], {}), 0, commands);
2239 }
2240 });
2241 return children;
2242 }
2243 function stringify(params) {
2244 var res = {};
2245 forEach(params, function (v, k) { return res[k] = "" + v; });
2246 return res;
2247 }
2248 function compare(path, params, segment) {
2249 return path == segment.path && shallowEqual(params, segment.parameters);
2250 }
2251
2252 /**
2253 * @license
2254 * Copyright Google Inc. All Rights Reserved.
2255 *
2256 * Use of this source code is governed by an MIT-style license that can be
2257 * found in the LICENSE file at https://angular.io/license
2258 */
2259 var activateRoutes = function (rootContexts, routeReuseStrategy, forwardEvent) {
2260 return operators.map(function (t) {
2261 new ActivateRoutes(routeReuseStrategy, t.targetRouterState, t.currentRouterState, forwardEvent)
2262 .activate(rootContexts);
2263 return t;
2264 });
2265 };
2266 var ActivateRoutes = /** @class */ (function () {
2267 function ActivateRoutes(routeReuseStrategy, futureState, currState, forwardEvent) {
2268 this.routeReuseStrategy = routeReuseStrategy;
2269 this.futureState = futureState;
2270 this.currState = currState;
2271 this.forwardEvent = forwardEvent;
2272 }
2273 ActivateRoutes.prototype.activate = function (parentContexts) {
2274 var futureRoot = this.futureState._root;
2275 var currRoot = this.currState ? this.currState._root : null;
2276 this.deactivateChildRoutes(futureRoot, currRoot, parentContexts);
2277 advanceActivatedRoute(this.futureState.root);
2278 this.activateChildRoutes(futureRoot, currRoot, parentContexts);
2279 };
2280 // De-activate the child route that are not re-used for the future state
2281 ActivateRoutes.prototype.deactivateChildRoutes = function (futureNode, currNode, contexts) {
2282 var _this = this;
2283 var children = nodeChildrenAsMap(currNode);
2284 // Recurse on the routes active in the future state to de-activate deeper children
2285 futureNode.children.forEach(function (futureChild) {
2286 var childOutletName = futureChild.value.outlet;
2287 _this.deactivateRoutes(futureChild, children[childOutletName], contexts);
2288 delete children[childOutletName];
2289 });
2290 // De-activate the routes that will not be re-used
2291 forEach(children, function (v, childName) {
2292 _this.deactivateRouteAndItsChildren(v, contexts);
2293 });
2294 };
2295 ActivateRoutes.prototype.deactivateRoutes = function (futureNode, currNode, parentContext) {
2296 var future = futureNode.value;
2297 var curr = currNode ? currNode.value : null;
2298 if (future === curr) {
2299 // Reusing the node, check to see if the children need to be de-activated
2300 if (future.component) {
2301 // If we have a normal route, we need to go through an outlet.
2302 var context = parentContext.getContext(future.outlet);
2303 if (context) {
2304 this.deactivateChildRoutes(futureNode, currNode, context.children);
2305 }
2306 }
2307 else {
2308 // if we have a componentless route, we recurse but keep the same outlet map.
2309 this.deactivateChildRoutes(futureNode, currNode, parentContext);
2310 }
2311 }
2312 else {
2313 if (curr) {
2314 // Deactivate the current route which will not be re-used
2315 this.deactivateRouteAndItsChildren(currNode, parentContext);
2316 }
2317 }
2318 };
2319 ActivateRoutes.prototype.deactivateRouteAndItsChildren = function (route, parentContexts) {
2320 if (this.routeReuseStrategy.shouldDetach(route.value.snapshot)) {
2321 this.detachAndStoreRouteSubtree(route, parentContexts);
2322 }
2323 else {
2324 this.deactivateRouteAndOutlet(route, parentContexts);
2325 }
2326 };
2327 ActivateRoutes.prototype.detachAndStoreRouteSubtree = function (route, parentContexts) {
2328 var context = parentContexts.getContext(route.value.outlet);
2329 if (context && context.outlet) {
2330 var componentRef = context.outlet.detach();
2331 var contexts = context.children.onOutletDeactivated();
2332 this.routeReuseStrategy.store(route.value.snapshot, { componentRef: componentRef, route: route, contexts: contexts });
2333 }
2334 };
2335 ActivateRoutes.prototype.deactivateRouteAndOutlet = function (route, parentContexts) {
2336 var _this = this;
2337 var context = parentContexts.getContext(route.value.outlet);
2338 if (context) {
2339 var children = nodeChildrenAsMap(route);
2340 var contexts_1 = route.value.component ? context.children : parentContexts;
2341 forEach(children, function (v, k) { return _this.deactivateRouteAndItsChildren(v, contexts_1); });
2342 if (context.outlet) {
2343 // Destroy the component
2344 context.outlet.deactivate();
2345 // Destroy the contexts for all the outlets that were in the component
2346 context.children.onOutletDeactivated();
2347 }
2348 }
2349 };
2350 ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, contexts) {
2351 var _this = this;
2352 var children = nodeChildrenAsMap(currNode);
2353 futureNode.children.forEach(function (c) {
2354 _this.activateRoutes(c, children[c.value.outlet], contexts);
2355 _this.forwardEvent(new ActivationEnd(c.value.snapshot));
2356 });
2357 if (futureNode.children.length) {
2358 this.forwardEvent(new ChildActivationEnd(futureNode.value.snapshot));
2359 }
2360 };
2361 ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentContexts) {
2362 var future = futureNode.value;
2363 var curr = currNode ? currNode.value : null;
2364 advanceActivatedRoute(future);
2365 // reusing the node
2366 if (future === curr) {
2367 if (future.component) {
2368 // If we have a normal route, we need to go through an outlet.
2369 var context = parentContexts.getOrCreateContext(future.outlet);
2370 this.activateChildRoutes(futureNode, currNode, context.children);
2371 }
2372 else {
2373 // if we have a componentless route, we recurse but keep the same outlet map.
2374 this.activateChildRoutes(futureNode, currNode, parentContexts);
2375 }
2376 }
2377 else {
2378 if (future.component) {
2379 // if we have a normal route, we need to place the component into the outlet and recurse.
2380 var context = parentContexts.getOrCreateContext(future.outlet);
2381 if (this.routeReuseStrategy.shouldAttach(future.snapshot)) {
2382 var stored = this.routeReuseStrategy.retrieve(future.snapshot);
2383 this.routeReuseStrategy.store(future.snapshot, null);
2384 context.children.onOutletReAttached(stored.contexts);
2385 context.attachRef = stored.componentRef;
2386 context.route = stored.route.value;
2387 if (context.outlet) {
2388 // Attach right away when the outlet has already been instantiated
2389 // Otherwise attach from `RouterOutlet.ngOnInit` when it is instantiated
2390 context.outlet.attach(stored.componentRef, stored.route.value);
2391 }
2392 advanceActivatedRouteNodeAndItsChildren(stored.route);
2393 }
2394 else {
2395 var config = parentLoadedConfig(future.snapshot);
2396 var cmpFactoryResolver = config ? config.module.componentFactoryResolver : null;
2397 context.attachRef = null;
2398 context.route = future;
2399 context.resolver = cmpFactoryResolver;
2400 if (context.outlet) {
2401 // Activate the outlet when it has already been instantiated
2402 // Otherwise it will get activated from its `ngOnInit` when instantiated
2403 context.outlet.activateWith(future, cmpFactoryResolver);
2404 }
2405 this.activateChildRoutes(futureNode, null, context.children);
2406 }
2407 }
2408 else {
2409 // if we have a componentless route, we recurse but keep the same outlet map.
2410 this.activateChildRoutes(futureNode, null, parentContexts);
2411 }
2412 }
2413 };
2414 return ActivateRoutes;
2415 }());
2416 function advanceActivatedRouteNodeAndItsChildren(node) {
2417 advanceActivatedRoute(node.value);
2418 node.children.forEach(advanceActivatedRouteNodeAndItsChildren);
2419 }
2420 function parentLoadedConfig(snapshot) {
2421 for (var s = snapshot.parent; s; s = s.parent) {
2422 var route = s.routeConfig;
2423 if (route && route._loadedConfig)
2424 return route._loadedConfig;
2425 if (route && route.component)
2426 return null;
2427 }
2428 return null;
2429 }
2430
2431 /**
2432 * @license
2433 * Copyright Google Inc. All Rights Reserved.
2434 *
2435 * Use of this source code is governed by an MIT-style license that can be
2436 * found in the LICENSE file at https://angular.io/license
2437 */
2438 /**
2439 * Simple function check, but generic so type inference will flow. Example:
2440 *
2441 * function product(a: number, b: number) {
2442 * return a * b;
2443 * }
2444 *
2445 * if (isFunction<product>(fn)) {
2446 * return fn(1, 2);
2447 * } else {
2448 * throw "Must provide the `product` function";
2449 * }
2450 */
2451 function isFunction(v) {
2452 return typeof v === 'function';
2453 }
2454 function isBoolean(v) {
2455 return typeof v === 'boolean';
2456 }
2457 function isUrlTree(v) {
2458 return v instanceof UrlTree;
2459 }
2460 function isCanLoad(guard) {
2461 return guard && isFunction(guard.canLoad);
2462 }
2463 function isCanActivate(guard) {
2464 return guard && isFunction(guard.canActivate);
2465 }
2466 function isCanActivateChild(guard) {
2467 return guard && isFunction(guard.canActivateChild);
2468 }
2469 function isCanDeactivate(guard) {
2470 return guard && isFunction(guard.canDeactivate);
2471 }
2472
2473 /**
2474 * @license
2475 * Copyright Google Inc. All Rights Reserved.
2476 *
2477 * Use of this source code is governed by an MIT-style license that can be
2478 * found in the LICENSE file at https://angular.io/license
2479 */
2480 var NoMatch = /** @class */ (function () {
2481 function NoMatch(segmentGroup) {
2482 this.segmentGroup = segmentGroup || null;
2483 }
2484 return NoMatch;
2485 }());
2486 var AbsoluteRedirect = /** @class */ (function () {
2487 function AbsoluteRedirect(urlTree) {
2488 this.urlTree = urlTree;
2489 }
2490 return AbsoluteRedirect;
2491 }());
2492 function noMatch(segmentGroup) {
2493 return new rxjs.Observable(function (obs) { return obs.error(new NoMatch(segmentGroup)); });
2494 }
2495 function absoluteRedirect(newTree) {
2496 return new rxjs.Observable(function (obs) { return obs.error(new AbsoluteRedirect(newTree)); });
2497 }
2498 function namedOutletsRedirect(redirectTo) {
2499 return new rxjs.Observable(function (obs) { return obs.error(new Error("Only absolute redirects can have named outlets. redirectTo: '" + redirectTo + "'")); });
2500 }
2501 function canLoadFails(route) {
2502 return new rxjs.Observable(function (obs) { return obs.error(navigationCancelingError("Cannot load children because the guard of the route \"path: '" + route.path + "'\" returned false")); });
2503 }
2504 /**
2505 * Returns the `UrlTree` with the redirection applied.
2506 *
2507 * Lazy modules are loaded along the way.
2508 */
2509 function applyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
2510 return new ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config).apply();
2511 }
2512 var ApplyRedirects = /** @class */ (function () {
2513 function ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
2514 this.configLoader = configLoader;
2515 this.urlSerializer = urlSerializer;
2516 this.urlTree = urlTree;
2517 this.config = config;
2518 this.allowRedirects = true;
2519 this.ngModule = moduleInjector.get(core.NgModuleRef);
2520 }
2521 ApplyRedirects.prototype.apply = function () {
2522 var _this = this;
2523 var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, this.urlTree.root, PRIMARY_OUTLET);
2524 var urlTrees$ = expanded$.pipe(operators.map(function (rootSegmentGroup) { return _this.createUrlTree(rootSegmentGroup, _this.urlTree.queryParams, _this.urlTree.fragment); }));
2525 return urlTrees$.pipe(operators.catchError(function (e) {
2526 if (e instanceof AbsoluteRedirect) {
2527 // after an absolute redirect we do not apply any more redirects!
2528 _this.allowRedirects = false;
2529 // we need to run matching, so we can fetch all lazy-loaded modules
2530 return _this.match(e.urlTree);
2531 }
2532 if (e instanceof NoMatch) {
2533 throw _this.noMatchError(e);
2534 }
2535 throw e;
2536 }));
2537 };
2538 ApplyRedirects.prototype.match = function (tree) {
2539 var _this = this;
2540 var expanded$ = this.expandSegmentGroup(this.ngModule, this.config, tree.root, PRIMARY_OUTLET);
2541 var mapped$ = expanded$.pipe(operators.map(function (rootSegmentGroup) {
2542 return _this.createUrlTree(rootSegmentGroup, tree.queryParams, tree.fragment);
2543 }));
2544 return mapped$.pipe(operators.catchError(function (e) {
2545 if (e instanceof NoMatch) {
2546 throw _this.noMatchError(e);
2547 }
2548 throw e;
2549 }));
2550 };
2551 ApplyRedirects.prototype.noMatchError = function (e) {
2552 return new Error("Cannot match any routes. URL Segment: '" + e.segmentGroup + "'");
2553 };
2554 ApplyRedirects.prototype.createUrlTree = function (rootCandidate, queryParams, fragment) {
2555 var _a;
2556 var root = rootCandidate.segments.length > 0 ?
2557 new UrlSegmentGroup([], (_a = {}, _a[PRIMARY_OUTLET] = rootCandidate, _a)) :
2558 rootCandidate;
2559 return new UrlTree(root, queryParams, fragment);
2560 };
2561 ApplyRedirects.prototype.expandSegmentGroup = function (ngModule, routes, segmentGroup, outlet) {
2562 if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
2563 return this.expandChildren(ngModule, routes, segmentGroup)
2564 .pipe(operators.map(function (children) { return new UrlSegmentGroup([], children); }));
2565 }
2566 return this.expandSegment(ngModule, segmentGroup, routes, segmentGroup.segments, outlet, true);
2567 };
2568 // Recursively expand segment groups for all the child outlets
2569 ApplyRedirects.prototype.expandChildren = function (ngModule, routes, segmentGroup) {
2570 var _this = this;
2571 return waitForMap(segmentGroup.children, function (childOutlet, child) { return _this.expandSegmentGroup(ngModule, routes, child, childOutlet); });
2572 };
2573 ApplyRedirects.prototype.expandSegment = function (ngModule, segmentGroup, routes, segments, outlet, allowRedirects) {
2574 var _this = this;
2575 return rxjs.of.apply(void 0, __spread(routes)).pipe(operators.map(function (r) {
2576 var expanded$ = _this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
2577 return expanded$.pipe(operators.catchError(function (e) {
2578 if (e instanceof NoMatch) {
2579 // TODO(i): this return type doesn't match the declared Observable<UrlSegmentGroup> -
2580 // talk to Jason
2581 return rxjs.of(null);
2582 }
2583 throw e;
2584 }));
2585 }), operators.concatAll(), operators.first(function (s) { return !!s; }), operators.catchError(function (e, _) {
2586 if (e instanceof rxjs.EmptyError || e.name === 'EmptyError') {
2587 if (_this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
2588 return rxjs.of(new UrlSegmentGroup([], {}));
2589 }
2590 throw new NoMatch(segmentGroup);
2591 }
2592 throw e;
2593 }));
2594 };
2595 ApplyRedirects.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
2596 return segments.length === 0 && !segmentGroup.children[outlet];
2597 };
2598 ApplyRedirects.prototype.expandSegmentAgainstRoute = function (ngModule, segmentGroup, routes, route, paths, outlet, allowRedirects) {
2599 if (getOutlet(route) !== outlet) {
2600 return noMatch(segmentGroup);
2601 }
2602 if (route.redirectTo === undefined) {
2603 return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths);
2604 }
2605 if (allowRedirects && this.allowRedirects) {
2606 return this.expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, paths, outlet);
2607 }
2608 return noMatch(segmentGroup);
2609 };
2610 ApplyRedirects.prototype.expandSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
2611 if (route.path === '**') {
2612 return this.expandWildCardWithParamsAgainstRouteUsingRedirect(ngModule, routes, route, outlet);
2613 }
2614 return this.expandRegularSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, segments, outlet);
2615 };
2616 ApplyRedirects.prototype.expandWildCardWithParamsAgainstRouteUsingRedirect = function (ngModule, routes, route, outlet) {
2617 var _this = this;
2618 var newTree = this.applyRedirectCommands([], route.redirectTo, {});
2619 if (route.redirectTo.startsWith('/')) {
2620 return absoluteRedirect(newTree);
2621 }
2622 return this.lineralizeSegments(route, newTree).pipe(operators.mergeMap(function (newSegments) {
2623 var group = new UrlSegmentGroup(newSegments, {});
2624 return _this.expandSegment(ngModule, group, routes, newSegments, outlet, false);
2625 }));
2626 };
2627 ApplyRedirects.prototype.expandRegularSegmentAgainstRouteUsingRedirect = function (ngModule, segmentGroup, routes, route, segments, outlet) {
2628 var _this = this;
2629 var _a = match(segmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild, positionalParamSegments = _a.positionalParamSegments;
2630 if (!matched)
2631 return noMatch(segmentGroup);
2632 var newTree = this.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments);
2633 if (route.redirectTo.startsWith('/')) {
2634 return absoluteRedirect(newTree);
2635 }
2636 return this.lineralizeSegments(route, newTree).pipe(operators.mergeMap(function (newSegments) {
2637 return _this.expandSegment(ngModule, segmentGroup, routes, newSegments.concat(segments.slice(lastChild)), outlet, false);
2638 }));
2639 };
2640 ApplyRedirects.prototype.matchSegmentAgainstRoute = function (ngModule, rawSegmentGroup, route, segments) {
2641 var _this = this;
2642 if (route.path === '**') {
2643 if (route.loadChildren) {
2644 return this.configLoader.load(ngModule.injector, route)
2645 .pipe(operators.map(function (cfg) {
2646 route._loadedConfig = cfg;
2647 return new UrlSegmentGroup(segments, {});
2648 }));
2649 }
2650 return rxjs.of(new UrlSegmentGroup(segments, {}));
2651 }
2652 var _a = match(rawSegmentGroup, route, segments), matched = _a.matched, consumedSegments = _a.consumedSegments, lastChild = _a.lastChild;
2653 if (!matched)
2654 return noMatch(rawSegmentGroup);
2655 var rawSlicedSegments = segments.slice(lastChild);
2656 var childConfig$ = this.getChildConfig(ngModule, route, segments);
2657 return childConfig$.pipe(operators.mergeMap(function (routerConfig) {
2658 var childModule = routerConfig.module;
2659 var childConfig = routerConfig.routes;
2660 var _a = split(rawSegmentGroup, consumedSegments, rawSlicedSegments, childConfig), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
2661 if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
2662 var expanded$_1 = _this.expandChildren(childModule, childConfig, segmentGroup);
2663 return expanded$_1.pipe(operators.map(function (children) { return new UrlSegmentGroup(consumedSegments, children); }));
2664 }
2665 if (childConfig.length === 0 && slicedSegments.length === 0) {
2666 return rxjs.of(new UrlSegmentGroup(consumedSegments, {}));
2667 }
2668 var expanded$ = _this.expandSegment(childModule, segmentGroup, childConfig, slicedSegments, PRIMARY_OUTLET, true);
2669 return expanded$.pipe(operators.map(function (cs) {
2670 return new UrlSegmentGroup(consumedSegments.concat(cs.segments), cs.children);
2671 }));
2672 }));
2673 };
2674 ApplyRedirects.prototype.getChildConfig = function (ngModule, route, segments) {
2675 var _this = this;
2676 if (route.children) {
2677 // The children belong to the same module
2678 return rxjs.of(new LoadedRouterConfig(route.children, ngModule));
2679 }
2680 if (route.loadChildren) {
2681 // lazy children belong to the loaded module
2682 if (route._loadedConfig !== undefined) {
2683 return rxjs.of(route._loadedConfig);
2684 }
2685 return runCanLoadGuard(ngModule.injector, route, segments)
2686 .pipe(operators.mergeMap(function (shouldLoad) {
2687 if (shouldLoad) {
2688 return _this.configLoader.load(ngModule.injector, route)
2689 .pipe(operators.map(function (cfg) {
2690 route._loadedConfig = cfg;
2691 return cfg;
2692 }));
2693 }
2694 return canLoadFails(route);
2695 }));
2696 }
2697 return rxjs.of(new LoadedRouterConfig([], ngModule));
2698 };
2699 ApplyRedirects.prototype.lineralizeSegments = function (route, urlTree) {
2700 var res = [];
2701 var c = urlTree.root;
2702 while (true) {
2703 res = res.concat(c.segments);
2704 if (c.numberOfChildren === 0) {
2705 return rxjs.of(res);
2706 }
2707 if (c.numberOfChildren > 1 || !c.children[PRIMARY_OUTLET]) {
2708 return namedOutletsRedirect(route.redirectTo);
2709 }
2710 c = c.children[PRIMARY_OUTLET];
2711 }
2712 };
2713 ApplyRedirects.prototype.applyRedirectCommands = function (segments, redirectTo, posParams) {
2714 return this.applyRedirectCreatreUrlTree(redirectTo, this.urlSerializer.parse(redirectTo), segments, posParams);
2715 };
2716 ApplyRedirects.prototype.applyRedirectCreatreUrlTree = function (redirectTo, urlTree, segments, posParams) {
2717 var newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
2718 return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
2719 };
2720 ApplyRedirects.prototype.createQueryParams = function (redirectToParams, actualParams) {
2721 var res = {};
2722 forEach(redirectToParams, function (v, k) {
2723 var copySourceValue = typeof v === 'string' && v.startsWith(':');
2724 if (copySourceValue) {
2725 var sourceName = v.substring(1);
2726 res[k] = actualParams[sourceName];
2727 }
2728 else {
2729 res[k] = v;
2730 }
2731 });
2732 return res;
2733 };
2734 ApplyRedirects.prototype.createSegmentGroup = function (redirectTo, group, segments, posParams) {
2735 var _this = this;
2736 var updatedSegments = this.createSegments(redirectTo, group.segments, segments, posParams);
2737 var children = {};
2738 forEach(group.children, function (child, name) {
2739 children[name] = _this.createSegmentGroup(redirectTo, child, segments, posParams);
2740 });
2741 return new UrlSegmentGroup(updatedSegments, children);
2742 };
2743 ApplyRedirects.prototype.createSegments = function (redirectTo, redirectToSegments, actualSegments, posParams) {
2744 var _this = this;
2745 return redirectToSegments.map(function (s) { return s.path.startsWith(':') ? _this.findPosParam(redirectTo, s, posParams) :
2746 _this.findOrReturn(s, actualSegments); });
2747 };
2748 ApplyRedirects.prototype.findPosParam = function (redirectTo, redirectToUrlSegment, posParams) {
2749 var pos = posParams[redirectToUrlSegment.path.substring(1)];
2750 if (!pos)
2751 throw new Error("Cannot redirect to '" + redirectTo + "'. Cannot find '" + redirectToUrlSegment.path + "'.");
2752 return pos;
2753 };
2754 ApplyRedirects.prototype.findOrReturn = function (redirectToUrlSegment, actualSegments) {
2755 var e_1, _a;
2756 var idx = 0;
2757 try {
2758 for (var actualSegments_1 = __values(actualSegments), actualSegments_1_1 = actualSegments_1.next(); !actualSegments_1_1.done; actualSegments_1_1 = actualSegments_1.next()) {
2759 var s = actualSegments_1_1.value;
2760 if (s.path === redirectToUrlSegment.path) {
2761 actualSegments.splice(idx);
2762 return s;
2763 }
2764 idx++;
2765 }
2766 }
2767 catch (e_1_1) { e_1 = { error: e_1_1 }; }
2768 finally {
2769 try {
2770 if (actualSegments_1_1 && !actualSegments_1_1.done && (_a = actualSegments_1.return)) _a.call(actualSegments_1);
2771 }
2772 finally { if (e_1) throw e_1.error; }
2773 }
2774 return redirectToUrlSegment;
2775 };
2776 return ApplyRedirects;
2777 }());
2778 function runCanLoadGuard(moduleInjector, route, segments) {
2779 var canLoad = route.canLoad;
2780 if (!canLoad || canLoad.length === 0)
2781 return rxjs.of(true);
2782 var obs = rxjs.from(canLoad).pipe(operators.map(function (injectionToken) {
2783 var guard = moduleInjector.get(injectionToken);
2784 var guardVal;
2785 if (isCanLoad(guard)) {
2786 guardVal = guard.canLoad(route, segments);
2787 }
2788 else if (isFunction(guard)) {
2789 guardVal = guard(route, segments);
2790 }
2791 else {
2792 throw new Error('Invalid CanLoad guard');
2793 }
2794 return wrapIntoObservable(guardVal);
2795 }));
2796 return obs.pipe(operators.concatAll(), operators.every(function (result) { return result === true; }));
2797 }
2798 function match(segmentGroup, route, segments) {
2799 if (route.path === '') {
2800 if ((route.pathMatch === 'full') && (segmentGroup.hasChildren() || segments.length > 0)) {
2801 return { matched: false, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
2802 }
2803 return { matched: true, consumedSegments: [], lastChild: 0, positionalParamSegments: {} };
2804 }
2805 var matcher = route.matcher || defaultUrlMatcher;
2806 var res = matcher(segments, segmentGroup, route);
2807 if (!res) {
2808 return {
2809 matched: false,
2810 consumedSegments: [],
2811 lastChild: 0,
2812 positionalParamSegments: {},
2813 };
2814 }
2815 return {
2816 matched: true,
2817 consumedSegments: res.consumed,
2818 lastChild: res.consumed.length,
2819 positionalParamSegments: res.posParams,
2820 };
2821 }
2822 function split(segmentGroup, consumedSegments, slicedSegments, config) {
2823 if (slicedSegments.length > 0 &&
2824 containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, slicedSegments, config)) {
2825 var s = new UrlSegmentGroup(consumedSegments, createChildrenForEmptySegments(config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
2826 return { segmentGroup: mergeTrivialChildren(s), slicedSegments: [] };
2827 }
2828 if (slicedSegments.length === 0 &&
2829 containsEmptyPathRedirects(segmentGroup, slicedSegments, config)) {
2830 var s = new UrlSegmentGroup(segmentGroup.segments, addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, config, segmentGroup.children));
2831 return { segmentGroup: mergeTrivialChildren(s), slicedSegments: slicedSegments };
2832 }
2833 return { segmentGroup: segmentGroup, slicedSegments: slicedSegments };
2834 }
2835 function mergeTrivialChildren(s) {
2836 if (s.numberOfChildren === 1 && s.children[PRIMARY_OUTLET]) {
2837 var c = s.children[PRIMARY_OUTLET];
2838 return new UrlSegmentGroup(s.segments.concat(c.segments), c.children);
2839 }
2840 return s;
2841 }
2842 function addEmptySegmentsToChildrenIfNeeded(segmentGroup, slicedSegments, routes, children) {
2843 var e_2, _a;
2844 var res = {};
2845 try {
2846 for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
2847 var r = routes_1_1.value;
2848 if (isEmptyPathRedirect(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) {
2849 res[getOutlet(r)] = new UrlSegmentGroup([], {});
2850 }
2851 }
2852 }
2853 catch (e_2_1) { e_2 = { error: e_2_1 }; }
2854 finally {
2855 try {
2856 if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
2857 }
2858 finally { if (e_2) throw e_2.error; }
2859 }
2860 return __assign({}, children, res);
2861 }
2862 function createChildrenForEmptySegments(routes, primarySegmentGroup) {
2863 var e_3, _a;
2864 var res = {};
2865 res[PRIMARY_OUTLET] = primarySegmentGroup;
2866 try {
2867 for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
2868 var r = routes_2_1.value;
2869 if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) {
2870 res[getOutlet(r)] = new UrlSegmentGroup([], {});
2871 }
2872 }
2873 }
2874 catch (e_3_1) { e_3 = { error: e_3_1 }; }
2875 finally {
2876 try {
2877 if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
2878 }
2879 finally { if (e_3) throw e_3.error; }
2880 }
2881 return res;
2882 }
2883 function containsEmptyPathRedirectsWithNamedOutlets(segmentGroup, segments, routes) {
2884 return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r) && getOutlet(r) !== PRIMARY_OUTLET; });
2885 }
2886 function containsEmptyPathRedirects(segmentGroup, segments, routes) {
2887 return routes.some(function (r) { return isEmptyPathRedirect(segmentGroup, segments, r); });
2888 }
2889 function isEmptyPathRedirect(segmentGroup, segments, r) {
2890 if ((segmentGroup.hasChildren() || segments.length > 0) && r.pathMatch === 'full') {
2891 return false;
2892 }
2893 return r.path === '' && r.redirectTo !== undefined;
2894 }
2895 function getOutlet(route) {
2896 return route.outlet || PRIMARY_OUTLET;
2897 }
2898
2899 /**
2900 * @license
2901 * Copyright Google Inc. All Rights Reserved.
2902 *
2903 * Use of this source code is governed by an MIT-style license that can be
2904 * found in the LICENSE file at https://angular.io/license
2905 */
2906 function applyRedirects$1(moduleInjector, configLoader, urlSerializer, config) {
2907 return function (source) {
2908 return source.pipe(operators.switchMap(function (t) { return applyRedirects(moduleInjector, configLoader, urlSerializer, t.extractedUrl, config)
2909 .pipe(operators.map(function (urlAfterRedirects) { return (__assign({}, t, { urlAfterRedirects: urlAfterRedirects })); })); }));
2910 };
2911 }
2912
2913 /**
2914 * @license
2915 * Copyright Google Inc. All Rights Reserved.
2916 *
2917 * Use of this source code is governed by an MIT-style license that can be
2918 * found in the LICENSE file at https://angular.io/license
2919 */
2920 var CanActivate = /** @class */ (function () {
2921 function CanActivate(path) {
2922 this.path = path;
2923 this.route = this.path[this.path.length - 1];
2924 }
2925 return CanActivate;
2926 }());
2927 var CanDeactivate = /** @class */ (function () {
2928 function CanDeactivate(component, route) {
2929 this.component = component;
2930 this.route = route;
2931 }
2932 return CanDeactivate;
2933 }());
2934 function getAllRouteGuards(future, curr, parentContexts) {
2935 var futureRoot = future._root;
2936 var currRoot = curr ? curr._root : null;
2937 return getChildRouteGuards(futureRoot, currRoot, parentContexts, [futureRoot.value]);
2938 }
2939 function getCanActivateChild(p) {
2940 var canActivateChild = p.routeConfig ? p.routeConfig.canActivateChild : null;
2941 if (!canActivateChild || canActivateChild.length === 0)
2942 return null;
2943 return { node: p, guards: canActivateChild };
2944 }
2945 function getToken(token, snapshot, moduleInjector) {
2946 var config = getClosestLoadedConfig(snapshot);
2947 var injector = config ? config.module.injector : moduleInjector;
2948 return injector.get(token);
2949 }
2950 function getClosestLoadedConfig(snapshot) {
2951 if (!snapshot)
2952 return null;
2953 for (var s = snapshot.parent; s; s = s.parent) {
2954 var route = s.routeConfig;
2955 if (route && route._loadedConfig)
2956 return route._loadedConfig;
2957 }
2958 return null;
2959 }
2960 function getChildRouteGuards(futureNode, currNode, contexts, futurePath, checks) {
2961 if (checks === void 0) { checks = {
2962 canDeactivateChecks: [],
2963 canActivateChecks: []
2964 }; }
2965 var prevChildren = nodeChildrenAsMap(currNode);
2966 // Process the children of the future route
2967 futureNode.children.forEach(function (c) {
2968 getRouteGuards(c, prevChildren[c.value.outlet], contexts, futurePath.concat([c.value]), checks);
2969 delete prevChildren[c.value.outlet];
2970 });
2971 // Process any children left from the current route (not active for the future route)
2972 forEach(prevChildren, function (v, k) {
2973 return deactivateRouteAndItsChildren(v, contexts.getContext(k), checks);
2974 });
2975 return checks;
2976 }
2977 function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks) {
2978 if (checks === void 0) { checks = {
2979 canDeactivateChecks: [],
2980 canActivateChecks: []
2981 }; }
2982 var future = futureNode.value;
2983 var curr = currNode ? currNode.value : null;
2984 var context = parentContexts ? parentContexts.getContext(futureNode.value.outlet) : null;
2985 // reusing the node
2986 if (curr && future.routeConfig === curr.routeConfig) {
2987 var shouldRun = shouldRunGuardsAndResolvers(curr, future, future.routeConfig.runGuardsAndResolvers);
2988 if (shouldRun) {
2989 checks.canActivateChecks.push(new CanActivate(futurePath));
2990 }
2991 else {
2992 // we need to set the data
2993 future.data = curr.data;
2994 future._resolvedData = curr._resolvedData;
2995 }
2996 // If we have a component, we need to go through an outlet.
2997 if (future.component) {
2998 getChildRouteGuards(futureNode, currNode, context ? context.children : null, futurePath, checks);
2999 // if we have a componentless route, we recurse but keep the same outlet map.
3000 }
3001 else {
3002 getChildRouteGuards(futureNode, currNode, parentContexts, futurePath, checks);
3003 }
3004 if (shouldRun) {
3005 var component = context && context.outlet && context.outlet.component || null;
3006 checks.canDeactivateChecks.push(new CanDeactivate(component, curr));
3007 }
3008 }
3009 else {
3010 if (curr) {
3011 deactivateRouteAndItsChildren(currNode, context, checks);
3012 }
3013 checks.canActivateChecks.push(new CanActivate(futurePath));
3014 // If we have a component, we need to go through an outlet.
3015 if (future.component) {
3016 getChildRouteGuards(futureNode, null, context ? context.children : null, futurePath, checks);
3017 // if we have a componentless route, we recurse but keep the same outlet map.
3018 }
3019 else {
3020 getChildRouteGuards(futureNode, null, parentContexts, futurePath, checks);
3021 }
3022 }
3023 return checks;
3024 }
3025 function shouldRunGuardsAndResolvers(curr, future, mode) {
3026 if (typeof mode === 'function') {
3027 return mode(curr, future);
3028 }
3029 switch (mode) {
3030 case 'pathParamsChange':
3031 return !equalPath(curr.url, future.url);
3032 case 'pathParamsOrQueryParamsChange':
3033 return !equalPath(curr.url, future.url) ||
3034 !shallowEqual(curr.queryParams, future.queryParams);
3035 case 'always':
3036 return true;
3037 case 'paramsOrQueryParamsChange':
3038 return !equalParamsAndUrlSegments(curr, future) ||
3039 !shallowEqual(curr.queryParams, future.queryParams);
3040 case 'paramsChange':
3041 default:
3042 return !equalParamsAndUrlSegments(curr, future);
3043 }
3044 }
3045 function deactivateRouteAndItsChildren(route, context, checks) {
3046 var children = nodeChildrenAsMap(route);
3047 var r = route.value;
3048 forEach(children, function (node, childName) {
3049 if (!r.component) {
3050 deactivateRouteAndItsChildren(node, context, checks);
3051 }
3052 else if (context) {
3053 deactivateRouteAndItsChildren(node, context.children.getContext(childName), checks);
3054 }
3055 else {
3056 deactivateRouteAndItsChildren(node, null, checks);
3057 }
3058 });
3059 if (!r.component) {
3060 checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3061 }
3062 else if (context && context.outlet && context.outlet.isActivated) {
3063 checks.canDeactivateChecks.push(new CanDeactivate(context.outlet.component, r));
3064 }
3065 else {
3066 checks.canDeactivateChecks.push(new CanDeactivate(null, r));
3067 }
3068 }
3069
3070 /**
3071 * @license
3072 * Copyright Google Inc. All Rights Reserved.
3073 *
3074 * Use of this source code is governed by an MIT-style license that can be
3075 * found in the LICENSE file at https://angular.io/license
3076 */
3077 var INITIAL_VALUE = Symbol('INITIAL_VALUE');
3078 function prioritizedGuardValue() {
3079 return operators.switchMap(function (obs) {
3080 return rxjs.combineLatest.apply(void 0, __spread(obs.map(function (o) { return o.pipe(operators.take(1), operators.startWith(INITIAL_VALUE)); }))).pipe(operators.scan(function (acc, list) {
3081 var isPending = false;
3082 return list.reduce(function (innerAcc, val, i) {
3083 if (innerAcc !== INITIAL_VALUE)
3084 return innerAcc;
3085 // Toggle pending flag if any values haven't been set yet
3086 if (val === INITIAL_VALUE)
3087 isPending = true;
3088 // Any other return values are only valid if we haven't yet hit a pending call.
3089 // This guarantees that in the case of a guard at the bottom of the tree that
3090 // returns a redirect, we will wait for the higher priority guard at the top to
3091 // finish before performing the redirect.
3092 if (!isPending) {
3093 // Early return when we hit a `false` value as that should always cancel
3094 // navigation
3095 if (val === false)
3096 return val;
3097 if (i === list.length - 1 || isUrlTree(val)) {
3098 return val;
3099 }
3100 }
3101 return innerAcc;
3102 }, acc);
3103 }, INITIAL_VALUE), operators.filter(function (item) { return item !== INITIAL_VALUE; }), operators.map(function (item) { return isUrlTree(item) ? item : item === true; }), //
3104 operators.take(1));
3105 });
3106 }
3107
3108 /**
3109 * @license
3110 * Copyright Google Inc. All Rights Reserved.
3111 *
3112 * Use of this source code is governed by an MIT-style license that can be
3113 * found in the LICENSE file at https://angular.io/license
3114 */
3115 function checkGuards(moduleInjector, forwardEvent) {
3116 return function (source) {
3117 return source.pipe(operators.mergeMap(function (t) {
3118 var targetSnapshot = t.targetSnapshot, currentSnapshot = t.currentSnapshot, _a = t.guards, canActivateChecks = _a.canActivateChecks, canDeactivateChecks = _a.canDeactivateChecks;
3119 if (canDeactivateChecks.length === 0 && canActivateChecks.length === 0) {
3120 return rxjs.of(__assign({}, t, { guardsResult: true }));
3121 }
3122 return runCanDeactivateChecks(canDeactivateChecks, targetSnapshot, currentSnapshot, moduleInjector)
3123 .pipe(operators.mergeMap(function (canDeactivate) {
3124 return canDeactivate && isBoolean(canDeactivate) ?
3125 runCanActivateChecks(targetSnapshot, canActivateChecks, moduleInjector, forwardEvent) :
3126 rxjs.of(canDeactivate);
3127 }), operators.map(function (guardsResult) { return (__assign({}, t, { guardsResult: guardsResult })); }));
3128 }));
3129 };
3130 }
3131 function runCanDeactivateChecks(checks, futureRSS, currRSS, moduleInjector) {
3132 return rxjs.from(checks).pipe(operators.mergeMap(function (check) {
3133 return runCanDeactivate(check.component, check.route, currRSS, futureRSS, moduleInjector);
3134 }), operators.first(function (result) { return result !== true; }, true));
3135 }
3136 function runCanActivateChecks(futureSnapshot, checks, moduleInjector, forwardEvent) {
3137 return rxjs.from(checks).pipe(operators.concatMap(function (check) {
3138 return rxjs.from([
3139 fireChildActivationStart(check.route.parent, forwardEvent),
3140 fireActivationStart(check.route, forwardEvent),
3141 runCanActivateChild(futureSnapshot, check.path, moduleInjector),
3142 runCanActivate(futureSnapshot, check.route, moduleInjector)
3143 ])
3144 .pipe(operators.concatAll(), operators.first(function (result) {
3145 return result !== true;
3146 }, true));
3147 }), operators.first(function (result) { return result !== true; }, true));
3148 }
3149 /**
3150 * This should fire off `ActivationStart` events for each route being activated at this
3151 * level.
3152 * In other words, if you're activating `a` and `b` below, `path` will contain the
3153 * `ActivatedRouteSnapshot`s for both and we will fire `ActivationStart` for both. Always
3154 * return
3155 * `true` so checks continue to run.
3156 */
3157 function fireActivationStart(snapshot, forwardEvent) {
3158 if (snapshot !== null && forwardEvent) {
3159 forwardEvent(new ActivationStart(snapshot));
3160 }
3161 return rxjs.of(true);
3162 }
3163 /**
3164 * This should fire off `ChildActivationStart` events for each route being activated at this
3165 * level.
3166 * In other words, if you're activating `a` and `b` below, `path` will contain the
3167 * `ActivatedRouteSnapshot`s for both and we will fire `ChildActivationStart` for both. Always
3168 * return
3169 * `true` so checks continue to run.
3170 */
3171 function fireChildActivationStart(snapshot, forwardEvent) {
3172 if (snapshot !== null && forwardEvent) {
3173 forwardEvent(new ChildActivationStart(snapshot));
3174 }
3175 return rxjs.of(true);
3176 }
3177 function runCanActivate(futureRSS, futureARS, moduleInjector) {
3178 var canActivate = futureARS.routeConfig ? futureARS.routeConfig.canActivate : null;
3179 if (!canActivate || canActivate.length === 0)
3180 return rxjs.of(true);
3181 var canActivateObservables = canActivate.map(function (c) {
3182 return rxjs.defer(function () {
3183 var guard = getToken(c, futureARS, moduleInjector);
3184 var observable;
3185 if (isCanActivate(guard)) {
3186 observable = wrapIntoObservable(guard.canActivate(futureARS, futureRSS));
3187 }
3188 else if (isFunction(guard)) {
3189 observable = wrapIntoObservable(guard(futureARS, futureRSS));
3190 }
3191 else {
3192 throw new Error('Invalid CanActivate guard');
3193 }
3194 return observable.pipe(operators.first());
3195 });
3196 });
3197 return rxjs.of(canActivateObservables).pipe(prioritizedGuardValue());
3198 }
3199 function runCanActivateChild(futureRSS, path, moduleInjector) {
3200 var futureARS = path[path.length - 1];
3201 var canActivateChildGuards = path.slice(0, path.length - 1)
3202 .reverse()
3203 .map(function (p) { return getCanActivateChild(p); })
3204 .filter(function (_) { return _ !== null; });
3205 var canActivateChildGuardsMapped = canActivateChildGuards.map(function (d) {
3206 return rxjs.defer(function () {
3207 var guardsMapped = d.guards.map(function (c) {
3208 var guard = getToken(c, d.node, moduleInjector);
3209 var observable;
3210 if (isCanActivateChild(guard)) {
3211 observable = wrapIntoObservable(guard.canActivateChild(futureARS, futureRSS));
3212 }
3213 else if (isFunction(guard)) {
3214 observable = wrapIntoObservable(guard(futureARS, futureRSS));
3215 }
3216 else {
3217 throw new Error('Invalid CanActivateChild guard');
3218 }
3219 return observable.pipe(operators.first());
3220 });
3221 return rxjs.of(guardsMapped).pipe(prioritizedGuardValue());
3222 });
3223 });
3224 return rxjs.of(canActivateChildGuardsMapped).pipe(prioritizedGuardValue());
3225 }
3226 function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector) {
3227 var canDeactivate = currARS && currARS.routeConfig ? currARS.routeConfig.canDeactivate : null;
3228 if (!canDeactivate || canDeactivate.length === 0)
3229 return rxjs.of(true);
3230 var canDeactivateObservables = canDeactivate.map(function (c) {
3231 var guard = getToken(c, currARS, moduleInjector);
3232 var observable;
3233 if (isCanDeactivate(guard)) {
3234 observable =
3235 wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
3236 }
3237 else if (isFunction(guard)) {
3238 observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
3239 }
3240 else {
3241 throw new Error('Invalid CanDeactivate guard');
3242 }
3243 return observable.pipe(operators.first());
3244 });
3245 return rxjs.of(canDeactivateObservables).pipe(prioritizedGuardValue());
3246 }
3247
3248 /**
3249 * @license
3250 * Copyright Google Inc. All Rights Reserved.
3251 *
3252 * Use of this source code is governed by an MIT-style license that can be
3253 * found in the LICENSE file at https://angular.io/license
3254 */
3255 var NoMatch$1 = /** @class */ (function () {
3256 function NoMatch() {
3257 }
3258 return NoMatch;
3259 }());
3260 function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
3261 if (paramsInheritanceStrategy === void 0) { paramsInheritanceStrategy = 'emptyOnly'; }
3262 if (relativeLinkResolution === void 0) { relativeLinkResolution = 'legacy'; }
3263 return new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
3264 .recognize();
3265 }
3266 var Recognizer = /** @class */ (function () {
3267 function Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution) {
3268 this.rootComponentType = rootComponentType;
3269 this.config = config;
3270 this.urlTree = urlTree;
3271 this.url = url;
3272 this.paramsInheritanceStrategy = paramsInheritanceStrategy;
3273 this.relativeLinkResolution = relativeLinkResolution;
3274 }
3275 Recognizer.prototype.recognize = function () {
3276 try {
3277 var rootSegmentGroup = split$1(this.urlTree.root, [], [], this.config, this.relativeLinkResolution).segmentGroup;
3278 var children = this.processSegmentGroup(this.config, rootSegmentGroup, PRIMARY_OUTLET);
3279 var root = new ActivatedRouteSnapshot([], Object.freeze({}), Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, {}, PRIMARY_OUTLET, this.rootComponentType, null, this.urlTree.root, -1, {});
3280 var rootNode = new TreeNode(root, children);
3281 var routeState = new RouterStateSnapshot(this.url, rootNode);
3282 this.inheritParamsAndData(routeState._root);
3283 return rxjs.of(routeState);
3284 }
3285 catch (e) {
3286 return new rxjs.Observable(function (obs) { return obs.error(e); });
3287 }
3288 };
3289 Recognizer.prototype.inheritParamsAndData = function (routeNode) {
3290 var _this = this;
3291 var route = routeNode.value;
3292 var i = inheritedParamsDataResolve(route, this.paramsInheritanceStrategy);
3293 route.params = Object.freeze(i.params);
3294 route.data = Object.freeze(i.data);
3295 routeNode.children.forEach(function (n) { return _this.inheritParamsAndData(n); });
3296 };
3297 Recognizer.prototype.processSegmentGroup = function (config, segmentGroup, outlet) {
3298 if (segmentGroup.segments.length === 0 && segmentGroup.hasChildren()) {
3299 return this.processChildren(config, segmentGroup);
3300 }
3301 return this.processSegment(config, segmentGroup, segmentGroup.segments, outlet);
3302 };
3303 Recognizer.prototype.processChildren = function (config, segmentGroup) {
3304 var _this = this;
3305 var children = mapChildrenIntoArray(segmentGroup, function (child, childOutlet) { return _this.processSegmentGroup(config, child, childOutlet); });
3306 checkOutletNameUniqueness(children);
3307 sortActivatedRouteSnapshots(children);
3308 return children;
3309 };
3310 Recognizer.prototype.processSegment = function (config, segmentGroup, segments, outlet) {
3311 var e_1, _a;
3312 try {
3313 for (var config_1 = __values(config), config_1_1 = config_1.next(); !config_1_1.done; config_1_1 = config_1.next()) {
3314 var r = config_1_1.value;
3315 try {
3316 return this.processSegmentAgainstRoute(r, segmentGroup, segments, outlet);
3317 }
3318 catch (e) {
3319 if (!(e instanceof NoMatch$1))
3320 throw e;
3321 }
3322 }
3323 }
3324 catch (e_1_1) { e_1 = { error: e_1_1 }; }
3325 finally {
3326 try {
3327 if (config_1_1 && !config_1_1.done && (_a = config_1.return)) _a.call(config_1);
3328 }
3329 finally { if (e_1) throw e_1.error; }
3330 }
3331 if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) {
3332 return [];
3333 }
3334 throw new NoMatch$1();
3335 };
3336 Recognizer.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) {
3337 return segments.length === 0 && !segmentGroup.children[outlet];
3338 };
3339 Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, segments, outlet) {
3340 if (route.redirectTo)
3341 throw new NoMatch$1();
3342 if ((route.outlet || PRIMARY_OUTLET) !== outlet)
3343 throw new NoMatch$1();
3344 var snapshot;
3345 var consumedSegments = [];
3346 var rawSlicedSegments = [];
3347 if (route.path === '**') {
3348 var params = segments.length > 0 ? last(segments).parameters : {};
3349 snapshot = new ActivatedRouteSnapshot(segments, params, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + segments.length, getResolve(route));
3350 }
3351 else {
3352 var result = match$1(rawSegment, route, segments);
3353 consumedSegments = result.consumedSegments;
3354 rawSlicedSegments = segments.slice(result.lastChild);
3355 snapshot = new ActivatedRouteSnapshot(consumedSegments, result.parameters, Object.freeze(__assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), outlet, route.component, route, getSourceSegmentGroup(rawSegment), getPathIndexShift(rawSegment) + consumedSegments.length, getResolve(route));
3356 }
3357 var childConfig = getChildConfig(route);
3358 var _a = split$1(rawSegment, consumedSegments, rawSlicedSegments, childConfig, this.relativeLinkResolution), segmentGroup = _a.segmentGroup, slicedSegments = _a.slicedSegments;
3359 if (slicedSegments.length === 0 && segmentGroup.hasChildren()) {
3360 var children_1 = this.processChildren(childConfig, segmentGroup);
3361 return [new TreeNode(snapshot, children_1)];
3362 }
3363 if (childConfig.length === 0 && slicedSegments.length === 0) {
3364 return [new TreeNode(snapshot, [])];
3365 }
3366 var children = this.processSegment(childConfig, segmentGroup, slicedSegments, PRIMARY_OUTLET);
3367 return [new TreeNode(snapshot, children)];
3368 };
3369 return Recognizer;
3370 }());
3371 function sortActivatedRouteSnapshots(nodes) {
3372 nodes.sort(function (a, b) {
3373 if (a.value.outlet === PRIMARY_OUTLET)
3374 return -1;
3375 if (b.value.outlet === PRIMARY_OUTLET)
3376 return 1;
3377 return a.value.outlet.localeCompare(b.value.outlet);
3378 });
3379 }
3380 function getChildConfig(route) {
3381 if (route.children) {
3382 return route.children;
3383 }
3384 if (route.loadChildren) {
3385 return route._loadedConfig.routes;
3386 }
3387 return [];
3388 }
3389 function match$1(segmentGroup, route, segments) {
3390 if (route.path === '') {
3391 if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
3392 throw new NoMatch$1();
3393 }
3394 return { consumedSegments: [], lastChild: 0, parameters: {} };
3395 }
3396 var matcher = route.matcher || defaultUrlMatcher;
3397 var res = matcher(segments, segmentGroup, route);
3398 if (!res)
3399 throw new NoMatch$1();
3400 var posParams = {};
3401 forEach(res.posParams, function (v, k) { posParams[k] = v.path; });
3402 var parameters = res.consumed.length > 0 ? __assign({}, posParams, res.consumed[res.consumed.length - 1].parameters) :
3403 posParams;
3404 return { consumedSegments: res.consumed, lastChild: res.consumed.length, parameters: parameters };
3405 }
3406 function checkOutletNameUniqueness(nodes) {
3407 var names = {};
3408 nodes.forEach(function (n) {
3409 var routeWithSameOutletName = names[n.value.outlet];
3410 if (routeWithSameOutletName) {
3411 var p = routeWithSameOutletName.url.map(function (s) { return s.toString(); }).join('/');
3412 var c = n.value.url.map(function (s) { return s.toString(); }).join('/');
3413 throw new Error("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
3414 }
3415 names[n.value.outlet] = n.value;
3416 });
3417 }
3418 function getSourceSegmentGroup(segmentGroup) {
3419 var s = segmentGroup;
3420 while (s._sourceSegment) {
3421 s = s._sourceSegment;
3422 }
3423 return s;
3424 }
3425 function getPathIndexShift(segmentGroup) {
3426 var s = segmentGroup;
3427 var res = (s._segmentIndexShift ? s._segmentIndexShift : 0);
3428 while (s._sourceSegment) {
3429 s = s._sourceSegment;
3430 res += (s._segmentIndexShift ? s._segmentIndexShift : 0);
3431 }
3432 return res - 1;
3433 }
3434 function split$1(segmentGroup, consumedSegments, slicedSegments, config, relativeLinkResolution) {
3435 if (slicedSegments.length > 0 &&
3436 containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) {
3437 var s_1 = new UrlSegmentGroup(consumedSegments, createChildrenForEmptyPaths(segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children)));
3438 s_1._sourceSegment = segmentGroup;
3439 s_1._segmentIndexShift = consumedSegments.length;
3440 return { segmentGroup: s_1, slicedSegments: [] };
3441 }
3442 if (slicedSegments.length === 0 &&
3443 containsEmptyPathMatches(segmentGroup, slicedSegments, config)) {
3444 var s_2 = new UrlSegmentGroup(segmentGroup.segments, addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, config, segmentGroup.children, relativeLinkResolution));
3445 s_2._sourceSegment = segmentGroup;
3446 s_2._segmentIndexShift = consumedSegments.length;
3447 return { segmentGroup: s_2, slicedSegments: slicedSegments };
3448 }
3449 var s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children);
3450 s._sourceSegment = segmentGroup;
3451 s._segmentIndexShift = consumedSegments.length;
3452 return { segmentGroup: s, slicedSegments: slicedSegments };
3453 }
3454 function addEmptyPathsToChildrenIfNeeded(segmentGroup, consumedSegments, slicedSegments, routes, children, relativeLinkResolution) {
3455 var e_2, _a;
3456 var res = {};
3457 try {
3458 for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
3459 var r = routes_1_1.value;
3460 if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet$1(r)]) {
3461 var s = new UrlSegmentGroup([], {});
3462 s._sourceSegment = segmentGroup;
3463 if (relativeLinkResolution === 'legacy') {
3464 s._segmentIndexShift = segmentGroup.segments.length;
3465 }
3466 else {
3467 s._segmentIndexShift = consumedSegments.length;
3468 }
3469 res[getOutlet$1(r)] = s;
3470 }
3471 }
3472 }
3473 catch (e_2_1) { e_2 = { error: e_2_1 }; }
3474 finally {
3475 try {
3476 if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
3477 }
3478 finally { if (e_2) throw e_2.error; }
3479 }
3480 return __assign({}, children, res);
3481 }
3482 function createChildrenForEmptyPaths(segmentGroup, consumedSegments, routes, primarySegment) {
3483 var e_3, _a;
3484 var res = {};
3485 res[PRIMARY_OUTLET] = primarySegment;
3486 primarySegment._sourceSegment = segmentGroup;
3487 primarySegment._segmentIndexShift = consumedSegments.length;
3488 try {
3489 for (var routes_2 = __values(routes), routes_2_1 = routes_2.next(); !routes_2_1.done; routes_2_1 = routes_2.next()) {
3490 var r = routes_2_1.value;
3491 if (r.path === '' && getOutlet$1(r) !== PRIMARY_OUTLET) {
3492 var s = new UrlSegmentGroup([], {});
3493 s._sourceSegment = segmentGroup;
3494 s._segmentIndexShift = consumedSegments.length;
3495 res[getOutlet$1(r)] = s;
3496 }
3497 }
3498 }
3499 catch (e_3_1) { e_3 = { error: e_3_1 }; }
3500 finally {
3501 try {
3502 if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
3503 }
3504 finally { if (e_3) throw e_3.error; }
3505 }
3506 return res;
3507 }
3508 function containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, routes) {
3509 return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet$1(r) !== PRIMARY_OUTLET; });
3510 }
3511 function containsEmptyPathMatches(segmentGroup, slicedSegments, routes) {
3512 return routes.some(function (r) { return emptyPathMatch(segmentGroup, slicedSegments, r); });
3513 }
3514 function emptyPathMatch(segmentGroup, slicedSegments, r) {
3515 if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') {
3516 return false;
3517 }
3518 return r.path === '' && r.redirectTo === undefined;
3519 }
3520 function getOutlet$1(route) {
3521 return route.outlet || PRIMARY_OUTLET;
3522 }
3523 function getData(route) {
3524 return route.data || {};
3525 }
3526 function getResolve(route) {
3527 return route.resolve || {};
3528 }
3529
3530 /**
3531 * @license
3532 * Copyright Google Inc. All Rights Reserved.
3533 *
3534 * Use of this source code is governed by an MIT-style license that can be
3535 * found in the LICENSE file at https://angular.io/license
3536 */
3537 function recognize$1(rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
3538 return function (source) {
3539 return source.pipe(operators.mergeMap(function (t) { return recognize(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
3540 .pipe(operators.map(function (targetSnapshot) { return (__assign({}, t, { targetSnapshot: targetSnapshot })); })); }));
3541 };
3542 }
3543
3544 /**
3545 * @license
3546 * Copyright Google Inc. All Rights Reserved.
3547 *
3548 * Use of this source code is governed by an MIT-style license that can be
3549 * found in the LICENSE file at https://angular.io/license
3550 */
3551 function resolveData(paramsInheritanceStrategy, moduleInjector) {
3552 return function (source) {
3553 return source.pipe(operators.mergeMap(function (t) {
3554 var targetSnapshot = t.targetSnapshot, canActivateChecks = t.guards.canActivateChecks;
3555 if (!canActivateChecks.length) {
3556 return rxjs.of(t);
3557 }
3558 return rxjs.from(canActivateChecks)
3559 .pipe(operators.concatMap(function (check) { return runResolve(check.route, targetSnapshot, paramsInheritanceStrategy, moduleInjector); }), operators.reduce(function (_, __) { return _; }), operators.map(function (_) { return t; }));
3560 }));
3561 };
3562 }
3563 function runResolve(futureARS, futureRSS, paramsInheritanceStrategy, moduleInjector) {
3564 var resolve = futureARS._resolve;
3565 return resolveNode(resolve, futureARS, futureRSS, moduleInjector)
3566 .pipe(operators.map(function (resolvedData) {
3567 futureARS._resolvedData = resolvedData;
3568 futureARS.data = __assign({}, futureARS.data, inheritedParamsDataResolve(futureARS, paramsInheritanceStrategy).resolve);
3569 return null;
3570 }));
3571 }
3572 function resolveNode(resolve, futureARS, futureRSS, moduleInjector) {
3573 var keys = Object.keys(resolve);
3574 if (keys.length === 0) {
3575 return rxjs.of({});
3576 }
3577 if (keys.length === 1) {
3578 var key_1 = keys[0];
3579 return getResolver(resolve[key_1], futureARS, futureRSS, moduleInjector)
3580 .pipe(operators.map(function (value) {
3581 var _a;
3582 return _a = {}, _a[key_1] = value, _a;
3583 }));
3584 }
3585 var data = {};
3586 var runningResolvers$ = rxjs.from(keys).pipe(operators.mergeMap(function (key) {
3587 return getResolver(resolve[key], futureARS, futureRSS, moduleInjector)
3588 .pipe(operators.map(function (value) {
3589 data[key] = value;
3590 return value;
3591 }));
3592 }));
3593 return runningResolvers$.pipe(operators.last(), operators.map(function () { return data; }));
3594 }
3595 function getResolver(injectionToken, futureARS, futureRSS, moduleInjector) {
3596 var resolver = getToken(injectionToken, futureARS, moduleInjector);
3597 return resolver.resolve ? wrapIntoObservable(resolver.resolve(futureARS, futureRSS)) :
3598 wrapIntoObservable(resolver(futureARS, futureRSS));
3599 }
3600
3601 /**
3602 * @license
3603 * Copyright Google Inc. All Rights Reserved.
3604 *
3605 * Use of this source code is governed by an MIT-style license that can be
3606 * found in the LICENSE file at https://angular.io/license
3607 */
3608 /**
3609 * Perform a side effect through a switchMap for every emission on the source Observable,
3610 * but return an Observable that is identical to the source. It's essentially the same as
3611 * the `tap` operator, but if the side effectful `next` function returns an ObservableInput,
3612 * it will wait before continuing with the original value.
3613 */
3614 function switchTap(next) {
3615 return function (source) {
3616 return source.pipe(operators.switchMap(function (v) {
3617 var nextResult = next(v);
3618 if (nextResult) {
3619 return rxjs.from(nextResult).pipe(operators.map(function () { return v; }));
3620 }
3621 return rxjs.from([v]);
3622 }));
3623 };
3624 }
3625
3626 /**
3627 * @license
3628 * Copyright Google Inc. All Rights Reserved.
3629 *
3630 * Use of this source code is governed by an MIT-style license that can be
3631 * found in the LICENSE file at https://angular.io/license
3632 */
3633 /**
3634 * @description
3635 *
3636 * Provides a way to customize when activated routes get reused.
3637 *
3638 * @publicApi
3639 */
3640 var RouteReuseStrategy = /** @class */ (function () {
3641 function RouteReuseStrategy() {
3642 }
3643 return RouteReuseStrategy;
3644 }());
3645 /**
3646 * Does not detach any subtrees. Reuses routes as long as their route config is the same.
3647 */
3648 var DefaultRouteReuseStrategy = /** @class */ (function () {
3649 function DefaultRouteReuseStrategy() {
3650 }
3651 DefaultRouteReuseStrategy.prototype.shouldDetach = function (route) { return false; };
3652 DefaultRouteReuseStrategy.prototype.store = function (route, detachedTree) { };
3653 DefaultRouteReuseStrategy.prototype.shouldAttach = function (route) { return false; };
3654 DefaultRouteReuseStrategy.prototype.retrieve = function (route) { return null; };
3655 DefaultRouteReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
3656 return future.routeConfig === curr.routeConfig;
3657 };
3658 return DefaultRouteReuseStrategy;
3659 }());
3660
3661 /**
3662 * @license
3663 * Copyright Google Inc. All Rights Reserved.
3664 *
3665 * Use of this source code is governed by an MIT-style license that can be
3666 * found in the LICENSE file at https://angular.io/license
3667 */
3668 /**
3669 * @docsNotRequired
3670 * @publicApi
3671 */
3672 var ROUTES = new core.InjectionToken('ROUTES');
3673 var RouterConfigLoader = /** @class */ (function () {
3674 function RouterConfigLoader(loader, compiler, onLoadStartListener, onLoadEndListener) {
3675 this.loader = loader;
3676 this.compiler = compiler;
3677 this.onLoadStartListener = onLoadStartListener;
3678 this.onLoadEndListener = onLoadEndListener;
3679 }
3680 RouterConfigLoader.prototype.load = function (parentInjector, route) {
3681 var _this = this;
3682 if (this.onLoadStartListener) {
3683 this.onLoadStartListener(route);
3684 }
3685 var moduleFactory$ = this.loadModuleFactory(route.loadChildren);
3686 return moduleFactory$.pipe(operators.map(function (factory) {
3687 if (_this.onLoadEndListener) {
3688 _this.onLoadEndListener(route);
3689 }
3690 var module = factory.create(parentInjector);
3691 return new LoadedRouterConfig(flatten(module.injector.get(ROUTES)).map(standardizeConfig), module);
3692 }));
3693 };
3694 RouterConfigLoader.prototype.loadModuleFactory = function (loadChildren) {
3695 var _this = this;
3696 if (typeof loadChildren === 'string') {
3697 return rxjs.from(this.loader.load(loadChildren));
3698 }
3699 else {
3700 return wrapIntoObservable(loadChildren()).pipe(operators.mergeMap(function (t) {
3701 if (t instanceof core.NgModuleFactory) {
3702 return rxjs.of(t);
3703 }
3704 else {
3705 return rxjs.from(_this.compiler.compileModuleAsync(t));
3706 }
3707 }));
3708 }
3709 };
3710 return RouterConfigLoader;
3711 }());
3712
3713 /**
3714 * @license
3715 * Copyright Google Inc. All Rights Reserved.
3716 *
3717 * Use of this source code is governed by an MIT-style license that can be
3718 * found in the LICENSE file at https://angular.io/license
3719 */
3720 /**
3721 * @description
3722 *
3723 * Provides a way to migrate AngularJS applications to Angular.
3724 *
3725 * @publicApi
3726 */
3727 var UrlHandlingStrategy = /** @class */ (function () {
3728 function UrlHandlingStrategy() {
3729 }
3730 return UrlHandlingStrategy;
3731 }());
3732 /**
3733 * @publicApi
3734 */
3735 var DefaultUrlHandlingStrategy = /** @class */ (function () {
3736 function DefaultUrlHandlingStrategy() {
3737 }
3738 DefaultUrlHandlingStrategy.prototype.shouldProcessUrl = function (url) { return true; };
3739 DefaultUrlHandlingStrategy.prototype.extract = function (url) { return url; };
3740 DefaultUrlHandlingStrategy.prototype.merge = function (newUrlPart, wholeUrl) { return newUrlPart; };
3741 return DefaultUrlHandlingStrategy;
3742 }());
3743
3744 /**
3745 * @license
3746 * Copyright Google Inc. All Rights Reserved.
3747 *
3748 * Use of this source code is governed by an MIT-style license that can be
3749 * found in the LICENSE file at https://angular.io/license
3750 */
3751 function defaultErrorHandler(error) {
3752 throw error;
3753 }
3754 function defaultMalformedUriErrorHandler(error, urlSerializer, url) {
3755 return urlSerializer.parse('/');
3756 }
3757 /**
3758 * @internal
3759 */
3760 function defaultRouterHook(snapshot, runExtras) {
3761 return rxjs.of(null);
3762 }
3763 /**
3764 * @description
3765 *
3766 * An NgModule that provides navigation and URL manipulation capabilities.
3767 *
3768 * @see `Route`.
3769 * @see [Routing and Navigation Guide](guide/router).
3770 *
3771 * @ngModule RouterModule
3772 *
3773 * @publicApi
3774 */
3775 var Router = /** @class */ (function () {
3776 /**
3777 * Creates the router service.
3778 */
3779 // TODO: vsavkin make internal after the final is out.
3780 function Router(rootComponentType, urlSerializer, rootContexts, location, injector, loader, compiler, config) {
3781 var _this = this;
3782 this.rootComponentType = rootComponentType;
3783 this.urlSerializer = urlSerializer;
3784 this.rootContexts = rootContexts;
3785 this.location = location;
3786 this.config = config;
3787 this.lastSuccessfulNavigation = null;
3788 this.currentNavigation = null;
3789 this.navigationId = 0;
3790 this.isNgZoneEnabled = false;
3791 /**
3792 * An event stream for routing events in this NgModule.
3793 */
3794 this.events = new rxjs.Subject();
3795 /**
3796 * A handler for navigation errors in this NgModule.
3797 */
3798 this.errorHandler = defaultErrorHandler;
3799 /**
3800 * Malformed uri error handler is invoked when `Router.parseUrl(url)` throws an
3801 * error due to containing an invalid character. The most common case would be a `%` sign
3802 * that's not encoded and is not part of a percent encoded sequence.
3803 */
3804 this.malformedUriErrorHandler = defaultMalformedUriErrorHandler;
3805 /**
3806 * True if at least one navigation event has occurred,
3807 * false otherwise.
3808 */
3809 this.navigated = false;
3810 this.lastSuccessfulId = -1;
3811 /**
3812 * Hooks that enable you to pause navigation,
3813 * either before or after the preactivation phase.
3814 * Used by `RouterModule`.
3815 *
3816 * @internal
3817 */
3818 this.hooks = {
3819 beforePreactivation: defaultRouterHook,
3820 afterPreactivation: defaultRouterHook
3821 };
3822 /**
3823 * Extracts and merges URLs. Used for AngularJS to Angular migrations.
3824 */
3825 this.urlHandlingStrategy = new DefaultUrlHandlingStrategy();
3826 /**
3827 * The strategy for re-using routes.
3828 */
3829 this.routeReuseStrategy = new DefaultRouteReuseStrategy();
3830 /**
3831 * How to handle a navigation request to the current URL. One of:
3832 * - `'ignore'` : The router ignores the request.
3833 * - `'reload'` : The router reloads the URL. Use to implement a "refresh" feature.
3834 */
3835 this.onSameUrlNavigation = 'ignore';
3836 /**
3837 * How to merge parameters, data, and resolved data from parent to child
3838 * routes. One of:
3839 *
3840 * - `'emptyOnly'` : Inherit parent parameters, data, and resolved data
3841 * for path-less or component-less routes.
3842 * - `'always'` : Inherit parent parameters, data, and resolved data
3843 * for all child routes.
3844 */
3845 this.paramsInheritanceStrategy = 'emptyOnly';
3846 /**
3847 * Defines when the router updates the browser URL. The default behavior is to update after
3848 * successful navigation. However, some applications may prefer a mode where the URL gets
3849 * updated at the beginning of navigation. The most common use case would be updating the
3850 * URL early so if navigation fails, you can show an error message with the URL that failed.
3851 * Available options are:
3852 *
3853 * - `'deferred'`, the default, updates the browser URL after navigation has finished.
3854 * - `'eager'`, updates browser URL at the beginning of navigation.
3855 */
3856 this.urlUpdateStrategy = 'deferred';
3857 /**
3858 * See {@link RouterModule} for more information.
3859 */
3860 this.relativeLinkResolution = 'legacy';
3861 var onLoadStart = function (r) { return _this.triggerEvent(new RouteConfigLoadStart(r)); };
3862 var onLoadEnd = function (r) { return _this.triggerEvent(new RouteConfigLoadEnd(r)); };
3863 this.ngModule = injector.get(core.NgModuleRef);
3864 this.console = injector.get(core.ɵConsole);
3865 var ngZone = injector.get(core.NgZone);
3866 this.isNgZoneEnabled = ngZone instanceof core.NgZone;
3867 this.resetConfig(config);
3868 this.currentUrlTree = createEmptyUrlTree();
3869 this.rawUrlTree = this.currentUrlTree;
3870 this.browserUrlTree = this.currentUrlTree;
3871 this.configLoader = new RouterConfigLoader(loader, compiler, onLoadStart, onLoadEnd);
3872 this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
3873 this.transitions = new rxjs.BehaviorSubject({
3874 id: 0,
3875 currentUrlTree: this.currentUrlTree,
3876 currentRawUrl: this.currentUrlTree,
3877 extractedUrl: this.urlHandlingStrategy.extract(this.currentUrlTree),
3878 urlAfterRedirects: this.urlHandlingStrategy.extract(this.currentUrlTree),
3879 rawUrl: this.currentUrlTree,
3880 extras: {},
3881 resolve: null,
3882 reject: null,
3883 promise: Promise.resolve(true),
3884 source: 'imperative',
3885 restoredState: null,
3886 currentSnapshot: this.routerState.snapshot,
3887 targetSnapshot: null,
3888 currentRouterState: this.routerState,
3889 targetRouterState: null,
3890 guards: { canActivateChecks: [], canDeactivateChecks: [] },
3891 guardsResult: null,
3892 });
3893 this.navigations = this.setupNavigations(this.transitions);
3894 this.processNavigations();
3895 }
3896 Router.prototype.setupNavigations = function (transitions) {
3897 var _this = this;
3898 var eventsSubject = this.events;
3899 return transitions.pipe(operators.filter(function (t) { return t.id !== 0; }),
3900 // Extract URL
3901 operators.map(function (t) { return (__assign({}, t, { extractedUrl: _this.urlHandlingStrategy.extract(t.rawUrl) })); }),
3902 // Using switchMap so we cancel executing navigations when a new one comes in
3903 operators.switchMap(function (t) {
3904 var completed = false;
3905 var errored = false;
3906 return rxjs.of(t).pipe(
3907 // Store the Navigation object
3908 operators.tap(function (t) {
3909 _this.currentNavigation = {
3910 id: t.id,
3911 initialUrl: t.currentRawUrl,
3912 extractedUrl: t.extractedUrl,
3913 trigger: t.source,
3914 extras: t.extras,
3915 previousNavigation: _this.lastSuccessfulNavigation ? __assign({}, _this.lastSuccessfulNavigation, { previousNavigation: null }) :
3916 null
3917 };
3918 }), operators.switchMap(function (t) {
3919 var urlTransition = !_this.navigated || t.extractedUrl.toString() !== _this.browserUrlTree.toString();
3920 var processCurrentUrl = (_this.onSameUrlNavigation === 'reload' ? true : urlTransition) &&
3921 _this.urlHandlingStrategy.shouldProcessUrl(t.rawUrl);
3922 if (processCurrentUrl) {
3923 return rxjs.of(t).pipe(
3924 // Fire NavigationStart event
3925 operators.switchMap(function (t) {
3926 var transition = _this.transitions.getValue();
3927 eventsSubject.next(new NavigationStart(t.id, _this.serializeUrl(t.extractedUrl), t.source, t.restoredState));
3928 if (transition !== _this.transitions.getValue()) {
3929 return rxjs.EMPTY;
3930 }
3931 return [t];
3932 }),
3933 // This delay is required to match old behavior that forced navigation to
3934 // always be async
3935 operators.switchMap(function (t) { return Promise.resolve(t); }),
3936 // ApplyRedirects
3937 applyRedirects$1(_this.ngModule.injector, _this.configLoader, _this.urlSerializer, _this.config),
3938 // Update the currentNavigation
3939 operators.tap(function (t) {
3940 _this.currentNavigation = __assign({}, _this.currentNavigation, { finalUrl: t.urlAfterRedirects });
3941 }),
3942 // Recognize
3943 recognize$1(_this.rootComponentType, _this.config, function (url) { return _this.serializeUrl(url); }, _this.paramsInheritanceStrategy, _this.relativeLinkResolution),
3944 // Update URL if in `eager` update mode
3945 operators.tap(function (t) {
3946 if (_this.urlUpdateStrategy === 'eager') {
3947 if (!t.extras.skipLocationChange) {
3948 _this.setBrowserUrl(t.urlAfterRedirects, !!t.extras.replaceUrl, t.id, t.extras.state);
3949 }
3950 _this.browserUrlTree = t.urlAfterRedirects;
3951 }
3952 }),
3953 // Fire RoutesRecognized
3954 operators.tap(function (t) {
3955 var routesRecognized = new RoutesRecognized(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
3956 eventsSubject.next(routesRecognized);
3957 }));
3958 }
3959 else {
3960 var processPreviousUrl = urlTransition && _this.rawUrlTree &&
3961 _this.urlHandlingStrategy.shouldProcessUrl(_this.rawUrlTree);
3962 /* When the current URL shouldn't be processed, but the previous one was, we
3963 * handle this "error condition" by navigating to the previously successful URL,
3964 * but leaving the URL intact.*/
3965 if (processPreviousUrl) {
3966 var id = t.id, extractedUrl = t.extractedUrl, source = t.source, restoredState = t.restoredState, extras = t.extras;
3967 var navStart = new NavigationStart(id, _this.serializeUrl(extractedUrl), source, restoredState);
3968 eventsSubject.next(navStart);
3969 var targetSnapshot = createEmptyState(extractedUrl, _this.rootComponentType).snapshot;
3970 return rxjs.of(__assign({}, t, { targetSnapshot: targetSnapshot, urlAfterRedirects: extractedUrl, extras: __assign({}, extras, { skipLocationChange: false, replaceUrl: false }) }));
3971 }
3972 else {
3973 /* When neither the current or previous URL can be processed, do nothing other
3974 * than update router's internal reference to the current "settled" URL. This
3975 * way the next navigation will be coming from the current URL in the browser.
3976 */
3977 _this.rawUrlTree = t.rawUrl;
3978 _this.browserUrlTree = t.urlAfterRedirects;
3979 t.resolve(null);
3980 return rxjs.EMPTY;
3981 }
3982 }
3983 }),
3984 // Before Preactivation
3985 switchTap(function (t) {
3986 var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _a = t.extras, skipLocationChange = _a.skipLocationChange, replaceUrl = _a.replaceUrl;
3987 return _this.hooks.beforePreactivation(targetSnapshot, {
3988 navigationId: navigationId,
3989 appliedUrlTree: appliedUrlTree,
3990 rawUrlTree: rawUrlTree,
3991 skipLocationChange: !!skipLocationChange,
3992 replaceUrl: !!replaceUrl,
3993 });
3994 }),
3995 // --- GUARDS ---
3996 operators.tap(function (t) {
3997 var guardsStart = new GuardsCheckStart(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
3998 _this.triggerEvent(guardsStart);
3999 }), operators.map(function (t) { return (__assign({}, t, { guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, _this.rootContexts) })); }), checkGuards(_this.ngModule.injector, function (evt) { return _this.triggerEvent(evt); }), operators.tap(function (t) {
4000 if (isUrlTree(t.guardsResult)) {
4001 var error = navigationCancelingError("Redirecting to \"" + _this.serializeUrl(t.guardsResult) + "\"");
4002 error.url = t.guardsResult;
4003 throw error;
4004 }
4005 }), operators.tap(function (t) {
4006 var guardsEnd = new GuardsCheckEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
4007 _this.triggerEvent(guardsEnd);
4008 }), operators.filter(function (t) {
4009 if (!t.guardsResult) {
4010 _this.resetUrlToCurrentUrlTree();
4011 var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), '');
4012 eventsSubject.next(navCancel);
4013 t.resolve(false);
4014 return false;
4015 }
4016 return true;
4017 }),
4018 // --- RESOLVE ---
4019 switchTap(function (t) {
4020 if (t.guards.canActivateChecks.length) {
4021 return rxjs.of(t).pipe(operators.tap(function (t) {
4022 var resolveStart = new ResolveStart(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4023 _this.triggerEvent(resolveStart);
4024 }), resolveData(_this.paramsInheritanceStrategy, _this.ngModule.injector), //
4025 operators.tap(function (t) {
4026 var resolveEnd = new ResolveEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4027 _this.triggerEvent(resolveEnd);
4028 }));
4029 }
4030 return undefined;
4031 }),
4032 // --- AFTER PREACTIVATION ---
4033 switchTap(function (t) {
4034 var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _a = t.extras, skipLocationChange = _a.skipLocationChange, replaceUrl = _a.replaceUrl;
4035 return _this.hooks.afterPreactivation(targetSnapshot, {
4036 navigationId: navigationId,
4037 appliedUrlTree: appliedUrlTree,
4038 rawUrlTree: rawUrlTree,
4039 skipLocationChange: !!skipLocationChange,
4040 replaceUrl: !!replaceUrl,
4041 });
4042 }), operators.map(function (t) {
4043 var targetRouterState = createRouterState(_this.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4044 return (__assign({}, t, { targetRouterState: targetRouterState }));
4045 }),
4046 /* Once here, we are about to activate syncronously. The assumption is this will
4047 succeed, and user code may read from the Router service. Therefore before
4048 activation, we need to update router properties storing the current URL and the
4049 RouterState, as well as updated the browser URL. All this should happen *before*
4050 activating. */
4051 operators.tap(function (t) {
4052 _this.currentUrlTree = t.urlAfterRedirects;
4053 _this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, t.rawUrl);
4054 _this.routerState = t.targetRouterState;
4055 if (_this.urlUpdateStrategy === 'deferred') {
4056 if (!t.extras.skipLocationChange) {
4057 _this.setBrowserUrl(_this.rawUrlTree, !!t.extras.replaceUrl, t.id, t.extras.state);
4058 }
4059 _this.browserUrlTree = t.urlAfterRedirects;
4060 }
4061 }), activateRoutes(_this.rootContexts, _this.routeReuseStrategy, function (evt) { return _this.triggerEvent(evt); }), operators.tap({ next: function () { completed = true; }, complete: function () { completed = true; } }), operators.finalize(function () {
4062 /* When the navigation stream finishes either through error or success, we set the
4063 * `completed` or `errored` flag. However, there are some situations where we could
4064 * get here without either of those being set. For instance, a redirect during
4065 * NavigationStart. Therefore, this is a catch-all to make sure the NavigationCancel
4066 * event is fired when a navigation gets cancelled but not caught by other means. */
4067 if (!completed && !errored) {
4068 // Must reset to current URL tree here to ensure history.state is set. On a fresh
4069 // page load, if a new navigation comes in before a successful navigation
4070 // completes, there will be nothing in history.state.navigationId. This can cause
4071 // sync problems with AngularJS sync code which looks for a value here in order
4072 // to determine whether or not to handle a given popstate event or to leave it
4073 // to the Angualr router.
4074 _this.resetUrlToCurrentUrlTree();
4075 var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), "Navigation ID " + t.id + " is not equal to the current navigation id " + _this.navigationId);
4076 eventsSubject.next(navCancel);
4077 t.resolve(false);
4078 }
4079 // currentNavigation should always be reset to null here. If navigation was
4080 // successful, lastSuccessfulTransition will have already been set. Therefore we
4081 // can safely set currentNavigation to null here.
4082 _this.currentNavigation = null;
4083 }), operators.catchError(function (e) {
4084 errored = true;
4085 /* This error type is issued during Redirect, and is handled as a cancellation
4086 * rather than an error. */
4087 if (isNavigationCancelingError(e)) {
4088 var redirecting = isUrlTree(e.url);
4089 if (!redirecting) {
4090 // Set property only if we're not redirecting. If we landed on a page and
4091 // redirect to `/` route, the new navigation is going to see the `/` isn't
4092 // a change from the default currentUrlTree and won't navigate. This is
4093 // only applicable with initial navigation, so setting `navigated` only when
4094 // not redirecting resolves this scenario.
4095 _this.navigated = true;
4096 _this.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);
4097 }
4098 var navCancel = new NavigationCancel(t.id, _this.serializeUrl(t.extractedUrl), e.message);
4099 eventsSubject.next(navCancel);
4100 t.resolve(false);
4101 if (redirecting) {
4102 _this.navigateByUrl(e.url);
4103 }
4104 /* All other errors should reset to the router's internal URL reference to the
4105 * pre-error state. */
4106 }
4107 else {
4108 _this.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);
4109 var navError = new NavigationError(t.id, _this.serializeUrl(t.extractedUrl), e);
4110 eventsSubject.next(navError);
4111 try {
4112 t.resolve(_this.errorHandler(e));
4113 }
4114 catch (ee) {
4115 t.reject(ee);
4116 }
4117 }
4118 return rxjs.EMPTY;
4119 }));
4120 // TODO(jasonaden): remove cast once g3 is on updated TypeScript
4121 }));
4122 };
4123 /**
4124 * @internal
4125 * TODO: this should be removed once the constructor of the router made internal
4126 */
4127 Router.prototype.resetRootComponentType = function (rootComponentType) {
4128 this.rootComponentType = rootComponentType;
4129 // TODO: vsavkin router 4.0 should make the root component set to null
4130 // this will simplify the lifecycle of the router.
4131 this.routerState.root.component = this.rootComponentType;
4132 };
4133 Router.prototype.getTransition = function () {
4134 var transition = this.transitions.value;
4135 // This value needs to be set. Other values such as extractedUrl are set on initial navigation
4136 // but the urlAfterRedirects may not get set if we aren't processing the new URL *and* not
4137 // processing the previous URL.
4138 transition.urlAfterRedirects = this.browserUrlTree;
4139 return transition;
4140 };
4141 Router.prototype.setTransition = function (t) {
4142 this.transitions.next(__assign({}, this.getTransition(), t));
4143 };
4144 /**
4145 * Sets up the location change listener and performs the initial navigation.
4146 */
4147 Router.prototype.initialNavigation = function () {
4148 this.setUpLocationChangeListener();
4149 if (this.navigationId === 0) {
4150 this.navigateByUrl(this.location.path(true), { replaceUrl: true });
4151 }
4152 };
4153 /**
4154 * Sets up the location change listener.
4155 */
4156 Router.prototype.setUpLocationChangeListener = function () {
4157 var _this = this;
4158 // Don't need to use Zone.wrap any more, because zone.js
4159 // already patch onPopState, so location change callback will
4160 // run into ngZone
4161 if (!this.locationSubscription) {
4162 this.locationSubscription = this.location.subscribe(function (change) {
4163 var rawUrlTree = _this.parseUrl(change['url']);
4164 var source = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
4165 // Navigations coming from Angular router have a navigationId state property. When this
4166 // exists, restore the state.
4167 var state = change.state && change.state.navigationId ? change.state : null;
4168 setTimeout(function () { _this.scheduleNavigation(rawUrlTree, source, state, { replaceUrl: true }); }, 0);
4169 });
4170 }
4171 };
4172 Object.defineProperty(Router.prototype, "url", {
4173 /** The current URL. */
4174 get: function () { return this.serializeUrl(this.currentUrlTree); },
4175 enumerable: true,
4176 configurable: true
4177 });
4178 /** The current Navigation object if one exists */
4179 Router.prototype.getCurrentNavigation = function () { return this.currentNavigation; };
4180 /** @internal */
4181 Router.prototype.triggerEvent = function (event) { this.events.next(event); };
4182 /**
4183 * Resets the configuration used for navigation and generating links.
4184 *
4185 * @param config The route array for the new configuration.
4186 *
4187 * @usageNotes
4188 *
4189 * ```
4190 * router.resetConfig([
4191 * { path: 'team/:id', component: TeamCmp, children: [
4192 * { path: 'simple', component: SimpleCmp },
4193 * { path: 'user/:name', component: UserCmp }
4194 * ]}
4195 * ]);
4196 * ```
4197 */
4198 Router.prototype.resetConfig = function (config) {
4199 validateConfig(config);
4200 this.config = config.map(standardizeConfig);
4201 this.navigated = false;
4202 this.lastSuccessfulId = -1;
4203 };
4204 /** @docsNotRequired */
4205 Router.prototype.ngOnDestroy = function () { this.dispose(); };
4206 /** Disposes of the router. */
4207 Router.prototype.dispose = function () {
4208 if (this.locationSubscription) {
4209 this.locationSubscription.unsubscribe();
4210 this.locationSubscription = null;
4211 }
4212 };
4213 /**
4214 * Applies an array of commands to the current URL tree and creates a new URL tree.
4215 *
4216 * When given an activate route, applies the given commands starting from the route.
4217 * When not given a route, applies the given command starting from the root.
4218 *
4219 * @param commands An array of commands to apply.
4220 * @param navigationExtras
4221 * @returns The new URL tree.
4222 *
4223 * @usageNotes
4224 *
4225 * ```
4226 * // create /team/33/user/11
4227 * router.createUrlTree(['/team', 33, 'user', 11]);
4228 *
4229 * // create /team/33;expand=true/user/11
4230 * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
4231 *
4232 * // you can collapse static segments like this (this works only with the first passed-in value):
4233 * router.createUrlTree(['/team/33/user', userId]);
4234 *
4235 * // If the first segment can contain slashes, and you do not want the router to split it, you
4236 * // can do the following:
4237 *
4238 * router.createUrlTree([{segmentPath: '/one/two'}]);
4239 *
4240 * // create /team/33/(user/11//right:chat)
4241 * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
4242 *
4243 * // remove the right secondary node
4244 * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
4245 *
4246 * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
4247 *
4248 * // navigate to /team/33/user/11/details
4249 * router.createUrlTree(['details'], {relativeTo: route});
4250 *
4251 * // navigate to /team/33/user/22
4252 * router.createUrlTree(['../22'], {relativeTo: route});
4253 *
4254 * // navigate to /team/44/user/22
4255 * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
4256 * ```
4257 */
4258 Router.prototype.createUrlTree = function (commands, navigationExtras) {
4259 if (navigationExtras === void 0) { navigationExtras = {}; }
4260 var relativeTo = navigationExtras.relativeTo, queryParams = navigationExtras.queryParams, fragment = navigationExtras.fragment, preserveQueryParams = navigationExtras.preserveQueryParams, queryParamsHandling = navigationExtras.queryParamsHandling, preserveFragment = navigationExtras.preserveFragment;
4261 if (core.isDevMode() && preserveQueryParams && console && console.warn) {
4262 console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
4263 }
4264 var a = relativeTo || this.routerState.root;
4265 var f = preserveFragment ? this.currentUrlTree.fragment : fragment;
4266 var q = null;
4267 if (queryParamsHandling) {
4268 switch (queryParamsHandling) {
4269 case 'merge':
4270 q = __assign({}, this.currentUrlTree.queryParams, queryParams);
4271 break;
4272 case 'preserve':
4273 q = this.currentUrlTree.queryParams;
4274 break;
4275 default:
4276 q = queryParams || null;
4277 }
4278 }
4279 else {
4280 q = preserveQueryParams ? this.currentUrlTree.queryParams : queryParams || null;
4281 }
4282 if (q !== null) {
4283 q = this.removeEmptyProps(q);
4284 }
4285 return createUrlTree(a, this.currentUrlTree, commands, q, f);
4286 };
4287 /**
4288 * Navigate based on the provided URL, which must be absolute.
4289 *
4290 * @param url An absolute URL. The function does not apply any delta to the current URL.
4291 * @param extras An object containing properties that modify the navigation strategy.
4292 * The function ignores any properties in the `NavigationExtras` that would change the
4293 * provided URL.
4294 *
4295 * @returns A Promise that resolves to 'true' when navigation succeeds,
4296 * to 'false' when navigation fails, or is rejected on error.
4297 *
4298 * @usageNotes
4299 *
4300 * ### Example
4301 *
4302 * ```
4303 * router.navigateByUrl("/team/33/user/11");
4304 *
4305 * // Navigate without updating the URL
4306 * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
4307 * ```
4308 *
4309 */
4310 Router.prototype.navigateByUrl = function (url, extras) {
4311 if (extras === void 0) { extras = { skipLocationChange: false }; }
4312 if (core.isDevMode() && this.isNgZoneEnabled && !core.NgZone.isInAngularZone()) {
4313 this.console.warn("Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?");
4314 }
4315 var urlTree = isUrlTree(url) ? url : this.parseUrl(url);
4316 var mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
4317 return this.scheduleNavigation(mergedTree, 'imperative', null, extras);
4318 };
4319 /**
4320 * Navigate based on the provided array of commands and a starting point.
4321 * If no starting route is provided, the navigation is absolute.
4322 *
4323 * Returns a promise that:
4324 * - resolves to 'true' when navigation succeeds,
4325 * - resolves to 'false' when navigation fails,
4326 * - is rejected when an error happens.
4327 *
4328 * @usageNotes
4329 *
4330 * ### Example
4331 *
4332 * ```
4333 * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
4334 *
4335 * // Navigate without updating the URL
4336 * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true});
4337 * ```
4338 *
4339 * The first parameter of `navigate()` is a delta to be applied to the current URL
4340 * or the one provided in the `relativeTo` property of the second parameter (the
4341 * `NavigationExtras`).
4342 *
4343 * In order to affect this browser's `history.state` entry, the `state`
4344 * parameter can be passed. This must be an object because the router
4345 * will add the `navigationId` property to this object before creating
4346 * the new history item.
4347 */
4348 Router.prototype.navigate = function (commands, extras) {
4349 if (extras === void 0) { extras = { skipLocationChange: false }; }
4350 validateCommands(commands);
4351 return this.navigateByUrl(this.createUrlTree(commands, extras), extras);
4352 };
4353 /** Serializes a `UrlTree` into a string */
4354 Router.prototype.serializeUrl = function (url) { return this.urlSerializer.serialize(url); };
4355 /** Parses a string into a `UrlTree` */
4356 Router.prototype.parseUrl = function (url) {
4357 var urlTree;
4358 try {
4359 urlTree = this.urlSerializer.parse(url);
4360 }
4361 catch (e) {
4362 urlTree = this.malformedUriErrorHandler(e, this.urlSerializer, url);
4363 }
4364 return urlTree;
4365 };
4366 /** Returns whether the url is activated */
4367 Router.prototype.isActive = function (url, exact) {
4368 if (isUrlTree(url)) {
4369 return containsTree(this.currentUrlTree, url, exact);
4370 }
4371 var urlTree = this.parseUrl(url);
4372 return containsTree(this.currentUrlTree, urlTree, exact);
4373 };
4374 Router.prototype.removeEmptyProps = function (params) {
4375 return Object.keys(params).reduce(function (result, key) {
4376 var value = params[key];
4377 if (value !== null && value !== undefined) {
4378 result[key] = value;
4379 }
4380 return result;
4381 }, {});
4382 };
4383 Router.prototype.processNavigations = function () {
4384 var _this = this;
4385 this.navigations.subscribe(function (t) {
4386 _this.navigated = true;
4387 _this.lastSuccessfulId = t.id;
4388 _this.events
4389 .next(new NavigationEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(_this.currentUrlTree)));
4390 _this.lastSuccessfulNavigation = _this.currentNavigation;
4391 _this.currentNavigation = null;
4392 t.resolve(true);
4393 }, function (e) { _this.console.warn("Unhandled Navigation Error: "); });
4394 };
4395 Router.prototype.scheduleNavigation = function (rawUrl, source, restoredState, extras) {
4396 var lastNavigation = this.getTransition();
4397 // If the user triggers a navigation imperatively (e.g., by using navigateByUrl),
4398 // and that navigation results in 'replaceState' that leads to the same URL,
4399 // we should skip those.
4400 if (lastNavigation && source !== 'imperative' && lastNavigation.source === 'imperative' &&
4401 lastNavigation.rawUrl.toString() === rawUrl.toString()) {
4402 return Promise.resolve(true); // return value is not used
4403 }
4404 // Because of a bug in IE and Edge, the location class fires two events (popstate and
4405 // hashchange) every single time. The second one should be ignored. Otherwise, the URL will
4406 // flicker. Handles the case when a popstate was emitted first.
4407 if (lastNavigation && source == 'hashchange' && lastNavigation.source === 'popstate' &&
4408 lastNavigation.rawUrl.toString() === rawUrl.toString()) {
4409 return Promise.resolve(true); // return value is not used
4410 }
4411 // Because of a bug in IE and Edge, the location class fires two events (popstate and
4412 // hashchange) every single time. The second one should be ignored. Otherwise, the URL will
4413 // flicker. Handles the case when a hashchange was emitted first.
4414 if (lastNavigation && source == 'popstate' && lastNavigation.source === 'hashchange' &&
4415 lastNavigation.rawUrl.toString() === rawUrl.toString()) {
4416 return Promise.resolve(true); // return value is not used
4417 }
4418 var resolve = null;
4419 var reject = null;
4420 var promise = new Promise(function (res, rej) {
4421 resolve = res;
4422 reject = rej;
4423 });
4424 var id = ++this.navigationId;
4425 this.setTransition({
4426 id: id,
4427 source: source,
4428 restoredState: restoredState,
4429 currentUrlTree: this.currentUrlTree,
4430 currentRawUrl: this.rawUrlTree, rawUrl: rawUrl, extras: extras, resolve: resolve, reject: reject, promise: promise,
4431 currentSnapshot: this.routerState.snapshot,
4432 currentRouterState: this.routerState
4433 });
4434 // Make sure that the error is propagated even though `processNavigations` catch
4435 // handler does not rethrow
4436 return promise.catch(function (e) { return Promise.reject(e); });
4437 };
4438 Router.prototype.setBrowserUrl = function (url, replaceUrl, id, state) {
4439 var path = this.urlSerializer.serialize(url);
4440 state = state || {};
4441 if (this.location.isCurrentPathEqualTo(path) || replaceUrl) {
4442 // TODO(jasonaden): Remove first `navigationId` and rely on `ng` namespace.
4443 this.location.replaceState(path, '', __assign({}, state, { navigationId: id }));
4444 }
4445 else {
4446 this.location.go(path, '', __assign({}, state, { navigationId: id }));
4447 }
4448 };
4449 Router.prototype.resetStateAndUrl = function (storedState, storedUrl, rawUrl) {
4450 this.routerState = storedState;
4451 this.currentUrlTree = storedUrl;
4452 this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, rawUrl);
4453 this.resetUrlToCurrentUrlTree();
4454 };
4455 Router.prototype.resetUrlToCurrentUrlTree = function () {
4456 this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', { navigationId: this.lastSuccessfulId });
4457 };
4458 return Router;
4459 }());
4460 function validateCommands(commands) {
4461 for (var i = 0; i < commands.length; i++) {
4462 var cmd = commands[i];
4463 if (cmd == null) {
4464 throw new Error("The requested path contains " + cmd + " segment at index " + i);
4465 }
4466 }
4467 }
4468
4469 /**
4470 * @license
4471 * Copyright Google Inc. All Rights Reserved.
4472 *
4473 * Use of this source code is governed by an MIT-style license that can be
4474 * found in the LICENSE file at https://angular.io/license
4475 */
4476 /**
4477 * @description
4478 *
4479 * Lets you link to specific routes in your app.
4480 *
4481 * Consider the following route configuration:
4482 * `[{ path: 'user/:name', component: UserCmp }]`.
4483 * When linking to this `user/:name` route, you use the `RouterLink` directive.
4484 *
4485 * If the link is static, you can use the directive as follows:
4486 * `<a routerLink="/user/bob">link to user component</a>`
4487 *
4488 * If you use dynamic values to generate the link, you can pass an array of path
4489 * segments, followed by the params for each segment.
4490 *
4491 * For instance `['/team', teamId, 'user', userName, {details: true}]`
4492 * means that we want to generate a link to `/team/11/user/bob;details=true`.
4493 *
4494 * Multiple static segments can be merged into one
4495 * (e.g., `['/team/11/user', userName, {details: true}]`).
4496 *
4497 * The first segment name can be prepended with `/`, `./`, or `../`:
4498 * * If the first segment begins with `/`, the router will look up the route from the root of the
4499 * app.
4500 * * If the first segment begins with `./`, or doesn't begin with a slash, the router will
4501 * instead look in the children of the current activated route.
4502 * * And if the first segment begins with `../`, the router will go up one level.
4503 *
4504 * You can set query params and fragment as follows:
4505 *
4506 * ```
4507 * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" fragment="education">
4508 * link to user component
4509 * </a>
4510 * ```
4511 * RouterLink will use these to generate this link: `/user/bob#education?debug=true`.
4512 *
4513 * (Deprecated in v4.0.0 use `queryParamsHandling` instead) You can also tell the
4514 * directive to preserve the current query params and fragment:
4515 *
4516 * ```
4517 * <a [routerLink]="['/user/bob']" preserveQueryParams preserveFragment>
4518 * link to user component
4519 * </a>
4520 * ```
4521 *
4522 * You can tell the directive how to handle queryParams. Available options are:
4523 * - `'merge'`: merge the queryParams into the current queryParams
4524 * - `'preserve'`: preserve the current queryParams
4525 * - default/`''`: use the queryParams only
4526 *
4527 * Same options for {@link NavigationExtras#queryParamsHandling
4528 * NavigationExtras#queryParamsHandling}.
4529 *
4530 * ```
4531 * <a [routerLink]="['/user/bob']" [queryParams]="{debug: true}" queryParamsHandling="merge">
4532 * link to user component
4533 * </a>
4534 * ```
4535 *
4536 * You can provide a `state` value to be persisted to the browser's History.state
4537 * property (See https://developer.mozilla.org/en-US/docs/Web/API/History#Properties). It's
4538 * used as follows:
4539 *
4540 * ```
4541 * <a [routerLink]="['/user/bob']" [state]="{tracingId: 123}">
4542 * link to user component
4543 * </a>
4544 * ```
4545 *
4546 * And later the value can be read from the router through `router.getCurrentNavigation`.
4547 * For example, to capture the `tracingId` above during the `NavigationStart` event:
4548 *
4549 * ```
4550 * // Get NavigationStart events
4551 * router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => {
4552 * const navigation = router.getCurrentNavigation();
4553 * tracingService.trace({id: navigation.extras.state.tracingId});
4554 * });
4555 * ```
4556 *
4557 * The router link directive always treats the provided input as a delta to the current url.
4558 *
4559 * For instance, if the current url is `/user/(box//aux:team)`.
4560 *
4561 * Then the following link `<a [routerLink]="['/user/jim']">Jim</a>` will generate the link
4562 * `/user/(jim//aux:team)`.
4563 *
4564 * See {@link Router#createUrlTree createUrlTree} for more information.
4565 *
4566 * @ngModule RouterModule
4567 *
4568 * @publicApi
4569 */
4570 var RouterLink = /** @class */ (function () {
4571 function RouterLink(router, route, tabIndex, renderer, el) {
4572 this.router = router;
4573 this.route = route;
4574 this.commands = [];
4575 if (tabIndex == null) {
4576 renderer.setAttribute(el.nativeElement, 'tabindex', '0');
4577 }
4578 }
4579 Object.defineProperty(RouterLink.prototype, "routerLink", {
4580 set: function (commands) {
4581 if (commands != null) {
4582 this.commands = Array.isArray(commands) ? commands : [commands];
4583 }
4584 else {
4585 this.commands = [];
4586 }
4587 },
4588 enumerable: true,
4589 configurable: true
4590 });
4591 Object.defineProperty(RouterLink.prototype, "preserveQueryParams", {
4592 /**
4593 * @deprecated 4.0.0 use `queryParamsHandling` instead.
4594 */
4595 set: function (value) {
4596 if (core.isDevMode() && console && console.warn) {
4597 console.warn('preserveQueryParams is deprecated!, use queryParamsHandling instead.');
4598 }
4599 this.preserve = value;
4600 },
4601 enumerable: true,
4602 configurable: true
4603 });
4604 RouterLink.prototype.onClick = function () {
4605 var extras = {
4606 skipLocationChange: attrBoolValue(this.skipLocationChange),
4607 replaceUrl: attrBoolValue(this.replaceUrl),
4608 };
4609 this.router.navigateByUrl(this.urlTree, extras);
4610 return true;
4611 };
4612 Object.defineProperty(RouterLink.prototype, "urlTree", {
4613 get: function () {
4614 return this.router.createUrlTree(this.commands, {
4615 relativeTo: this.route,
4616 queryParams: this.queryParams,
4617 fragment: this.fragment,
4618 preserveQueryParams: attrBoolValue(this.preserve),
4619 queryParamsHandling: this.queryParamsHandling,
4620 preserveFragment: attrBoolValue(this.preserveFragment),
4621 });
4622 },
4623 enumerable: true,
4624 configurable: true
4625 });
4626 __decorate([
4627 core.Input(),
4628 __metadata("design:type", Object)
4629 ], RouterLink.prototype, "queryParams", void 0);
4630 __decorate([
4631 core.Input(),
4632 __metadata("design:type", String)
4633 ], RouterLink.prototype, "fragment", void 0);
4634 __decorate([
4635 core.Input(),
4636 __metadata("design:type", String)
4637 ], RouterLink.prototype, "queryParamsHandling", void 0);
4638 __decorate([
4639 core.Input(),
4640 __metadata("design:type", Boolean)
4641 ], RouterLink.prototype, "preserveFragment", void 0);
4642 __decorate([
4643 core.Input(),
4644 __metadata("design:type", Boolean)
4645 ], RouterLink.prototype, "skipLocationChange", void 0);
4646 __decorate([
4647 core.Input(),
4648 __metadata("design:type", Boolean)
4649 ], RouterLink.prototype, "replaceUrl", void 0);
4650 __decorate([
4651 core.Input(),
4652 __metadata("design:type", Object)
4653 ], RouterLink.prototype, "state", void 0);
4654 __decorate([
4655 core.Input(),
4656 __metadata("design:type", Object),
4657 __metadata("design:paramtypes", [Object])
4658 ], RouterLink.prototype, "routerLink", null);
4659 __decorate([
4660 core.Input(),
4661 __metadata("design:type", Boolean),
4662 __metadata("design:paramtypes", [Boolean])
4663 ], RouterLink.prototype, "preserveQueryParams", null);
4664 __decorate([
4665 core.HostListener('click'),
4666 __metadata("design:type", Function),
4667 __metadata("design:paramtypes", []),
4668 __metadata("design:returntype", Boolean)
4669 ], RouterLink.prototype, "onClick", null);
4670 RouterLink = __decorate([
4671 core.Directive({ selector: ':not(a):not(area)[routerLink]' }),
4672 __param(2, core.Attribute('tabindex')),
4673 __metadata("design:paramtypes", [Router, ActivatedRoute, String, core.Renderer2, core.ElementRef])
4674 ], RouterLink);
4675 return RouterLink;
4676 }());
4677 /**
4678 * @description
4679 *
4680 * Lets you link to specific routes in your app.
4681 *
4682 * See `RouterLink` for more information.
4683 *
4684 * @ngModule RouterModule
4685 *
4686 * @publicApi
4687 */
4688 var RouterLinkWithHref = /** @class */ (function () {
4689 function RouterLinkWithHref(router, route, locationStrategy) {
4690 var _this = this;
4691 this.router = router;
4692 this.route = route;
4693 this.locationStrategy = locationStrategy;
4694 this.commands = [];
4695 this.subscription = router.events.subscribe(function (s) {
4696 if (s instanceof NavigationEnd) {
4697 _this.updateTargetUrlAndHref();
4698 }
4699 });
4700 }
4701 Object.defineProperty(RouterLinkWithHref.prototype, "routerLink", {
4702 set: function (commands) {
4703 if (commands != null) {
4704 this.commands = Array.isArray(commands) ? commands : [commands];
4705 }
4706 else {
4707 this.commands = [];
4708 }
4709 },
4710 enumerable: true,
4711 configurable: true
4712 });
4713 Object.defineProperty(RouterLinkWithHref.prototype, "preserveQueryParams", {
4714 set: function (value) {
4715 if (core.isDevMode() && console && console.warn) {
4716 console.warn('preserveQueryParams is deprecated, use queryParamsHandling instead.');
4717 }
4718 this.preserve = value;
4719 },
4720 enumerable: true,
4721 configurable: true
4722 });
4723 RouterLinkWithHref.prototype.ngOnChanges = function (changes) { this.updateTargetUrlAndHref(); };
4724 RouterLinkWithHref.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
4725 RouterLinkWithHref.prototype.onClick = function (button, ctrlKey, metaKey, shiftKey) {
4726 if (button !== 0 || ctrlKey || metaKey || shiftKey) {
4727 return true;
4728 }
4729 if (typeof this.target === 'string' && this.target != '_self') {
4730 return true;
4731 }
4732 var extras = {
4733 skipLocationChange: attrBoolValue(this.skipLocationChange),
4734 replaceUrl: attrBoolValue(this.replaceUrl),
4735 state: this.state
4736 };
4737 this.router.navigateByUrl(this.urlTree, extras);
4738 return false;
4739 };
4740 RouterLinkWithHref.prototype.updateTargetUrlAndHref = function () {
4741 this.href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree));
4742 };
4743 Object.defineProperty(RouterLinkWithHref.prototype, "urlTree", {
4744 get: function () {
4745 return this.router.createUrlTree(this.commands, {
4746 relativeTo: this.route,
4747 queryParams: this.queryParams,
4748 fragment: this.fragment,
4749 preserveQueryParams: attrBoolValue(this.preserve),
4750 queryParamsHandling: this.queryParamsHandling,
4751 preserveFragment: attrBoolValue(this.preserveFragment),
4752 });
4753 },
4754 enumerable: true,
4755 configurable: true
4756 });
4757 __decorate([
4758 core.HostBinding('attr.target'), core.Input(),
4759 __metadata("design:type", String)
4760 ], RouterLinkWithHref.prototype, "target", void 0);
4761 __decorate([
4762 core.Input(),
4763 __metadata("design:type", Object)
4764 ], RouterLinkWithHref.prototype, "queryParams", void 0);
4765 __decorate([
4766 core.Input(),
4767 __metadata("design:type", String)
4768 ], RouterLinkWithHref.prototype, "fragment", void 0);
4769 __decorate([
4770 core.Input(),
4771 __metadata("design:type", String)
4772 ], RouterLinkWithHref.prototype, "queryParamsHandling", void 0);
4773 __decorate([
4774 core.Input(),
4775 __metadata("design:type", Boolean)
4776 ], RouterLinkWithHref.prototype, "preserveFragment", void 0);
4777 __decorate([
4778 core.Input(),
4779 __metadata("design:type", Boolean)
4780 ], RouterLinkWithHref.prototype, "skipLocationChange", void 0);
4781 __decorate([
4782 core.Input(),
4783 __metadata("design:type", Boolean)
4784 ], RouterLinkWithHref.prototype, "replaceUrl", void 0);
4785 __decorate([
4786 core.Input(),
4787 __metadata("design:type", Object)
4788 ], RouterLinkWithHref.prototype, "state", void 0);
4789 __decorate([
4790 core.HostBinding(),
4791 __metadata("design:type", String)
4792 ], RouterLinkWithHref.prototype, "href", void 0);
4793 __decorate([
4794 core.Input(),
4795 __metadata("design:type", Object),
4796 __metadata("design:paramtypes", [Object])
4797 ], RouterLinkWithHref.prototype, "routerLink", null);
4798 __decorate([
4799 core.Input(),
4800 __metadata("design:type", Boolean),
4801 __metadata("design:paramtypes", [Boolean])
4802 ], RouterLinkWithHref.prototype, "preserveQueryParams", null);
4803 __decorate([
4804 core.HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey']),
4805 __metadata("design:type", Function),
4806 __metadata("design:paramtypes", [Number, Boolean, Boolean, Boolean]),
4807 __metadata("design:returntype", Boolean)
4808 ], RouterLinkWithHref.prototype, "onClick", null);
4809 RouterLinkWithHref = __decorate([
4810 core.Directive({ selector: 'a[routerLink],area[routerLink]' }),
4811 __metadata("design:paramtypes", [Router, ActivatedRoute,
4812 common.LocationStrategy])
4813 ], RouterLinkWithHref);
4814 return RouterLinkWithHref;
4815 }());
4816 function attrBoolValue(s) {
4817 return s === '' || !!s;
4818 }
4819
4820 /**
4821 * @license
4822 * Copyright Google Inc. All Rights Reserved.
4823 *
4824 * Use of this source code is governed by an MIT-style license that can be
4825 * found in the LICENSE file at https://angular.io/license
4826 */
4827 /**
4828 *
4829 * @description
4830 *
4831 * Lets you add a CSS class to an element when the link's route becomes active.
4832 *
4833 * This directive lets you add a CSS class to an element when the link's route
4834 * becomes active.
4835 *
4836 * Consider the following example:
4837 *
4838 * ```
4839 * <a routerLink="/user/bob" routerLinkActive="active-link">Bob</a>
4840 * ```
4841 *
4842 * When the url is either '/user' or '/user/bob', the active-link class will
4843 * be added to the `a` tag. If the url changes, the class will be removed.
4844 *
4845 * You can set more than one class, as follows:
4846 *
4847 * ```
4848 * <a routerLink="/user/bob" routerLinkActive="class1 class2">Bob</a>
4849 * <a routerLink="/user/bob" [routerLinkActive]="['class1', 'class2']">Bob</a>
4850 * ```
4851 *
4852 * You can configure RouterLinkActive by passing `exact: true`. This will add the classes
4853 * only when the url matches the link exactly.
4854 *
4855 * ```
4856 * <a routerLink="/user/bob" routerLinkActive="active-link" [routerLinkActiveOptions]="{exact:
4857 * true}">Bob</a>
4858 * ```
4859 *
4860 * You can assign the RouterLinkActive instance to a template variable and directly check
4861 * the `isActive` status.
4862 * ```
4863 * <a routerLink="/user/bob" routerLinkActive #rla="routerLinkActive">
4864 * Bob {{ rla.isActive ? '(already open)' : ''}}
4865 * </a>
4866 * ```
4867 *
4868 * Finally, you can apply the RouterLinkActive directive to an ancestor of a RouterLink.
4869 *
4870 * ```
4871 * <div routerLinkActive="active-link" [routerLinkActiveOptions]="{exact: true}">
4872 * <a routerLink="/user/jim">Jim</a>
4873 * <a routerLink="/user/bob">Bob</a>
4874 * </div>
4875 * ```
4876 *
4877 * This will set the active-link class on the div tag if the url is either '/user/jim' or
4878 * '/user/bob'.
4879 *
4880 * @ngModule RouterModule
4881 *
4882 * @publicApi
4883 */
4884 var RouterLinkActive = /** @class */ (function () {
4885 function RouterLinkActive(router, element, renderer, link, linkWithHref) {
4886 var _this = this;
4887 this.router = router;
4888 this.element = element;
4889 this.renderer = renderer;
4890 this.link = link;
4891 this.linkWithHref = linkWithHref;
4892 this.classes = [];
4893 this.isActive = false;
4894 this.routerLinkActiveOptions = { exact: false };
4895 this.subscription = router.events.subscribe(function (s) {
4896 if (s instanceof NavigationEnd) {
4897 _this.update();
4898 }
4899 });
4900 }
4901 RouterLinkActive.prototype.ngAfterContentInit = function () {
4902 var _this = this;
4903 this.links.changes.subscribe(function (_) { return _this.update(); });
4904 this.linksWithHrefs.changes.subscribe(function (_) { return _this.update(); });
4905 this.update();
4906 };
4907 Object.defineProperty(RouterLinkActive.prototype, "routerLinkActive", {
4908 set: function (data) {
4909 var classes = Array.isArray(data) ? data : data.split(' ');
4910 this.classes = classes.filter(function (c) { return !!c; });
4911 },
4912 enumerable: true,
4913 configurable: true
4914 });
4915 RouterLinkActive.prototype.ngOnChanges = function (changes) { this.update(); };
4916 RouterLinkActive.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
4917 RouterLinkActive.prototype.update = function () {
4918 var _this = this;
4919 if (!this.links || !this.linksWithHrefs || !this.router.navigated)
4920 return;
4921 Promise.resolve().then(function () {
4922 var hasActiveLinks = _this.hasActiveLinks();
4923 if (_this.isActive !== hasActiveLinks) {
4924 _this.isActive = hasActiveLinks;
4925 _this.classes.forEach(function (c) {
4926 if (hasActiveLinks) {
4927 _this.renderer.addClass(_this.element.nativeElement, c);
4928 }
4929 else {
4930 _this.renderer.removeClass(_this.element.nativeElement, c);
4931 }
4932 });
4933 }
4934 });
4935 };
4936 RouterLinkActive.prototype.isLinkActive = function (router) {
4937 var _this = this;
4938 return function (link) {
4939 return router.isActive(link.urlTree, _this.routerLinkActiveOptions.exact);
4940 };
4941 };
4942 RouterLinkActive.prototype.hasActiveLinks = function () {
4943 var isActiveCheckFn = this.isLinkActive(this.router);
4944 return this.link && isActiveCheckFn(this.link) ||
4945 this.linkWithHref && isActiveCheckFn(this.linkWithHref) ||
4946 this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
4947 };
4948 __decorate([
4949 core.ContentChildren(RouterLink, { descendants: true }),
4950 __metadata("design:type", core.QueryList)
4951 ], RouterLinkActive.prototype, "links", void 0);
4952 __decorate([
4953 core.ContentChildren(RouterLinkWithHref, { descendants: true }),
4954 __metadata("design:type", core.QueryList)
4955 ], RouterLinkActive.prototype, "linksWithHrefs", void 0);
4956 __decorate([
4957 core.Input(),
4958 __metadata("design:type", Object)
4959 ], RouterLinkActive.prototype, "routerLinkActiveOptions", void 0);
4960 __decorate([
4961 core.Input(),
4962 __metadata("design:type", Object),
4963 __metadata("design:paramtypes", [Object])
4964 ], RouterLinkActive.prototype, "routerLinkActive", null);
4965 RouterLinkActive = __decorate([
4966 core.Directive({
4967 selector: '[routerLinkActive]',
4968 exportAs: 'routerLinkActive',
4969 }),
4970 __param(3, core.Optional()),
4971 __param(4, core.Optional()),
4972 __metadata("design:paramtypes", [Router, core.ElementRef, core.Renderer2,
4973 RouterLink,
4974 RouterLinkWithHref])
4975 ], RouterLinkActive);
4976 return RouterLinkActive;
4977 }());
4978
4979 /**
4980 * @license
4981 * Copyright Google Inc. All Rights Reserved.
4982 *
4983 * Use of this source code is governed by an MIT-style license that can be
4984 * found in the LICENSE file at https://angular.io/license
4985 */
4986 /**
4987 * Store contextual information about a `RouterOutlet`
4988 *
4989 * @publicApi
4990 */
4991 var OutletContext = /** @class */ (function () {
4992 function OutletContext() {
4993 this.outlet = null;
4994 this.route = null;
4995 this.resolver = null;
4996 this.children = new ChildrenOutletContexts();
4997 this.attachRef = null;
4998 }
4999 return OutletContext;
5000 }());
5001 /**
5002 * Store contextual information about the children (= nested) `RouterOutlet`
5003 *
5004 * @publicApi
5005 */
5006 var ChildrenOutletContexts = /** @class */ (function () {
5007 function ChildrenOutletContexts() {
5008 // contexts for child outlets, by name.
5009 this.contexts = new Map();
5010 }
5011 /** Called when a `RouterOutlet` directive is instantiated */
5012 ChildrenOutletContexts.prototype.onChildOutletCreated = function (childName, outlet) {
5013 var context = this.getOrCreateContext(childName);
5014 context.outlet = outlet;
5015 this.contexts.set(childName, context);
5016 };
5017 /**
5018 * Called when a `RouterOutlet` directive is destroyed.
5019 * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
5020 * re-created later.
5021 */
5022 ChildrenOutletContexts.prototype.onChildOutletDestroyed = function (childName) {
5023 var context = this.getContext(childName);
5024 if (context) {
5025 context.outlet = null;
5026 }
5027 };
5028 /**
5029 * Called when the corresponding route is deactivated during navigation.
5030 * Because the component get destroyed, all children outlet are destroyed.
5031 */
5032 ChildrenOutletContexts.prototype.onOutletDeactivated = function () {
5033 var contexts = this.contexts;
5034 this.contexts = new Map();
5035 return contexts;
5036 };
5037 ChildrenOutletContexts.prototype.onOutletReAttached = function (contexts) { this.contexts = contexts; };
5038 ChildrenOutletContexts.prototype.getOrCreateContext = function (childName) {
5039 var context = this.getContext(childName);
5040 if (!context) {
5041 context = new OutletContext();
5042 this.contexts.set(childName, context);
5043 }
5044 return context;
5045 };
5046 ChildrenOutletContexts.prototype.getContext = function (childName) { return this.contexts.get(childName) || null; };
5047 return ChildrenOutletContexts;
5048 }());
5049
5050 /**
5051 * @license
5052 * Copyright Google Inc. All Rights Reserved.
5053 *
5054 * Use of this source code is governed by an MIT-style license that can be
5055 * found in the LICENSE file at https://angular.io/license
5056 */
5057 /**
5058 * @description
5059 *
5060 * Acts as a placeholder that Angular dynamically fills based on the current router state.
5061 *
5062 * ```
5063 * <router-outlet></router-outlet>
5064 * <router-outlet name='left'></router-outlet>
5065 * <router-outlet name='right'></router-outlet>
5066 * ```
5067 *
5068 * A router outlet will emit an activate event any time a new component is being instantiated,
5069 * and a deactivate event when it is being destroyed.
5070 *
5071 * ```
5072 * <router-outlet
5073 * (activate)='onActivate($event)'
5074 * (deactivate)='onDeactivate($event)'></router-outlet>
5075 * ```
5076 * @ngModule RouterModule
5077 *
5078 * @publicApi
5079 */
5080 var RouterOutlet = /** @class */ (function () {
5081 function RouterOutlet(parentContexts, location, resolver, name, changeDetector) {
5082 this.parentContexts = parentContexts;
5083 this.location = location;
5084 this.resolver = resolver;
5085 this.changeDetector = changeDetector;
5086 this.activated = null;
5087 this._activatedRoute = null;
5088 this.activateEvents = new core.EventEmitter();
5089 this.deactivateEvents = new core.EventEmitter();
5090 this.name = name || PRIMARY_OUTLET;
5091 parentContexts.onChildOutletCreated(this.name, this);
5092 }
5093 RouterOutlet.prototype.ngOnDestroy = function () { this.parentContexts.onChildOutletDestroyed(this.name); };
5094 RouterOutlet.prototype.ngOnInit = function () {
5095 if (!this.activated) {
5096 // If the outlet was not instantiated at the time the route got activated we need to populate
5097 // the outlet when it is initialized (ie inside a NgIf)
5098 var context = this.parentContexts.getContext(this.name);
5099 if (context && context.route) {
5100 if (context.attachRef) {
5101 // `attachRef` is populated when there is an existing component to mount
5102 this.attach(context.attachRef, context.route);
5103 }
5104 else {
5105 // otherwise the component defined in the configuration is created
5106 this.activateWith(context.route, context.resolver || null);
5107 }
5108 }
5109 }
5110 };
5111 Object.defineProperty(RouterOutlet.prototype, "isActivated", {
5112 get: function () { return !!this.activated; },
5113 enumerable: true,
5114 configurable: true
5115 });
5116 Object.defineProperty(RouterOutlet.prototype, "component", {
5117 get: function () {
5118 if (!this.activated)
5119 throw new Error('Outlet is not activated');
5120 return this.activated.instance;
5121 },
5122 enumerable: true,
5123 configurable: true
5124 });
5125 Object.defineProperty(RouterOutlet.prototype, "activatedRoute", {
5126 get: function () {
5127 if (!this.activated)
5128 throw new Error('Outlet is not activated');
5129 return this._activatedRoute;
5130 },
5131 enumerable: true,
5132 configurable: true
5133 });
5134 Object.defineProperty(RouterOutlet.prototype, "activatedRouteData", {
5135 get: function () {
5136 if (this._activatedRoute) {
5137 return this._activatedRoute.snapshot.data;
5138 }
5139 return {};
5140 },
5141 enumerable: true,
5142 configurable: true
5143 });
5144 /**
5145 * Called when the `RouteReuseStrategy` instructs to detach the subtree
5146 */
5147 RouterOutlet.prototype.detach = function () {
5148 if (!this.activated)
5149 throw new Error('Outlet is not activated');
5150 this.location.detach();
5151 var cmp = this.activated;
5152 this.activated = null;
5153 this._activatedRoute = null;
5154 return cmp;
5155 };
5156 /**
5157 * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
5158 */
5159 RouterOutlet.prototype.attach = function (ref, activatedRoute) {
5160 this.activated = ref;
5161 this._activatedRoute = activatedRoute;
5162 this.location.insert(ref.hostView);
5163 };
5164 RouterOutlet.prototype.deactivate = function () {
5165 if (this.activated) {
5166 var c = this.component;
5167 this.activated.destroy();
5168 this.activated = null;
5169 this._activatedRoute = null;
5170 this.deactivateEvents.emit(c);
5171 }
5172 };
5173 RouterOutlet.prototype.activateWith = function (activatedRoute, resolver) {
5174 if (this.isActivated) {
5175 throw new Error('Cannot activate an already activated outlet');
5176 }
5177 this._activatedRoute = activatedRoute;
5178 var snapshot = activatedRoute._futureSnapshot;
5179 var component = snapshot.routeConfig.component;
5180 resolver = resolver || this.resolver;
5181 var factory = resolver.resolveComponentFactory(component);
5182 var childContexts = this.parentContexts.getOrCreateContext(this.name).children;
5183 var injector = new OutletInjector(activatedRoute, childContexts, this.location.injector);
5184 this.activated = this.location.createComponent(factory, this.location.length, injector);
5185 // Calling `markForCheck` to make sure we will run the change detection when the
5186 // `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
5187 this.changeDetector.markForCheck();
5188 this.activateEvents.emit(this.activated.instance);
5189 };
5190 __decorate([
5191 core.Output('activate'),
5192 __metadata("design:type", Object)
5193 ], RouterOutlet.prototype, "activateEvents", void 0);
5194 __decorate([
5195 core.Output('deactivate'),
5196 __metadata("design:type", Object)
5197 ], RouterOutlet.prototype, "deactivateEvents", void 0);
5198 RouterOutlet = __decorate([
5199 core.Directive({ selector: 'router-outlet', exportAs: 'outlet' }),
5200 __param(3, core.Attribute('name')),
5201 __metadata("design:paramtypes", [ChildrenOutletContexts, core.ViewContainerRef,
5202 core.ComponentFactoryResolver, String, core.ChangeDetectorRef])
5203 ], RouterOutlet);
5204 return RouterOutlet;
5205 }());
5206 var OutletInjector = /** @class */ (function () {
5207 function OutletInjector(route, childContexts, parent) {
5208 this.route = route;
5209 this.childContexts = childContexts;
5210 this.parent = parent;
5211 }
5212 OutletInjector.prototype.get = function (token, notFoundValue) {
5213 if (token === ActivatedRoute) {
5214 return this.route;
5215 }
5216 if (token === ChildrenOutletContexts) {
5217 return this.childContexts;
5218 }
5219 return this.parent.get(token, notFoundValue);
5220 };
5221 return OutletInjector;
5222 }());
5223
5224 /**
5225 *@license
5226 *Copyright Google Inc. All Rights Reserved.
5227 *
5228 *Use of this source code is governed by an MIT-style license that can be
5229 *found in the LICENSE file at https://angular.io/license
5230 */
5231 /**
5232 * @description
5233 *
5234 * Provides a preloading strategy.
5235 *
5236 * @publicApi
5237 */
5238 var PreloadingStrategy = /** @class */ (function () {
5239 function PreloadingStrategy() {
5240 }
5241 return PreloadingStrategy;
5242 }());
5243 /**
5244 * @description
5245 *
5246 * Provides a preloading strategy that preloads all modules as quickly as possible.
5247 *
5248 * ```
5249 * RouteModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
5250 * ```
5251 *
5252 * @publicApi
5253 */
5254 var PreloadAllModules = /** @class */ (function () {
5255 function PreloadAllModules() {
5256 }
5257 PreloadAllModules.prototype.preload = function (route, fn) {
5258 return fn().pipe(operators.catchError(function () { return rxjs.of(null); }));
5259 };
5260 return PreloadAllModules;
5261 }());
5262 /**
5263 * @description
5264 *
5265 * Provides a preloading strategy that does not preload any modules.
5266 *
5267 * This strategy is enabled by default.
5268 *
5269 * @publicApi
5270 */
5271 var NoPreloading = /** @class */ (function () {
5272 function NoPreloading() {
5273 }
5274 NoPreloading.prototype.preload = function (route, fn) { return rxjs.of(null); };
5275 return NoPreloading;
5276 }());
5277 /**
5278 * The preloader optimistically loads all router configurations to
5279 * make navigations into lazily-loaded sections of the application faster.
5280 *
5281 * The preloader runs in the background. When the router bootstraps, the preloader
5282 * starts listening to all navigation events. After every such event, the preloader
5283 * will check if any configurations can be loaded lazily.
5284 *
5285 * If a route is protected by `canLoad` guards, the preloaded will not load it.
5286 *
5287 * @publicApi
5288 */
5289 var RouterPreloader = /** @class */ (function () {
5290 function RouterPreloader(router, moduleLoader, compiler, injector, preloadingStrategy) {
5291 this.router = router;
5292 this.injector = injector;
5293 this.preloadingStrategy = preloadingStrategy;
5294 var onStartLoad = function (r) { return router.triggerEvent(new RouteConfigLoadStart(r)); };
5295 var onEndLoad = function (r) { return router.triggerEvent(new RouteConfigLoadEnd(r)); };
5296 this.loader = new RouterConfigLoader(moduleLoader, compiler, onStartLoad, onEndLoad);
5297 }
5298 RouterPreloader.prototype.setUpPreloading = function () {
5299 var _this = this;
5300 this.subscription =
5301 this.router.events
5302 .pipe(operators.filter(function (e) { return e instanceof NavigationEnd; }), operators.concatMap(function () { return _this.preload(); }))
5303 .subscribe(function () { });
5304 };
5305 RouterPreloader.prototype.preload = function () {
5306 var ngModule = this.injector.get(core.NgModuleRef);
5307 return this.processRoutes(ngModule, this.router.config);
5308 };
5309 // TODO(jasonaden): This class relies on code external to the class to call setUpPreloading. If
5310 // this hasn't been done, ngOnDestroy will fail as this.subscription will be undefined. This
5311 // should be refactored.
5312 RouterPreloader.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); };
5313 RouterPreloader.prototype.processRoutes = function (ngModule, routes) {
5314 var e_1, _a;
5315 var res = [];
5316 try {
5317 for (var routes_1 = __values(routes), routes_1_1 = routes_1.next(); !routes_1_1.done; routes_1_1 = routes_1.next()) {
5318 var route = routes_1_1.value;
5319 // we already have the config loaded, just recurse
5320 if (route.loadChildren && !route.canLoad && route._loadedConfig) {
5321 var childConfig = route._loadedConfig;
5322 res.push(this.processRoutes(childConfig.module, childConfig.routes));
5323 // no config loaded, fetch the config
5324 }
5325 else if (route.loadChildren && !route.canLoad) {
5326 res.push(this.preloadConfig(ngModule, route));
5327 // recurse into children
5328 }
5329 else if (route.children) {
5330 res.push(this.processRoutes(ngModule, route.children));
5331 }
5332 }
5333 }
5334 catch (e_1_1) { e_1 = { error: e_1_1 }; }
5335 finally {
5336 try {
5337 if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
5338 }
5339 finally { if (e_1) throw e_1.error; }
5340 }
5341 return rxjs.from(res).pipe(operators.mergeAll(), operators.map(function (_) { return void 0; }));
5342 };
5343 RouterPreloader.prototype.preloadConfig = function (ngModule, route) {
5344 var _this = this;
5345 return this.preloadingStrategy.preload(route, function () {
5346 var loaded$ = _this.loader.load(ngModule.injector, route);
5347 return loaded$.pipe(operators.mergeMap(function (config) {
5348 route._loadedConfig = config;
5349 return _this.processRoutes(config.module, config.routes);
5350 }));
5351 });
5352 };
5353 RouterPreloader = __decorate([
5354 core.Injectable(),
5355 __metadata("design:paramtypes", [Router, core.NgModuleFactoryLoader, core.Compiler,
5356 core.Injector, PreloadingStrategy])
5357 ], RouterPreloader);
5358 return RouterPreloader;
5359 }());
5360
5361 /**
5362 * @license
5363 * Copyright Google Inc. All Rights Reserved.
5364 *
5365 * Use of this source code is governed by an MIT-style license that can be
5366 * found in the LICENSE file at https://angular.io/license
5367 */
5368 var RouterScroller = /** @class */ (function () {
5369 function RouterScroller(router,
5370 /** @docsNotRequired */ viewportScroller, options) {
5371 if (options === void 0) { options = {}; }
5372 this.router = router;
5373 this.viewportScroller = viewportScroller;
5374 this.options = options;
5375 this.lastId = 0;
5376 this.lastSource = 'imperative';
5377 this.restoredId = 0;
5378 this.store = {};
5379 // Default both options to 'disabled'
5380 options.scrollPositionRestoration = options.scrollPositionRestoration || 'disabled';
5381 options.anchorScrolling = options.anchorScrolling || 'disabled';
5382 }
5383 RouterScroller.prototype.init = function () {
5384 // we want to disable the automatic scrolling because having two places
5385 // responsible for scrolling results race conditions, especially given
5386 // that browser don't implement this behavior consistently
5387 if (this.options.scrollPositionRestoration !== 'disabled') {
5388 this.viewportScroller.setHistoryScrollRestoration('manual');
5389 }
5390 this.routerEventsSubscription = this.createScrollEvents();
5391 this.scrollEventsSubscription = this.consumeScrollEvents();
5392 };
5393 RouterScroller.prototype.createScrollEvents = function () {
5394 var _this = this;
5395 return this.router.events.subscribe(function (e) {
5396 if (e instanceof NavigationStart) {
5397 // store the scroll position of the current stable navigations.
5398 _this.store[_this.lastId] = _this.viewportScroller.getScrollPosition();
5399 _this.lastSource = e.navigationTrigger;
5400 _this.restoredId = e.restoredState ? e.restoredState.navigationId : 0;
5401 }
5402 else if (e instanceof NavigationEnd) {
5403 _this.lastId = e.id;
5404 _this.scheduleScrollEvent(e, _this.router.parseUrl(e.urlAfterRedirects).fragment);
5405 }
5406 });
5407 };
5408 RouterScroller.prototype.consumeScrollEvents = function () {
5409 var _this = this;
5410 return this.router.events.subscribe(function (e) {
5411 if (!(e instanceof Scroll))
5412 return;
5413 // a popstate event. The pop state event will always ignore anchor scrolling.
5414 if (e.position) {
5415 if (_this.options.scrollPositionRestoration === 'top') {
5416 _this.viewportScroller.scrollToPosition([0, 0]);
5417 }
5418 else if (_this.options.scrollPositionRestoration === 'enabled') {
5419 _this.viewportScroller.scrollToPosition(e.position);
5420 }
5421 // imperative navigation "forward"
5422 }
5423 else {
5424 if (e.anchor && _this.options.anchorScrolling === 'enabled') {
5425 _this.viewportScroller.scrollToAnchor(e.anchor);
5426 }
5427 else if (_this.options.scrollPositionRestoration !== 'disabled') {
5428 _this.viewportScroller.scrollToPosition([0, 0]);
5429 }
5430 }
5431 });
5432 };
5433 RouterScroller.prototype.scheduleScrollEvent = function (routerEvent, anchor) {
5434 this.router.triggerEvent(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
5435 };
5436 RouterScroller.prototype.ngOnDestroy = function () {
5437 if (this.routerEventsSubscription) {
5438 this.routerEventsSubscription.unsubscribe();
5439 }
5440 if (this.scrollEventsSubscription) {
5441 this.scrollEventsSubscription.unsubscribe();
5442 }
5443 };
5444 return RouterScroller;
5445 }());
5446
5447 /**
5448 * @license
5449 * Copyright Google Inc. All Rights Reserved.
5450 *
5451 * Use of this source code is governed by an MIT-style license that can be
5452 * found in the LICENSE file at https://angular.io/license
5453 */
5454 /**
5455 * @description
5456 *
5457 * Contains a list of directives
5458 *
5459 *
5460 */
5461 var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent];
5462 /**
5463 * @description
5464 *
5465 * Is used in DI to configure the router.
5466 *
5467 * @publicApi
5468 */
5469 var ROUTER_CONFIGURATION = new core.InjectionToken('ROUTER_CONFIGURATION');
5470 /**
5471 * @docsNotRequired
5472 */
5473 var ROUTER_FORROOT_GUARD = new core.InjectionToken('ROUTER_FORROOT_GUARD');
5474 var ɵ0 = { enableTracing: false };
5475 var ROUTER_PROVIDERS = [
5476 common.Location,
5477 { provide: UrlSerializer, useClass: DefaultUrlSerializer },
5478 {
5479 provide: Router,
5480 useFactory: setupRouter,
5481 deps: [
5482 core.ApplicationRef, UrlSerializer, ChildrenOutletContexts, common.Location, core.Injector,
5483 core.NgModuleFactoryLoader, core.Compiler, ROUTES, ROUTER_CONFIGURATION,
5484 [UrlHandlingStrategy, new core.Optional()], [RouteReuseStrategy, new core.Optional()]
5485 ]
5486 },
5487 ChildrenOutletContexts,
5488 { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
5489 { provide: core.NgModuleFactoryLoader, useClass: core.SystemJsNgModuleLoader },
5490 RouterPreloader,
5491 NoPreloading,
5492 PreloadAllModules,
5493 { provide: ROUTER_CONFIGURATION, useValue: ɵ0 },
5494 ];
5495 function routerNgProbeToken() {
5496 return new core.NgProbeToken('Router', Router);
5497 }
5498 /**
5499 * @usageNotes
5500 *
5501 * RouterModule can be imported multiple times: once per lazily-loaded bundle.
5502 * Since the router deals with a global shared resource--location, we cannot have
5503 * more than one router service active.
5504 *
5505 * That is why there are two ways to create the module: `RouterModule.forRoot` and
5506 * `RouterModule.forChild`.
5507 *
5508 * * `forRoot` creates a module that contains all the directives, the given routes, and the router
5509 * service itself.
5510 * * `forChild` creates a module that contains all the directives and the given routes, but does not
5511 * include the router service.
5512 *
5513 * When registered at the root, the module should be used as follows
5514 *
5515 * ```
5516 * @NgModule({
5517 * imports: [RouterModule.forRoot(ROUTES)]
5518 * })
5519 * class MyNgModule {}
5520 * ```
5521 *
5522 * For submodules and lazy loaded submodules the module should be used as follows:
5523 *
5524 * ```
5525 * @NgModule({
5526 * imports: [RouterModule.forChild(ROUTES)]
5527 * })
5528 * class MyNgModule {}
5529 * ```
5530 *
5531 * @description
5532 *
5533 * Adds router directives and providers.
5534 *
5535 * Managing state transitions is one of the hardest parts of building applications. This is
5536 * especially true on the web, where you also need to ensure that the state is reflected in the URL.
5537 * In addition, we often want to split applications into multiple bundles and load them on demand.
5538 * Doing this transparently is not trivial.
5539 *
5540 * The Angular router solves these problems. Using the router, you can declaratively specify
5541 * application states, manage state transitions while taking care of the URL, and load bundles on
5542 * demand.
5543 *
5544 * [Read this developer guide](https://angular.io/docs/ts/latest/guide/router.html) to get an
5545 * overview of how the router should be used.
5546 *
5547 * @publicApi
5548 */
5549 var RouterModule = /** @class */ (function () {
5550 // Note: We are injecting the Router so it gets created eagerly...
5551 function RouterModule(guard, router) {
5552 }
5553 RouterModule_1 = RouterModule;
5554 /**
5555 * Creates a module with all the router providers and directives. It also optionally sets up an
5556 * application listener to perform an initial navigation.
5557 *
5558 * Configuration Options:
5559 *
5560 * * `enableTracing` Toggles whether the router should log all navigation events to the console.
5561 * * `useHash` Enables the location strategy that uses the URL fragment instead of the history
5562 * API.
5563 * * `initialNavigation` Disables the initial navigation.
5564 * * `errorHandler` Defines a custom error handler for failed navigations.
5565 * * `preloadingStrategy` Configures a preloading strategy. See `PreloadAllModules`.
5566 * * `onSameUrlNavigation` Define what the router should do if it receives a navigation request to
5567 * the current URL.
5568 * * `scrollPositionRestoration` Configures if the scroll position needs to be restored when
5569 * navigating back.
5570 * * `anchorScrolling` Configures if the router should scroll to the element when the url has a
5571 * fragment.
5572 * * `scrollOffset` Configures the scroll offset the router will use when scrolling to an element.
5573 * * `paramsInheritanceStrategy` Defines how the router merges params, data and resolved data from
5574 * parent to child routes.
5575 * * `malformedUriErrorHandler` Defines a custom malformed uri error handler function. This
5576 * handler is invoked when encodedURI contains invalid character sequences.
5577 * * `urlUpdateStrategy` Defines when the router updates the browser URL. The default behavior is
5578 * to update after successful navigation.
5579 * * `relativeLinkResolution` Enables the correct relative link resolution in components with
5580 * empty paths.
5581 *
5582 * See `ExtraOptions` for more details about the above options.
5583 */
5584 RouterModule.forRoot = function (routes, config) {
5585 return {
5586 ngModule: RouterModule_1,
5587 providers: [
5588 ROUTER_PROVIDERS,
5589 provideRoutes(routes),
5590 {
5591 provide: ROUTER_FORROOT_GUARD,
5592 useFactory: provideForRootGuard,
5593 deps: [[Router, new core.Optional(), new core.SkipSelf()]]
5594 },
5595 { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },
5596 {
5597 provide: common.LocationStrategy,
5598 useFactory: provideLocationStrategy,
5599 deps: [
5600 common.PlatformLocation, [new core.Inject(common.APP_BASE_HREF), new core.Optional()], ROUTER_CONFIGURATION
5601 ]
5602 },
5603 {
5604 provide: RouterScroller,
5605 useFactory: createRouterScroller,
5606 deps: [Router, common.ViewportScroller, ROUTER_CONFIGURATION]
5607 },
5608 {
5609 provide: PreloadingStrategy,
5610 useExisting: config && config.preloadingStrategy ? config.preloadingStrategy :
5611 NoPreloading
5612 },
5613 { provide: core.NgProbeToken, multi: true, useFactory: routerNgProbeToken },
5614 provideRouterInitializer(),
5615 ],
5616 };
5617 };
5618 /**
5619 * Creates a module with all the router directives and a provider registering routes.
5620 */
5621 RouterModule.forChild = function (routes) {
5622 return { ngModule: RouterModule_1, providers: [provideRoutes(routes)] };
5623 };
5624 var RouterModule_1;
5625 RouterModule = RouterModule_1 = __decorate([
5626 core.NgModule({
5627 declarations: ROUTER_DIRECTIVES,
5628 exports: ROUTER_DIRECTIVES,
5629 entryComponents: [ɵEmptyOutletComponent]
5630 }),
5631 __param(0, core.Optional()), __param(0, core.Inject(ROUTER_FORROOT_GUARD)), __param(1, core.Optional()),
5632 __metadata("design:paramtypes", [Object, Router])
5633 ], RouterModule);
5634 return RouterModule;
5635 }());
5636 function createRouterScroller(router, viewportScroller, config) {
5637 if (config.scrollOffset) {
5638 viewportScroller.setOffset(config.scrollOffset);
5639 }
5640 return new RouterScroller(router, viewportScroller, config);
5641 }
5642 function provideLocationStrategy(platformLocationStrategy, baseHref, options) {
5643 if (options === void 0) { options = {}; }
5644 return options.useHash ? new common.HashLocationStrategy(platformLocationStrategy, baseHref) :
5645 new common.PathLocationStrategy(platformLocationStrategy, baseHref);
5646 }
5647 function provideForRootGuard(router) {
5648 if (router) {
5649 throw new Error("RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.");
5650 }
5651 return 'guarded';
5652 }
5653 /**
5654 * @description
5655 *
5656 * Registers routes.
5657 *
5658 * @usageNotes
5659 * ### Example
5660 *
5661 * ```
5662 * @NgModule({
5663 * imports: [RouterModule.forChild(ROUTES)],
5664 * providers: [provideRoutes(EXTRA_ROUTES)]
5665 * })
5666 * class MyNgModule {}
5667 * ```
5668 *
5669 * @publicApi
5670 */
5671 function provideRoutes(routes) {
5672 return [
5673 { provide: core.ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes },
5674 { provide: ROUTES, multi: true, useValue: routes },
5675 ];
5676 }
5677 function setupRouter(ref, urlSerializer, contexts, location, injector, loader, compiler, config, opts, urlHandlingStrategy, routeReuseStrategy) {
5678 if (opts === void 0) { opts = {}; }
5679 var router = new Router(null, urlSerializer, contexts, location, injector, loader, compiler, flatten(config));
5680 if (urlHandlingStrategy) {
5681 router.urlHandlingStrategy = urlHandlingStrategy;
5682 }
5683 if (routeReuseStrategy) {
5684 router.routeReuseStrategy = routeReuseStrategy;
5685 }
5686 if (opts.errorHandler) {
5687 router.errorHandler = opts.errorHandler;
5688 }
5689 if (opts.malformedUriErrorHandler) {
5690 router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
5691 }
5692 if (opts.enableTracing) {
5693 var dom_1 = platformBrowser.ɵgetDOM();
5694 router.events.subscribe(function (e) {
5695 dom_1.logGroup("Router Event: " + e.constructor.name);
5696 dom_1.log(e.toString());
5697 dom_1.log(e);
5698 dom_1.logGroupEnd();
5699 });
5700 }
5701 if (opts.onSameUrlNavigation) {
5702 router.onSameUrlNavigation = opts.onSameUrlNavigation;
5703 }
5704 if (opts.paramsInheritanceStrategy) {
5705 router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
5706 }
5707 if (opts.urlUpdateStrategy) {
5708 router.urlUpdateStrategy = opts.urlUpdateStrategy;
5709 }
5710 if (opts.relativeLinkResolution) {
5711 router.relativeLinkResolution = opts.relativeLinkResolution;
5712 }
5713 return router;
5714 }
5715 function rootRoute(router) {
5716 return router.routerState.root;
5717 }
5718 /**
5719 * To initialize the router properly we need to do in two steps:
5720 *
5721 * We need to start the navigation in a APP_INITIALIZER to block the bootstrap if
5722 * a resolver or a guards executes asynchronously. Second, we need to actually run
5723 * activation in a BOOTSTRAP_LISTENER. We utilize the afterPreactivation
5724 * hook provided by the router to do that.
5725 *
5726 * The router navigation starts, reaches the point when preactivation is done, and then
5727 * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
5728 */
5729 var RouterInitializer = /** @class */ (function () {
5730 function RouterInitializer(injector) {
5731 this.injector = injector;
5732 this.initNavigation = false;
5733 this.resultOfPreactivationDone = new rxjs.Subject();
5734 }
5735 RouterInitializer.prototype.appInitializer = function () {
5736 var _this = this;
5737 var p = this.injector.get(common.LOCATION_INITIALIZED, Promise.resolve(null));
5738 return p.then(function () {
5739 var resolve = null;
5740 var res = new Promise(function (r) { return resolve = r; });
5741 var router = _this.injector.get(Router);
5742 var opts = _this.injector.get(ROUTER_CONFIGURATION);
5743 if (_this.isLegacyDisabled(opts) || _this.isLegacyEnabled(opts)) {
5744 resolve(true);
5745 }
5746 else if (opts.initialNavigation === 'disabled') {
5747 router.setUpLocationChangeListener();
5748 resolve(true);
5749 }
5750 else if (opts.initialNavigation === 'enabled') {
5751 router.hooks.afterPreactivation = function () {
5752 // only the initial navigation should be delayed
5753 if (!_this.initNavigation) {
5754 _this.initNavigation = true;
5755 resolve(true);
5756 return _this.resultOfPreactivationDone;
5757 // subsequent navigations should not be delayed
5758 }
5759 else {
5760 return rxjs.of(null);
5761 }
5762 };
5763 router.initialNavigation();
5764 }
5765 else {
5766 throw new Error("Invalid initialNavigation options: '" + opts.initialNavigation + "'");
5767 }
5768 return res;
5769 });
5770 };
5771 RouterInitializer.prototype.bootstrapListener = function (bootstrappedComponentRef) {
5772 var opts = this.injector.get(ROUTER_CONFIGURATION);
5773 var preloader = this.injector.get(RouterPreloader);
5774 var routerScroller = this.injector.get(RouterScroller);
5775 var router = this.injector.get(Router);
5776 var ref = this.injector.get(core.ApplicationRef);
5777 if (bootstrappedComponentRef !== ref.components[0]) {
5778 return;
5779 }
5780 if (this.isLegacyEnabled(opts)) {
5781 router.initialNavigation();
5782 }
5783 else if (this.isLegacyDisabled(opts)) {
5784 router.setUpLocationChangeListener();
5785 }
5786 preloader.setUpPreloading();
5787 routerScroller.init();
5788 router.resetRootComponentType(ref.componentTypes[0]);
5789 this.resultOfPreactivationDone.next(null);
5790 this.resultOfPreactivationDone.complete();
5791 };
5792 RouterInitializer.prototype.isLegacyEnabled = function (opts) {
5793 return opts.initialNavigation === 'legacy_enabled' || opts.initialNavigation === true ||
5794 opts.initialNavigation === undefined;
5795 };
5796 RouterInitializer.prototype.isLegacyDisabled = function (opts) {
5797 return opts.initialNavigation === 'legacy_disabled' || opts.initialNavigation === false;
5798 };
5799 RouterInitializer = __decorate([
5800 core.Injectable(),
5801 __metadata("design:paramtypes", [core.Injector])
5802 ], RouterInitializer);
5803 return RouterInitializer;
5804 }());
5805 function getAppInitializer(r) {
5806 return r.appInitializer.bind(r);
5807 }
5808 function getBootstrapListener(r) {
5809 return r.bootstrapListener.bind(r);
5810 }
5811 /**
5812 * A token for the router initializer that will be called after the app is bootstrapped.
5813 *
5814 * @publicApi
5815 */
5816 var ROUTER_INITIALIZER = new core.InjectionToken('Router Initializer');
5817 function provideRouterInitializer() {
5818 return [
5819 RouterInitializer,
5820 {
5821 provide: core.APP_INITIALIZER,
5822 multi: true,
5823 useFactory: getAppInitializer,
5824 deps: [RouterInitializer]
5825 },
5826 { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener, deps: [RouterInitializer] },
5827 { provide: core.APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
5828 ];
5829 }
5830
5831 /**
5832 * @license
5833 * Copyright Google Inc. All Rights Reserved.
5834 *
5835 * Use of this source code is governed by an MIT-style license that can be
5836 * found in the LICENSE file at https://angular.io/license
5837 */
5838 /**
5839 * @publicApi
5840 */
5841 var VERSION = new core.Version('8.0.2');
5842
5843 /**
5844 * @license
5845 * Copyright Google Inc. All Rights Reserved.
5846 *
5847 * Use of this source code is governed by an MIT-style license that can be
5848 * found in the LICENSE file at https://angular.io/license
5849 */
5850
5851 /**
5852 * @license
5853 * Copyright Google Inc. All Rights Reserved.
5854 *
5855 * Use of this source code is governed by an MIT-style license that can be
5856 * found in the LICENSE file at https://angular.io/license
5857 */
5858
5859 /**
5860 * @license
5861 * Copyright Google Inc. All Rights Reserved.
5862 *
5863 * Use of this source code is governed by an MIT-style license that can be
5864 * found in the LICENSE file at https://angular.io/license
5865 */
5866 // This file only reexports content of the `src` folder. Keep it that way.
5867
5868 /**
5869 * @license
5870 * Copyright Google Inc. All Rights Reserved.
5871 *
5872 * Use of this source code is governed by an MIT-style license that can be
5873 * found in the LICENSE file at https://angular.io/license
5874 */
5875
5876 /**
5877 * Generated bundle index. Do not edit.
5878 */
5879
5880 exports.ɵangular_packages_router_router_l = ɵEmptyOutletComponent;
5881 exports.ɵEmptyOutletComponent = ɵEmptyOutletComponent;
5882 exports.ɵangular_packages_router_router_a = ROUTER_FORROOT_GUARD;
5883 exports.ɵangular_packages_router_router_h = RouterInitializer;
5884 exports.ɵangular_packages_router_router_c = createRouterScroller;
5885 exports.ɵangular_packages_router_router_i = getAppInitializer;
5886 exports.ɵangular_packages_router_router_j = getBootstrapListener;
5887 exports.ɵangular_packages_router_router_e = provideForRootGuard;
5888 exports.ɵangular_packages_router_router_d = provideLocationStrategy;
5889 exports.ɵangular_packages_router_router_k = provideRouterInitializer;
5890 exports.ɵangular_packages_router_router_g = rootRoute;
5891 exports.ɵangular_packages_router_router_b = routerNgProbeToken;
5892 exports.ɵangular_packages_router_router_f = setupRouter;
5893 exports.ɵangular_packages_router_router_o = RouterScroller;
5894 exports.ɵangular_packages_router_router_m = Tree;
5895 exports.ɵangular_packages_router_router_n = TreeNode;
5896 exports.RouterLink = RouterLink;
5897 exports.RouterLinkWithHref = RouterLinkWithHref;
5898 exports.RouterLinkActive = RouterLinkActive;
5899 exports.RouterOutlet = RouterOutlet;
5900 exports.ActivationEnd = ActivationEnd;
5901 exports.ActivationStart = ActivationStart;
5902 exports.ChildActivationEnd = ChildActivationEnd;
5903 exports.ChildActivationStart = ChildActivationStart;
5904 exports.GuardsCheckEnd = GuardsCheckEnd;
5905 exports.GuardsCheckStart = GuardsCheckStart;
5906 exports.NavigationCancel = NavigationCancel;
5907 exports.NavigationEnd = NavigationEnd;
5908 exports.NavigationError = NavigationError;
5909 exports.NavigationStart = NavigationStart;
5910 exports.ResolveEnd = ResolveEnd;
5911 exports.ResolveStart = ResolveStart;
5912 exports.RouteConfigLoadEnd = RouteConfigLoadEnd;
5913 exports.RouteConfigLoadStart = RouteConfigLoadStart;
5914 exports.RouterEvent = RouterEvent;
5915 exports.RoutesRecognized = RoutesRecognized;
5916 exports.Scroll = Scroll;
5917 exports.RouteReuseStrategy = RouteReuseStrategy;
5918 exports.Router = Router;
5919 exports.ROUTES = ROUTES;
5920 exports.ROUTER_CONFIGURATION = ROUTER_CONFIGURATION;
5921 exports.ROUTER_INITIALIZER = ROUTER_INITIALIZER;
5922 exports.RouterModule = RouterModule;
5923 exports.provideRoutes = provideRoutes;
5924 exports.ChildrenOutletContexts = ChildrenOutletContexts;
5925 exports.OutletContext = OutletContext;
5926 exports.NoPreloading = NoPreloading;
5927 exports.PreloadAllModules = PreloadAllModules;
5928 exports.PreloadingStrategy = PreloadingStrategy;
5929 exports.RouterPreloader = RouterPreloader;
5930 exports.ActivatedRoute = ActivatedRoute;
5931 exports.ActivatedRouteSnapshot = ActivatedRouteSnapshot;
5932 exports.RouterState = RouterState;
5933 exports.RouterStateSnapshot = RouterStateSnapshot;
5934 exports.PRIMARY_OUTLET = PRIMARY_OUTLET;
5935 exports.convertToParamMap = convertToParamMap;
5936 exports.UrlHandlingStrategy = UrlHandlingStrategy;
5937 exports.DefaultUrlSerializer = DefaultUrlSerializer;
5938 exports.UrlSegment = UrlSegment;
5939 exports.UrlSegmentGroup = UrlSegmentGroup;
5940 exports.UrlSerializer = UrlSerializer;
5941 exports.UrlTree = UrlTree;
5942 exports.VERSION = VERSION;
5943 exports.ɵROUTER_PROVIDERS = ROUTER_PROVIDERS;
5944 exports.ɵflatten = flatten;
5945
5946 Object.defineProperty(exports, '__esModule', { value: true });
5947
5948}));
5949//# sourceMappingURL=router.umd.js.map