@angular/router 0.1.0 → 2.0.0-rc.2

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 (190) hide show
  1. package/bundles/router.umd.js +1812 -0
  2. package/bundles/router.umd.min.js +2 -0
  3. package/esm/index.d.ts +15 -0
  4. package/esm/index.js +15 -0
  5. package/esm/index.js.map +1 -0
  6. package/esm/src/constants.d.ts +5 -0
  7. package/esm/src/constants.js +6 -0
  8. package/esm/src/constants.js.map +1 -0
  9. package/esm/src/constants.metadata.json +1 -0
  10. package/esm/src/core_private.d.ts +3 -0
  11. package/esm/src/core_private.js +4 -0
  12. package/esm/src/core_private.js.map +1 -0
  13. package/esm/src/core_private.metadata.json +1 -0
  14. package/esm/src/directives/router_directives.d.ts +21 -0
  15. package/esm/src/directives/router_directives.js +24 -0
  16. package/esm/src/directives/router_directives.js.map +1 -0
  17. package/esm/src/directives/router_directives.metadata.json +1 -0
  18. package/esm/src/directives/router_link.d.ts +49 -0
  19. package/esm/src/directives/router_link.js +68 -0
  20. package/esm/src/directives/router_link.js.map +1 -0
  21. package/esm/src/directives/router_link.metadata.json +1 -0
  22. package/esm/src/directives/router_outlet.d.ts +36 -0
  23. package/esm/src/directives/router_outlet.js +42 -0
  24. package/esm/src/directives/router_outlet.js.map +1 -0
  25. package/esm/src/directives/router_outlet.metadata.json +1 -0
  26. package/esm/src/facade/async.d.ts +90 -0
  27. package/esm/src/facade/async.js +137 -0
  28. package/esm/src/facade/async.js.map +1 -0
  29. package/esm/src/facade/base_wrapped_exception.d.ts +14 -0
  30. package/esm/src/facade/base_wrapped_exception.js +17 -0
  31. package/esm/src/facade/base_wrapped_exception.js.map +1 -0
  32. package/esm/src/facade/collection.d.ts +103 -0
  33. package/esm/src/facade/collection.js +343 -0
  34. package/esm/src/facade/collection.js.map +1 -0
  35. package/esm/src/facade/collection.metadata.json +1 -0
  36. package/esm/src/facade/exception_handler.d.ts +29 -0
  37. package/esm/src/facade/exception_handler.js +124 -0
  38. package/esm/src/facade/exception_handler.js.map +1 -0
  39. package/esm/src/facade/exceptions.d.ts +32 -0
  40. package/esm/src/facade/exceptions.js +42 -0
  41. package/esm/src/facade/exceptions.js.map +1 -0
  42. package/esm/src/facade/exceptions.metadata.json +1 -0
  43. package/esm/src/facade/lang.d.ts +158 -0
  44. package/esm/src/facade/lang.js +386 -0
  45. package/esm/src/facade/lang.js.map +1 -0
  46. package/esm/src/facade/lang.metadata.json +1 -0
  47. package/esm/src/facade/promise.d.ts +17 -0
  48. package/esm/src/facade/promise.js +41 -0
  49. package/esm/src/facade/promise.js.map +1 -0
  50. package/esm/src/interfaces.d.ts +23 -0
  51. package/esm/src/interfaces.js +1 -0
  52. package/esm/src/interfaces.js.map +1 -0
  53. package/esm/src/lifecycle_reflector.d.ts +1 -0
  54. package/esm/src/lifecycle_reflector.js +10 -0
  55. package/esm/src/lifecycle_reflector.js.map +1 -0
  56. package/esm/src/link.d.ts +2 -0
  57. package/esm/src/link.js +183 -0
  58. package/esm/src/link.js.map +1 -0
  59. package/esm/src/metadata/decorators.d.ts +16 -0
  60. package/esm/src/metadata/decorators.js +9 -0
  61. package/esm/src/metadata/decorators.js.map +1 -0
  62. package/esm/src/metadata/decorators.metadata.json +1 -0
  63. package/esm/src/metadata/metadata.d.ts +48 -0
  64. package/esm/src/metadata/metadata.js +48 -0
  65. package/esm/src/metadata/metadata.js.map +1 -0
  66. package/esm/src/recognize.d.ts +4 -0
  67. package/esm/src/recognize.js +164 -0
  68. package/esm/src/recognize.js.map +1 -0
  69. package/esm/src/router.d.ts +95 -0
  70. package/esm/src/router.js +243 -0
  71. package/esm/src/router.js.map +1 -0
  72. package/esm/src/router_providers.d.ts +23 -0
  73. package/esm/src/router_providers.js +26 -0
  74. package/esm/src/router_providers.js.map +1 -0
  75. package/esm/src/router_providers.metadata.json +1 -0
  76. package/esm/src/router_providers_common.d.ts +11 -0
  77. package/esm/src/router_providers_common.js +32 -0
  78. package/esm/src/router_providers_common.js.map +1 -0
  79. package/esm/src/router_providers_common.metadata.json +1 -0
  80. package/esm/src/router_url_serializer.d.ts +21 -0
  81. package/esm/src/router_url_serializer.js +164 -0
  82. package/esm/src/router_url_serializer.js.map +1 -0
  83. package/esm/src/segments.d.ts +51 -0
  84. package/esm/src/segments.js +137 -0
  85. package/esm/src/segments.js.map +1 -0
  86. package/esm/src/segments.metadata.json +1 -0
  87. package/esm/testing/router_testing_providers.d.ts +1 -0
  88. package/esm/testing/router_testing_providers.js +31 -0
  89. package/esm/testing/router_testing_providers.js.map +1 -0
  90. package/esm/testing/router_testing_providers.metadata.json +1 -0
  91. package/esm/testing.d.ts +1 -0
  92. package/esm/testing.js +2 -0
  93. package/esm/testing.js.map +1 -0
  94. package/index.d.ts +15 -0
  95. package/index.js +31 -0
  96. package/index.js.map +1 -0
  97. package/package.json +16 -1
  98. package/src/constants.d.ts +5 -0
  99. package/src/constants.js +7 -0
  100. package/src/constants.js.map +1 -0
  101. package/src/constants.metadata.json +1 -0
  102. package/src/core_private.d.ts +3 -0
  103. package/src/core_private.js +5 -0
  104. package/src/core_private.js.map +1 -0
  105. package/src/core_private.metadata.json +1 -0
  106. package/src/directives/router_directives.d.ts +21 -0
  107. package/src/directives/router_directives.js +25 -0
  108. package/src/directives/router_directives.js.map +1 -0
  109. package/src/directives/router_directives.metadata.json +1 -0
  110. package/src/directives/router_link.d.ts +49 -0
  111. package/src/directives/router_link.js +76 -0
  112. package/src/directives/router_link.js.map +1 -0
  113. package/src/directives/router_link.metadata.json +1 -0
  114. package/src/directives/router_outlet.d.ts +36 -0
  115. package/src/directives/router_outlet.js +53 -0
  116. package/src/directives/router_outlet.js.map +1 -0
  117. package/src/directives/router_outlet.metadata.json +1 -0
  118. package/src/facade/async.d.ts +90 -0
  119. package/src/facade/async.js +160 -0
  120. package/src/facade/async.js.map +1 -0
  121. package/src/facade/base_wrapped_exception.d.ts +14 -0
  122. package/src/facade/base_wrapped_exception.js +50 -0
  123. package/src/facade/base_wrapped_exception.js.map +1 -0
  124. package/src/facade/collection.d.ts +103 -0
  125. package/src/facade/collection.js +368 -0
  126. package/src/facade/collection.js.map +1 -0
  127. package/src/facade/collection.metadata.json +1 -0
  128. package/src/facade/exception_handler.d.ts +29 -0
  129. package/src/facade/exception_handler.js +133 -0
  130. package/src/facade/exception_handler.js.map +1 -0
  131. package/src/facade/exceptions.d.ts +32 -0
  132. package/src/facade/exceptions.js +82 -0
  133. package/src/facade/exceptions.js.map +1 -0
  134. package/src/facade/exceptions.metadata.json +1 -0
  135. package/src/facade/lang.d.ts +158 -0
  136. package/src/facade/lang.js +480 -0
  137. package/src/facade/lang.js.map +1 -0
  138. package/src/facade/lang.metadata.json +1 -0
  139. package/src/facade/promise.d.ts +17 -0
  140. package/src/facade/promise.js +49 -0
  141. package/src/facade/promise.js.map +1 -0
  142. package/src/interfaces.d.ts +23 -0
  143. package/src/interfaces.js +2 -0
  144. package/src/interfaces.js.map +1 -0
  145. package/src/lifecycle_reflector.d.ts +1 -0
  146. package/src/lifecycle_reflector.js +12 -0
  147. package/src/lifecycle_reflector.js.map +1 -0
  148. package/src/link.d.ts +2 -0
  149. package/src/link.js +189 -0
  150. package/src/link.js.map +1 -0
  151. package/src/metadata/decorators.d.ts +16 -0
  152. package/src/metadata/decorators.js +10 -0
  153. package/src/metadata/decorators.js.map +1 -0
  154. package/src/metadata/decorators.metadata.json +1 -0
  155. package/src/metadata/metadata.d.ts +48 -0
  156. package/src/metadata/metadata.js +66 -0
  157. package/src/metadata/metadata.js.map +1 -0
  158. package/src/recognize.d.ts +4 -0
  159. package/src/recognize.js +172 -0
  160. package/src/recognize.js.map +1 -0
  161. package/src/router.d.ts +95 -0
  162. package/src/router.js +276 -0
  163. package/src/router.js.map +1 -0
  164. package/src/router_providers.d.ts +23 -0
  165. package/src/router_providers.js +27 -0
  166. package/src/router_providers.js.map +1 -0
  167. package/src/router_providers.metadata.json +1 -0
  168. package/src/router_providers_common.d.ts +11 -0
  169. package/src/router_providers_common.js +35 -0
  170. package/src/router_providers_common.js.map +1 -0
  171. package/src/router_providers_common.metadata.json +1 -0
  172. package/src/router_url_serializer.d.ts +21 -0
  173. package/src/router_url_serializer.js +184 -0
  174. package/src/router_url_serializer.js.map +1 -0
  175. package/src/segments.d.ts +51 -0
  176. package/src/segments.js +181 -0
  177. package/src/segments.js.map +1 -0
  178. package/src/segments.metadata.json +1 -0
  179. package/testing/router_testing_providers.d.ts +1 -0
  180. package/testing/router_testing_providers.js +35 -0
  181. package/testing/router_testing_providers.js.map +1 -0
  182. package/testing/router_testing_providers.metadata.json +1 -0
  183. package/testing.d.ts +1 -0
  184. package/testing.js +6 -0
  185. package/testing.js.map +1 -0
  186. package/angular1/angular_1_router.js +0 -2922
  187. package/angular1/ng_route_shim.js +0 -349
  188. package/angular2/router.dev.js +0 -3107
  189. package/angular2/router.js +0 -3107
  190. package/angular2/router.min.js +0 -3
@@ -0,0 +1,1812 @@
1
+ /**
2
+ * @license AngularJS v0.0.0-PLACEHOLDER
3
+ * (c) 2010-2016 Google, Inc. https://angular.io/
4
+ * License: MIT
5
+ */
6
+ var __extends = (this && this.__extends) || function (d, b) {
7
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8
+ function __() { this.constructor = d; }
9
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10
+ };
11
+ (function (global, factory) {
12
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('rxjs/Subject'), require('rxjs/observable/PromiseObservable'), require('rxjs/operator/toPromise'), require('rxjs/Observable')) :
13
+ typeof define === 'function' && define.amd ? define(['exports', '@angular/common', '@angular/core', 'rxjs/Subject', 'rxjs/observable/PromiseObservable', 'rxjs/operator/toPromise', 'rxjs/Observable'], factory) :
14
+ (factory((global.ng = global.ng || {}, global.ng.router = global.ng.router || {}), global.ng.common, global.ng.core, global.Rx, global.Rx, global.Rx.Observable.prototype, global.Rx));
15
+ }(this, function (exports, _angular_common, _angular_core, rxjs_Subject, rxjs_observable_PromiseObservable, rxjs_operator_toPromise, rxjs_Observable) {
16
+ 'use strict';
17
+ var globalScope;
18
+ if (typeof window === 'undefined') {
19
+ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
20
+ // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492
21
+ globalScope = self;
22
+ }
23
+ else {
24
+ globalScope = global;
25
+ }
26
+ }
27
+ else {
28
+ globalScope = window;
29
+ }
30
+ // Need to declare a new variable for global here since TypeScript
31
+ // exports the original value of the symbol.
32
+ var global$1 = globalScope;
33
+ var Type = Function;
34
+ // TODO: remove calls to assert in production environment
35
+ // Note: Can't just export this and import in in other files
36
+ // as `assert` is a reserved keyword in Dart
37
+ global$1.assert = function assert(condition) {
38
+ // TODO: to be fixed properly via #2830, noop for now
39
+ };
40
+ function isPresent(obj) {
41
+ return obj !== undefined && obj !== null;
42
+ }
43
+ function isBlank(obj) {
44
+ return obj === undefined || obj === null;
45
+ }
46
+ function isString(obj) {
47
+ return typeof obj === 'string';
48
+ }
49
+ function isStringMap(obj) {
50
+ return typeof obj === 'object' && obj !== null;
51
+ }
52
+ function isArray(obj) {
53
+ return Array.isArray(obj);
54
+ }
55
+ function noop() { }
56
+ function stringify(token) {
57
+ if (typeof token === 'string') {
58
+ return token;
59
+ }
60
+ if (token === undefined || token === null) {
61
+ return '' + token;
62
+ }
63
+ if (token.name) {
64
+ return token.name;
65
+ }
66
+ if (token.overriddenName) {
67
+ return token.overriddenName;
68
+ }
69
+ var res = token.toString();
70
+ var newLineIndex = res.indexOf('\n');
71
+ return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
72
+ }
73
+ var NumberParseError = (function (_super) {
74
+ __extends(NumberParseError, _super);
75
+ function NumberParseError(message) {
76
+ _super.call(this);
77
+ this.message = message;
78
+ }
79
+ NumberParseError.prototype.toString = function () { return this.message; };
80
+ return NumberParseError;
81
+ }(Error));
82
+ var NumberWrapper = (function () {
83
+ function NumberWrapper() {
84
+ }
85
+ NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); };
86
+ NumberWrapper.equal = function (a, b) { return a === b; };
87
+ NumberWrapper.parseIntAutoRadix = function (text) {
88
+ var result = parseInt(text);
89
+ if (isNaN(result)) {
90
+ throw new NumberParseError('Invalid integer literal when parsing ' + text);
91
+ }
92
+ return result;
93
+ };
94
+ NumberWrapper.parseInt = function (text, radix) {
95
+ if (radix == 10) {
96
+ if (/^(\-|\+)?[0-9]+$/.test(text)) {
97
+ return parseInt(text, radix);
98
+ }
99
+ }
100
+ else if (radix == 16) {
101
+ if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
102
+ return parseInt(text, radix);
103
+ }
104
+ }
105
+ else {
106
+ var result = parseInt(text, radix);
107
+ if (!isNaN(result)) {
108
+ return result;
109
+ }
110
+ }
111
+ throw new NumberParseError('Invalid integer literal when parsing ' + text + ' in base ' + radix);
112
+ };
113
+ // TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
114
+ NumberWrapper.parseFloat = function (text) { return parseFloat(text); };
115
+ Object.defineProperty(NumberWrapper, "NaN", {
116
+ get: function () { return NaN; },
117
+ enumerable: true,
118
+ configurable: true
119
+ });
120
+ NumberWrapper.isNaN = function (value) { return isNaN(value); };
121
+ NumberWrapper.isInteger = function (value) { return Number.isInteger(value); };
122
+ return NumberWrapper;
123
+ }());
124
+ var RegExpWrapper = (function () {
125
+ function RegExpWrapper() {
126
+ }
127
+ RegExpWrapper.create = function (regExpStr, flags) {
128
+ if (flags === void 0) { flags = ''; }
129
+ flags = flags.replace(/g/g, '');
130
+ return new global$1.RegExp(regExpStr, flags + 'g');
131
+ };
132
+ RegExpWrapper.firstMatch = function (regExp, input) {
133
+ // Reset multimatch regex state
134
+ regExp.lastIndex = 0;
135
+ return regExp.exec(input);
136
+ };
137
+ RegExpWrapper.test = function (regExp, input) {
138
+ regExp.lastIndex = 0;
139
+ return regExp.test(input);
140
+ };
141
+ RegExpWrapper.matcher = function (regExp, input) {
142
+ // Reset regex state for the case
143
+ // someone did not loop over all matches
144
+ // last time.
145
+ regExp.lastIndex = 0;
146
+ return { re: regExp, input: input };
147
+ };
148
+ RegExpWrapper.replaceAll = function (regExp, input, replace) {
149
+ var c = regExp.exec(input);
150
+ var res = '';
151
+ regExp.lastIndex = 0;
152
+ var prev = 0;
153
+ while (c) {
154
+ res += input.substring(prev, c.index);
155
+ res += replace(c);
156
+ prev = c.index + c[0].length;
157
+ regExp.lastIndex = prev;
158
+ c = regExp.exec(input);
159
+ }
160
+ res += input.substring(prev);
161
+ return res;
162
+ };
163
+ return RegExpWrapper;
164
+ }());
165
+ var PromiseCompleter = (function () {
166
+ function PromiseCompleter() {
167
+ var _this = this;
168
+ this.promise = new Promise(function (res, rej) {
169
+ _this.resolve = res;
170
+ _this.reject = rej;
171
+ });
172
+ }
173
+ return PromiseCompleter;
174
+ }());
175
+ var PromiseWrapper = (function () {
176
+ function PromiseWrapper() {
177
+ }
178
+ PromiseWrapper.resolve = function (obj) { return Promise.resolve(obj); };
179
+ PromiseWrapper.reject = function (obj, _) { return Promise.reject(obj); };
180
+ // Note: We can't rename this method into `catch`, as this is not a valid
181
+ // method name in Dart.
182
+ PromiseWrapper.catchError = function (promise, onError) {
183
+ return promise.catch(onError);
184
+ };
185
+ PromiseWrapper.all = function (promises) {
186
+ if (promises.length == 0)
187
+ return Promise.resolve([]);
188
+ return Promise.all(promises);
189
+ };
190
+ PromiseWrapper.then = function (promise, success, rejection) {
191
+ return promise.then(success, rejection);
192
+ };
193
+ PromiseWrapper.wrap = function (computation) {
194
+ return new Promise(function (res, rej) {
195
+ try {
196
+ res(computation());
197
+ }
198
+ catch (e) {
199
+ rej(e);
200
+ }
201
+ });
202
+ };
203
+ PromiseWrapper.scheduleMicrotask = function (computation) {
204
+ PromiseWrapper.then(PromiseWrapper.resolve(null), computation, function (_) { });
205
+ };
206
+ PromiseWrapper.isPromise = function (obj) { return obj instanceof Promise; };
207
+ PromiseWrapper.completer = function () { return new PromiseCompleter(); };
208
+ return PromiseWrapper;
209
+ }());
210
+ var ObservableWrapper = (function () {
211
+ function ObservableWrapper() {
212
+ }
213
+ // TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
214
+ ObservableWrapper.subscribe = function (emitter, onNext, onError, onComplete) {
215
+ if (onComplete === void 0) { onComplete = function () { }; }
216
+ onError = (typeof onError === 'function') && onError || noop;
217
+ onComplete = (typeof onComplete === 'function') && onComplete || noop;
218
+ return emitter.subscribe({ next: onNext, error: onError, complete: onComplete });
219
+ };
220
+ ObservableWrapper.isObservable = function (obs) { return !!obs.subscribe; };
221
+ /**
222
+ * Returns whether `obs` has any subscribers listening to events.
223
+ */
224
+ ObservableWrapper.hasSubscribers = function (obs) { return obs.observers.length > 0; };
225
+ ObservableWrapper.dispose = function (subscription) { subscription.unsubscribe(); };
226
+ /**
227
+ * @deprecated - use callEmit() instead
228
+ */
229
+ ObservableWrapper.callNext = function (emitter, value) { emitter.next(value); };
230
+ ObservableWrapper.callEmit = function (emitter, value) { emitter.emit(value); };
231
+ ObservableWrapper.callError = function (emitter, error) { emitter.error(error); };
232
+ ObservableWrapper.callComplete = function (emitter) { emitter.complete(); };
233
+ ObservableWrapper.fromPromise = function (promise) {
234
+ return rxjs_observable_PromiseObservable.PromiseObservable.create(promise);
235
+ };
236
+ ObservableWrapper.toPromise = function (obj) { return rxjs_operator_toPromise.toPromise.call(obj); };
237
+ return ObservableWrapper;
238
+ }());
239
+ /**
240
+ * Use by directives and components to emit custom Events.
241
+ *
242
+ * ### Examples
243
+ *
244
+ * In the following example, `Zippy` alternatively emits `open` and `close` events when its
245
+ * title gets clicked:
246
+ *
247
+ * ```
248
+ * @Component({
249
+ * selector: 'zippy',
250
+ * template: `
251
+ * <div class="zippy">
252
+ * <div (click)="toggle()">Toggle</div>
253
+ * <div [hidden]="!visible">
254
+ * <ng-content></ng-content>
255
+ * </div>
256
+ * </div>`})
257
+ * export class Zippy {
258
+ * visible: boolean = true;
259
+ * @Output() open: EventEmitter<any> = new EventEmitter();
260
+ * @Output() close: EventEmitter<any> = new EventEmitter();
261
+ *
262
+ * toggle() {
263
+ * this.visible = !this.visible;
264
+ * if (this.visible) {
265
+ * this.open.emit(null);
266
+ * } else {
267
+ * this.close.emit(null);
268
+ * }
269
+ * }
270
+ * }
271
+ * ```
272
+ *
273
+ * The events payload can be accessed by the parameter `$event` on the components output event
274
+ * handler:
275
+ *
276
+ * ```
277
+ * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
278
+ * ```
279
+ *
280
+ * Uses Rx.Observable but provides an adapter to make it work as specified here:
281
+ * https://github.com/jhusain/observable-spec
282
+ *
283
+ * Once a reference implementation of the spec is available, switch to it.
284
+ * @stable
285
+ */
286
+ var EventEmitter = (function (_super) {
287
+ __extends(EventEmitter, _super);
288
+ /**
289
+ * Creates an instance of [EventEmitter], which depending on [isAsync],
290
+ * delivers events synchronously or asynchronously.
291
+ */
292
+ function EventEmitter(isAsync) {
293
+ if (isAsync === void 0) { isAsync = false; }
294
+ _super.call(this);
295
+ this.__isAsync = isAsync;
296
+ }
297
+ EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
298
+ /**
299
+ * @deprecated - use .emit(value) instead
300
+ */
301
+ EventEmitter.prototype.next = function (value) { _super.prototype.next.call(this, value); };
302
+ EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
303
+ var schedulerFn;
304
+ var errorFn = function (err) { return null; };
305
+ var completeFn = function () { return null; };
306
+ if (generatorOrNext && typeof generatorOrNext === 'object') {
307
+ schedulerFn = this.__isAsync ? function (value /** TODO #9100 */) {
308
+ setTimeout(function () { return generatorOrNext.next(value); });
309
+ } : function (value /** TODO #9100 */) { generatorOrNext.next(value); };
310
+ if (generatorOrNext.error) {
311
+ errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
312
+ function (err) { generatorOrNext.error(err); };
313
+ }
314
+ if (generatorOrNext.complete) {
315
+ completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
316
+ function () { generatorOrNext.complete(); };
317
+ }
318
+ }
319
+ else {
320
+ schedulerFn = this.__isAsync ? function (value /** TODO #9100 */) {
321
+ setTimeout(function () { return generatorOrNext(value); });
322
+ } : function (value /** TODO #9100 */) { generatorOrNext(value); };
323
+ if (error) {
324
+ errorFn =
325
+ this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
326
+ }
327
+ if (complete) {
328
+ completeFn =
329
+ this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
330
+ }
331
+ }
332
+ return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
333
+ };
334
+ return EventEmitter;
335
+ }(rxjs_Subject.Subject));
336
+ /**
337
+ * Name of the default outlet outlet.
338
+ * @type {string}
339
+ */
340
+ var DEFAULT_OUTLET_NAME = '__DEFAULT';
341
+ var Map$1 = global$1.Map;
342
+ var Set = global$1.Set;
343
+ // Safari and Internet Explorer do not support the iterable parameter to the
344
+ // Map constructor. We work around that by manually adding the items.
345
+ var createMapFromPairs = (function () {
346
+ try {
347
+ if (new Map$1([[1, 2]]).size === 1) {
348
+ return function createMapFromPairs(pairs) { return new Map$1(pairs); };
349
+ }
350
+ }
351
+ catch (e) {
352
+ }
353
+ return function createMapAndPopulateFromPairs(pairs) {
354
+ var map = new Map$1();
355
+ for (var i = 0; i < pairs.length; i++) {
356
+ var pair = pairs[i];
357
+ map.set(pair[0], pair[1]);
358
+ }
359
+ return map;
360
+ };
361
+ })();
362
+ var createMapFromMap = (function () {
363
+ try {
364
+ if (new Map$1(new Map$1())) {
365
+ return function createMapFromMap(m) { return new Map$1(m); };
366
+ }
367
+ }
368
+ catch (e) {
369
+ }
370
+ return function createMapAndPopulateFromMap(m) {
371
+ var map = new Map$1();
372
+ m.forEach(function (v, k) { map.set(k, v); });
373
+ return map;
374
+ };
375
+ })();
376
+ var _clearValues = (function () {
377
+ if ((new Map$1()).keys().next) {
378
+ return function _clearValues(m) {
379
+ var keyIterator = m.keys();
380
+ var k;
381
+ while (!((k = keyIterator.next()).done)) {
382
+ m.set(k.value, null);
383
+ }
384
+ };
385
+ }
386
+ else {
387
+ return function _clearValuesWithForeEach(m) {
388
+ m.forEach(function (v, k) { m.set(k, null); });
389
+ };
390
+ }
391
+ })();
392
+ // Safari doesn't implement MapIterator.next(), which is used is Traceur's polyfill of Array.from
393
+ // TODO(mlaval): remove the work around once we have a working polyfill of Array.from
394
+ var _arrayFromMap = (function () {
395
+ try {
396
+ if ((new Map$1()).values().next) {
397
+ return function createArrayFromMap(m, getValues) {
398
+ return getValues ? Array.from(m.values()) : Array.from(m.keys());
399
+ };
400
+ }
401
+ }
402
+ catch (e) {
403
+ }
404
+ return function createArrayFromMapWithForeach(m, getValues) {
405
+ var res = ListWrapper.createFixedSize(m.size), i = 0;
406
+ m.forEach(function (v, k) {
407
+ res[i] = getValues ? v : k;
408
+ i++;
409
+ });
410
+ return res;
411
+ };
412
+ })();
413
+ /**
414
+ * Wraps Javascript Objects
415
+ */
416
+ var StringMapWrapper = (function () {
417
+ function StringMapWrapper() {
418
+ }
419
+ StringMapWrapper.create = function () {
420
+ // Note: We are not using Object.create(null) here due to
421
+ // performance!
422
+ // http://jsperf.com/ng2-object-create-null
423
+ return {};
424
+ };
425
+ StringMapWrapper.contains = function (map, key) {
426
+ return map.hasOwnProperty(key);
427
+ };
428
+ StringMapWrapper.get = function (map, key) {
429
+ return map.hasOwnProperty(key) ? map[key] : undefined;
430
+ };
431
+ StringMapWrapper.set = function (map, key, value) { map[key] = value; };
432
+ StringMapWrapper.keys = function (map) { return Object.keys(map); };
433
+ StringMapWrapper.values = function (map) {
434
+ return Object.keys(map).reduce(function (r, a) {
435
+ r.push(map[a]);
436
+ return r;
437
+ }, []);
438
+ };
439
+ StringMapWrapper.isEmpty = function (map) {
440
+ for (var prop in map) {
441
+ return false;
442
+ }
443
+ return true;
444
+ };
445
+ StringMapWrapper.delete = function (map, key) { delete map[key]; };
446
+ StringMapWrapper.forEach = function (map, callback) {
447
+ for (var prop in map) {
448
+ if (map.hasOwnProperty(prop)) {
449
+ callback(map[prop], prop);
450
+ }
451
+ }
452
+ };
453
+ StringMapWrapper.merge = function (m1, m2) {
454
+ var m = {};
455
+ for (var attr in m1) {
456
+ if (m1.hasOwnProperty(attr)) {
457
+ m[attr] = m1[attr];
458
+ }
459
+ }
460
+ for (var attr in m2) {
461
+ if (m2.hasOwnProperty(attr)) {
462
+ m[attr] = m2[attr];
463
+ }
464
+ }
465
+ return m;
466
+ };
467
+ StringMapWrapper.equals = function (m1, m2) {
468
+ var k1 = Object.keys(m1);
469
+ var k2 = Object.keys(m2);
470
+ if (k1.length != k2.length) {
471
+ return false;
472
+ }
473
+ var key;
474
+ for (var i = 0; i < k1.length; i++) {
475
+ key = k1[i];
476
+ if (m1[key] !== m2[key]) {
477
+ return false;
478
+ }
479
+ }
480
+ return true;
481
+ };
482
+ return StringMapWrapper;
483
+ }());
484
+ var ListWrapper = (function () {
485
+ function ListWrapper() {
486
+ }
487
+ // JS has no way to express a statically fixed size list, but dart does so we
488
+ // keep both methods.
489
+ ListWrapper.createFixedSize = function (size) { return new Array(size); };
490
+ ListWrapper.createGrowableSize = function (size) { return new Array(size); };
491
+ ListWrapper.clone = function (array) { return array.slice(0); };
492
+ ListWrapper.forEachWithIndex = function (array, fn) {
493
+ for (var i = 0; i < array.length; i++) {
494
+ fn(array[i], i);
495
+ }
496
+ };
497
+ ListWrapper.first = function (array) {
498
+ if (!array)
499
+ return null;
500
+ return array[0];
501
+ };
502
+ ListWrapper.last = function (array) {
503
+ if (!array || array.length == 0)
504
+ return null;
505
+ return array[array.length - 1];
506
+ };
507
+ ListWrapper.indexOf = function (array, value, startIndex) {
508
+ if (startIndex === void 0) { startIndex = 0; }
509
+ return array.indexOf(value, startIndex);
510
+ };
511
+ ListWrapper.contains = function (list, el) { return list.indexOf(el) !== -1; };
512
+ ListWrapper.reversed = function (array) {
513
+ var a = ListWrapper.clone(array);
514
+ return a.reverse();
515
+ };
516
+ ListWrapper.concat = function (a, b) { return a.concat(b); };
517
+ ListWrapper.insert = function (list, index, value) { list.splice(index, 0, value); };
518
+ ListWrapper.removeAt = function (list, index) {
519
+ var res = list[index];
520
+ list.splice(index, 1);
521
+ return res;
522
+ };
523
+ ListWrapper.removeAll = function (list, items) {
524
+ for (var i = 0; i < items.length; ++i) {
525
+ var index = list.indexOf(items[i]);
526
+ list.splice(index, 1);
527
+ }
528
+ };
529
+ ListWrapper.remove = function (list, el) {
530
+ var index = list.indexOf(el);
531
+ if (index > -1) {
532
+ list.splice(index, 1);
533
+ return true;
534
+ }
535
+ return false;
536
+ };
537
+ ListWrapper.clear = function (list) { list.length = 0; };
538
+ ListWrapper.isEmpty = function (list) { return list.length == 0; };
539
+ ListWrapper.fill = function (list, value, start, end) {
540
+ if (start === void 0) { start = 0; }
541
+ if (end === void 0) { end = null; }
542
+ list.fill(value, start, end === null ? list.length : end);
543
+ };
544
+ ListWrapper.equals = function (a, b) {
545
+ if (a.length != b.length)
546
+ return false;
547
+ for (var i = 0; i < a.length; ++i) {
548
+ if (a[i] !== b[i])
549
+ return false;
550
+ }
551
+ return true;
552
+ };
553
+ ListWrapper.slice = function (l, from, to) {
554
+ if (from === void 0) { from = 0; }
555
+ if (to === void 0) { to = null; }
556
+ return l.slice(from, to === null ? undefined : to);
557
+ };
558
+ ListWrapper.splice = function (l, from, length) { return l.splice(from, length); };
559
+ ListWrapper.sort = function (l, compareFn) {
560
+ if (isPresent(compareFn)) {
561
+ l.sort(compareFn);
562
+ }
563
+ else {
564
+ l.sort();
565
+ }
566
+ };
567
+ ListWrapper.toString = function (l) { return l.toString(); };
568
+ ListWrapper.toJSON = function (l) { return JSON.stringify(l); };
569
+ ListWrapper.maximum = function (list, predicate) {
570
+ if (list.length == 0) {
571
+ return null;
572
+ }
573
+ var solution = null;
574
+ var maxValue = -Infinity;
575
+ for (var index = 0; index < list.length; index++) {
576
+ var candidate = list[index];
577
+ if (isBlank(candidate)) {
578
+ continue;
579
+ }
580
+ var candidateValue = predicate(candidate);
581
+ if (candidateValue > maxValue) {
582
+ solution = candidate;
583
+ maxValue = candidateValue;
584
+ }
585
+ }
586
+ return solution;
587
+ };
588
+ ListWrapper.flatten = function (list) {
589
+ var target = [];
590
+ _flattenArray(list, target);
591
+ return target;
592
+ };
593
+ ListWrapper.addAll = function (list, source) {
594
+ for (var i = 0; i < source.length; i++) {
595
+ list.push(source[i]);
596
+ }
597
+ };
598
+ return ListWrapper;
599
+ }());
600
+ function _flattenArray(source, target) {
601
+ if (isPresent(source)) {
602
+ for (var i = 0; i < source.length; i++) {
603
+ var item = source[i];
604
+ if (isArray(item)) {
605
+ _flattenArray(item, target);
606
+ }
607
+ else {
608
+ target.push(item);
609
+ }
610
+ }
611
+ }
612
+ return target;
613
+ }
614
+ // Safari and Internet Explorer do not support the iterable parameter to the
615
+ // Set constructor. We work around that by manually adding the items.
616
+ var createSetFromList = (function () {
617
+ var test = new Set([1, 2, 3]);
618
+ if (test.size === 3) {
619
+ return function createSetFromList(lst) { return new Set(lst); };
620
+ }
621
+ else {
622
+ return function createSetAndPopulateFromList(lst) {
623
+ var res = new Set(lst);
624
+ if (res.size !== lst.length) {
625
+ for (var i = 0; i < lst.length; i++) {
626
+ res.add(lst[i]);
627
+ }
628
+ }
629
+ return res;
630
+ };
631
+ }
632
+ })();
633
+ function hasLifecycleHook(name, obj) {
634
+ if (isBlank(obj))
635
+ return false;
636
+ var type = obj.constructor;
637
+ if (!(type instanceof Type))
638
+ return false;
639
+ return name in type.prototype;
640
+ }
641
+ /**
642
+ * @stable
643
+ */
644
+ var BaseException$1 = (function (_super) {
645
+ __extends(BaseException$1, _super);
646
+ function BaseException$1(message) {
647
+ if (message === void 0) { message = '--'; }
648
+ _super.call(this, message);
649
+ this.message = message;
650
+ this.stack = (new Error(message)).stack;
651
+ }
652
+ BaseException$1.prototype.toString = function () { return this.message; };
653
+ return BaseException$1;
654
+ }(Error));
655
+ var Tree = (function () {
656
+ function Tree(root) {
657
+ this._root = root;
658
+ }
659
+ Object.defineProperty(Tree.prototype, "root", {
660
+ get: function () { return this._root.value; },
661
+ enumerable: true,
662
+ configurable: true
663
+ });
664
+ Tree.prototype.parent = function (t) {
665
+ var p = this.pathFromRoot(t);
666
+ return p.length > 1 ? p[p.length - 2] : null;
667
+ };
668
+ Tree.prototype.children = function (t) {
669
+ var n = _findNode(t, this._root);
670
+ return isPresent(n) ? n.children.map(function (t) { return t.value; }) : null;
671
+ };
672
+ Tree.prototype.firstChild = function (t) {
673
+ var n = _findNode(t, this._root);
674
+ return isPresent(n) && n.children.length > 0 ? n.children[0].value : null;
675
+ };
676
+ Tree.prototype.pathFromRoot = function (t) { return _findPath(t, this._root, []).map(function (s) { return s.value; }); };
677
+ Tree.prototype.contains = function (tree) { return _contains(this._root, tree._root); };
678
+ return Tree;
679
+ }());
680
+ var UrlTree = (function (_super) {
681
+ __extends(UrlTree, _super);
682
+ function UrlTree(root) {
683
+ _super.call(this, root);
684
+ }
685
+ return UrlTree;
686
+ }(Tree));
687
+ var RouteTree = (function (_super) {
688
+ __extends(RouteTree, _super);
689
+ function RouteTree(root) {
690
+ _super.call(this, root);
691
+ }
692
+ return RouteTree;
693
+ }(Tree));
694
+ function rootNode(tree) {
695
+ return tree._root;
696
+ }
697
+ function _findNode(expected, c) {
698
+ if (expected === c.value)
699
+ return c;
700
+ for (var _i = 0, _a = c.children; _i < _a.length; _i++) {
701
+ var cc = _a[_i];
702
+ var r = _findNode(expected, cc);
703
+ if (isPresent(r))
704
+ return r;
705
+ }
706
+ return null;
707
+ }
708
+ function _findPath(expected, c, collected) {
709
+ collected.push(c);
710
+ if (expected === c.value)
711
+ return collected;
712
+ for (var _i = 0, _a = c.children; _i < _a.length; _i++) {
713
+ var cc = _a[_i];
714
+ var r = _findPath(expected, cc, ListWrapper.clone(collected));
715
+ if (isPresent(r))
716
+ return r;
717
+ }
718
+ return null;
719
+ }
720
+ function _contains(tree, subtree) {
721
+ if (tree.value !== subtree.value)
722
+ return false;
723
+ var _loop_1 = function(subtreeNode) {
724
+ var s = tree.children.filter(function (child) { return child.value === subtreeNode.value; });
725
+ if (s.length === 0)
726
+ return { value: false };
727
+ if (!_contains(s[0], subtreeNode))
728
+ return { value: false };
729
+ };
730
+ for (var _i = 0, _a = subtree.children; _i < _a.length; _i++) {
731
+ var subtreeNode = _a[_i];
732
+ var state_1 = _loop_1(subtreeNode);
733
+ if (typeof state_1 === "object") return state_1.value;
734
+ }
735
+ return true;
736
+ }
737
+ var TreeNode = (function () {
738
+ function TreeNode(value, children) {
739
+ this.value = value;
740
+ this.children = children;
741
+ }
742
+ return TreeNode;
743
+ }());
744
+ var UrlSegment = (function () {
745
+ function UrlSegment(segment, parameters, outlet) {
746
+ this.segment = segment;
747
+ this.parameters = parameters;
748
+ this.outlet = outlet;
749
+ }
750
+ UrlSegment.prototype.toString = function () {
751
+ var outletPrefix = isBlank(this.outlet) ? '' : this.outlet + ":";
752
+ return "" + outletPrefix + this.segment + _serializeParams(this.parameters);
753
+ };
754
+ return UrlSegment;
755
+ }());
756
+ function _serializeParams(params) {
757
+ var res = '';
758
+ StringMapWrapper.forEach(params, function (v /** TODO #9100 */, k /** TODO #9100 */) { return res += ";" + k + "=" + v; });
759
+ return res;
760
+ }
761
+ var RouteSegment = (function () {
762
+ function RouteSegment(urlSegments, parameters, outlet, type, componentFactory) {
763
+ this.urlSegments = urlSegments;
764
+ this.parameters = parameters;
765
+ this.outlet = outlet;
766
+ this._type = type;
767
+ this._componentFactory = componentFactory;
768
+ }
769
+ RouteSegment.prototype.getParam = function (param) {
770
+ return isPresent(this.parameters) ? this.parameters[param] : null;
771
+ };
772
+ RouteSegment.prototype.getParamAsNumber = function (param) {
773
+ return isPresent(this.parameters) ? NumberWrapper.parseFloat(this.parameters[param]) : null;
774
+ };
775
+ Object.defineProperty(RouteSegment.prototype, "type", {
776
+ get: function () { return this._type; },
777
+ enumerable: true,
778
+ configurable: true
779
+ });
780
+ Object.defineProperty(RouteSegment.prototype, "stringifiedUrlSegments", {
781
+ get: function () { return this.urlSegments.map(function (s) { return s.toString(); }).join('/'); },
782
+ enumerable: true,
783
+ configurable: true
784
+ });
785
+ return RouteSegment;
786
+ }());
787
+ function createEmptyRouteTree(type) {
788
+ var root = new RouteSegment([new UrlSegment('', {}, null)], {}, DEFAULT_OUTLET_NAME, type, null);
789
+ return new RouteTree(new TreeNode(root, []));
790
+ }
791
+ function equalUrlSegments(a, b) {
792
+ if (a.length !== b.length)
793
+ return false;
794
+ for (var i = 0; i < a.length; ++i) {
795
+ if (a[i].segment != b[i].segment)
796
+ return false;
797
+ if (a[i].outlet != b[i].outlet)
798
+ return false;
799
+ if (!StringMapWrapper.equals(a[i].parameters, b[i].parameters))
800
+ return false;
801
+ }
802
+ return true;
803
+ }
804
+ function routeSegmentComponentFactory(a) {
805
+ return a._componentFactory;
806
+ }
807
+ function link(segment, routeTree, urlTree, commands) {
808
+ if (commands.length === 0)
809
+ return urlTree;
810
+ var normalizedCommands = _normalizeCommands(commands);
811
+ if (_navigateToRoot(normalizedCommands)) {
812
+ return new UrlTree(new TreeNode(urlTree.root, []));
813
+ }
814
+ var startingNode = _findStartingNode(normalizedCommands, urlTree, segment, routeTree);
815
+ var updated = normalizedCommands.commands.length > 0 ?
816
+ _updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) :
817
+ [];
818
+ var newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated);
819
+ return new UrlTree(newRoot);
820
+ }
821
+ function _navigateToRoot(normalizedChange) {
822
+ return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 &&
823
+ normalizedChange.commands[0] == '/';
824
+ }
825
+ var _NormalizedNavigationCommands = (function () {
826
+ function _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, commands) {
827
+ this.isAbsolute = isAbsolute;
828
+ this.numberOfDoubleDots = numberOfDoubleDots;
829
+ this.commands = commands;
830
+ }
831
+ return _NormalizedNavigationCommands;
832
+ }());
833
+ function _normalizeCommands(commands) {
834
+ if (isString(commands[0]) && commands.length === 1 && commands[0] == '/') {
835
+ return new _NormalizedNavigationCommands(true, 0, commands);
836
+ }
837
+ var numberOfDoubleDots = 0;
838
+ var isAbsolute = false;
839
+ var res = [];
840
+ for (var i = 0; i < commands.length; ++i) {
841
+ var c = commands[i];
842
+ if (!isString(c)) {
843
+ res.push(c);
844
+ continue;
845
+ }
846
+ var parts = c.split('/');
847
+ for (var j = 0; j < parts.length; ++j) {
848
+ var cc = parts[j];
849
+ // first exp is treated in a special way
850
+ if (i == 0) {
851
+ if (j == 0 && cc == '.') {
852
+ }
853
+ else if (j == 0 && cc == '') {
854
+ isAbsolute = true;
855
+ }
856
+ else if (cc == '..') {
857
+ numberOfDoubleDots++;
858
+ }
859
+ else if (cc != '') {
860
+ res.push(cc);
861
+ }
862
+ }
863
+ else {
864
+ if (cc != '') {
865
+ res.push(cc);
866
+ }
867
+ }
868
+ }
869
+ }
870
+ return new _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, res);
871
+ }
872
+ function _findUrlSegment(segment, routeTree, urlTree, numberOfDoubleDots) {
873
+ var s = segment;
874
+ while (s.urlSegments.length === 0) {
875
+ s = routeTree.parent(s);
876
+ }
877
+ var urlSegment = ListWrapper.last(s.urlSegments);
878
+ var path = urlTree.pathFromRoot(urlSegment);
879
+ if (path.length <= numberOfDoubleDots) {
880
+ throw new BaseException$1('Invalid number of \'../\'');
881
+ }
882
+ return path[path.length - 1 - numberOfDoubleDots];
883
+ }
884
+ function _findStartingNode(normalizedChange, urlTree, segment, routeTree) {
885
+ if (normalizedChange.isAbsolute) {
886
+ return rootNode(urlTree);
887
+ }
888
+ else {
889
+ var urlSegment = _findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots);
890
+ return _findMatchingNode(urlSegment, rootNode(urlTree));
891
+ }
892
+ }
893
+ function _findMatchingNode(segment, node) {
894
+ if (node.value === segment)
895
+ return node;
896
+ for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
897
+ var c = _a[_i];
898
+ var r = _findMatchingNode(segment, c);
899
+ if (isPresent(r))
900
+ return r;
901
+ }
902
+ return null;
903
+ }
904
+ function _constructNewTree(node, original, updated) {
905
+ if (node === original) {
906
+ return new TreeNode(node.value, updated);
907
+ }
908
+ else {
909
+ return new TreeNode(node.value, node.children.map(function (c) { return _constructNewTree(c, original, updated); }));
910
+ }
911
+ }
912
+ function _update(node, commands) {
913
+ var rest = commands.slice(1);
914
+ var next = rest.length === 0 ? null : rest[0];
915
+ var outlet = _outlet(commands);
916
+ var segment = _segment(commands);
917
+ // reach the end of the tree => create new tree nodes.
918
+ if (isBlank(node) && !isStringMap(next)) {
919
+ var urlSegment = new UrlSegment(segment, {}, outlet);
920
+ var children = rest.length === 0 ? [] : [_update(null, rest)];
921
+ return new TreeNode(urlSegment, children);
922
+ }
923
+ else if (isBlank(node) && isStringMap(next)) {
924
+ var urlSegment = new UrlSegment(segment, _stringify(next), outlet);
925
+ return _recurse(urlSegment, node, rest.slice(1));
926
+ }
927
+ else if (outlet != node.value.outlet) {
928
+ return node;
929
+ }
930
+ else if (isStringMap(segment)) {
931
+ var newSegment = new UrlSegment(node.value.segment, _stringify(segment), node.value.outlet);
932
+ return _recurse(newSegment, node, rest);
933
+ }
934
+ else if (isStringMap(next) && _compare(segment, _stringify(next), node.value)) {
935
+ return _recurse(node.value, node, rest.slice(1));
936
+ }
937
+ else if (isStringMap(next)) {
938
+ var urlSegment = new UrlSegment(segment, _stringify(next), outlet);
939
+ return _recurse(urlSegment, node, rest.slice(1));
940
+ }
941
+ else if (_compare(segment, {}, node.value)) {
942
+ return _recurse(node.value, node, rest);
943
+ }
944
+ else {
945
+ var urlSegment = new UrlSegment(segment, {}, outlet);
946
+ return _recurse(urlSegment, node, rest);
947
+ }
948
+ }
949
+ function _stringify(params) {
950
+ var res = {};
951
+ StringMapWrapper.forEach(params, function (v /** TODO #9100 */, k /** TODO #9100 */) { return res[k] = v.toString(); });
952
+ return res;
953
+ }
954
+ function _compare(path, params, segment) {
955
+ return path == segment.segment && StringMapWrapper.equals(params, segment.parameters);
956
+ }
957
+ function _recurse(urlSegment, node, rest) {
958
+ if (rest.length === 0) {
959
+ return new TreeNode(urlSegment, []);
960
+ }
961
+ return new TreeNode(urlSegment, _updateMany(ListWrapper.clone(node.children), rest));
962
+ }
963
+ function _updateMany(nodes, commands) {
964
+ var outlet = _outlet(commands);
965
+ var nodesInRightOutlet = nodes.filter(function (c) { return c.value.outlet == outlet; });
966
+ if (nodesInRightOutlet.length > 0) {
967
+ var nodeRightOutlet = nodesInRightOutlet[0]; // there can be only one
968
+ nodes[nodes.indexOf(nodeRightOutlet)] = _update(nodeRightOutlet, commands);
969
+ }
970
+ else {
971
+ nodes.push(_update(null, commands));
972
+ }
973
+ return nodes;
974
+ }
975
+ function _segment(commands) {
976
+ if (!isString(commands[0]))
977
+ return commands[0];
978
+ var parts = commands[0].toString().split(':');
979
+ return parts.length > 1 ? parts[1] : commands[0];
980
+ }
981
+ function _outlet(commands) {
982
+ if (!isString(commands[0]))
983
+ return null;
984
+ var parts = commands[0].toString().split(':');
985
+ return parts.length > 1 ? parts[0] : null;
986
+ }
987
+ var makeDecorator = _angular_core.__core_private__.makeDecorator;
988
+ var reflector = _angular_core.__core_private__.reflector;
989
+ /**
990
+ * See {@link RouteMetadata} for more information.
991
+ * @ts2dart_const
992
+ */
993
+ var Route = (function () {
994
+ function Route(_a) {
995
+ var _b = _a === void 0 ? {} : _a, path = _b.path, component = _b.component;
996
+ this.path = path;
997
+ this.component = component;
998
+ }
999
+ Route.prototype.toString = function () { return "@Route(" + this.path + ", " + stringify(this.component) + ")"; };
1000
+ return Route;
1001
+ }());
1002
+ /**
1003
+ * Defines routes for a given component.
1004
+ *
1005
+ * It takes an array of {@link RouteMetadata}s.
1006
+ * @ts2dart_const
1007
+ */
1008
+ var RoutesMetadata = (function () {
1009
+ function RoutesMetadata(routes) {
1010
+ this.routes = routes;
1011
+ }
1012
+ RoutesMetadata.prototype.toString = function () { return "@Routes(" + this.routes + ")"; };
1013
+ return RoutesMetadata;
1014
+ }());
1015
+ function recognize(componentResolver, rootComponent, url, existingTree) {
1016
+ var matched = new _MatchResult(rootComponent, [url.root], {}, rootNode(url).children, []);
1017
+ return _constructSegment(componentResolver, matched, rootNode(existingTree))
1018
+ .then(function (roots) { return new RouteTree(roots[0]); });
1019
+ }
1020
+ function _recognize(componentResolver, parentComponent, url, existingSegments) {
1021
+ var metadata = _readMetadata(parentComponent); // should read from the factory instead
1022
+ if (isBlank(metadata)) {
1023
+ throw new _angular_core.BaseException("Component '" + stringify(parentComponent) + "' does not have route configuration");
1024
+ }
1025
+ var match;
1026
+ try {
1027
+ match = _match(metadata, url);
1028
+ }
1029
+ catch (e) {
1030
+ return PromiseWrapper.reject(e, null);
1031
+ }
1032
+ var segmentsWithRightOutlet = existingSegments.filter(function (r) { return r.value.outlet == match.outlet; });
1033
+ var segmentWithRightOutlet = segmentsWithRightOutlet.length > 0 ? segmentsWithRightOutlet[0] : null;
1034
+ var main = _constructSegment(componentResolver, match, segmentWithRightOutlet);
1035
+ var aux = _recognizeMany(componentResolver, parentComponent, match.aux, existingSegments)
1036
+ .then(_checkOutletNameUniqueness);
1037
+ return PromiseWrapper.all([main, aux]).then(ListWrapper.flatten);
1038
+ }
1039
+ function _recognizeMany(componentResolver, parentComponent, urls, existingSegments) {
1040
+ var recognized = urls.map(function (u) { return _recognize(componentResolver, parentComponent, u, existingSegments); });
1041
+ return PromiseWrapper.all(recognized).then(ListWrapper.flatten);
1042
+ }
1043
+ function _constructSegment(componentResolver, matched, existingSegment) {
1044
+ return componentResolver.resolveComponent(matched.component).then(function (factory) {
1045
+ var segment = _createOrReuseSegment(matched, factory, existingSegment);
1046
+ var existingChildren = isPresent(existingSegment) ? existingSegment.children : [];
1047
+ if (matched.leftOverUrl.length > 0) {
1048
+ return _recognizeMany(componentResolver, factory.componentType, matched.leftOverUrl, existingChildren)
1049
+ .then(function (children) { return [new TreeNode(segment, children)]; });
1050
+ }
1051
+ else {
1052
+ return _recognizeLeftOvers(componentResolver, factory.componentType, existingChildren)
1053
+ .then(function (children) { return [new TreeNode(segment, children)]; });
1054
+ }
1055
+ });
1056
+ }
1057
+ function _createOrReuseSegment(matched, factory, segmentNode) {
1058
+ var segment = isPresent(segmentNode) ? segmentNode.value : null;
1059
+ if (isPresent(segment) && equalUrlSegments(segment.urlSegments, matched.consumedUrlSegments) &&
1060
+ StringMapWrapper.equals(segment.parameters, matched.parameters) &&
1061
+ segment.outlet == matched.outlet && factory.componentType == segment.type) {
1062
+ return segment;
1063
+ }
1064
+ else {
1065
+ return new RouteSegment(matched.consumedUrlSegments, matched.parameters, matched.outlet, factory.componentType, factory);
1066
+ }
1067
+ }
1068
+ function _recognizeLeftOvers(componentResolver, parentComponent, existingSegments) {
1069
+ return componentResolver.resolveComponent(parentComponent).then(function (factory) {
1070
+ var metadata = _readMetadata(factory.componentType);
1071
+ if (isBlank(metadata)) {
1072
+ return [];
1073
+ }
1074
+ var r = metadata.routes.filter(function (r) { return r.path == '' || r.path == '/'; });
1075
+ if (r.length === 0) {
1076
+ return PromiseWrapper.resolve([]);
1077
+ }
1078
+ else {
1079
+ var segmentsWithMatchingOutlet = existingSegments.filter(function (r) { return r.value.outlet == DEFAULT_OUTLET_NAME; });
1080
+ var segmentWithMatchingOutlet_1 = segmentsWithMatchingOutlet.length > 0 ? segmentsWithMatchingOutlet[0] : null;
1081
+ var existingChildren = isPresent(segmentWithMatchingOutlet_1) ? segmentWithMatchingOutlet_1.children : [];
1082
+ return _recognizeLeftOvers(componentResolver, r[0].component, existingChildren)
1083
+ .then(function (children) {
1084
+ return componentResolver.resolveComponent(r[0].component).then(function (factory) {
1085
+ var segment = _createOrReuseSegment(new _MatchResult(r[0].component, [], {}, [], []), factory, segmentWithMatchingOutlet_1);
1086
+ return [new TreeNode(segment, children)];
1087
+ });
1088
+ });
1089
+ }
1090
+ });
1091
+ }
1092
+ function _match(metadata, url) {
1093
+ for (var _i = 0, _a = metadata.routes; _i < _a.length; _i++) {
1094
+ var r = _a[_i];
1095
+ var matchingResult = _matchWithParts(r, url);
1096
+ if (isPresent(matchingResult)) {
1097
+ return matchingResult;
1098
+ }
1099
+ }
1100
+ var availableRoutes = metadata.routes.map(function (r) { return ("'" + r.path + "'"); }).join(', ');
1101
+ throw new _angular_core.BaseException("Cannot match any routes. Current segment: '" + url.value + "'. Available routes: [" + availableRoutes + "].");
1102
+ }
1103
+ function _matchWithParts(route, url) {
1104
+ var path = route.path.startsWith('/') ? route.path.substring(1) : route.path;
1105
+ if (path == '*') {
1106
+ return new _MatchResult(route.component, [], null, [], []);
1107
+ }
1108
+ var parts = path.split('/');
1109
+ var positionalParams = {};
1110
+ var consumedUrlSegments = [];
1111
+ var lastParent = null;
1112
+ var lastSegment = null;
1113
+ var current = url;
1114
+ for (var i = 0; i < parts.length; ++i) {
1115
+ if (isBlank(current))
1116
+ return null;
1117
+ var p_1 = parts[i];
1118
+ var isLastSegment = i === parts.length - 1;
1119
+ var isLastParent = i === parts.length - 2;
1120
+ var isPosParam = p_1.startsWith(':');
1121
+ if (!isPosParam && p_1 != current.value.segment)
1122
+ return null;
1123
+ if (isLastSegment) {
1124
+ lastSegment = current;
1125
+ }
1126
+ if (isLastParent) {
1127
+ lastParent = current;
1128
+ }
1129
+ if (isPosParam) {
1130
+ positionalParams[p_1.substring(1)] = current.value.segment;
1131
+ }
1132
+ consumedUrlSegments.push(current.value);
1133
+ current = ListWrapper.first(current.children);
1134
+ }
1135
+ var p = lastSegment.value.parameters;
1136
+ var parameters = StringMapWrapper.merge(p, positionalParams);
1137
+ var axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : [];
1138
+ return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children, axuUrlSubtrees);
1139
+ }
1140
+ function _checkOutletNameUniqueness(nodes) {
1141
+ var names = {};
1142
+ nodes.forEach(function (n) {
1143
+ var segmentWithSameOutletName = names[n.value.outlet];
1144
+ if (isPresent(segmentWithSameOutletName)) {
1145
+ var p = segmentWithSameOutletName.stringifiedUrlSegments;
1146
+ var c = n.value.stringifiedUrlSegments;
1147
+ throw new _angular_core.BaseException("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
1148
+ }
1149
+ names[n.value.outlet] = n.value;
1150
+ });
1151
+ return nodes;
1152
+ }
1153
+ var _MatchResult = (function () {
1154
+ function _MatchResult(component, consumedUrlSegments, parameters, leftOverUrl, aux) {
1155
+ this.component = component;
1156
+ this.consumedUrlSegments = consumedUrlSegments;
1157
+ this.parameters = parameters;
1158
+ this.leftOverUrl = leftOverUrl;
1159
+ this.aux = aux;
1160
+ }
1161
+ Object.defineProperty(_MatchResult.prototype, "outlet", {
1162
+ get: function () {
1163
+ return this.consumedUrlSegments.length === 0 || isBlank(this.consumedUrlSegments[0].outlet) ?
1164
+ DEFAULT_OUTLET_NAME :
1165
+ this.consumedUrlSegments[0].outlet;
1166
+ },
1167
+ enumerable: true,
1168
+ configurable: true
1169
+ });
1170
+ return _MatchResult;
1171
+ }());
1172
+ function _readMetadata(componentType) {
1173
+ var metadata = reflector.annotations(componentType).filter(function (f) { return f instanceof RoutesMetadata; });
1174
+ return ListWrapper.first(metadata);
1175
+ }
1176
+ var RouterOutletMap = (function () {
1177
+ function RouterOutletMap() {
1178
+ /** @internal */
1179
+ this._outlets = {};
1180
+ }
1181
+ RouterOutletMap.prototype.registerOutlet = function (name, outlet) { this._outlets[name] = outlet; };
1182
+ return RouterOutletMap;
1183
+ }());
1184
+ /**
1185
+ * The `Router` is responsible for mapping URLs to components.
1186
+ *
1187
+ * You can see the state of the router by inspecting the read-only fields `router.urlTree`
1188
+ * and `router.routeTree`.
1189
+ */
1190
+ var Router = (function () {
1191
+ /**
1192
+ * @internal
1193
+ */
1194
+ function Router(_rootComponent, _rootComponentType, _componentResolver, _urlSerializer, _routerOutletMap, _location) {
1195
+ this._rootComponent = _rootComponent;
1196
+ this._rootComponentType = _rootComponentType;
1197
+ this._componentResolver = _componentResolver;
1198
+ this._urlSerializer = _urlSerializer;
1199
+ this._routerOutletMap = _routerOutletMap;
1200
+ this._location = _location;
1201
+ this._changes = new EventEmitter();
1202
+ this._routeTree = createEmptyRouteTree(this._rootComponentType);
1203
+ this._setUpLocationChangeListener();
1204
+ this.navigateByUrl(this._location.path());
1205
+ }
1206
+ Object.defineProperty(Router.prototype, "urlTree", {
1207
+ /**
1208
+ * Returns the current url tree.
1209
+ */
1210
+ get: function () { return this._urlTree; },
1211
+ enumerable: true,
1212
+ configurable: true
1213
+ });
1214
+ Object.defineProperty(Router.prototype, "routeTree", {
1215
+ /**
1216
+ * Returns the current route tree.
1217
+ */
1218
+ get: function () { return this._routeTree; },
1219
+ enumerable: true,
1220
+ configurable: true
1221
+ });
1222
+ Object.defineProperty(Router.prototype, "changes", {
1223
+ /**
1224
+ * An observable or url changes from the router.
1225
+ */
1226
+ get: function () { return this._changes; },
1227
+ enumerable: true,
1228
+ configurable: true
1229
+ });
1230
+ /**
1231
+ * Navigate based on the provided url. This navigation is always absolute.
1232
+ *
1233
+ * ### Usage
1234
+ *
1235
+ * ```
1236
+ * router.navigateByUrl("/team/33/user/11");
1237
+ * ```
1238
+ */
1239
+ Router.prototype.navigateByUrl = function (url) {
1240
+ return this._navigate(this._urlSerializer.parse(url));
1241
+ };
1242
+ /**
1243
+ * Navigate based on the provided array of commands and a starting point.
1244
+ * If no segment is provided, the navigation is absolute.
1245
+ *
1246
+ * ### Usage
1247
+ *
1248
+ * ```
1249
+ * router.navigate(['team', 33, 'team', '11], segment);
1250
+ * ```
1251
+ */
1252
+ Router.prototype.navigate = function (commands, segment) {
1253
+ return this._navigate(this.createUrlTree(commands, segment));
1254
+ };
1255
+ /**
1256
+ * @internal
1257
+ */
1258
+ Router.prototype.dispose = function () { ObservableWrapper.dispose(this._locationSubscription); };
1259
+ /**
1260
+ * Applies an array of commands to the current url tree and creates
1261
+ * a new url tree.
1262
+ *
1263
+ * When given a segment, applies the given commands starting from the segment.
1264
+ * When not given a segment, applies the given command starting from the root.
1265
+ *
1266
+ * ### Usage
1267
+ *
1268
+ * ```
1269
+ * // create /team/33/user/11
1270
+ * router.createUrlTree(['/team', 33, 'user', 11]);
1271
+ *
1272
+ * // create /team/33;expand=true/user/11
1273
+ * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
1274
+ *
1275
+ * // you can collapse static fragments like this
1276
+ * router.createUrlTree(['/team/33/user', userId]);
1277
+ *
1278
+ * // assuming the current url is `/team/33/user/11` and the segment points to `user/11`
1279
+ *
1280
+ * // navigate to /team/33/user/11/details
1281
+ * router.createUrlTree(['details'], segment);
1282
+ *
1283
+ * // navigate to /team/33/user/22
1284
+ * router.createUrlTree(['../22'], segment);
1285
+ *
1286
+ * // navigate to /team/44/user/22
1287
+ * router.createUrlTree(['../../team/44/user/22'], segment);
1288
+ * ```
1289
+ */
1290
+ Router.prototype.createUrlTree = function (commands, segment) {
1291
+ var s = isPresent(segment) ? segment : this._routeTree.root;
1292
+ return link(s, this._routeTree, this.urlTree, commands);
1293
+ };
1294
+ /**
1295
+ * Serializes a {@link UrlTree} into a string.
1296
+ */
1297
+ Router.prototype.serializeUrl = function (url) { return this._urlSerializer.serialize(url); };
1298
+ Router.prototype._setUpLocationChangeListener = function () {
1299
+ var _this = this;
1300
+ this._locationSubscription = this._location.subscribe(function (change) { _this._navigate(_this._urlSerializer.parse(change['url']), change['pop']); });
1301
+ };
1302
+ Router.prototype._navigate = function (url, preventPushState) {
1303
+ var _this = this;
1304
+ this._urlTree = url;
1305
+ return recognize(this._componentResolver, this._rootComponentType, url, this._routeTree)
1306
+ .then(function (currTree) {
1307
+ return new _ActivateSegments(currTree, _this._routeTree)
1308
+ .activate(_this._routerOutletMap, _this._rootComponent)
1309
+ .then(function (updated) {
1310
+ if (updated) {
1311
+ _this._routeTree = currTree;
1312
+ if (isBlank(preventPushState) || !preventPushState) {
1313
+ var path = _this._urlSerializer.serialize(_this._urlTree);
1314
+ if (_this._location.isCurrentPathEqualTo(path)) {
1315
+ _this._location.replaceState(path);
1316
+ }
1317
+ else {
1318
+ _this._location.go(path);
1319
+ }
1320
+ }
1321
+ _this._changes.emit(null);
1322
+ }
1323
+ });
1324
+ });
1325
+ };
1326
+ return Router;
1327
+ }());
1328
+ var _ActivateSegments = (function () {
1329
+ function _ActivateSegments(currTree, prevTree) {
1330
+ this.currTree = currTree;
1331
+ this.prevTree = prevTree;
1332
+ this.deactivations = [];
1333
+ this.performMutation = true;
1334
+ }
1335
+ _ActivateSegments.prototype.activate = function (parentOutletMap, rootComponent) {
1336
+ var _this = this;
1337
+ var prevRoot = isPresent(this.prevTree) ? rootNode(this.prevTree) : null;
1338
+ var currRoot = rootNode(this.currTree);
1339
+ return this.canDeactivate(currRoot, prevRoot, parentOutletMap, rootComponent).then(function (res) {
1340
+ _this.performMutation = true;
1341
+ if (res) {
1342
+ _this.activateChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]);
1343
+ }
1344
+ return res;
1345
+ });
1346
+ };
1347
+ _ActivateSegments.prototype.canDeactivate = function (currRoot, prevRoot, outletMap, rootComponent) {
1348
+ var _this = this;
1349
+ this.performMutation = false;
1350
+ this.activateChildSegments(currRoot, prevRoot, outletMap, [rootComponent]);
1351
+ var allPaths = PromiseWrapper.all(this.deactivations.map(function (r) { return _this.checkCanDeactivatePath(r); }));
1352
+ return allPaths.then(function (values) { return values.filter(function (v) { return v; }).length === values.length; });
1353
+ };
1354
+ _ActivateSegments.prototype.checkCanDeactivatePath = function (path) {
1355
+ var _this = this;
1356
+ var curr = PromiseWrapper.resolve(true);
1357
+ var _loop_2 = function(p) {
1358
+ curr = curr.then(function (_) {
1359
+ if (hasLifecycleHook('routerCanDeactivate', p)) {
1360
+ return p.routerCanDeactivate(_this.prevTree, _this.currTree);
1361
+ }
1362
+ else {
1363
+ return _;
1364
+ }
1365
+ });
1366
+ };
1367
+ for (var _i = 0, _a = ListWrapper.reversed(path); _i < _a.length; _i++) {
1368
+ var p = _a[_i];
1369
+ _loop_2(p);
1370
+ }
1371
+ return curr;
1372
+ };
1373
+ _ActivateSegments.prototype.activateChildSegments = function (currNode, prevNode, outletMap, components) {
1374
+ var _this = this;
1375
+ var prevChildren = isPresent(prevNode) ? prevNode.children.reduce(function (m, c) {
1376
+ m[c.value.outlet] = c;
1377
+ return m;
1378
+ }, {}) : {};
1379
+ currNode.children.forEach(function (c) {
1380
+ _this.activateSegments(c, prevChildren[c.value.outlet], outletMap, components);
1381
+ StringMapWrapper.delete(prevChildren, c.value.outlet);
1382
+ });
1383
+ StringMapWrapper.forEach(prevChildren, function (v /** TODO #9100 */, k /** TODO #9100 */) { return _this.deactivateOutlet(outletMap._outlets[k], components); });
1384
+ };
1385
+ _ActivateSegments.prototype.activateSegments = function (currNode, prevNode, parentOutletMap, components) {
1386
+ var curr = currNode.value;
1387
+ var prev = isPresent(prevNode) ? prevNode.value : null;
1388
+ var outlet = this.getOutlet(parentOutletMap, currNode.value);
1389
+ if (curr === prev) {
1390
+ this.activateChildSegments(currNode, prevNode, outlet.outletMap, components.concat([outlet.component]));
1391
+ }
1392
+ else {
1393
+ this.deactivateOutlet(outlet, components);
1394
+ if (this.performMutation) {
1395
+ var outletMap = new RouterOutletMap();
1396
+ var component = this.activateNewSegments(outletMap, curr, prev, outlet);
1397
+ this.activateChildSegments(currNode, prevNode, outletMap, components.concat([component]));
1398
+ }
1399
+ }
1400
+ };
1401
+ _ActivateSegments.prototype.activateNewSegments = function (outletMap, curr, prev, outlet) {
1402
+ var resolved = _angular_core.ReflectiveInjector.resolve([{ provide: RouterOutletMap, useValue: outletMap }, { provide: RouteSegment, useValue: curr }]);
1403
+ var ref = outlet.activate(routeSegmentComponentFactory(curr), resolved, outletMap);
1404
+ if (hasLifecycleHook('routerOnActivate', ref.instance)) {
1405
+ ref.instance.routerOnActivate(curr, prev, this.currTree, this.prevTree);
1406
+ }
1407
+ return ref.instance;
1408
+ };
1409
+ _ActivateSegments.prototype.getOutlet = function (outletMap, segment) {
1410
+ var outlet = outletMap._outlets[segment.outlet];
1411
+ if (isBlank(outlet)) {
1412
+ if (segment.outlet == DEFAULT_OUTLET_NAME) {
1413
+ throw new _angular_core.BaseException("Cannot find default outlet");
1414
+ }
1415
+ else {
1416
+ throw new _angular_core.BaseException("Cannot find the outlet " + segment.outlet);
1417
+ }
1418
+ }
1419
+ return outlet;
1420
+ };
1421
+ _ActivateSegments.prototype.deactivateOutlet = function (outlet, components) {
1422
+ var _this = this;
1423
+ if (isPresent(outlet) && outlet.isActivated) {
1424
+ StringMapWrapper.forEach(outlet.outletMap._outlets, function (v /** TODO #9100 */, k /** TODO #9100 */) { return _this.deactivateOutlet(v, components); });
1425
+ if (this.performMutation) {
1426
+ outlet.deactivate();
1427
+ }
1428
+ else {
1429
+ this.deactivations.push(components.concat([outlet.component]));
1430
+ }
1431
+ }
1432
+ };
1433
+ return _ActivateSegments;
1434
+ }());
1435
+ var RouterLink = (function () {
1436
+ function RouterLink(_routeSegment, _router, _locationStrategy) {
1437
+ var _this = this;
1438
+ this._routeSegment = _routeSegment;
1439
+ this._router = _router;
1440
+ this._locationStrategy = _locationStrategy;
1441
+ this._commands = [];
1442
+ this.isActive = false;
1443
+ // because auxiliary links take existing primary and auxiliary routes into account,
1444
+ // we need to update the link whenever params or other routes change.
1445
+ this._subscription =
1446
+ ObservableWrapper.subscribe(_router.changes, function (_) { _this._updateTargetUrlAndHref(); });
1447
+ }
1448
+ RouterLink.prototype.ngOnDestroy = function () { ObservableWrapper.dispose(this._subscription); };
1449
+ Object.defineProperty(RouterLink.prototype, "routerLink", {
1450
+ set: function (data) {
1451
+ if (isArray(data)) {
1452
+ this._commands = data;
1453
+ }
1454
+ else {
1455
+ this._commands = [data];
1456
+ }
1457
+ this._updateTargetUrlAndHref();
1458
+ },
1459
+ enumerable: true,
1460
+ configurable: true
1461
+ });
1462
+ RouterLink.prototype.onClick = function (button, ctrlKey, metaKey) {
1463
+ if (button != 0 || ctrlKey || metaKey) {
1464
+ return true;
1465
+ }
1466
+ if (isString(this.target) && this.target != '_self') {
1467
+ return true;
1468
+ }
1469
+ this._router.navigate(this._commands, this._routeSegment);
1470
+ return false;
1471
+ };
1472
+ RouterLink.prototype._updateTargetUrlAndHref = function () {
1473
+ var tree = this._router.createUrlTree(this._commands, this._routeSegment);
1474
+ if (isPresent(tree)) {
1475
+ this.href = this._locationStrategy.prepareExternalUrl(this._router.serializeUrl(tree));
1476
+ this.isActive = this._router.urlTree.contains(tree);
1477
+ }
1478
+ else {
1479
+ this.isActive = false;
1480
+ }
1481
+ };
1482
+ return RouterLink;
1483
+ }());
1484
+ /** @nocollapse */
1485
+ RouterLink.decorators = [
1486
+ { type: _angular_core.Directive, args: [{ selector: '[routerLink]' },] },
1487
+ ];
1488
+ /** @nocollapse */
1489
+ RouterLink.ctorParameters = [
1490
+ { type: RouteSegment, },
1491
+ { type: Router, },
1492
+ { type: _angular_common.LocationStrategy, },
1493
+ ];
1494
+ /** @nocollapse */
1495
+ RouterLink.propDecorators = {
1496
+ 'target': [{ type: _angular_core.Input },],
1497
+ 'href': [{ type: _angular_core.HostBinding },],
1498
+ 'isActive': [{ type: _angular_core.HostBinding, args: ['class.router-link-active',] },],
1499
+ 'routerLink': [{ type: _angular_core.Input },],
1500
+ 'onClick': [{ type: _angular_core.HostListener, args: ['click', ['$event.button', '$event.ctrlKey', '$event.metaKey'],] },],
1501
+ };
1502
+ var RouterOutlet = (function () {
1503
+ function RouterOutlet(parentOutletMap, _location, name) {
1504
+ this._location = _location;
1505
+ parentOutletMap.registerOutlet(isBlank(name) ? DEFAULT_OUTLET_NAME : name, this);
1506
+ }
1507
+ RouterOutlet.prototype.deactivate = function () {
1508
+ this._activated.destroy();
1509
+ this._activated = null;
1510
+ };
1511
+ Object.defineProperty(RouterOutlet.prototype, "component", {
1512
+ /**
1513
+ * Returns the loaded component.
1514
+ */
1515
+ get: function () { return isPresent(this._activated) ? this._activated.instance : null; },
1516
+ enumerable: true,
1517
+ configurable: true
1518
+ });
1519
+ Object.defineProperty(RouterOutlet.prototype, "isActivated", {
1520
+ /**
1521
+ * Returns true is the outlet is not empty.
1522
+ */
1523
+ get: function () { return isPresent(this._activated); },
1524
+ enumerable: true,
1525
+ configurable: true
1526
+ });
1527
+ /**
1528
+ * Called by the Router to instantiate a new component.
1529
+ */
1530
+ RouterOutlet.prototype.activate = function (factory, providers, outletMap) {
1531
+ this.outletMap = outletMap;
1532
+ var inj = _angular_core.ReflectiveInjector.fromResolvedProviders(providers, this._location.parentInjector);
1533
+ this._activated = this._location.createComponent(factory, this._location.length, inj, []);
1534
+ return this._activated;
1535
+ };
1536
+ return RouterOutlet;
1537
+ }());
1538
+ /** @nocollapse */
1539
+ RouterOutlet.decorators = [
1540
+ { type: _angular_core.Directive, args: [{ selector: 'router-outlet' },] },
1541
+ ];
1542
+ /** @nocollapse */
1543
+ RouterOutlet.ctorParameters = [
1544
+ { type: RouterOutletMap, },
1545
+ { type: _angular_core.ViewContainerRef, },
1546
+ { type: undefined, decorators: [{ type: _angular_core.Attribute, args: ['name',] },] },
1547
+ ];
1548
+ /**
1549
+ * A list of directives. To use the router directives like {@link RouterOutlet} and
1550
+ * {@link RouterLink}, add this to your `directives` array in the {@link View} decorator of your
1551
+ * component.
1552
+ *
1553
+ * ```
1554
+ * import {Component} from '@angular/core';
1555
+ * import {ROUTER_DIRECTIVES, Routes} from '@angular/router';
1556
+ *
1557
+ * @Component({directives: [ROUTER_DIRECTIVES]})
1558
+ * @Routes([
1559
+ * {...},
1560
+ * ])
1561
+ * class AppCmp {
1562
+ * // ...
1563
+ * }
1564
+ *
1565
+ * bootstrap(AppCmp);
1566
+ * ```
1567
+ */
1568
+ var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink];
1569
+ /**
1570
+ * Defines routes for a given component.
1571
+ *
1572
+ * It takes an array of {@link RouteMetadata}s.
1573
+ */
1574
+ var Routes = makeDecorator(RoutesMetadata);
1575
+ /**
1576
+ * Defines a way to serialize/deserialize a url tree.
1577
+ */
1578
+ var RouterUrlSerializer = (function () {
1579
+ function RouterUrlSerializer() {
1580
+ }
1581
+ return RouterUrlSerializer;
1582
+ }());
1583
+ /**
1584
+ * A default implementation of the serialization.
1585
+ */
1586
+ var DefaultRouterUrlSerializer = (function (_super) {
1587
+ __extends(DefaultRouterUrlSerializer, _super);
1588
+ function DefaultRouterUrlSerializer() {
1589
+ _super.apply(this, arguments);
1590
+ }
1591
+ DefaultRouterUrlSerializer.prototype.parse = function (url) {
1592
+ var root = new _UrlParser().parse(url);
1593
+ return new UrlTree(root);
1594
+ };
1595
+ DefaultRouterUrlSerializer.prototype.serialize = function (tree) { return _serializeUrlTreeNode(rootNode(tree)); };
1596
+ return DefaultRouterUrlSerializer;
1597
+ }(RouterUrlSerializer));
1598
+ function _serializeUrlTreeNode(node) {
1599
+ return "" + node.value + _serializeChildren(node);
1600
+ }
1601
+ function _serializeUrlTreeNodes(nodes) {
1602
+ var main = nodes[0].value.toString();
1603
+ var auxNodes = nodes.slice(1);
1604
+ var aux = auxNodes.length > 0 ? "(" + auxNodes.map(_serializeUrlTreeNode).join("//") + ")" : '';
1605
+ var children = _serializeChildren(nodes[0]);
1606
+ return "" + main + aux + children;
1607
+ }
1608
+ function _serializeChildren(node) {
1609
+ if (node.children.length > 0) {
1610
+ return "/" + _serializeUrlTreeNodes(node.children);
1611
+ }
1612
+ else {
1613
+ return '';
1614
+ }
1615
+ }
1616
+ var SEGMENT_RE = RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
1617
+ function matchUrlSegment(str) {
1618
+ var match = RegExpWrapper.firstMatch(SEGMENT_RE, str);
1619
+ return isPresent(match) ? match[0] : '';
1620
+ }
1621
+ var QUERY_PARAM_VALUE_RE = RegExpWrapper.create('^[^\\(\\)\\?;&#]+');
1622
+ function matchUrlQueryParamValue(str) {
1623
+ var match = RegExpWrapper.firstMatch(QUERY_PARAM_VALUE_RE, str);
1624
+ return isPresent(match) ? match[0] : '';
1625
+ }
1626
+ var _UrlParser = (function () {
1627
+ function _UrlParser() {
1628
+ }
1629
+ _UrlParser.prototype.peekStartsWith = function (str) { return this._remaining.startsWith(str); };
1630
+ _UrlParser.prototype.capture = function (str) {
1631
+ if (!this._remaining.startsWith(str)) {
1632
+ throw new _angular_core.BaseException("Expected \"" + str + "\".");
1633
+ }
1634
+ this._remaining = this._remaining.substring(str.length);
1635
+ };
1636
+ _UrlParser.prototype.parse = function (url) {
1637
+ this._remaining = url;
1638
+ if (url == '' || url == '/') {
1639
+ return new TreeNode(new UrlSegment('', {}, null), []);
1640
+ }
1641
+ else {
1642
+ return this.parseRoot();
1643
+ }
1644
+ };
1645
+ _UrlParser.prototype.parseRoot = function () {
1646
+ var segments = this.parseSegments();
1647
+ return new TreeNode(new UrlSegment('', {}, null), segments);
1648
+ };
1649
+ _UrlParser.prototype.parseSegments = function (outletName) {
1650
+ if (outletName === void 0) { outletName = null; }
1651
+ if (this._remaining.length == 0) {
1652
+ return [];
1653
+ }
1654
+ if (this.peekStartsWith('/')) {
1655
+ this.capture('/');
1656
+ }
1657
+ var path = matchUrlSegment(this._remaining);
1658
+ this.capture(path);
1659
+ if (path.indexOf(':') > -1) {
1660
+ var parts = path.split(':');
1661
+ outletName = parts[0];
1662
+ path = parts[1];
1663
+ }
1664
+ var matrixParams = {};
1665
+ if (this.peekStartsWith(';')) {
1666
+ matrixParams = this.parseMatrixParams();
1667
+ }
1668
+ var aux = [];
1669
+ if (this.peekStartsWith('(')) {
1670
+ aux = this.parseAuxiliaryRoutes();
1671
+ }
1672
+ var children = [];
1673
+ if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
1674
+ this.capture('/');
1675
+ children = this.parseSegments();
1676
+ }
1677
+ var segment = new UrlSegment(path, matrixParams, outletName);
1678
+ var node = new TreeNode(segment, children);
1679
+ return [node].concat(aux);
1680
+ };
1681
+ _UrlParser.prototype.parseQueryParams = function () {
1682
+ var params = {};
1683
+ this.capture('?');
1684
+ this.parseQueryParam(params);
1685
+ while (this._remaining.length > 0 && this.peekStartsWith('&')) {
1686
+ this.capture('&');
1687
+ this.parseQueryParam(params);
1688
+ }
1689
+ return params;
1690
+ };
1691
+ _UrlParser.prototype.parseMatrixParams = function () {
1692
+ var params = {};
1693
+ while (this._remaining.length > 0 && this.peekStartsWith(';')) {
1694
+ this.capture(';');
1695
+ this.parseParam(params);
1696
+ }
1697
+ return params;
1698
+ };
1699
+ _UrlParser.prototype.parseParam = function (params) {
1700
+ var key = matchUrlSegment(this._remaining);
1701
+ if (isBlank(key)) {
1702
+ return;
1703
+ }
1704
+ this.capture(key);
1705
+ var value = 'true';
1706
+ if (this.peekStartsWith('=')) {
1707
+ this.capture('=');
1708
+ var valueMatch = matchUrlSegment(this._remaining);
1709
+ if (isPresent(valueMatch)) {
1710
+ value = valueMatch;
1711
+ this.capture(value);
1712
+ }
1713
+ }
1714
+ params[key] = value;
1715
+ };
1716
+ _UrlParser.prototype.parseQueryParam = function (params) {
1717
+ var key = matchUrlSegment(this._remaining);
1718
+ if (isBlank(key)) {
1719
+ return;
1720
+ }
1721
+ this.capture(key);
1722
+ var value = 'true';
1723
+ if (this.peekStartsWith('=')) {
1724
+ this.capture('=');
1725
+ var valueMatch = matchUrlQueryParamValue(this._remaining);
1726
+ if (isPresent(valueMatch)) {
1727
+ value = valueMatch;
1728
+ this.capture(value);
1729
+ }
1730
+ }
1731
+ params[key] = value;
1732
+ };
1733
+ _UrlParser.prototype.parseAuxiliaryRoutes = function () {
1734
+ var segments = [];
1735
+ this.capture('(');
1736
+ while (!this.peekStartsWith(')') && this._remaining.length > 0) {
1737
+ segments = segments.concat(this.parseSegments('aux'));
1738
+ if (this.peekStartsWith('//')) {
1739
+ this.capture('//');
1740
+ }
1741
+ }
1742
+ this.capture(')');
1743
+ return segments;
1744
+ };
1745
+ return _UrlParser;
1746
+ }());
1747
+ /**
1748
+ * The Platform agnostic ROUTER PROVIDERS
1749
+ */
1750
+ var ROUTER_PROVIDERS_COMMON = [
1751
+ RouterOutletMap,
1752
+ /*@ts2dart_Provider*/ { provide: RouterUrlSerializer, useClass: DefaultRouterUrlSerializer },
1753
+ /*@ts2dart_Provider*/ { provide: _angular_common.LocationStrategy, useClass: _angular_common.PathLocationStrategy }, _angular_common.Location,
1754
+ /*@ts2dart_Provider*/ {
1755
+ provide: Router,
1756
+ useFactory: routerFactory,
1757
+ deps: /*@ts2dart_const*/ [_angular_core.ApplicationRef, _angular_core.ComponentResolver, RouterUrlSerializer, RouterOutletMap, _angular_common.Location],
1758
+ },
1759
+ /*@ts2dart_Provider*/ { provide: RouteSegment, useFactory: routeSegmentFactory, deps: [Router] }
1760
+ ];
1761
+ function routerFactory(app, componentResolver, urlSerializer, routerOutletMap, location) {
1762
+ if (app.componentTypes.length == 0) {
1763
+ throw new _angular_core.BaseException('Bootstrap at least one component before injecting Router.');
1764
+ }
1765
+ // TODO: vsavkin this should not be null
1766
+ var router = new Router(null, app.componentTypes[0], componentResolver, urlSerializer, routerOutletMap, location);
1767
+ app.registerDisposeListener(function () { return router.dispose(); });
1768
+ return router;
1769
+ }
1770
+ function routeSegmentFactory(router) {
1771
+ return router.routeTree.root;
1772
+ }
1773
+ /**
1774
+ * A list of providers. To use the router, you must add this to your application.
1775
+ *
1776
+ * ```
1777
+ * import {Component} from '@angular/core';
1778
+ * import {
1779
+ * ROUTER_DIRECTIVES,
1780
+ * ROUTER_PROVIDERS,
1781
+ * Routes
1782
+ * } from '@angular/router';
1783
+ *
1784
+ * @Component({directives: [ROUTER_DIRECTIVES]})
1785
+ * @Routes([
1786
+ * {...},
1787
+ * ])
1788
+ * class AppCmp {
1789
+ * // ...
1790
+ * }
1791
+ *
1792
+ * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
1793
+ * ```
1794
+ */
1795
+ // TODO: merge with router_providers_common.ts
1796
+ var ROUTER_PROVIDERS = [ROUTER_PROVIDERS_COMMON];
1797
+ exports.ROUTER_DIRECTIVES = ROUTER_DIRECTIVES;
1798
+ exports.RouterLink = RouterLink;
1799
+ exports.RouterOutlet = RouterOutlet;
1800
+ exports.Routes = Routes;
1801
+ exports.Route = Route;
1802
+ exports.Router = Router;
1803
+ exports.RouterOutletMap = RouterOutletMap;
1804
+ exports.ROUTER_PROVIDERS = ROUTER_PROVIDERS;
1805
+ exports.DefaultRouterUrlSerializer = DefaultRouterUrlSerializer;
1806
+ exports.RouterUrlSerializer = RouterUrlSerializer;
1807
+ exports.RouteSegment = RouteSegment;
1808
+ exports.RouteTree = RouteTree;
1809
+ exports.Tree = Tree;
1810
+ exports.UrlSegment = UrlSegment;
1811
+ exports.UrlTree = UrlTree;
1812
+ }));