@coolon/angular-ui-powerups 0.0.98 → 0.0.102

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 (83) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +2036 -1518
  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 +19 -19
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +19 -19
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +20 -5
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +13 -3
  11. package/esm2015/lib/interaction/index.js +5 -4
  12. package/esm2015/lib/interaction/interaction-context-base.js +21 -8
  13. package/esm2015/lib/interaction/interaction-context.js +53 -46
  14. package/esm2015/lib/interaction/interaction.module.js +3 -3
  15. package/esm2015/lib/interaction/services/interaction.service.js +232 -0
  16. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +62 -0
  17. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +145 -0
  18. package/esm2015/lib/interaction/services/modal-interaction-context.factory.js +17 -0
  19. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  20. package/esm2015/lib/place/guards/navigation-state.js +406 -262
  21. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
  22. package/esm2015/lib/place/guards/place.guard.js +215 -0
  23. package/esm2015/lib/place/index.js +2 -3
  24. package/esm2015/lib/place/place-router.js +161 -118
  25. package/esm2015/lib/place/url-snapshot.js +124 -36
  26. package/esm2015/public_api.js +3 -3
  27. package/esm5/coolon-angular-ui-powerups.js +19 -19
  28. package/esm5/index.js +2 -2
  29. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +24 -14
  30. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +10 -3
  31. package/esm5/lib/interaction/index.js +5 -4
  32. package/esm5/lib/interaction/interaction-context-base.js +25 -8
  33. package/esm5/lib/interaction/interaction-context.js +81 -56
  34. package/esm5/lib/interaction/interaction.module.js +3 -3
  35. package/esm5/lib/interaction/services/interaction.service.js +280 -0
  36. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +65 -0
  37. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +170 -0
  38. package/esm5/lib/interaction/services/modal-interaction-context.factory.js +27 -0
  39. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  40. package/esm5/lib/place/guards/navigation-state.js +552 -304
  41. package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
  42. package/esm5/lib/place/guards/place.guard.js +300 -0
  43. package/esm5/lib/place/index.js +2 -3
  44. package/esm5/lib/place/place-router.js +199 -137
  45. package/esm5/lib/place/url-snapshot.js +153 -42
  46. package/esm5/public_api.js +3 -3
  47. package/fesm2015/coolon-angular-ui-powerups.js +1636 -1300
  48. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  49. package/fesm5/coolon-angular-ui-powerups.js +1985 -1466
  50. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  51. package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -0
  52. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -1
  53. package/lib/interaction/index.d.ts +4 -3
  54. package/lib/interaction/interaction-context-base.d.ts +3 -1
  55. package/lib/interaction/interaction-context.d.ts +11 -13
  56. package/lib/interaction/services/interaction.service.d.ts +46 -0
  57. package/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.d.ts +15 -0
  58. package/lib/interaction/services/{dialog-interaction-context.d.ts → mat-dialog-interaction/dialog-interaction-context.d.ts} +2 -2
  59. package/lib/interaction/services/modal-interaction-context.factory.d.ts +4 -0
  60. package/lib/place/guards/navigation-state.d.ts +83 -49
  61. package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
  62. package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +9 -4
  63. package/lib/place/index.d.ts +1 -2
  64. package/lib/place/place-router.d.ts +17 -22
  65. package/lib/place/url-snapshot.d.ts +23 -6
  66. package/package.json +1 -1
  67. package/schematics/place-routes/place-def.js +1 -0
  68. package/schematics/place-routes/place-def.js.map +1 -1
  69. package/schematics/place-routes/templates/place-routes.ts.template +10 -11
  70. package/styles/styles.scss +1 -1
  71. package/esm2015/lib/interaction/services/dialog-interaction-context.js +0 -163
  72. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -151
  73. package/esm2015/lib/interaction/services/modal-interaction.service.js +0 -109
  74. package/esm2015/lib/place/guards/abstract-place.guard.js +0 -165
  75. package/esm2015/lib/place/guards/interaction.guard.js +0 -113
  76. package/esm5/lib/interaction/services/dialog-interaction-context.js +0 -188
  77. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -179
  78. package/esm5/lib/interaction/services/modal-interaction.service.js +0 -153
  79. package/esm5/lib/place/guards/abstract-place.guard.js +0 -212
  80. package/esm5/lib/place/guards/interaction.guard.js +0 -125
  81. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -24
  82. package/lib/interaction/services/modal-interaction.service.d.ts +0 -15
  83. package/lib/place/guards/interaction.guard.d.ts +0 -17
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('lodash'), require('@coolon/typescript-utilities'), require('@angular/material/dialog'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('@angular/animations'), require('resize-observer-polyfill'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', 'lodash', '@coolon/typescript-utilities', '@angular/material/dialog', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', '@angular/animations', 'resize-observer-polyfill', 'rxjs'], factory) :
4
- (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.___default, global.typescriptUtilities, global.ng.material.dialog, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.ng.animations, global.ResizeObserver, global.rxjs));
5
- }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, ___default, typescriptUtilities, dialog, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, animations$1, ResizeObserver, rxjs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('@coolon/typescript-utilities'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill'), require('@angular/material/dialog'), require('rxjs')) :
3
+ typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', '@coolon/typescript-utilities', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill', '@angular/material/dialog', 'rxjs'], factory) :
4
+ (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.typescriptUtilities, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver, global.ng.material.dialog, global.rxjs));
5
+ }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, typescriptUtilities, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver, dialog, rxjs) { 'use strict';
6
6
 
7
7
  var ___default__default = 'default' in ___default ? ___default['default'] : ___default;
8
8
  ResizeObserver = ResizeObserver && ResizeObserver.hasOwnProperty('default') ? ResizeObserver['default'] : ResizeObserver;
@@ -1105,7 +1105,7 @@
1105
1105
  * @abstract
1106
1106
  * @template D, R, E
1107
1107
  */
1108
- exports.ɵbh = /** @class */ (function (_super) {
1108
+ exports.ɵbi = /** @class */ (function (_super) {
1109
1109
  __extends(Activity, _super);
1110
1110
  function Activity() {
1111
1111
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -1195,12 +1195,12 @@
1195
1195
  * @type {?}
1196
1196
  * @private
1197
1197
  */
1198
- exports.ɵbh.prototype._busyModel;
1198
+ exports.ɵbi.prototype._busyModel;
1199
1199
  /**
1200
1200
  * @type {?}
1201
1201
  * @private
1202
1202
  */
1203
- exports.ɵbh.prototype._activityContext;
1203
+ exports.ɵbi.prototype._activityContext;
1204
1204
  }
1205
1205
  (function (Activity) {
1206
1206
  /**
@@ -1215,7 +1215,7 @@
1215
1215
  /** @type {?} */
1216
1216
  Callbacks.prototype.onCancel;
1217
1217
  }
1218
- })(exports.ɵbh || (exports.ɵbh = {}));
1218
+ })(exports.ɵbi || (exports.ɵbi = {}));
1219
1219
 
1220
1220
  /**
1221
1221
  * @fileoverview added by tsickle
@@ -1237,7 +1237,7 @@
1237
1237
  return _super !== null && _super.apply(this, arguments) || this;
1238
1238
  }
1239
1239
  return AbstractActivity;
1240
- }(exports.ɵbh));
1240
+ }(exports.ɵbi));
1241
1241
 
1242
1242
  /**
1243
1243
  * @fileoverview added by tsickle
@@ -1283,15 +1283,10 @@
1283
1283
  /**
1284
1284
  * @abstract
1285
1285
  */
1286
- /**
1287
- * @abstract
1288
- */
1289
- exports.ɵbc = /** @class */ (function (_super) {
1286
+ var InteractionContext = /** @class */ (function (_super) {
1290
1287
  __extends(InteractionContext, _super);
1291
1288
  function InteractionContext() {
1292
- var _this = _super !== null && _super.apply(this, arguments) || this;
1293
- _this.activityListeners = new pectin.EventListenerList();
1294
- return _this;
1289
+ return _super !== null && _super.apply(this, arguments) || this;
1295
1290
  }
1296
1291
  /**
1297
1292
  * Returns true if an activity is currently running.
@@ -1308,65 +1303,115 @@
1308
1303
  return this.active.value;
1309
1304
  };
1310
1305
  /**
1311
- * @param {?} listener
1312
1306
  * @return {?}
1313
1307
  */
1314
- InteractionContext.prototype.addActivityListener = /**
1315
- * @param {?} listener
1308
+ InteractionContext.prototype.dispose = /**
1316
1309
  * @return {?}
1317
1310
  */
1318
- function (listener) {
1319
- return this.activityListeners.add(listener);
1311
+ function () {
1312
+ // TODO: think about auto cancelling any outstanding activity on dispose.
1313
+ // See NavigationState.Navigating for a use-case.
1314
+ pectin.assert.isFalsey(this.isActive());
1315
+ _super.prototype.dispose.call(this);
1320
1316
  };
1321
1317
  /**
1322
- * @protected
1318
+ * Cancels the current activity and returns true the context is no longer active, false if
1319
+ * there is still another activity running.
1320
+ */
1321
+ /**
1322
+ * Cancels the current activity and returns true the context is no longer active, false if
1323
+ * there is still another activity running.
1323
1324
  * @return {?}
1324
1325
  */
1325
- InteractionContext.prototype.notifyActivityStarted = /**
1326
- * @protected
1326
+ InteractionContext.prototype.cancelCurrentActivity = /**
1327
+ * Cancels the current activity and returns true the context is no longer active, false if
1328
+ * there is still another activity running.
1327
1329
  * @return {?}
1328
1330
  */
1329
1331
  function () {
1330
- this.activityListeners.fire((/**
1331
- * @param {?} l
1332
- * @return {?}
1333
- */
1334
- function (l) { return l.onActivityStarted(); }));
1332
+ return __awaiter(this, void 0, void 0, function () {
1333
+ var when, activity;
1334
+ var _this = this;
1335
+ return __generator(this, function (_a) {
1336
+ switch (_a.label) {
1337
+ case 0:
1338
+ when = pectin.Dsl.disposeWith(this).when;
1339
+ return [4 /*yield*/, this.getCurrentActivity()];
1340
+ case 1:
1341
+ activity = _a.sent();
1342
+ return [2 /*return*/, new Promise((/**
1343
+ * @param {?} resolve
1344
+ * @return {?}
1345
+ */
1346
+ function (resolve) {
1347
+ when.valueOf(_this.activeActivity)
1348
+ .changes((/**
1349
+ * @param {?} nextActivity
1350
+ * @return {?}
1351
+ */
1352
+ function (nextActivity) {
1353
+ resolve(!nextActivity);
1354
+ }), { once: true });
1355
+ activity.cancel();
1356
+ }))];
1357
+ }
1358
+ });
1359
+ });
1335
1360
  };
1336
1361
  /**
1337
- * @protected
1338
1362
  * @return {?}
1339
1363
  */
1340
- InteractionContext.prototype.notifyActivityFinished = /**
1341
- * @protected
1364
+ InteractionContext.prototype.abort = /**
1342
1365
  * @return {?}
1343
1366
  */
1344
1367
  function () {
1345
- this.activityListeners.fire((/**
1346
- * @param {?} l
1347
- * @return {?}
1348
- */
1349
- function (l) { return l.onActivityFinished(); }));
1368
+ return __awaiter(this, void 0, void 0, function () {
1369
+ var count;
1370
+ return __generator(this, function (_a) {
1371
+ switch (_a.label) {
1372
+ case 0:
1373
+ pectin.assert.isTruthy(this.isActive());
1374
+ count = 1;
1375
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1376
+ case 1:
1377
+ _a.sent();
1378
+ console.log("aborted -> " + count++);
1379
+ _a.label = 2;
1380
+ case 2:
1381
+ if (!this.isActive()) return [3 /*break*/, 4];
1382
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1383
+ case 3:
1384
+ _a.sent();
1385
+ console.log("aborted -> " + count++);
1386
+ return [3 /*break*/, 2];
1387
+ case 4: return [2 /*return*/];
1388
+ }
1389
+ });
1390
+ });
1350
1391
  };
1392
+ __decorate([
1393
+ pectin.Trace(),
1394
+ __metadata("design:type", Function),
1395
+ __metadata("design:paramtypes", []),
1396
+ __metadata("design:returntype", Promise)
1397
+ ], InteractionContext.prototype, "abort", null);
1351
1398
  return InteractionContext;
1352
1399
  }(pectin.GarbageCollector));
1353
1400
  if (false) {
1354
- /**
1355
- * @type {?}
1356
- * @private
1357
- */
1358
- exports.ɵbc.prototype.activityListeners;
1359
1401
  /** @type {?} */
1360
- exports.ɵbc.prototype.activityList;
1402
+ InteractionContext.prototype.active;
1361
1403
  /** @type {?} */
1362
- exports.ɵbc.prototype.active;
1404
+ InteractionContext.prototype.activityList;
1405
+ /** @type {?} */
1406
+ InteractionContext.prototype.activeActivity;
1363
1407
  /**
1364
1408
  * Returns the activity that is currently active.
1365
1409
  * This model is only updated in the next tick after the view has been updated.
1366
1410
  * @abstract
1411
+ * @protected
1367
1412
  * @return {?}
1368
1413
  */
1369
- exports.ɵbc.prototype.getCurrentActivity = function () { };
1414
+ InteractionContext.prototype.getCurrentActivity = function () { };
1370
1415
  /**
1371
1416
  * @abstract
1372
1417
  * @template D, R, E
@@ -1374,25 +1419,25 @@
1374
1419
  * @param {?=} data
1375
1420
  * @return {?}
1376
1421
  */
1377
- exports.ɵbc.prototype.startActivity = function (activityType, data) { };
1422
+ InteractionContext.prototype.startActivity = function (activityType, data) { };
1378
1423
  /**
1379
1424
  * @abstract
1380
1425
  * @param {?} alert
1381
1426
  * @return {?}
1382
1427
  */
1383
- exports.ɵbc.prototype.alert = function (alert) { };
1428
+ InteractionContext.prototype.alert = function (alert) { };
1384
1429
  /**
1385
1430
  * @abstract
1386
1431
  * @param {?} confirm
1387
1432
  * @return {?}
1388
1433
  */
1389
- exports.ɵbc.prototype.confirm = function (confirm) { };
1434
+ InteractionContext.prototype.confirm = function (confirm) { };
1390
1435
  /**
1391
1436
  * @abstract
1392
1437
  * @param {?} confirm
1393
1438
  * @return {?}
1394
1439
  */
1395
- exports.ɵbc.prototype.confirmOrReject = function (confirm) { };
1440
+ InteractionContext.prototype.confirmOrReject = function (confirm) { };
1396
1441
  /**
1397
1442
  * Presents the confirmation to the user and runs the activity only if the user confirms.
1398
1443
  * @abstract
@@ -1402,25 +1447,8 @@
1402
1447
  * @param {?=} data the activity data.
1403
1448
  * @return {?}
1404
1449
  */
1405
- exports.ɵbc.prototype.confirmThen = function (confirm, activityType, data) { };
1450
+ InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
1406
1451
  }
1407
- (function (InteractionContext) {
1408
- /**
1409
- * @record
1410
- */
1411
- function Listener() { }
1412
- InteractionContext.Listener = Listener;
1413
- if (false) {
1414
- /**
1415
- * @return {?}
1416
- */
1417
- Listener.prototype.onActivityStarted = function () { };
1418
- /**
1419
- * @return {?}
1420
- */
1421
- Listener.prototype.onActivityFinished = function () { };
1422
- }
1423
- })(exports.ɵbc || (exports.ɵbc = {}));
1424
1452
 
1425
1453
  /**
1426
1454
  * @fileoverview added by tsickle
@@ -1429,7 +1457,7 @@
1429
1457
  /**
1430
1458
  * @template D, R, E
1431
1459
  */
1432
- exports.ɵbj = /** @class */ (function (_super) {
1460
+ exports.ɵbk = /** @class */ (function (_super) {
1433
1461
  __extends(ConfirmThenDialogComponent, _super);
1434
1462
  function ConfirmThenDialogComponent(config, interactionContext) {
1435
1463
  var _this = _super.call(this) || this;
@@ -1495,15 +1523,15 @@
1495
1523
  /** @nocollapse */
1496
1524
  ConfirmThenDialogComponent.ctorParameters = function () { return [
1497
1525
  { type: undefined, decorators: [{ type: core.Inject, args: [ACTIVITY_DATA,] }] },
1498
- { type: exports.ɵbc }
1526
+ { type: InteractionContext }
1499
1527
  ]; };
1500
1528
  return ConfirmThenDialogComponent;
1501
1529
  }(AbstractActivity));
1502
1530
  if (false) {
1503
1531
  /** @type {?} */
1504
- exports.ɵbj.prototype.config;
1532
+ exports.ɵbk.prototype.config;
1505
1533
  /** @type {?} */
1506
- exports.ɵbj.prototype.interactionContext;
1534
+ exports.ɵbk.prototype.interactionContext;
1507
1535
  }
1508
1536
  (function (ConfirmThenDialogComponent) {
1509
1537
  /**
@@ -1520,7 +1548,7 @@
1520
1548
  /** @type {?} */
1521
1549
  Data.prototype.data;
1522
1550
  }
1523
- })(exports.ɵbj || (exports.ɵbj = {}));
1551
+ })(exports.ɵbk || (exports.ɵbk = {}));
1524
1552
 
1525
1553
  /**
1526
1554
  * @fileoverview added by tsickle
@@ -1589,13 +1617,14 @@
1589
1617
  */
1590
1618
  _this._activityListDelegate = new pectin.DelegatingListModel();
1591
1619
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1592
- when.listOf(_this.activityList).becomesPopulated((/**
1593
- * @param {?} activities
1620
+ _this._currentActivity = chain(_this.activityList).last();
1621
+ when.valueOf(_this._currentActivity).becomesTruthy((/**
1622
+ * @param {?} activity
1594
1623
  * @return {?}
1595
1624
  */
1596
- function (activities) {
1625
+ function (activity) {
1597
1626
  if (_this.deferredGetCurrentActivity) {
1598
- _this.deferredGetCurrentActivity.resolve(___default.last(activities));
1627
+ _this.deferredGetCurrentActivity.resolve(activity);
1599
1628
  _this.deferredGetCurrentActivity = null;
1600
1629
  }
1601
1630
  }));
@@ -1624,6 +1653,16 @@
1624
1653
  enumerable: true,
1625
1654
  configurable: true
1626
1655
  });
1656
+ Object.defineProperty(InteractionContextBase.prototype, "activeActivity", {
1657
+ get: /**
1658
+ * @return {?}
1659
+ */
1660
+ function () {
1661
+ return this._currentActivity;
1662
+ },
1663
+ enumerable: true,
1664
+ configurable: true
1665
+ });
1627
1666
  /**
1628
1667
  * Returns the activity that is currently active.
1629
1668
  * This model is only updated in the next tick after the view has been updated.
@@ -1650,12 +1689,14 @@
1650
1689
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1651
1690
  }
1652
1691
  else {
1653
- if (this.activityList.length < 1) {
1692
+ if (!this._currentActivity.value) {
1693
+ // we'be been asked before we've got any activities, create a deferred promise
1694
+ // that we resolve when the list populates.
1654
1695
  this.deferredGetCurrentActivity = pectin.Deferred.defer();
1655
1696
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1656
1697
  }
1657
1698
  else {
1658
- return [2 /*return*/, ___default.last(this.activityList.value)];
1699
+ return [2 /*return*/, this._currentActivity.value];
1659
1700
  }
1660
1701
  }
1661
1702
  }
@@ -1736,14 +1777,14 @@
1736
1777
  * @return {?}
1737
1778
  */
1738
1779
  function (confirm, activityType, data) {
1739
- return this._startActivity(exports.ɵbj, {
1780
+ return this._startActivity(exports.ɵbk, {
1740
1781
  confirm: confirm,
1741
1782
  activityType: activityType,
1742
1783
  data: data
1743
1784
  }, true);
1744
1785
  };
1745
1786
  return InteractionContextBase;
1746
- }(exports.ɵbc));
1787
+ }(InteractionContext));
1747
1788
  if (false) {
1748
1789
  /**
1749
1790
  * Returns the current list of activities that are in progress.
@@ -1757,6 +1798,11 @@
1757
1798
  * @private
1758
1799
  */
1759
1800
  InteractionContextBase.prototype.deferredGetCurrentActivity;
1801
+ /**
1802
+ * @type {?}
1803
+ * @private
1804
+ */
1805
+ InteractionContextBase.prototype._currentActivity;
1760
1806
  /**
1761
1807
  * @abstract
1762
1808
  * @protected
@@ -1828,7 +1874,7 @@
1828
1874
  var injector = core.Injector.create({
1829
1875
  providers: [
1830
1876
  {
1831
- provide: exports.ɵbc,
1877
+ provide: InteractionContext,
1832
1878
  useValue: this.interactionContext
1833
1879
  },
1834
1880
  { provide: ACTIVITY_DATA, useValue: activityContext.activityData }
@@ -2000,6 +2046,15 @@
2000
2046
  this._complete = true;
2001
2047
  this.activityCallbacks.onCancel(error);
2002
2048
  };
2049
+ /**
2050
+ * @return {?}
2051
+ */
2052
+ TabContext.prototype.dispose = /**
2053
+ * @return {?}
2054
+ */
2055
+ function () {
2056
+ this.component.dispose();
2057
+ };
2003
2058
  return TabContext;
2004
2059
  }());
2005
2060
  if (false) {
@@ -2089,20 +2144,10 @@
2089
2144
  enumerable: true,
2090
2145
  configurable: true
2091
2146
  });
2092
- // get isFinished() {
2093
- // return !this._initialActivityOutletContext;
2094
- // }
2095
- // get isFinished() {
2096
- // return !this._initialActivityOutletContext;
2097
- // }
2098
2147
  /**
2099
2148
  * @return {?}
2100
2149
  */
2101
- ActivityContainerComponent.prototype.ngOnInit =
2102
- // get isFinished() {
2103
- // return !this._initialActivityOutletContext;
2104
- // }
2105
- /**
2150
+ ActivityContainerComponent.prototype.ngOnInit = /**
2106
2151
  * @return {?}
2107
2152
  */
2108
2153
  function () {
@@ -2184,6 +2229,7 @@
2184
2229
  * @return {?}
2185
2230
  */
2186
2231
  function () {
2232
+ this.updateActivityList();
2187
2233
  this._initialActivityOutletContext.value = null;
2188
2234
  this.initialActivityOutletContextEvent.emit(null);
2189
2235
  };
@@ -2216,14 +2262,24 @@
2216
2262
  * @return {?}
2217
2263
  */
2218
2264
  function () {
2219
- var _this = this;
2220
2265
  if (this.tabs.selectedIndex < this.activityTabs.length - 1) {
2266
+ /** @type {?} */
2267
+ var tabs = this.activityTabs.value;
2268
+ /** @type {?} */
2269
+ var remainingActivities_1 = tabs.slice(0, 1 + this.tabs.selectedIndex);
2270
+ /** @type {?} */
2271
+ var finishedActivityTabs = tabs.slice(1 + this.tabs.selectedIndex);
2272
+ finishedActivityTabs.forEach((/**
2273
+ * @param {?} a
2274
+ * @return {?}
2275
+ */
2276
+ function (a) { return a.dispose(); }));
2221
2277
  this.activityTabs.runInTransaction((/**
2222
2278
  * @param {?} draft
2223
2279
  * @return {?}
2224
2280
  */
2225
2281
  function (draft) {
2226
- draft.value = draft.value.slice(0, 1 + _this.tabs.selectedIndex);
2282
+ draft.value = remainingActivities_1;
2227
2283
  }));
2228
2284
  }
2229
2285
  };
@@ -2355,206 +2411,357 @@
2355
2411
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2356
2412
  */
2357
2413
  /**
2358
- * @template D, R, E
2414
+ * @abstract
2359
2415
  */
2360
- var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2361
- __extends(InplaceInteractionContextComponent, _super);
2362
- function InplaceInteractionContextComponent() {
2363
- var _this = _super.call(this) || this;
2364
- _this._active = new pectin.MutableValueModel(false);
2365
- return _this;
2416
+ var /**
2417
+ * @abstract
2418
+ */
2419
+ ModalInteractionContextFactory = /** @class */ (function () {
2420
+ function ModalInteractionContextFactory() {
2366
2421
  }
2422
+ return ModalInteractionContextFactory;
2423
+ }());
2424
+ if (false) {
2367
2425
  /**
2426
+ * @abstract
2368
2427
  * @return {?}
2369
2428
  */
2370
- InplaceInteractionContextComponent.prototype.ngAfterViewInit = /**
2429
+ ModalInteractionContextFactory.prototype.createInteractionContext = function () { };
2430
+ }
2431
+
2432
+ /**
2433
+ * @fileoverview added by tsickle
2434
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2435
+ */
2436
+ /** @type {?} */
2437
+ var inplaceMonitorCount = 0;
2438
+ exports.ɵv = /** @class */ (function () {
2439
+ function InteractionService(modelInteractionContextFactory) {
2440
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
2441
+ this.garbage = new pectin.GarbageCollector();
2442
+ this.exclusiveContext = new pectin.MutableValueModel();
2443
+ this._activeModalInteractionContextModel = new pectin.MutableValueModel();
2444
+ this._activeInlineInteractionContextModel = new pectin.MutableValueModel();
2445
+ var _a = pectin.Dsl.disposeWith(this.garbage), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2446
+ this._activeInteractionContext = chain(this._activeModalInteractionContextModel)
2447
+ .otherwise(this._activeInlineInteractionContextModel)
2448
+ .pluck('interactionContext');
2449
+ this.active = chain(this._activeInteractionContext).isNotNil();
2450
+ this.modelInteractionActive = chain(this._activeModalInteractionContextModel).isNotNil();
2451
+ this.inlineInteractionActive = chain(this._activeInlineInteractionContextModel).isNotNil();
2452
+ // TODO: chain.concat(listOrValueModels) would be nice.
2453
+ this.activeInteractionContextIds = chain(new pectin.MutableListModel())
2454
+ .append(this._activeInlineInteractionContextModel)
2455
+ .append(this._activeModalInteractionContextModel)
2456
+ .rejectNil()
2457
+ .pluck('id');
2458
+ }
2459
+ /**
2460
+ * @return {?}
2461
+ */
2462
+ InteractionService.prototype.isActive = /**
2371
2463
  * @return {?}
2372
2464
  */
2373
2465
  function () {
2374
- this.setActivityList(this.interactionContext.activityList);
2466
+ return this.active.value;
2375
2467
  };
2376
- Object.defineProperty(InplaceInteractionContextComponent.prototype, "active", {
2377
- get: /**
2378
- * @return {?}
2379
- */
2380
- function () {
2381
- return this._active.readonly;
2382
- },
2383
- enumerable: true,
2384
- configurable: true
2385
- });
2386
2468
  /**
2387
- * @protected
2388
- * @template D1, R1, E1
2389
- * @param {?} activityType
2390
- * @param {?=} data
2391
2469
  * @return {?}
2392
2470
  */
2393
- InplaceInteractionContextComponent.prototype._startActivity = /**
2394
- * @protected
2395
- * @template D1, R1, E1
2396
- * @param {?} activityType
2397
- * @param {?=} data
2471
+ InteractionService.prototype.isModalActive = /**
2398
2472
  * @return {?}
2399
2473
  */
2400
- function (activityType, data) {
2401
- var _this = this;
2402
- this._active.value = true;
2474
+ function () {
2475
+ return this.modelInteractionActive.value;
2476
+ };
2477
+ /**
2478
+ * @param {?} disposable
2479
+ * @return {?}
2480
+ */
2481
+ InteractionService.prototype.createModalInteractionContextFor = /**
2482
+ * @param {?} disposable
2483
+ * @return {?}
2484
+ */
2485
+ function (disposable) {
2486
+ /** @type {?} */
2487
+ var context = this.modelInteractionContextFactory.createInteractionContext();
2488
+ disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
2489
+ return context;
2490
+ };
2491
+ /**
2492
+ * @param {?} interactionContext
2493
+ * @return {?}
2494
+ */
2495
+ InteractionService.prototype._registerInplaceInteractionContext = /**
2496
+ * @param {?} interactionContext
2497
+ * @return {?}
2498
+ */
2499
+ function (interactionContext) {
2500
+ interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2501
+ };
2502
+ // @Trace()
2503
+ // @Trace()
2504
+ /**
2505
+ * @return {?}
2506
+ */
2507
+ InteractionService.prototype.getActiveContext =
2508
+ // @Trace()
2509
+ /**
2510
+ * @return {?}
2511
+ */
2512
+ function () {
2513
+ typescriptUtilities.assert.isTruthy(this.isActive());
2514
+ return this._activeInteractionContext.value;
2515
+ };
2516
+ /**
2517
+ * Creates an interaction context that will prevent any other contexts from starting an
2518
+ * activity until it is disposed. This is intended for use by the router for passing
2519
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2520
+ * try and interact in a way that we can't track and synchronise with the browser back
2521
+ * button.
2522
+ */
2523
+ /**
2524
+ * Creates an interaction context that will prevent any other contexts from starting an
2525
+ * activity until it is disposed. This is intended for use by the router for passing
2526
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2527
+ * try and interact in a way that we can't track and synchronise with the browser back
2528
+ * button.
2529
+ * @return {?}
2530
+ */
2531
+ InteractionService.prototype._createExclusiveModalInteractionContext = /**
2532
+ * Creates an interaction context that will prevent any other contexts from starting an
2533
+ * activity until it is disposed. This is intended for use by the router for passing
2534
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2535
+ * try and interact in a way that we can't track and synchronise with the browser back
2536
+ * button.
2537
+ * @return {?}
2538
+ */
2539
+ function () {
2540
+ this.exclusiveContext.value = this.modelInteractionContextFactory.createInteractionContext();
2403
2541
  /** @type {?} */
2404
2542
  var self = this;
2405
- return new Promise((/**
2406
- * @param {?} resolve
2407
- * @param {?} reject
2408
- * @return {?}
2409
- */
2410
- function (resolve, reject) {
2411
- _this.interactionContext.initialActivityOutletContext = {
2412
- activityClass: activityType,
2413
- activityData: data,
2414
- onDone: /**
2415
- * @param {?} result
2416
- * @return {?}
2417
- */
2418
- function (result) {
2419
- self._active.value = false;
2420
- resolve(result);
2421
- },
2422
- onCancel: /**
2423
- * @param {?} error
2424
- * @return {?}
2425
- */
2426
- function (error) {
2427
- self._active.value = false;
2428
- reject(error);
2429
- }
2430
- };
2431
- }));
2543
+ this.exclusiveContext.value.registerDisposable({
2544
+ dispose: /**
2545
+ * @return {?}
2546
+ */
2547
+ function () {
2548
+ self.exclusiveContext.value = null;
2549
+ }
2550
+ });
2551
+ return this.exclusiveContext.value;
2432
2552
  };
2433
- InplaceInteractionContextComponent.decorators = [
2434
- { type: core.Component, args: [{
2435
- selector: 'aup-inplace-interaction-context',
2436
- template: "<mat-tab-group no-tab-header [selectedIndex]=\"isActive() ? 1 : 0\" full-height-tabs [dynamicHeight]=\"false\">\n <mat-tab>\n <ng-content></ng-content>\n </mat-tab>\n <mat-tab>\n <aup-activity-container #activityContainer\n [(initialActivityOutletContext)]=\"initialActivityContext\"\n [dynamicHeight]=\"false\"></aup-activity-container>\n </mat-tab>\n</mat-tab-group>\n\n",
2437
- styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
2438
- }] }
2553
+ InteractionService.decorators = [
2554
+ { type: core.Injectable, args: [{
2555
+ providedIn: 'root'
2556
+ },] }
2439
2557
  ];
2440
2558
  /** @nocollapse */
2441
- InplaceInteractionContextComponent.ctorParameters = function () { return []; };
2442
- InplaceInteractionContextComponent.propDecorators = {
2443
- interactionContext: [{ type: core.ViewChild, args: ['activityContainer', { static: true },] }]
2444
- };
2445
- return InplaceInteractionContextComponent;
2446
- }(InteractionContextBase));
2559
+ InteractionService.ctorParameters = function () { return [
2560
+ { type: ModalInteractionContextFactory }
2561
+ ]; };
2562
+ /** @nocollapse */ InteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(core.ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
2563
+ return InteractionService;
2564
+ }());
2447
2565
  if (false) {
2566
+ /**
2567
+ * @type {?}
2568
+ * @private
2569
+ */
2570
+ exports.ɵv.prototype.garbage;
2448
2571
  /** @type {?} */
2449
- InplaceInteractionContextComponent.prototype.interactionContext;
2450
- /** @type {?} */
2451
- InplaceInteractionContextComponent.prototype.initialActivityContext;
2572
+ exports.ɵv.prototype.active;
2452
2573
  /**
2453
2574
  * @type {?}
2454
2575
  * @private
2455
2576
  */
2456
- InplaceInteractionContextComponent.prototype._active;
2577
+ exports.ɵv.prototype.exclusiveContext;
2578
+ /**
2579
+ * @type {?}
2580
+ * @private
2581
+ */
2582
+ exports.ɵv.prototype._activeModalInteractionContextModel;
2583
+ /**
2584
+ * @type {?}
2585
+ * @private
2586
+ */
2587
+ exports.ɵv.prototype._activeInlineInteractionContextModel;
2588
+ /**
2589
+ * @type {?}
2590
+ * @private
2591
+ */
2592
+ exports.ɵv.prototype._activeInteractionContext;
2593
+ /** @type {?} */
2594
+ exports.ɵv.prototype.activeInteractionContextIds;
2595
+ /** @type {?} */
2596
+ exports.ɵv.prototype.modelInteractionActive;
2597
+ /** @type {?} */
2598
+ exports.ɵv.prototype.inlineInteractionActive;
2599
+ /** @type {?} */
2600
+ exports.ɵv.prototype.modelInteractionContextFactory;
2457
2601
  }
2458
-
2459
- /**
2460
- * @fileoverview added by tsickle
2461
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2462
- */
2463
- var InteractionOutletComponent = /** @class */ (function () {
2464
- function InteractionOutletComponent() {
2602
+ (function (InteractionService) {
2603
+ /**
2604
+ * @record
2605
+ */
2606
+ function Callback() { }
2607
+ InteractionService.Callback = Callback;
2608
+ if (false) {
2609
+ /**
2610
+ * @param {?} monitor
2611
+ * @return {?}
2612
+ */
2613
+ Callback.prototype.onStarted = function (monitor) { };
2614
+ /**
2615
+ * @param {?} monitor
2616
+ * @return {?}
2617
+ */
2618
+ Callback.prototype.onFinished = function (monitor) { };
2465
2619
  }
2466
- InteractionOutletComponent.decorators = [
2467
- { type: core.Component, args: [{
2468
- selector: 'aup-interaction-outlet',
2469
- template: "<router-outlet name=\"interaction-context\"></router-outlet>\n",
2470
- styles: [":host{display:block}"]
2471
- }] }
2472
- ];
2473
- /** @nocollapse */
2474
- InteractionOutletComponent.ctorParameters = function () { return []; };
2475
- return InteractionOutletComponent;
2476
- }());
2620
+ var Monitor = /** @class */ (function (_super) {
2621
+ __extends(Monitor, _super);
2622
+ function Monitor(id, interactionContext, currentActiveMonitor, exclusiveContext) {
2623
+ var _this = _super.call(this) || this;
2624
+ _this.id = id;
2625
+ _this.interactionContext = interactionContext;
2626
+ _this.currentActiveMonitor = currentActiveMonitor;
2627
+ _this.exclusiveContext = exclusiveContext;
2628
+ var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2629
+ when.valueOf(interactionContext.active).becomesTruthy((/**
2630
+ * @return {?}
2631
+ */
2632
+ function () { return _this.onStarted(); }));
2633
+ when.valueOf(interactionContext.active).becomesFalsey((/**
2634
+ * @return {?}
2635
+ */
2636
+ function () { return _this.onFinished(); }));
2637
+ interactionContext.registerDisposable(_this);
2638
+ return _this;
2639
+ }
2640
+ /**
2641
+ * @protected
2642
+ * @return {?}
2643
+ */
2644
+ Monitor.prototype.onStarted = /**
2645
+ * @protected
2646
+ * @return {?}
2647
+ */
2648
+ function () {
2649
+ this.assertCanStart();
2650
+ this.currentActiveMonitor.value = this;
2651
+ };
2652
+ /**
2653
+ * @private
2654
+ * @return {?}
2655
+ */
2656
+ Monitor.prototype.assertCanStart = /**
2657
+ * @private
2658
+ * @return {?}
2659
+ */
2660
+ function () {
2661
+ typescriptUtilities.assert.isFalsey(this.currentActiveMonitor.value);
2662
+ if (this.exclusiveContext.value && this.interactionContext !== this.exclusiveContext.value) {
2663
+ pectin.lang.illegalState('Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)');
2664
+ }
2665
+ };
2666
+ /**
2667
+ * @protected
2668
+ * @return {?}
2669
+ */
2670
+ Monitor.prototype.onFinished = /**
2671
+ * @protected
2672
+ * @return {?}
2673
+ */
2674
+ function () {
2675
+ this.assertCurrentlyActive();
2676
+ this.currentActiveMonitor.value = null;
2677
+ };
2678
+ /**
2679
+ * @private
2680
+ * @return {?}
2681
+ */
2682
+ Monitor.prototype.assertCurrentlyActive = /**
2683
+ * @private
2684
+ * @return {?}
2685
+ */
2686
+ function () {
2687
+ typescriptUtilities.assert.isTruthy(this.currentActiveMonitor.value === this);
2688
+ };
2689
+ return Monitor;
2690
+ }(pectin.GarbageCollector));
2691
+ InteractionService.Monitor = Monitor;
2692
+ if (false) {
2693
+ /** @type {?} */
2694
+ Monitor.prototype.id;
2695
+ /** @type {?} */
2696
+ Monitor.prototype.interactionContext;
2697
+ /** @type {?} */
2698
+ Monitor.prototype.currentActiveMonitor;
2699
+ /** @type {?} */
2700
+ Monitor.prototype.exclusiveContext;
2701
+ }
2702
+ })(exports.ɵv || (exports.ɵv = {}));
2477
2703
 
2478
2704
  /**
2479
2705
  * @fileoverview added by tsickle
2480
2706
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2481
2707
  */
2482
- var DialogInteractionContext = /** @class */ (function (_super) {
2483
- __extends(DialogInteractionContext, _super);
2484
- function DialogInteractionContext(dialogService, config) {
2708
+ /**
2709
+ * @template D, R, E
2710
+ */
2711
+ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2712
+ __extends(InplaceInteractionContextComponent, _super);
2713
+ function InplaceInteractionContextComponent(interactionService) {
2485
2714
  var _this = _super.call(this) || this;
2486
- _this.dialogService = dialogService;
2487
- _this.config = config;
2488
- _this._activeModel = new pectin.MutableValueModel(false);
2489
- typescriptUtilities.assert.notNil(dialogService);
2490
- _this.onDispose((/**
2491
- * @return {?}
2492
- */
2493
- function () {
2494
- if (_this.isActive()) {
2495
- pectin.lang.illegalState('Dispose called while active.');
2496
- }
2497
- }));
2715
+ _this.interactionService = interactionService;
2716
+ _this._active = new pectin.MutableValueModel(false);
2717
+ _this.interactionService._registerInplaceInteractionContext(_this);
2498
2718
  return _this;
2499
2719
  }
2500
- Object.defineProperty(DialogInteractionContext.prototype, "active", {
2720
+ /**
2721
+ * @return {?}
2722
+ */
2723
+ InplaceInteractionContextComponent.prototype.ngAfterViewInit = /**
2724
+ * @return {?}
2725
+ */
2726
+ function () {
2727
+ this.setActivityList(this.interactionContext.activityList);
2728
+ };
2729
+ Object.defineProperty(InplaceInteractionContextComponent.prototype, "active", {
2501
2730
  get: /**
2502
2731
  * @return {?}
2503
2732
  */
2504
2733
  function () {
2505
- return this._activeModel.readonly;
2734
+ return this._active.readonly;
2506
2735
  },
2507
2736
  enumerable: true,
2508
2737
  configurable: true
2509
2738
  });
2510
2739
  /**
2511
2740
  * @protected
2512
- * @template D, R, E
2741
+ * @template D1, R1, E1
2513
2742
  * @param {?} activityType
2514
- * @param {?} data
2515
- * @param {?=} disableClose
2743
+ * @param {?=} data
2516
2744
  * @return {?}
2517
2745
  */
2518
- DialogInteractionContext.prototype._startActivity = /**
2746
+ InplaceInteractionContextComponent.prototype._startActivity = /**
2519
2747
  * @protected
2520
- * @template D, R, E
2748
+ * @template D1, R1, E1
2521
2749
  * @param {?} activityType
2522
- * @param {?} data
2523
- * @param {?=} disableClose
2750
+ * @param {?=} data
2524
2751
  * @return {?}
2525
2752
  */
2526
- function (activityType, data, disableClose) {
2753
+ function (activityType, data) {
2527
2754
  var _this = this;
2528
- if (disableClose === void 0) { disableClose = true; }
2529
- if (this.isActive()) {
2530
- pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
2531
- * @param {?} a
2532
- * @return {?}
2533
- */
2534
- function (a) { return a.constructor.name; })).join(', '));
2535
- }
2536
- this._activeModel.value = true;
2537
- this.notifyActivityStarted();
2538
- /** @type {?} */
2539
- var config = __assign({}, this.config, {
2540
- data: data,
2541
- disableClose: disableClose,
2542
- panelClass: 'dialog-interaction-service'
2543
- });
2755
+ this._active.value = true;
2544
2756
  /** @type {?} */
2545
2757
  var self = this;
2546
- /** @type {?} */
2547
- var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
2548
2758
  return new Promise((/**
2549
2759
  * @param {?} resolve
2550
2760
  * @param {?} reject
2551
2761
  * @return {?}
2552
2762
  */
2553
2763
  function (resolve, reject) {
2554
- /** @type {?} */
2555
- var activityContainer = matDialogRef.componentInstance;
2556
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
2557
- activityContainer.initialActivityOutletContext = {
2764
+ _this.interactionContext.initialActivityOutletContext = {
2558
2765
  activityClass: activityType,
2559
2766
  activityData: data,
2560
2767
  onDone: /**
@@ -2562,411 +2769,69 @@
2562
2769
  * @return {?}
2563
2770
  */
2564
2771
  function (result) {
2772
+ self._active.value = false;
2565
2773
  resolve(result);
2566
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2567
2774
  },
2568
2775
  onCancel: /**
2569
2776
  * @param {?} error
2570
2777
  * @return {?}
2571
2778
  */
2572
2779
  function (error) {
2780
+ self._active.value = false;
2573
2781
  reject(error);
2574
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2575
2782
  }
2576
2783
  };
2577
- // we need to check if our onDone/onCancel methods above we called or if we were
2578
- // closed by the user clicking the backdrop. If the later then we need to reject
2579
- // our promise.
2580
- matDialogRef.afterClosed().subscribe((/**
2581
- * @param {?} promiseAlreadyFinished
2582
- * @return {?}
2583
- */
2584
- function (promiseAlreadyFinished) {
2585
- if (!promiseAlreadyFinished) {
2586
- reject('auto-closed');
2587
- }
2588
- }));
2589
- matDialogRef.updateSize();
2590
- matDialogRef.afterOpened().subscribe((/**
2591
- * @param {?} promiseAlreadyFinished
2592
- * @return {?}
2593
- */
2594
- function (promiseAlreadyFinished) {
2595
- matDialogRef.updateSize();
2596
- }));
2597
- })).finally((/**
2598
- * @return {?}
2599
- */
2600
- function () {
2601
- _this._activeModel.value = false;
2602
- _this.notifyActivityFinished();
2603
- self.safelyUpdateActivityListDelegate(null);
2604
- }));
2605
- };
2606
- /**
2607
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2608
- * @param delegate
2609
- */
2610
- /**
2611
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2612
- * @param {?} delegate
2613
- * @return {?}
2614
- */
2615
- DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
2616
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2617
- * @param {?} delegate
2618
- * @return {?}
2619
- */
2620
- function (delegate) {
2621
- var _this = this;
2622
- setTimeout((/**
2623
- * @return {?}
2624
- */
2625
- function () { return _this.setActivityList(delegate); }));
2626
- };
2627
- DialogInteractionContext.decorators = [
2628
- { type: core.Injectable, args: [{
2629
- providedIn: 'root'
2630
- },] }
2631
- ];
2632
- /** @nocollapse */
2633
- DialogInteractionContext.ctorParameters = function () { return [
2634
- { type: material.MatDialog },
2635
- { type: dialog.MatDialogConfig }
2636
- ]; };
2637
- /** @nocollapse */ DialogInteractionContext.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(dialog.MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2638
- return DialogInteractionContext;
2639
- }(InteractionContextBase));
2640
- if (false) {
2641
- /**
2642
- * @type {?}
2643
- * @private
2644
- */
2645
- DialogInteractionContext.prototype._activeModel;
2646
- /**
2647
- * @type {?}
2648
- * @private
2649
- */
2650
- DialogInteractionContext.prototype.dialogService;
2651
- /** @type {?} */
2652
- DialogInteractionContext.prototype.config;
2653
- }
2654
-
2655
- /**
2656
- * @fileoverview added by tsickle
2657
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2658
- */
2659
- var Guard = /** @class */ (function (_super) {
2660
- __extends(Guard, _super);
2661
- function Guard() {
2662
- return _super.call(this, { initialValue: false }) || this;
2663
- }
2664
- Object.defineProperty(Guard.prototype, "value", {
2665
- get: /**
2666
- * @return {?}
2667
- */
2668
- function () {
2669
- return this.store.read();
2670
- },
2671
- enumerable: true,
2672
- configurable: true
2673
- });
2674
- /**
2675
- * @template R
2676
- * @param {?} fun
2677
- * @return {?}
2678
- */
2679
- Guard.prototype.whileTrue = /**
2680
- * @template R
2681
- * @param {?} fun
2682
- * @return {?}
2683
- */
2684
- function (fun) {
2685
- this.startTransaction().commit(true);
2686
- try {
2687
- return fun();
2688
- }
2689
- finally {
2690
- this.startTransaction().commit(false);
2691
- }
2692
- };
2693
- /**
2694
- * @template R
2695
- * @param {?} fun
2696
- * @param {?=} defaultValue
2697
- * @return {?}
2698
- */
2699
- Guard.prototype.runIfFalse = /**
2700
- * @template R
2701
- * @param {?} fun
2702
- * @param {?=} defaultValue
2703
- * @return {?}
2704
- */
2705
- function (fun, defaultValue) {
2706
- if (defaultValue === void 0) { defaultValue = null; }
2707
- return !this.value ? fun() : defaultValue;
2708
- };
2709
- return Guard;
2710
- }(pectin.ValueModel));
2711
- /**
2712
- * @abstract
2713
- */
2714
- var /**
2715
- * @abstract
2716
- */
2717
- ModalInteractionService = /** @class */ (function (_super) {
2718
- __extends(ModalInteractionService, _super);
2719
- function ModalInteractionService() {
2720
- var _this = _super.call(this) || this;
2721
- _this._activityListeners = new pectin.EventListenerList();
2722
- return _this;
2723
- }
2724
- /**
2725
- * @return {?}
2726
- */
2727
- ModalInteractionService.prototype.isActive = /**
2728
- * @return {?}
2729
- */
2730
- function () {
2731
- return this.active.value;
2732
- };
2733
- /**
2734
- * @param {?} listener
2735
- * @return {?}
2736
- */
2737
- ModalInteractionService.prototype.addActivityListener = /**
2738
- * @param {?} listener
2739
- * @return {?}
2740
- */
2741
- function (listener) {
2742
- return this._activityListeners.add(listener);
2743
- };
2744
- /**
2745
- * @protected
2746
- * @return {?}
2747
- */
2748
- ModalInteractionService.prototype.notifyActivityStarted = /**
2749
- * @protected
2750
- * @return {?}
2751
- */
2752
- function () {
2753
- this._activityListeners.fire((/**
2754
- * @param {?} l
2755
- * @return {?}
2756
- */
2757
- function (l) { return l.onActivityStarted(); }));
2758
- };
2759
- /**
2760
- * @protected
2761
- * @return {?}
2762
- */
2763
- ModalInteractionService.prototype.notifyActivityFinished = /**
2764
- * @protected
2765
- * @return {?}
2766
- */
2767
- function () {
2768
- this._activityListeners.fire((/**
2769
- * @param {?} l
2770
- * @return {?}
2771
- */
2772
- function (l) { return l.onActivityFinished(); }));
2773
- };
2774
- return ModalInteractionService;
2775
- }(pectin.GarbageCollector));
2776
- if (false) {
2777
- /**
2778
- * @type {?}
2779
- * @private
2780
- */
2781
- ModalInteractionService.prototype._activityListeners;
2782
- /** @type {?} */
2783
- ModalInteractionService.prototype.active;
2784
- /**
2785
- * @abstract
2786
- * @param {?} disposable
2787
- * @return {?}
2788
- */
2789
- ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2790
- /**
2791
- * @abstract
2792
- * @return {?}
2793
- */
2794
- ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2795
- /**
2796
- * @abstract
2797
- * @return {?}
2798
- */
2799
- ModalInteractionService.prototype.getCurrentActivity = function () { };
2800
- }
2801
-
2802
- /**
2803
- * @fileoverview added by tsickle
2804
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2805
- */
2806
- /** @type {?} */
2807
- var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2808
- var DialogInteractionService = /** @class */ (function (_super) {
2809
- __extends(DialogInteractionService, _super);
2810
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2811
- var _this = _super.call(this) || this;
2812
- _this.dialogService = dialogService;
2813
- _this.dialogServiceDefaults = dialogServiceDefaults;
2814
- _this.matDialogDefaultConfig = matDialogDefaultConfig;
2815
- _this._activeInteractionContextModel = new pectin.MutableValueModel();
2816
- typescriptUtilities.assert.notNil(dialogService);
2817
- var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2818
- _this.active = chain(_this._activeInteractionContextModel).isNotNil();
2819
- return _this;
2820
- }
2821
- /**
2822
- * @param {?} disposable
2823
- * @return {?}
2824
- */
2825
- DialogInteractionService.prototype.createInteractionContextFor = /**
2826
- * @param {?} disposable
2827
- * @return {?}
2828
- */
2829
- function (disposable) {
2830
- return disposable.registerDisposable(this._createInteractionContext());
2831
- };
2832
- /**
2833
- * @return {?}
2834
- */
2835
- DialogInteractionService.prototype._createInteractionContext = /**
2836
- * @return {?}
2837
- */
2838
- function () {
2839
- /** @type {?} */
2840
- var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2841
- /** @type {?} */
2842
- var self = this;
2843
- /** @type {?} */
2844
- var dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2845
- dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2846
- onActivityStarted: /**
2847
- * @return {?}
2848
- */
2849
- function () {
2850
- self.onActivityStarted(dialogInteractionContext);
2851
- },
2852
- onActivityFinished: /**
2853
- * @return {?}
2854
- */
2855
- function () {
2856
- self.onActivityFinished(dialogInteractionContext);
2857
- }
2858
- }));
2859
- return dialogInteractionContext;
2860
- };
2861
- /**
2862
- * @return {?}
2863
- */
2864
- DialogInteractionService.prototype.createExclusiveInteractionContext = /**
2865
- * @return {?}
2866
- */
2867
- function () {
2868
- this.exclusiveContext = this._createInteractionContext();
2869
- /** @type {?} */
2870
- var self = this;
2871
- this.exclusiveContext.registerDisposable({
2872
- dispose: /**
2873
- * @return {?}
2874
- */
2875
- function () {
2876
- self.exclusiveContext = null;
2877
- }
2878
- });
2879
- return this.exclusiveContext;
2880
- };
2881
- // @Trace()
2882
- // @Trace()
2883
- /**
2884
- * @param {?} dialogInteractionContext
2885
- * @return {?}
2886
- */
2887
- DialogInteractionService.prototype.onActivityStarted =
2888
- // @Trace()
2889
- /**
2890
- * @param {?} dialogInteractionContext
2891
- * @return {?}
2892
- */
2893
- function (dialogInteractionContext) {
2894
- typescriptUtilities.assert.isFalsey(this.isActive());
2895
- if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2896
- pectin.lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2897
- }
2898
- this._activeInteractionContextModel.value = dialogInteractionContext;
2899
- this.notifyActivityStarted();
2900
- };
2901
- // @Trace()
2902
- // @Trace()
2903
- /**
2904
- * @param {?} dialogInteractionContext
2905
- * @return {?}
2906
- */
2907
- DialogInteractionService.prototype.onActivityFinished =
2908
- // @Trace()
2909
- /**
2910
- * @param {?} dialogInteractionContext
2911
- * @return {?}
2912
- */
2913
- function (dialogInteractionContext) {
2914
- typescriptUtilities.assert.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2915
- this._activeInteractionContextModel.value = null;
2916
- this.notifyActivityFinished();
2917
- };
2918
- /**
2919
- * @return {?}
2920
- */
2921
- DialogInteractionService.prototype.getCurrentActivity = /**
2922
- * @return {?}
2923
- */
2924
- function () {
2925
- return __awaiter(this, void 0, void 0, function () {
2926
- return __generator(this, function (_a) {
2927
- typescriptUtilities.assert.isTruthy(this.isActive());
2928
- return [2 /*return*/, this._activeInteractionContextModel.value.getCurrentActivity()];
2929
- });
2930
- });
2931
- };
2932
- DialogInteractionService.decorators = [
2933
- { type: core.Injectable, args: [{
2934
- providedIn: 'root'
2935
- },] }
2784
+ }));
2785
+ };
2786
+ InplaceInteractionContextComponent.decorators = [
2787
+ { type: core.Component, args: [{
2788
+ selector: 'aup-inplace-interaction-context',
2789
+ template: "<mat-tab-group no-tab-header [selectedIndex]=\"isActive() ? 1 : 0\" full-height-tabs [dynamicHeight]=\"false\">\n <mat-tab>\n <ng-content></ng-content>\n </mat-tab>\n <mat-tab>\n <aup-activity-container #activityContainer\n [(initialActivityOutletContext)]=\"initialActivityContext\"\n [dynamicHeight]=\"false\"></aup-activity-container>\n </mat-tab>\n</mat-tab-group>\n\n",
2790
+ styles: [":host{display:flex;flex-direction:column}mat-tab-group{flex:1}"]
2791
+ }] }
2936
2792
  ];
2937
2793
  /** @nocollapse */
2938
- DialogInteractionService.ctorParameters = function () { return [
2939
- { type: material.MatDialog },
2940
- { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2941
- { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2794
+ InplaceInteractionContextComponent.ctorParameters = function () { return [
2795
+ { type: exports.ɵv }
2942
2796
  ]; };
2943
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2944
- return DialogInteractionService;
2945
- }(ModalInteractionService));
2797
+ InplaceInteractionContextComponent.propDecorators = {
2798
+ interactionContext: [{ type: core.ViewChild, args: ['activityContainer', { static: true },] }]
2799
+ };
2800
+ return InplaceInteractionContextComponent;
2801
+ }(InteractionContextBase));
2946
2802
  if (false) {
2947
- /**
2948
- * @type {?}
2949
- * @private
2950
- */
2951
- DialogInteractionService.prototype._activeInteractionContextModel;
2952
2803
  /** @type {?} */
2953
- DialogInteractionService.prototype.active;
2954
- /**
2955
- * @type {?}
2956
- * @private
2957
- */
2958
- DialogInteractionService.prototype.exclusiveContext;
2804
+ InplaceInteractionContextComponent.prototype.interactionContext;
2805
+ /** @type {?} */
2806
+ InplaceInteractionContextComponent.prototype.initialActivityContext;
2959
2807
  /**
2960
2808
  * @type {?}
2961
2809
  * @private
2962
2810
  */
2963
- DialogInteractionService.prototype.dialogService;
2964
- /** @type {?} */
2965
- DialogInteractionService.prototype.dialogServiceDefaults;
2811
+ InplaceInteractionContextComponent.prototype._active;
2966
2812
  /** @type {?} */
2967
- DialogInteractionService.prototype.matDialogDefaultConfig;
2813
+ InplaceInteractionContextComponent.prototype.interactionService;
2968
2814
  }
2969
2815
 
2816
+ /**
2817
+ * @fileoverview added by tsickle
2818
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2819
+ */
2820
+ var InteractionOutletComponent = /** @class */ (function () {
2821
+ function InteractionOutletComponent() {
2822
+ }
2823
+ InteractionOutletComponent.decorators = [
2824
+ { type: core.Component, args: [{
2825
+ selector: 'aup-interaction-outlet',
2826
+ template: "<router-outlet name=\"interaction-context\"></router-outlet>\n",
2827
+ styles: [":host{display:block}"]
2828
+ }] }
2829
+ ];
2830
+ /** @nocollapse */
2831
+ InteractionOutletComponent.ctorParameters = function () { return []; };
2832
+ return InteractionOutletComponent;
2833
+ }());
2834
+
2970
2835
  /**
2971
2836
  * @fileoverview added by tsickle
2972
2837
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2987,7 +2852,7 @@
2987
2852
  declarations: [
2988
2853
  ActivityContainerComponent,
2989
2854
  ConfirmationDialogComponent,
2990
- exports.ɵbj,
2855
+ exports.ɵbk,
2991
2856
  AlertDialogComponent,
2992
2857
  ActivityOutletComponent,
2993
2858
  InteractionOutletComponent,
@@ -3002,11 +2867,11 @@
3002
2867
  entryComponents: [
3003
2868
  ActivityContainerComponent,
3004
2869
  ConfirmationDialogComponent,
3005
- exports.ɵbj,
2870
+ exports.ɵbk,
3006
2871
  AlertDialogComponent
3007
2872
  ],
3008
2873
  providers: [
3009
- DialogInteractionService,
2874
+ exports.ɵv,
3010
2875
  ]
3011
2876
  },] }
3012
2877
  ];
@@ -3979,67 +3844,110 @@
3979
3844
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3980
3845
  */
3981
3846
  var PlaceComponentDeactivationHandler = /** @class */ (function () {
3982
- function PlaceComponentDeactivationHandler(component, navigationSession) {
3847
+ function PlaceComponentDeactivationHandler(component, navigationState, isPrimaryComponent) {
3983
3848
  this.component = component;
3984
- this.navigationSession = navigationSession;
3849
+ this.navigationState = navigationState;
3850
+ this.isPrimaryComponent = isPrimaryComponent;
3985
3851
  }
3852
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "interactionService", {
3853
+ get: /**
3854
+ * @return {?}
3855
+ */
3856
+ function () {
3857
+ return this.navigationState.interactionService;
3858
+ },
3859
+ enumerable: true,
3860
+ configurable: true
3861
+ });
3862
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeRouter", {
3863
+ get: /**
3864
+ * @return {?}
3865
+ */
3866
+ function () {
3867
+ return this.navigationState.placeRouter;
3868
+ },
3869
+ enumerable: true,
3870
+ configurable: true
3871
+ });
3986
3872
  /**
3873
+ * @param {?} currentUrl
3987
3874
  * @param {?} nextState
3988
3875
  * @return {?}
3989
3876
  */
3990
3877
  PlaceComponentDeactivationHandler.prototype.canDeactivate = /**
3878
+ * @param {?} currentUrl
3991
3879
  * @param {?} nextState
3992
3880
  * @return {?}
3993
3881
  */
3994
- function (nextState) {
3882
+ function (currentUrl, nextState) {
3995
3883
  return __awaiter(this, void 0, void 0, function () {
3996
3884
  return __generator(this, function (_a) {
3997
3885
  // We'll get called multiple times if there's any parameter sanitisation so
3998
3886
  // we always return true if we accepted promise from a previous cycle of the current
3999
3887
  // navigation session.
4000
3888
  if (!this.canDeactivatePromise) {
4001
- this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3889
+ console.log("creating deactivate promise for -> " + this.component.constructor.name);
3890
+ this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
4002
3891
  }
4003
3892
  return [2 /*return*/, this.canDeactivatePromise];
4004
3893
  });
4005
3894
  });
4006
3895
  };
3896
+ // @Trace()
3897
+ // @Trace()
4007
3898
  /**
4008
3899
  * @protected
3900
+ * @param {?} currentUrl
4009
3901
  * @param {?} nextState
4010
3902
  * @return {?}
4011
3903
  */
4012
- PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3904
+ PlaceComponentDeactivationHandler.prototype.canDeactivateComponent =
3905
+ // @Trace()
3906
+ /**
4013
3907
  * @protected
3908
+ * @param {?} currentUrl
4014
3909
  * @param {?} nextState
4015
3910
  * @return {?}
4016
3911
  */
4017
- function (nextState) {
3912
+ function (currentUrl, nextState) {
4018
3913
  return __awaiter(this, void 0, void 0, function () {
4019
- var activity;
3914
+ var routeIds, currentIds;
4020
3915
  return __generator(this, function (_a) {
4021
3916
  switch (_a.label) {
4022
3917
  case 0:
4023
- if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
4024
- // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
4025
- // a model interaction is active. This is because:
4026
- // 1. the user can't click anything to navigate away
4027
- // 2. clicking the back button will only change the outlet route portion of the URL. This
4028
- // is all handled by the InteractionGuard and so the component guards will never run.
4029
- //
4030
- // Now we just cancel the current activity...
4031
- return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
3918
+ console.log(this.navigationState.toString());
3919
+ if (!this.navigationState.isPopState) return [3 /*break*/, 5];
3920
+ if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
3921
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
3922
+ currentIds = this.interactionService.activeInteractionContextIds.value;
3923
+ if (!!___default.isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
3924
+ return [4 /*yield*/, this.interactionService.getActiveContext().cancelCurrentActivity()];
4032
3925
  case 1:
4033
- activity = _a.sent();
4034
- activity.cancel(null);
4035
- return [2 /*return*/, false]; // ..and stay where we are.
4036
- case 2:
3926
+ _a.sent();
3927
+ return [2 /*return*/, currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3928
+ case 2: return [3 /*break*/, 5];
3929
+ case 3:
3930
+ if (!(this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 5];
3931
+ return [4 /*yield*/, this.component.interactionContext.cancelCurrentActivity()];
3932
+ case 4:
3933
+ _a.sent();
3934
+ return [2 /*return*/, currentUrl
3935
+ .updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3936
+ case 5:
4037
3937
  // Ok, so now we're really leaving, so we ask the component if we should.;
4038
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
4039
- // No interaction in progress, so ask the component .
4040
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
4041
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
4042
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3938
+ if (this.isNotJustAChangeInRouteId(nextState)) {
3939
+ if (this.component.canDeactivate) {
3940
+ // No interaction in progress, so ask the component .
3941
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3942
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3943
+ return [2 /*return*/, this.component.canDeactivate(this.navigationState.interactionContext)];
3944
+ }
3945
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
3946
+ // we'll just cancel the navigation and print a warning.
3947
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3948
+ console.warn('Route changed while component has active interaction, cancelling navigation');
3949
+ return [2 /*return*/, false];
3950
+ }
4043
3951
  }
4044
3952
  return [2 /*return*/, true];
4045
3953
  }
@@ -4073,7 +3981,9 @@
4073
3981
  /** @type {?} */
4074
3982
  PlaceComponentDeactivationHandler.prototype.component;
4075
3983
  /** @type {?} */
4076
- PlaceComponentDeactivationHandler.prototype.navigationSession;
3984
+ PlaceComponentDeactivationHandler.prototype.navigationState;
3985
+ /** @type {?} */
3986
+ PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
4077
3987
  }
4078
3988
 
4079
3989
  /**
@@ -4082,6 +3992,9 @@
4082
3992
  */
4083
3993
  /**
4084
3994
  * @abstract
3995
+ */
3996
+ /**
3997
+ * @abstract
4085
3998
  */
4086
3999
  exports.NavigationState = /** @class */ (function (_super) {
4087
4000
  __extends(NavigationState, _super);
@@ -4091,6 +4004,46 @@
4091
4004
  _this._visits = new Map();
4092
4005
  return _this;
4093
4006
  }
4007
+ Object.defineProperty(NavigationState.prototype, "name", {
4008
+ get: /**
4009
+ * @return {?}
4010
+ */
4011
+ function () {
4012
+ return this.constructor.name;
4013
+ },
4014
+ enumerable: true,
4015
+ configurable: true
4016
+ });
4017
+ Object.defineProperty(NavigationState.prototype, "idle", {
4018
+ get: /**
4019
+ * @return {?}
4020
+ */
4021
+ function () {
4022
+ return !this.isTransitional;
4023
+ },
4024
+ enumerable: true,
4025
+ configurable: true
4026
+ });
4027
+ Object.defineProperty(NavigationState.prototype, "placeRouter", {
4028
+ get: /**
4029
+ * @return {?}
4030
+ */
4031
+ function () {
4032
+ return this.context.placeRouter;
4033
+ },
4034
+ enumerable: true,
4035
+ configurable: true
4036
+ });
4037
+ Object.defineProperty(NavigationState.prototype, "interactionService", {
4038
+ get: /**
4039
+ * @return {?}
4040
+ */
4041
+ function () {
4042
+ return this.context.interactionService;
4043
+ },
4044
+ enumerable: true,
4045
+ configurable: true
4046
+ });
4094
4047
  Object.defineProperty(NavigationState.prototype, "interactionContext", {
4095
4048
  get: /**
4096
4049
  * @return {?}
@@ -4123,6 +4076,74 @@
4123
4076
  function (placeDef) {
4124
4077
  return this._visits.get(placeDef);
4125
4078
  };
4079
+ /**
4080
+ * @param {?} visit
4081
+ * @param {?} initialUrl
4082
+ * @return {?}
4083
+ */
4084
+ NavigationState.prototype.onPlaceNavigationStart = /**
4085
+ * @param {?} visit
4086
+ * @param {?} initialUrl
4087
+ * @return {?}
4088
+ */
4089
+ function (visit, initialUrl) {
4090
+ return this.illegalTransition('onPlaceNavigationStart');
4091
+ };
4092
+ /**
4093
+ * @param {?} event
4094
+ * @return {?}
4095
+ */
4096
+ NavigationState.prototype.onPopState = /**
4097
+ * @param {?} event
4098
+ * @return {?}
4099
+ */
4100
+ function (event) {
4101
+ return this.illegalTransition(event);
4102
+ };
4103
+ /**
4104
+ * @param {?} event
4105
+ * @return {?}
4106
+ */
4107
+ NavigationState.prototype.onRouterStarted = /**
4108
+ * @param {?} event
4109
+ * @return {?}
4110
+ */
4111
+ function (event) {
4112
+ return this.illegalTransition(event);
4113
+ };
4114
+ /**
4115
+ * @param {?} event
4116
+ * @return {?}
4117
+ */
4118
+ NavigationState.prototype.onRouterCancelled = /**
4119
+ * @param {?} event
4120
+ * @return {?}
4121
+ */
4122
+ function (event) {
4123
+ return this.illegalTransition(event);
4124
+ };
4125
+ /**
4126
+ * @param {?} event
4127
+ * @return {?}
4128
+ */
4129
+ NavigationState.prototype.onRouterError = /**
4130
+ * @param {?} event
4131
+ * @return {?}
4132
+ */
4133
+ function (event) {
4134
+ return this.illegalTransition(event);
4135
+ };
4136
+ /**
4137
+ * @param {?} event
4138
+ * @return {?}
4139
+ */
4140
+ NavigationState.prototype.onRouterEnd = /**
4141
+ * @param {?} event
4142
+ * @return {?}
4143
+ */
4144
+ function (event) {
4145
+ return this.illegalTransition(event);
4146
+ };
4126
4147
  /**
4127
4148
  * @param {?} newUrl
4128
4149
  * @return {?}
@@ -4134,6 +4155,25 @@
4134
4155
  function (newUrl) {
4135
4156
  return this.illegalTransition('onBackClickedDuringNavigationInteraction');
4136
4157
  };
4158
+ /**
4159
+ * @param {?} component
4160
+ * @param {?} currentUrl
4161
+ * @param {?} nextUrl
4162
+ * @return {?}
4163
+ */
4164
+ NavigationState.prototype.canDeactivatePlace = /**
4165
+ * @param {?} component
4166
+ * @param {?} currentUrl
4167
+ * @param {?} nextUrl
4168
+ * @return {?}
4169
+ */
4170
+ function (component, currentUrl, nextUrl) {
4171
+ return __awaiter(this, void 0, void 0, function () {
4172
+ return __generator(this, function (_a) {
4173
+ return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
4174
+ });
4175
+ });
4176
+ };
4137
4177
  /**
4138
4178
  * @return {?}
4139
4179
  */
@@ -4167,34 +4207,53 @@
4167
4207
  * @return {?}
4168
4208
  */
4169
4209
  function () {
4170
- return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
4210
+ return this.placeRouter.getCurrentRouterUrl();
4171
4211
  };
4172
4212
  /**
4173
4213
  * @protected
4174
4214
  * @param {?} event
4175
4215
  * @return {?}
4176
4216
  */
4177
- NavigationState.prototype.createActiveSession = /**
4217
+ NavigationState.prototype.createTransitionStateFor = /**
4178
4218
  * @protected
4179
4219
  * @param {?} event
4180
4220
  * @return {?}
4181
4221
  */
4182
4222
  function (event) {
4183
- // TODO: check if the event is purely for interaction context changes.
4184
- return new NavigationState.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
4223
+ /** @type {?} */
4224
+ var popstate = event.navigationTrigger === 'popstate';
4225
+ return popstate ?
4226
+ this.interactionService.isActive() ?
4227
+ new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4228
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4229
+ :
4230
+ this.interactionService.isActive() ?
4231
+ new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4232
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4185
4233
  };
4186
4234
  /**
4187
4235
  * @protected
4188
- * @param {?} url
4189
4236
  * @return {?}
4190
4237
  */
4191
- NavigationState.prototype.updateLocation = /**
4238
+ NavigationState.prototype.createIdleState = /**
4192
4239
  * @protected
4240
+ * @return {?}
4241
+ */
4242
+ function () {
4243
+ return this.interactionService.isActive() ?
4244
+ new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4245
+ new NavigationState.Idle(this.context);
4246
+ };
4247
+ /**
4248
+ * @param {?} url
4249
+ * @return {?}
4250
+ */
4251
+ NavigationState.prototype.resetBrowserLocation = /**
4193
4252
  * @param {?} url
4194
4253
  * @return {?}
4195
4254
  */
4196
4255
  function (url) {
4197
- this.context.angularLocation.go(url);
4256
+ this.placeRouter.resetBrowserLocation(url);
4198
4257
  };
4199
4258
  /**
4200
4259
  * @return {?}
@@ -4205,12 +4264,6 @@
4205
4264
  function () {
4206
4265
  return this.constructor.name;
4207
4266
  };
4208
- __decorate([
4209
- pectin.Trace(),
4210
- __metadata("design:type", Function),
4211
- __metadata("design:paramtypes", [Object]),
4212
- __metadata("design:returntype", void 0)
4213
- ], NavigationState.prototype, "updateLocation", null);
4214
4267
  return NavigationState;
4215
4268
  }(pectin.GarbageCollector));
4216
4269
  if (false) {
@@ -4220,54 +4273,22 @@
4220
4273
  */
4221
4274
  exports.NavigationState.prototype._visits;
4222
4275
  /** @type {?} */
4223
- exports.NavigationState.prototype.isPopState;
4224
- /** @type {?} */
4225
- exports.NavigationState.prototype.active;
4276
+ exports.NavigationState.prototype.isTransitional;
4226
4277
  /** @type {?} */
4227
4278
  exports.NavigationState.prototype.startingUrl;
4279
+ /** @type {?} */
4280
+ exports.NavigationState.prototype.isPopState;
4228
4281
  /**
4229
4282
  * @type {?}
4230
4283
  * @protected
4231
4284
  */
4232
4285
  exports.NavigationState.prototype.context;
4233
- /**
4234
- * @abstract
4235
- * @param {?} event
4236
- * @return {?}
4237
- */
4238
- exports.NavigationState.prototype.onStart = function (event) { };
4239
- /**
4240
- * @abstract
4241
- * @param {?} event
4242
- * @return {?}
4243
- */
4244
- exports.NavigationState.prototype.onCancel = function (event) { };
4245
- /**
4246
- * @abstract
4247
- * @param {?} event
4248
- * @return {?}
4249
- */
4250
- exports.NavigationState.prototype.onError = function (event) { };
4251
- /**
4252
- * @abstract
4253
- * @param {?} event
4254
- * @return {?}
4255
- */
4256
- exports.NavigationState.prototype.onEnd = function (event) { };
4257
- /**
4258
- * @abstract
4259
- * @param {?} component
4260
- * @param {?} nextState
4261
- * @return {?}
4262
- */
4263
- exports.NavigationState.prototype.canDeactivatePlace = function (component, nextState) { };
4264
4286
  }
4265
4287
  (function (NavigationState) {
4266
4288
  var Context = /** @class */ (function () {
4267
- function Context(router, modalInteractionService, angularLocation, notifySuccess) {
4268
- this.router = router;
4269
- this.modalInteractionService = modalInteractionService;
4270
- this.angularLocation = angularLocation;
4289
+ function Context(placeRouter, interactionService, notifySuccess) {
4290
+ this.placeRouter = placeRouter;
4291
+ this.interactionService = interactionService;
4271
4292
  this.notifySuccess = notifySuccess;
4272
4293
  }
4273
4294
  return Context;
@@ -4275,11 +4296,9 @@
4275
4296
  NavigationState.Context = Context;
4276
4297
  if (false) {
4277
4298
  /** @type {?} */
4278
- Context.prototype.router;
4279
- /** @type {?} */
4280
- Context.prototype.modalInteractionService;
4299
+ Context.prototype.placeRouter;
4281
4300
  /** @type {?} */
4282
- Context.prototype.angularLocation;
4301
+ Context.prototype.interactionService;
4283
4302
  /** @type {?} */
4284
4303
  Context.prototype.notifySuccess;
4285
4304
  }
@@ -4287,100 +4306,85 @@
4287
4306
  __extends(Idle, _super);
4288
4307
  function Idle(context) {
4289
4308
  var _this = _super.call(this, context) || this;
4290
- _this.active = false;
4309
+ _this.isTransitional = false;
4291
4310
  _this.startingUrl = null;
4311
+ _this.isPopState = false;
4292
4312
  return _this;
4293
- }
4294
- /**
4295
- * @param {?} component
4296
- * @param {?} nextState
4297
- * @return {?}
4298
- */
4299
- Idle.prototype.canDeactivatePlace = /**
4300
- * @param {?} component
4301
- * @param {?} nextState
4302
- * @return {?}
4303
- */
4304
- function (component, nextState) {
4305
- return __awaiter(this, void 0, void 0, function () {
4306
- return __generator(this, function (_a) {
4307
- return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
4308
- });
4309
- });
4310
- };
4311
- /**
4312
- * @param {?} event
4313
- * @return {?}
4314
- */
4315
- Idle.prototype.onStart = /**
4316
- * @param {?} event
4317
- * @return {?}
4318
- */
4319
- function (event) {
4320
- // calling angularLocation.go() to clear back state can trigger router cycles to the current url if we don't ignore them
4321
- if (event.url === this.currentRouterUrl()) {
4322
- pectin.Logger.get(this).info("navigation started to same url -> " + event.url);
4323
- return this;
4324
- }
4325
- if (event.url === (this.currentRouterUrl() + "(aup-interaction:modal)")) {
4326
- pectin.Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4327
- return new ModalInteractionSession(this.context, event.url);
4328
- }
4329
- return this.createActiveSession(event);
4330
- };
4313
+ }
4331
4314
  /**
4332
- * @param {?} event
4315
+ * @param {?} visit
4316
+ * @param {?} initialUrl
4333
4317
  * @return {?}
4334
4318
  */
4335
- Idle.prototype.onCancel = /**
4336
- * @param {?} event
4319
+ Idle.prototype.onPlaceNavigationStart = /**
4320
+ * @param {?} visit
4321
+ * @param {?} initialUrl
4337
4322
  * @return {?}
4338
4323
  */
4339
- function (event) {
4340
- return this.illegalTransition(event);
4324
+ function (visit, initialUrl) {
4325
+ /** @type {?} */
4326
+ var navigationTransition = new NavigationTransition(this.context, initialUrl);
4327
+ navigationTransition.storeVisit(visit);
4328
+ return navigationTransition;
4341
4329
  };
4342
4330
  /**
4343
4331
  * @param {?} event
4344
4332
  * @return {?}
4345
4333
  */
4346
- Idle.prototype.onEnd = /**
4334
+ Idle.prototype.onRouterStarted = /**
4347
4335
  * @param {?} event
4348
4336
  * @return {?}
4349
4337
  */
4350
4338
  function (event) {
4351
- return this.illegalTransition(event);
4339
+ // calling angularLocation.go() to clear back state can trigger router cycles to the current url if we don't ignore them
4340
+ if (event.url === this.currentRouterUrl()) {
4341
+ pectin.Logger.get(this).info("navigation started to same url -> " + event.url);
4342
+ return this;
4343
+ }
4344
+ if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4345
+ pectin.Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4346
+ return new InteractionTransition(this.context, event.url);
4347
+ }
4348
+ else {
4349
+ return this.createTransitionStateFor(event);
4350
+ }
4352
4351
  };
4353
4352
  /**
4354
4353
  * @param {?} event
4355
4354
  * @return {?}
4356
4355
  */
4357
- Idle.prototype.onError = /**
4356
+ Idle.prototype.onPopState = /**
4358
4357
  * @param {?} event
4359
4358
  * @return {?}
4360
4359
  */
4361
4360
  function (event) {
4362
- return this.illegalTransition(event);
4361
+ return this.createTransitionStateFor(event);
4363
4362
  };
4364
4363
  return Idle;
4365
4364
  }(NavigationState));
4366
4365
  NavigationState.Idle = Idle;
4367
4366
  if (false) {
4368
4367
  /** @type {?} */
4369
- Idle.prototype.isPopState;
4370
- /** @type {?} */
4371
- Idle.prototype.active;
4368
+ Idle.prototype.isTransitional;
4372
4369
  /** @type {?} */
4373
4370
  Idle.prototype.startingUrl;
4371
+ /** @type {?} */
4372
+ Idle.prototype.isPopState;
4374
4373
  }
4375
- var Active = /** @class */ (function (_super) {
4376
- __extends(Active, _super);
4377
- function Active(context, isPopState, startingUrl) {
4374
+ /**
4375
+ * @abstract
4376
+ */
4377
+ var /**
4378
+ * @abstract
4379
+ */
4380
+ AbstractNavigationTransition = /** @class */ (function (_super) {
4381
+ __extends(AbstractNavigationTransition, _super);
4382
+ function AbstractNavigationTransition(context, startingUrl) {
4378
4383
  var _this = _super.call(this, context) || this;
4379
- _this.isPopState = isPopState;
4380
4384
  _this.startingUrl = startingUrl;
4381
- _this.active = true;
4385
+ _this.isTransitional = true;
4382
4386
  _this.componentDeactivationHandlers = new Map();
4383
- _this._interactionContext = _this.context.modalInteractionService.createExclusiveInteractionContext();
4387
+ _this._interactionContext = _this.interactionService._createExclusiveModalInteractionContext();
4384
4388
  _this.onDispose((/**
4385
4389
  * @return {?}
4386
4390
  */
@@ -4388,14 +4392,14 @@
4388
4392
  // the interaction context can be detached during the back button cancellation state transition
4389
4393
  // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
4390
4394
  // called before the context has been cancelled. It might be work having the interaction context
4391
- // automatically cancel if the context is disposed.
4395
+ // automatically cancel if the context is disposed so we don't have worry about detaching etc.
4392
4396
  if (_this._interactionContext) {
4393
- _this._interactionContext.dispose();
4397
+ _this._interactionContext.dispose(); // or do something like cancelAndDispose?
4394
4398
  }
4395
4399
  }));
4396
4400
  return _this;
4397
4401
  }
4398
- Object.defineProperty(Active.prototype, "interactionContext", {
4402
+ Object.defineProperty(AbstractNavigationTransition.prototype, "interactionContext", {
4399
4403
  get: /**
4400
4404
  * @return {?}
4401
4405
  */
@@ -4409,19 +4413,20 @@
4409
4413
  * @param {?} event
4410
4414
  * @return {?}
4411
4415
  */
4412
- Active.prototype.onStart = /**
4416
+ AbstractNavigationTransition.prototype.onRouterStarted = /**
4413
4417
  * @param {?} event
4414
4418
  * @return {?}
4415
4419
  */
4416
4420
  function (event) {
4417
- // active sessions can have many cancel start cycles.
4421
+ // active sessions can have many cancel start cycles due
4422
+ // to place guard redirects
4418
4423
  return this;
4419
4424
  };
4420
4425
  /**
4421
4426
  * @param {?} event
4422
4427
  * @return {?}
4423
4428
  */
4424
- Active.prototype.onEnd = /**
4429
+ AbstractNavigationTransition.prototype.onRouterEnd = /**
4425
4430
  * @param {?} event
4426
4431
  * @return {?}
4427
4432
  */
@@ -4430,85 +4435,47 @@
4430
4435
  this.context.notifySuccess(this);
4431
4436
  return new Idle(this.context);
4432
4437
  };
4433
- /**
4434
- * @param {?} event
4435
- * @return {?}
4436
- */
4437
- Active.prototype.onCancel = /**
4438
- * @param {?} event
4439
- * @return {?}
4440
- */
4441
- function (event) {
4442
- if (this.isPopState) { // back button clicked and a guard cancelled
4443
- // Angular doesn't preserve the url when a guard cancels the back button.
4444
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4445
- pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4446
- this.updateLocation(this.startingUrl);
4447
- }
4448
- return this.isPopState ? new Idle(this.context) : this;
4449
- };
4450
- /**
4451
- * @param {?} event
4452
- * @return {?}
4453
- */
4454
- Active.prototype.onError = /**
4455
- * @param {?} event
4456
- * @return {?}
4457
- */
4458
- function (event) {
4459
- // navigation was aborted.
4460
- if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
4461
- // Angular doesn't preserve the url when a guard cancels the back button.
4462
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4463
- pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4464
- this.updateLocation(this.startingUrl);
4465
- }
4466
- return new Idle(this.context);
4467
- };
4468
4438
  /**
4469
4439
  * @param {?} locationTriggerUrl
4470
4440
  * @return {?}
4471
4441
  */
4472
- Active.prototype.onBackClickedDuringNavigationInteraction = /**
4442
+ AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4473
4443
  * @param {?} locationTriggerUrl
4474
4444
  * @return {?}
4475
4445
  */
4476
4446
  function (locationTriggerUrl) {
4447
+ pectin.Logger.get(this).info("back button pressed during navigation session interaction promise");
4448
+ // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4477
4449
  /** @type {?} */
4478
- var context = this.detachInteractionContext();
4479
- context.getCurrentActivity().then((/**
4480
- * @param {?} activity
4450
+ var navigationInteraction = this.detachInteractionContext();
4451
+ var when = pectin.Dsl.disposeWith(navigationInteraction).when;
4452
+ // TODO: I need to make the exclusive interaction context disallow nested activities or
4453
+ // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4454
+ navigationInteraction.cancelCurrentActivity().then((/**
4481
4455
  * @return {?}
4482
4456
  */
4483
- function (activity) {
4484
- context.addActivityListener({
4485
- onActivityFinished: /**
4486
- * @return {?}
4487
- */
4488
- function () {
4489
- context.dispose();
4490
- },
4491
- onActivityStarted: /**
4492
- * @return {?}
4493
- */
4494
- function () {
4495
- }
4496
- });
4497
- activity.cancel(null);
4457
+ function () {
4458
+ navigationInteraction.dispose();
4498
4459
  }));
4499
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
4460
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4500
4461
  };
4462
+ // @Trace()
4463
+ // @Trace()
4501
4464
  /**
4502
4465
  * @param {?} component
4503
- * @param {?} nextState
4466
+ * @param {?} currentUrl
4467
+ * @param {?} nextUrl
4504
4468
  * @return {?}
4505
4469
  */
4506
- Active.prototype.canDeactivatePlace = /**
4470
+ AbstractNavigationTransition.prototype.canDeactivatePlace =
4471
+ // @Trace()
4472
+ /**
4507
4473
  * @param {?} component
4508
- * @param {?} nextState
4474
+ * @param {?} currentUrl
4475
+ * @param {?} nextUrl
4509
4476
  * @return {?}
4510
4477
  */
4511
- function (component, nextState) {
4478
+ function (component, currentUrl, nextUrl) {
4512
4479
  return __awaiter(this, void 0, void 0, function () {
4513
4480
  var handler, isPrimaryHandler;
4514
4481
  return __generator(this, function (_a) {
@@ -4516,10 +4483,10 @@
4516
4483
  handler = this.componentDeactivationHandlers.get(component);
4517
4484
  if (!handler) {
4518
4485
  isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
4519
- handler = new PlaceComponentDeactivationHandler(component, this);
4486
+ handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
4520
4487
  this.componentDeactivationHandlers.set(component, handler);
4521
4488
  }
4522
- return [2 /*return*/, handler.canDeactivate(nextState)];
4489
+ return [2 /*return*/, handler.canDeactivate(currentUrl, nextUrl)];
4523
4490
  });
4524
4491
  });
4525
4492
  };
@@ -4527,7 +4494,7 @@
4527
4494
  * @private
4528
4495
  * @return {?}
4529
4496
  */
4530
- Active.prototype.detachInteractionContext = /**
4497
+ AbstractNavigationTransition.prototype.detachInteractionContext = /**
4531
4498
  * @private
4532
4499
  * @return {?}
4533
4500
  */
@@ -4537,226 +4504,390 @@
4537
4504
  this._interactionContext = null;
4538
4505
  return context;
4539
4506
  };
4540
- /**
4541
- * @return {?}
4542
- */
4543
- Active.prototype.toString = /**
4544
- * @return {?}
4545
- */
4546
- function () {
4547
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", isPopState:" + this.isPopState + ")";
4548
- };
4549
- __decorate([
4550
- pectin.Trace(),
4551
- __metadata("design:type", Function),
4552
- __metadata("design:paramtypes", [router.NavigationStart]),
4553
- __metadata("design:returntype", NavigationState)
4554
- ], Active.prototype, "onStart", null);
4555
- __decorate([
4556
- pectin.Trace(),
4557
- __metadata("design:type", Function),
4558
- __metadata("design:paramtypes", [router.NavigationCancel]),
4559
- __metadata("design:returntype", NavigationState)
4560
- ], Active.prototype, "onCancel", null);
4561
- __decorate([
4562
- pectin.Trace(),
4563
- __metadata("design:type", Function),
4564
- __metadata("design:paramtypes", [router.NavigationError]),
4565
- __metadata("design:returntype", NavigationState)
4566
- ], Active.prototype, "onError", null);
4567
- return Active;
4507
+ return AbstractNavigationTransition;
4568
4508
  }(NavigationState));
4569
- NavigationState.Active = Active;
4509
+ NavigationState.AbstractNavigationTransition = AbstractNavigationTransition;
4570
4510
  if (false) {
4571
4511
  /** @type {?} */
4572
- Active.prototype.active;
4512
+ AbstractNavigationTransition.prototype.isTransitional;
4573
4513
  /**
4574
4514
  * @type {?}
4575
4515
  * @private
4576
4516
  */
4577
- Active.prototype.componentDeactivationHandlers;
4517
+ AbstractNavigationTransition.prototype.componentDeactivationHandlers;
4578
4518
  /**
4579
4519
  * @type {?}
4580
4520
  * @private
4581
4521
  */
4582
- Active.prototype._interactionContext;
4522
+ AbstractNavigationTransition.prototype._interactionContext;
4583
4523
  /** @type {?} */
4584
- Active.prototype.isPopState;
4585
- /** @type {?} */
4586
- Active.prototype.startingUrl;
4524
+ AbstractNavigationTransition.prototype.startingUrl;
4587
4525
  }
4588
- var ModalInteractionSession = /** @class */ (function (_super) {
4589
- __extends(ModalInteractionSession, _super);
4590
- function ModalInteractionSession(context, startingUrl) {
4591
- var _this = _super.call(this, context) || this;
4592
- _this.startingUrl = startingUrl;
4593
- _this.active = false;
4526
+ var NavigationTransition = /** @class */ (function (_super) {
4527
+ __extends(NavigationTransition, _super);
4528
+ function NavigationTransition() {
4529
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4594
4530
  _this.isPopState = false;
4595
4531
  return _this;
4596
4532
  }
4597
4533
  /**
4598
- * @param {?} url
4534
+ * @param {?} event
4599
4535
  * @return {?}
4600
4536
  */
4601
- ModalInteractionSession.hasInteraction = /**
4602
- * @param {?} url
4537
+ NavigationTransition.prototype.onRouterCancelled = /**
4538
+ * @param {?} event
4603
4539
  * @return {?}
4604
4540
  */
4605
- function (url) {
4606
- return url.endsWith('(aup-interaction:modal)');
4541
+ function (event) {
4542
+ return this;
4607
4543
  };
4608
4544
  /**
4609
4545
  * @param {?} event
4610
4546
  * @return {?}
4611
4547
  */
4612
- ModalInteractionSession.prototype.onStart = /**
4548
+ NavigationTransition.prototype.onRouterError = /**
4613
4549
  * @param {?} event
4614
4550
  * @return {?}
4615
4551
  */
4616
4552
  function (event) {
4617
- // VERY VERY IMPORTANT BACK BUTTON NOTE:
4618
- // When the back button is clicked we'll enter here first, and push the url
4619
- // back to the browser. Angular seems to ignore it from a routing perspective
4620
- // and then the InteractionGuard will cancel the navigation. This process seems
4621
- // to keep the brower history in a sane state.
4622
- if (this.context.modalInteractionService.isActive()) {
4623
- if (!ModalInteractionSession.hasInteraction(event.url)) {
4624
- // this capture the case where
4625
- this.updateLocation(this.startingUrl);
4626
- }
4627
- }
4628
- return this;
4553
+ // navigation was aborted.
4554
+ return new Idle(this.context);
4555
+ };
4556
+ /**
4557
+ * @return {?}
4558
+ */
4559
+ NavigationTransition.prototype.toString = /**
4560
+ * @return {?}
4561
+ */
4562
+ function () {
4563
+ return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4629
4564
  };
4565
+ return NavigationTransition;
4566
+ }(AbstractNavigationTransition));
4567
+ NavigationState.NavigationTransition = NavigationTransition;
4568
+ if (false) {
4569
+ /** @type {?} */
4570
+ NavigationTransition.prototype.isPopState;
4571
+ }
4572
+ var PopStateTransition = /** @class */ (function (_super) {
4573
+ __extends(PopStateTransition, _super);
4574
+ function PopStateTransition() {
4575
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4576
+ _this.isPopState = true;
4577
+ return _this;
4578
+ }
4630
4579
  /**
4631
4580
  * @param {?} event
4632
4581
  * @return {?}
4633
4582
  */
4634
- ModalInteractionSession.prototype.onCancel = /**
4583
+ PopStateTransition.prototype.onRouterCancelled = /**
4635
4584
  * @param {?} event
4636
4585
  * @return {?}
4637
4586
  */
4638
4587
  function (event) {
4639
- // this.updateLocation(this.startingUrl);
4640
- return this;
4588
+ // Angular doesn't preserve the url when a guard cancels the back button.
4589
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4590
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4591
+ this.resetBrowserLocation(this.startingUrl);
4592
+ return new Idle(this.context);
4641
4593
  };
4642
4594
  /**
4643
4595
  * @param {?} event
4644
4596
  * @return {?}
4645
4597
  */
4646
- ModalInteractionSession.prototype.onEnd = /**
4598
+ PopStateTransition.prototype.onRouterError = /**
4647
4599
  * @param {?} event
4648
4600
  * @return {?}
4649
4601
  */
4650
4602
  function (event) {
4651
- if (this.context.modalInteractionService.isActive()) {
4652
- return this;
4653
- }
4654
- else {
4655
- return new Idle(this.context);
4603
+ // navigation was aborted.
4604
+ if (this.currentRouterUrl() !== this.startingUrl) {
4605
+ // Angular doesn't preserve the url when a guard cancels the back button.
4606
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4607
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4608
+ this.resetBrowserLocation(this.startingUrl);
4656
4609
  }
4610
+ return new Idle(this.context);
4611
+ };
4612
+ return PopStateTransition;
4613
+ }(AbstractNavigationTransition));
4614
+ NavigationState.PopStateTransition = PopStateTransition;
4615
+ if (false) {
4616
+ /** @type {?} */
4617
+ PopStateTransition.prototype.isPopState;
4618
+ }
4619
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4620
+ __extends(IdleDuringInteraction, _super);
4621
+ function IdleDuringInteraction(context, startingUrl) {
4622
+ var _this = _super.call(this, context) || this;
4623
+ _this.startingUrl = startingUrl;
4624
+ _this.isTransitional = false;
4625
+ _this.isPopState = false;
4626
+ return _this;
4627
+ }
4628
+ /**
4629
+ * @param {?} visit
4630
+ * @param {?} initialUrl
4631
+ * @return {?}
4632
+ */
4633
+ IdleDuringInteraction.prototype.onPlaceNavigationStart = /**
4634
+ * @param {?} visit
4635
+ * @param {?} initialUrl
4636
+ * @return {?}
4637
+ */
4638
+ function (visit, initialUrl) {
4639
+ /** @type {?} */
4640
+ var navigationTransition = new InteractionTransition(this.context, initialUrl);
4641
+ navigationTransition.storeVisit(visit);
4642
+ return navigationTransition;
4657
4643
  };
4658
4644
  /**
4659
4645
  * @param {?} event
4660
4646
  * @return {?}
4661
4647
  */
4662
- ModalInteractionSession.prototype.onError = /**
4648
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4663
4649
  * @param {?} event
4664
4650
  * @return {?}
4665
4651
  */
4666
4652
  function (event) {
4667
- return this.illegalTransition(event);
4653
+ return new InteractionTransition(this.context, event.url);
4668
4654
  };
4669
4655
  /**
4670
- * @param {?} component
4671
- * @param {?} nextState
4656
+ * @param {?} event
4672
4657
  * @return {?}
4673
4658
  */
4674
- ModalInteractionSession.prototype.canDeactivatePlace = /**
4675
- * @param {?} component
4676
- * @param {?} nextState
4659
+ IdleDuringInteraction.prototype.onPopState = /**
4660
+ * @param {?} event
4677
4661
  * @return {?}
4678
4662
  */
4679
- function (component, nextState) {
4680
- return __awaiter(this, void 0, void 0, function () {
4681
- return __generator(this, function (_a) {
4682
- return [2 /*return*/, true];
4683
- });
4684
- });
4663
+ function (event) {
4664
+ return new InteractionPopStateTransition(this.context, event.url);
4685
4665
  };
4686
4666
  __decorate([
4687
4667
  pectin.Trace(),
4688
4668
  __metadata("design:type", Function),
4689
4669
  __metadata("design:paramtypes", [router.NavigationStart]),
4690
4670
  __metadata("design:returntype", NavigationState)
4691
- ], ModalInteractionSession.prototype, "onStart", null);
4692
- __decorate([
4693
- pectin.Trace(),
4694
- __metadata("design:type", Function),
4695
- __metadata("design:paramtypes", [router.NavigationCancel]),
4696
- __metadata("design:returntype", NavigationState)
4697
- ], ModalInteractionSession.prototype, "onCancel", null);
4671
+ ], IdleDuringInteraction.prototype, "onRouterStarted", null);
4698
4672
  __decorate([
4699
4673
  pectin.Trace(),
4700
4674
  __metadata("design:type", Function),
4701
- __metadata("design:paramtypes", [router.NavigationEnd]),
4675
+ __metadata("design:paramtypes", [router.NavigationStart]),
4702
4676
  __metadata("design:returntype", NavigationState)
4703
- ], ModalInteractionSession.prototype, "onEnd", null);
4704
- return ModalInteractionSession;
4677
+ ], IdleDuringInteraction.prototype, "onPopState", null);
4678
+ return IdleDuringInteraction;
4705
4679
  }(NavigationState));
4706
- NavigationState.ModalInteractionSession = ModalInteractionSession;
4680
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4681
+ if (false) {
4682
+ /** @type {?} */
4683
+ IdleDuringInteraction.prototype.isTransitional;
4684
+ /** @type {?} */
4685
+ IdleDuringInteraction.prototype.isPopState;
4686
+ /** @type {?} */
4687
+ IdleDuringInteraction.prototype.startingUrl;
4688
+ }
4689
+ /**
4690
+ * @abstract
4691
+ */
4692
+ var /**
4693
+ * @abstract
4694
+ */
4695
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4696
+ __extends(AbstractInteractionTransition, _super);
4697
+ function AbstractInteractionTransition(context, startingUrl) {
4698
+ var _this = _super.call(this, context, startingUrl) || this;
4699
+ _this.startingUrl = startingUrl;
4700
+ _this.isTransitional = true;
4701
+ return _this;
4702
+ }
4703
+ return AbstractInteractionTransition;
4704
+ }(AbstractNavigationTransition));
4705
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4707
4706
  if (false) {
4708
4707
  /** @type {?} */
4709
- ModalInteractionSession.prototype.active;
4708
+ AbstractInteractionTransition.prototype.isTransitional;
4709
+ /** @type {?} */
4710
+ AbstractInteractionTransition.prototype.startingUrl;
4711
+ }
4712
+ /**
4713
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4714
+ * happily ignore interaction contexts.
4715
+ */
4716
+ var /**
4717
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4718
+ * happily ignore interaction contexts.
4719
+ */
4720
+ InteractionTransition = /** @class */ (function (_super) {
4721
+ __extends(InteractionTransition, _super);
4722
+ function InteractionTransition() {
4723
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4724
+ _this.isPopState = false;
4725
+ return _this;
4726
+ }
4727
+ /**
4728
+ * @param {?} event
4729
+ * @return {?}
4730
+ */
4731
+ InteractionTransition.prototype.onRouterCancelled = /**
4732
+ * @param {?} event
4733
+ * @return {?}
4734
+ */
4735
+ function (event) {
4736
+ if (this.context.interactionService.isActive()) {
4737
+ /** @type {?} */
4738
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4739
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4740
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4741
+ }
4742
+ else {
4743
+ return new Idle(this.context);
4744
+ }
4745
+ };
4746
+ /**
4747
+ * @param {?} event
4748
+ * @return {?}
4749
+ */
4750
+ InteractionTransition.prototype.onRouterError = /**
4751
+ * @param {?} event
4752
+ * @return {?}
4753
+ */
4754
+ function (event) {
4755
+ // navigation was aborted.
4756
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4757
+ };
4758
+ /**
4759
+ * @param {?} event
4760
+ * @return {?}
4761
+ */
4762
+ InteractionTransition.prototype.onRouterEnd = /**
4763
+ * @param {?} event
4764
+ * @return {?}
4765
+ */
4766
+ function (event) {
4767
+ if (this.context.interactionService.isActive()) {
4768
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4769
+ }
4770
+ else {
4771
+ return new Idle(this.context);
4772
+ }
4773
+ };
4774
+ return InteractionTransition;
4775
+ }(AbstractInteractionTransition));
4776
+ NavigationState.InteractionTransition = InteractionTransition;
4777
+ if (false) {
4710
4778
  /** @type {?} */
4711
- ModalInteractionSession.prototype.isPopState;
4779
+ InteractionTransition.prototype.isPopState;
4780
+ }
4781
+ /**
4782
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4783
+ * happily ignore interaction contexts.
4784
+ */
4785
+ var /**
4786
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4787
+ * happily ignore interaction contexts.
4788
+ */
4789
+ InteractionPopStateTransition = /** @class */ (function (_super) {
4790
+ __extends(InteractionPopStateTransition, _super);
4791
+ function InteractionPopStateTransition() {
4792
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4793
+ _this.isPopState = true;
4794
+ return _this;
4795
+ }
4796
+ /**
4797
+ * @param {?} event
4798
+ * @return {?}
4799
+ */
4800
+ InteractionPopStateTransition.prototype.onRouterCancelled = /**
4801
+ * @param {?} event
4802
+ * @return {?}
4803
+ */
4804
+ function (event) {
4805
+ if (this.interactionService.isActive()) {
4806
+ /** @type {?} */
4807
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4808
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4809
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4810
+ }
4811
+ else {
4812
+ return new Idle(this.context);
4813
+ }
4814
+ };
4815
+ /**
4816
+ * @param {?} event
4817
+ * @return {?}
4818
+ */
4819
+ InteractionPopStateTransition.prototype.onRouterEnd = /**
4820
+ * @param {?} event
4821
+ * @return {?}
4822
+ */
4823
+ function (event) {
4824
+ if (this.context.interactionService.isActive()) {
4825
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4826
+ }
4827
+ else {
4828
+ return new Idle(this.context);
4829
+ }
4830
+ };
4831
+ return InteractionPopStateTransition;
4832
+ }(AbstractInteractionTransition));
4833
+ NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4834
+ if (false) {
4712
4835
  /** @type {?} */
4713
- ModalInteractionSession.prototype.startingUrl;
4836
+ InteractionPopStateTransition.prototype.isPopState;
4714
4837
  }
4715
4838
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4716
4839
  __extends(CancelledDuringNavigationInteraction, _super);
4717
- function CancelledDuringNavigationInteraction(context, startingUrl, locationChangeTriggerUrl) {
4840
+ function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
4718
4841
  var _this = _super.call(this, context) || this;
4719
4842
  _this.startingUrl = startingUrl;
4843
+ _this.startingEventWasAPopState = startingEventWasAPopState;
4720
4844
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4721
- _this.active = false;
4722
- _this.capturedFauxRouterStart = false;
4845
+ _this.isPopState = false;
4846
+ _this.gotPopStateWithLeavingUrl = false;
4723
4847
  return _this;
4724
- // This will trigger a return to the route we originally started with.
4725
- // this.angularLocation.go(this.startingUrl);
4726
4848
  }
4849
+ Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
4850
+ get: /**
4851
+ * @return {?}
4852
+ */
4853
+ function () {
4854
+ return true;
4855
+ },
4856
+ enumerable: true,
4857
+ configurable: true
4858
+ });
4727
4859
  /**
4728
- * @param {?} component
4729
- * @param {?} nextState
4860
+ * @param {?} event
4730
4861
  * @return {?}
4731
4862
  */
4732
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace = /**
4733
- * @param {?} component
4734
- * @param {?} nextState
4863
+ CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
4864
+ * @param {?} event
4735
4865
  * @return {?}
4736
4866
  */
4737
- function (component, nextState) {
4738
- return __awaiter(this, void 0, void 0, function () {
4739
- return __generator(this, function (_a) {
4740
- return [2 /*return*/, false];
4741
- });
4742
- });
4867
+ function (event) {
4868
+ return this.ignore(event);
4743
4869
  };
4744
4870
  /**
4745
4871
  * @param {?} event
4746
4872
  * @return {?}
4747
4873
  */
4748
- CancelledDuringNavigationInteraction.prototype.onCancel = /**
4874
+ CancelledDuringNavigationInteraction.prototype.onRouterCancelled = /**
4749
4875
  * @param {?} event
4750
4876
  * @return {?}
4751
4877
  */
4752
4878
  function (event) {
4753
- return this.ignore(event);
4879
+ // Depending on the state of the router and what was done we get a different
4880
+ // sequence of events. I.e. If they just clicked a link we'll get a cancel
4881
+ // with the locationChangeTriggerUrl as the final event. However the user
4882
+ // started the initial navigation with a pop state then we'll get one of
4883
+ // those with the locationChangeTriggerUrl but no cancel event with it.
4884
+ return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4754
4885
  };
4755
4886
  /**
4756
4887
  * @param {?} event
4757
4888
  * @return {?}
4758
4889
  */
4759
- CancelledDuringNavigationInteraction.prototype.onEnd = /**
4890
+ CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
4760
4891
  * @param {?} event
4761
4892
  * @return {?}
4762
4893
  */
@@ -4767,7 +4898,7 @@
4767
4898
  * @param {?} event
4768
4899
  * @return {?}
4769
4900
  */
4770
- CancelledDuringNavigationInteraction.prototype.onError = /**
4901
+ CancelledDuringNavigationInteraction.prototype.onRouterError = /**
4771
4902
  * @param {?} event
4772
4903
  * @return {?}
4773
4904
  */
@@ -4778,18 +4909,36 @@
4778
4909
  * @param {?} event
4779
4910
  * @return {?}
4780
4911
  */
4781
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4912
+ CancelledDuringNavigationInteraction.prototype.onPopState = /**
4782
4913
  * @param {?} event
4783
4914
  * @return {?}
4784
4915
  */
4785
4916
  function (event) {
4786
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4787
- this.capturedFauxRouterStart = true;
4788
- return this.ignore(event, 'url matched back button location change');
4789
- }
4790
- else {
4791
- return this.createActiveSession(event);
4792
- }
4917
+ this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
4918
+ return this.ignore(event);
4919
+ };
4920
+ // @Trace()
4921
+ // @Trace()
4922
+ /**
4923
+ * @param {?} component
4924
+ * @param {?} currentUrl
4925
+ * @param {?} nextUrl
4926
+ * @return {?}
4927
+ */
4928
+ CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4929
+ // @Trace()
4930
+ /**
4931
+ * @param {?} component
4932
+ * @param {?} currentUrl
4933
+ * @param {?} nextUrl
4934
+ * @return {?}
4935
+ */
4936
+ function (component, currentUrl, nextUrl) {
4937
+ return __awaiter(this, void 0, void 0, function () {
4938
+ return __generator(this, function (_a) {
4939
+ return [2 /*return*/, false];
4940
+ });
4941
+ });
4793
4942
  };
4794
4943
  /**
4795
4944
  * @param {?} event
@@ -4802,7 +4951,7 @@
4802
4951
  * @return {?}
4803
4952
  */
4804
4953
  function (event, reason) {
4805
- reason = reason ? " (" + reason + ")" : '';
4954
+ reason = reason ? " -> " + reason : '';
4806
4955
  pectin.Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4807
4956
  return this;
4808
4957
  };
@@ -4813,24 +4962,30 @@
4813
4962
  * @return {?}
4814
4963
  */
4815
4964
  function () {
4816
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4965
+ return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4817
4966
  };
4967
+ __decorate([
4968
+ pectin.Trace(),
4969
+ __metadata("design:type", Function),
4970
+ __metadata("design:paramtypes", [router.NavigationCancel]),
4971
+ __metadata("design:returntype", NavigationState)
4972
+ ], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
4818
4973
  return CancelledDuringNavigationInteraction;
4819
4974
  }(NavigationState));
4820
4975
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4821
4976
  if (false) {
4822
- /** @type {?} */
4823
- CancelledDuringNavigationInteraction.prototype.active;
4824
4977
  /** @type {?} */
4825
4978
  CancelledDuringNavigationInteraction.prototype.isPopState;
4826
4979
  /**
4827
4980
  * @type {?}
4828
4981
  * @private
4829
4982
  */
4830
- CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
4983
+ CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
4831
4984
  /** @type {?} */
4832
4985
  CancelledDuringNavigationInteraction.prototype.startingUrl;
4833
4986
  /** @type {?} */
4987
+ CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
4988
+ /** @type {?} */
4834
4989
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4835
4990
  }
4836
4991
  })(exports.NavigationState || (exports.NavigationState = {}));
@@ -4919,20 +5074,14 @@
4919
5074
  * @fileoverview added by tsickle
4920
5075
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4921
5076
  */
4922
- var UrlSnapshot = /** @class */ (function () {
4923
- function UrlSnapshot(urlTree) {
4924
- this.urlTree = urlTree;
4925
- // console.log({ segments: this.urlTree.root.children.primary.segments });
5077
+ exports.UrlSnapshot = /** @class */ (function () {
5078
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
5079
+ function UrlSnapshot(urlSerializer, url, options) {
5080
+ this.urlSerializer = urlSerializer;
5081
+ this.url = url;
5082
+ this.options = options;
5083
+ this.urlTree = urlSerializer.parse(url);
4926
5084
  }
4927
- /**
4928
- * @return {?}
4929
- */
4930
- UrlSnapshot.prototype.cloneUrlSegmentList = /**
4931
- * @return {?}
4932
- */
4933
- function () {
4934
- return __spread(this.urlTree.root.children.primary.segments);
4935
- };
4936
5085
  /**
4937
5086
  * @param {?} visit
4938
5087
  * @return {?}
@@ -4942,11 +5091,13 @@
4942
5091
  * @return {?}
4943
5092
  */
4944
5093
  function (visit) {
5094
+ /** @type {?} */
5095
+ var urlTree = this.urlSerializer.parse(this.url);
4945
5096
  // Ugly, but it works for now.
4946
5097
  /** @type {?} */
4947
- var segments = this.cloneUrlSegmentList();
5098
+ var segments = __spread(this.getPrimarySegments(urlTree));
4948
5099
  /** @type {?} */
4949
- var visitSegments = this.convertToUrlSegments(visit);
5100
+ var visitSegments = this.getSegmentsFor(visit);
4950
5101
  /** @type {?} */
4951
5102
  var replaceAt = segments.findIndex((/**
4952
5103
  * @param {?} segment
@@ -4955,7 +5106,21 @@
4955
5106
  function (segment) { return segment.path === visitSegments[0].path; }));
4956
5107
  // do not use the return value, it's the items that were removed!
4957
5108
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4958
- return segments;
5109
+ urlTree.root.children.primary.segments = segments;
5110
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5111
+ };
5112
+ /**
5113
+ * @private
5114
+ * @param {?} urlTree
5115
+ * @return {?}
5116
+ */
5117
+ UrlSnapshot.prototype.getPrimarySegments = /**
5118
+ * @private
5119
+ * @param {?} urlTree
5120
+ * @return {?}
5121
+ */
5122
+ function (urlTree) {
5123
+ return this.urlTree.root.children.primary.segments;
4959
5124
  };
4960
5125
  /**
4961
5126
  * Converts the visit into segments. Please not that these segments are not e
@@ -4963,11 +5128,13 @@
4963
5128
  */
4964
5129
  /**
4965
5130
  * Converts the visit into segments. Please not that these segments are not e
5131
+ * @protected
4966
5132
  * @param {?} visit
4967
5133
  * @return {?}
4968
5134
  */
4969
- UrlSnapshot.prototype.convertToUrlSegments = /**
5135
+ UrlSnapshot.prototype.getSegmentsFor = /**
4970
5136
  * Converts the visit into segments. Please not that these segments are not e
5137
+ * @protected
4971
5138
  * @param {?} visit
4972
5139
  * @return {?}
4973
5140
  */
@@ -4986,79 +5153,182 @@
4986
5153
  ];
4987
5154
  };
4988
5155
  /**
4989
- * @param {?} visit
5156
+ * @param {?} placeDef
4990
5157
  * @return {?}
4991
5158
  */
4992
- UrlSnapshot.prototype.createRedirectCommandsFor = /**
4993
- * @param {?} visit
5159
+ UrlSnapshot.prototype.includesPathOf = /**
5160
+ * @param {?} placeDef
4994
5161
  * @return {?}
4995
5162
  */
4996
- function (visit) {
4997
- /** @type {?} */
4998
- var segments = this.updateVisitSegments(visit);
4999
- /** @type {?} */
5000
- var commands = [];
5001
- segments.forEach((/**
5163
+ function (placeDef) {
5164
+ return this.getPrimarySegments(this.urlTree).find((/**
5002
5165
  * @param {?} s
5003
5166
  * @return {?}
5004
5167
  */
5005
- function (s) {
5006
- commands.push(s.path);
5007
- if (s.parameterMap.keys.length > 0) {
5008
- commands.push(s.parameters);
5009
- }
5010
- }));
5011
- return commands;
5168
+ function (s) { return s.path === placeDef.path; }));
5012
5169
  };
5013
5170
  /**
5014
- * @param {?} placeDef
5015
5171
  * @return {?}
5016
5172
  */
5017
- UrlSnapshot.prototype.includesPathOf = /**
5018
- * @param {?} placeDef
5173
+ UrlSnapshot.prototype.getInteractionIds = /**
5019
5174
  * @return {?}
5020
5175
  */
5021
- function (placeDef) {
5022
- return this.cloneUrlSegmentList().find((/**
5023
- * @param {?} s
5024
- * @return {?}
5025
- */
5026
- function (s) { return s.path === placeDef.path; }));
5176
+ function () {
5177
+ /** @type {?} */
5178
+ var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
5179
+ if (queryParam) {
5180
+ return UrlSnapshot.parseInteractionIds(queryParam);
5181
+ }
5182
+ else {
5183
+ return [];
5184
+ }
5185
+ };
5186
+ /**
5187
+ * @return {?}
5188
+ */
5189
+ UrlSnapshot.prototype.hasInteractionIds = /**
5190
+ * @return {?}
5191
+ */
5192
+ function () {
5193
+ return this.getInteractionIds().length > 0;
5194
+ };
5195
+ // @Trace()
5196
+ // @Trace()
5197
+ /**
5198
+ * @param {?} ids
5199
+ * @return {?}
5200
+ */
5201
+ UrlSnapshot.prototype.updateInteractionIds =
5202
+ // @Trace()
5203
+ /**
5204
+ * @param {?} ids
5205
+ * @return {?}
5206
+ */
5207
+ function (ids) {
5208
+ if (ids.length === 0) {
5209
+ return this.removeInteractionIds();
5210
+ }
5211
+ else {
5212
+ /** @type {?} */
5213
+ var urlTree = this.urlSerializer.parse(this.url);
5214
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
5215
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5216
+ }
5217
+ };
5218
+ // @Trace()
5219
+ // @Trace()
5220
+ /**
5221
+ * @return {?}
5222
+ */
5223
+ UrlSnapshot.prototype.removeInteractionIds =
5224
+ // @Trace()
5225
+ /**
5226
+ * @return {?}
5227
+ */
5228
+ function () {
5229
+ /** @type {?} */
5230
+ var urlTree = this.urlSerializer.parse(this.url);
5231
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
5232
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
5233
+ }
5234
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5235
+ };
5236
+ /**
5237
+ * @param {?} options
5238
+ * @return {?}
5239
+ */
5240
+ UrlSnapshot.prototype.withOptions = /**
5241
+ * @param {?} options
5242
+ * @return {?}
5243
+ */
5244
+ function (options) {
5245
+ return new UrlSnapshot(this.urlSerializer, this.url, options);
5246
+ };
5247
+ /**
5248
+ * @return {?}
5249
+ */
5250
+ UrlSnapshot.prototype.getNavigationExtras = /**
5251
+ * @return {?}
5252
+ */
5253
+ function () {
5254
+ return this.options;
5027
5255
  };
5028
5256
  return UrlSnapshot;
5029
5257
  }());
5030
5258
  if (false) {
5031
5259
  /** @type {?} */
5032
- UrlSnapshot.prototype.urlTree;
5260
+ exports.UrlSnapshot.prototype.urlTree;
5261
+ /** @type {?} */
5262
+ exports.UrlSnapshot.prototype.urlSerializer;
5263
+ /** @type {?} */
5264
+ exports.UrlSnapshot.prototype.url;
5265
+ /**
5266
+ * @type {?}
5267
+ * @private
5268
+ */
5269
+ exports.UrlSnapshot.prototype.options;
5033
5270
  }
5271
+ (function (UrlSnapshot) {
5272
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
5273
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
5274
+ /**
5275
+ * @param {?} path
5276
+ * @return {?}
5277
+ */
5278
+ function parseInteractionIds(path) {
5279
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
5280
+ }
5281
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
5282
+ /**
5283
+ * @param {?} interactionIds
5284
+ * @return {?}
5285
+ */
5286
+ function createPathIdFor(interactionIds) {
5287
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
5288
+ }
5289
+ UrlSnapshot.createPathIdFor = createPathIdFor;
5290
+ /**
5291
+ * @record
5292
+ */
5293
+ function NavigationOptions() { }
5294
+ UrlSnapshot.NavigationOptions = NavigationOptions;
5295
+ if (false) {
5296
+ /** @type {?|undefined} */
5297
+ NavigationOptions.prototype.replaceUrl;
5298
+ }
5299
+ })(exports.UrlSnapshot || (exports.UrlSnapshot = {}));
5034
5300
 
5035
5301
  /**
5036
5302
  * @fileoverview added by tsickle
5037
5303
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
5038
5304
  */
5039
- exports.ɵt = /** @class */ (function (_super) {
5305
+ var PlaceRouter = /** @class */ (function (_super) {
5040
5306
  __extends(PlaceRouter, _super);
5041
- function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
5307
+ function PlaceRouter(router$1, urlSerializer, angularLocation, placeHistory, interactionService) {
5042
5308
  var _this = _super.call(this) || this;
5043
5309
  _this.router = router$1;
5044
5310
  _this.urlSerializer = urlSerializer;
5045
5311
  _this.angularLocation = angularLocation;
5046
5312
  _this.placeHistory = placeHistory;
5047
- _this.modalInteractionService = modalInteractionService;
5048
- _this.firstRoute = true;
5049
- _this._navigationSessionModel = new pectin.MutableValueModel();
5313
+ _this.interactionService = interactionService;
5314
+ _this._navigationStateModel = new pectin.MutableValueModel();
5050
5315
  _this._activeVisits = new pectin.MutableListModel();
5051
5316
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
5052
5317
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
5053
- _this.navigationSessionActive = chain(_this.navigationSessionModel).pluck('active');
5054
- _this._navigationSessionContext = new exports.NavigationState.Context(_this.router, _this.modalInteractionService, _this.angularLocation, (/**
5318
+ _this.navigationInProgress = chain(_this.navigationStateModel).pluck('isTransitional');
5319
+ _this._navigationSessionContext = new exports.NavigationState.Context(_this, _this.interactionService, (/**
5055
5320
  * @param {?} session
5056
5321
  * @return {?}
5057
5322
  */
5058
5323
  function (session) {
5059
5324
  _this.processNavigationSuccess(session);
5060
5325
  }));
5061
- _this._navigationSessionModel.value = new exports.NavigationState.Idle(_this._navigationSessionContext);
5326
+ _this._navigationStateModel.value = new exports.NavigationState.Idle(_this._navigationSessionContext);
5327
+ _this._navigationStateTypeModel = chain(_this._navigationStateModel).map((/**
5328
+ * @param {?} state
5329
+ * @return {?}
5330
+ */
5331
+ function (state) { return (/** @type {?} */ (state.constructor)); }));
5062
5332
  // TODO: make setup the callbacks in during module initiation to make this testable.
5063
5333
  _this.router.events.subscribe((/**
5064
5334
  * @param {?} event
@@ -5072,53 +5342,83 @@
5072
5342
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
5073
5343
  // =======================
5074
5344
  if (event instanceof router.NavigationStart) {
5075
- _this.runStateTransition((/**
5076
- * @param {?} session
5077
- * @return {?}
5078
- */
5079
- function (session) { return session.onStart(event); }));
5345
+ if (event.navigationTrigger === 'popstate') {
5346
+ _this.runStateTransition((/**
5347
+ * @param {?} state
5348
+ * @return {?}
5349
+ */
5350
+ function (state) { return state.onPopState(event); }));
5351
+ }
5352
+ else {
5353
+ _this.runStateTransition((/**
5354
+ * @param {?} state
5355
+ * @return {?}
5356
+ */
5357
+ function (state) { return state.onRouterStarted(event); }));
5358
+ }
5080
5359
  }
5081
5360
  if (event instanceof router.NavigationEnd) {
5361
+ console.log(event);
5082
5362
  _this.runStateTransition((/**
5083
- * @param {?} session
5363
+ * @param {?} state
5084
5364
  * @return {?}
5085
5365
  */
5086
- function (session) { return session.onEnd(event); }));
5366
+ function (state) { return state.onRouterEnd(event); }));
5087
5367
  }
5088
5368
  if (event instanceof router.NavigationError) {
5369
+ console.log(event);
5089
5370
  _this.runStateTransition((/**
5090
- * @param {?} session
5371
+ * @param {?} state
5091
5372
  * @return {?}
5092
5373
  */
5093
- function (session) { return session.onError(event); }));
5374
+ function (state) { return state.onRouterError(event); }));
5094
5375
  }
5095
5376
  if (event instanceof router.NavigationCancel) {
5377
+ console.log(event);
5096
5378
  _this.runStateTransition((/**
5097
- * @param {?} session
5379
+ * @param {?} state
5098
5380
  * @return {?}
5099
5381
  */
5100
- function (session) { return session.onCancel(event); }));
5382
+ function (state) { return state.onRouterCancelled(event); }));
5101
5383
  }
5102
5384
  }));
5103
5385
  // Push dialog state to the url so we can capture the back button.
5104
- _this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(_this.navigationSessionActive, _this.router));
5386
+ when.listOf(_this.interactionService.activeInteractionContextIds).changes((/**
5387
+ * @param {?} ids
5388
+ * @param {?} previous
5389
+ * @return {?}
5390
+ */
5391
+ function (ids, previous) {
5392
+ _this.syncInteractionIdsWithRouter();
5393
+ }), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5394
+ // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
5395
+ /** @type {?} */
5396
+ var urlChanges = new pectin.MutableStream();
5105
5397
  // The angular router doesn't always fire router events when the back button is pushed while a navigation
5106
5398
  // session is in progress. Sometimes we only know about it from the url change.
5399
+ // IMPORTANT ORDER DEPENDENCY
5400
+ // This only works because we're notified of the change after the router has started reacting to it. This
5401
+ // we can can use our navigationState to determine things.
5107
5402
  angularLocation.onUrlChange((/**
5108
5403
  * @param {?} url
5109
5404
  * @return {?}
5110
5405
  */
5111
5406
  function (url) {
5112
- console.log("#### url changed ->", { url: url, navIsActive: _this.navigationSessionActive.value });
5113
5407
  /** @type {?} */
5114
- var interactionContext = _this.navigationSessionActive.value && _this.navigationSession.interactionContext;
5115
- if (interactionContext && interactionContext.isActive()) {
5116
- pectin.Logger.get(_this).info("back button pressed during navigation session interaction");
5117
- _this.runStateTransition((/**
5118
- * @param {?} navigationSession
5119
- * @return {?}
5120
- */
5121
- function (navigationSession) { return navigationSession.onBackClickedDuringNavigationInteraction(url); }));
5408
+ var navigationState = _this._navigationStateModel.value;
5409
+ console.log("URLChange -> " + url, { state: navigationState });
5410
+ urlChanges.publish({ url: url, state: navigationState });
5411
+ // The url has changed while we're in a transitional state
5412
+ if (navigationState.isTransitional) {
5413
+ /** @type {?} */
5414
+ var navigationInteraction = _this.navigationState.interactionContext;
5415
+ if (navigationInteraction && navigationInteraction.isActive()) {
5416
+ _this.runStateTransition((/**
5417
+ * @param {?} state
5418
+ * @return {?}
5419
+ */
5420
+ function (state) { return state.onBackClickedDuringNavigationInteraction(url); }));
5421
+ }
5122
5422
  }
5123
5423
  }));
5124
5424
  return _this;
@@ -5137,7 +5437,7 @@
5137
5437
  var _this = this;
5138
5438
  // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
5139
5439
  // changes that occur while routerNavigationActive is true.
5140
- pectin.assert.isTruthy(this.navigationSessionActive.value);
5440
+ pectin.assert.isTruthy(this.navigationInProgress.value);
5141
5441
  /** @type {?} */
5142
5442
  var visits = session.getVisits();
5143
5443
  visits.forEach((/**
@@ -5147,22 +5447,22 @@
5147
5447
  function (v) { return _this.placeHistory.add(v); }));
5148
5448
  this._activeVisits.value = visits;
5149
5449
  };
5150
- Object.defineProperty(PlaceRouter.prototype, "navigationSession", {
5450
+ Object.defineProperty(PlaceRouter.prototype, "navigationState", {
5151
5451
  get: /**
5152
5452
  * @return {?}
5153
5453
  */
5154
5454
  function () {
5155
- return this._navigationSessionModel.value;
5455
+ return this._navigationStateModel.value;
5156
5456
  },
5157
5457
  enumerable: true,
5158
5458
  configurable: true
5159
5459
  });
5160
- Object.defineProperty(PlaceRouter.prototype, "navigationSessionModel", {
5460
+ Object.defineProperty(PlaceRouter.prototype, "navigationStateModel", {
5161
5461
  get: /**
5162
5462
  * @return {?}
5163
5463
  */
5164
5464
  function () {
5165
- return this._navigationSessionModel.readonly;
5465
+ return this._navigationStateModel.readonly;
5166
5466
  },
5167
5467
  enumerable: true,
5168
5468
  configurable: true
@@ -5253,9 +5553,9 @@
5253
5553
  */
5254
5554
  function (router) {
5255
5555
  /** @type {?} */
5256
- var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
5257
- console.log('### Push Changes to route Redirect', { commands: commands });
5258
- return router.navigate(commands);
5556
+ var urlSnapshot = _this.parseUrl(_this.router.routerState.snapshot.url).updateVisitSegments(next);
5557
+ console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
5558
+ return _this.navigateByUrl(urlSnapshot);
5259
5559
  }))];
5260
5560
  }
5261
5561
  return [2 /*return*/];
@@ -5278,7 +5578,7 @@
5278
5578
  return __generator(this, function (_a) {
5279
5579
  switch (_a.label) {
5280
5580
  case 0:
5281
- if (this.navigationSessionActive.value) {
5581
+ if (this.navigationInProgress.value) {
5282
5582
  pectin.lang.illegalState('Navigation already in progress');
5283
5583
  }
5284
5584
  this.runStateTransition((/**
@@ -5287,7 +5587,7 @@
5287
5587
  */
5288
5588
  function (current) {
5289
5589
  /** @type {?} */
5290
- var session = new exports.NavigationState.Active(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5590
+ var session = _this.navigationState.onPlaceNavigationStart(visit, _this.getCurrentRouterUrl());
5291
5591
  session.storeVisit(visit);
5292
5592
  return session;
5293
5593
  }));
@@ -5301,12 +5601,12 @@
5301
5601
  case 3:
5302
5602
  // Router has finished (since there was no router change required) so we
5303
5603
  // need to end the navigation session.
5304
- if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
5604
+ if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {
5305
5605
  this.runStateTransition((/**
5306
5606
  * @param {?} session
5307
5607
  * @return {?}
5308
5608
  */
5309
- function (session) { return session.onEnd(new router.NavigationEnd(-1, '', '')); }));
5609
+ function (session) { return session.onRouterEnd(new router.NavigationEnd(-1, '', '')); }));
5310
5610
  }
5311
5611
  return [7 /*endfinally*/];
5312
5612
  case 4: return [2 /*return*/];
@@ -5314,22 +5614,26 @@
5314
5614
  });
5315
5615
  });
5316
5616
  };
5617
+ // @Trace()
5618
+ // @Trace()
5317
5619
  /**
5318
5620
  * @protected
5319
5621
  * @param {?} transition
5320
5622
  * @return {?}
5321
5623
  */
5322
- PlaceRouter.prototype.runStateTransition = /**
5624
+ PlaceRouter.prototype.runStateTransition =
5625
+ // @Trace()
5626
+ /**
5323
5627
  * @protected
5324
5628
  * @param {?} transition
5325
5629
  * @return {?}
5326
5630
  */
5327
5631
  function (transition) {
5328
5632
  /** @type {?} */
5329
- var previous = this._navigationSessionModel.value;
5633
+ var previous = this._navigationStateModel.value;
5330
5634
  /** @type {?} */
5331
- var next = transition(this.navigationSession);
5332
- this._navigationSessionModel.value = next;
5635
+ var next = transition(this.navigationState);
5636
+ this._navigationStateModel.value = next;
5333
5637
  if (next !== previous) {
5334
5638
  previous.dispose();
5335
5639
  pectin.Logger.get(this).info("Router State Transition: " + previous.toString() + " -> " + next.toString());
@@ -5368,15 +5672,114 @@
5368
5672
  function (child) { return child.url; })));
5369
5673
  };
5370
5674
  /**
5371
- * @param {?} snapshot
5675
+ * @param {?} url
5372
5676
  * @return {?}
5373
5677
  */
5374
5678
  PlaceRouter.prototype.parseUrl = /**
5375
- * @param {?} snapshot
5679
+ * @param {?} url
5680
+ * @return {?}
5681
+ */
5682
+ function (url) {
5683
+ return new exports.UrlSnapshot(this.urlSerializer, url, {});
5684
+ };
5685
+ /**
5686
+ * @param {?} url
5687
+ * @return {?}
5688
+ */
5689
+ PlaceRouter.prototype.resetBrowserLocation = /**
5690
+ * @param {?} url
5691
+ * @return {?}
5692
+ */
5693
+ function (url) {
5694
+ this.angularLocation.go(url);
5695
+ };
5696
+ /**
5697
+ * @return {?}
5698
+ */
5699
+ PlaceRouter.prototype.getCurrentRouterUrl = /**
5700
+ * @return {?}
5701
+ */
5702
+ function () {
5703
+ return this.router.routerState ? this.router.routerState.snapshot.url : null;
5704
+ };
5705
+ /**
5706
+ * @return {?}
5707
+ */
5708
+ PlaceRouter.prototype.getCurrentRouteSnapshot = /**
5709
+ * @return {?}
5710
+ */
5711
+ function () {
5712
+ return this.parseUrl(this.getCurrentRouterUrl());
5713
+ };
5714
+ /**
5715
+ * @param {?} url
5716
+ * @return {?}
5717
+ */
5718
+ PlaceRouter.prototype.getActiveInteractionIdsFromUrl = /**
5719
+ * @param {?} url
5720
+ * @return {?}
5721
+ */
5722
+ function (url) {
5723
+ return this.parseUrl(url).getInteractionIds();
5724
+ };
5725
+ // @Trace()
5726
+ // @Trace()
5727
+ /**
5728
+ * @param {?} url
5729
+ * @return {?}
5730
+ */
5731
+ PlaceRouter.prototype.hasActiveInteractionIds =
5732
+ // @Trace()
5733
+ /**
5734
+ * @param {?} url
5735
+ * @return {?}
5736
+ */
5737
+ function (url) {
5738
+ return this.getActiveInteractionIdsFromUrl(url).length > 0;
5739
+ };
5740
+ // @Trace()
5741
+ // @Trace()
5742
+ /**
5743
+ * @param {?} urlSnapshot
5744
+ * @return {?}
5745
+ */
5746
+ PlaceRouter.prototype.navigateByUrl =
5747
+ // @Trace()
5748
+ /**
5749
+ * @param {?} urlSnapshot
5750
+ * @return {?}
5751
+ */
5752
+ function (urlSnapshot) {
5753
+ this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
5754
+ };
5755
+ // @Trace()
5756
+ // @Trace()
5757
+ /**
5758
+ * @return {?}
5759
+ */
5760
+ PlaceRouter.prototype.syncInteractionIdsWithRouter =
5761
+ // @Trace()
5762
+ /**
5376
5763
  * @return {?}
5377
5764
  */
5378
- function (snapshot) {
5379
- return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
5765
+ function () {
5766
+ pectin.assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5767
+ // Updating interaction routes during an existing navigation breaks all the things.
5768
+ /** @type {?} */
5769
+ var currentIds = this.interactionService.activeInteractionContextIds.value;
5770
+ if (___default__default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
5771
+ console.log('activity ids were the same, skipping');
5772
+ }
5773
+ else {
5774
+ if (currentIds.length < 1) {
5775
+ // no more interactions to remove from history.
5776
+ this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
5777
+ }
5778
+ else {
5779
+ // todo was or is...
5780
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
5781
+ }
5782
+ }
5380
5783
  };
5381
5784
  PlaceRouter.decorators = [
5382
5785
  { type: core.Injectable, args: [{
@@ -5389,9 +5792,9 @@
5389
5792
  { type: router.UrlSerializer },
5390
5793
  { type: common.Location },
5391
5794
  { type: PlaceHistory },
5392
- { type: ModalInteractionService }
5795
+ { type: exports.ɵv }
5393
5796
  ]; };
5394
- /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory), core.ɵɵinject(ModalInteractionService)); }, token: PlaceRouter, providedIn: "root" });
5797
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory), core.ɵɵinject(exports.ɵv)); }, token: PlaceRouter, providedIn: "root" });
5395
5798
  return PlaceRouter;
5396
5799
  }(pectin.GarbageCollector));
5397
5800
  if (false) {
@@ -5399,127 +5802,52 @@
5399
5802
  * @type {?}
5400
5803
  * @private
5401
5804
  */
5402
- exports.ɵt.prototype.firstRoute;
5805
+ PlaceRouter.prototype._navigationStateModel;
5403
5806
  /**
5404
5807
  * @type {?}
5405
5808
  * @private
5406
5809
  */
5407
- exports.ɵt.prototype._navigationSessionModel;
5810
+ PlaceRouter.prototype._activeVisits;
5811
+ /** @type {?} */
5812
+ PlaceRouter.prototype.navigationInProgress;
5813
+ /** @type {?} */
5814
+ PlaceRouter.prototype.activeVisitIndex;
5408
5815
  /**
5409
5816
  * @type {?}
5410
5817
  * @private
5411
5818
  */
5412
- exports.ɵt.prototype._activeVisits;
5413
- /** @type {?} */
5414
- exports.ɵt.prototype.navigationSessionActive;
5415
- /** @type {?} */
5416
- exports.ɵt.prototype.activeVisitIndex;
5819
+ PlaceRouter.prototype._navigationSessionContext;
5417
5820
  /**
5418
5821
  * @type {?}
5419
5822
  * @private
5420
5823
  */
5421
- exports.ɵt.prototype._navigationSessionContext;
5824
+ PlaceRouter.prototype._navigationStateTypeModel;
5422
5825
  /**
5423
5826
  * @type {?}
5424
5827
  * @private
5425
5828
  */
5426
- exports.ɵt.prototype.router;
5829
+ PlaceRouter.prototype.router;
5427
5830
  /**
5428
5831
  * @type {?}
5429
5832
  * @private
5430
5833
  */
5431
- exports.ɵt.prototype.urlSerializer;
5834
+ PlaceRouter.prototype.urlSerializer;
5432
5835
  /**
5433
5836
  * @type {?}
5434
5837
  * @private
5435
5838
  */
5436
- exports.ɵt.prototype.angularLocation;
5839
+ PlaceRouter.prototype.angularLocation;
5437
5840
  /**
5438
5841
  * @type {?}
5439
5842
  * @private
5440
5843
  */
5441
- exports.ɵt.prototype.placeHistory;
5844
+ PlaceRouter.prototype.placeHistory;
5442
5845
  /**
5443
5846
  * @type {?}
5444
5847
  * @private
5445
5848
  */
5446
- exports.ɵt.prototype.modalInteractionService;
5849
+ PlaceRouter.prototype.interactionService;
5447
5850
  }
5448
- (function (PlaceRouter) {
5449
- PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
5450
- var InteractionRouteMediator = /** @class */ (function () {
5451
- function InteractionRouteMediator(navigationSessionModelActive, router) {
5452
- this.navigationSessionModelActive = navigationSessionModelActive;
5453
- this.router = router;
5454
- }
5455
- Object.defineProperty(InteractionRouteMediator.prototype, "isNavigating", {
5456
- get: /**
5457
- * @return {?}
5458
- */
5459
- function () {
5460
- return this.navigationSessionModelActive.value;
5461
- },
5462
- enumerable: true,
5463
- configurable: true
5464
- });
5465
- // If we're not in a navigation we push
5466
- // @Trace()
5467
- // If we're not in a navigation we push
5468
- // @Trace()
5469
- /**
5470
- * @return {?}
5471
- */
5472
- InteractionRouteMediator.prototype.onActivityStarted =
5473
- // If we're not in a navigation we push
5474
- // @Trace()
5475
- /**
5476
- * @return {?}
5477
- */
5478
- function () {
5479
- var _a;
5480
- if (!this.isNavigating) {
5481
- this.router.navigate(['.', {
5482
- outlets: (_a = {},
5483
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = ['modal'] // "open" must be a valid route for this outlet.
5484
- ,
5485
- _a)
5486
- }], {
5487
- replaceUrl: false
5488
- });
5489
- }
5490
- };
5491
- // @Trace()
5492
- // @Trace()
5493
- /**
5494
- * @return {?}
5495
- */
5496
- InteractionRouteMediator.prototype.onActivityFinished =
5497
- // @Trace()
5498
- /**
5499
- * @return {?}
5500
- */
5501
- function () {
5502
- var _a;
5503
- if (!this.isNavigating) {
5504
- this.router.navigate(['.', {
5505
- outlets: (_a = {},
5506
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = null,
5507
- _a)
5508
- }], {
5509
- replaceUrl: true // remove the interaction from the history.
5510
- });
5511
- }
5512
- };
5513
- return InteractionRouteMediator;
5514
- }());
5515
- PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
5516
- if (false) {
5517
- /** @type {?} */
5518
- InteractionRouteMediator.prototype.navigationSessionModelActive;
5519
- /** @type {?} */
5520
- InteractionRouteMediator.prototype.router;
5521
- }
5522
- })(exports.ɵt || (exports.ɵt = {}));
5523
5851
 
5524
5852
  /**
5525
5853
  * @fileoverview added by tsickle
@@ -5670,10 +5998,10 @@
5670
5998
  function (next, previous) {
5671
5999
  _this.pushVisitChangesToRoute(next, previous);
5672
6000
  }), {
5673
- unless: _this.placeRouter.navigationSessionActive
6001
+ unless: _this.placeRouter.navigationInProgress
5674
6002
  });
5675
6003
  chain(_this._activePlace)
5676
- .postponeWhile(placeRouter.navigationSessionActive)
6004
+ .postponeWhile(placeRouter.navigationInProgress)
5677
6005
  .subscribe((/**
5678
6006
  * @param {?} place
5679
6007
  * @return {?}
@@ -5903,7 +6231,7 @@
5903
6231
  /** @nocollapse */
5904
6232
  PlaceOutletComponent.ctorParameters = function () { return [
5905
6233
  { type: router.Router },
5906
- { type: exports.ɵt },
6234
+ { type: PlaceRouter },
5907
6235
  { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [AUP_PLACE_CONFIG,] }] },
5908
6236
  { type: PlaceOutletComponent, decorators: [{ type: core.SkipSelf }, { type: core.Optional }] }
5909
6237
  ]; };
@@ -6694,45 +7022,264 @@
6694
7022
  * @fileoverview added by tsickle
6695
7023
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6696
7024
  */
6697
- /**
6698
- * @record
6699
- * @template R, E
6700
- */
6701
- function Result() { }
6702
- (function (Result) {
7025
+ /**
7026
+ * @record
7027
+ * @template R, E
7028
+ */
7029
+ function Result() { }
7030
+ (function (Result) {
7031
+ /**
7032
+ * @record
7033
+ * @template R, E
7034
+ */
7035
+ function Callback() { }
7036
+ Result.Callback = Callback;
7037
+ if (false) {
7038
+ /** @type {?} */
7039
+ Callback.prototype.then;
7040
+ /** @type {?} */
7041
+ Callback.prototype.catch;
7042
+ }
7043
+ })(Result || (Result = {}));
7044
+
7045
+ /**
7046
+ * @fileoverview added by tsickle
7047
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7048
+ */
7049
+ /**
7050
+ * @record
7051
+ * @template D, R, E
7052
+ */
7053
+ function ActivityOutletContext() { }
7054
+ if (false) {
7055
+ /** @type {?} */
7056
+ ActivityOutletContext.prototype.activityClass;
7057
+ /** @type {?} */
7058
+ ActivityOutletContext.prototype.activityData;
7059
+ /**
7060
+ * @param {?} component
7061
+ * @return {?}
7062
+ */
7063
+ ActivityOutletContext.prototype.componentReady = function (component) { };
7064
+ }
7065
+
7066
+ /**
7067
+ * @fileoverview added by tsickle
7068
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7069
+ */
7070
+ var DialogInteractionContext = /** @class */ (function (_super) {
7071
+ __extends(DialogInteractionContext, _super);
7072
+ function DialogInteractionContext(dialogService, config) {
7073
+ var _this = _super.call(this) || this;
7074
+ _this.dialogService = dialogService;
7075
+ _this.config = config;
7076
+ _this._activeModel = new pectin.MutableValueModel(false);
7077
+ typescriptUtilities.assert.notNil(dialogService);
7078
+ _this.onDispose((/**
7079
+ * @return {?}
7080
+ */
7081
+ function () {
7082
+ if (_this.isActive()) {
7083
+ pectin.lang.illegalState('Dispose called while active.');
7084
+ }
7085
+ }));
7086
+ return _this;
7087
+ }
7088
+ Object.defineProperty(DialogInteractionContext.prototype, "active", {
7089
+ get: /**
7090
+ * @return {?}
7091
+ */
7092
+ function () {
7093
+ return this._activeModel.readonly;
7094
+ },
7095
+ enumerable: true,
7096
+ configurable: true
7097
+ });
7098
+ /**
7099
+ * @protected
7100
+ * @template D, R, E
7101
+ * @param {?} activityType
7102
+ * @param {?} data
7103
+ * @param {?=} disableClose
7104
+ * @return {?}
7105
+ */
7106
+ DialogInteractionContext.prototype._startActivity = /**
7107
+ * @protected
7108
+ * @template D, R, E
7109
+ * @param {?} activityType
7110
+ * @param {?} data
7111
+ * @param {?=} disableClose
7112
+ * @return {?}
7113
+ */
7114
+ function (activityType, data, disableClose) {
7115
+ var _this = this;
7116
+ if (disableClose === void 0) { disableClose = true; }
7117
+ if (this.isActive()) {
7118
+ pectin.lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
7119
+ * @param {?} a
7120
+ * @return {?}
7121
+ */
7122
+ function (a) { return a.constructor.name; })).join(', '));
7123
+ }
7124
+ this._activeModel.value = true;
7125
+ /** @type {?} */
7126
+ var config = __assign({}, this.config, {
7127
+ data: data,
7128
+ disableClose: disableClose,
7129
+ panelClass: 'dialog-interaction-context'
7130
+ });
7131
+ /** @type {?} */
7132
+ var self = this;
7133
+ /** @type {?} */
7134
+ var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
7135
+ return new Promise((/**
7136
+ * @param {?} resolve
7137
+ * @param {?} reject
7138
+ * @return {?}
7139
+ */
7140
+ function (resolve, reject) {
7141
+ /** @type {?} */
7142
+ var activityContainer = matDialogRef.componentInstance;
7143
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
7144
+ activityContainer.initialActivityOutletContext = {
7145
+ activityClass: activityType,
7146
+ activityData: data,
7147
+ onDone: /**
7148
+ * @param {?} result
7149
+ * @return {?}
7150
+ */
7151
+ function (result) {
7152
+ resolve(result);
7153
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
7154
+ },
7155
+ onCancel: /**
7156
+ * @param {?} error
7157
+ * @return {?}
7158
+ */
7159
+ function (error) {
7160
+ reject(error);
7161
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
7162
+ }
7163
+ };
7164
+ // we need to check if our onDone/onCancel methods above we called or if we were
7165
+ // closed by the user clicking the backdrop. If the later then we need to reject
7166
+ // our promise.
7167
+ matDialogRef.afterClosed().subscribe((/**
7168
+ * @param {?} promiseAlreadyFinished
7169
+ * @return {?}
7170
+ */
7171
+ function (promiseAlreadyFinished) {
7172
+ if (!promiseAlreadyFinished) {
7173
+ reject('auto-closed');
7174
+ }
7175
+ }));
7176
+ matDialogRef.updateSize();
7177
+ matDialogRef.afterOpened().subscribe((/**
7178
+ * @param {?} promiseAlreadyFinished
7179
+ * @return {?}
7180
+ */
7181
+ function (promiseAlreadyFinished) {
7182
+ matDialogRef.updateSize();
7183
+ }));
7184
+ })).finally((/**
7185
+ * @return {?}
7186
+ */
7187
+ function () {
7188
+ self.safelyUpdateActivityListDelegate(null);
7189
+ _this._activeModel.value = false;
7190
+ }));
7191
+ };
7192
+ /**
7193
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
7194
+ * @param delegate
7195
+ */
7196
+ /**
7197
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
7198
+ * @param {?} delegate
7199
+ * @return {?}
7200
+ */
7201
+ DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
7202
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
7203
+ * @param {?} delegate
7204
+ * @return {?}
7205
+ */
7206
+ function (delegate) {
7207
+ var _this = this;
7208
+ setTimeout((/**
7209
+ * @return {?}
7210
+ */
7211
+ function () { return _this.setActivityList(delegate); }));
7212
+ };
7213
+ return DialogInteractionContext;
7214
+ }(InteractionContextBase));
7215
+ if (false) {
7216
+ /**
7217
+ * @type {?}
7218
+ * @private
7219
+ */
7220
+ DialogInteractionContext.prototype._activeModel;
7221
+ /**
7222
+ * @type {?}
7223
+ * @private
7224
+ */
7225
+ DialogInteractionContext.prototype.dialogService;
7226
+ /** @type {?} */
7227
+ DialogInteractionContext.prototype.config;
7228
+ }
7229
+
7230
+ /**
7231
+ * @fileoverview added by tsickle
7232
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7233
+ */
7234
+ /** @type {?} */
7235
+ var DIALOG_INTERACTION_SERVICE_DEFAULTS = new core.InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
7236
+ var DialogInteractionContextFactory = /** @class */ (function (_super) {
7237
+ __extends(DialogInteractionContextFactory, _super);
7238
+ function DialogInteractionContextFactory(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
7239
+ var _this = _super.call(this) || this;
7240
+ _this.dialogService = dialogService;
7241
+ _this.dialogServiceDefaults = dialogServiceDefaults;
7242
+ _this.matDialogDefaultConfig = matDialogDefaultConfig;
7243
+ typescriptUtilities.assert.notNil(dialogService);
7244
+ return _this;
7245
+ }
6703
7246
  /**
6704
- * @record
6705
- * @template R, E
7247
+ * @return {?}
6706
7248
  */
6707
- function Callback() { }
6708
- Result.Callback = Callback;
6709
- if (false) {
6710
- /** @type {?} */
6711
- Callback.prototype.then;
7249
+ DialogInteractionContextFactory.prototype.createInteractionContext = /**
7250
+ * @return {?}
7251
+ */
7252
+ function () {
6712
7253
  /** @type {?} */
6713
- Callback.prototype.catch;
6714
- }
6715
- })(Result || (Result = {}));
6716
-
6717
- /**
6718
- * @fileoverview added by tsickle
6719
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6720
- */
6721
- /**
6722
- * @record
6723
- * @template D, R, E
6724
- */
6725
- function ActivityOutletContext() { }
7254
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
7255
+ return new DialogInteractionContext(this.dialogService, config);
7256
+ };
7257
+ DialogInteractionContextFactory.decorators = [
7258
+ { type: core.Injectable, args: [{
7259
+ providedIn: 'root'
7260
+ },] }
7261
+ ];
7262
+ /** @nocollapse */
7263
+ DialogInteractionContextFactory.ctorParameters = function () { return [
7264
+ { type: material.MatDialog },
7265
+ { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
7266
+ { type: dialog.MatDialogConfig, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MAT_DIALOG_DEFAULT_OPTIONS,] }] }
7267
+ ]; };
7268
+ /** @nocollapse */ DialogInteractionContextFactory.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(core.ɵɵinject(dialog.MatDialog), core.ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), core.ɵɵinject(dialog.MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
7269
+ return DialogInteractionContextFactory;
7270
+ }(ModalInteractionContextFactory));
6726
7271
  if (false) {
6727
7272
  /** @type {?} */
6728
- ActivityOutletContext.prototype.activityClass;
6729
- /** @type {?} */
6730
- ActivityOutletContext.prototype.activityData;
7273
+ DialogInteractionContextFactory.prototype.active;
6731
7274
  /**
6732
- * @param {?} component
6733
- * @return {?}
7275
+ * @type {?}
7276
+ * @private
6734
7277
  */
6735
- ActivityOutletContext.prototype.componentReady = function (component) { };
7278
+ DialogInteractionContextFactory.prototype.dialogService;
7279
+ /** @type {?} */
7280
+ DialogInteractionContextFactory.prototype.dialogServiceDefaults;
7281
+ /** @type {?} */
7282
+ DialogInteractionContextFactory.prototype.matDialogDefaultConfig;
6736
7283
  }
6737
7284
 
6738
7285
  /**
@@ -6809,103 +7356,6 @@
6809
7356
  }
6810
7357
  })(Place || (Place = {}));
6811
7358
 
6812
- /**
6813
- * @fileoverview added by tsickle
6814
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6815
- */
6816
- var VisitSanitiser = /** @class */ (function () {
6817
- function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
6818
- this.activatedRoute = activatedRoute;
6819
- this.router = router;
6820
- this.placeHistory = placeHistory;
6821
- this.injector = injector;
6822
- }
6823
- // @Trace()
6824
- // @Trace()
6825
- /**
6826
- * @param {?} visit
6827
- * @return {?}
6828
- */
6829
- VisitSanitiser.prototype.sanitise =
6830
- // @Trace()
6831
- /**
6832
- * @param {?} visit
6833
- * @return {?}
6834
- */
6835
- function (visit) {
6836
- return __awaiter(this, void 0, void 0, function () {
6837
- var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
6838
- return __generator(this, function (_a) {
6839
- switch (_a.label) {
6840
- case 0:
6841
- placeDef = visit.placeDefinition;
6842
- if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
6843
- routeIdDef = placeDef.getRouteIdParameterDef();
6844
- routeId = visit.getRouteId();
6845
- return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
6846
- case 1:
6847
- sanitisedValue = _a.sent();
6848
- // console.log({routeId, sanitisedValue});
6849
- // ###------- EARLY EXIT --------###
6850
- if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
6851
- // if the route id has changed we redirect immediately as other
6852
- // parameter sanitisers might use it.
6853
- return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
6854
- }
6855
- _a.label = 2;
6856
- case 2:
6857
- // if we didn't replace the routeId we continue the url present parameters.
6858
- parameterDefs = placeDef.getVisitParameterDefs({
6859
- includeRouteParameters: true,
6860
- includeNonRouteParameters: true
6861
- });
6862
- sanitisedVisit = visit;
6863
- i = 0;
6864
- _a.label = 3;
6865
- case 3:
6866
- if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
6867
- def = parameterDefs[i];
6868
- value = visit.getParameter(def.name);
6869
- return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
6870
- case 4:
6871
- sanitisedValue = _a.sent();
6872
- if (def.hasChanged(value, sanitisedValue)) {
6873
- sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
6874
- }
6875
- _a.label = 5;
6876
- case 5:
6877
- i++;
6878
- return [3 /*break*/, 3];
6879
- case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
6880
- }
6881
- });
6882
- });
6883
- };
6884
- return VisitSanitiser;
6885
- }());
6886
- if (false) {
6887
- /**
6888
- * @type {?}
6889
- * @private
6890
- */
6891
- VisitSanitiser.prototype.activatedRoute;
6892
- /**
6893
- * @type {?}
6894
- * @private
6895
- */
6896
- VisitSanitiser.prototype.router;
6897
- /**
6898
- * @type {?}
6899
- * @private
6900
- */
6901
- VisitSanitiser.prototype.placeHistory;
6902
- /**
6903
- * @type {?}
6904
- * @private
6905
- */
6906
- VisitSanitiser.prototype.injector;
6907
- }
6908
-
6909
7359
  /**
6910
7360
  * @fileoverview added by tsickle
6911
7361
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -7010,58 +7460,190 @@
7010
7460
  this.params = params;
7011
7461
  }
7012
7462
  /**
7013
- * @param {?} name
7463
+ * @param {?} name
7464
+ * @return {?}
7465
+ */
7466
+ ParamMapAdapter.prototype.get = /**
7467
+ * @param {?} name
7468
+ * @return {?}
7469
+ */
7470
+ function (name) {
7471
+ return this.params[name];
7472
+ };
7473
+ /**
7474
+ * @param {?} name
7475
+ * @return {?}
7476
+ */
7477
+ ParamMapAdapter.prototype.getAll = /**
7478
+ * @param {?} name
7479
+ * @return {?}
7480
+ */
7481
+ function (name) {
7482
+ /** @type {?} */
7483
+ var value = this.get(name);
7484
+ return Array.isArray(value) ? value : [value];
7485
+ };
7486
+ /**
7487
+ * @param {?} name
7488
+ * @return {?}
7489
+ */
7490
+ ParamMapAdapter.prototype.has = /**
7491
+ * @param {?} name
7492
+ * @return {?}
7493
+ */
7494
+ function (name) {
7495
+ return this.keys.includes(name);
7496
+ };
7497
+ Object.defineProperty(ParamMapAdapter.prototype, "keys", {
7498
+ get: /**
7499
+ * @return {?}
7500
+ */
7501
+ function () {
7502
+ return Object.keys(this.params);
7503
+ },
7504
+ enumerable: true,
7505
+ configurable: true
7506
+ });
7507
+ return ParamMapAdapter;
7508
+ }());
7509
+ if (false) {
7510
+ /**
7511
+ * @type {?}
7512
+ * @private
7513
+ */
7514
+ ParamMapAdapter.prototype.params;
7515
+ }
7516
+
7517
+ /**
7518
+ * @fileoverview added by tsickle
7519
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7520
+ */
7521
+ var NoopAuthGuard = /** @class */ (function () {
7522
+ function NoopAuthGuard() {
7523
+ }
7524
+ /**
7525
+ * @param {?} activatedRoute
7526
+ * @param {?} state
7527
+ * @return {?}
7528
+ */
7529
+ NoopAuthGuard.prototype.canActivate = /**
7530
+ * @param {?} activatedRoute
7531
+ * @param {?} state
7532
+ * @return {?}
7533
+ */
7534
+ function (activatedRoute, state) {
7535
+ return __awaiter(this, void 0, void 0, function () {
7536
+ return __generator(this, function (_a) {
7537
+ return [2 /*return*/, true];
7538
+ });
7539
+ });
7540
+ };
7541
+ NoopAuthGuard.decorators = [
7542
+ { type: core.Injectable, args: [{
7543
+ providedIn: 'root'
7544
+ },] }
7545
+ ];
7546
+ /** @nocollapse */
7547
+ NoopAuthGuard.ctorParameters = function () { return []; };
7548
+ /** @nocollapse */ NoopAuthGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7549
+ return NoopAuthGuard;
7550
+ }());
7551
+
7552
+ /**
7553
+ * @fileoverview added by tsickle
7554
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7555
+ */
7556
+ var VisitSanitiser = /** @class */ (function () {
7557
+ function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
7558
+ this.activatedRoute = activatedRoute;
7559
+ this.router = router;
7560
+ this.placeHistory = placeHistory;
7561
+ this.injector = injector;
7562
+ }
7563
+ // @Trace()
7564
+ // @Trace()
7565
+ /**
7566
+ * @param {?} visit
7014
7567
  * @return {?}
7015
7568
  */
7016
- ParamMapAdapter.prototype.get = /**
7017
- * @param {?} name
7569
+ VisitSanitiser.prototype.sanitise =
7570
+ // @Trace()
7571
+ /**
7572
+ * @param {?} visit
7018
7573
  * @return {?}
7019
7574
  */
7020
- function (name) {
7021
- return this.params[name];
7575
+ function (visit) {
7576
+ return __awaiter(this, void 0, void 0, function () {
7577
+ var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
7578
+ return __generator(this, function (_a) {
7579
+ switch (_a.label) {
7580
+ case 0:
7581
+ placeDef = visit.placeDefinition;
7582
+ if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
7583
+ routeIdDef = placeDef.getRouteIdParameterDef();
7584
+ routeId = visit.getRouteId();
7585
+ return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
7586
+ case 1:
7587
+ sanitisedValue = _a.sent();
7588
+ // console.log({routeId, sanitisedValue});
7589
+ // ###------- EARLY EXIT --------###
7590
+ if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7591
+ // if the route id has changed we redirect immediately as other
7592
+ // parameter sanitisers might use it.
7593
+ return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
7594
+ }
7595
+ _a.label = 2;
7596
+ case 2:
7597
+ // if we didn't replace the routeId we continue the url present parameters.
7598
+ parameterDefs = placeDef.getVisitParameterDefs({
7599
+ includeRouteParameters: true,
7600
+ includeNonRouteParameters: true
7601
+ });
7602
+ sanitisedVisit = visit;
7603
+ i = 0;
7604
+ _a.label = 3;
7605
+ case 3:
7606
+ if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
7607
+ def = parameterDefs[i];
7608
+ value = visit.getParameter(def.name);
7609
+ return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
7610
+ case 4:
7611
+ sanitisedValue = _a.sent();
7612
+ if (def.hasChanged(value, sanitisedValue)) {
7613
+ sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
7614
+ }
7615
+ _a.label = 5;
7616
+ case 5:
7617
+ i++;
7618
+ return [3 /*break*/, 3];
7619
+ case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
7620
+ }
7621
+ });
7622
+ });
7022
7623
  };
7624
+ return VisitSanitiser;
7625
+ }());
7626
+ if (false) {
7023
7627
  /**
7024
- * @param {?} name
7025
- * @return {?}
7026
- */
7027
- ParamMapAdapter.prototype.getAll = /**
7028
- * @param {?} name
7029
- * @return {?}
7628
+ * @type {?}
7629
+ * @private
7030
7630
  */
7031
- function (name) {
7032
- /** @type {?} */
7033
- var value = this.get(name);
7034
- return Array.isArray(value) ? value : [value];
7035
- };
7631
+ VisitSanitiser.prototype.activatedRoute;
7036
7632
  /**
7037
- * @param {?} name
7038
- * @return {?}
7633
+ * @type {?}
7634
+ * @private
7039
7635
  */
7040
- ParamMapAdapter.prototype.has = /**
7041
- * @param {?} name
7042
- * @return {?}
7636
+ VisitSanitiser.prototype.router;
7637
+ /**
7638
+ * @type {?}
7639
+ * @private
7043
7640
  */
7044
- function (name) {
7045
- return this.keys.includes(name);
7046
- };
7047
- Object.defineProperty(ParamMapAdapter.prototype, "keys", {
7048
- get: /**
7049
- * @return {?}
7050
- */
7051
- function () {
7052
- return Object.keys(this.params);
7053
- },
7054
- enumerable: true,
7055
- configurable: true
7056
- });
7057
- return ParamMapAdapter;
7058
- }());
7059
- if (false) {
7641
+ VisitSanitiser.prototype.placeHistory;
7060
7642
  /**
7061
7643
  * @type {?}
7062
7644
  * @private
7063
7645
  */
7064
- ParamMapAdapter.prototype.params;
7646
+ VisitSanitiser.prototype.injector;
7065
7647
  }
7066
7648
 
7067
7649
  /**
@@ -7071,12 +7653,16 @@
7071
7653
  /**
7072
7654
  * @abstract
7073
7655
  */
7074
- var AbstractPlaceGuard = /** @class */ (function () {
7075
- function AbstractPlaceGuard(router, urlSerializer, placeRouter, placeHistory, injector) {
7656
+ var /**
7657
+ * @abstract
7658
+ */
7659
+ PlaceGuard = /** @class */ (function () {
7660
+ function PlaceGuard(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
7076
7661
  this.router = router;
7077
7662
  this.urlSerializer = urlSerializer;
7078
7663
  this.placeRouter = placeRouter;
7079
7664
  this.placeHistory = placeHistory;
7665
+ this.interactionService = interactionService;
7080
7666
  this.injector = injector;
7081
7667
  }
7082
7668
  // @Trace()
@@ -7086,7 +7672,7 @@
7086
7672
  * @param {?} state
7087
7673
  * @return {?}
7088
7674
  */
7089
- AbstractPlaceGuard.prototype.canActivate =
7675
+ PlaceGuard.prototype.canActivate =
7090
7676
  // @Trace()
7091
7677
  /**
7092
7678
  * @param {?} activatedRoute
@@ -7097,44 +7683,59 @@
7097
7683
  return __awaiter(this, void 0, void 0, function () {
7098
7684
  var _this = this;
7099
7685
  return __generator(this, function (_a) {
7686
+ // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
7687
+ // weren't nested or if I implemented a handler chain.
7100
7688
  return [2 /*return*/, this.authorisePlaceThen(activatedRoute, state, (/**
7101
7689
  * @param {?} placeDefinition
7102
7690
  * @return {?}
7103
7691
  */
7104
7692
  function (placeDefinition) { return __awaiter(_this, void 0, void 0, function () {
7105
- var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, commands;
7693
+ var result;
7694
+ var _this = this;
7106
7695
  return __generator(this, function (_a) {
7107
7696
  switch (_a.label) {
7108
- case 0:
7109
- // Parse our route params.
7110
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7111
- parsedParams = placeDefinition.parseRouteParams(params);
7112
- initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7113
- sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7114
- return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7697
+ case 0: return [4 /*yield*/, this.cleanInteractionState(activatedRoute, state, (/**
7698
+ * @return {?}
7699
+ */
7700
+ function () { return __awaiter(_this, void 0, void 0, function () {
7701
+ var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, urlSnapshot;
7702
+ return __generator(this, function (_a) {
7703
+ switch (_a.label) {
7704
+ case 0:
7705
+ // Parse our route params.
7706
+ params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7707
+ parsedParams = placeDefinition.parseRouteParams(params);
7708
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7709
+ sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7710
+ return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7711
+ case 1:
7712
+ sanitisedVisit = _a.sent();
7713
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7714
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7715
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7716
+ // Regenerate the url
7717
+ urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
7718
+ console.log('##### Place Guard Redirect', urlSnapshot);
7719
+ return [2 /*return*/, urlSnapshot];
7720
+ }
7721
+ else {
7722
+ return [2 /*return*/, true];
7723
+ }
7724
+ return [2 /*return*/];
7725
+ }
7726
+ });
7727
+ }); }))];
7115
7728
  case 1:
7116
- sanitisedVisit = _a.sent();
7117
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7118
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
7119
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7120
- // Regenerate the url
7121
- commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
7122
- console.log('##### Place Guard Redirect', commands);
7123
- return [2 /*return*/, this.router.createUrlTree(commands, {
7124
- replaceUrl: true,
7125
- skipLocationChange: false
7126
- })];
7127
- }
7128
- else {
7129
- return [2 /*return*/, true];
7130
- }
7131
- return [2 /*return*/];
7729
+ result = _a.sent();
7730
+ return [2 /*return*/, this.handleGuardResult(result)];
7132
7731
  }
7133
7732
  });
7134
7733
  }); }))];
7135
7734
  });
7136
7735
  });
7137
7736
  };
7737
+ // @Trace()
7738
+ // @Trace()
7138
7739
  /**
7139
7740
  * @param {?} component
7140
7741
  * @param {?} currentRoute
@@ -7142,7 +7743,9 @@
7142
7743
  * @param {?=} nextState
7143
7744
  * @return {?}
7144
7745
  */
7145
- AbstractPlaceGuard.prototype.canDeactivate = /**
7746
+ PlaceGuard.prototype.canDeactivate =
7747
+ // @Trace()
7748
+ /**
7146
7749
  * @param {?} component
7147
7750
  * @param {?} currentRoute
7148
7751
  * @param {?} currentState
@@ -7151,32 +7754,59 @@
7151
7754
  */
7152
7755
  function (component, currentRoute, currentState, nextState) {
7153
7756
  return __awaiter(this, void 0, void 0, function () {
7757
+ var currentUrl, nextUrl, result;
7154
7758
  return __generator(this, function (_a) {
7155
- return [2 /*return*/, this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState))];
7759
+ switch (_a.label) {
7760
+ case 0:
7761
+ currentUrl = this.placeRouter.parseUrl(currentState.url);
7762
+ nextUrl = this.placeRouter.parseUrl(nextState.url);
7763
+ return [4 /*yield*/, this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl)];
7764
+ case 1:
7765
+ result = _a.sent();
7766
+ return [2 /*return*/, this.handleGuardResult(result)];
7767
+ }
7156
7768
  });
7157
7769
  });
7158
7770
  };
7771
+ /**
7772
+ * @private
7773
+ * @param {?} result
7774
+ * @return {?}
7775
+ */
7776
+ PlaceGuard.prototype.handleGuardResult = /**
7777
+ * @private
7778
+ * @param {?} result
7779
+ * @return {?}
7780
+ */
7781
+ function (result) {
7782
+ if (result instanceof exports.UrlSnapshot) {
7783
+ return result.urlTree;
7784
+ }
7785
+ else {
7786
+ return result;
7787
+ }
7788
+ };
7159
7789
  // @Trace()
7160
7790
  // @Trace()
7161
7791
  /**
7162
7792
  * @protected
7163
7793
  * @param {?} activatedRoute
7164
7794
  * @param {?} state
7165
- * @param {?} canActivate
7795
+ * @param {?} runPlaceGuards
7166
7796
  * @return {?}
7167
7797
  */
7168
- AbstractPlaceGuard.prototype.authorisePlaceThen =
7798
+ PlaceGuard.prototype.authorisePlaceThen =
7169
7799
  // @Trace()
7170
7800
  /**
7171
7801
  * @protected
7172
7802
  * @param {?} activatedRoute
7173
7803
  * @param {?} state
7174
- * @param {?} canActivate
7804
+ * @param {?} runPlaceGuards
7175
7805
  * @return {?}
7176
7806
  */
7177
- function (activatedRoute, state, canActivate) {
7807
+ function (activatedRoute, state, runPlaceGuards) {
7178
7808
  return __awaiter(this, void 0, void 0, function () {
7179
- var placeDefinition, authorised, _a;
7809
+ var placeDefinition, authoriseResult, _a;
7180
7810
  return __generator(this, function (_b) {
7181
7811
  switch (_b.label) {
7182
7812
  case 0:
@@ -7191,13 +7821,14 @@
7191
7821
  _a = true;
7192
7822
  _b.label = 3;
7193
7823
  case 3:
7194
- authorised = _a;
7195
- if (authorised === true) {
7196
- return [2 /*return*/, canActivate(placeDefinition)];
7824
+ authoriseResult = _a;
7825
+ if (authoriseResult === true) {
7826
+ // we're authorised, now run the place guards.
7827
+ return [2 /*return*/, runPlaceGuards(placeDefinition)];
7197
7828
  }
7198
7829
  else {
7199
- console.log('not authorised result', authorised);
7200
- return [2 /*return*/, authorised];
7830
+ console.log('not authorised result', authoriseResult);
7831
+ return [2 /*return*/, authoriseResult];
7201
7832
  }
7202
7833
  return [3 /*break*/, 5];
7203
7834
  case 4: return [2 /*return*/, pectin.lang.illegalState("expected component to be an instance of PlaceComponent, got " + activatedRoute.component)];
@@ -7206,12 +7837,16 @@
7206
7837
  });
7207
7838
  });
7208
7839
  };
7840
+ // @Trace()
7841
+ // @Trace()
7209
7842
  /**
7210
7843
  * @param {?} activatedRoute
7211
7844
  * @param {?} state
7212
7845
  * @return {?}
7213
7846
  */
7214
- AbstractPlaceGuard.prototype.isAuthorised = /**
7847
+ PlaceGuard.prototype.isAuthorised =
7848
+ // @Trace()
7849
+ /**
7215
7850
  * @param {?} activatedRoute
7216
7851
  * @param {?} state
7217
7852
  * @return {?}
@@ -7225,195 +7860,79 @@
7225
7860
  });
7226
7861
  });
7227
7862
  };
7228
- __decorate([
7229
- pectin.Trace(),
7230
- __metadata("design:type", Function),
7231
- __metadata("design:paramtypes", [router.ActivatedRouteSnapshot, router.RouterStateSnapshot]),
7232
- __metadata("design:returntype", Promise)
7233
- ], AbstractPlaceGuard.prototype, "isAuthorised", null);
7234
- return AbstractPlaceGuard;
7235
- }());
7236
- if (false) {
7237
- /**
7238
- * @type {?}
7239
- * @private
7240
- */
7241
- AbstractPlaceGuard.prototype.router;
7242
- /**
7243
- * @type {?}
7244
- * @private
7245
- */
7246
- AbstractPlaceGuard.prototype.urlSerializer;
7247
- /**
7248
- * @type {?}
7249
- * @private
7250
- */
7251
- AbstractPlaceGuard.prototype.placeRouter;
7252
- /**
7253
- * @type {?}
7254
- * @private
7255
- */
7256
- AbstractPlaceGuard.prototype.placeHistory;
7257
- /**
7258
- * @type {?}
7259
- * @private
7260
- */
7261
- AbstractPlaceGuard.prototype.injector;
7262
- /**
7263
- * @abstract
7264
- * @param {?} injector
7265
- * @return {?}
7266
- */
7267
- AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
7268
- }
7269
-
7270
- /**
7271
- * @fileoverview added by tsickle
7272
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7273
- */
7274
- var InteractionGuard = /** @class */ (function () {
7275
- function InteractionGuard(router, injector, placeRouter, angularLocation, modalInteractionService) {
7276
- this.router = router;
7277
- this.injector = injector;
7278
- this.placeRouter = placeRouter;
7279
- this.angularLocation = angularLocation;
7280
- this.modalInteractionService = modalInteractionService;
7281
- }
7863
+ // @Trace()
7864
+ // @Trace()
7282
7865
  /**
7283
7866
  * @param {?} route
7284
7867
  * @param {?} state
7868
+ * @param {?} then
7285
7869
  * @return {?}
7286
7870
  */
7287
- InteractionGuard.prototype.canActivate = /**
7871
+ PlaceGuard.prototype.cleanInteractionState =
7872
+ // @Trace()
7873
+ /**
7288
7874
  * @param {?} route
7289
7875
  * @param {?} state
7876
+ * @param {?} then
7290
7877
  * @return {?}
7291
7878
  */
7292
- function (route, state) {
7293
- /** @type {?} */
7294
- var url = this.router.parseUrl(state.url);
7295
- if (!this.modalInteractionService.isActive() && url.root.children[exports.ɵt.INTERACTION_ROUTER_OUTLET]) {
7296
- // This happens if we reload the page or the url was pasted as the route should only be activated
7297
- // after the interaction context has become active.
7298
- delete url.root.children[exports.ɵt.INTERACTION_ROUTER_OUTLET];
7299
- return url;
7300
- }
7301
- else {
7302
- return true;
7303
- }
7304
- };
7305
- /**
7306
- * @param {?} component
7307
- * @param {?} currentRoute
7308
- * @param {?} currentState
7309
- * @param {?=} nextState
7310
- * @return {?}
7311
- */
7312
- InteractionGuard.prototype.canDeactivate = /**
7313
- * @param {?} component
7314
- * @param {?} currentRoute
7315
- * @param {?} currentState
7316
- * @param {?=} nextState
7317
- * @return {?}
7318
- */
7319
- function (component, currentRoute, currentState, nextState) {
7879
+ function (route, state, then) {
7320
7880
  return __awaiter(this, void 0, void 0, function () {
7321
- var popstateReturnUrl, activity;
7881
+ var url;
7322
7882
  return __generator(this, function (_a) {
7323
- switch (_a.label) {
7324
- case 0:
7325
- popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
7326
- if (!this.modalInteractionService.isActive()) return [3 /*break*/, 2];
7327
- // The activity is still active so the route change was triggered by the back button.
7328
- return [4 /*yield*/, this.modalInteractionService.getCurrentActivity()];
7329
- case 1:
7330
- activity = _a.sent();
7331
- activity.cancel();
7332
- // See ModalInteractionSession#onStart() for the url updating.
7333
- return [2 /*return*/, false];
7334
- case 2: return [2 /*return*/, true];
7883
+ url = this.placeRouter.parseUrl(state.url);
7884
+ if (!this.interactionService.isActive() && url.hasInteractionIds()) {
7885
+ // This happens if we reload the page or the url was pasted as the route should only be activated
7886
+ // after the interaction context has become active.
7887
+ return [2 /*return*/, url.removeInteractionIds()];
7888
+ }
7889
+ else {
7890
+ return [2 /*return*/, then()];
7335
7891
  }
7892
+ return [2 /*return*/];
7336
7893
  });
7337
7894
  });
7338
7895
  };
7339
- InteractionGuard.decorators = [
7340
- { type: core.Injectable, args: [{
7341
- providedIn: 'root'
7342
- },] }
7343
- ];
7344
- /** @nocollapse */
7345
- InteractionGuard.ctorParameters = function () { return [
7346
- { type: router.Router },
7347
- { type: core.Injector },
7348
- { type: exports.ɵt },
7349
- { type: common.Location },
7350
- { type: ModalInteractionService }
7351
- ]; };
7352
- /** @nocollapse */ InteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(exports.ɵt), core.ɵɵinject(common.Location), core.ɵɵinject(ModalInteractionService)); }, token: InteractionGuard, providedIn: "root" });
7353
- return InteractionGuard;
7896
+ return PlaceGuard;
7354
7897
  }());
7355
7898
  if (false) {
7356
7899
  /**
7357
7900
  * @type {?}
7358
7901
  * @private
7359
7902
  */
7360
- InteractionGuard.prototype.router;
7903
+ PlaceGuard.prototype.router;
7361
7904
  /**
7362
7905
  * @type {?}
7363
7906
  * @private
7364
7907
  */
7365
- InteractionGuard.prototype.injector;
7908
+ PlaceGuard.prototype.urlSerializer;
7366
7909
  /**
7367
7910
  * @type {?}
7368
7911
  * @private
7369
7912
  */
7370
- InteractionGuard.prototype.placeRouter;
7913
+ PlaceGuard.prototype.placeRouter;
7371
7914
  /**
7372
7915
  * @type {?}
7373
7916
  * @private
7374
7917
  */
7375
- InteractionGuard.prototype.angularLocation;
7918
+ PlaceGuard.prototype.placeHistory;
7376
7919
  /**
7377
7920
  * @type {?}
7378
7921
  * @private
7379
7922
  */
7380
- InteractionGuard.prototype.modalInteractionService;
7381
- }
7382
-
7383
- /**
7384
- * @fileoverview added by tsickle
7385
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7386
- */
7387
- var NoopAuthGuard = /** @class */ (function () {
7388
- function NoopAuthGuard() {
7389
- }
7923
+ PlaceGuard.prototype.interactionService;
7390
7924
  /**
7391
- * @param {?} activatedRoute
7392
- * @param {?} state
7393
- * @return {?}
7925
+ * @type {?}
7926
+ * @private
7394
7927
  */
7395
- NoopAuthGuard.prototype.canActivate = /**
7396
- * @param {?} activatedRoute
7397
- * @param {?} state
7928
+ PlaceGuard.prototype.injector;
7929
+ /**
7930
+ * @abstract
7931
+ * @param {?} injector
7398
7932
  * @return {?}
7399
7933
  */
7400
- function (activatedRoute, state) {
7401
- return __awaiter(this, void 0, void 0, function () {
7402
- return __generator(this, function (_a) {
7403
- return [2 /*return*/, true];
7404
- });
7405
- });
7406
- };
7407
- NoopAuthGuard.decorators = [
7408
- { type: core.Injectable, args: [{
7409
- providedIn: 'root'
7410
- },] }
7411
- ];
7412
- /** @nocollapse */
7413
- NoopAuthGuard.ctorParameters = function () { return []; };
7414
- /** @nocollapse */ NoopAuthGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7415
- return NoopAuthGuard;
7416
- }());
7934
+ PlaceGuard.prototype.getAuthGuard = function (injector) { };
7935
+ }
7417
7936
 
7418
7937
  /**
7419
7938
  * @fileoverview added by tsickle
@@ -7679,9 +8198,8 @@
7679
8198
  exports.AUP_PLACE_CONFIG = AUP_PLACE_CONFIG;
7680
8199
  exports.AbstractActivity = AbstractActivity;
7681
8200
  exports.AbstractInputComponent = AbstractInputComponent;
7682
- exports.AbstractPlaceGuard = AbstractPlaceGuard;
7683
8201
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
7684
- exports.Activity = exports.ɵbh;
8202
+ exports.Activity = exports.ɵbi;
7685
8203
  exports.ActivityContainerComponent = ActivityContainerComponent;
7686
8204
  exports.ActivityOutletComponent = ActivityOutletComponent;
7687
8205
  exports.AlertDialogComponent = AlertDialogComponent;
@@ -7689,37 +8207,38 @@
7689
8207
  exports.BusyOverlayComponent = BusyOverlayComponent;
7690
8208
  exports.CommandDirective = CommandDirective;
7691
8209
  exports.ComponentsModule = ComponentsModule;
7692
- exports.ConfirmThenDialogComponent = exports.ɵbj;
8210
+ exports.ConfirmThenDialogComponent = exports.ɵbk;
7693
8211
  exports.ConfirmationDialogComponent = ConfirmationDialogComponent;
7694
8212
  exports.ConsolidatedParameterMap = ConsolidatedParameterMap;
7695
8213
  exports.DEFINITION_META_DATA_KEY = DEFINITION_META_DATA_KEY;
7696
8214
  exports.DIALOG_INTERACTION_SERVICE_DEFAULTS = DIALOG_INTERACTION_SERVICE_DEFAULTS;
7697
8215
  exports.DialogInteractionContext = DialogInteractionContext;
7698
- exports.DialogInteractionService = DialogInteractionService;
8216
+ exports.DialogInteractionContextFactory = DialogInteractionContextFactory;
7699
8217
  exports.Dimension = Dimension;
7700
8218
  exports.DirectivesModule = DirectivesModule;
7701
8219
  exports.DisposableComponent = DisposableComponent;
7702
8220
  exports.EmptyStateComponent = EmptyStateComponent;
7703
8221
  exports.FocusBindingDirective = FocusBindingDirective;
7704
8222
  exports.InplaceInteractionContextComponent = InplaceInteractionContextComponent;
7705
- exports.InteractionContext = exports.ɵbc;
8223
+ exports.InteractionContext = InteractionContext;
7706
8224
  exports.InteractionContextBase = InteractionContextBase;
7707
- exports.InteractionGuard = InteractionGuard;
7708
8225
  exports.InteractionModule = InteractionModule;
7709
8226
  exports.InteractionOutletComponent = InteractionOutletComponent;
8227
+ exports.InteractionService = exports.ɵv;
7710
8228
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
7711
8229
  exports.ListPlaceNavComponent = ListPlaceNavComponent;
7712
- exports.ModalInteractionService = ModalInteractionService;
8230
+ exports.ModalInteractionContextFactory = ModalInteractionContextFactory;
7713
8231
  exports.NoopAuthGuard = NoopAuthGuard;
7714
8232
  exports.NoopComponent = NoopComponent;
7715
8233
  exports.NumberInputComponent = NumberInputComponent;
7716
8234
  exports.PasswordInputComponent = PasswordInputComponent;
7717
8235
  exports.Place = Place;
7718
8236
  exports.PlaceComponentDeactivationHandler = PlaceComponentDeactivationHandler;
8237
+ exports.PlaceGuard = PlaceGuard;
7719
8238
  exports.PlaceHistory = PlaceHistory;
7720
8239
  exports.PlaceModule = PlaceModule;
7721
8240
  exports.PlaceOutletComponent = PlaceOutletComponent;
7722
- exports.PlaceRouter = exports.ɵt;
8241
+ exports.PlaceRouter = PlaceRouter;
7723
8242
  exports.Point = Point;
7724
8243
  exports.ROUTE_PARAMETER_LIST_KEY = ROUTE_PARAMETER_LIST_KEY;
7725
8244
  exports.ResizeAwareComponent = ResizeAwareComponent;
@@ -7727,7 +8246,6 @@
7727
8246
  exports.SelectInputComponent = SelectInputComponent;
7728
8247
  exports.StringInputComponent = StringInputComponent;
7729
8248
  exports.TabbedPlaceNavigationComponent = TabbedPlaceNavigationComponent;
7730
- exports.UrlSnapshot = UrlSnapshot;
7731
8249
  exports.Visit = Visit;
7732
8250
  exports.VisitParameter = VisitParameter;
7733
8251
  exports.VisitParameterList = VisitParameterList;
@@ -7736,17 +8254,17 @@
7736
8254
  exports.slideDownAndUpAnimation = slideDownAndUpAnimation;
7737
8255
  exports.ɵa = DirectivesModule;
7738
8256
  exports.ɵb = CommandDirective;
7739
- exports.ɵba = ActivityContainerComponent;
7740
- exports.ɵbb = InteractionContextBase;
7741
- exports.ɵbd = ActivityOutletComponent;
7742
- exports.ɵbe = ConfirmationDialogComponent;
7743
- exports.ɵbf = AbstractActivity;
7744
- exports.ɵbg = ACTIVITY_DATA;
7745
- exports.ɵbk = AlertDialogComponent;
7746
- exports.ɵbm = InteractionOutletComponent;
7747
- exports.ɵbn = InplaceInteractionContextComponent;
7748
- exports.ɵbo = DIALOG_INTERACTION_SERVICE_DEFAULTS;
7749
- exports.ɵbp = DialogInteractionService;
8257
+ exports.ɵba = InteractionModule;
8258
+ exports.ɵbb = ActivityContainerComponent;
8259
+ exports.ɵbc = InteractionContextBase;
8260
+ exports.ɵbd = InteractionContext;
8261
+ exports.ɵbe = ActivityOutletComponent;
8262
+ exports.ɵbf = ConfirmationDialogComponent;
8263
+ exports.ɵbg = AbstractActivity;
8264
+ exports.ɵbh = ACTIVITY_DATA;
8265
+ exports.ɵbl = AlertDialogComponent;
8266
+ exports.ɵbn = InteractionOutletComponent;
8267
+ exports.ɵbo = InplaceInteractionContextComponent;
7750
8268
  exports.ɵc = FocusBindingDirective;
7751
8269
  exports.ɵd = DisposableComponent;
7752
8270
  exports.ɵe = ComponentsModule;
@@ -7763,12 +8281,12 @@
7763
8281
  exports.ɵp = leftRightPlaceAnimation;
7764
8282
  exports.ɵq = LEFT_RIGHT_PLACE_ANIMATION;
7765
8283
  exports.ɵr = AUP_PLACE_CONFIG;
8284
+ exports.ɵt = PlaceRouter;
7766
8285
  exports.ɵu = PlaceHistory;
7767
- exports.ɵv = ModalInteractionService;
7768
- exports.ɵw = TabbedPlaceNavigationComponent;
7769
- exports.ɵx = AbstractPlaceNavigationComponent;
7770
- exports.ɵy = ListPlaceNavComponent;
7771
- exports.ɵz = InteractionModule;
8286
+ exports.ɵw = ModalInteractionContextFactory;
8287
+ exports.ɵx = TabbedPlaceNavigationComponent;
8288
+ exports.ɵy = AbstractPlaceNavigationComponent;
8289
+ exports.ɵz = ListPlaceNavComponent;
7772
8290
 
7773
8291
  Object.defineProperty(exports, '__esModule', { value: true });
7774
8292