@coolon/angular-ui-powerups 0.0.96 → 0.0.98

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 (93) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +2960 -2288
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.d.ts +17 -20
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +17 -20
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +16 -52
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +16 -47
  11. package/esm2015/lib/interaction/index.js +4 -2
  12. package/esm2015/lib/interaction/interaction-context-base.js +158 -0
  13. package/esm2015/lib/interaction/interaction-context.js +58 -78
  14. package/esm2015/lib/interaction/interaction.module.js +1 -1
  15. package/esm2015/lib/interaction/services/dialog-interaction-context.js +163 -0
  16. package/esm2015/lib/interaction/services/dialog-interaction.service.js +68 -181
  17. package/esm2015/lib/interaction/services/modal-interaction.service.js +109 -0
  18. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +9 -43
  19. package/esm2015/lib/place/guards/abstract-place.guard.js +165 -0
  20. package/esm2015/lib/place/guards/consolidated-param-map.js +133 -0
  21. package/esm2015/lib/place/guards/interaction.guard.js +113 -0
  22. package/esm2015/lib/place/guards/navigation-state.js +613 -0
  23. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +87 -0
  24. package/esm2015/lib/place/index.js +7 -5
  25. package/esm2015/lib/place/place-component.js +1 -1
  26. package/esm2015/lib/place/place-router.js +162 -236
  27. package/esm2015/lib/place/place.module.js +2 -4
  28. package/esm2015/lib/place/route/visit-sanitiser.js +2 -2
  29. package/esm2015/lib/place/url-snapshot.js +96 -0
  30. package/esm2015/public_api.js +3 -3
  31. package/esm5/coolon-angular-ui-powerups.js +17 -20
  32. package/esm5/index.js +2 -2
  33. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +23 -74
  34. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +26 -76
  35. package/esm5/lib/interaction/index.js +4 -2
  36. package/esm5/lib/interaction/interaction-context-base.js +211 -0
  37. package/esm5/lib/interaction/interaction-context.js +72 -94
  38. package/esm5/lib/interaction/interaction.module.js +1 -1
  39. package/esm5/lib/interaction/services/dialog-interaction-context.js +188 -0
  40. package/esm5/lib/interaction/services/dialog-interaction.service.js +83 -232
  41. package/esm5/lib/interaction/services/modal-interaction.service.js +153 -0
  42. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +9 -43
  43. package/esm5/lib/place/guards/abstract-place.guard.js +212 -0
  44. package/esm5/lib/place/guards/consolidated-param-map.js +161 -0
  45. package/esm5/lib/place/guards/interaction.guard.js +125 -0
  46. package/esm5/lib/place/guards/navigation-state.js +764 -0
  47. package/esm5/lib/place/guards/place-component-deactivation-handler.js +104 -0
  48. package/esm5/lib/place/index.js +7 -5
  49. package/esm5/lib/place/place-component.js +1 -1
  50. package/esm5/lib/place/place-router.js +191 -294
  51. package/esm5/lib/place/place.module.js +2 -4
  52. package/esm5/lib/place/route/visit-sanitiser.js +2 -2
  53. package/esm5/lib/place/url-snapshot.js +120 -0
  54. package/esm5/public_api.js +3 -3
  55. package/fesm2015/coolon-angular-ui-powerups.js +2135 -1587
  56. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  57. package/fesm5/coolon-angular-ui-powerups.js +3083 -2412
  58. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  59. package/lib/interaction/components/activity-container/activity-container.component.d.ts +6 -11
  60. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +4 -9
  61. package/lib/interaction/index.d.ts +3 -1
  62. package/lib/interaction/interaction-context-base.d.ts +27 -0
  63. package/lib/interaction/interaction-context.d.ts +18 -15
  64. package/lib/interaction/services/dialog-interaction-context.d.ts +18 -0
  65. package/lib/interaction/services/dialog-interaction.service.d.ts +14 -23
  66. package/lib/interaction/services/modal-interaction.service.d.ts +15 -0
  67. package/lib/place/components/place-outlet/place-outlet.component.d.ts +1 -4
  68. package/lib/place/guards/abstract-place.guard.d.ts +19 -0
  69. package/lib/place/guards/consolidated-param-map.d.ts +14 -0
  70. package/lib/{interaction/guards/interaction-guard.service.d.ts → place/guards/interaction.guard.d.ts} +8 -4
  71. package/lib/place/guards/navigation-state.d.ts +96 -0
  72. package/lib/place/guards/place-component-deactivation-handler.d.ts +12 -0
  73. package/lib/place/index.d.ts +6 -4
  74. package/lib/place/place-component.d.ts +1 -1
  75. package/lib/place/place-router.d.ts +25 -33
  76. package/lib/place/url-snapshot.d.ts +16 -0
  77. package/package.json +1 -1
  78. package/schematics/place-routes/place-def.js +2 -2
  79. package/schematics/place-routes/templates/place-routes.ts.template +9 -16
  80. package/esm2015/lib/interaction/guards/interaction-guard.service.js +0 -85
  81. package/esm2015/lib/place/guards/abstract-enter-place.guard.js +0 -315
  82. package/esm2015/lib/place/guards/leave-place.guard.js +0 -47
  83. package/esm2015/lib/place/navigation-session.js +0 -279
  84. package/esm2015/lib/place/places/noop-gateway-place.component.js +0 -58
  85. package/esm5/lib/interaction/guards/interaction-guard.service.js +0 -94
  86. package/esm5/lib/place/guards/abstract-enter-place.guard.js +0 -387
  87. package/esm5/lib/place/guards/leave-place.guard.js +0 -55
  88. package/esm5/lib/place/navigation-session.js +0 -353
  89. package/esm5/lib/place/places/noop-gateway-place.component.js +0 -61
  90. package/lib/place/guards/abstract-enter-place.guard.d.ts +0 -33
  91. package/lib/place/guards/leave-place.guard.d.ts +0 -8
  92. package/lib/place/navigation-session.d.ts +0 -43
  93. package/lib/place/places/noop-gateway-place.component.d.ts +0 -10
@@ -1,16 +1,16 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
- import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, Optional, ɵɵdefineInjectable, ɵɵinject, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
2
+ import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatInputModule, MatFormFieldModule, MatSelectModule, MatDialog, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
- import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableListModel, MutableValueModel, Binding, Trace, Guard as Guard$1, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
7
+ import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, EventListenerList, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard as Guard$1, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
8
  import { __decorate, __metadata, __awaiter } from 'tslib';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { Router, RouterModule, NavigationStart, NavigationEnd, NavigationError, UrlSerializer, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
10
+ import { RouterModule, NavigationStart, NavigationCancel, NavigationError, NavigationEnd, UrlSegment, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
11
  import ___default, { last, isNil, isEqual } from 'lodash';
12
12
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
- import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
13
+ import { MatDialogConfig, MatDialog as MatDialog$1, MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
14
14
  import { MatIconModule } from '@angular/material/icon';
15
15
  import { MatListModule } from '@angular/material/list';
16
16
  import { MatTooltipModule } from '@angular/material/tooltip';
@@ -752,145 +752,6 @@ ComponentsModule.decorators = [
752
752
  },] }
753
753
  ];
754
754
 
755
- /**
756
- * @fileoverview added by tsickle
757
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
758
- */
759
- /**
760
- * @abstract
761
- */
762
- class InteractionContext extends GarbageCollector {
763
- /**
764
- * @protected
765
- */
766
- constructor() {
767
- super();
768
- /**
769
- * Returns the current list of activities that are in progress.
770
- * This model is only updated in the next tick after the view has been updated.
771
- */
772
- this._activityListDelegate = new DelegatingListModel();
773
- const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
774
- when.listOf(this.activityList).becomesPopulated((/**
775
- * @param {?} activities
776
- * @return {?}
777
- */
778
- (activities) => {
779
- if (this.deferredGetCurrentActivity) {
780
- this.deferredGetCurrentActivity.resolve(last(activities));
781
- this.deferredGetCurrentActivity = null;
782
- }
783
- }));
784
- }
785
- /**
786
- * @protected
787
- * @param {?} activityList
788
- * @return {?}
789
- */
790
- setActivityList(activityList) {
791
- this._activityListDelegate.setDelegate(activityList);
792
- }
793
- /**
794
- * @return {?}
795
- */
796
- get activityList() {
797
- return this._activityListDelegate.readonly;
798
- }
799
- /**
800
- * Returns the activity that is currently active.
801
- * This model is only updated in the next tick after the view has been updated.
802
- * @return {?}
803
- */
804
- getCurrentActivity() {
805
- return __awaiter(this, void 0, void 0, function* () {
806
- if (!this.isActive()) {
807
- return Promise.reject('no activity in progress');
808
- }
809
- else {
810
- if (this.deferredGetCurrentActivity) {
811
- // we're already waiting then just return the same promise
812
- return this.deferredGetCurrentActivity.promise;
813
- }
814
- else {
815
- if (this.activityList.length < 1) {
816
- this.deferredGetCurrentActivity = Deferred.defer();
817
- return this.deferredGetCurrentActivity.promise;
818
- }
819
- else {
820
- return last(this.activityList.value);
821
- }
822
- }
823
- }
824
- });
825
- }
826
- /**
827
- * @param {?} confirm
828
- * @return {?}
829
- */
830
- confirm(confirm) {
831
- // Important: we have to implement confirmOrReject as the main entry point
832
- // as the canDeactivation guards need to be able to cancel an interaction
833
- // without caring about returning a value.
834
- return this.confirmOrReject(confirm).then((/**
835
- * @return {?}
836
- */
837
- () => true)).catch((/**
838
- * @return {?}
839
- */
840
- () => false));
841
- }
842
- }
843
- if (false) {
844
- /**
845
- * Returns the current list of activities that are in progress.
846
- * This model is only updated in the next tick after the view has been updated.
847
- * @type {?}
848
- * @private
849
- */
850
- InteractionContext.prototype._activityListDelegate;
851
- /**
852
- * @type {?}
853
- * @private
854
- */
855
- InteractionContext.prototype.deferredGetCurrentActivity;
856
- /**
857
- * Returns true if an activity is currently running.
858
- * @abstract
859
- * @return {?}
860
- */
861
- InteractionContext.prototype.isActive = function () { };
862
- /**
863
- * @abstract
864
- * @template D, R, E
865
- * @param {?} activityType
866
- * @param {?=} data
867
- * @return {?}
868
- */
869
- InteractionContext.prototype.startActivity = function (activityType, data) { };
870
- /**
871
- * @abstract
872
- * @param {?} confirm
873
- * @return {?}
874
- */
875
- InteractionContext.prototype.confirmOrReject = function (confirm) { };
876
- /**
877
- * Presents the confirmation to the user and runs the activity only if the user confirms.
878
- * @abstract
879
- * @template D, R, E
880
- * @param {?} confirm
881
- * @param {?} activityType the activity to run if confirmed.
882
- * @param {?=} data the activity data.
883
- * @return {?}
884
- */
885
- InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
886
- /**
887
- * @abstract
888
- * @param {?} alert
889
- * @return {?}
890
- */
891
- InteractionContext.prototype.alert = function (alert) { };
892
- }
893
-
894
755
  /**
895
756
  * @fileoverview added by tsickle
896
757
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -986,170 +847,167 @@ if (false) {
986
847
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
987
848
  */
988
849
  /**
989
- * ActivityOutletComponent creates and displays an activity and delegates the interaction context functionality to an
990
- * external service.
991
- *
992
- * It might be nice to have wrapper component that allows more declarative use, i.e.
993
- * <activity-view [activityClass]="...", [activityData]="..." (done)=".." (cancel)="..."></activity-view>
850
+ * Deprecated. You can now extend the Activity class directly.
851
+ * @abstract
994
852
  * @template D, R, E
995
853
  */
996
- class ActivityOutletComponent {
854
+ class AbstractActivity extends Activity {
855
+ }
856
+
857
+ /**
858
+ * @fileoverview added by tsickle
859
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
860
+ */
861
+ class AlertDialogComponent extends AbstractActivity {
997
862
  /**
998
- * @param {?} componentFactoryResolver
999
- * @param {?} viewContainerRef
1000
- * @param {?} injector
863
+ * @param {?} alert
1001
864
  */
1002
- constructor(componentFactoryResolver, viewContainerRef, injector) {
1003
- this.componentFactoryResolver = componentFactoryResolver;
1004
- this.viewContainerRef = viewContainerRef;
1005
- this.injector = injector;
865
+ constructor(alert) {
866
+ super();
867
+ this.alert = alert;
1006
868
  }
1007
869
  /**
1008
- * @param {?} activityContext
1009
870
  * @return {?}
1010
871
  */
1011
- set activityContext(activityContext) {
1012
- assert.isNil(this._activityContext);
1013
- this._activityContext = activityContext;
1014
- this.loadActivity(activityContext);
872
+ ngOnInit() {
873
+ }
874
+ }
875
+ AlertDialogComponent.decorators = [
876
+ { type: Component, args: [{
877
+ selector: 'aup-alert-dialog',
878
+ template: "<h3 matDialogTitle *ngIf=\"alert.title\">{{alert.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of alert.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-raised-button color=\"primary\" (click)=\"done()\" data-cy=\"close-button\">{{alert.ok()}}</button>\n</div>\n",
879
+ styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{justify-content:flex-end}"]
880
+ }] }
881
+ ];
882
+ /** @nocollapse */
883
+ AlertDialogComponent.ctorParameters = () => [
884
+ { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
885
+ ];
886
+ if (false) {
887
+ /** @type {?} */
888
+ AlertDialogComponent.prototype.alert;
889
+ }
890
+
891
+ /**
892
+ * @fileoverview added by tsickle
893
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
894
+ */
895
+ /**
896
+ * @abstract
897
+ */
898
+ class InteractionContext extends GarbageCollector {
899
+ constructor() {
900
+ super(...arguments);
901
+ this.activityListeners = new EventListenerList();
1015
902
  }
1016
- ;
1017
903
  /**
904
+ * Returns true if an activity is currently running.
1018
905
  * @return {?}
1019
906
  */
1020
- get activityContext() {
1021
- return this._activityContext;
907
+ isActive() {
908
+ return this.active.value;
1022
909
  }
1023
910
  /**
911
+ * @param {?} listener
1024
912
  * @return {?}
1025
913
  */
1026
- ngOnInit() {
914
+ addActivityListener(listener) {
915
+ return this.activityListeners.add(listener);
1027
916
  }
1028
917
  /**
1029
- * @param {?} activityContext
918
+ * @protected
1030
919
  * @return {?}
1031
920
  */
1032
- loadActivity(activityContext) {
1033
- /** @type {?} */
1034
- const injector = Injector.create({
1035
- providers: [
1036
- {
1037
- provide: InteractionContext,
1038
- useValue: this.interactionContext
1039
- },
1040
- { provide: ACTIVITY_DATA, useValue: activityContext.activityData }
1041
- ],
1042
- parent: this.injector
1043
- });
1044
- /** @type {?} */
1045
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityContext.activityClass);
1046
- this.viewContainerRef.clear();
1047
- this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
1048
- this.activityComponentRef.instance.initialise(activityContext);
1049
- if (this.activityContext.componentReady) {
1050
- this.activityContext.componentReady(this.component);
1051
- }
921
+ notifyActivityStarted() {
922
+ this.activityListeners.fire((/**
923
+ * @param {?} l
924
+ * @return {?}
925
+ */
926
+ l => l.onActivityStarted()));
1052
927
  }
1053
928
  /**
929
+ * @protected
1054
930
  * @return {?}
1055
931
  */
1056
- get component() {
1057
- return this.activityComponentRef.instance;
932
+ notifyActivityFinished() {
933
+ this.activityListeners.fire((/**
934
+ * @param {?} l
935
+ * @return {?}
936
+ */
937
+ l => l.onActivityFinished()));
1058
938
  }
1059
939
  }
1060
- ActivityOutletComponent.decorators = [
1061
- { type: Component, args: [{
1062
- selector: 'aup-activity-outlet',
1063
- template: '',
1064
- styles: [":host{display:block}"]
1065
- }] }
1066
- ];
1067
- /** @nocollapse */
1068
- ActivityOutletComponent.ctorParameters = () => [
1069
- { type: ComponentFactoryResolver },
1070
- { type: ViewContainerRef },
1071
- { type: Injector }
1072
- ];
1073
- ActivityOutletComponent.propDecorators = {
1074
- interactionContext: [{ type: Input }],
1075
- activityContext: [{ type: Input }]
1076
- };
1077
940
  if (false) {
1078
- /** @type {?} */
1079
- ActivityOutletComponent.prototype.interactionContext;
1080
941
  /**
1081
942
  * @type {?}
1082
943
  * @private
1083
944
  */
1084
- ActivityOutletComponent.prototype._activityContext;
945
+ InteractionContext.prototype.activityListeners;
946
+ /** @type {?} */
947
+ InteractionContext.prototype.activityList;
948
+ /** @type {?} */
949
+ InteractionContext.prototype.active;
1085
950
  /**
1086
- * @type {?}
1087
- * @private
951
+ * Returns the activity that is currently active.
952
+ * This model is only updated in the next tick after the view has been updated.
953
+ * @abstract
954
+ * @return {?}
1088
955
  */
1089
- ActivityOutletComponent.prototype.activityComponentRef;
956
+ InteractionContext.prototype.getCurrentActivity = function () { };
1090
957
  /**
1091
- * @type {?}
1092
- * @private
958
+ * @abstract
959
+ * @template D, R, E
960
+ * @param {?} activityType
961
+ * @param {?=} data
962
+ * @return {?}
1093
963
  */
1094
- ActivityOutletComponent.prototype.componentFactoryResolver;
964
+ InteractionContext.prototype.startActivity = function (activityType, data) { };
1095
965
  /**
1096
- * @type {?}
1097
- * @private
966
+ * @abstract
967
+ * @param {?} alert
968
+ * @return {?}
1098
969
  */
1099
- ActivityOutletComponent.prototype.viewContainerRef;
970
+ InteractionContext.prototype.alert = function (alert) { };
1100
971
  /**
1101
- * @type {?}
1102
- * @private
972
+ * @abstract
973
+ * @param {?} confirm
974
+ * @return {?}
1103
975
  */
1104
- ActivityOutletComponent.prototype.injector;
1105
- /* Skipping unhandled member: ;*/
1106
- }
1107
-
1108
- /**
1109
- * @fileoverview added by tsickle
1110
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1111
- */
1112
- /**
1113
- * Deprecated. You can now extend the Activity class directly.
1114
- * @abstract
1115
- * @template D, R, E
1116
- */
1117
- class AbstractActivity extends Activity {
1118
- }
1119
-
1120
- /**
1121
- * @fileoverview added by tsickle
1122
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1123
- */
1124
- class AlertDialogComponent extends AbstractActivity {
976
+ InteractionContext.prototype.confirm = function (confirm) { };
1125
977
  /**
1126
- * @param {?} alert
978
+ * @abstract
979
+ * @param {?} confirm
980
+ * @return {?}
1127
981
  */
1128
- constructor(alert) {
1129
- super();
1130
- this.alert = alert;
1131
- }
982
+ InteractionContext.prototype.confirmOrReject = function (confirm) { };
1132
983
  /**
984
+ * Presents the confirmation to the user and runs the activity only if the user confirms.
985
+ * @abstract
986
+ * @template D, R, E
987
+ * @param {?} confirm
988
+ * @param {?} activityType the activity to run if confirmed.
989
+ * @param {?=} data the activity data.
1133
990
  * @return {?}
1134
991
  */
1135
- ngOnInit() {
1136
- }
1137
- }
1138
- AlertDialogComponent.decorators = [
1139
- { type: Component, args: [{
1140
- selector: 'aup-alert-dialog',
1141
- template: "<h3 matDialogTitle *ngIf=\"alert.title\">{{alert.title()}}</h3>\n<div matDialogContent>\n <p *ngFor=\"let line of alert.content()\">{{line}}</p>\n</div>\n<div matDialogActions>\n <button mat-raised-button color=\"primary\" (click)=\"done()\" data-cy=\"close-button\">{{alert.ok()}}</button>\n</div>\n",
1142
- styles: [":host{display:block;padding:var(--aup-default-padding)}.mat-dialog-content{margin:0;padding:0}.mat-dialog-actions{justify-content:flex-end}"]
1143
- }] }
1144
- ];
1145
- /** @nocollapse */
1146
- AlertDialogComponent.ctorParameters = () => [
1147
- { type: undefined, decorators: [{ type: Inject, args: [ACTIVITY_DATA,] }] }
1148
- ];
1149
- if (false) {
1150
- /** @type {?} */
1151
- AlertDialogComponent.prototype.alert;
992
+ InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
1152
993
  }
994
+ (function (InteractionContext) {
995
+ /**
996
+ * @record
997
+ */
998
+ function Listener() { }
999
+ InteractionContext.Listener = Listener;
1000
+ if (false) {
1001
+ /**
1002
+ * @return {?}
1003
+ */
1004
+ Listener.prototype.onActivityStarted = function () { };
1005
+ /**
1006
+ * @return {?}
1007
+ */
1008
+ Listener.prototype.onActivityFinished = function () { };
1009
+ }
1010
+ })(InteractionContext || (InteractionContext = {}));
1153
1011
 
1154
1012
  /**
1155
1013
  * @fileoverview added by tsickle
@@ -1284,115 +1142,392 @@ if (false) {
1284
1142
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1285
1143
  */
1286
1144
  /**
1287
- * Note: this class is mutable and is stored in a list model. This is normally a big no no but
1288
- * we're manually deriving other models from the list after view state changes. I.e. we not
1289
- * using pectin chains on any of the mutable fields.
1290
- * @template D, R, E
1145
+ * @abstract
1291
1146
  */
1292
- class TabContext {
1147
+ class InteractionContextBase extends InteractionContext {
1293
1148
  /**
1294
- * @param {?} activityData
1295
- * @param {?} activityClass
1296
- * @param {?} interactionContext
1297
- * @param {?} activityCallbacks
1149
+ * @protected
1298
1150
  */
1299
- constructor(activityData, activityClass, interactionContext, activityCallbacks) {
1300
- this.activityData = activityData;
1301
- this.activityClass = activityClass;
1302
- this.interactionContext = interactionContext;
1303
- this.activityCallbacks = activityCallbacks;
1304
- this._complete = false;
1151
+ constructor() {
1152
+ super();
1153
+ /**
1154
+ * Returns the current list of activities that are in progress.
1155
+ * This model is only updated in the next tick after the view has been updated.
1156
+ */
1157
+ this._activityListDelegate = new DelegatingListModel();
1158
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1159
+ when.listOf(this.activityList).becomesPopulated((/**
1160
+ * @param {?} activities
1161
+ * @return {?}
1162
+ */
1163
+ (activities) => {
1164
+ if (this.deferredGetCurrentActivity) {
1165
+ this.deferredGetCurrentActivity.resolve(last(activities));
1166
+ this.deferredGetCurrentActivity = null;
1167
+ }
1168
+ }));
1169
+ }
1170
+ /**
1171
+ * @protected
1172
+ * @param {?} activityList
1173
+ * @return {?}
1174
+ */
1175
+ setActivityList(activityList) {
1176
+ this._activityListDelegate.setDelegate(activityList);
1305
1177
  }
1306
1178
  /**
1307
1179
  * @return {?}
1308
1180
  */
1309
- isComponentRealised() {
1310
- return !!this._component;
1181
+ get activityList() {
1182
+ return this._activityListDelegate.readonly;
1311
1183
  }
1312
1184
  /**
1185
+ * Returns the activity that is currently active.
1186
+ * This model is only updated in the next tick after the view has been updated.
1313
1187
  * @return {?}
1314
1188
  */
1315
- isComplete() {
1316
- return this._complete;
1189
+ getCurrentActivity() {
1190
+ return __awaiter(this, void 0, void 0, function* () {
1191
+ if (!this.isActive()) {
1192
+ return Promise.reject('no activity in progress');
1193
+ }
1194
+ else {
1195
+ if (this.deferredGetCurrentActivity) {
1196
+ // we're already waiting then just return the same promise
1197
+ return this.deferredGetCurrentActivity.promise;
1198
+ }
1199
+ else {
1200
+ if (this.activityList.length < 1) {
1201
+ this.deferredGetCurrentActivity = Deferred.defer();
1202
+ return this.deferredGetCurrentActivity.promise;
1203
+ }
1204
+ else {
1205
+ return last(this.activityList.value);
1206
+ }
1207
+ }
1208
+ }
1209
+ });
1317
1210
  }
1318
1211
  /**
1319
- * @param {?} component
1212
+ * @template D, R, E
1213
+ * @param {?} activityType
1214
+ * @param {?=} data
1320
1215
  * @return {?}
1321
1216
  */
1322
- componentReady(component) {
1323
- assert.isNil(this._component);
1324
- this._component = component;
1217
+ startActivity(activityType, data) {
1218
+ return this._startActivity(activityType, data);
1325
1219
  }
1326
1220
  /**
1221
+ * @param {?} confirm
1327
1222
  * @return {?}
1328
1223
  */
1329
- get component() {
1330
- return this._component;
1224
+ confirm(confirm) {
1225
+ // Important: we have to implement confirmOrReject as the main entry point
1226
+ // as the canDeactivation guards need to be able to cancel an interaction
1227
+ // without caring about returning a value.
1228
+ return this.confirmOrReject(confirm).then((/**
1229
+ * @return {?}
1230
+ */
1231
+ () => true)).catch((/**
1232
+ * @return {?}
1233
+ */
1234
+ () => false));
1331
1235
  }
1332
- // @Trace()
1333
1236
  /**
1334
- * @param {?} result
1237
+ * @param {?} alert
1335
1238
  * @return {?}
1336
1239
  */
1337
- onDone(result) {
1338
- this._complete = true;
1339
- this.activityCallbacks.onDone(result);
1240
+ alert(alert) {
1241
+ // TODO: Test disableClose === false
1242
+ return this._startActivity(AlertDialogComponent, alert, false);
1340
1243
  }
1341
- // @Trace()
1342
1244
  /**
1343
- * @param {?} error
1245
+ * @param {?} confirm
1344
1246
  * @return {?}
1345
1247
  */
1346
- onCancel(error) {
1347
- this._complete = true;
1348
- this.activityCallbacks.onCancel(error);
1248
+ confirmOrReject(confirm) {
1249
+ return this._startActivity(ConfirmationDialogComponent, confirm, true);
1250
+ }
1251
+ /**
1252
+ * @template D, R, E
1253
+ * @param {?} confirm
1254
+ * @param {?} activityType
1255
+ * @param {?=} data
1256
+ * @return {?}
1257
+ */
1258
+ confirmThen(confirm, activityType, data) {
1259
+ return this._startActivity(ConfirmThenDialogComponent, {
1260
+ confirm,
1261
+ activityType: activityType,
1262
+ data: data
1263
+ }, true);
1349
1264
  }
1350
1265
  }
1351
1266
  if (false) {
1352
1267
  /**
1268
+ * Returns the current list of activities that are in progress.
1269
+ * This model is only updated in the next tick after the view has been updated.
1353
1270
  * @type {?}
1354
1271
  * @private
1355
1272
  */
1356
- TabContext.prototype._complete;
1273
+ InteractionContextBase.prototype._activityListDelegate;
1357
1274
  /**
1358
1275
  * @type {?}
1359
1276
  * @private
1360
1277
  */
1361
- TabContext.prototype._component;
1362
- /** @type {?} */
1363
- TabContext.prototype.activityData;
1364
- /** @type {?} */
1365
- TabContext.prototype.activityClass;
1366
- /** @type {?} */
1367
- TabContext.prototype.interactionContext;
1368
- /** @type {?} */
1369
- TabContext.prototype.activityCallbacks;
1278
+ InteractionContextBase.prototype.deferredGetCurrentActivity;
1279
+ /**
1280
+ * @abstract
1281
+ * @protected
1282
+ * @template D, R, E
1283
+ * @param {?} activityType
1284
+ * @param {?=} data
1285
+ * @param {?=} disableClose
1286
+ * @return {?}
1287
+ */
1288
+ InteractionContextBase.prototype._startActivity = function (activityType, data, disableClose) { };
1370
1289
  }
1290
+
1291
+ /**
1292
+ * @fileoverview added by tsickle
1293
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1294
+ */
1371
1295
  /**
1296
+ * ActivityOutletComponent creates and displays an activity and delegates the interaction context functionality to an
1297
+ * external service.
1298
+ *
1299
+ * It might be nice to have wrapper component that allows more declarative use, i.e.
1300
+ * <activity-view [activityClass]="...", [activityData]="..." (done)=".." (cancel)="..."></activity-view>
1372
1301
  * @template D, R, E
1373
1302
  */
1374
- class ActivityContainerComponent extends InteractionContext {
1375
- constructor() {
1376
- super();
1377
- this.throttledNestedActivityFinishEvents = new MutableStream();
1378
- // tslint:disable-next-line:no-output-rename
1379
- this.initialActivityOutletContextEvent = new EventEmitter();
1380
- this.dynamicHeight = false;
1381
- this.activityTabs = new MutableListModel();
1382
- this._activityList = new MutableListModel();
1303
+ class ActivityOutletComponent {
1304
+ /**
1305
+ * @param {?} componentFactoryResolver
1306
+ * @param {?} viewContainerRef
1307
+ * @param {?} injector
1308
+ */
1309
+ constructor(componentFactoryResolver, viewContainerRef, injector) {
1310
+ this.componentFactoryResolver = componentFactoryResolver;
1311
+ this.viewContainerRef = viewContainerRef;
1312
+ this.injector = injector;
1313
+ }
1314
+ /**
1315
+ * @param {?} activityContext
1316
+ * @return {?}
1317
+ */
1318
+ set activityContext(activityContext) {
1319
+ assert.isNil(this._activityContext);
1320
+ this._activityContext = activityContext;
1321
+ this.loadActivity(activityContext);
1322
+ }
1323
+ ;
1324
+ /**
1325
+ * @return {?}
1326
+ */
1327
+ get activityContext() {
1328
+ return this._activityContext;
1329
+ }
1330
+ /**
1331
+ * @return {?}
1332
+ */
1333
+ ngOnInit() {
1334
+ }
1335
+ /**
1336
+ * @param {?} activityContext
1337
+ * @return {?}
1338
+ */
1339
+ loadActivity(activityContext) {
1340
+ /** @type {?} */
1341
+ const injector = Injector.create({
1342
+ providers: [
1343
+ {
1344
+ provide: InteractionContext,
1345
+ useValue: this.interactionContext
1346
+ },
1347
+ { provide: ACTIVITY_DATA, useValue: activityContext.activityData }
1348
+ ],
1349
+ parent: this.injector
1350
+ });
1351
+ /** @type {?} */
1352
+ const componentFactory = this.componentFactoryResolver.resolveComponentFactory(activityContext.activityClass);
1353
+ this.viewContainerRef.clear();
1354
+ this.activityComponentRef = this.viewContainerRef.createComponent(componentFactory, 0, injector);
1355
+ this.activityComponentRef.instance.initialise(activityContext);
1356
+ if (this.activityContext.componentReady) {
1357
+ this.activityContext.componentReady(this.component);
1358
+ }
1359
+ }
1360
+ /**
1361
+ * @return {?}
1362
+ */
1363
+ get component() {
1364
+ return this.activityComponentRef.instance;
1365
+ }
1366
+ }
1367
+ ActivityOutletComponent.decorators = [
1368
+ { type: Component, args: [{
1369
+ selector: 'aup-activity-outlet',
1370
+ template: '',
1371
+ styles: [":host{display:block}"]
1372
+ }] }
1373
+ ];
1374
+ /** @nocollapse */
1375
+ ActivityOutletComponent.ctorParameters = () => [
1376
+ { type: ComponentFactoryResolver },
1377
+ { type: ViewContainerRef },
1378
+ { type: Injector }
1379
+ ];
1380
+ ActivityOutletComponent.propDecorators = {
1381
+ interactionContext: [{ type: Input }],
1382
+ activityContext: [{ type: Input }]
1383
+ };
1384
+ if (false) {
1385
+ /** @type {?} */
1386
+ ActivityOutletComponent.prototype.interactionContext;
1387
+ /**
1388
+ * @type {?}
1389
+ * @private
1390
+ */
1391
+ ActivityOutletComponent.prototype._activityContext;
1392
+ /**
1393
+ * @type {?}
1394
+ * @private
1395
+ */
1396
+ ActivityOutletComponent.prototype.activityComponentRef;
1397
+ /**
1398
+ * @type {?}
1399
+ * @private
1400
+ */
1401
+ ActivityOutletComponent.prototype.componentFactoryResolver;
1402
+ /**
1403
+ * @type {?}
1404
+ * @private
1405
+ */
1406
+ ActivityOutletComponent.prototype.viewContainerRef;
1407
+ /**
1408
+ * @type {?}
1409
+ * @private
1410
+ */
1411
+ ActivityOutletComponent.prototype.injector;
1412
+ /* Skipping unhandled member: ;*/
1413
+ }
1414
+
1415
+ /**
1416
+ * @fileoverview added by tsickle
1417
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1418
+ */
1419
+ /**
1420
+ * Note: this class is mutable and is stored in a list model. This is normally a big no no but
1421
+ * we're manually deriving other models from the list after view state changes. I.e. we not
1422
+ * using pectin chains on any of the mutable fields.
1423
+ * @template D, R, E
1424
+ */
1425
+ class TabContext {
1426
+ /**
1427
+ * @param {?} activityData
1428
+ * @param {?} activityClass
1429
+ * @param {?} interactionContext
1430
+ * @param {?} activityCallbacks
1431
+ */
1432
+ constructor(activityData, activityClass, interactionContext, activityCallbacks) {
1433
+ this.activityData = activityData;
1434
+ this.activityClass = activityClass;
1435
+ this.interactionContext = interactionContext;
1436
+ this.activityCallbacks = activityCallbacks;
1437
+ this._complete = false;
1438
+ }
1439
+ /**
1440
+ * @return {?}
1441
+ */
1442
+ isComponentRealised() {
1443
+ return !!this._component;
1444
+ }
1445
+ /**
1446
+ * @return {?}
1447
+ */
1448
+ isComplete() {
1449
+ return this._complete;
1450
+ }
1451
+ /**
1452
+ * @param {?} component
1453
+ * @return {?}
1454
+ */
1455
+ componentReady(component) {
1456
+ assert.isNil(this._component);
1457
+ this._component = component;
1458
+ }
1459
+ /**
1460
+ * @return {?}
1461
+ */
1462
+ get component() {
1463
+ return this._component;
1464
+ }
1465
+ // @Trace()
1466
+ /**
1467
+ * @param {?} result
1468
+ * @return {?}
1469
+ */
1470
+ onDone(result) {
1471
+ this._complete = true;
1472
+ this.activityCallbacks.onDone(result);
1473
+ }
1474
+ // @Trace()
1475
+ /**
1476
+ * @param {?} error
1477
+ * @return {?}
1478
+ */
1479
+ onCancel(error) {
1480
+ this._complete = true;
1481
+ this.activityCallbacks.onCancel(error);
1482
+ }
1483
+ }
1484
+ if (false) {
1485
+ /**
1486
+ * @type {?}
1487
+ * @private
1488
+ */
1489
+ TabContext.prototype._complete;
1490
+ /**
1491
+ * @type {?}
1492
+ * @private
1493
+ */
1494
+ TabContext.prototype._component;
1495
+ /** @type {?} */
1496
+ TabContext.prototype.activityData;
1497
+ /** @type {?} */
1498
+ TabContext.prototype.activityClass;
1499
+ /** @type {?} */
1500
+ TabContext.prototype.interactionContext;
1501
+ /** @type {?} */
1502
+ TabContext.prototype.activityCallbacks;
1503
+ }
1504
+ /**
1505
+ * @template D, R, E
1506
+ */
1507
+ class ActivityContainerComponent extends InteractionContextBase {
1508
+ constructor() {
1509
+ super();
1510
+ this.throttledNestedActivityFinishEvents = new MutableStream();
1511
+ this._initialActivityOutletContext = new MutableValueModel();
1512
+ // tslint:disable-next-line:no-output-rename
1513
+ this.initialActivityOutletContextEvent = new EventEmitter();
1514
+ this.dynamicHeight = false;
1515
+ this.activityTabs = new MutableListModel();
1516
+ this._activityList = new MutableListModel();
1383
1517
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
1384
1518
  chain(this.throttledNestedActivityFinishEvents).throttle(50).subscribe((/**
1385
1519
  * @return {?}
1386
1520
  */
1387
1521
  () => this.onNestedActivityFinished()));
1388
1522
  this.setActivityList(this._activityList.readonly);
1523
+ this.active = chain(this._initialActivityOutletContext).isNotNil();
1389
1524
  }
1390
1525
  /**
1391
1526
  * @param {?} initialContext
1392
1527
  * @return {?}
1393
1528
  */
1394
1529
  set initialActivityOutletContext(initialContext) {
1395
- assert.isNil(this._initialActivityOutletContext);
1530
+ assert.isNil(this._initialActivityOutletContext.value);
1396
1531
  // we clean up at the start as we leave the initial activity in place after it finishes
1397
1532
  // so that the activity remains visible during the inplace-interaction-context animations.
1398
1533
  this.activityTabs.value = [];
@@ -1400,7 +1535,7 @@ class ActivityContainerComponent extends InteractionContext {
1400
1535
  /** @type {?} */
1401
1536
  const self = this;
1402
1537
  if (initialContext) {
1403
- this._initialActivityOutletContext = initialContext;
1538
+ this._initialActivityOutletContext.value = initialContext;
1404
1539
  this.activityTabs.push(new TabContext(initialContext.activityData, initialContext.activityClass, this, {
1405
1540
  onDone: (/**
1406
1541
  * @param {?} result
@@ -1425,20 +1560,11 @@ class ActivityContainerComponent extends InteractionContext {
1425
1560
  * @return {?}
1426
1561
  */
1427
1562
  get initialActivityOutletContext() {
1428
- return this._initialActivityOutletContext;
1429
- }
1430
- /**
1431
- * @return {?}
1432
- */
1433
- isActive() {
1434
- return !!this._initialActivityOutletContext;
1435
- }
1436
- /**
1437
- * @return {?}
1438
- */
1439
- get isFinished() {
1440
- return !this._initialActivityOutletContext;
1563
+ return this._initialActivityOutletContext.value;
1441
1564
  }
1565
+ // get isFinished() {
1566
+ // return !this._initialActivityOutletContext;
1567
+ // }
1442
1568
  /**
1443
1569
  * @return {?}
1444
1570
  */
@@ -1468,7 +1594,7 @@ class ActivityContainerComponent extends InteractionContext {
1468
1594
  * @param {?=} data
1469
1595
  * @return {?}
1470
1596
  */
1471
- startActivity(activityType, data) {
1597
+ _startActivity(activityType, data) {
1472
1598
  this.cleanupStaleNestedActivities();
1473
1599
  /** @type {?} */
1474
1600
  const self = this;
@@ -1501,40 +1627,12 @@ class ActivityContainerComponent extends InteractionContext {
1501
1627
  self.tabs.selectedIndex = this.activityTabs.length;
1502
1628
  }));
1503
1629
  }
1504
- /**
1505
- * @param {?} alert
1506
- * @return {?}
1507
- */
1508
- alert(alert) {
1509
- return this.startActivity(AlertDialogComponent, alert);
1510
- }
1511
- /**
1512
- * @param {?} confirm
1513
- * @return {?}
1514
- */
1515
- confirmOrReject(confirm) {
1516
- return this.startActivity(ConfirmationDialogComponent, confirm);
1517
- }
1518
- /**
1519
- * @template D1, R1, E1
1520
- * @param {?} confirm
1521
- * @param {?} activityType
1522
- * @param {?=} data
1523
- * @return {?}
1524
- */
1525
- confirmThen(confirm, activityType, data) {
1526
- return this.startActivity(ConfirmThenDialogComponent, {
1527
- confirm,
1528
- activityType: activityType,
1529
- data: data
1530
- });
1531
- }
1532
1630
  /**
1533
1631
  * @private
1534
1632
  * @return {?}
1535
1633
  */
1536
1634
  finishInitialActivity() {
1537
- this._initialActivityOutletContext = null;
1635
+ this._initialActivityOutletContext.value = null;
1538
1636
  this.initialActivityOutletContextEvent.emit(null);
1539
1637
  }
1540
1638
  // @Trace()
@@ -1650,6 +1748,8 @@ if (false) {
1650
1748
  ActivityContainerComponent.prototype.outlets;
1651
1749
  /** @type {?} */
1652
1750
  ActivityContainerComponent.prototype.activityTabs;
1751
+ /** @type {?} */
1752
+ ActivityContainerComponent.prototype.active;
1653
1753
  /**
1654
1754
  * @type {?}
1655
1755
  * @private
@@ -1664,9 +1764,10 @@ if (false) {
1664
1764
  /**
1665
1765
  * @template D, R, E
1666
1766
  */
1667
- class InplaceInteractionContextComponent extends InteractionContext {
1767
+ class InplaceInteractionContextComponent extends InteractionContextBase {
1668
1768
  constructor() {
1669
1769
  super();
1770
+ this._active = new MutableValueModel(false);
1670
1771
  }
1671
1772
  /**
1672
1773
  * @return {?}
@@ -1677,55 +1778,18 @@ class InplaceInteractionContextComponent extends InteractionContext {
1677
1778
  /**
1678
1779
  * @return {?}
1679
1780
  */
1680
- isActive() {
1681
- return this.interactionContext.isActive();
1781
+ get active() {
1782
+ return this._active.readonly;
1682
1783
  }
1683
1784
  /**
1684
- * @param {?} alert
1685
- * @return {?}
1686
- */
1687
- alert(alert) {
1688
- // TODO: Test disableClose === false
1689
- return this._startActivity(AlertDialogComponent, alert);
1690
- }
1691
- /**
1692
- * @param {?} confirm
1693
- * @return {?}
1694
- */
1695
- confirmOrReject(confirm) {
1696
- return this._startActivity(ConfirmationDialogComponent, confirm);
1697
- }
1698
- /**
1699
- * @template D1, R1, E1
1700
- * @param {?} confirm
1701
- * @param {?} activityType
1702
- * @param {?=} data
1703
- * @return {?}
1704
- */
1705
- confirmThen(confirm, activityType, data) {
1706
- return this._startActivity(ConfirmThenDialogComponent, {
1707
- confirm,
1708
- activityType: activityType,
1709
- data: data
1710
- });
1711
- }
1712
- /**
1713
- * @template D1, R1, E1
1714
- * @param {?} activityType
1715
- * @param {?=} data
1716
- * @return {?}
1717
- */
1718
- startActivity(activityType, data) {
1719
- return this._startActivity(activityType, data);
1720
- }
1721
- /**
1722
- * @protected
1723
- * @template D1, R1, E1
1724
- * @param {?} activityType
1725
- * @param {?=} data
1785
+ * @protected
1786
+ * @template D1, R1, E1
1787
+ * @param {?} activityType
1788
+ * @param {?=} data
1726
1789
  * @return {?}
1727
1790
  */
1728
1791
  _startActivity(activityType, data) {
1792
+ this._active.value = true;
1729
1793
  /** @type {?} */
1730
1794
  const self = this;
1731
1795
  return new Promise((/**
@@ -1742,6 +1806,7 @@ class InplaceInteractionContextComponent extends InteractionContext {
1742
1806
  * @return {?}
1743
1807
  */
1744
1808
  onDone(result) {
1809
+ self._active.value = false;
1745
1810
  resolve(result);
1746
1811
  },
1747
1812
  /**
@@ -1749,6 +1814,7 @@ class InplaceInteractionContextComponent extends InteractionContext {
1749
1814
  * @return {?}
1750
1815
  */
1751
1816
  onCancel(error) {
1817
+ self._active.value = false;
1752
1818
  reject(error);
1753
1819
  }
1754
1820
  };
@@ -1765,13 +1831,18 @@ InplaceInteractionContextComponent.decorators = [
1765
1831
  /** @nocollapse */
1766
1832
  InplaceInteractionContextComponent.ctorParameters = () => [];
1767
1833
  InplaceInteractionContextComponent.propDecorators = {
1768
- interactionContext: [{ type: ViewChild, args: ["activityContainer", { static: true },] }]
1834
+ interactionContext: [{ type: ViewChild, args: ['activityContainer', { static: true },] }]
1769
1835
  };
1770
1836
  if (false) {
1771
1837
  /** @type {?} */
1772
1838
  InplaceInteractionContextComponent.prototype.interactionContext;
1773
1839
  /** @type {?} */
1774
1840
  InplaceInteractionContextComponent.prototype.initialActivityContext;
1841
+ /**
1842
+ * @type {?}
1843
+ * @private
1844
+ */
1845
+ InplaceInteractionContextComponent.prototype._active;
1775
1846
  }
1776
1847
 
1777
1848
  /**
@@ -1796,84 +1867,34 @@ InteractionOutletComponent.ctorParameters = () => [];
1796
1867
  * @fileoverview added by tsickle
1797
1868
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1798
1869
  */
1799
- /** @type {?} */
1800
- const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
1801
- class Guard extends ValueModel {
1802
- constructor() {
1803
- super({ initialValue: false });
1804
- }
1805
- /**
1806
- * @return {?}
1807
- */
1808
- get value() {
1809
- return this.store.read();
1810
- }
1811
- /**
1812
- * @template R
1813
- * @param {?} fun
1814
- * @return {?}
1815
- */
1816
- whileTrue(fun) {
1817
- this.startTransaction().commit(true);
1818
- try {
1819
- return fun();
1820
- }
1821
- finally {
1822
- this.startTransaction().commit(false);
1823
- }
1824
- }
1825
- /**
1826
- * @template R
1827
- * @param {?} fun
1828
- * @param {?=} defaultValue
1829
- * @return {?}
1830
- */
1831
- runIfFalse(fun, defaultValue = null) {
1832
- return !this.value ? fun() : defaultValue;
1833
- }
1834
- }
1835
- class DialogInteractionService extends InteractionContext {
1870
+ class DialogInteractionContext extends InteractionContextBase {
1836
1871
  /**
1837
1872
  * @param {?} dialogService
1838
- * @param {?} location
1839
- * @param {?} router
1840
- * @param {?} dialogServiceDefaults
1841
- * @param {?} matDialogDefaultConfig
1873
+ * @param {?} config
1842
1874
  */
1843
- constructor(dialogService, location, router, dialogServiceDefaults, matDialogDefaultConfig) {
1875
+ constructor(dialogService, config) {
1844
1876
  super();
1845
1877
  this.dialogService = dialogService;
1846
- this.location = location;
1847
- this.router = router;
1848
- this.dialogServiceDefaults = dialogServiceDefaults;
1849
- this.matDialogDefaultConfig = matDialogDefaultConfig;
1850
- this.startingGuard = new Guard();
1851
- this._inActivityPromise = new MutableValueModel(false);
1878
+ this.config = config;
1879
+ this._activeModel = new MutableValueModel(false);
1852
1880
  assert$1.notNil(dialogService);
1853
- }
1854
- /**
1855
- * @return {?}
1856
- */
1857
- isActive() {
1858
- return this._inActivityPromise.value;
1881
+ this.onDispose((/**
1882
+ * @return {?}
1883
+ */
1884
+ () => {
1885
+ if (this.isActive()) {
1886
+ lang.illegalState('Dispose called while active.');
1887
+ }
1888
+ }));
1859
1889
  }
1860
1890
  /**
1861
1891
  * @return {?}
1862
1892
  */
1863
1893
  get active() {
1864
- return this._inActivityPromise.readonly;
1865
- }
1866
- /**
1867
- * @template D, R, E
1868
- * @param {?} activityType
1869
- * @param {?=} data
1870
- * @return {?}
1871
- */
1872
- startActivity(activityType, data) {
1873
- return this._startActivity(activityType, data);
1894
+ return this._activeModel.readonly;
1874
1895
  }
1875
1896
  /**
1876
- * @private
1897
+ * @protected
1877
1898
  * @template D, R, E
1878
1899
  * @param {?} activityType
1879
1900
  * @param {?} data
@@ -1888,75 +1909,74 @@ class DialogInteractionService extends InteractionContext {
1888
1909
  */
1889
1910
  a => a.constructor.name)).join(', ')}`);
1890
1911
  }
1891
- return this.startingGuard.whileTrue((/**
1912
+ this._activeModel.value = true;
1913
+ this.notifyActivityStarted();
1914
+ /** @type {?} */
1915
+ const config = Object.assign({}, this.config, {
1916
+ data,
1917
+ disableClose,
1918
+ panelClass: 'dialog-interaction-service'
1919
+ });
1920
+ /** @type {?} */
1921
+ const self = this;
1922
+ /** @type {?} */
1923
+ const matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
1924
+ return new Promise((/**
1925
+ * @param {?} resolve
1926
+ * @param {?} reject
1892
1927
  * @return {?}
1893
1928
  */
1894
- () => {
1895
- // console.log('###### STARTING');
1896
- this._inActivityPromise.value = true;
1897
- // this.currentActivityId = uuid.v1();
1898
- // this.location.go(this.router.routerState.snapshot.url, "aup");
1899
- /** @type {?} */
1900
- const self = this;
1901
- /** @type {?} */
1902
- const config = Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults, {
1903
- data,
1904
- disableClose,
1905
- panelClass: 'dialog-interaction-service'
1906
- });
1929
+ (resolve, reject) => {
1907
1930
  /** @type {?} */
1908
- const matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
1909
- return new Promise((/**
1910
- * @param {?} resolve
1911
- * @param {?} reject
1912
- * @return {?}
1913
- */
1914
- (resolve, reject) => {
1915
- /** @type {?} */
1916
- const activityContainer = matDialogRef.componentInstance;
1917
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1918
- activityContainer.initialActivityOutletContext = {
1919
- activityClass: activityType,
1920
- activityData: data,
1921
- /**
1922
- * @param {?} result
1923
- * @return {?}
1924
- */
1925
- onDone(result) {
1926
- resolve(result);
1927
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1928
- },
1929
- /**
1930
- * @param {?} error
1931
- * @return {?}
1932
- */
1933
- onCancel(error) {
1934
- reject(error);
1935
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1936
- }
1937
- };
1938
- // we need to check if our onDone/onCancel methods above we called or if we were
1939
- // closed by the user clicking the backdrop. If the later then we need to reject
1940
- // our promise.
1941
- matDialogRef.afterClosed().subscribe((/**
1942
- * @param {?} promiseAlreadyFinished
1931
+ const activityContainer = matDialogRef.componentInstance;
1932
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
1933
+ activityContainer.initialActivityOutletContext = {
1934
+ activityClass: activityType,
1935
+ activityData: data,
1936
+ /**
1937
+ * @param {?} result
1943
1938
  * @return {?}
1944
1939
  */
1945
- promiseAlreadyFinished => {
1946
- if (!promiseAlreadyFinished) {
1947
- reject('auto-closed');
1948
- }
1949
- }));
1950
- matDialogRef.updateSize();
1951
- })).finally((/**
1940
+ onDone(result) {
1941
+ resolve(result);
1942
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1943
+ },
1944
+ /**
1945
+ * @param {?} error
1946
+ * @return {?}
1947
+ */
1948
+ onCancel(error) {
1949
+ reject(error);
1950
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
1951
+ }
1952
+ };
1953
+ // we need to check if our onDone/onCancel methods above we called or if we were
1954
+ // closed by the user clicking the backdrop. If the later then we need to reject
1955
+ // our promise.
1956
+ matDialogRef.afterClosed().subscribe((/**
1957
+ * @param {?} promiseAlreadyFinished
1952
1958
  * @return {?}
1953
1959
  */
1954
- () => {
1955
- this._inActivityPromise.value = false;
1956
- // console.log('###### FINISHED');
1957
- // this.currentActivityId = null;
1958
- self.safelyUpdateActivityListDelegate(null);
1960
+ promiseAlreadyFinished => {
1961
+ if (!promiseAlreadyFinished) {
1962
+ reject('auto-closed');
1963
+ }
1964
+ }));
1965
+ matDialogRef.updateSize();
1966
+ matDialogRef.afterOpened().subscribe((/**
1967
+ * @param {?} promiseAlreadyFinished
1968
+ * @return {?}
1969
+ */
1970
+ promiseAlreadyFinished => {
1971
+ matDialogRef.updateSize();
1959
1972
  }));
1973
+ })).finally((/**
1974
+ * @return {?}
1975
+ */
1976
+ () => {
1977
+ this._activeModel.value = false;
1978
+ this.notifyActivityFinished();
1979
+ self.safelyUpdateActivityListDelegate(null);
1960
1980
  }));
1961
1981
  }
1962
1982
  /**
@@ -1970,99 +1990,305 @@ class DialogInteractionService extends InteractionContext {
1970
1990
  */
1971
1991
  () => this.setActivityList(delegate)));
1972
1992
  }
1973
- /**
1974
- * @param {?} alert
1975
- * @return {?}
1976
- */
1977
- alert(alert) {
1978
- // TODO: Test disableClose === false
1979
- return this._startActivity(AlertDialogComponent, alert, false);
1980
- }
1981
- /**
1982
- * @param {?} confirm
1983
- * @return {?}
1984
- */
1985
- confirmOrReject(confirm) {
1986
- return this._startActivity(ConfirmationDialogComponent, confirm, true);
1987
- }
1988
- /**
1989
- * @template D, R, E
1990
- * @param {?} confirm
1991
- * @param {?} activityType
1992
- * @param {?=} data
1993
- * @return {?}
1994
- */
1995
- confirmThen(confirm, activityType, data) {
1996
- return this._startActivity(ConfirmThenDialogComponent, {
1997
- confirm,
1998
- activityType: activityType,
1999
- data: data
2000
- }, true);
2001
- }
2002
1993
  }
2003
- DialogInteractionService.decorators = [
1994
+ DialogInteractionContext.decorators = [
2004
1995
  { type: Injectable, args: [{
2005
1996
  providedIn: 'root'
2006
1997
  },] }
2007
1998
  ];
2008
1999
  /** @nocollapse */
2009
- DialogInteractionService.ctorParameters = () => [
2000
+ DialogInteractionContext.ctorParameters = () => [
2010
2001
  { type: MatDialog },
2011
- { type: Location },
2012
- { type: Router },
2013
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2014
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2002
+ { type: MatDialogConfig }
2015
2003
  ];
2016
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(Location), ɵɵinject(Router), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2004
+ /** @nocollapse */ DialogInteractionContext.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(ɵɵinject(MatDialog$1), ɵɵinject(MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2017
2005
  if (false) {
2018
2006
  /**
2019
2007
  * @type {?}
2020
2008
  * @private
2021
2009
  */
2022
- DialogInteractionService.prototype.startingGuard;
2023
- /**
2024
- * @type {?}
2025
- * @private
2026
- */
2027
- DialogInteractionService.prototype._inActivityPromise;
2010
+ DialogInteractionContext.prototype._activeModel;
2028
2011
  /**
2029
2012
  * @type {?}
2030
2013
  * @private
2031
2014
  */
2032
- DialogInteractionService.prototype.dialogService;
2015
+ DialogInteractionContext.prototype.dialogService;
2033
2016
  /** @type {?} */
2034
- DialogInteractionService.prototype.location;
2035
- /** @type {?} */
2036
- DialogInteractionService.prototype.router;
2037
- /** @type {?} */
2038
- DialogInteractionService.prototype.dialogServiceDefaults;
2039
- /** @type {?} */
2040
- DialogInteractionService.prototype.matDialogDefaultConfig;
2017
+ DialogInteractionContext.prototype.config;
2041
2018
  }
2042
2019
 
2043
2020
  /**
2044
2021
  * @fileoverview added by tsickle
2045
2022
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2046
2023
  */
2047
- class InteractionModule {
2024
+ class Guard extends ValueModel {
2025
+ constructor() {
2026
+ super({ initialValue: false });
2027
+ }
2028
+ /**
2029
+ * @return {?}
2030
+ */
2031
+ get value() {
2032
+ return this.store.read();
2033
+ }
2034
+ /**
2035
+ * @template R
2036
+ * @param {?} fun
2037
+ * @return {?}
2038
+ */
2039
+ whileTrue(fun) {
2040
+ this.startTransaction().commit(true);
2041
+ try {
2042
+ return fun();
2043
+ }
2044
+ finally {
2045
+ this.startTransaction().commit(false);
2046
+ }
2047
+ }
2048
+ /**
2049
+ * @template R
2050
+ * @param {?} fun
2051
+ * @param {?=} defaultValue
2052
+ * @return {?}
2053
+ */
2054
+ runIfFalse(fun, defaultValue = null) {
2055
+ return !this.value ? fun() : defaultValue;
2056
+ }
2048
2057
  }
2049
- InteractionModule.decorators = [
2050
- { type: NgModule, args: [{
2051
- imports: [
2052
- CommonModule,
2053
- MatButtonModule,
2054
- MatDialogModule,
2055
- MatTabsModule$1,
2056
- PortalModule,
2057
- RouterModule
2058
- ],
2059
- declarations: [
2060
- ActivityContainerComponent,
2061
- ConfirmationDialogComponent,
2062
- ConfirmThenDialogComponent,
2063
- AlertDialogComponent,
2064
- ActivityOutletComponent,
2065
- InteractionOutletComponent,
2058
+ /**
2059
+ * @abstract
2060
+ */
2061
+ class ModalInteractionService extends GarbageCollector {
2062
+ constructor() {
2063
+ super();
2064
+ this._activityListeners = new EventListenerList();
2065
+ }
2066
+ /**
2067
+ * @return {?}
2068
+ */
2069
+ isActive() {
2070
+ return this.active.value;
2071
+ }
2072
+ /**
2073
+ * @param {?} listener
2074
+ * @return {?}
2075
+ */
2076
+ addActivityListener(listener) {
2077
+ return this._activityListeners.add(listener);
2078
+ }
2079
+ /**
2080
+ * @protected
2081
+ * @return {?}
2082
+ */
2083
+ notifyActivityStarted() {
2084
+ this._activityListeners.fire((/**
2085
+ * @param {?} l
2086
+ * @return {?}
2087
+ */
2088
+ l => l.onActivityStarted()));
2089
+ }
2090
+ /**
2091
+ * @protected
2092
+ * @return {?}
2093
+ */
2094
+ notifyActivityFinished() {
2095
+ this._activityListeners.fire((/**
2096
+ * @param {?} l
2097
+ * @return {?}
2098
+ */
2099
+ l => l.onActivityFinished()));
2100
+ }
2101
+ }
2102
+ if (false) {
2103
+ /**
2104
+ * @type {?}
2105
+ * @private
2106
+ */
2107
+ ModalInteractionService.prototype._activityListeners;
2108
+ /** @type {?} */
2109
+ ModalInteractionService.prototype.active;
2110
+ /**
2111
+ * @abstract
2112
+ * @param {?} disposable
2113
+ * @return {?}
2114
+ */
2115
+ ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2116
+ /**
2117
+ * @abstract
2118
+ * @return {?}
2119
+ */
2120
+ ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2121
+ /**
2122
+ * @abstract
2123
+ * @return {?}
2124
+ */
2125
+ ModalInteractionService.prototype.getCurrentActivity = function () { };
2126
+ }
2127
+
2128
+ /**
2129
+ * @fileoverview added by tsickle
2130
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2131
+ */
2132
+ /** @type {?} */
2133
+ const DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2134
+ class DialogInteractionService extends ModalInteractionService {
2135
+ /**
2136
+ * @param {?} dialogService
2137
+ * @param {?} dialogServiceDefaults
2138
+ * @param {?} matDialogDefaultConfig
2139
+ */
2140
+ constructor(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2141
+ super();
2142
+ this.dialogService = dialogService;
2143
+ this.dialogServiceDefaults = dialogServiceDefaults;
2144
+ this.matDialogDefaultConfig = matDialogDefaultConfig;
2145
+ this._activeInteractionContextModel = new MutableValueModel();
2146
+ assert$1.notNil(dialogService);
2147
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
2148
+ this.active = chain(this._activeInteractionContextModel).isNotNil();
2149
+ }
2150
+ /**
2151
+ * @param {?} disposable
2152
+ * @return {?}
2153
+ */
2154
+ createInteractionContextFor(disposable) {
2155
+ return disposable.registerDisposable(this._createInteractionContext());
2156
+ }
2157
+ /**
2158
+ * @return {?}
2159
+ */
2160
+ _createInteractionContext() {
2161
+ /** @type {?} */
2162
+ const config = Object.assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2163
+ /** @type {?} */
2164
+ const self = this;
2165
+ /** @type {?} */
2166
+ const dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2167
+ dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2168
+ /**
2169
+ * @return {?}
2170
+ */
2171
+ onActivityStarted() {
2172
+ self.onActivityStarted(dialogInteractionContext);
2173
+ },
2174
+ /**
2175
+ * @return {?}
2176
+ */
2177
+ onActivityFinished() {
2178
+ self.onActivityFinished(dialogInteractionContext);
2179
+ }
2180
+ }));
2181
+ return dialogInteractionContext;
2182
+ }
2183
+ /**
2184
+ * @return {?}
2185
+ */
2186
+ createExclusiveInteractionContext() {
2187
+ this.exclusiveContext = this._createInteractionContext();
2188
+ /** @type {?} */
2189
+ const self = this;
2190
+ this.exclusiveContext.registerDisposable({
2191
+ /**
2192
+ * @return {?}
2193
+ */
2194
+ dispose() {
2195
+ self.exclusiveContext = null;
2196
+ }
2197
+ });
2198
+ return this.exclusiveContext;
2199
+ }
2200
+ // @Trace()
2201
+ /**
2202
+ * @param {?} dialogInteractionContext
2203
+ * @return {?}
2204
+ */
2205
+ onActivityStarted(dialogInteractionContext) {
2206
+ assert$1.isFalsey(this.isActive());
2207
+ if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2208
+ lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2209
+ }
2210
+ this._activeInteractionContextModel.value = dialogInteractionContext;
2211
+ this.notifyActivityStarted();
2212
+ }
2213
+ // @Trace()
2214
+ /**
2215
+ * @param {?} dialogInteractionContext
2216
+ * @return {?}
2217
+ */
2218
+ onActivityFinished(dialogInteractionContext) {
2219
+ assert$1.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2220
+ this._activeInteractionContextModel.value = null;
2221
+ this.notifyActivityFinished();
2222
+ }
2223
+ /**
2224
+ * @return {?}
2225
+ */
2226
+ getCurrentActivity() {
2227
+ return __awaiter(this, void 0, void 0, function* () {
2228
+ assert$1.isTruthy(this.isActive());
2229
+ return this._activeInteractionContextModel.value.getCurrentActivity();
2230
+ });
2231
+ }
2232
+ }
2233
+ DialogInteractionService.decorators = [
2234
+ { type: Injectable, args: [{
2235
+ providedIn: 'root'
2236
+ },] }
2237
+ ];
2238
+ /** @nocollapse */
2239
+ DialogInteractionService.ctorParameters = () => [
2240
+ { type: MatDialog },
2241
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2242
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2243
+ ];
2244
+ /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2245
+ if (false) {
2246
+ /**
2247
+ * @type {?}
2248
+ * @private
2249
+ */
2250
+ DialogInteractionService.prototype._activeInteractionContextModel;
2251
+ /** @type {?} */
2252
+ DialogInteractionService.prototype.active;
2253
+ /**
2254
+ * @type {?}
2255
+ * @private
2256
+ */
2257
+ DialogInteractionService.prototype.exclusiveContext;
2258
+ /**
2259
+ * @type {?}
2260
+ * @private
2261
+ */
2262
+ DialogInteractionService.prototype.dialogService;
2263
+ /** @type {?} */
2264
+ DialogInteractionService.prototype.dialogServiceDefaults;
2265
+ /** @type {?} */
2266
+ DialogInteractionService.prototype.matDialogDefaultConfig;
2267
+ }
2268
+
2269
+ /**
2270
+ * @fileoverview added by tsickle
2271
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2272
+ */
2273
+ class InteractionModule {
2274
+ }
2275
+ InteractionModule.decorators = [
2276
+ { type: NgModule, args: [{
2277
+ imports: [
2278
+ CommonModule,
2279
+ MatButtonModule,
2280
+ MatDialogModule,
2281
+ MatTabsModule$1,
2282
+ PortalModule,
2283
+ RouterModule
2284
+ ],
2285
+ declarations: [
2286
+ ActivityContainerComponent,
2287
+ ConfirmationDialogComponent,
2288
+ ConfirmThenDialogComponent,
2289
+ AlertDialogComponent,
2290
+ ActivityOutletComponent,
2291
+ InteractionOutletComponent,
2066
2292
  InplaceInteractionContextComponent
2067
2293
  ],
2068
2294
  exports: [
@@ -2849,6 +3075,92 @@ if (false) {
2849
3075
  PlaceConfig.prototype.animationDuration;
2850
3076
  }
2851
3077
 
3078
+ /**
3079
+ * @fileoverview added by tsickle
3080
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3081
+ */
3082
+ class PlaceComponentDeactivationHandler {
3083
+ /**
3084
+ * @param {?} component
3085
+ * @param {?} navigationSession
3086
+ */
3087
+ constructor(component, navigationSession) {
3088
+ this.component = component;
3089
+ this.navigationSession = navigationSession;
3090
+ }
3091
+ /**
3092
+ * @param {?} nextState
3093
+ * @return {?}
3094
+ */
3095
+ canDeactivate(nextState) {
3096
+ return __awaiter(this, void 0, void 0, function* () {
3097
+ // We'll get called multiple times if there's any parameter sanitisation so
3098
+ // we always return true if we accepted promise from a previous cycle of the current
3099
+ // navigation session.
3100
+ if (!this.canDeactivatePromise) {
3101
+ this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3102
+ }
3103
+ return this.canDeactivatePromise;
3104
+ });
3105
+ }
3106
+ /**
3107
+ * @protected
3108
+ * @param {?} nextState
3109
+ * @return {?}
3110
+ */
3111
+ canDeactivateComponent(nextState) {
3112
+ return __awaiter(this, void 0, void 0, function* () {
3113
+ // Automatically cancel any active activities if the navigation session was triggered by the back button.
3114
+ // any other navigations (such as the user clicking a differnt place) must be handled by the component itself
3115
+ // during the canDeativate method. If we handled more than just the pop state then it leads to the UI ignoring
3116
+ // clicks and just cancelling things which is deeply disconcerting.
3117
+ if (this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive()) {
3118
+ // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3119
+ // a model interaction is active. This is because:
3120
+ // 1. the user can't click anything to navigate away
3121
+ // 2. clicking the back button will only change the outlet route portion of the URL. This
3122
+ // is all handled by the InteractionGuard and so the component guards will never run.
3123
+ //
3124
+ // Now we just cancel the current activity...
3125
+ /** @type {?} */
3126
+ const activity = yield this.component.interactionContext.getCurrentActivity();
3127
+ activity.cancel(null);
3128
+ return false; // ..and stay where we are.
3129
+ }
3130
+ // Ok, so now we're really leaving, so we ask the component if we should.;
3131
+ if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3132
+ // No interaction in progress, so ask the component .
3133
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3134
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3135
+ return this.component.canDeactivate(this.navigationSession.interactionContext);
3136
+ }
3137
+ return true;
3138
+ });
3139
+ }
3140
+ /**
3141
+ * @protected
3142
+ * @param {?} nextState
3143
+ * @return {?}
3144
+ */
3145
+ isNotJustAChangeInRouteId(nextState) {
3146
+ // Because places with a route-id cover two route segments we get asked to deactivate
3147
+ // if the route id is added or removed. So if our path is still present the url
3148
+ // then we shouldn't deactivate the place.
3149
+ return !nextState.includesPathOf(this.component.placeDefinition);
3150
+ }
3151
+ }
3152
+ if (false) {
3153
+ /**
3154
+ * @type {?}
3155
+ * @private
3156
+ */
3157
+ PlaceComponentDeactivationHandler.prototype.canDeactivatePromise;
3158
+ /** @type {?} */
3159
+ PlaceComponentDeactivationHandler.prototype.component;
3160
+ /** @type {?} */
3161
+ PlaceComponentDeactivationHandler.prototype.navigationSession;
3162
+ }
3163
+
2852
3164
  /**
2853
3165
  * @fileoverview added by tsickle
2854
3166
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2856,19 +3168,20 @@ if (false) {
2856
3168
  /**
2857
3169
  * @abstract
2858
3170
  */
2859
- class NavigationSession {
3171
+ class NavigationState extends GarbageCollector {
2860
3172
  /**
2861
- * @protected
2862
- * @param {?} firstNavigation
2863
- * @param {?} appModalInteractionContext
3173
+ * @param {?} context
2864
3174
  */
2865
- constructor(firstNavigation, appModalInteractionContext) {
2866
- this.firstNavigation = firstNavigation;
2867
- this.appModalInteractionContext = appModalInteractionContext;
2868
- this._alreadyAccepted = [];
3175
+ constructor(context) {
3176
+ super();
3177
+ this.context = context;
2869
3178
  this._visits = new Map();
2870
- this.componentDeactivationHandlers = new Map();
2871
- this.dialogOpenOnStart = this.appModalInteractionContext.isActive();
3179
+ }
3180
+ /**
3181
+ * @return {?}
3182
+ */
3183
+ get interactionContext() {
3184
+ return null;
2872
3185
  }
2873
3186
  /**
2874
3187
  * @param {?} visit
@@ -2885,247 +3198,577 @@ class NavigationSession {
2885
3198
  return this._visits.get(placeDef);
2886
3199
  }
2887
3200
  /**
2888
- * @param {?} component
2889
- * @param {?} nextState
3201
+ * @param {?} newUrl
2890
3202
  * @return {?}
2891
3203
  */
2892
- canDeactivate(component, nextState) {
2893
- return __awaiter(this, void 0, void 0, function* () {
2894
- // lookup the handler and create it if we've not seen it yet
2895
- /** @type {?} */
2896
- let handler = this.componentDeactivationHandlers.get(component);
2897
- if (!handler) {
2898
- /** @type {?} */
2899
- const isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
2900
- handler = new NavigationSession.ComponentDeactivationHandler(component, this.appModalInteractionContext, isPrimaryHandler);
2901
- this.componentDeactivationHandlers.set(component, handler);
2902
- }
2903
- return handler.canDeactivate(nextState);
2904
- });
3204
+ onBackClickedDuringNavigationInteraction(newUrl) {
3205
+ return this.illegalTransition('onBackClickedDuringNavigationInteraction');
2905
3206
  }
2906
3207
  /**
2907
- * @param {?} url
2908
3208
  * @return {?}
2909
3209
  */
2910
- setPopstateReturnUrl(url) {
2911
- this._popStateReturnUrl = url;
3210
+ getVisits() {
3211
+ return Array.from(this._visits.values());
2912
3212
  }
2913
3213
  /**
3214
+ * @protected
3215
+ * @template R
3216
+ * @param {?} message
2914
3217
  * @return {?}
2915
3218
  */
2916
- get isPopState() {
2917
- return !!this._popStateReturnUrl;
3219
+ illegalTransition(message) {
3220
+ return lang.illegalState(`${message.toString()} not supported by ${this.toString()}`);
2918
3221
  }
2919
3222
  /**
3223
+ * @protected
2920
3224
  * @return {?}
2921
3225
  */
2922
- get popStateReturnUrl() {
2923
- return this._popStateReturnUrl;
3226
+ currentRouterUrl() {
3227
+ return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
2924
3228
  }
2925
3229
  /**
3230
+ * @protected
3231
+ * @param {?} event
2926
3232
  * @return {?}
2927
3233
  */
2928
- getVisits() {
2929
- return Array.from(this._visits.values());
3234
+ createActiveSession(event) {
3235
+ // TODO: check if the event is purely for interaction context changes.
3236
+ return new NavigationState.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
2930
3237
  }
2931
- }
2932
- if (false) {
2933
3238
  /**
2934
- * @type {?}
2935
- * @private
3239
+ * @protected
3240
+ * @param {?} url
3241
+ * @return {?}
2936
3242
  */
2937
- NavigationSession.prototype._alreadyAccepted;
3243
+ updateLocation(url) {
3244
+ this.context.angularLocation.go(url);
3245
+ }
2938
3246
  /**
2939
- * @type {?}
2940
- * @private
3247
+ * @return {?}
2941
3248
  */
2942
- NavigationSession.prototype._visits;
2943
- /**
2944
- * @type {?}
3249
+ toString() {
3250
+ return this.constructor.name;
3251
+ }
3252
+ }
3253
+ __decorate([
3254
+ Trace(),
3255
+ __metadata("design:type", Function),
3256
+ __metadata("design:paramtypes", [Object]),
3257
+ __metadata("design:returntype", void 0)
3258
+ ], NavigationState.prototype, "updateLocation", null);
3259
+ if (false) {
3260
+ /**
3261
+ * @type {?}
2945
3262
  * @private
2946
3263
  */
2947
- NavigationSession.prototype._popStateReturnUrl;
3264
+ NavigationState.prototype._visits;
3265
+ /** @type {?} */
3266
+ NavigationState.prototype.isPopState;
2948
3267
  /** @type {?} */
2949
- NavigationSession.prototype.isExternal;
3268
+ NavigationState.prototype.active;
2950
3269
  /** @type {?} */
2951
- NavigationSession.prototype.dialogOpenOnStart;
3270
+ NavigationState.prototype.startingUrl;
2952
3271
  /**
2953
3272
  * @type {?}
2954
- * @private
3273
+ * @protected
2955
3274
  */
2956
- NavigationSession.prototype.componentDeactivationHandlers;
2957
- /** @type {?} */
2958
- NavigationSession.prototype.firstNavigation;
3275
+ NavigationState.prototype.context;
2959
3276
  /**
2960
- * @type {?}
2961
- * @private
3277
+ * @abstract
3278
+ * @param {?} event
3279
+ * @return {?}
3280
+ */
3281
+ NavigationState.prototype.onStart = function (event) { };
3282
+ /**
3283
+ * @abstract
3284
+ * @param {?} event
3285
+ * @return {?}
3286
+ */
3287
+ NavigationState.prototype.onCancel = function (event) { };
3288
+ /**
3289
+ * @abstract
3290
+ * @param {?} event
3291
+ * @return {?}
3292
+ */
3293
+ NavigationState.prototype.onError = function (event) { };
3294
+ /**
3295
+ * @abstract
3296
+ * @param {?} event
3297
+ * @return {?}
3298
+ */
3299
+ NavigationState.prototype.onEnd = function (event) { };
3300
+ /**
3301
+ * @abstract
3302
+ * @param {?} component
3303
+ * @param {?} nextState
3304
+ * @return {?}
2962
3305
  */
2963
- NavigationSession.prototype.appModalInteractionContext;
3306
+ NavigationState.prototype.canDeactivatePlace = function (component, nextState) { };
2964
3307
  }
2965
- (function (NavigationSession) {
2966
- class External extends NavigationSession {
3308
+ (function (NavigationState) {
3309
+ class Context {
2967
3310
  /**
2968
- * @param {?} isFirstTime
2969
- * @param {?} appModelInteractionContext
3311
+ * @param {?} router
3312
+ * @param {?} modalInteractionService
3313
+ * @param {?} angularLocation
3314
+ * @param {?} notifySuccess
2970
3315
  */
2971
- constructor(isFirstTime, appModelInteractionContext) {
2972
- super(isFirstTime, appModelInteractionContext);
2973
- this.isExternal = true;
3316
+ constructor(router, modalInteractionService, angularLocation, notifySuccess) {
3317
+ this.router = router;
3318
+ this.modalInteractionService = modalInteractionService;
3319
+ this.angularLocation = angularLocation;
3320
+ this.notifySuccess = notifySuccess;
2974
3321
  }
2975
3322
  }
3323
+ NavigationState.Context = Context;
2976
3324
  if (false) {
2977
3325
  /** @type {?} */
2978
- External.prototype.isExternal;
3326
+ Context.prototype.router;
3327
+ /** @type {?} */
3328
+ Context.prototype.modalInteractionService;
3329
+ /** @type {?} */
3330
+ Context.prototype.angularLocation;
3331
+ /** @type {?} */
3332
+ Context.prototype.notifySuccess;
2979
3333
  }
2980
- class Internal extends NavigationSession {
3334
+ class Idle extends NavigationState {
3335
+ /**
3336
+ * @param {?} context
3337
+ */
3338
+ constructor(context) {
3339
+ super(context);
3340
+ this.active = false;
3341
+ this.startingUrl = null;
3342
+ }
3343
+ /**
3344
+ * @param {?} component
3345
+ * @param {?} nextState
3346
+ * @return {?}
3347
+ */
3348
+ canDeactivatePlace(component, nextState) {
3349
+ return __awaiter(this, void 0, void 0, function* () {
3350
+ return this.illegalTransition('canDeactivatePlace');
3351
+ });
3352
+ }
3353
+ /**
3354
+ * @param {?} event
3355
+ * @return {?}
3356
+ */
3357
+ onStart(event) {
3358
+ // calling angularLocation.go() to clear back state can trigger router cycles to the current url if we don't ignore them
3359
+ if (event.url === this.currentRouterUrl()) {
3360
+ Logger.get(this).info(`navigation started to same url -> ${event.url}`);
3361
+ return this;
3362
+ }
3363
+ if (event.url === (`${this.currentRouterUrl()}(aup-interaction:modal)`)) {
3364
+ Logger.get(this).info(`navigation started with interaction outlet -> ${event.url}`);
3365
+ return new ModalInteractionSession(this.context, event.url);
3366
+ }
3367
+ return this.createActiveSession(event);
3368
+ }
3369
+ /**
3370
+ * @param {?} event
3371
+ * @return {?}
3372
+ */
3373
+ onCancel(event) {
3374
+ return this.illegalTransition(event);
3375
+ }
3376
+ /**
3377
+ * @param {?} event
3378
+ * @return {?}
3379
+ */
3380
+ onEnd(event) {
3381
+ return this.illegalTransition(event);
3382
+ }
2981
3383
  /**
2982
- * @param {?} visit
2983
- * @param {?} appModelInteractionContext
3384
+ * @param {?} event
3385
+ * @return {?}
2984
3386
  */
2985
- constructor(visit, appModelInteractionContext) {
2986
- super(false, appModelInteractionContext);
2987
- this.isExternal = false;
2988
- this.storeVisit(visit);
3387
+ onError(event) {
3388
+ return this.illegalTransition(event);
2989
3389
  }
2990
3390
  }
3391
+ NavigationState.Idle = Idle;
2991
3392
  if (false) {
2992
3393
  /** @type {?} */
2993
- Internal.prototype.isExternal;
3394
+ Idle.prototype.isPopState;
3395
+ /** @type {?} */
3396
+ Idle.prototype.active;
3397
+ /** @type {?} */
3398
+ Idle.prototype.startingUrl;
2994
3399
  }
2995
- class Factory {
3400
+ class Active extends NavigationState {
3401
+ /**
3402
+ * @param {?} context
3403
+ * @param {?} isPopState
3404
+ * @param {?} startingUrl
3405
+ */
3406
+ constructor(context, isPopState, startingUrl) {
3407
+ super(context);
3408
+ this.isPopState = isPopState;
3409
+ this.startingUrl = startingUrl;
3410
+ this.active = true;
3411
+ this.componentDeactivationHandlers = new Map();
3412
+ this._interactionContext = this.context.modalInteractionService.createExclusiveInteractionContext();
3413
+ this.onDispose((/**
3414
+ * @return {?}
3415
+ */
3416
+ () => {
3417
+ // the interaction context can be detached during the back button cancellation state transition
3418
+ // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
3419
+ // called before the context has been cancelled. It might be work having the interaction context
3420
+ // automatically cancel if the context is disposed.
3421
+ if (this._interactionContext) {
3422
+ this._interactionContext.dispose();
3423
+ }
3424
+ }));
3425
+ }
3426
+ /**
3427
+ * @return {?}
3428
+ */
3429
+ get interactionContext() {
3430
+ return this._interactionContext;
3431
+ }
3432
+ /**
3433
+ * @param {?} event
3434
+ * @return {?}
3435
+ */
3436
+ onStart(event) {
3437
+ // active sessions can have many cancel start cycles.
3438
+ return this;
3439
+ }
3440
+ /**
3441
+ * @param {?} event
3442
+ * @return {?}
3443
+ */
3444
+ onEnd(event) {
3445
+ // navigation succeeded
3446
+ this.context.notifySuccess(this);
3447
+ return new Idle(this.context);
3448
+ }
2996
3449
  /**
2997
- * @param {?} interactionContext
3450
+ * @param {?} event
3451
+ * @return {?}
3452
+ */
3453
+ onCancel(event) {
3454
+ if (this.isPopState) { // back button clicked and a guard cancelled
3455
+ // Angular doesn't preserve the url when a guard cancels the back button.
3456
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3457
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3458
+ this.updateLocation(this.startingUrl);
3459
+ }
3460
+ return this.isPopState ? new Idle(this.context) : this;
3461
+ }
3462
+ /**
3463
+ * @param {?} event
3464
+ * @return {?}
3465
+ */
3466
+ onError(event) {
3467
+ // navigation was aborted.
3468
+ if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
3469
+ // Angular doesn't preserve the url when a guard cancels the back button.
3470
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3471
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3472
+ this.updateLocation(this.startingUrl);
3473
+ }
3474
+ return new Idle(this.context);
3475
+ }
3476
+ /**
3477
+ * @param {?} locationTriggerUrl
3478
+ * @return {?}
3479
+ */
3480
+ onBackClickedDuringNavigationInteraction(locationTriggerUrl) {
3481
+ /** @type {?} */
3482
+ const context = this.detachInteractionContext();
3483
+ context.getCurrentActivity().then((/**
3484
+ * @param {?} activity
3485
+ * @return {?}
3486
+ */
3487
+ activity => {
3488
+ context.addActivityListener({
3489
+ /**
3490
+ * @return {?}
3491
+ */
3492
+ onActivityFinished() {
3493
+ context.dispose();
3494
+ },
3495
+ /**
3496
+ * @return {?}
3497
+ */
3498
+ onActivityStarted() {
3499
+ }
3500
+ });
3501
+ activity.cancel(null);
3502
+ }));
3503
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
3504
+ }
3505
+ /**
3506
+ * @param {?} component
3507
+ * @param {?} nextState
3508
+ * @return {?}
2998
3509
  */
2999
- constructor(interactionContext) {
3000
- this.interactionContext = interactionContext;
3510
+ canDeactivatePlace(component, nextState) {
3511
+ return __awaiter(this, void 0, void 0, function* () {
3512
+ // lookup the handler and create it if we've not seen it yet
3513
+ /** @type {?} */
3514
+ let handler = this.componentDeactivationHandlers.get(component);
3515
+ if (!handler) {
3516
+ /** @type {?} */
3517
+ const isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
3518
+ handler = new PlaceComponentDeactivationHandler(component, this);
3519
+ this.componentDeactivationHandlers.set(component, handler);
3520
+ }
3521
+ return handler.canDeactivate(nextState);
3522
+ });
3001
3523
  }
3002
3524
  /**
3003
- * @param {?} visit
3525
+ * @private
3004
3526
  * @return {?}
3005
3527
  */
3006
- createInternal(visit) {
3007
- return new Internal(visit, this.interactionContext);
3528
+ detachInteractionContext() {
3529
+ /** @type {?} */
3530
+ const context = this._interactionContext;
3531
+ this._interactionContext = null;
3532
+ return context;
3008
3533
  }
3009
3534
  /**
3010
- * @param {?} firstTimeRoute
3011
3535
  * @return {?}
3012
3536
  */
3013
- createExternal(firstTimeRoute) {
3014
- return new External(firstTimeRoute, this.interactionContext);
3537
+ toString() {
3538
+ return `${this.constructor.name}(startingUrl: ${this.startingUrl}, isPopState:${this.isPopState})`;
3015
3539
  }
3016
3540
  }
3017
- NavigationSession.Factory = Factory;
3541
+ __decorate([
3542
+ Trace(),
3543
+ __metadata("design:type", Function),
3544
+ __metadata("design:paramtypes", [NavigationStart]),
3545
+ __metadata("design:returntype", NavigationState)
3546
+ ], Active.prototype, "onStart", null);
3547
+ __decorate([
3548
+ Trace(),
3549
+ __metadata("design:type", Function),
3550
+ __metadata("design:paramtypes", [NavigationCancel]),
3551
+ __metadata("design:returntype", NavigationState)
3552
+ ], Active.prototype, "onCancel", null);
3553
+ __decorate([
3554
+ Trace(),
3555
+ __metadata("design:type", Function),
3556
+ __metadata("design:paramtypes", [NavigationError]),
3557
+ __metadata("design:returntype", NavigationState)
3558
+ ], Active.prototype, "onError", null);
3559
+ NavigationState.Active = Active;
3018
3560
  if (false) {
3019
3561
  /** @type {?} */
3020
- Factory.prototype.interactionContext;
3562
+ Active.prototype.active;
3563
+ /**
3564
+ * @type {?}
3565
+ * @private
3566
+ */
3567
+ Active.prototype.componentDeactivationHandlers;
3568
+ /**
3569
+ * @type {?}
3570
+ * @private
3571
+ */
3572
+ Active.prototype._interactionContext;
3573
+ /** @type {?} */
3574
+ Active.prototype.isPopState;
3575
+ /** @type {?} */
3576
+ Active.prototype.startingUrl;
3021
3577
  }
3022
- class ComponentDeactivationHandler {
3578
+ class ModalInteractionSession extends NavigationState {
3023
3579
  /**
3024
- * @param {?} component
3025
- * @param {?} appModelInteractionContext
3026
- * @param {?} primary
3580
+ * @param {?} context
3581
+ * @param {?} startingUrl
3027
3582
  */
3028
- constructor(component, appModelInteractionContext, primary) {
3029
- this.component = component;
3030
- this.appModelInteractionContext = appModelInteractionContext;
3031
- this.primary = primary;
3032
- this.alreadyAccepted = false;
3033
- // super();
3583
+ constructor(context, startingUrl) {
3584
+ super(context);
3585
+ this.startingUrl = startingUrl;
3586
+ this.active = false;
3587
+ this.isPopState = false;
3034
3588
  }
3035
3589
  /**
3036
- * @param {?} nextState
3590
+ * @param {?} url
3037
3591
  * @return {?}
3038
3592
  */
3039
- canDeactivate(nextState) {
3040
- return __awaiter(this, void 0, void 0, function* () {
3041
- console.log(`${this.constructor.name}.canDeactivate`, { component: this.component });
3042
- if (this.alreadyAccepted) {
3043
- // We'll get called multiple times if there's any parameter sanitisation so
3044
- // we always return true if we accepted on a previous cycle of the current
3045
- // navigation session.
3046
- return true;
3047
- }
3048
- else {
3049
- if (this.primary && this.appModelInteractionContext.isActive()) {
3050
- // We check the global interaction first
3051
- yield this.cancelCurrentActivityOf(this.appModelInteractionContext);
3052
- return false;
3053
- }
3054
- this.alreadyAccepted = yield this.canDeactivateComponent(nextState);
3055
- return this.alreadyAccepted;
3593
+ static hasInteraction(url) {
3594
+ return url.endsWith('(aup-interaction:modal)');
3595
+ }
3596
+ /**
3597
+ * @param {?} event
3598
+ * @return {?}
3599
+ */
3600
+ onStart(event) {
3601
+ // VERY VERY IMPORTANT BACK BUTTON NOTE:
3602
+ // When the back button is clicked we'll enter here first, and push the url
3603
+ // back to the browser. Angular seems to ignore it from a routing perspective
3604
+ // and then the InteractionGuard will cancel the navigation. This process seems
3605
+ // to keep the brower history in a sane state.
3606
+ if (this.context.modalInteractionService.isActive()) {
3607
+ if (!ModalInteractionSession.hasInteraction(event.url)) {
3608
+ // this capture the case where
3609
+ this.updateLocation(this.startingUrl);
3056
3610
  }
3057
- });
3611
+ }
3612
+ return this;
3613
+ }
3614
+ /**
3615
+ * @param {?} event
3616
+ * @return {?}
3617
+ */
3618
+ onCancel(event) {
3619
+ // this.updateLocation(this.startingUrl);
3620
+ return this;
3621
+ }
3622
+ /**
3623
+ * @param {?} event
3624
+ * @return {?}
3625
+ */
3626
+ onEnd(event) {
3627
+ if (this.context.modalInteractionService.isActive()) {
3628
+ return this;
3629
+ }
3630
+ else {
3631
+ return new Idle(this.context);
3632
+ }
3633
+ }
3634
+ /**
3635
+ * @param {?} event
3636
+ * @return {?}
3637
+ */
3638
+ onError(event) {
3639
+ return this.illegalTransition(event);
3058
3640
  }
3059
3641
  /**
3060
- * @protected
3642
+ * @param {?} component
3061
3643
  * @param {?} nextState
3062
3644
  * @return {?}
3063
3645
  */
3064
- canDeactivateComponent(nextState) {
3646
+ canDeactivatePlace(component, nextState) {
3065
3647
  return __awaiter(this, void 0, void 0, function* () {
3066
- // check if the component has an active interaction. This will handle
3067
- // an inplace interaction contexts
3068
- /** @type {?} */
3069
- const hasCustomInteractionContext = this.component.interactionContext &&
3070
- !this.isAppModalInteractionContext(this.component.interactionContext) &&
3071
- this.component.interactionContext.isActive();
3072
- if (hasCustomInteractionContext) {
3073
- this.cancelCurrentActivityOf(this.component.interactionContext);
3074
- return false;
3075
- }
3076
- if (this.isLeavingCurrentPlace(nextState) && this.component.canDeactivate) {
3077
- // No interaction in progress, so ask the component .
3078
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3079
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3080
- return this.component.canDeactivate();
3081
- }
3082
3648
  return true;
3083
3649
  });
3084
3650
  }
3651
+ }
3652
+ __decorate([
3653
+ Trace(),
3654
+ __metadata("design:type", Function),
3655
+ __metadata("design:paramtypes", [NavigationStart]),
3656
+ __metadata("design:returntype", NavigationState)
3657
+ ], ModalInteractionSession.prototype, "onStart", null);
3658
+ __decorate([
3659
+ Trace(),
3660
+ __metadata("design:type", Function),
3661
+ __metadata("design:paramtypes", [NavigationCancel]),
3662
+ __metadata("design:returntype", NavigationState)
3663
+ ], ModalInteractionSession.prototype, "onCancel", null);
3664
+ __decorate([
3665
+ Trace(),
3666
+ __metadata("design:type", Function),
3667
+ __metadata("design:paramtypes", [NavigationEnd]),
3668
+ __metadata("design:returntype", NavigationState)
3669
+ ], ModalInteractionSession.prototype, "onEnd", null);
3670
+ NavigationState.ModalInteractionSession = ModalInteractionSession;
3671
+ if (false) {
3672
+ /** @type {?} */
3673
+ ModalInteractionSession.prototype.active;
3674
+ /** @type {?} */
3675
+ ModalInteractionSession.prototype.isPopState;
3676
+ /** @type {?} */
3677
+ ModalInteractionSession.prototype.startingUrl;
3678
+ }
3679
+ class CancelledDuringNavigationInteraction extends NavigationState {
3085
3680
  /**
3086
- * @param {?} interactionContext
3087
- * @return {?}
3681
+ * @param {?} context
3682
+ * @param {?} startingUrl
3683
+ * @param {?} locationChangeTriggerUrl
3088
3684
  */
3089
- isAppModalInteractionContext(interactionContext) {
3090
- return this.appModelInteractionContext === interactionContext;
3685
+ constructor(context, startingUrl, locationChangeTriggerUrl) {
3686
+ super(context);
3687
+ this.startingUrl = startingUrl;
3688
+ this.locationChangeTriggerUrl = locationChangeTriggerUrl;
3689
+ this.active = false;
3690
+ this.capturedFauxRouterStart = false;
3691
+ // This will trigger a return to the route we originally started with.
3692
+ // this.angularLocation.go(this.startingUrl);
3091
3693
  }
3092
3694
  /**
3093
- * @protected
3094
- * @param {?} interactionContext
3695
+ * @param {?} component
3696
+ * @param {?} nextState
3095
3697
  * @return {?}
3096
3698
  */
3097
- cancelCurrentActivityOf(interactionContext) {
3699
+ canDeactivatePlace(component, nextState) {
3098
3700
  return __awaiter(this, void 0, void 0, function* () {
3099
- /** @type {?} */
3100
- const activity = yield interactionContext.getCurrentActivity();
3101
- console.log('cancelling', { activity });
3102
- activity.cancel(null);
3701
+ return false;
3103
3702
  });
3104
3703
  }
3105
3704
  /**
3106
- * @protected
3107
- * @param {?} nextState
3705
+ * @param {?} event
3706
+ * @return {?}
3707
+ */
3708
+ onCancel(event) {
3709
+ return this.ignore(event);
3710
+ }
3711
+ /**
3712
+ * @param {?} event
3713
+ * @return {?}
3714
+ */
3715
+ onEnd(event) {
3716
+ return this.ignore(event);
3717
+ }
3718
+ /**
3719
+ * @param {?} event
3108
3720
  * @return {?}
3109
3721
  */
3110
- isLeavingCurrentPlace(nextState) {
3111
- return !nextState.includesPathOf(this.component.placeDefinition);
3722
+ onError(event) {
3723
+ return this.ignore(event);
3724
+ }
3725
+ /**
3726
+ * @param {?} event
3727
+ * @return {?}
3728
+ */
3729
+ onStart(event) {
3730
+ if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
3731
+ this.capturedFauxRouterStart = true;
3732
+ return this.ignore(event, 'url matched back button location change');
3733
+ }
3734
+ else {
3735
+ return this.createActiveSession(event);
3736
+ }
3737
+ }
3738
+ /**
3739
+ * @param {?} event
3740
+ * @param {?=} reason
3741
+ * @return {?}
3742
+ */
3743
+ ignore(event, reason) {
3744
+ reason = reason ? ` (${reason})` : '';
3745
+ Logger.get(this).info(`ignoring router event${reason}: ${event.constructor.name} -> ${event.url}`);
3746
+ return this;
3747
+ }
3748
+ /**
3749
+ * @return {?}
3750
+ */
3751
+ toString() {
3752
+ return `${this.constructor.name}(startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
3112
3753
  }
3113
3754
  }
3114
- NavigationSession.ComponentDeactivationHandler = ComponentDeactivationHandler;
3755
+ NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
3115
3756
  if (false) {
3757
+ /** @type {?} */
3758
+ CancelledDuringNavigationInteraction.prototype.active;
3759
+ /** @type {?} */
3760
+ CancelledDuringNavigationInteraction.prototype.isPopState;
3116
3761
  /**
3117
3762
  * @type {?}
3118
3763
  * @private
3119
3764
  */
3120
- ComponentDeactivationHandler.prototype.alreadyAccepted;
3121
- /** @type {?} */
3122
- ComponentDeactivationHandler.prototype.component;
3765
+ CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
3123
3766
  /** @type {?} */
3124
- ComponentDeactivationHandler.prototype.appModelInteractionContext;
3767
+ CancelledDuringNavigationInteraction.prototype.startingUrl;
3125
3768
  /** @type {?} */
3126
- ComponentDeactivationHandler.prototype.primary;
3769
+ CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
3127
3770
  }
3128
- })(NavigationSession || (NavigationSession = {}));
3771
+ })(NavigationState || (NavigationState = {}));
3129
3772
 
3130
3773
  /**
3131
3774
  * @fileoverview added by tsickle
@@ -3193,308 +3836,130 @@ if (false) {
3193
3836
  * @fileoverview added by tsickle
3194
3837
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3195
3838
  */
3196
- /**
3197
- * @param {?} options
3198
- * @return {?}
3199
- */
3200
- function Place(options) {
3201
- return (/**
3202
- * @param {?} target
3839
+ class UrlSnapshot {
3840
+ /**
3841
+ * @param {?} urlTree
3842
+ */
3843
+ constructor(urlTree) {
3844
+ this.urlTree = urlTree;
3845
+ // console.log({ segments: this.urlTree.root.children.primary.segments });
3846
+ }
3847
+ /**
3203
3848
  * @return {?}
3204
3849
  */
3205
- (target) => {
3206
- if (PlaceComponent.isPlaceComponentConstructor(target)) {
3207
- PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? false : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
3208
- * @param {?} c
3209
- * @return {?}
3210
- */
3211
- c => PlaceComponent.getDefinition(c)))));
3212
- }
3213
- else {
3214
- lang.illegalState(`${target} must extend PlaceComponent to use the @Place decorator`);
3215
- }
3216
- });
3217
- }
3218
- (function (Place) {
3850
+ cloneUrlSegmentList() {
3851
+ return [...this.urlTree.root.children.primary.segments];
3852
+ }
3219
3853
  /**
3220
- * @record
3854
+ * @param {?} visit
3855
+ * @return {?}
3221
3856
  */
3222
- function Options() { }
3223
- Place.Options = Options;
3224
- if (false) {
3857
+ updateVisitSegments(visit) {
3858
+ // Ugly, but it works for now.
3225
3859
  /** @type {?} */
3226
- Options.prototype.path;
3227
- /** @type {?|undefined} */
3228
- Options.prototype.data;
3229
- /** @type {?|undefined} */
3230
- Options.prototype.authenticate;
3231
- /** @type {?|undefined} */
3232
- Options.prototype.children;
3233
- /** @type {?|undefined} */
3234
- Options.prototype.defaultChild;
3235
- }
3236
- })(Place || (Place = {}));
3237
-
3238
- /**
3239
- * @fileoverview added by tsickle
3240
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3241
- */
3242
- // WARNING: interface has both a type and a value, skipping emit
3243
- var Formatter;
3244
- (function (Formatter) {
3245
- class StringType {
3246
- /**
3247
- * @param {?} value
3248
- * @return {?}
3249
- */
3250
- format(value) {
3251
- return value;
3252
- }
3253
- /**
3254
- * @param {?} value
3255
- * @return {?}
3256
- */
3257
- parse(value) {
3258
- return value;
3259
- }
3260
- }
3261
- class NumberType {
3262
- /**
3263
- * @param {?} value
3264
- * @return {?}
3265
- */
3266
- format(value) {
3267
- return ___default.isNumber(value) && !___default.isNaN(value) ? `${value}` : null;
3268
- }
3269
- /**
3270
- * @param {?} value
3271
- * @return {?}
3272
- */
3273
- parse(value) {
3274
- /** @type {?} */
3275
- const parsed = Number.parseFloat(value);
3276
- return ___default.isNaN(parsed) ? null : parsed;
3277
- }
3278
- }
3279
- class BooleanType {
3280
- /**
3281
- * @param {?} value
3282
- * @return {?}
3283
- */
3284
- format(value) {
3285
- return value ? 'true' : 'false';
3286
- }
3287
- /**
3288
- * @param {?} value
3860
+ const segments = this.cloneUrlSegmentList();
3861
+ /** @type {?} */
3862
+ const visitSegments = this.convertToUrlSegments(visit);
3863
+ /** @type {?} */
3864
+ const replaceAt = segments.findIndex((/**
3865
+ * @param {?} segment
3289
3866
  * @return {?}
3290
3867
  */
3291
- parse(value) {
3292
- return value === 'true';
3293
- }
3868
+ segment => segment.path === visitSegments[0].path));
3869
+ // do not use the return value, it's the items that were removed!
3870
+ segments.splice(replaceAt, visitSegments.length, ...visitSegments);
3871
+ return segments;
3294
3872
  }
3295
- Formatter.STRING = new StringType();
3296
- Formatter.NUMBER = new NumberType();
3297
- Formatter.BOOLEAN = new BooleanType();
3298
- })(Formatter || (Formatter = {}));
3299
-
3300
- /**
3301
- * @fileoverview added by tsickle
3302
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3303
- */
3304
- /**
3305
- * @record
3306
- * @template T
3307
- */
3308
- function RouteIdOptions() { }
3309
- if (false) {
3310
- /** @type {?|undefined} */
3311
- RouteIdOptions.prototype.as;
3312
- /** @type {?|undefined} */
3313
- RouteIdOptions.prototype.optional;
3314
- /** @type {?|undefined} */
3315
- RouteIdOptions.prototype.remember;
3316
- /** @type {?|undefined} */
3317
- RouteIdOptions.prototype.defaultValue;
3318
- }
3319
- /**
3320
- * @record
3321
- * @template T
3322
- */
3323
- function RouteParameterOptions() { }
3324
- if (false) {
3325
- /** @type {?|undefined} */
3326
- RouteParameterOptions.prototype.as;
3327
- /** @type {?|undefined} */
3328
- RouteParameterOptions.prototype.optional;
3329
- /** @type {?|undefined} */
3330
- RouteParameterOptions.prototype.remember;
3331
- /** @type {?|undefined} */
3332
- RouteParameterOptions.prototype.defaultValue;
3333
- /** @type {?|undefined} */
3334
- RouteParameterOptions.prototype.storeInUrl;
3335
- }
3336
- /**
3337
- * @record
3338
- * @template T
3339
- */
3340
- function RouteListParameterOptions() { }
3341
- if (false) {
3342
- /** @type {?|undefined} */
3343
- RouteListParameterOptions.prototype.as;
3344
- /** @type {?|undefined} */
3345
- RouteListParameterOptions.prototype.optional;
3346
- /** @type {?|undefined} */
3347
- RouteListParameterOptions.prototype.remember;
3348
- /** @type {?|undefined} */
3349
- RouteListParameterOptions.prototype.defaultValue;
3350
- /** @type {?|undefined} */
3351
- RouteListParameterOptions.prototype.storeInUrl;
3352
- }
3353
- /**
3354
- * @template T
3355
- * @param {?} type
3356
- * @param {?=} options
3357
- * @return {?}
3358
- */
3359
- function RouteId(type, options) {
3360
- return (/**
3361
- * @param {?} prototype
3362
- * @param {?} propertyKey
3873
+ /**
3874
+ * Converts the visit into segments. Please not that these segments are not e
3875
+ * @param {?} visit
3363
3876
  * @return {?}
3364
3877
  */
3365
- (prototype, propertyKey) => {
3366
- /** @type {?} */
3367
- const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
3368
- Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
3369
- UseDelegate()(prototype, propertyKey);
3370
- });
3371
- }
3372
- /**
3373
- * @template T
3374
- * @param {?=} options
3375
- * @return {?}
3376
- */
3377
- function VisitParameter(options) {
3378
- /** @type {?} */
3379
- const opts = Opts.get(options);
3380
- return (/**
3381
- * @param {?} prototype
3382
- * @param {?} propertyKey
3878
+ convertToUrlSegments(visit) {
3879
+ return visit.placeDefinition.hasRouteId() ?
3880
+ [
3881
+ // NOTE:
3882
+ // It's important to attach the params to the root path and not the id. If we attach them
3883
+ // to an empty id then the angular router won't match the pattern.
3884
+ new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
3885
+ new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
3886
+ ]
3887
+ :
3888
+ [
3889
+ new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
3890
+ ];
3891
+ }
3892
+ /**
3893
+ * @param {?} visit
3383
3894
  * @return {?}
3384
3895
  */
3385
- (prototype, propertyKey) => {
3896
+ createRedirectCommandsFor(visit) {
3386
3897
  /** @type {?} */
3387
- const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
3388
- Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
3389
- UseDelegate()(prototype, propertyKey);
3390
- });
3391
- }
3392
- /**
3393
- * @template E
3394
- * @param {?=} options
3395
- * @return {?}
3396
- */
3397
- function VisitParameterList(options) {
3398
- /** @type {?} */
3399
- const opts = Opts.get(options);
3400
- return (/**
3401
- * @param {?} prototype
3402
- * @param {?} propertyKey
3403
- * @return {?}
3404
- */
3405
- (prototype, propertyKey) => {
3898
+ const segments = this.updateVisitSegments(visit);
3406
3899
  /** @type {?} */
3407
- const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
3408
- Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
3409
- UseDelegate()(prototype, propertyKey);
3410
- });
3411
- }
3412
-
3413
- /**
3414
- * @fileoverview added by tsickle
3415
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3416
- */
3417
- let NoopGatewayPlace = class NoopGatewayPlace extends PlaceComponent {
3418
- /**
3419
- * @param {?} router
3420
- */
3421
- constructor(router) {
3422
- super();
3423
- this.router = router;
3900
+ const commands = [];
3901
+ segments.forEach((/**
3902
+ * @param {?} s
3903
+ * @return {?}
3904
+ */
3905
+ s => {
3906
+ commands.push(s.path);
3907
+ if (s.parameterMap.keys.length > 0) {
3908
+ commands.push(s.parameters);
3909
+ }
3910
+ }));
3911
+ return commands;
3424
3912
  }
3425
3913
  /**
3914
+ * @param {?} placeDef
3426
3915
  * @return {?}
3427
3916
  */
3428
- ngOnInit() {
3429
- this.router.navigateByUrl(this.returnUrl.value);
3917
+ includesPathOf(placeDef) {
3918
+ return this.cloneUrlSegmentList().find((/**
3919
+ * @param {?} s
3920
+ * @return {?}
3921
+ */
3922
+ s => s.path === placeDef.path));
3430
3923
  }
3431
- };
3432
- NoopGatewayPlace.ctorParameters = () => [
3433
- { type: Router }
3434
- ];
3435
- NoopGatewayPlace.decorators = [
3436
- { type: Component, args: [{
3437
- template: ''
3438
- }] }
3439
- ];
3440
- /** @nocollapse */
3441
- NoopGatewayPlace.ctorParameters = () => [
3442
- { type: Router }
3443
- ];
3444
- __decorate([
3445
- VisitParameter({ storeInUrl: Formatter.STRING }),
3446
- __metadata("design:type", MutableValueModel)
3447
- ], NoopGatewayPlace.prototype, "returnUrl", void 0);
3448
- NoopGatewayPlace = __decorate([
3449
- Place({
3450
- path: 'aup-gateway-route',
3451
- authenticate: false
3452
- }),
3453
- __metadata("design:paramtypes", [Router])
3454
- ], NoopGatewayPlace);
3924
+ }
3455
3925
  if (false) {
3456
3926
  /** @type {?} */
3457
- NoopGatewayPlace.prototype.returnUrl;
3458
- /** @type {?} */
3459
- NoopGatewayPlace.prototype.router;
3927
+ UrlSnapshot.prototype.urlTree;
3460
3928
  }
3461
3929
 
3462
3930
  /**
3463
3931
  * @fileoverview added by tsickle
3464
3932
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3465
3933
  */
3466
- /** @type {?} */
3467
- const noopPlaceDef = PlaceComponent.getDefinition(NoopGatewayPlace);
3468
3934
  class PlaceRouter extends GarbageCollector {
3469
3935
  /**
3470
3936
  * @param {?} router
3471
3937
  * @param {?} urlSerializer
3472
- * @param {?} interactionContext
3473
3938
  * @param {?} angularLocation
3474
3939
  * @param {?} placeHistory
3940
+ * @param {?} modalInteractionService
3475
3941
  */
3476
- constructor(router, urlSerializer, interactionContext, angularLocation, placeHistory) {
3942
+ constructor(router, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
3477
3943
  super();
3478
3944
  this.router = router;
3479
3945
  this.urlSerializer = urlSerializer;
3480
- this.interactionContext = interactionContext;
3481
3946
  this.angularLocation = angularLocation;
3482
3947
  this.placeHistory = placeHistory;
3948
+ this.modalInteractionService = modalInteractionService;
3483
3949
  this.firstRoute = true;
3484
3950
  this._navigationSessionModel = new MutableValueModel();
3485
3951
  this._activeVisits = new MutableListModel();
3486
- this.initialRedirectStarted = false;
3487
- this.initialRedirectFinished = false;
3488
3952
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
3489
3953
  this.activeVisitIndex = chain(this._activeVisits).indexBy('placeDefinition');
3490
- this.navigationSessionFactory = new NavigationSession.Factory(interactionContext);
3491
- angularLocation.onUrlChange((/**
3492
- * @param {?} url
3954
+ this.navigationSessionActive = chain(this.navigationSessionModel).pluck('active');
3955
+ this._navigationSessionContext = new NavigationState.Context(this.router, this.modalInteractionService, this.angularLocation, (/**
3956
+ * @param {?} session
3493
3957
  * @return {?}
3494
3958
  */
3495
- url => {
3496
- console.log(`location.onUrlChange -> ${url}`);
3959
+ session => {
3960
+ this.processNavigationSuccess(session);
3497
3961
  }));
3962
+ this._navigationSessionModel.value = new NavigationState.Idle(this._navigationSessionContext);
3498
3963
  // TODO: make setup the callbacks in during module initiation to make this testable.
3499
3964
  this.router.events.subscribe((/**
3500
3965
  * @param {?} event
@@ -3505,28 +3970,76 @@ class PlaceRouter extends GarbageCollector {
3505
3970
  // ======================
3506
3971
  // NavigationStart -> .... -> NavigationCancel --> redirect, go around again in the same session
3507
3972
  // NavigationStart -> .... -> NavigationEnd --> navigation complete, end session.
3508
- // NavigationStart -> .... -> NavigationError --> navigation canceled, end session.
3973
+ // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
3509
3974
  // =======================
3510
3975
  if (event instanceof NavigationStart) {
3511
- this.onAngularRouterStarted(event);
3976
+ this.runStateTransition((/**
3977
+ * @param {?} session
3978
+ * @return {?}
3979
+ */
3980
+ session => session.onStart(event)));
3512
3981
  }
3513
3982
  if (event instanceof NavigationEnd) {
3514
- this.onAngularRouterFinished(false);
3983
+ this.runStateTransition((/**
3984
+ * @param {?} session
3985
+ * @return {?}
3986
+ */
3987
+ session => session.onEnd(event)));
3515
3988
  }
3516
3989
  if (event instanceof NavigationError) {
3517
- this.onAngularRouterFinished(true);
3990
+ this.runStateTransition((/**
3991
+ * @param {?} session
3992
+ * @return {?}
3993
+ */
3994
+ session => session.onError(event)));
3995
+ }
3996
+ if (event instanceof NavigationCancel) {
3997
+ this.runStateTransition((/**
3998
+ * @param {?} session
3999
+ * @return {?}
4000
+ */
4001
+ session => session.onCancel(event)));
3518
4002
  }
3519
4003
  }));
3520
- this.navigationSessionActive = chain(this.navigationSessionModel).isNotNil();
3521
- this.navigationSessionActive.subscribe((/**
3522
- * @param {?} active
4004
+ // Push dialog state to the url so we can capture the back button.
4005
+ this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(this.navigationSessionActive, this.router));
4006
+ // The angular router doesn't always fire router events when the back button is pushed while a navigation
4007
+ // session is in progress. Sometimes we only know about it from the url change.
4008
+ angularLocation.onUrlChange((/**
4009
+ * @param {?} url
3523
4010
  * @return {?}
3524
4011
  */
3525
- active => {
3526
- console.log('navigationSessionActive', active);
4012
+ url => {
4013
+ console.log(`#### url changed ->`, { url, navIsActive: this.navigationSessionActive.value });
4014
+ /** @type {?} */
4015
+ const interactionContext = this.navigationSessionActive.value && this.navigationSession.interactionContext;
4016
+ if (interactionContext && interactionContext.isActive()) {
4017
+ Logger.get(this).info(`back button pressed during navigation session interaction`);
4018
+ this.runStateTransition((/**
4019
+ * @param {?} navigationSession
4020
+ * @return {?}
4021
+ */
4022
+ navigationSession => navigationSession.onBackClickedDuringNavigationInteraction(url)));
4023
+ }
3527
4024
  }));
3528
- // const txo = new TransactionObserver().onEvent(e => console.log(e.toString()));
3529
- // txo.observe('this.navigationSessionModel', this.navigationSessionModel);
4025
+ }
4026
+ /**
4027
+ * @private
4028
+ * @param {?} session
4029
+ * @return {?}
4030
+ */
4031
+ processNavigationSuccess(session) {
4032
+ // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
4033
+ // changes that occur while routerNavigationActive is true.
4034
+ assert.isTruthy(this.navigationSessionActive.value);
4035
+ /** @type {?} */
4036
+ const visits = session.getVisits();
4037
+ visits.forEach((/**
4038
+ * @param {?} v
4039
+ * @return {?}
4040
+ */
4041
+ v => this.placeHistory.add(v)));
4042
+ this._activeVisits.value = visits;
3530
4043
  }
3531
4044
  /**
3532
4045
  * @return {?}
@@ -3570,14 +4083,6 @@ class PlaceRouter extends GarbageCollector {
3570
4083
  })));
3571
4084
  });
3572
4085
  }
3573
- /**
3574
- * @param {?} visit
3575
- * @param {?=} navigationExtras
3576
- * @return {?}
3577
- */
3578
- createRedirectFor(visit, navigationExtras) {
3579
- return this.router.createUrlTree(this.createRouteParameters(visit), navigationExtras);
3580
- }
3581
4086
  // @Trace()
3582
4087
  /**
3583
4088
  * @param {?} activatedRoute
@@ -3599,15 +4104,6 @@ class PlaceRouter extends GarbageCollector {
3599
4104
  router => {
3600
4105
  /** @type {?} */
3601
4106
  const commands = this.parseUrl(this.router.routerState.snapshot).createRedirectCommandsFor(next);
3602
- // // we have to to use the definition for route id as our redirection always includes
3603
- // // the id in the url segements (but leaves it blank when there's no id). I.e. in the
3604
- // // no id case we're doing the following redirect [<placePath>, ""] -> ["..", <id>]
3605
- // const relativePath = !!previous.placeDefinition.hasRouteId() ? '..' : '.';
3606
- // const commands = [
3607
- // relativePath,
3608
- // ...this.createRouteParameters(next),
3609
- // ...this.extractChildPath(activatedRoute.snapshot)
3610
- // ];
3611
4107
  console.log('### Push Changes to route Redirect', { commands });
3612
4108
  return router.navigate(commands);
3613
4109
  }));
@@ -3616,84 +4112,67 @@ class PlaceRouter extends GarbageCollector {
3616
4112
  }
3617
4113
  /**
3618
4114
  * @param {?} visit
3619
- * @param {?} customNavigation
4115
+ * @param {?} runNavigationCommands
3620
4116
  * @return {?}
3621
4117
  */
3622
- doNavigation(visit, customNavigation) {
4118
+ doNavigation(visit, runNavigationCommands) {
3623
4119
  return __awaiter(this, void 0, void 0, function* () {
3624
- this._navigationSessionModel.value = this.navigationSessionFactory.createInternal(visit);
4120
+ if (this.navigationSessionActive.value) {
4121
+ lang.illegalState('Navigation already in progress');
4122
+ }
4123
+ this.runStateTransition((/**
4124
+ * @param {?} current
4125
+ * @return {?}
4126
+ */
4127
+ current => {
4128
+ /** @type {?} */
4129
+ const session = new NavigationState.Active(this._navigationSessionContext, false, this.router.routerState.snapshot.url);
4130
+ session.storeVisit(visit);
4131
+ return session;
4132
+ }));
3625
4133
  try {
3626
- yield customNavigation(this.router);
4134
+ yield runNavigationCommands(this.router);
3627
4135
  }
3628
4136
  finally {
3629
4137
  // Router has finished (since there was no router change required) so we
3630
4138
  // need to end the navigation session.
3631
- if (this.navigationSession && !this.router.getCurrentNavigation()) {
3632
- this.onAngularRouterFinished(false);
4139
+ if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
4140
+ this.runStateTransition((/**
4141
+ * @param {?} session
4142
+ * @return {?}
4143
+ */
4144
+ session => session.onEnd(new NavigationEnd(-1, '', ''))));
3633
4145
  }
3634
4146
  }
3635
4147
  });
3636
4148
  }
3637
4149
  /**
3638
- * @private
3639
- * @param {?} visit
4150
+ * @protected
4151
+ * @param {?} transition
3640
4152
  * @return {?}
3641
4153
  */
3642
- createRouteParameters(visit) {
4154
+ runStateTransition(transition) {
3643
4155
  /** @type {?} */
3644
- const def = visit.placeDefinition;
3645
- return visit.hasRouteId() ?
3646
- [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
3647
- [def.getFormattedRouteParameters(visit)];
3648
- }
3649
- // @Trace()
3650
- /**
3651
- * @private
3652
- * @param {?} event
3653
- * @return {?}
3654
- */
3655
- onAngularRouterStarted(event) {
3656
- if (!this.navigationSession) { // We been activated by an external route rather than placeRouter.go(visit)
3657
- console.log('navigation started', { firstTime: this.firstRoute });
3658
- /** @type {?} */
3659
- const session = this.navigationSessionFactory.createExternal(this.firstRoute);
3660
- if (event.navigationTrigger === 'popstate') {
3661
- session.setPopstateReturnUrl(this.router.routerState.snapshot.url);
3662
- }
3663
- this._navigationSessionModel.value = session;
4156
+ const previous = this._navigationSessionModel.value;
4157
+ /** @type {?} */
4158
+ const next = transition(this.navigationSession);
4159
+ this._navigationSessionModel.value = next;
4160
+ if (next !== previous) {
4161
+ previous.dispose();
4162
+ Logger.get(this).info(`Router State Transition: ${previous.toString()} -> ${next.toString()}`);
3664
4163
  }
3665
- this.firstRoute = false;
3666
4164
  }
3667
- // @Trace()
3668
4165
  /**
3669
4166
  * @private
3670
- * @param {?} cancelled
4167
+ * @param {?} visit
3671
4168
  * @return {?}
3672
4169
  */
3673
- onAngularRouterFinished(cancelled) {
4170
+ createRouteParameters(visit) {
3674
4171
  /** @type {?} */
3675
- const session = this._navigationSessionModel.value;
3676
- if (!cancelled) {
3677
- // Update visits before we end the navigation session. This allows the placeOutets to
3678
- // ignore visit changes that occur while the navigation is in progress
3679
- /** @type {?} */
3680
- const visits = session.getVisits();
3681
- visits.forEach((/**
3682
- * @param {?} v
3683
- * @return {?}
3684
- */
3685
- v => this.placeHistory.add(v)));
3686
- this._activeVisits.value = visits;
3687
- }
3688
- else {
3689
- // Angular doesn't preserve the url when a guard cancels the back button.
3690
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3691
- if (session.isPopState) {
3692
- console.log('cancelled during popstate');
3693
- this.angularLocation.go(session.popStateReturnUrl);
3694
- }
3695
- }
3696
- this._navigationSessionModel.value = null;
4172
+ const def = visit.placeDefinition;
4173
+ return visit.hasRouteId() ?
4174
+ [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
4175
+ [def.getFormattedRouteParameters(visit)];
3697
4176
  }
3698
4177
  /**
3699
4178
  * @param {?} activatedRoute
@@ -3711,35 +4190,7 @@ class PlaceRouter extends GarbageCollector {
3711
4190
  * @return {?}
3712
4191
  */
3713
4192
  parseUrl(snapshot) {
3714
- return new PlaceRouter.UrlHelper(this.urlSerializer.parse(snapshot.url));
3715
- }
3716
- // TODO: this all only sort of works. Opening dialogs and clicking back multiple times breaks things.
3717
- // TODO: next stage is to investigate tracking dialog state in a different placeoutlet and keeping those
3718
- // TODO: urls out of the history.
3719
- /**
3720
- * @param {?} activatedRoute
3721
- * @param {?} state
3722
- * @return {?}
3723
- */
3724
- performInitialNavigationIntercept(activatedRoute, state) {
3725
- assert.isTruthy(this.isInitialNavigation());
3726
- Logger.get(this).info(`Redirecting to: ${noopPlaceDef.path}`, { returnUrl: state.url });
3727
- if (!this.initialRedirectFinished) {
3728
- this.initialRedirectFinished = true;
3729
- return this.router.createUrlTree([noopPlaceDef.path, {
3730
- returnUrl: state.url
3731
- }], {
3732
- replaceUrl: true,
3733
- // make sure we update our history
3734
- skipLocationChange: false
3735
- });
3736
- }
3737
- }
3738
- /**
3739
- * @return {?}
3740
- */
3741
- isInitialNavigation() {
3742
- return this.navigationSession.firstNavigation && !this.initialRedirectFinished;
4193
+ return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
3743
4194
  }
3744
4195
  }
3745
4196
  PlaceRouter.decorators = [
@@ -3751,17 +4202,11 @@ PlaceRouter.decorators = [
3751
4202
  PlaceRouter.ctorParameters = () => [
3752
4203
  { type: Router },
3753
4204
  { type: UrlSerializer },
3754
- { type: InteractionContext },
3755
4205
  { type: Location },
3756
- { type: PlaceHistory }
4206
+ { type: PlaceHistory },
4207
+ { type: ModalInteractionService }
3757
4208
  ];
3758
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(InteractionContext), ɵɵinject(Location), ɵɵinject(PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
3759
- __decorate([
3760
- Trace(),
3761
- __metadata("design:type", Function),
3762
- __metadata("design:paramtypes", [Visit, Object]),
3763
- __metadata("design:returntype", Promise)
3764
- ], PlaceRouter.prototype, "navigate", null);
4209
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(ModalInteractionService)); }, token: PlaceRouter, providedIn: "root" });
3765
4210
  if (false) {
3766
4211
  /**
3767
4212
  * @type {?}
@@ -3786,137 +4231,88 @@ if (false) {
3786
4231
  * @type {?}
3787
4232
  * @private
3788
4233
  */
3789
- PlaceRouter.prototype.navigationSessionFactory;
4234
+ PlaceRouter.prototype._navigationSessionContext;
3790
4235
  /**
3791
4236
  * @type {?}
3792
4237
  * @private
3793
4238
  */
3794
- PlaceRouter.prototype.initialRedirectStarted;
4239
+ PlaceRouter.prototype.router;
3795
4240
  /**
3796
4241
  * @type {?}
3797
4242
  * @private
3798
4243
  */
3799
- PlaceRouter.prototype.initialRedirectFinished;
4244
+ PlaceRouter.prototype.urlSerializer;
3800
4245
  /**
3801
4246
  * @type {?}
3802
4247
  * @private
3803
4248
  */
3804
- PlaceRouter.prototype.router;
4249
+ PlaceRouter.prototype.angularLocation;
3805
4250
  /**
3806
4251
  * @type {?}
3807
4252
  * @private
3808
4253
  */
3809
- PlaceRouter.prototype.urlSerializer;
4254
+ PlaceRouter.prototype.placeHistory;
3810
4255
  /**
3811
4256
  * @type {?}
3812
4257
  * @private
3813
4258
  */
3814
- PlaceRouter.prototype.interactionContext;
3815
- /** @type {?} */
3816
- PlaceRouter.prototype.angularLocation;
3817
- /** @type {?} */
3818
- PlaceRouter.prototype.placeHistory;
4259
+ PlaceRouter.prototype.modalInteractionService;
3819
4260
  }
3820
4261
  (function (PlaceRouter) {
3821
- class UrlHelper {
4262
+ PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
4263
+ class InteractionRouteMediator {
3822
4264
  /**
3823
- * @param {?} urlTree
4265
+ * @param {?} navigationSessionModelActive
4266
+ * @param {?} router
3824
4267
  */
3825
- constructor(urlTree) {
3826
- this.urlTree = urlTree;
3827
- console.log({ segments: this.urlTree.root.children.primary.segments });
4268
+ constructor(navigationSessionModelActive, router) {
4269
+ this.navigationSessionModelActive = navigationSessionModelActive;
4270
+ this.router = router;
3828
4271
  }
3829
4272
  /**
3830
4273
  * @return {?}
3831
4274
  */
3832
- cloneUrlSegmentList() {
3833
- return [...this.urlTree.root.children.primary.segments];
4275
+ get isNavigating() {
4276
+ return this.navigationSessionModelActive.value;
3834
4277
  }
4278
+ // If we're not in a navigation we push
4279
+ // @Trace()
3835
4280
  /**
3836
- * @param {?} visit
3837
4281
  * @return {?}
3838
4282
  */
3839
- updateVisitSegments(visit) {
3840
- // Ugly, but it works for now.
3841
- /** @type {?} */
3842
- const segments = this.cloneUrlSegmentList();
3843
- /** @type {?} */
3844
- const visitSegments = this.convertToUrlSegments(visit);
3845
- /** @type {?} */
3846
- const replaceAt = segments.findIndex((/**
3847
- * @param {?} segment
3848
- * @return {?}
3849
- */
3850
- segment => segment.path === visitSegments[0].path));
3851
- // do not use the return value, it's the items that were removed!
3852
- segments.splice(replaceAt, visitSegments.length, ...visitSegments);
3853
- return segments;
3854
- }
3855
- /**
3856
- * Converts the visit into segments. Please not that these segments are not e
3857
- * @param {?} visit
3858
- * @return {?}
3859
- */
3860
- convertToUrlSegments(visit) {
3861
- return visit.placeDefinition.hasRouteId() ?
3862
- [
3863
- // NOTE:
3864
- // It's important to attach the params to the root path and not the id. If we attach them
3865
- // to an empty id then the angular router won't match the pattern.
3866
- new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),
3867
- new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})
3868
- ]
3869
- :
3870
- [
3871
- new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
3872
- ];
3873
- }
3874
- /**
3875
- * @param {?} visit
3876
- * @return {?}
3877
- */
3878
- createRedirectCommandsFor(visit) {
3879
- /** @type {?} */
3880
- const segments = this.updateVisitSegments(visit);
3881
- /** @type {?} */
3882
- const commands = [];
3883
- segments.forEach((/**
3884
- * @param {?} s
3885
- * @return {?}
3886
- */
3887
- s => {
3888
- commands.push(s.path);
3889
- if (s.parameterMap.keys.length > 0) {
3890
- commands.push(s.parameters);
3891
- }
3892
- }));
3893
- return commands;
4283
+ onActivityStarted() {
4284
+ if (!this.isNavigating) {
4285
+ this.router.navigate(['.', {
4286
+ outlets: {
4287
+ [PlaceRouter.INTERACTION_ROUTER_OUTLET]: ['modal'] // "open" must be a valid route for this outlet.
4288
+ }
4289
+ }], {
4290
+ replaceUrl: false
4291
+ });
4292
+ }
3894
4293
  }
4294
+ // @Trace()
3895
4295
  /**
3896
- * @param {?} placeDef
3897
4296
  * @return {?}
3898
4297
  */
3899
- includesPathOf(placeDef) {
3900
- return this.cloneUrlSegmentList().find((/**
3901
- * @param {?} s
3902
- * @return {?}
3903
- */
3904
- s => s.path === placeDef.path));
4298
+ onActivityFinished() {
4299
+ if (!this.isNavigating) {
4300
+ this.router.navigate(['.', {
4301
+ outlets: {
4302
+ [PlaceRouter.INTERACTION_ROUTER_OUTLET]: null
4303
+ }
4304
+ }], {
4305
+ replaceUrl: true // remove the interaction from the history.
4306
+ });
4307
+ }
3905
4308
  }
3906
4309
  }
3907
- __decorate([
3908
- Trace(),
3909
- __metadata("design:type", Function),
3910
- __metadata("design:paramtypes", [Visit]),
3911
- __metadata("design:returntype", Array)
3912
- ], UrlHelper.prototype, "createRedirectCommandsFor", null);
3913
- PlaceRouter.UrlHelper = UrlHelper;
4310
+ PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
3914
4311
  if (false) {
3915
- /**
3916
- * @type {?}
3917
- * @private
3918
- */
3919
- UrlHelper.prototype.urlTree;
4312
+ /** @type {?} */
4313
+ InteractionRouteMediator.prototype.navigationSessionModelActive;
4314
+ /** @type {?} */
4315
+ InteractionRouteMediator.prototype.router;
3920
4316
  }
3921
4317
  })(PlaceRouter || (PlaceRouter = {}));
3922
4318
 
@@ -4011,7 +4407,6 @@ class PlaceOutletComponent extends DisposableComponent {
4011
4407
  this.placeConfig = placeConfig;
4012
4408
  this.placeChanged = new EventEmitter();
4013
4409
  this._activePlace = new MutableValueModel();
4014
- this._previousPlace = new MutableValueModel();
4015
4410
  this._activePlaceVisitModel = new DelegatingValueModel();
4016
4411
  this._inOutletActivation = new Guard$1();
4017
4412
  this._inOutletDeactivation = new Guard$1();
@@ -4033,32 +4428,12 @@ class PlaceOutletComponent extends DisposableComponent {
4033
4428
  .pluck('placeDefinition')
4034
4429
  .pluckList('children')
4035
4430
  .pluck('component');
4036
- // TODO: This is a hack to prevent animation during the NoopGatewayPlace
4037
- /** @type {?} */
4038
- const activePlaceType = chain(this._activePlace).map((/**
4039
- * @param {?} p
4040
- * @return {?}
4041
- */
4042
- p => {
4043
- return (/** @type {?} */ (p.constructor));
4044
- }), {
4045
- postponeWhile: chain(this.activePlaceModel).isNil()
4046
- });
4047
4431
  /** @type {?} */
4048
- const previousPlaceType = chain(this._previousPlace).map((/**
4432
+ const activatePlaceType = chain(this.activePlaceModel).map((/**
4049
4433
  * @param {?} p
4050
4434
  * @return {?}
4051
4435
  */
4052
4436
  p => (/** @type {?} */ (p.constructor))));
4053
- this.ready = chain.reduce(activePlaceType, previousPlaceType, (/**
4054
- * @param {?} current
4055
- * @param {?} previous
4056
- * @return {?}
4057
- */
4058
- (current, previous) => {
4059
- return !!current && current !== NoopGatewayPlace && previous !== NoopGatewayPlace;
4060
- }));
4061
- this.enableAnimation = valueOf.all(this.ready, this.animateModel).areTruthy();
4062
4437
  this.placeAnimationOrder = chain(this.customPlaceAnimationOrderModel)
4063
4438
  .otherwise(defaultPlaceAnimationOrder)
4064
4439
  .reduce((/**
@@ -4068,14 +4443,14 @@ class PlaceOutletComponent extends DisposableComponent {
4068
4443
  (placesInOrder) => {
4069
4444
  /** @type {?} */
4070
4445
  let placeIndex = 0;
4071
- if (activePlaceType.value) {
4072
- placeIndex = placesInOrder.indexOf(activePlaceType.value);
4073
- if (isNil(this.initialPlaceIndex && placeIndex >= 0)) {
4446
+ if (activatePlaceType.value) {
4447
+ placeIndex = placesInOrder.indexOf(activatePlaceType.value);
4448
+ if (isNil(this.initialPlaceIndex)) {
4074
4449
  this.initialPlaceIndex = placeIndex;
4075
4450
  }
4076
4451
  }
4077
4452
  return isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;
4078
- }), { dependsOn: activePlaceType });
4453
+ }), { dependsOn: activatePlaceType });
4079
4454
  // Push incoming changes into the component
4080
4455
  this.routerVisit = chain(this._activePlace).pluck('placeDefinition').findIn(placeRouter.activeVisitIndex);
4081
4456
  // Our router visit will change when our active is nullified during deactivation, which will push a null visit
@@ -4104,8 +4479,6 @@ class PlaceOutletComponent extends DisposableComponent {
4104
4479
  * @return {?}
4105
4480
  */
4106
4481
  place => this.placeChanged.emit(place)));
4107
- // const txo = new TransactionObserver().onEvent(e => console.log(e.toString()));
4108
- // txo.observe('inRouteVisitUpdate', inRouteVisitUpdate);
4109
4482
  }
4110
4483
  /**
4111
4484
  * @return {?}
@@ -4210,7 +4583,7 @@ class PlaceOutletComponent extends DisposableComponent {
4210
4583
  console.error(error);
4211
4584
  }
4212
4585
  }));
4213
- if (!this.enableAnimation.value) {
4586
+ if (!this.animateModel.value) {
4214
4587
  // we're not animating so trigger any post animation callbacks now.
4215
4588
  this.animationDone();
4216
4589
  }
@@ -4224,7 +4597,6 @@ class PlaceOutletComponent extends DisposableComponent {
4224
4597
  * @return {?}
4225
4598
  */
4226
4599
  () => {
4227
- this._previousPlace.value = this._activePlace.value;
4228
4600
  this._activePlace.value = null;
4229
4601
  this._activatedRouteModel.value = null;
4230
4602
  this._placeDefinition.value = null;
@@ -4251,7 +4623,7 @@ class PlaceOutletComponent extends DisposableComponent {
4251
4623
  PlaceOutletComponent.decorators = [
4252
4624
  { type: Component, args: [{
4253
4625
  selector: 'aup-place-outlet',
4254
- template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n [@.disabled]=\"!enableAnimation.value\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n</div>\n\n",
4626
+ template: "<div class=\"router-outlet-container\"\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n [@.disabled]=\"!animateModel.value\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n</div>\n\n",
4255
4627
  animations: [LEFT_RIGHT_PLACE_ANIMATION],
4256
4628
  styles: [":host{display:flex;flex-direction:column;min-height:0;overflow-x:hidden}.router-outlet-container{flex:1;display:block;position:relative;min-height:0}router-outlet{display:none}"]
4257
4629
  }] }
@@ -4265,7 +4637,7 @@ PlaceOutletComponent.ctorParameters = () => [
4265
4637
  ];
4266
4638
  PlaceOutletComponent.propDecorators = {
4267
4639
  animate: [{ type: Input }],
4268
- animateModel: [{ type: Input, args: ['animateModel',] }],
4640
+ animateModel: [{ type: Input }],
4269
4641
  customPlaceAnimationOrderModel: [{ type: Input, args: ['placeAnimationOrderModel',] }],
4270
4642
  customPlaceAnimationOrder: [{ type: Input, args: ['placeAnimationOrder',] }],
4271
4643
  placeChanged: [{ type: Output }],
@@ -4305,11 +4677,6 @@ if (false) {
4305
4677
  * @private
4306
4678
  */
4307
4679
  PlaceOutletComponent.prototype._activePlace;
4308
- /**
4309
- * @type {?}
4310
- * @private
4311
- */
4312
- PlaceOutletComponent.prototype._previousPlace;
4313
4680
  /**
4314
4681
  * @type {?}
4315
4682
  * @private
@@ -4362,10 +4729,6 @@ if (false) {
4362
4729
  * @private
4363
4730
  */
4364
4731
  PlaceOutletComponent.prototype.routerVisit;
4365
- /** @type {?} */
4366
- PlaceOutletComponent.prototype.ready;
4367
- /** @type {?} */
4368
- PlaceOutletComponent.prototype.enableAnimation;
4369
4732
  /**
4370
4733
  * @type {?}
4371
4734
  * @private
@@ -4650,8 +5013,7 @@ PlaceModule.decorators = [
4650
5013
  PlaceOutletComponent,
4651
5014
  TabbedPlaceNavigationComponent,
4652
5015
  ListPlaceNavComponent,
4653
- AbstractPlaceNavigationComponent,
4654
- NoopGatewayPlace
5016
+ AbstractPlaceNavigationComponent
4655
5017
  ],
4656
5018
  entryComponents: [BusyOverlayComponent],
4657
5019
  exports: [
@@ -5031,82 +5393,6 @@ if (false) {
5031
5393
  ActivityOutletContext.prototype.componentReady = function (component) { };
5032
5394
  }
5033
5395
 
5034
- /**
5035
- * @fileoverview added by tsickle
5036
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5037
- */
5038
- class InteractionGuard {
5039
- /**
5040
- * @param {?} router
5041
- * @param {?} injector
5042
- * @param {?} interactionContext
5043
- */
5044
- constructor(router, injector, interactionContext) {
5045
- this.router = router;
5046
- this.injector = injector;
5047
- this.interactionContext = interactionContext;
5048
- }
5049
- /**
5050
- * @param {?} route
5051
- * @param {?} state
5052
- * @return {?}
5053
- */
5054
- canActivate(route, state) {
5055
- return true;
5056
- }
5057
- /**
5058
- * @param {?} component
5059
- * @param {?} currentRoute
5060
- * @param {?} currentState
5061
- * @param {?=} nextState
5062
- * @return {?}
5063
- */
5064
- canDeactivate(component, currentRoute, currentState, nextState) {
5065
- return !this.interactionContext.isActive();
5066
- }
5067
- }
5068
- InteractionGuard.decorators = [
5069
- { type: Injectable, args: [{
5070
- providedIn: 'root'
5071
- },] }
5072
- ];
5073
- /** @nocollapse */
5074
- InteractionGuard.ctorParameters = () => [
5075
- { type: Router },
5076
- { type: Injector },
5077
- { type: InteractionContext }
5078
- ];
5079
- /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(InteractionContext)); }, token: InteractionGuard, providedIn: "root" });
5080
- __decorate([
5081
- Trace(),
5082
- __metadata("design:type", Function),
5083
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
5084
- __metadata("design:returntype", Object)
5085
- ], InteractionGuard.prototype, "canActivate", null);
5086
- __decorate([
5087
- Trace(),
5088
- __metadata("design:type", Function),
5089
- __metadata("design:paramtypes", [NoopComponent, ActivatedRouteSnapshot, RouterStateSnapshot, RouterStateSnapshot]),
5090
- __metadata("design:returntype", Object)
5091
- ], InteractionGuard.prototype, "canDeactivate", null);
5092
- if (false) {
5093
- /**
5094
- * @type {?}
5095
- * @private
5096
- */
5097
- InteractionGuard.prototype.router;
5098
- /**
5099
- * @type {?}
5100
- * @private
5101
- */
5102
- InteractionGuard.prototype.injector;
5103
- /**
5104
- * @type {?}
5105
- * @private
5106
- */
5107
- InteractionGuard.prototype.interactionContext;
5108
- }
5109
-
5110
5396
  /**
5111
5397
  * @fileoverview added by tsickle
5112
5398
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -5130,10 +5416,56 @@ if (false) {
5130
5416
  */
5131
5417
  NavItem.prototype.icon = function () { };
5132
5418
  /**
5133
- * @return {?}
5419
+ * @return {?}
5420
+ */
5421
+ NavItem.prototype.tooltip = function () { };
5422
+ }
5423
+
5424
+ /**
5425
+ * @fileoverview added by tsickle
5426
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5427
+ */
5428
+ /**
5429
+ * @param {?} options
5430
+ * @return {?}
5431
+ */
5432
+ function Place(options) {
5433
+ return (/**
5434
+ * @param {?} target
5435
+ * @return {?}
5436
+ */
5437
+ (target) => {
5438
+ if (PlaceComponent.isPlaceComponentConstructor(target)) {
5439
+ PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? false : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
5440
+ * @param {?} c
5441
+ * @return {?}
5442
+ */
5443
+ c => PlaceComponent.getDefinition(c)))));
5444
+ }
5445
+ else {
5446
+ lang.illegalState(`${target} must extend PlaceComponent to use the @Place decorator`);
5447
+ }
5448
+ });
5449
+ }
5450
+ (function (Place) {
5451
+ /**
5452
+ * @record
5134
5453
  */
5135
- NavItem.prototype.tooltip = function () { };
5136
- }
5454
+ function Options() { }
5455
+ Place.Options = Options;
5456
+ if (false) {
5457
+ /** @type {?} */
5458
+ Options.prototype.path;
5459
+ /** @type {?|undefined} */
5460
+ Options.prototype.data;
5461
+ /** @type {?|undefined} */
5462
+ Options.prototype.authenticate;
5463
+ /** @type {?|undefined} */
5464
+ Options.prototype.children;
5465
+ /** @type {?|undefined} */
5466
+ Options.prototype.defaultChild;
5467
+ }
5468
+ })(Place || (Place = {}));
5137
5469
 
5138
5470
  /**
5139
5471
  * @fileoverview added by tsickle
@@ -5168,7 +5500,7 @@ class VisitSanitiser {
5168
5500
  const routeId = visit.getRouteId();
5169
5501
  /** @type {?} */
5170
5502
  const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector);
5171
- console.log({ routeId, sanitisedValue });
5503
+ // console.log({routeId, sanitisedValue});
5172
5504
  // ###------- EARLY EXIT --------###
5173
5505
  if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
5174
5506
  // if the route id has changed we redirect immediately as other
@@ -5222,6 +5554,137 @@ if (false) {
5222
5554
  VisitSanitiser.prototype.injector;
5223
5555
  }
5224
5556
 
5557
+ /**
5558
+ * @fileoverview added by tsickle
5559
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5560
+ */
5561
+ /**
5562
+ * This a work around for the fact that an activated route with multiple segments doesn't
5563
+ * include the segment params in the paramMap as well as each segment returns an empty
5564
+ * param map even when `parameter`s has content.
5565
+ */
5566
+ class ConsolidatedParameterMap {
5567
+ /**
5568
+ * @param {?} paramMap
5569
+ * @param {?} urlSegments
5570
+ */
5571
+ constructor(paramMap, urlSegments) {
5572
+ this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
5573
+ * @param {?} s
5574
+ * @return {?}
5575
+ */
5576
+ s => new ParamMapAdapter(s.parameters)))).filter((/**
5577
+ * @param {?} m
5578
+ * @return {?}
5579
+ */
5580
+ m => !!m)); // the activated route param map can be null
5581
+ }
5582
+ /**
5583
+ * @param {?} name
5584
+ * @return {?}
5585
+ */
5586
+ get(name) {
5587
+ /** @type {?} */
5588
+ const paramMap = this.paramMaps.find((/**
5589
+ * @param {?} m
5590
+ * @return {?}
5591
+ */
5592
+ m => m.has(name)));
5593
+ return paramMap.get(name);
5594
+ }
5595
+ /**
5596
+ * @param {?} name
5597
+ * @return {?}
5598
+ */
5599
+ getAll(name) {
5600
+ /** @type {?} */
5601
+ const paramMap = this.paramMaps.find((/**
5602
+ * @param {?} m
5603
+ * @return {?}
5604
+ */
5605
+ m => m.has(name)));
5606
+ return paramMap.getAll(name);
5607
+ }
5608
+ /**
5609
+ * @param {?} name
5610
+ * @return {?}
5611
+ */
5612
+ has(name) {
5613
+ return !!this.paramMaps.find((/**
5614
+ * @param {?} m
5615
+ * @return {?}
5616
+ */
5617
+ m => m.has(name)));
5618
+ }
5619
+ /**
5620
+ * @return {?}
5621
+ */
5622
+ get keys() {
5623
+ return this.paramMaps.reduce((/**
5624
+ * @param {?} result
5625
+ * @param {?} params
5626
+ * @return {?}
5627
+ */
5628
+ (result, params) => result.concat(params.keys)), []);
5629
+ }
5630
+ }
5631
+ __decorate([
5632
+ Memoize(),
5633
+ __metadata("design:type", Array),
5634
+ __metadata("design:paramtypes", [])
5635
+ ], ConsolidatedParameterMap.prototype, "keys", null);
5636
+ if (false) {
5637
+ /**
5638
+ * @type {?}
5639
+ * @private
5640
+ */
5641
+ ConsolidatedParameterMap.prototype.paramMaps;
5642
+ }
5643
+ class ParamMapAdapter {
5644
+ /**
5645
+ * @param {?} params
5646
+ */
5647
+ constructor(params) {
5648
+ this.params = params;
5649
+ }
5650
+ /**
5651
+ * @param {?} name
5652
+ * @return {?}
5653
+ */
5654
+ get(name) {
5655
+ return this.params[name];
5656
+ }
5657
+ /**
5658
+ * @param {?} name
5659
+ * @return {?}
5660
+ */
5661
+ getAll(name) {
5662
+ /** @type {?} */
5663
+ const value = this.get(name);
5664
+ return Array.isArray(value) ? value : [value];
5665
+ }
5666
+ /**
5667
+ * @param {?} name
5668
+ * @return {?}
5669
+ */
5670
+ has(name) {
5671
+ return this.keys.includes(name);
5672
+ }
5673
+ /**
5674
+ * @return {?}
5675
+ */
5676
+ get keys() {
5677
+ return Object.keys(this.params);
5678
+ }
5679
+ }
5680
+ if (false) {
5681
+ /**
5682
+ * @type {?}
5683
+ * @private
5684
+ */
5685
+ ParamMapAdapter.prototype.params;
5686
+ }
5687
+
5225
5688
  /**
5226
5689
  * @fileoverview added by tsickle
5227
5690
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -5229,7 +5692,7 @@ if (false) {
5229
5692
  /**
5230
5693
  * @abstract
5231
5694
  */
5232
- class AbstractEnterPlaceGuard {
5695
+ class AbstractPlaceGuard {
5233
5696
  /**
5234
5697
  * @param {?} router
5235
5698
  * @param {?} urlSerializer
@@ -5252,45 +5715,53 @@ class AbstractEnterPlaceGuard {
5252
5715
  */
5253
5716
  canActivate(activatedRoute, state) {
5254
5717
  return __awaiter(this, void 0, void 0, function* () {
5255
- return this.interceptInitialRouteOtherwise(activatedRoute, state, (/**
5718
+ return this.authorisePlaceThen(activatedRoute, state, (/**
5719
+ * @param {?} placeDefinition
5256
5720
  * @return {?}
5257
5721
  */
5258
- () => {
5259
- return this.authorisePlaceThen(activatedRoute, state, (/**
5260
- * @param {?} placeDefinition
5261
- * @return {?}
5262
- */
5263
- (placeDefinition) => __awaiter(this, void 0, void 0, function* () {
5264
- // Parse our route params.
5265
- /** @type {?} */
5266
- const params = new AbstractEnterPlaceGuard.ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
5267
- /** @type {?} */
5268
- const parsedParams = placeDefinition.parseRouteParams(params);
5269
- /** @type {?} */
5270
- const initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
5271
- /** @type {?} */
5272
- const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
5722
+ (placeDefinition) => __awaiter(this, void 0, void 0, function* () {
5723
+ // Parse our route params.
5724
+ /** @type {?} */
5725
+ const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
5726
+ /** @type {?} */
5727
+ const parsedParams = placeDefinition.parseRouteParams(params);
5728
+ /** @type {?} */
5729
+ const initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
5730
+ /** @type {?} */
5731
+ const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
5732
+ /** @type {?} */
5733
+ const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
5734
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
5735
+ this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
5736
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
5737
+ // Regenerate the url
5273
5738
  /** @type {?} */
5274
- const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
5275
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
5276
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
5277
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
5278
- // Regenerate the url
5279
- /** @type {?} */
5280
- const commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
5281
- console.log('##### Place Guard Redirect', commands);
5282
- return this.router.createUrlTree(commands, {
5283
- replaceUrl: true,
5284
- skipLocationChange: false
5285
- });
5286
- }
5287
- else {
5288
- return true;
5289
- }
5290
- })));
5291
- }));
5739
+ const commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
5740
+ console.log('##### Place Guard Redirect', commands);
5741
+ return this.router.createUrlTree(commands, {
5742
+ replaceUrl: true,
5743
+ skipLocationChange: false
5744
+ });
5745
+ }
5746
+ else {
5747
+ return true;
5748
+ }
5749
+ })));
5750
+ });
5751
+ }
5752
+ /**
5753
+ * @param {?} component
5754
+ * @param {?} currentRoute
5755
+ * @param {?} currentState
5756
+ * @param {?=} nextState
5757
+ * @return {?}
5758
+ */
5759
+ canDeactivate(component, currentRoute, currentState, nextState) {
5760
+ return __awaiter(this, void 0, void 0, function* () {
5761
+ return this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState));
5292
5762
  });
5293
5763
  }
5764
+ // @Trace()
5294
5765
  /**
5295
5766
  * @protected
5296
5767
  * @param {?} activatedRoute
@@ -5309,7 +5780,7 @@ class AbstractEnterPlaceGuard {
5309
5780
  return canActivate(placeDefinition);
5310
5781
  }
5311
5782
  else {
5312
- console.log("not authorised result", authorised);
5783
+ console.log('not authorised result', authorised);
5313
5784
  return authorised;
5314
5785
  }
5315
5786
  }
@@ -5318,29 +5789,6 @@ class AbstractEnterPlaceGuard {
5318
5789
  }
5319
5790
  });
5320
5791
  }
5321
- /**
5322
- * @protected
5323
- * @param {?} activatedRoute
5324
- * @param {?} state
5325
- * @param {?} canActivate
5326
- * @return {?}
5327
- */
5328
- interceptInitialRouteOtherwise(activatedRoute, state, canActivate) {
5329
- return __awaiter(this, void 0, void 0, function* () {
5330
- // TODO: this all only sort of works. Opening dialogs and clicking back multiple times breaks things.
5331
- // TODO: next stage is to investigate tracking dialog state in a different placeoutlet and keeping those
5332
- // TODO: urls out of the history.
5333
- if (this.placeRouter.isInitialNavigation()) {
5334
- // This is the very first entry into our app so we redirect to a dummy place so we can get bump our
5335
- // history by one. This ensures that we can capture back button presses on the initial page without
5336
- // leaving our app.
5337
- return this.placeRouter.performInitialNavigationIntercept(activatedRoute, state);
5338
- }
5339
- else {
5340
- return canActivate();
5341
- }
5342
- });
5343
- }
5344
5792
  /**
5345
5793
  * @param {?} activatedRoute
5346
5794
  * @param {?} state
@@ -5351,194 +5799,85 @@ class AbstractEnterPlaceGuard {
5351
5799
  /** @type {?} */
5352
5800
  const authorised = this.getAuthGuard(this.injector).canActivate(activatedRoute, state);
5353
5801
  return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
5354
- });
5355
- }
5356
- }
5357
- __decorate([
5358
- Trace(),
5359
- __metadata("design:type", Function),
5360
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot, Function]),
5361
- __metadata("design:returntype", Promise)
5362
- ], AbstractEnterPlaceGuard.prototype, "authorisePlaceThen", null);
5363
- __decorate([
5364
- Trace(),
5365
- __metadata("design:type", Function),
5366
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
5367
- __metadata("design:returntype", Promise)
5368
- ], AbstractEnterPlaceGuard.prototype, "isAuthorised", null);
5369
- if (false) {
5370
- /**
5371
- * @type {?}
5372
- * @private
5373
- */
5374
- AbstractEnterPlaceGuard.prototype.router;
5375
- /**
5376
- * @type {?}
5377
- * @private
5378
- */
5379
- AbstractEnterPlaceGuard.prototype.urlSerializer;
5380
- /**
5381
- * @type {?}
5382
- * @private
5383
- */
5384
- AbstractEnterPlaceGuard.prototype.placeRouter;
5385
- /**
5386
- * @type {?}
5387
- * @private
5388
- */
5389
- AbstractEnterPlaceGuard.prototype.placeHistory;
5390
- /**
5391
- * @type {?}
5392
- * @private
5393
- */
5394
- AbstractEnterPlaceGuard.prototype.injector;
5395
- /**
5396
- * @abstract
5397
- * @param {?} injector
5398
- * @return {?}
5399
- */
5400
- AbstractEnterPlaceGuard.prototype.getAuthGuard = function (injector) { };
5401
- }
5402
- (function (AbstractEnterPlaceGuard) {
5403
- /**
5404
- * This a work around for the fact that an activated route with multiple segments doesn't
5405
- * include the segment params in the paramMap as well as each segment returns an empty
5406
- * param map even when `parameter`s has content.
5407
- */
5408
- class ConsolidatedParameterMap {
5409
- /**
5410
- * @param {?} paramMap
5411
- * @param {?} urlSegments
5412
- */
5413
- constructor(paramMap, urlSegments) {
5414
- this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
5415
- * @param {?} s
5416
- * @return {?}
5417
- */
5418
- s => new ParamMapAdapter(s.parameters)))).filter((/**
5419
- * @param {?} m
5420
- * @return {?}
5421
- */
5422
- m => !!m)); // the activated route param map can be null
5423
- }
5424
- /**
5425
- * @param {?} name
5426
- * @return {?}
5427
- */
5428
- get(name) {
5429
- /** @type {?} */
5430
- const paramMap = this.paramMaps.find((/**
5431
- * @param {?} m
5432
- * @return {?}
5433
- */
5434
- m => m.has(name)));
5435
- return paramMap.get(name);
5436
- }
5437
- /**
5438
- * @param {?} name
5439
- * @return {?}
5440
- */
5441
- getAll(name) {
5442
- /** @type {?} */
5443
- const paramMap = this.paramMaps.find((/**
5444
- * @param {?} m
5445
- * @return {?}
5446
- */
5447
- m => m.has(name)));
5448
- return paramMap.getAll(name);
5449
- }
5450
- /**
5451
- * @param {?} name
5452
- * @return {?}
5453
- */
5454
- has(name) {
5455
- return !!this.paramMaps.find((/**
5456
- * @param {?} m
5457
- * @return {?}
5458
- */
5459
- m => m.has(name)));
5460
- }
5461
- /**
5462
- * @return {?}
5463
- */
5464
- get keys() {
5465
- return this.paramMaps.reduce((/**
5466
- * @param {?} result
5467
- * @param {?} params
5468
- * @return {?}
5469
- */
5470
- (result, params) => result.concat(params.keys)), []);
5471
- }
5472
- }
5473
- __decorate([
5474
- Memoize(),
5475
- __metadata("design:type", Array),
5476
- __metadata("design:paramtypes", [])
5477
- ], ConsolidatedParameterMap.prototype, "keys", null);
5478
- AbstractEnterPlaceGuard.ConsolidatedParameterMap = ConsolidatedParameterMap;
5479
- if (false) {
5480
- /**
5481
- * @type {?}
5482
- * @private
5483
- */
5484
- ConsolidatedParameterMap.prototype.paramMaps;
5485
- }
5486
- class ParamMapAdapter {
5487
- /**
5488
- * @param {?} params
5489
- */
5490
- constructor(params) {
5491
- this.params = params;
5492
- }
5493
- /**
5494
- * @param {?} name
5495
- * @return {?}
5496
- */
5497
- get(name) {
5498
- return this.params[name];
5499
- }
5500
- /**
5501
- * @param {?} name
5502
- * @return {?}
5503
- */
5504
- getAll(name) {
5505
- /** @type {?} */
5506
- const value = this.get(name);
5507
- return Array.isArray(value) ? value : [value];
5508
- }
5509
- /**
5510
- * @param {?} name
5511
- * @return {?}
5512
- */
5513
- has(name) {
5514
- return this.keys.includes(name);
5515
- }
5516
- /**
5517
- * @return {?}
5518
- */
5519
- get keys() {
5520
- return Object.keys(this.params);
5521
- }
5522
- }
5523
- if (false) {
5524
- /**
5525
- * @type {?}
5526
- * @private
5527
- */
5528
- ParamMapAdapter.prototype.params;
5802
+ });
5529
5803
  }
5530
- })(AbstractEnterPlaceGuard || (AbstractEnterPlaceGuard = {}));
5804
+ }
5805
+ __decorate([
5806
+ Trace(),
5807
+ __metadata("design:type", Function),
5808
+ __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
5809
+ __metadata("design:returntype", Promise)
5810
+ ], AbstractPlaceGuard.prototype, "isAuthorised", null);
5811
+ if (false) {
5812
+ /**
5813
+ * @type {?}
5814
+ * @private
5815
+ */
5816
+ AbstractPlaceGuard.prototype.router;
5817
+ /**
5818
+ * @type {?}
5819
+ * @private
5820
+ */
5821
+ AbstractPlaceGuard.prototype.urlSerializer;
5822
+ /**
5823
+ * @type {?}
5824
+ * @private
5825
+ */
5826
+ AbstractPlaceGuard.prototype.placeRouter;
5827
+ /**
5828
+ * @type {?}
5829
+ * @private
5830
+ */
5831
+ AbstractPlaceGuard.prototype.placeHistory;
5832
+ /**
5833
+ * @type {?}
5834
+ * @private
5835
+ */
5836
+ AbstractPlaceGuard.prototype.injector;
5837
+ /**
5838
+ * @abstract
5839
+ * @param {?} injector
5840
+ * @return {?}
5841
+ */
5842
+ AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
5843
+ }
5531
5844
 
5532
5845
  /**
5533
5846
  * @fileoverview added by tsickle
5534
5847
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5535
5848
  */
5536
- class LeavePlaceGuard {
5849
+ class InteractionGuard {
5537
5850
  /**
5851
+ * @param {?} router
5852
+ * @param {?} injector
5538
5853
  * @param {?} placeRouter
5854
+ * @param {?} angularLocation
5855
+ * @param {?} modalInteractionService
5539
5856
  */
5540
- constructor(placeRouter) {
5857
+ constructor(router, injector, placeRouter, angularLocation, modalInteractionService) {
5858
+ this.router = router;
5859
+ this.injector = injector;
5541
5860
  this.placeRouter = placeRouter;
5861
+ this.angularLocation = angularLocation;
5862
+ this.modalInteractionService = modalInteractionService;
5863
+ }
5864
+ /**
5865
+ * @param {?} route
5866
+ * @param {?} state
5867
+ * @return {?}
5868
+ */
5869
+ canActivate(route, state) {
5870
+ /** @type {?} */
5871
+ const url = this.router.parseUrl(state.url);
5872
+ if (!this.modalInteractionService.isActive() && url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET]) {
5873
+ // This happens if we reload the page or the url was pasted as the route should only be activated
5874
+ // after the interaction context has become active.
5875
+ delete url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET];
5876
+ return url;
5877
+ }
5878
+ else {
5879
+ return true;
5880
+ }
5542
5881
  }
5543
5882
  /**
5544
5883
  * @param {?} component
@@ -5549,26 +5888,60 @@ class LeavePlaceGuard {
5549
5888
  */
5550
5889
  canDeactivate(component, currentRoute, currentState, nextState) {
5551
5890
  return __awaiter(this, void 0, void 0, function* () {
5552
- return this.placeRouter.navigationSession.canDeactivate(component, this.placeRouter.parseUrl(nextState));
5891
+ /** @type {?} */
5892
+ const popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
5893
+ if (this.modalInteractionService.isActive()) {
5894
+ // The activity is still active so the route change was triggered by the back button.
5895
+ /** @type {?} */
5896
+ const activity = yield this.modalInteractionService.getCurrentActivity();
5897
+ activity.cancel();
5898
+ // See ModalInteractionSession#onStart() for the url updating.
5899
+ return false;
5900
+ }
5901
+ return true;
5553
5902
  });
5554
5903
  }
5555
5904
  }
5556
- LeavePlaceGuard.decorators = [
5905
+ InteractionGuard.decorators = [
5557
5906
  { type: Injectable, args: [{
5558
5907
  providedIn: 'root'
5559
5908
  },] }
5560
5909
  ];
5561
5910
  /** @nocollapse */
5562
- LeavePlaceGuard.ctorParameters = () => [
5563
- { type: PlaceRouter }
5911
+ InteractionGuard.ctorParameters = () => [
5912
+ { type: Router },
5913
+ { type: Injector },
5914
+ { type: PlaceRouter },
5915
+ { type: Location },
5916
+ { type: ModalInteractionService }
5564
5917
  ];
5565
- /** @nocollapse */ LeavePlaceGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function LeavePlaceGuard_Factory() { return new LeavePlaceGuard(ɵɵinject(PlaceRouter)); }, token: LeavePlaceGuard, providedIn: "root" });
5918
+ /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(ModalInteractionService)); }, token: InteractionGuard, providedIn: "root" });
5566
5919
  if (false) {
5567
5920
  /**
5568
5921
  * @type {?}
5569
5922
  * @private
5570
5923
  */
5571
- LeavePlaceGuard.prototype.placeRouter;
5924
+ InteractionGuard.prototype.router;
5925
+ /**
5926
+ * @type {?}
5927
+ * @private
5928
+ */
5929
+ InteractionGuard.prototype.injector;
5930
+ /**
5931
+ * @type {?}
5932
+ * @private
5933
+ */
5934
+ InteractionGuard.prototype.placeRouter;
5935
+ /**
5936
+ * @type {?}
5937
+ * @private
5938
+ */
5939
+ InteractionGuard.prototype.angularLocation;
5940
+ /**
5941
+ * @type {?}
5942
+ * @private
5943
+ */
5944
+ InteractionGuard.prototype.modalInteractionService;
5572
5945
  }
5573
5946
 
5574
5947
  /**
@@ -5598,6 +5971,68 @@ NoopAuthGuard.decorators = [
5598
5971
  NoopAuthGuard.ctorParameters = () => [];
5599
5972
  /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
5600
5973
 
5974
+ /**
5975
+ * @fileoverview added by tsickle
5976
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5977
+ */
5978
+ // WARNING: interface has both a type and a value, skipping emit
5979
+ var Formatter;
5980
+ (function (Formatter) {
5981
+ class StringType {
5982
+ /**
5983
+ * @param {?} value
5984
+ * @return {?}
5985
+ */
5986
+ format(value) {
5987
+ return value;
5988
+ }
5989
+ /**
5990
+ * @param {?} value
5991
+ * @return {?}
5992
+ */
5993
+ parse(value) {
5994
+ return value;
5995
+ }
5996
+ }
5997
+ class NumberType {
5998
+ /**
5999
+ * @param {?} value
6000
+ * @return {?}
6001
+ */
6002
+ format(value) {
6003
+ return ___default.isNumber(value) && !___default.isNaN(value) ? `${value}` : null;
6004
+ }
6005
+ /**
6006
+ * @param {?} value
6007
+ * @return {?}
6008
+ */
6009
+ parse(value) {
6010
+ /** @type {?} */
6011
+ const parsed = Number.parseFloat(value);
6012
+ return ___default.isNaN(parsed) ? null : parsed;
6013
+ }
6014
+ }
6015
+ class BooleanType {
6016
+ /**
6017
+ * @param {?} value
6018
+ * @return {?}
6019
+ */
6020
+ format(value) {
6021
+ return value ? 'true' : 'false';
6022
+ }
6023
+ /**
6024
+ * @param {?} value
6025
+ * @return {?}
6026
+ */
6027
+ parse(value) {
6028
+ return value === 'true';
6029
+ }
6030
+ }
6031
+ Formatter.STRING = new StringType();
6032
+ Formatter.NUMBER = new NumberType();
6033
+ Formatter.BOOLEAN = new BooleanType();
6034
+ })(Formatter || (Formatter = {}));
6035
+
5601
6036
  /**
5602
6037
  * @fileoverview added by tsickle
5603
6038
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -5611,6 +6046,119 @@ function JsonArray() { }
5611
6046
  */
5612
6047
  function JsonMap() { }
5613
6048
 
6049
+ /**
6050
+ * @fileoverview added by tsickle
6051
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6052
+ */
6053
+ /**
6054
+ * @record
6055
+ * @template T
6056
+ */
6057
+ function RouteIdOptions() { }
6058
+ if (false) {
6059
+ /** @type {?|undefined} */
6060
+ RouteIdOptions.prototype.as;
6061
+ /** @type {?|undefined} */
6062
+ RouteIdOptions.prototype.optional;
6063
+ /** @type {?|undefined} */
6064
+ RouteIdOptions.prototype.remember;
6065
+ /** @type {?|undefined} */
6066
+ RouteIdOptions.prototype.defaultValue;
6067
+ }
6068
+ /**
6069
+ * @record
6070
+ * @template T
6071
+ */
6072
+ function RouteParameterOptions() { }
6073
+ if (false) {
6074
+ /** @type {?|undefined} */
6075
+ RouteParameterOptions.prototype.as;
6076
+ /** @type {?|undefined} */
6077
+ RouteParameterOptions.prototype.optional;
6078
+ /** @type {?|undefined} */
6079
+ RouteParameterOptions.prototype.remember;
6080
+ /** @type {?|undefined} */
6081
+ RouteParameterOptions.prototype.defaultValue;
6082
+ /** @type {?|undefined} */
6083
+ RouteParameterOptions.prototype.storeInUrl;
6084
+ }
6085
+ /**
6086
+ * @record
6087
+ * @template T
6088
+ */
6089
+ function RouteListParameterOptions() { }
6090
+ if (false) {
6091
+ /** @type {?|undefined} */
6092
+ RouteListParameterOptions.prototype.as;
6093
+ /** @type {?|undefined} */
6094
+ RouteListParameterOptions.prototype.optional;
6095
+ /** @type {?|undefined} */
6096
+ RouteListParameterOptions.prototype.remember;
6097
+ /** @type {?|undefined} */
6098
+ RouteListParameterOptions.prototype.defaultValue;
6099
+ /** @type {?|undefined} */
6100
+ RouteListParameterOptions.prototype.storeInUrl;
6101
+ }
6102
+ /**
6103
+ * @template T
6104
+ * @param {?} type
6105
+ * @param {?=} options
6106
+ * @return {?}
6107
+ */
6108
+ function RouteId(type, options) {
6109
+ return (/**
6110
+ * @param {?} prototype
6111
+ * @param {?} propertyKey
6112
+ * @return {?}
6113
+ */
6114
+ (prototype, propertyKey) => {
6115
+ /** @type {?} */
6116
+ const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
6117
+ Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6118
+ UseDelegate()(prototype, propertyKey);
6119
+ });
6120
+ }
6121
+ /**
6122
+ * @template T
6123
+ * @param {?=} options
6124
+ * @return {?}
6125
+ */
6126
+ function VisitParameter(options) {
6127
+ /** @type {?} */
6128
+ const opts = Opts.get(options);
6129
+ return (/**
6130
+ * @param {?} prototype
6131
+ * @param {?} propertyKey
6132
+ * @return {?}
6133
+ */
6134
+ (prototype, propertyKey) => {
6135
+ /** @type {?} */
6136
+ const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6137
+ Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6138
+ UseDelegate()(prototype, propertyKey);
6139
+ });
6140
+ }
6141
+ /**
6142
+ * @template E
6143
+ * @param {?=} options
6144
+ * @return {?}
6145
+ */
6146
+ function VisitParameterList(options) {
6147
+ /** @type {?} */
6148
+ const opts = Opts.get(options);
6149
+ return (/**
6150
+ * @param {?} prototype
6151
+ * @param {?} propertyKey
6152
+ * @return {?}
6153
+ */
6154
+ (prototype, propertyKey) => {
6155
+ /** @type {?} */
6156
+ const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6157
+ Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6158
+ UseDelegate()(prototype, propertyKey);
6159
+ });
6160
+ }
6161
+
5614
6162
  /**
5615
6163
  * @fileoverview added by tsickle
5616
6164
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -5670,5 +6218,5 @@ if (false) {
5670
6218
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5671
6219
  */
5672
6220
 
5673
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractEnterPlaceGuard, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, LeavePlaceGuard, ListPlaceNavComponent, NavigationSession, NoopAuthGuard, NoopComponent, NoopGatewayPlace, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, PlaceComponent as ɵba, Place as ɵbb, VisitParameter as ɵbc, Formatter as ɵbd, InteractionModule as ɵbe, ActivityContainerComponent as ɵbf, ActivityOutletComponent as ɵbg, ConfirmationDialogComponent as ɵbh, AbstractActivity as ɵbi, ACTIVITY_DATA as ɵbj, Activity as ɵbk, ConfirmThenDialogComponent as ɵbm, AlertDialogComponent as ɵbn, InteractionOutletComponent as ɵbp, InplaceInteractionContextComponent as ɵbq, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbr, DialogInteractionService as ɵbs, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, InteractionContext as ɵu, PlaceHistory as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, NoopGatewayPlace as ɵz };
6221
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionService, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, ActivityContainerComponent as ɵba, InteractionContextBase as ɵbb, InteractionContext as ɵbc, ActivityOutletComponent as ɵbd, ConfirmationDialogComponent as ɵbe, AbstractActivity as ɵbf, ACTIVITY_DATA as ɵbg, Activity as ɵbh, ConfirmThenDialogComponent as ɵbj, AlertDialogComponent as ɵbk, InteractionOutletComponent as ɵbm, InplaceInteractionContextComponent as ɵbn, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbo, DialogInteractionService as ɵbp, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, ModalInteractionService as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, InteractionModule as ɵz };
5674
6222
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map