@angular/router 14.1.0-next.1 → 14.1.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/esm2020/src/apply_redirects.mjs +12 -8
  2. package/esm2020/src/components/empty_outlet.mjs +3 -3
  3. package/esm2020/src/create_url_tree.mjs +6 -4
  4. package/esm2020/src/directives/router_link.mjs +6 -6
  5. package/esm2020/src/directives/router_link_active.mjs +3 -3
  6. package/esm2020/src/directives/router_outlet.mjs +14 -10
  7. package/esm2020/src/errors.mjs +2 -0
  8. package/esm2020/src/events.mjs +13 -3
  9. package/esm2020/src/index.mjs +1 -1
  10. package/esm2020/src/models.mjs +1 -1
  11. package/esm2020/src/operators/check_guards.mjs +15 -47
  12. package/esm2020/src/page_title_strategy.mjs +3 -3
  13. package/esm2020/src/private_export.mjs +2 -2
  14. package/esm2020/src/recognize.mjs +7 -7
  15. package/esm2020/src/router.mjs +22 -17
  16. package/esm2020/src/router_config_loader.mjs +3 -3
  17. package/esm2020/src/router_module.mjs +187 -138
  18. package/esm2020/src/router_preloader.mjs +16 -4
  19. package/esm2020/src/router_scroller.mjs +6 -5
  20. package/esm2020/src/shared.mjs +3 -2
  21. package/esm2020/src/url_tree.mjs +6 -4
  22. package/esm2020/src/utils/config.mjs +17 -17
  23. package/esm2020/src/utils/config_matching.mjs +5 -2
  24. package/esm2020/src/version.mjs +1 -1
  25. package/esm2020/testing/src/router_testing_module.mjs +8 -8
  26. package/fesm2015/router.mjs +332 -273
  27. package/fesm2015/router.mjs.map +1 -1
  28. package/fesm2015/testing.mjs +8 -8
  29. package/fesm2015/testing.mjs.map +1 -1
  30. package/fesm2015/upgrade.mjs +1 -1
  31. package/fesm2020/router.mjs +326 -270
  32. package/fesm2020/router.mjs.map +1 -1
  33. package/fesm2020/testing.mjs +8 -8
  34. package/fesm2020/testing.mjs.map +1 -1
  35. package/fesm2020/upgrade.mjs +1 -1
  36. package/index.d.ts +80 -9
  37. package/package.json +4 -4
  38. package/testing/index.d.ts +2 -2
  39. package/upgrade/index.d.ts +1 -1
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @license Angular v14.1.0-next.1
2
+ * @license Angular v14.1.0-next.4
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { ɵisObservable, ɵisPromise, EventEmitter, Directive, Attribute, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, InjectionToken, InjectFlags, NgModuleFactory, Injectable, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
8
+ import { ɵisObservable, ɵisPromise, ɵRuntimeError, EventEmitter, Directive, Attribute, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, InjectionToken, InjectFlags, NgModuleFactory, Injectable, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, Inject, ApplicationRef, ENVIRONMENT_INITIALIZER, Version } from '@angular/core';
9
9
  import { from, of, BehaviorSubject, combineLatest, concat, defer, pipe, throwError, EmptyError, Observable, EMPTY, ConnectableObservable, Subject } from 'rxjs';
10
10
  import { map, switchMap, take, startWith, scan, filter, mergeMap, first, concatMap, tap, catchError, last as last$1, takeWhile, defaultIfEmpty, takeLast, mapTo, finalize, refCount, mergeAll } from 'rxjs/operators';
11
11
  import * as i3 from '@angular/common';
12
- import { Location, LocationStrategy, PlatformLocation, APP_BASE_HREF, ViewportScroller, HashLocationStrategy, PathLocationStrategy, LOCATION_INITIALIZED } from '@angular/common';
12
+ import { Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy, ViewportScroller, LOCATION_INITIALIZED } from '@angular/common';
13
13
  import * as i1 from '@angular/platform-browser';
14
14
 
15
15
  /**
@@ -60,9 +60,10 @@ class ParamsAsMap {
60
60
  function convertToParamMap(params) {
61
61
  return new ParamsAsMap(params);
62
62
  }
63
+ const REDIRECTING_CANCELLATION_REASON = 'Redirecting to ';
63
64
  const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
64
65
  function navigationCancelingError(message) {
65
- const error = Error('NavigationCancelingError: ' + message);
66
+ const error = Error('NavigationCancelingError: ' + (message || ''));
66
67
  error[NAVIGATION_CANCELING_ERROR] = true;
67
68
  return error;
68
69
  }
@@ -191,6 +192,7 @@ function wrapIntoObservable(value) {
191
192
  * Use of this source code is governed by an MIT-style license that can be
192
193
  * found in the LICENSE file at https://angular.io/license
193
194
  */
195
+ const NG_DEV_MODE$7 = typeof ngDevMode === 'undefined' || ngDevMode;
194
196
  function createEmptyUrlTree() {
195
197
  return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
196
198
  }
@@ -655,7 +657,7 @@ class UrlParser {
655
657
  parseSegment() {
656
658
  const path = matchSegments(this.remaining);
657
659
  if (path === '' && this.peekStartsWith(';')) {
658
- throw new Error(`Empty path url segment cannot have parameters: '${this.remaining}'.`);
660
+ throw new ɵRuntimeError(4009 /* RuntimeErrorCode.EMPTY_PATH_WITH_PARAMS */, NG_DEV_MODE$7 && `Empty path url segment cannot have parameters: '${this.remaining}'.`);
659
661
  }
660
662
  this.capture(path);
661
663
  return new UrlSegment(decode(path), this.parseMatrixParams());
@@ -724,7 +726,7 @@ class UrlParser {
724
726
  // if is is not one of these characters, then the segment was unescaped
725
727
  // or the group was not closed
726
728
  if (next !== '/' && next !== ')' && next !== ';') {
727
- throw new Error(`Cannot parse url '${this.url}'`);
729
+ throw new ɵRuntimeError(4010 /* RuntimeErrorCode.UNPARSABLE_URL */, NG_DEV_MODE$7 && `Cannot parse url '${this.url}'`);
728
730
  }
729
731
  let outletName = undefined;
730
732
  if (path.indexOf(':') > -1) {
@@ -755,7 +757,7 @@ class UrlParser {
755
757
  }
756
758
  capture(str) {
757
759
  if (!this.consumeOptional(str)) {
758
- throw new Error(`Expected "${str}".`);
760
+ throw new ɵRuntimeError(4011 /* RuntimeErrorCode.UNEXPECTED_VALUE_IN_URL */, NG_DEV_MODE$7 && `Expected "${str}".`);
759
761
  }
760
762
  }
761
763
  }
@@ -805,6 +807,7 @@ function mergeTrivialChildren(s) {
805
807
  * Use of this source code is governed by an MIT-style license that can be
806
808
  * found in the LICENSE file at https://angular.io/license
807
809
  */
810
+ const NG_DEV_MODE$6 = typeof ngDevMode === 'undefined' || ngDevMode;
808
811
  /**
809
812
  * Creates a `UrlTree` relative to an `ActivatedRouteSnapshot`.
810
813
  *
@@ -982,11 +985,11 @@ class Navigation {
982
985
  this.numberOfDoubleDots = numberOfDoubleDots;
983
986
  this.commands = commands;
984
987
  if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
985
- throw new Error('Root segment cannot have matrix parameters');
988
+ throw new ɵRuntimeError(4003 /* RuntimeErrorCode.ROOT_SEGMENT_MATRIX_PARAMS */, NG_DEV_MODE$6 && 'Root segment cannot have matrix parameters');
986
989
  }
987
990
  const cmdWithOutlet = commands.find(isCommandWithOutlets);
988
991
  if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
989
- throw new Error('{outlets:{}} has to be the last command');
992
+ throw new ɵRuntimeError(4004 /* RuntimeErrorCode.MISPLACED_OUTLETS_COMMAND */, NG_DEV_MODE$6 && '{outlets:{}} has to be the last command');
990
993
  }
991
994
  }
992
995
  toRoot() {
@@ -1085,7 +1088,7 @@ function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
1085
1088
  dd -= ci;
1086
1089
  g = g.parent;
1087
1090
  if (!g) {
1088
- throw new Error('Invalid number of \'../\'');
1091
+ throw new ɵRuntimeError(4005 /* RuntimeErrorCode.INVALID_DOUBLE_DOTS */, NG_DEV_MODE$6 && 'Invalid number of \'../\'');
1089
1092
  }
1090
1093
  ci = g.segments.length;
1091
1094
  }
@@ -1340,10 +1343,20 @@ class NavigationCancel extends RouterEvent {
1340
1343
  id,
1341
1344
  /** @docsNotRequired */
1342
1345
  url,
1343
- /** @docsNotRequired */
1344
- reason) {
1346
+ /**
1347
+ * A description of why the navigation was cancelled. For debug purposes only. Use `code`
1348
+ * instead for a stable cancellation reason that can be used in production.
1349
+ */
1350
+ reason,
1351
+ /**
1352
+ * A code to indicate why the navigation was canceled. This cancellation code is stable for
1353
+ * the reason and can be relied on whereas the `reason` string could change and should not be
1354
+ * used in production.
1355
+ */
1356
+ code) {
1345
1357
  super(id, url);
1346
1358
  this.reason = reason;
1359
+ this.code = code;
1347
1360
  this.type = 2 /* EventType.NavigationCancel */;
1348
1361
  }
1349
1362
  /** @docsNotRequired */
@@ -2319,6 +2332,7 @@ class ChildrenOutletContexts {
2319
2332
  * Use of this source code is governed by an MIT-style license that can be
2320
2333
  * found in the LICENSE file at https://angular.io/license
2321
2334
  */
2335
+ const NG_DEV_MODE$5 = typeof ngDevMode === 'undefined' || ngDevMode;
2322
2336
  /**
2323
2337
  * @description
2324
2338
  *
@@ -2395,7 +2409,11 @@ class RouterOutlet {
2395
2409
  }
2396
2410
  /** @nodoc */
2397
2411
  ngOnDestroy() {
2398
- this.parentContexts.onChildOutletDestroyed(this.name);
2412
+ var _a;
2413
+ // Ensure that the registered outlet is this one before removing it on the context.
2414
+ if (((_a = this.parentContexts.getContext(this.name)) === null || _a === void 0 ? void 0 : _a.outlet) === this) {
2415
+ this.parentContexts.onChildOutletDestroyed(this.name);
2416
+ }
2399
2417
  }
2400
2418
  /** @nodoc */
2401
2419
  ngOnInit() {
@@ -2424,12 +2442,12 @@ class RouterOutlet {
2424
2442
  */
2425
2443
  get component() {
2426
2444
  if (!this.activated)
2427
- throw new Error('Outlet is not activated');
2445
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2428
2446
  return this.activated.instance;
2429
2447
  }
2430
2448
  get activatedRoute() {
2431
2449
  if (!this.activated)
2432
- throw new Error('Outlet is not activated');
2450
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2433
2451
  return this._activatedRoute;
2434
2452
  }
2435
2453
  get activatedRouteData() {
@@ -2443,7 +2461,7 @@ class RouterOutlet {
2443
2461
  */
2444
2462
  detach() {
2445
2463
  if (!this.activated)
2446
- throw new Error('Outlet is not activated');
2464
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2447
2465
  this.location.detach();
2448
2466
  const cmp = this.activated;
2449
2467
  this.activated = null;
@@ -2471,7 +2489,7 @@ class RouterOutlet {
2471
2489
  }
2472
2490
  activateWith(activatedRoute, resolverOrInjector) {
2473
2491
  if (this.isActivated) {
2474
- throw new Error('Cannot activate an already activated outlet');
2492
+ throw new ɵRuntimeError(4013 /* RuntimeErrorCode.OUTLET_ALREADY_ACTIVATED */, NG_DEV_MODE$5 && 'Cannot activate an already activated outlet');
2475
2493
  }
2476
2494
  this._activatedRoute = activatedRoute;
2477
2495
  const location = this.location;
@@ -2493,9 +2511,9 @@ class RouterOutlet {
2493
2511
  this.activateEvents.emit(this.activated.instance);
2494
2512
  }
2495
2513
  }
2496
- RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2497
- RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterOutlet, decorators: [{
2514
+ RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2515
+ RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2516
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterOutlet, decorators: [{
2499
2517
  type: Directive,
2500
2518
  args: [{ selector: 'router-outlet', exportAs: 'outlet' }]
2501
2519
  }], ctorParameters: function () {
@@ -2554,9 +2572,9 @@ function isComponentFactoryResolver(item) {
2554
2572
  */
2555
2573
  class ɵEmptyOutletComponent {
2556
2574
  }
2557
- ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2558
- ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0-next.1", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2559
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2575
+ ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2576
+ ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0-next.4", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2577
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2560
2578
  type: Component,
2561
2579
  args: [{ template: `<router-outlet></router-outlet>` }]
2562
2580
  }] });
@@ -2606,13 +2624,13 @@ function validateConfig(config, parentPath = '', requireStandaloneComponents = f
2606
2624
  }
2607
2625
  function assertStandalone(fullPath, component) {
2608
2626
  if (component && !ɵisStandalone(component)) {
2609
- throw new Error(`Invalid configuration of route '${fullPath}'. The component must be standalone.`);
2627
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}'. The component must be standalone.`);
2610
2628
  }
2611
2629
  }
2612
2630
  function validateNode(route, fullPath, requireStandaloneComponents) {
2613
2631
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
2614
2632
  if (!route) {
2615
- throw new Error(`
2633
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `
2616
2634
  Invalid configuration of route '${fullPath}': Encountered undefined route.
2617
2635
  The reason might be an extra comma.
2618
2636
 
@@ -2625,47 +2643,47 @@ function validateNode(route, fullPath, requireStandaloneComponents) {
2625
2643
  `);
2626
2644
  }
2627
2645
  if (Array.isArray(route)) {
2628
- throw new Error(`Invalid configuration of route '${fullPath}': Array cannot be specified`);
2646
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': Array cannot be specified`);
2629
2647
  }
2630
2648
  if (!route.component && !route.loadComponent && !route.children && !route.loadChildren &&
2631
2649
  (route.outlet && route.outlet !== PRIMARY_OUTLET)) {
2632
- throw new Error(`Invalid configuration of route '${fullPath}': a componentless route without children or loadChildren cannot have a named outlet set`);
2650
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': a componentless route without children or loadChildren cannot have a named outlet set`);
2633
2651
  }
2634
2652
  if (route.redirectTo && route.children) {
2635
- throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and children cannot be used together`);
2653
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': redirectTo and children cannot be used together`);
2636
2654
  }
2637
2655
  if (route.redirectTo && route.loadChildren) {
2638
- throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and loadChildren cannot be used together`);
2656
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': redirectTo and loadChildren cannot be used together`);
2639
2657
  }
2640
2658
  if (route.children && route.loadChildren) {
2641
- throw new Error(`Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`);
2659
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`);
2642
2660
  }
2643
2661
  if (route.redirectTo && (route.component || route.loadComponent)) {
2644
- throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and component/loadComponent cannot be used together`);
2662
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': redirectTo and component/loadComponent cannot be used together`);
2645
2663
  }
2646
2664
  if (route.component && route.loadComponent) {
2647
- throw new Error(`Invalid configuration of route '${fullPath}': component and loadComponent cannot be used together`);
2665
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': component and loadComponent cannot be used together`);
2648
2666
  }
2649
2667
  if (route.redirectTo && route.canActivate) {
2650
- throw new Error(`Invalid configuration of route '${fullPath}': redirectTo and canActivate cannot be used together. Redirects happen before activation ` +
2668
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': redirectTo and canActivate cannot be used together. Redirects happen before activation ` +
2651
2669
  `so canActivate will never be executed.`);
2652
2670
  }
2653
2671
  if (route.path && route.matcher) {
2654
- throw new Error(`Invalid configuration of route '${fullPath}': path and matcher cannot be used together`);
2672
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': path and matcher cannot be used together`);
2655
2673
  }
2656
2674
  if (route.redirectTo === void 0 && !route.component && !route.loadComponent &&
2657
2675
  !route.children && !route.loadChildren) {
2658
- throw new Error(`Invalid configuration of route '${fullPath}'. One of the following must be provided: component, loadComponent, redirectTo, children or loadChildren`);
2676
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}'. One of the following must be provided: component, loadComponent, redirectTo, children or loadChildren`);
2659
2677
  }
2660
2678
  if (route.path === void 0 && route.matcher === void 0) {
2661
- throw new Error(`Invalid configuration of route '${fullPath}': routes must have either a path or a matcher specified`);
2679
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': routes must have either a path or a matcher specified`);
2662
2680
  }
2663
2681
  if (typeof route.path === 'string' && route.path.charAt(0) === '/') {
2664
- throw new Error(`Invalid configuration of route '${fullPath}': path cannot start with a slash`);
2682
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}': path cannot start with a slash`);
2665
2683
  }
2666
2684
  if (route.path === '' && route.redirectTo !== void 0 && route.pathMatch === void 0) {
2667
2685
  const exp = `The default value of 'pathMatch' is 'prefix', but often the intent is to use 'full'.`;
2668
- throw new Error(`Invalid configuration of route '{path: "${fullPath}", redirectTo: "${route.redirectTo}"}': please provide 'pathMatch'. ${exp}`);
2686
+ throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '{path: "${fullPath}", redirectTo: "${route.redirectTo}"}': please provide 'pathMatch'. ${exp}`);
2669
2687
  }
2670
2688
  if (requireStandaloneComponents) {
2671
2689
  assertStandalone(fullPath, route.component);
@@ -3221,17 +3239,9 @@ function runCanActivate(futureRSS, futureARS, moduleInjector) {
3221
3239
  const canActivateObservables = canActivate.map((c) => {
3222
3240
  return defer(() => {
3223
3241
  const guard = getToken(c, futureARS, moduleInjector);
3224
- let observable;
3225
- if (isCanActivate(guard)) {
3226
- observable = wrapIntoObservable(guard.canActivate(futureARS, futureRSS));
3227
- }
3228
- else if (isFunction(guard)) {
3229
- observable = wrapIntoObservable(guard(futureARS, futureRSS));
3230
- }
3231
- else {
3232
- throw new Error('Invalid CanActivate guard');
3233
- }
3234
- return observable.pipe(first());
3242
+ const guardVal = isCanActivate(guard) ? guard.canActivate(futureARS, futureRSS) :
3243
+ guard(futureARS, futureRSS);
3244
+ return wrapIntoObservable(guardVal).pipe(first());
3235
3245
  });
3236
3246
  });
3237
3247
  return of(canActivateObservables).pipe(prioritizedGuardValue());
@@ -3246,17 +3256,9 @@ function runCanActivateChild(futureRSS, path, moduleInjector) {
3246
3256
  return defer(() => {
3247
3257
  const guardsMapped = d.guards.map((c) => {
3248
3258
  const guard = getToken(c, d.node, moduleInjector);
3249
- let observable;
3250
- if (isCanActivateChild(guard)) {
3251
- observable = wrapIntoObservable(guard.canActivateChild(futureARS, futureRSS));
3252
- }
3253
- else if (isFunction(guard)) {
3254
- observable = wrapIntoObservable(guard(futureARS, futureRSS));
3255
- }
3256
- else {
3257
- throw new Error('Invalid CanActivateChild guard');
3258
- }
3259
- return observable.pipe(first());
3259
+ const guardVal = isCanActivateChild(guard) ? guard.canActivateChild(futureARS, futureRSS) :
3260
+ guard(futureARS, futureRSS);
3261
+ return wrapIntoObservable(guardVal).pipe(first());
3260
3262
  });
3261
3263
  return of(guardsMapped).pipe(prioritizedGuardValue());
3262
3264
  });
@@ -3269,17 +3271,10 @@ function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector
3269
3271
  return of(true);
3270
3272
  const canDeactivateObservables = canDeactivate.map((c) => {
3271
3273
  const guard = getToken(c, currARS, moduleInjector);
3272
- let observable;
3273
- if (isCanDeactivate(guard)) {
3274
- observable = wrapIntoObservable(guard.canDeactivate(component, currARS, currRSS, futureRSS));
3275
- }
3276
- else if (isFunction(guard)) {
3277
- observable = wrapIntoObservable(guard(component, currARS, currRSS, futureRSS));
3278
- }
3279
- else {
3280
- throw new Error('Invalid CanDeactivate guard');
3281
- }
3282
- return observable.pipe(first());
3274
+ const guardVal = isCanDeactivate(guard) ?
3275
+ guard.canDeactivate(component, currARS, currRSS, futureRSS) :
3276
+ guard(component, currARS, currRSS, futureRSS);
3277
+ return wrapIntoObservable(guardVal).pipe(first());
3283
3278
  });
3284
3279
  return of(canDeactivateObservables).pipe(prioritizedGuardValue());
3285
3280
  }
@@ -3290,16 +3285,7 @@ function runCanLoadGuards(injector, route, segments, urlSerializer) {
3290
3285
  }
3291
3286
  const canLoadObservables = canLoad.map((injectionToken) => {
3292
3287
  const guard = injector.get(injectionToken);
3293
- let guardVal;
3294
- if (isCanLoad(guard)) {
3295
- guardVal = guard.canLoad(route, segments);
3296
- }
3297
- else if (isFunction(guard)) {
3298
- guardVal = guard(route, segments);
3299
- }
3300
- else {
3301
- throw new Error('Invalid CanLoad guard');
3302
- }
3288
+ const guardVal = isCanLoad(guard) ? guard.canLoad(route, segments) : guard(route, segments);
3303
3289
  return wrapIntoObservable(guardVal);
3304
3290
  });
3305
3291
  return of(canLoadObservables)
@@ -3309,7 +3295,7 @@ function redirectIfUrlTree(urlSerializer) {
3309
3295
  return pipe(tap((result) => {
3310
3296
  if (!isUrlTree(result))
3311
3297
  return;
3312
- const error = navigationCancelingError(`Redirecting to "${urlSerializer.serialize(result)}"`);
3298
+ const error = navigationCancelingError(REDIRECTING_CANCELLATION_REASON + urlSerializer.serialize(result));
3313
3299
  error.url = result;
3314
3300
  throw error;
3315
3301
  }), map(result => result === true));
@@ -3346,6 +3332,9 @@ function matchWithChecks(segmentGroup, route, segments, injector, urlSerializer)
3346
3332
  if (!result.matched) {
3347
3333
  return of(result);
3348
3334
  }
3335
+ // Only create the Route's `EnvironmentInjector` if it matches the attempted
3336
+ // navigation
3337
+ injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3349
3338
  return runCanMatchGuards(injector, route, segments, urlSerializer)
3350
3339
  .pipe(map((v) => v === true ? result : Object.assign({}, noMatch$1)));
3351
3340
  }
@@ -3486,6 +3475,7 @@ function noLeftoversInUrl(segmentGroup, segments, outlet) {
3486
3475
  * Use of this source code is governed by an MIT-style license that can be
3487
3476
  * found in the LICENSE file at https://angular.io/license
3488
3477
  */
3478
+ const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || ngDevMode;
3489
3479
  class NoMatch$1 {
3490
3480
  constructor(segmentGroup) {
3491
3481
  this.segmentGroup = segmentGroup || null;
@@ -3503,10 +3493,12 @@ function absoluteRedirect(newTree) {
3503
3493
  return throwError(new AbsoluteRedirect(newTree));
3504
3494
  }
3505
3495
  function namedOutletsRedirect(redirectTo) {
3506
- return throwError(new Error(`Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`));
3496
+ return throwError(new ɵRuntimeError(4000 /* RuntimeErrorCode.NAMED_OUTLET_REDIRECT */, NG_DEV_MODE$4 &&
3497
+ `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`));
3507
3498
  }
3508
3499
  function canLoadFails(route) {
3509
- return throwError(navigationCancelingError(`Cannot load children because the guard of the route "path: '${route.path}'" returned false`));
3500
+ return throwError(navigationCancelingError(NG_DEV_MODE$4 &&
3501
+ `Cannot load children because the guard of the route "path: '${route.path}'" returned false`));
3510
3502
  }
3511
3503
  /**
3512
3504
  * Returns the `UrlTree` with the redirection applied.
@@ -3565,7 +3557,7 @@ class ApplyRedirects {
3565
3557
  }));
3566
3558
  }
3567
3559
  noMatchError(e) {
3568
- return new Error(`Cannot match any routes. URL Segment: '${e.segmentGroup}'`);
3560
+ return new ɵRuntimeError(4002 /* RuntimeErrorCode.NO_MATCH */, NG_DEV_MODE$4 && `Cannot match any routes. URL Segment: '${e.segmentGroup}'`);
3569
3561
  }
3570
3562
  createUrlTree(rootCandidate, queryParams, fragment) {
3571
3563
  const root = createRoot(rootCandidate);
@@ -3682,11 +3674,11 @@ class ApplyRedirects {
3682
3674
  }
3683
3675
  return matchWithChecks(rawSegmentGroup, route, segments, injector, this.urlSerializer)
3684
3676
  .pipe(switchMap(({ matched, consumedSegments, remainingSegments }) => {
3677
+ var _a;
3685
3678
  if (!matched)
3686
3679
  return noMatch(rawSegmentGroup);
3687
- // Only create the Route's `EnvironmentInjector` if it matches the attempted
3688
- // navigation
3689
- injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3680
+ // If the route has an injector created from providers, we should start using that.
3681
+ injector = (_a = route._injector) !== null && _a !== void 0 ? _a : injector;
3690
3682
  const childConfig$ = this.getChildConfig(injector, route, segments);
3691
3683
  return childConfig$.pipe(mergeMap((routerConfig) => {
3692
3684
  var _a;
@@ -3782,7 +3774,8 @@ class ApplyRedirects {
3782
3774
  findPosParam(redirectTo, redirectToUrlSegment, posParams) {
3783
3775
  const pos = posParams[redirectToUrlSegment.path.substring(1)];
3784
3776
  if (!pos)
3785
- throw new Error(`Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3777
+ throw new ɵRuntimeError(4001 /* RuntimeErrorCode.MISSING_REDIRECT */, NG_DEV_MODE$4 &&
3778
+ `Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3786
3779
  return pos;
3787
3780
  }
3788
3781
  findOrReturn(redirectToUrlSegment, actualSegments) {
@@ -3817,7 +3810,7 @@ function applyRedirects(environmentInjector, configLoader, urlSerializer, config
3817
3810
  * Use of this source code is governed by an MIT-style license that can be
3818
3811
  * found in the LICENSE file at https://angular.io/license
3819
3812
  */
3820
- const NG_DEV_MODE$2 = typeof ngDevMode === 'undefined' || !!ngDevMode;
3813
+ const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || !!ngDevMode;
3821
3814
  class NoMatch {
3822
3815
  }
3823
3816
  function newObservableError(e) {
@@ -3906,7 +3899,7 @@ class Recognizer {
3906
3899
  // multiple activated results for the same outlet. We should merge the children of
3907
3900
  // these results so the final return value is only one `TreeNode` per outlet.
3908
3901
  const mergedChildren = mergeEmptyPathMatches(children);
3909
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
3902
+ if (NG_DEV_MODE$3) {
3910
3903
  // This should really never happen - we are only taking the first match for each
3911
3904
  // outlet and merge the empty path matches.
3912
3905
  checkOutletNameUniqueness(mergedChildren);
@@ -3941,7 +3934,7 @@ class Recognizer {
3941
3934
  // NG_DEV_MODE is used to prevent the getCorrectedPathIndexShift function from affecting
3942
3935
  // production bundle size. This value is intended only to surface a warning to users
3943
3936
  // depending on `relativeLinkResolution: 'legacy'` in dev mode.
3944
- (NG_DEV_MODE$2 ? getCorrectedPathIndexShift(rawSegment) + segments.length :
3937
+ (NG_DEV_MODE$3 ? getCorrectedPathIndexShift(rawSegment) + segments.length :
3945
3938
  pathIndexShift));
3946
3939
  matchResult = of({
3947
3940
  snapshot,
@@ -3958,22 +3951,21 @@ class Recognizer {
3958
3951
  return null;
3959
3952
  }
3960
3953
  const pathIndexShift = getPathIndexShift(rawSegment) + consumedSegments.length;
3961
- const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_b = (_a = route.component) !== null && _a !== void 0 ? _a : route._loadedComponent) !== null && _b !== void 0 ? _b : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$2 ?
3954
+ const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze(Object.assign({}, this.urlTree.queryParams)), this.urlTree.fragment, getData(route), getOutlet(route), (_b = (_a = route.component) !== null && _a !== void 0 ? _a : route._loadedComponent) !== null && _b !== void 0 ? _b : null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$3 ?
3962
3955
  getCorrectedPathIndexShift(rawSegment) + consumedSegments.length :
3963
3956
  pathIndexShift));
3964
3957
  return { snapshot, consumedSegments, remainingSegments };
3965
3958
  }));
3966
3959
  }
3967
3960
  return matchResult.pipe(switchMap((result) => {
3968
- var _a;
3961
+ var _a, _b;
3969
3962
  if (result === null) {
3970
3963
  return of(null);
3971
3964
  }
3972
3965
  const { snapshot, consumedSegments, remainingSegments } = result;
3973
- // Only create the Route's `EnvironmentInjector` if it matches the attempted
3974
- // navigation
3975
- injector = getOrCreateRouteInjectorIfNeeded(route, injector);
3976
- const childInjector = (_a = route._loadedInjector) !== null && _a !== void 0 ? _a : injector;
3966
+ // If the route has an injector created from providers, we should start using that.
3967
+ injector = (_a = route._injector) !== null && _a !== void 0 ? _a : injector;
3968
+ const childInjector = (_b = route._loadedInjector) !== null && _b !== void 0 ? _b : injector;
3977
3969
  const childConfig = getChildConfig(route);
3978
3970
  const { segmentGroup, slicedSegments } = split(rawSegment, consumedSegments, remainingSegments,
3979
3971
  // Filter out routes with redirectTo because we are trying to create activated route
@@ -4073,7 +4065,7 @@ function checkOutletNameUniqueness(nodes) {
4073
4065
  if (routeWithSameOutletName) {
4074
4066
  const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
4075
4067
  const c = n.value.url.map(s => s.toString()).join('/');
4076
- throw new Error(`Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
4068
+ throw new ɵRuntimeError(4006 /* RuntimeErrorCode.TWO_SEGMENTS_WITH_SAME_OUTLET */, NG_DEV_MODE$3 && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
4077
4069
  }
4078
4070
  names[n.value.outlet] = n.value;
4079
4071
  });
@@ -4282,7 +4274,7 @@ class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
4282
4274
  * Use of this source code is governed by an MIT-style license that can be
4283
4275
  * found in the LICENSE file at https://angular.io/license
4284
4276
  */
4285
- const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4277
+ const NG_DEV_MODE$2 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4286
4278
  /**
4287
4279
  * The [DI token](guide/glossary/#di-token) for a router configuration.
4288
4280
  *
@@ -4317,7 +4309,7 @@ class RouterConfigLoader {
4317
4309
  if (this.onLoadEndListener) {
4318
4310
  this.onLoadEndListener(route);
4319
4311
  }
4320
- NG_DEV_MODE$1 && assertStandalone((_a = route.path) !== null && _a !== void 0 ? _a : '', component);
4312
+ NG_DEV_MODE$2 && assertStandalone((_a = route.path) !== null && _a !== void 0 ? _a : '', component);
4321
4313
  route._loadedComponent = component;
4322
4314
  }), finalize(() => {
4323
4315
  this.componentLoaders.delete(route);
@@ -4360,7 +4352,7 @@ class RouterConfigLoader {
4360
4352
  rawRoutes = flatten(injector.get(ROUTES, [], InjectFlags.Self | InjectFlags.Optional));
4361
4353
  }
4362
4354
  const routes = rawRoutes.map(standardizeConfig);
4363
- NG_DEV_MODE$1 && validateConfig(routes, route.path, requireStandaloneComponents);
4355
+ NG_DEV_MODE$2 && validateConfig(routes, route.path, requireStandaloneComponents);
4364
4356
  return { routes, injector };
4365
4357
  }), finalize(() => {
4366
4358
  this.childrenLoaders.delete(route);
@@ -4382,9 +4374,9 @@ class RouterConfigLoader {
4382
4374
  }));
4383
4375
  }
4384
4376
  }
4385
- RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4386
- RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader });
4387
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterConfigLoader, decorators: [{
4377
+ RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4378
+ RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader });
4379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader, decorators: [{
4388
4380
  type: Injectable
4389
4381
  }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }]; } });
4390
4382
 
@@ -4419,7 +4411,7 @@ class DefaultUrlHandlingStrategy {
4419
4411
  }
4420
4412
  }
4421
4413
 
4422
- const NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
4414
+ const NG_DEV_MODE$1 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4423
4415
  function defaultErrorHandler(error) {
4424
4416
  throw error;
4425
4417
  }
@@ -4733,7 +4725,8 @@ class Router {
4733
4725
  this.triggerEvent(guardsStart);
4734
4726
  }), map(t => (Object.assign(Object.assign({}, t), { guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.rootContexts) }))), checkGuards(this.ngModule.injector, (evt) => this.triggerEvent(evt)), tap(t => {
4735
4727
  if (isUrlTree(t.guardsResult)) {
4736
- const error = navigationCancelingError(`Redirecting to "${this.serializeUrl(t.guardsResult)}"`);
4728
+ const error = navigationCancelingError(REDIRECTING_CANCELLATION_REASON +
4729
+ `"${this.serializeUrl(t.guardsResult)}"`);
4737
4730
  error.url = t.guardsResult;
4738
4731
  throw error;
4739
4732
  }
@@ -4742,7 +4735,7 @@ class Router {
4742
4735
  }), filter(t => {
4743
4736
  if (!t.guardsResult) {
4744
4737
  this.restoreHistory(t);
4745
- this.cancelNavigationTransition(t, '');
4738
+ this.cancelNavigationTransition(t, '', 3 /* NavigationCancellationCode.GuardRejected */);
4746
4739
  return false;
4747
4740
  }
4748
4741
  return true;
@@ -4760,7 +4753,9 @@ class Router {
4760
4753
  complete: () => {
4761
4754
  if (!dataResolved) {
4762
4755
  this.restoreHistory(t);
4763
- this.cancelNavigationTransition(t, `At least one route resolver didn't emit any value.`);
4756
+ this.cancelNavigationTransition(t, NG_DEV_MODE$1 ?
4757
+ `At least one route resolver didn't emit any value.` :
4758
+ '', 2 /* NavigationCancellationCode.NoDataFromResolver */);
4764
4759
  }
4765
4760
  }
4766
4761
  }));
@@ -4770,7 +4765,7 @@ class Router {
4770
4765
  }));
4771
4766
  }
4772
4767
  return undefined;
4773
- }), switchTap(() => this.afterPreactivation()),
4768
+ }),
4774
4769
  // --- LOAD COMPONENTS ---
4775
4770
  switchTap((t) => {
4776
4771
  const loadComponents = (route) => {
@@ -4790,7 +4785,7 @@ class Router {
4790
4785
  };
4791
4786
  return combineLatest(loadComponents(t.targetSnapshot.root))
4792
4787
  .pipe(defaultIfEmpty(), take(1));
4793
- }), map((t) => {
4788
+ }), switchTap(() => this.afterPreactivation()), map((t) => {
4794
4789
  const targetRouterState = createRouterState(this.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4795
4790
  return (Object.assign(Object.assign({}, t), { targetRouterState }));
4796
4791
  }),
@@ -4827,8 +4822,10 @@ class Router {
4827
4822
  * event is fired when a navigation gets cancelled but not caught by other
4828
4823
  * means. */
4829
4824
  if (!completed && !errored) {
4830
- const cancelationReason = `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}`;
4831
- this.cancelNavigationTransition(t, cancelationReason);
4825
+ const cancelationReason = NG_DEV_MODE$1 ?
4826
+ `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}` :
4827
+ '';
4828
+ this.cancelNavigationTransition(t, cancelationReason, 1 /* NavigationCancellationCode.SupersededByNewNavigation */);
4832
4829
  }
4833
4830
  // Only clear current navigation if it is still set to the one that
4834
4831
  // finalized.
@@ -4861,7 +4858,7 @@ class Router {
4861
4858
  this.navigated = true;
4862
4859
  this.restoreHistory(t, true);
4863
4860
  }
4864
- const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), e.message);
4861
+ const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), e.message, 0 /* NavigationCancellationCode.Redirect */);
4865
4862
  eventsSubject.next(navCancel);
4866
4863
  // When redirecting, we need to delay resolving the navigation
4867
4864
  // promise and push it to the redirect navigation
@@ -4990,7 +4987,7 @@ class Router {
4990
4987
  * ```
4991
4988
  */
4992
4989
  resetConfig(config) {
4993
- NG_DEV_MODE && validateConfig(config);
4990
+ NG_DEV_MODE$1 && validateConfig(config);
4994
4991
  this.config = config.map(standardizeConfig);
4995
4992
  this.navigated = false;
4996
4993
  this.lastSuccessfulId = -1;
@@ -5336,8 +5333,8 @@ class Router {
5336
5333
  resetUrlToCurrentUrlTree() {
5337
5334
  this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
5338
5335
  }
5339
- cancelNavigationTransition(t, reason) {
5340
- const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), reason);
5336
+ cancelNavigationTransition(t, reason, code) {
5337
+ const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), reason, code);
5341
5338
  this.triggerEvent(navCancel);
5342
5339
  t.resolve(false);
5343
5340
  }
@@ -5348,16 +5345,16 @@ class Router {
5348
5345
  return { navigationId };
5349
5346
  }
5350
5347
  }
5351
- Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5352
- Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router });
5353
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: Router, decorators: [{
5348
+ Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5349
+ Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router });
5350
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router, decorators: [{
5354
5351
  type: Injectable
5355
5352
  }], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
5356
5353
  function validateCommands(commands) {
5357
5354
  for (let i = 0; i < commands.length; i++) {
5358
5355
  const cmd = commands[i];
5359
5356
  if (cmd == null) {
5360
- throw new Error(`The requested path contains ${cmd} segment at index ${i}`);
5357
+ throw new ɵRuntimeError(4008 /* RuntimeErrorCode.NULLISH_COMMAND */, NG_DEV_MODE$1 && `The requested path contains ${cmd} segment at index ${i}`);
5361
5358
  }
5362
5359
  }
5363
5360
  }
@@ -5542,9 +5539,9 @@ class RouterLink {
5542
5539
  });
5543
5540
  }
5544
5541
  }
5545
- RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5546
- RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5547
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLink, decorators: [{
5542
+ RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5543
+ RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5544
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLink, decorators: [{
5548
5545
  type: Directive,
5549
5546
  args: [{ selector: ':not(a):not(area)[routerLink]' }]
5550
5547
  }], ctorParameters: function () {
@@ -5663,9 +5660,9 @@ class RouterLinkWithHref {
5663
5660
  });
5664
5661
  }
5665
5662
  }
5666
- RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5667
- RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5668
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5663
+ RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5664
+ RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5669
5666
  type: Directive,
5670
5667
  args: [{ selector: 'a[routerLink],area[routerLink]' }]
5671
5668
  }], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: i3.LocationStrategy }]; }, propDecorators: { target: [{
@@ -5892,9 +5889,9 @@ class RouterLinkActive {
5892
5889
  this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
5893
5890
  }
5894
5891
  }
5895
- RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
5896
- RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.1", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
5897
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterLinkActive, decorators: [{
5892
+ RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
5893
+ RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
5894
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkActive, decorators: [{
5898
5895
  type: Directive,
5899
5896
  args: [{
5900
5897
  selector: '[routerLinkActive]',
@@ -6000,9 +5997,9 @@ class DefaultTitleStrategy extends TitleStrategy {
6000
5997
  }
6001
5998
  }
6002
5999
  }
6003
- DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
6004
- DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
6005
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
6000
+ DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
6001
+ DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
6002
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
6006
6003
  type: Injectable,
6007
6004
  args: [{ providedIn: 'root' }]
6008
6005
  }], ctorParameters: function () { return [{ type: i1.Title }]; } });
@@ -6039,6 +6036,12 @@ class PreloadAllModules {
6039
6036
  return fn().pipe(catchError(() => of(null)));
6040
6037
  }
6041
6038
  }
6039
+ PreloadAllModules.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6040
+ PreloadAllModules.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, providedIn: 'root' });
6041
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, decorators: [{
6042
+ type: Injectable,
6043
+ args: [{ providedIn: 'root' }]
6044
+ }] });
6042
6045
  /**
6043
6046
  * @description
6044
6047
  *
@@ -6053,6 +6056,12 @@ class NoPreloading {
6053
6056
  return of(null);
6054
6057
  }
6055
6058
  }
6059
+ NoPreloading.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6060
+ NoPreloading.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, providedIn: 'root' });
6061
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, decorators: [{
6062
+ type: Injectable,
6063
+ args: [{ providedIn: 'root' }]
6064
+ }] });
6056
6065
  /**
6057
6066
  * The preloader optimistically loads all router configurations to
6058
6067
  * make navigations into lazily-loaded sections of the application faster.
@@ -6137,12 +6146,13 @@ class RouterPreloader {
6137
6146
  });
6138
6147
  }
6139
6148
  }
6140
- RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6141
- RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader });
6142
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterPreloader, decorators: [{
6149
+ RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6150
+ RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader });
6151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader, decorators: [{
6143
6152
  type: Injectable
6144
6153
  }], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.EnvironmentInjector }, { type: PreloadingStrategy }, { type: RouterConfigLoader }]; } });
6145
6154
 
6155
+ const ROUTER_SCROLLER = new InjectionToken('');
6146
6156
  class RouterScroller {
6147
6157
  constructor(router,
6148
6158
  /** @docsNotRequired */ viewportScroller, options = {}) {
@@ -6218,9 +6228,9 @@ class RouterScroller {
6218
6228
  }
6219
6229
  }
6220
6230
  }
6221
- RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6222
- RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller });
6223
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterScroller, decorators: [{
6231
+ RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6232
+ RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller });
6233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller, decorators: [{
6224
6234
  type: Injectable
6225
6235
  }], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: undefined }]; } });
6226
6236
 
@@ -6231,6 +6241,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1",
6231
6241
  * Use of this source code is governed by an MIT-style license that can be
6232
6242
  * found in the LICENSE file at https://angular.io/license
6233
6243
  */
6244
+ const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
6234
6245
  /**
6235
6246
  * The directives defined in the `RouterModule`.
6236
6247
  */
@@ -6240,11 +6251,15 @@ const ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkWithHref, RouterL
6240
6251
  *
6241
6252
  * @publicApi
6242
6253
  */
6243
- const ROUTER_CONFIGURATION = new InjectionToken('ROUTER_CONFIGURATION');
6254
+ const ROUTER_CONFIGURATION = new InjectionToken(NG_DEV_MODE ? 'router config' : 'ROUTER_CONFIGURATION', {
6255
+ providedIn: 'root',
6256
+ factory: () => ({}),
6257
+ });
6244
6258
  /**
6245
6259
  * @docsNotRequired
6246
6260
  */
6247
- const ROUTER_FORROOT_GUARD = new InjectionToken('ROUTER_FORROOT_GUARD');
6261
+ const ROUTER_FORROOT_GUARD = new InjectionToken(NG_DEV_MODE ? 'router duplicate forRoot guard' : 'ROUTER_FORROOT_GUARD');
6262
+ const ROUTER_PRELOADER = new InjectionToken(NG_DEV_MODE ? 'router preloader' : '');
6248
6263
  const ROUTER_PROVIDERS = [
6249
6264
  Location,
6250
6265
  { provide: UrlSerializer, useClass: DefaultUrlSerializer },
@@ -6259,10 +6274,6 @@ const ROUTER_PROVIDERS = [
6259
6274
  },
6260
6275
  ChildrenOutletContexts,
6261
6276
  { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
6262
- RouterPreloader,
6263
- NoPreloading,
6264
- PreloadAllModules,
6265
- { provide: ROUTER_CONFIGURATION, useValue: { enableTracing: false } },
6266
6277
  RouterConfigLoader,
6267
6278
  ];
6268
6279
  function routerNgProbeToken() {
@@ -6315,6 +6326,7 @@ class RouterModule {
6315
6326
  ngModule: RouterModule,
6316
6327
  providers: [
6317
6328
  ROUTER_PROVIDERS,
6329
+ NG_DEV_MODE ? ((config === null || config === void 0 ? void 0 : config.enableTracing) ? provideTracing() : []) : [],
6318
6330
  provideRoutes(routes),
6319
6331
  {
6320
6332
  provide: ROUTER_FORROOT_GUARD,
@@ -6322,22 +6334,11 @@ class RouterModule {
6322
6334
  deps: [[Router, new Optional(), new SkipSelf()]]
6323
6335
  },
6324
6336
  { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },
6325
- {
6326
- provide: LocationStrategy,
6327
- useFactory: provideLocationStrategy,
6328
- deps: [PlatformLocation, [new Inject(APP_BASE_HREF), new Optional()], ROUTER_CONFIGURATION]
6329
- },
6330
- {
6331
- provide: RouterScroller,
6332
- useFactory: createRouterScroller,
6333
- deps: [Router, ViewportScroller, ROUTER_CONFIGURATION]
6334
- },
6335
- {
6336
- provide: PreloadingStrategy,
6337
- useExisting: config && config.preloadingStrategy ? config.preloadingStrategy :
6338
- NoPreloading
6339
- },
6337
+ (config === null || config === void 0 ? void 0 : config.useHash) ? provideHashLocationStrategy() : providePathLocationStrategy(),
6338
+ provideRouterScroller(),
6339
+ (config === null || config === void 0 ? void 0 : config.preloadingStrategy) ? providePreloading(config.preloadingStrategy) : [],
6340
6340
  { provide: NgProbeToken, multi: true, useFactory: routerNgProbeToken },
6341
+ (config === null || config === void 0 ? void 0 : config.initialNavigation) ? provideInitialNavigation(config) : [],
6341
6342
  provideRouterInitializer(),
6342
6343
  ],
6343
6344
  };
@@ -6362,10 +6363,10 @@ class RouterModule {
6362
6363
  return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
6363
6364
  }
6364
6365
  }
6365
- RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6366
- RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6367
- RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule });
6368
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterModule, decorators: [{
6366
+ RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6367
+ RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6368
+ RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule });
6369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, decorators: [{
6369
6370
  type: NgModule,
6370
6371
  args: [{
6371
6372
  declarations: ROUTER_DIRECTIVES,
@@ -6381,19 +6382,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1",
6381
6382
  type: Optional
6382
6383
  }] }];
6383
6384
  } });
6384
- function createRouterScroller(router, viewportScroller, config) {
6385
- if (config.scrollOffset) {
6386
- viewportScroller.setOffset(config.scrollOffset);
6387
- }
6388
- return new RouterScroller(router, viewportScroller, config);
6385
+ function provideRouterScroller() {
6386
+ return {
6387
+ provide: ROUTER_SCROLLER,
6388
+ useFactory: () => {
6389
+ const router = inject(Router);
6390
+ const viewportScroller = inject(ViewportScroller);
6391
+ const config = inject(ROUTER_CONFIGURATION);
6392
+ if (config.scrollOffset) {
6393
+ viewportScroller.setOffset(config.scrollOffset);
6394
+ }
6395
+ return new RouterScroller(router, viewportScroller, config);
6396
+ },
6397
+ };
6389
6398
  }
6390
- function provideLocationStrategy(platformLocationStrategy, baseHref, options = {}) {
6391
- return options.useHash ? new HashLocationStrategy(platformLocationStrategy, baseHref) :
6392
- new PathLocationStrategy(platformLocationStrategy, baseHref);
6399
+ function provideHashLocationStrategy() {
6400
+ return { provide: LocationStrategy, useClass: HashLocationStrategy };
6401
+ }
6402
+ function providePathLocationStrategy() {
6403
+ return { provide: LocationStrategy, useClass: PathLocationStrategy };
6393
6404
  }
6394
6405
  function provideForRootGuard(router) {
6395
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && router) {
6396
- throw new Error(`RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.`);
6406
+ if (NG_DEV_MODE && router) {
6407
+ throw new ɵRuntimeError(4007 /* RuntimeErrorCode.FOR_ROOT_CALLED_TWICE */, `RouterModule.forRoot() called twice. Lazy loaded modules should use RouterModule.forChild() instead.`);
6397
6408
  }
6398
6409
  return 'guarded';
6399
6410
  }
@@ -6429,17 +6440,6 @@ function setupRouter(urlSerializer, contexts, location, injector, compiler, conf
6429
6440
  }
6430
6441
  router.titleStrategy = titleStrategy !== null && titleStrategy !== void 0 ? titleStrategy : defaultTitleStrategy;
6431
6442
  assignExtraOptionsToRouter(opts, router);
6432
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && opts.enableTracing) {
6433
- router.events.subscribe((e) => {
6434
- var _a, _b;
6435
- // tslint:disable:no-console
6436
- (_a = console.group) === null || _a === void 0 ? void 0 : _a.call(console, `Router Event: ${e.constructor.name}`);
6437
- console.log(stringifyEvent(e));
6438
- console.log(e);
6439
- (_b = console.groupEnd) === null || _b === void 0 ? void 0 : _b.call(console);
6440
- // tslint:enable:no-console
6441
- });
6442
- }
6443
6443
  return router;
6444
6444
  }
6445
6445
  function assignExtraOptionsToRouter(opts, router) {
@@ -6468,112 +6468,171 @@ function assignExtraOptionsToRouter(opts, router) {
6468
6468
  function rootRoute(router) {
6469
6469
  return router.routerState.root;
6470
6470
  }
6471
- /**
6472
- * Router initialization requires two steps:
6473
- *
6474
- * First, we start the navigation in a `APP_INITIALIZER` to block the bootstrap if
6475
- * a resolver or a guard executes asynchronously.
6476
- *
6477
- * Next, we actually run activation in a `BOOTSTRAP_LISTENER`, using the
6478
- * `afterPreactivation` hook provided by the router.
6479
- * The router navigation starts, reaches the point when preactivation is done, and then
6480
- * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
6481
- */
6482
- class RouterInitializer {
6483
- constructor(injector) {
6484
- this.injector = injector;
6485
- this.initNavigation = false;
6486
- this.destroyed = false;
6487
- this.resultOfPreactivationDone = new Subject();
6488
- }
6489
- appInitializer() {
6490
- const p = this.injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
6491
- return p.then(() => {
6492
- // If the injector was destroyed, the DI lookups below will fail.
6493
- if (this.destroyed) {
6494
- return Promise.resolve(true);
6495
- }
6496
- let resolve = null;
6497
- const res = new Promise(r => resolve = r);
6498
- const router = this.injector.get(Router);
6499
- const opts = this.injector.get(ROUTER_CONFIGURATION);
6500
- if (opts.initialNavigation === 'disabled') {
6501
- router.setUpLocationChangeListener();
6502
- resolve(true);
6503
- }
6504
- else if (opts.initialNavigation === 'enabledBlocking') {
6505
- router.afterPreactivation = () => {
6506
- // only the initial navigation should be delayed
6507
- if (!this.initNavigation) {
6508
- this.initNavigation = true;
6509
- resolve(true);
6510
- return this.resultOfPreactivationDone;
6511
- // subsequent navigations should not be delayed
6512
- }
6513
- else {
6514
- return of(void 0);
6515
- }
6516
- };
6517
- router.initialNavigation();
6518
- }
6519
- else {
6520
- resolve(true);
6521
- }
6522
- return res;
6523
- });
6524
- }
6525
- bootstrapListener(bootstrappedComponentRef) {
6526
- const opts = this.injector.get(ROUTER_CONFIGURATION);
6527
- const preloader = this.injector.get(RouterPreloader);
6528
- const routerScroller = this.injector.get(RouterScroller);
6529
- const router = this.injector.get(Router);
6530
- const ref = this.injector.get(ApplicationRef);
6471
+ function getBootstrapListener() {
6472
+ const injector = inject(Injector);
6473
+ return (bootstrappedComponentRef) => {
6474
+ var _a, _b;
6475
+ const ref = injector.get(ApplicationRef);
6531
6476
  if (bootstrappedComponentRef !== ref.components[0]) {
6532
6477
  return;
6533
6478
  }
6479
+ const router = injector.get(Router);
6480
+ const bootstrapDone = injector.get(BOOTSTRAP_DONE);
6534
6481
  // Default case
6535
- if (opts.initialNavigation === 'enabledNonBlocking' || opts.initialNavigation === undefined) {
6482
+ if (injector.get(INITIAL_NAVIGATION, null, InjectFlags.Optional) === null) {
6536
6483
  router.initialNavigation();
6537
6484
  }
6538
- preloader.setUpPreloading();
6539
- routerScroller.init();
6485
+ (_a = injector.get(ROUTER_PRELOADER, null, InjectFlags.Optional)) === null || _a === void 0 ? void 0 : _a.setUpPreloading();
6486
+ (_b = injector.get(ROUTER_SCROLLER, null, InjectFlags.Optional)) === null || _b === void 0 ? void 0 : _b.init();
6540
6487
  router.resetRootComponentType(ref.componentTypes[0]);
6541
- this.resultOfPreactivationDone.next(void 0);
6542
- this.resultOfPreactivationDone.complete();
6543
- }
6544
- ngOnDestroy() {
6545
- this.destroyed = true;
6546
- }
6547
- }
6548
- RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
6549
- RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer });
6550
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.1", ngImport: i0, type: RouterInitializer, decorators: [{
6551
- type: Injectable
6552
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
6553
- function getAppInitializer(r) {
6554
- return r.appInitializer.bind(r);
6555
- }
6556
- function getBootstrapListener(r) {
6557
- return r.bootstrapListener.bind(r);
6488
+ bootstrapDone.next();
6489
+ bootstrapDone.complete();
6490
+ };
6558
6491
  }
6492
+ // TODO(atscott): This should not be in the public API
6559
6493
  /**
6560
6494
  * A [DI token](guide/glossary/#di-token) for the router initializer that
6561
6495
  * is called after the app is bootstrapped.
6562
6496
  *
6563
6497
  * @publicApi
6564
6498
  */
6565
- const ROUTER_INITIALIZER = new InjectionToken('Router Initializer');
6499
+ const ROUTER_INITIALIZER = new InjectionToken(NG_DEV_MODE ? 'Router Initializer' : '');
6500
+ function provideInitialNavigation(config) {
6501
+ return [
6502
+ config.initialNavigation === 'disabled' ? provideDisabledInitialNavigation() : [],
6503
+ config.initialNavigation === 'enabledBlocking' ? provideEnabledBlockingInitialNavigation() : [],
6504
+ ];
6505
+ }
6566
6506
  function provideRouterInitializer() {
6567
6507
  return [
6568
- RouterInitializer,
6508
+ // ROUTER_INITIALIZER token should be removed. It's public API but shouldn't be. We can just
6509
+ // have `getBootstrapListener` directly attached to APP_BOOTSTRAP_LISTENER.
6510
+ { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener },
6511
+ { provide: APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
6512
+ ];
6513
+ }
6514
+ /**
6515
+ * A subject used to indicate that the bootstrapping phase is done. When initial navigation is
6516
+ * `enabledBlocking`, the first navigation waits until bootstrapping is finished before continuing
6517
+ * to the activation phase.
6518
+ */
6519
+ const BOOTSTRAP_DONE = new InjectionToken(NG_DEV_MODE ? 'bootstrap done indicator' : '', {
6520
+ factory: () => {
6521
+ return new Subject();
6522
+ }
6523
+ });
6524
+ function provideEnabledBlockingInitialNavigation() {
6525
+ return [
6526
+ { provide: INITIAL_NAVIGATION, useValue: 'enabledBlocking' },
6569
6527
  {
6570
6528
  provide: APP_INITIALIZER,
6571
6529
  multi: true,
6572
- useFactory: getAppInitializer,
6573
- deps: [RouterInitializer]
6530
+ deps: [Injector],
6531
+ useFactory: (injector) => {
6532
+ const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
6533
+ let initNavigation = false;
6534
+ /**
6535
+ * Performs the given action once the router finishes its next/current navigation.
6536
+ *
6537
+ * If the navigation is canceled or errors without a redirect, the navigation is considered
6538
+ * complete. If the `NavigationEnd` event emits, the navigation is also considered complete.
6539
+ */
6540
+ function afterNextNavigation(action) {
6541
+ const router = injector.get(Router);
6542
+ router.events
6543
+ .pipe(filter((e) => e instanceof NavigationEnd || e instanceof NavigationCancel ||
6544
+ e instanceof NavigationError), map(e => {
6545
+ if (e instanceof NavigationEnd) {
6546
+ // Navigation assumed to succeed if we get `ActivationStart`
6547
+ return true;
6548
+ }
6549
+ const redirecting = e instanceof NavigationCancel ?
6550
+ (e.code === 0 /* NavigationCancellationCode.Redirect */ ||
6551
+ e.code === 1 /* NavigationCancellationCode.SupersededByNewNavigation */) :
6552
+ false;
6553
+ return redirecting ? null : false;
6554
+ }), filter((result) => result !== null), take(1))
6555
+ .subscribe(() => {
6556
+ action();
6557
+ });
6558
+ }
6559
+ return () => {
6560
+ return locationInitialized.then(() => {
6561
+ return new Promise(resolve => {
6562
+ const router = injector.get(Router);
6563
+ const bootstrapDone = injector.get(BOOTSTRAP_DONE);
6564
+ afterNextNavigation(() => {
6565
+ // Unblock APP_INITIALIZER in case the initial navigation was canceled or errored
6566
+ // without a redirect.
6567
+ resolve(true);
6568
+ initNavigation = true;
6569
+ });
6570
+ router.afterPreactivation = () => {
6571
+ // Unblock APP_INITIALIZER once we get to `afterPreactivation`. At this point, we
6572
+ // assume activation will complete successfully (even though this is not
6573
+ // guaranteed).
6574
+ resolve(true);
6575
+ // only the initial navigation should be delayed until bootstrapping is done.
6576
+ if (!initNavigation) {
6577
+ return bootstrapDone.closed ? of(void 0) : bootstrapDone;
6578
+ // subsequent navigations should not be delayed
6579
+ }
6580
+ else {
6581
+ return of(void 0);
6582
+ }
6583
+ };
6584
+ router.initialNavigation();
6585
+ });
6586
+ });
6587
+ };
6588
+ }
6574
6589
  },
6575
- { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener, deps: [RouterInitializer] },
6576
- { provide: APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
6590
+ ];
6591
+ }
6592
+ const INITIAL_NAVIGATION = new InjectionToken(NG_DEV_MODE ? 'initial navigation' : '');
6593
+ function provideDisabledInitialNavigation() {
6594
+ return [
6595
+ {
6596
+ provide: APP_INITIALIZER,
6597
+ multi: true,
6598
+ useFactory: () => {
6599
+ const router = inject(Router);
6600
+ return () => {
6601
+ router.setUpLocationChangeListener();
6602
+ };
6603
+ }
6604
+ },
6605
+ { provide: INITIAL_NAVIGATION, useValue: 'disabled' }
6606
+ ];
6607
+ }
6608
+ function provideTracing() {
6609
+ if (NG_DEV_MODE) {
6610
+ return [{
6611
+ provide: ENVIRONMENT_INITIALIZER,
6612
+ multi: true,
6613
+ useFactory: () => {
6614
+ const router = inject(Router);
6615
+ return () => router.events.subscribe((e) => {
6616
+ var _a, _b;
6617
+ // tslint:disable:no-console
6618
+ (_a = console.group) === null || _a === void 0 ? void 0 : _a.call(console, `Router Event: ${e.constructor.name}`);
6619
+ console.log(stringifyEvent(e));
6620
+ console.log(e);
6621
+ (_b = console.groupEnd) === null || _b === void 0 ? void 0 : _b.call(console);
6622
+ // tslint:enable:no-console
6623
+ });
6624
+ }
6625
+ }];
6626
+ }
6627
+ else {
6628
+ return [];
6629
+ }
6630
+ }
6631
+ function providePreloading(preloadingStrategy) {
6632
+ return [
6633
+ RouterPreloader,
6634
+ { provide: ROUTER_PRELOADER, useExisting: RouterPreloader },
6635
+ { provide: PreloadingStrategy, useExisting: preloadingStrategy },
6577
6636
  ];
6578
6637
  }
6579
6638
 
@@ -6587,7 +6646,7 @@ function provideRouterInitializer() {
6587
6646
  /**
6588
6647
  * @publicApi
6589
6648
  */
6590
- const VERSION = new Version('14.1.0-next.1');
6649
+ const VERSION = new Version('14.1.0-next.4');
6591
6650
 
6592
6651
  /**
6593
6652
  * @license
@@ -6626,5 +6685,5 @@ const VERSION = new Version('14.1.0-next.1');
6626
6685
  * Generated bundle index. Do not edit.
6627
6686
  */
6628
6687
 
6629
- export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, createUrlTreeFromSnapshot, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten };
6688
+ export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, createUrlTreeFromSnapshot, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten, providePreloading as ɵprovidePreloading };
6630
6689
  //# sourceMappingURL=router.mjs.map